import type { AdminProfile } from "@/types/api/admin-auth";

/** 绑定代理节点的经营账号（非超管）。 */
export function isAgentOperator(profile: AdminProfile | null | undefined): boolean {
  return profile?.agent != null && profile.is_super_admin !== true;
}

/** 任意接入站点平台账号（site_admin / site_finance / site_cs）。 */
export function isSiteOperator(profile: AdminProfile | null | undefined): boolean {
  if (profile?.is_super_admin === true || profile?.agent != null) {
    return false;
  }
  const kind = profile?.account_kind;
  return kind === "site_admin" || kind === "site_finance" || kind === "site_cs" || profile?.site != null;
}

/** 站点主运营（满配 site_admin）；代理页站点方门控仅对此角色放宽。 */
export function isSiteAdminOperator(profile: AdminProfile | null | undefined): boolean {
  return profile?.account_kind === "site_admin" || (
    profile?.site != null
    && profile?.account_kind == null
    && profile?.is_super_admin !== true
    && profile?.agent == null
  );
}

export function isSiteFinanceOperator(profile: AdminProfile | null | undefined): boolean {
  return profile?.account_kind === "site_finance";
}

export function isSiteCsOperator(profile: AdminProfile | null | undefined): boolean {
  return profile?.account_kind === "site_cs";
}
