import { invoke } from "@tauri-apps/api/core";

/** Spiegelbild von UiState in src-tauri/src/lib.rs */
export interface UiState {
  backendUrl: string;
  loggedIn: boolean;
  nickname: string | null;
  plan: string | null;
  deviceId: string;
  hostname: string;
  registered: boolean;
  protectionApplied: boolean;
  releaseRequestedAt: string | null;
  releaseAvailableAt: string | null;
}

export const getState = () => invoke<UiState>("get_state");
export const pairAndRegister = (code: string) =>
  invoke<UiState>("pair_and_register", { code });
export const activateProtection = () => invoke<UiState>("activate_protection");
export const requestRelease = () => invoke<UiState>("request_release");
export const cancelRelease = () => invoke<UiState>("cancel_release");
export const logout = () => invoke<UiState>("logout");
