import type { MagicDeviceInfo, RegisterDeviceResponse, IphoneDeviceState } from "./useTauri";

export interface MagicSessionState {
  token?: string;
  deviceId: string;
  hardwareId?: string;
  dnsToken: string;
  profileUrl: string;
  label?: string;
}

export function useMagicSession() {
  return useState<MagicSessionState | null>("magic-session", () => null);
}

export function useMagicDevices() {
  return useState<MagicDeviceInfo[]>("magic-devices", () => []);
}

export function useCurrentMagicDevice() {
  const session = useMagicSession();
  const devices = useMagicDevices();

  return computed(() => {
    if (!session.value) return null;
    return devices.value.find((d) => d.deviceId === session.value!.deviceId) ?? null;
  });
}

export function useIphoneDevice() {
  return useState<IphoneDeviceState | null>("iphone-device", () => null);
}
