package com.foxx.androidcast.remoteaccess;

import java.util.Locale;

/** Developer setting: on-demand remote debug transport. */
public enum RemoteAccessMode {
    /** Remote access off; tear down tunnels and notify BE. */
    DISABLED,
    /** WireGuard outbound tunnel (v1). */
    WIREGUARD,
    /** Reverse SSH — alpha essential; selectable when implemented. */
    RSSH;

    public static RemoteAccessMode fromStored(String name) {
        if (name == null || name.isEmpty()) {
            return DISABLED;
        }
        try {
            return valueOf(name.trim().toUpperCase(Locale.ROOT));
        } catch (IllegalArgumentException e) {
            if ("NONE".equalsIgnoreCase(name)) {
                return DISABLED;
            }
            return DISABLED;
        }
    }

    /** BE heartbeat opt_in_mode / capabilities value. */
    public String toApiValue() {
        switch (this) {
            case WIREGUARD:
                return "wireguard";
            case RSSH:
                return "rssh";
            case DISABLED:
            default:
                return "none";
        }
    }

    public boolean isActive() {
        return this == WIREGUARD || this == RSSH;
    }
}
