export type AdminIntegrationSiteRow = {
  id: number;
  code: string;
  name: string;
  has_line_root: boolean;
  currency_code: string;
  status: number;
  wallet_api_url: string | null;
  lottery_h5_base_url: string | null;
  wallet_timeout_seconds: number;
  has_sso_secret: boolean;
  has_wallet_api_key: boolean;
  sso_secret_masked: string | null;
  wallet_api_key_masked: string | null;
  is_default: boolean;
  updated_at: string | null;
};

export type AdminIntegrationSiteDetail = AdminIntegrationSiteRow & {
  wallet_debit_path: string;
  wallet_credit_path: string;
  wallet_balance_path: string;
  iframe_allowed_origins: string[];
  lottery_h5_base_url: string | null;
  notes: string | null;
  is_default: boolean;
  created_at: string | null;
};

export type AdminIntegrationSiteSecrets = {
  sso_jwt_secret: string;
  wallet_api_key: string;
};

export type AdminIntegrationSiteListData = {
  items: AdminIntegrationSiteRow[];
};

export type AdminIntegrationSiteAdminAccountPayload = {
  username: string;
  nickname: string;
  password: string;
  email?: string | null;
};

export type AdminIntegrationSiteCreatePayload = {
  code: string;
  name: string;
  admin_account: AdminIntegrationSiteAdminAccountPayload;
  currency_code?: string;
  status?: number;
  wallet_api_url?: string | null;
  wallet_debit_path?: string;
  wallet_credit_path?: string;
  wallet_balance_path?: string;
  wallet_timeout_seconds?: number;
  iframe_allowed_origins?: string[];
  lottery_h5_base_url?: string | null;
  notes?: string | null;
};

export type AdminIntegrationSiteUpdatePayload = Omit<
  AdminIntegrationSiteCreatePayload,
  "code" | "admin_account"
>;

export type AdminIntegrationSiteWithSecrets = AdminIntegrationSiteDetail & {
  secrets?: AdminIntegrationSiteSecrets;
  secrets_display_once?: boolean;
  admin_user?: {
    id: number;
    username: string;
    nickname: string;
    email: string | null;
  };
};

export type AdminIntegrationSiteConnectivityProbe = {
  success: boolean;
  main_balance_minor: number | null;
  currency_code: string;
  request_url: string;
  http_status: number | null;
  message: string | null;
  response_preview?: Record<string, unknown> | null;
};

export type AdminIntegrationSiteConnectivityResult = {
  site_code: string;
  site_player_id: string;
  player_source: "database" | "synthetic";
  probe: AdminIntegrationSiteConnectivityProbe;
};

export type AdminIntegrationSiteParameterSheet = Record<string, unknown> & {
  site_code: string;
  name: string;
  security_note: string;
};
