import { CamelToSnake } from "./utils.js";
import { BillingPayerResourceType, BillingPaymentChargeType, BillingPaymentMethodStatus, BillingPaymentStatus, BillingStatementStatus, BillingSubscriptionPlanPeriod, BillingSubscriptionStatus } from "./billing.js";
import { CommerceSettingsJSON } from "./commerceSettings.js";
import { OAuthProvider } from "./oauth.js";
import { EmailCodeStrategy, EmailLinkStrategy, OAuthStrategy, PasswordStrategy, PhoneCodeStrategy, Web3Strategy } from "./strategies.js";
import { DisplayConfigJSON } from "./displayConfig.js";
import { OrganizationDomainOwnershipVerificationStatus, OrganizationDomainOwnershipVerificationStrategy, OrganizationDomainVerificationStatus, OrganizationEnrollmentMode } from "./organizationDomain.js";
import { OrganizationSettingsJSON } from "./organizationSettings.js";
import { ProtectConfigJSON } from "./protectConfig.js";
import { PhoneCodeChannel } from "./phoneCodeChannel.js";
import { UserSettingsJSON } from "./userSettings.js";
import { ClerkAPIErrorJSON } from "./errors.js";
import { VerificationStatus } from "./verification.js";
import { EmailAddressIdentifier, UsernameIdentifier } from "./identifiers.js";
import { SignInFirstFactor, SignInSecondFactor } from "./signInCommon.js";
import { SignUpField, SignUpIdentificationField, SignUpStatus } from "./signUpCommon.js";
import { SignInJSON } from "./signIn.js";
import { APIKeysSettingsJSON } from "./apiKeysSettings.js";
import { EnterpriseProtocol, EnterpriseProvider } from "./enterpriseAccount.js";
import { OrganizationInvitationStatus } from "./organizationInvitation.js";
import { SessionVerificationLevel, SessionVerificationStatus } from "./sessionVerification.js";
import { OrganizationSuggestionStatus } from "./organizationSuggestion.js";
import { SessionStatus, SessionTask } from "./session.js";
import { OrganizationCustomRoleKey, OrganizationPermissionKey } from "./organizationMembership.js";
import { ActClaim } from "./jwtv2.js";
import { BoxShadow, Color, EmUnit, FontWeight, HexColor } from "./theme.js";

//#region src/types/json.d.ts
interface ClerkResourceJSON {
  id: string;
  object: string;
}
type PartialWithClerkResource<T extends ClerkResourceJSON> = Omit<Partial<ClerkResourceJSON>, 'id' | 'object'> & Pick<T, 'id' | 'object'>;
interface DisplayThemeJSON {
  general: {
    color: HexColor;
    background_color: Color;
    font_family: string;
    font_color: HexColor;
    label_font_weight: FontWeight;
    padding: EmUnit;
    border_radius: EmUnit;
    box_shadow: BoxShadow;
  };
  buttons: {
    font_color: HexColor;
    font_family: string;
    font_weight: FontWeight;
  };
  accounts: {
    background_color: Color;
  };
}
interface ImageJSON {
  object: 'image';
  id: string;
  name: string;
  public_url: string;
}
interface EnvironmentJSON extends ClerkResourceJSON {
  api_keys_settings: APIKeysSettingsJSON;
  auth_config: AuthConfigJSON;
  client_debug_mode?: boolean;
  commerce_settings: CommerceSettingsJSON;
  display_config: DisplayConfigJSON;
  maintenance_mode: boolean;
  organization_settings: OrganizationSettingsJSON;
  partitioned_cookies?: boolean;
  user_settings: UserSettingsJSON;
  protect_config: ProtectConfigJSON;
}
type LastAuthenticationStrategy = EmailAddressIdentifier | EmailCodeStrategy | EmailLinkStrategy | PhoneCodeStrategy | PasswordStrategy | UsernameIdentifier | OAuthStrategy | Web3Strategy;
type ClientTrustState = 'new' | 'known' | 'pending';
interface ClientJSON extends ClerkResourceJSON {
  object: 'client';
  id: string;
  sessions: SessionJSON[];
  sign_up: SignUpJSON | null;
  sign_in: SignInJSON | null;
  captcha_bypass?: boolean;
  last_active_session_id: string | null;
  last_authentication_strategy: LastAuthenticationStrategy | null;
  cookie_expires_at: number | null;
  created_at: number;
  updated_at: number;
}
interface SignUpJSON extends ClerkResourceJSON {
  object: 'sign_up';
  status: SignUpStatus;
  required_fields: SignUpField[];
  optional_fields: SignUpField[];
  missing_fields: SignUpField[];
  unverified_fields: SignUpIdentificationField[];
  username: string | null;
  first_name: string | null;
  last_name: string | null;
  email_address: string | null;
  phone_number: string | null;
  web3_wallet: string | null;
  external_account_strategy: string | null;
  external_account: any;
  has_password: boolean;
  unsafe_metadata: SignUpUnsafeMetadata;
  created_session_id: string | null;
  created_user_id: string | null;
  abandon_at: number | null;
  legal_accepted_at: number | null;
  locale: string | null;
  verifications: SignUpVerificationsJSON | null;
  protect_check?: ProtectCheckJSON | null;
}
interface ProtectCheckJSON {
  /**
   * Always `'pending'` when surfaced to clients. Completed checks are never emitted on the wire.
   */
  status: 'pending';
  token: string;
  sdk_url: string;
  /**
   * Unix epoch timestamp in **milliseconds** at which the challenge expires.
   */
  expires_at?: number;
  ui_hints?: Record<string, string>;
}
/**
 * @experimental
 */
interface SignUpEnterpriseConnectionJSON extends ClerkResourceJSON {
  id: string;
  name: string;
}
interface SessionJSON extends ClerkResourceJSON {
  object: 'session';
  id: string;
  status: SessionStatus;
  /**
   * The tuple represents the minutes that have passed since the last time a first or second factor were verified.
   *
   * @experimental This API is experimental and may change at any moment.
   */
  factor_verification_age: [firstFactorAge: number, secondFactorAge: number] | null;
  expire_at: number;
  abandon_at: number;
  last_active_at: number;
  last_active_token: TokenJSON;
  last_active_organization_id: string | null;
  actor: ActClaim | null;
  tasks: Array<SessionTask> | null;
  user: UserJSON;
  public_user_data: PublicUserDataJSON;
  created_at: number;
  updated_at: number;
}
interface SessionVerificationJSON extends ClerkResourceJSON {
  object: 'session_verification';
  status: SessionVerificationStatus;
  first_factor_verification: VerificationJSON | null;
  session: SessionJSON;
  second_factor_verification: VerificationJSON | null;
  level: SessionVerificationLevel;
  supported_first_factors: SignInFirstFactorJSON[] | null;
  supported_second_factors: SignInSecondFactorJSON[] | null;
}
interface EmailAddressJSON extends ClerkResourceJSON {
  object: 'email_address';
  email_address: string;
  verification: VerificationJSON | null;
  linked_to: IdentificationLinkJSON[];
  matches_sso_connection: boolean;
}
interface IdentificationLinkJSON extends ClerkResourceJSON {
  id: string;
  type: string;
}
interface PhoneNumberJSON extends ClerkResourceJSON {
  object: 'phone_number';
  id: string;
  phone_number: string;
  reserved_for_second_factor: boolean;
  default_second_factor: boolean;
  linked_to: IdentificationLinkJSON[];
  verification: VerificationJSON | null;
  backup_codes?: string[];
}
interface PasskeyJSON extends ClerkResourceJSON {
  object: 'passkey';
  id: string;
  name: string | null;
  verification: VerificationJSON | null;
  last_used_at: number | null;
  updated_at: number;
  created_at: number;
}
interface Web3WalletJSON extends ClerkResourceJSON {
  object: 'web3_wallet';
  id: string;
  web3_wallet: string;
  verification: VerificationJSON | null;
}
interface ExternalAccountJSON extends ClerkResourceJSON {
  object: 'external_account';
  provider: OAuthProvider;
  identification_id: string;
  provider_user_id: string;
  approved_scopes: string;
  email_address: string;
  first_name: string;
  last_name: string;
  image_url: string;
  username: string;
  phone_number: string;
  public_metadata: Record<string, unknown>;
  label: string;
  verification?: VerificationJSON;
}
interface EnterpriseAccountJSON extends ClerkResourceJSON {
  object: 'enterprise_account';
  active: boolean;
  email_address: string;
  enterprise_connection: EnterpriseAccountConnectionJSON | null;
  first_name: string | null;
  last_name: string | null;
  protocol: EnterpriseProtocol;
  provider: EnterpriseProvider;
  provider_user_id: string | null;
  public_metadata: Record<string, unknown>;
  verification: VerificationJSON | null;
  last_authenticated_at: number | null;
  enterprise_connection_id: string | null;
}
interface EnterpriseAccountConnectionJSON extends ClerkResourceJSON {
  active: boolean;
  allow_idp_initiated: boolean;
  allow_subdomains: boolean;
  disable_additional_identifications: boolean;
  domain: string;
  logo_public_url: string | null;
  name: string;
  protocol: EnterpriseProtocol;
  provider: EnterpriseProvider;
  sync_user_attributes: boolean;
  allow_organization_account_linking: boolean;
  created_at: number;
  updated_at: number;
  enterprise_connection_id: string | null;
}
interface UserJSON extends ClerkResourceJSON {
  object: 'user';
  id: string;
  external_id: string | null;
  primary_email_address_id: string | null;
  primary_phone_number_id: string | null;
  primary_web3_wallet_id: string | null;
  image_url: string;
  has_image: boolean;
  username: string | null;
  email_addresses: EmailAddressJSON[];
  phone_numbers: PhoneNumberJSON[];
  web3_wallets: Web3WalletJSON[];
  external_accounts: ExternalAccountJSON[];
  enterprise_accounts: EnterpriseAccountJSON[];
  passkeys: PasskeyJSON[];
  organization_memberships: OrganizationMembershipJSON[];
  password_enabled: boolean;
  profile_image_id: string;
  first_name: string | null;
  last_name: string | null;
  totp_enabled: boolean;
  backup_code_enabled: boolean;
  two_factor_enabled: boolean;
  public_metadata: UserPublicMetadata;
  unsafe_metadata: UserUnsafeMetadata;
  last_sign_in_at: number | null;
  create_organization_enabled: boolean;
  create_organizations_limit: number | null;
  delete_self_enabled: boolean;
  legal_accepted_at: number | null;
  updated_at: number;
  created_at: number;
}
interface PublicUserDataJSON {
  first_name: string | null;
  last_name: string | null;
  image_url: string;
  has_image: boolean;
  identifier: string;
  user_id?: string;
  username?: string;
  banned?: boolean;
}
interface SessionWithActivitiesJSON extends Omit<SessionJSON, 'user'> {
  user: null;
  latest_activity: SessionActivityJSON;
}
interface AuthConfigJSON extends ClerkResourceJSON {
  single_session_mode: boolean;
  claimed_at: number | null;
  reverification: boolean;
  preferred_channels?: Record<string, PhoneCodeChannel>;
  session_minter?: boolean;
}
interface VerificationJSON extends ClerkResourceJSON {
  status: VerificationStatus;
  verified_at_client: string;
  strategy: string;
  nonce?: string;
  message?: string;
  external_verification_redirect_url?: string;
  attempts: number;
  expire_at: number;
  channel?: PhoneCodeChannel;
  error: ClerkAPIErrorJSON;
}
interface SignUpVerificationsJSON {
  email_address: SignUpVerificationJSON;
  phone_number: SignUpVerificationJSON;
  web3_wallet: SignUpVerificationJSON;
  external_account: VerificationJSON;
}
interface SignUpVerificationJSON extends VerificationJSON {
  next_action: string;
  supported_strategies: string[];
  channel?: PhoneCodeChannel;
}
interface TokenJSON extends ClerkResourceJSON {
  object: 'token';
  jwt: string;
}
interface SessionActivityJSON extends ClerkResourceJSON {
  object: 'session_activity';
  browser_name?: string;
  browser_version?: string;
  device_type?: string;
  ip_address?: string;
  city?: string;
  country?: string;
  is_mobile?: boolean;
}
interface OrganizationJSON extends ClerkResourceJSON {
  object: 'organization';
  id: string;
  image_url: string;
  has_image: boolean;
  name: string;
  slug: string;
  public_metadata: OrganizationPublicMetadata;
  created_at: number;
  updated_at: number;
  members_count: number;
  pending_invitations_count: number;
  admin_delete_enabled: boolean;
  max_allowed_memberships: number;
  self_serve_sso_enabled?: boolean;
  exclusive_membership?: boolean;
}
interface OrganizationMembershipJSON extends ClerkResourceJSON {
  object: 'organization_membership';
  id: string;
  organization: OrganizationJSON;
  permissions: OrganizationPermissionKey[];
  public_metadata: OrganizationMembershipPublicMetadata;
  public_user_data?: PublicUserDataJSON;
  role: OrganizationCustomRoleKey;
  role_name: string;
  created_at: number;
  updated_at: number;
}
interface OrganizationInvitationJSON extends ClerkResourceJSON {
  object: 'organization_invitation';
  id: string;
  email_address: string;
  organization_id: string;
  public_metadata: OrganizationInvitationPublicMetadata;
  status: OrganizationInvitationStatus;
  role: OrganizationCustomRoleKey;
  role_name: string;
  created_at: number;
  updated_at: number;
}
interface OrganizationDomainVerificationJSON {
  status: OrganizationDomainVerificationStatus;
  strategy: 'email_code';
  attempts: number;
  expires_at: number;
  verified_at?: number | null;
}
interface OrganizationDomainOwnershipVerificationJSON {
  status: OrganizationDomainOwnershipVerificationStatus;
  strategy: OrganizationDomainOwnershipVerificationStrategy;
  attempts: number | null;
  expire_at: number | null;
  verified_at: number | null;
  /**
   * Present only on ownership verification responses immediately after
   * `prepare_ownership_verification`. The fully qualified DNS name the org admin
   * must publish the TXT record under.
   */
  txt_record_name?: string | null;
  /**
   * Present only on ownership verification responses immediately after
   * `prepare_ownership_verification`. The exact value the org admin must publish
   * in the TXT record.
   */
  txt_record_value?: string | null;
}
interface OrganizationDomainJSON extends ClerkResourceJSON {
  object: 'organization_domain';
  id: string;
  name: string;
  organization_id: string;
  enrollment_mode: OrganizationEnrollmentMode;
  /**
   * @deprecated Use `affiliation_verification` instead.
   */
  verification: OrganizationDomainVerificationJSON | null;
  affiliation_verification: OrganizationDomainVerificationJSON | null;
  ownership_verification: OrganizationDomainOwnershipVerificationJSON | null;
  affiliation_email_address: string | null;
  created_at: number;
  updated_at: number;
  total_pending_invitations: number;
  total_pending_suggestions: number;
}
/**
 * A per-domain failure entry returned by the bulk ownership verification
 * endpoints, carrying the `organization_domain_id` and the API error code that
 * caused it to be skipped.
 */
interface OrganizationDomainBulkOwnershipVerificationErrorJSON {
  id: string;
  code: string;
}
/**
 * Partial-success payload returned by the bulk `prepare`/`attempt`
 * ownership verification endpoints. Each requested domain id lands in either
 * `data` (with its current ownership state) or `errors`.
 */
interface OrganizationDomainsBulkOwnershipVerificationJSON {
  data: OrganizationDomainJSON[];
  errors: OrganizationDomainBulkOwnershipVerificationErrorJSON[];
}
interface RoleJSON extends ClerkResourceJSON {
  object: 'role';
  id: string;
  key: string;
  name: string;
  description: string;
  permissions: PermissionJSON[];
  created_at: number;
  updated_at: number;
}
interface PermissionJSON extends ClerkResourceJSON {
  object: 'permission';
  id: string;
  key: string;
  name: string;
  description: string;
  type: 'system' | 'user';
  created_at: number;
  updated_at: number;
}
interface PublicOrganizationDataJSON {
  id: string;
  name: string;
  slug: string | null;
  has_image: boolean;
  image_url: string;
}
interface OrganizationSuggestionJSON extends ClerkResourceJSON {
  object: 'organization_suggestion';
  id: string;
  public_organization_data: PublicOrganizationDataJSON;
  status: OrganizationSuggestionStatus;
  created_at: number;
  updated_at: number;
}
interface OrganizationMembershipRequestJSON extends ClerkResourceJSON {
  object: 'organization_membership_request';
  id: string;
  organization_id: string;
  status: OrganizationInvitationStatus;
  public_user_data: PublicUserDataJSON;
  created_at: number;
  updated_at: number;
}
interface UserOrganizationInvitationJSON extends ClerkResourceJSON {
  object: 'organization_invitation';
  id: string;
  email_address: string;
  public_organization_data: PublicOrganizationDataJSON;
  public_metadata: OrganizationInvitationPublicMetadata;
  status: OrganizationInvitationStatus;
  role: OrganizationCustomRoleKey;
  created_at: number;
  updated_at: number;
}
interface UserDataJSON {
  first_name?: string;
  last_name?: string;
  image_url: string;
  has_image: boolean;
}
interface TOTPJSON extends ClerkResourceJSON {
  object: 'totp';
  id: string;
  secret?: string;
  uri?: string;
  verified: boolean;
  backup_codes?: string[];
  created_at: number;
  updated_at: number;
}
interface BackupCodeJSON extends ClerkResourceJSON {
  object: 'backup_code';
  id: string;
  codes: string[];
  created_at: number;
  updated_at: number;
}
interface DeletedObjectJSON {
  object: string;
  id?: string;
  slug?: string;
  deleted: boolean;
}
type SignInFirstFactorJSON = CamelToSnake<SignInFirstFactor>;
type SignInSecondFactorJSON = CamelToSnake<SignInSecondFactor>;
/**
 * Types for WebAuthN passkeys
 */
type Base64UrlString = string;
interface PublicKeyCredentialUserEntityJSON {
  name: string;
  displayName: string;
  id: Base64UrlString;
}
interface PublicKeyCredentialDescriptorJSON {
  type: 'public-key';
  id: Base64UrlString;
  transports?: ('ble' | 'hybrid' | 'internal' | 'nfc' | 'usb')[];
}
interface AuthenticatorSelectionCriteriaJSON {
  requireResidentKey: boolean;
  residentKey: 'discouraged' | 'preferred' | 'required';
  userVerification: 'discouraged' | 'preferred' | 'required';
}
interface PublicKeyCredentialCreationOptionsJSON {
  rp: PublicKeyCredentialRpEntity;
  user: PublicKeyCredentialUserEntityJSON;
  challenge: Base64UrlString;
  pubKeyCredParams: PublicKeyCredentialParameters[];
  timeout: number;
  excludeCredentials: PublicKeyCredentialDescriptorJSON[];
  authenticatorSelection: AuthenticatorSelectionCriteriaJSON;
  attestation: 'direct' | 'enterprise' | 'indirect' | 'none';
}
interface PublicKeyCredentialRequestOptionsJSON {
  allowCredentials: PublicKeyCredentialDescriptorJSON[];
  challenge: Base64UrlString;
  rpId: string;
  timeout: number;
  userVerification: 'discouraged' | 'preferred' | 'required';
}
interface WaitlistJSON extends ClerkResourceJSON {
  object: 'waitlist';
  id: string;
  created_at: number;
  updated_at: number;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface FeatureJSON extends ClerkResourceJSON {
  object: 'feature';
  id: string;
  name: string;
  description: string | null;
  slug: string;
  avatar_url: string | null;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingSubscriptionItemSeatsJSON {
  /**
   * The number of seats available. `null` means unlimited.
   */
  quantity: number | null;
  /**
   * The per-unit cost breakdown by pricing tier.
   */
  tiers?: BillingPerUnitTotalTierJSON[];
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 *
 * Represents a single pricing tier for a unit type on a plan.
 */
interface BillingPlanUnitPriceTierJSON extends ClerkResourceJSON {
  id: string;
  object: 'commerce_unit_price';
  starts_at_block: number;
  /**
   * `null` means unlimited.
   */
  ends_after_block: number | null;
  fee_per_block: BillingMoneyAmountJSON;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 *
 * Represents unit pricing for a specific unit type (e.g., seats) on a plan.
 */
interface BillingPlanUnitPriceJSON {
  name: string;
  block_size: number;
  tiers: BillingPlanUnitPriceTierJSON[];
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 *
 * Represents the cost breakdown for a single tier in checkout totals.
 */
interface BillingPerUnitTotalTierJSON {
  /**
   * `null` means unlimited.
   */
  quantity: number | null;
  fee_per_block: BillingMoneyAmountJSON;
  total: BillingMoneyAmountJSON;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 *
 * Represents the per-unit cost breakdown in checkout totals.
 */
interface BillingPerUnitTotalJSON {
  name: string;
  block_size: number;
  tiers: BillingPerUnitTotalTierJSON[];
}
interface BillingPriceJSON extends ClerkResourceJSON {
  object: 'commerce_price';
  fee: BillingMoneyAmountJSON | null;
  annual_monthly_fee: BillingMoneyAmountJSON | null;
  is_default: boolean;
  unit_prices?: BillingPlanUnitPriceJSON[];
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingPlanJSON extends ClerkResourceJSON {
  object: 'commerce_plan';
  id: string;
  name: string;
  fee: BillingMoneyAmountJSON | null;
  annual_fee: BillingMoneyAmountJSON | null;
  annual_monthly_fee: BillingMoneyAmountJSON | null;
  description: string | null;
  is_default: boolean;
  is_recurring: boolean;
  has_base_fee: boolean;
  for_payer_type: BillingPayerResourceType;
  publicly_visible: boolean;
  slug: string;
  avatar_url: string | null;
  features?: FeatureJSON[];
  free_trial_days?: number | null;
  free_trial_enabled?: boolean;
  /**
   * Per-unit pricing tiers for this plan (e.g., seats).
   */
  unit_prices?: BillingPlanUnitPriceJSON[];
  available_prices?: BillingPriceJSON[];
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingPaymentMethodJSON extends ClerkResourceJSON {
  object: 'commerce_payment_method';
  id: string;
  last4: string | null;
  payment_type?: 'card';
  card_type: string | null;
  is_default?: boolean;
  is_removable?: boolean;
  status: BillingPaymentMethodStatus;
  wallet_type?: string | null;
  expiry_year?: number | null;
  expiry_month?: number | null;
  created_at?: number | null;
  updated_at?: number | null;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingInitializedPaymentMethodJSON extends ClerkResourceJSON {
  object: 'commerce_payment_method_initialize';
  external_client_secret: string;
  external_gateway_id: string;
  payment_method_order: string[];
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingStatementJSON extends ClerkResourceJSON {
  object: 'commerce_statement';
  id: string;
  status: BillingStatementStatus;
  timestamp: number;
  groups: BillingStatementGroupJSON[];
  totals: BillingStatementTotalsJSON;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingStatementGroupJSON extends ClerkResourceJSON {
  object: 'commerce_statement_group';
  timestamp: number;
  items: BillingPaymentJSON[];
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 *
 * Per-payment cost breakdown including optional base fee and per-unit (e.g., seats) subtotals.
 */
interface BillingPaymentTotalsJSON {
  subtotal: BillingMoneyAmountJSON;
  grand_total: BillingMoneyAmountJSON;
  tax_total: BillingMoneyAmountJSON;
  base_fee?: BillingMoneyAmountJSON | null;
  per_unit_totals?: BillingPerUnitTotalJSON[];
  /**
   * Discounts applied to this payment such as mid-cycle prorated seat discounts. `null` when no discounts apply.
   */
  discounts?: BillingDiscountsJSON | null;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingPaymentJSON extends ClerkResourceJSON {
  object: 'commerce_payment';
  id: string;
  amount: BillingMoneyAmountJSON;
  paid_at: number | null;
  failed_at: number | null;
  updated_at: number;
  payment_method?: BillingPaymentMethodJSON | null;
  subscription_item: BillingSubscriptionItemJSON;
  charge_type: BillingPaymentChargeType;
  status: BillingPaymentStatus;
  /**
   * Per-payment breakdown with optional base fee and per-unit (e.g., seats)
   * subtotals. Absent on older responses.
   */
  totals?: BillingPaymentTotalsJSON | null;
}
interface BillingTotalsJSON {
  subtotal: BillingMoneyAmountJSON;
  base_fee: BillingMoneyAmountJSON | null;
  tax_total: BillingMoneyAmountJSON;
  grand_total: BillingMoneyAmountJSON;
  total_due_after_free_trial?: BillingMoneyAmountJSON | null;
  credit?: BillingMoneyAmountJSON | null;
  credits: BillingCreditsJSON | null;
  discounts: BillingDiscountsJSON | null;
  past_due?: BillingMoneyAmountJSON | null;
  total_due_now?: BillingMoneyAmountJSON;
  per_unit_totals?: BillingPerUnitTotalJSON[];
  totals_due_per_period?: BillingPeriodTotalsJSON;
  total_due_per_period?: BillingMoneyAmountJSON;
}
interface BillingSubscriptionItemNextPaymentJSON {
  amount: BillingMoneyAmountJSON;
  date: number;
  per_unit_totals?: BillingPerUnitTotalJSON[];
  totals?: BillingTotalsJSON;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingSubscriptionItemJSON extends ClerkResourceJSON {
  object: 'commerce_subscription_item';
  id: string;
  amount?: BillingMoneyAmountJSON;
  credit?: {
    amount: BillingMoneyAmountJSON;
  };
  /**
   * Seat entitlement details for this subscription item. Only set for organization subscription items with
   * seat-based billing.
   */
  seats?: BillingSubscriptionItemSeatsJSON;
  credits?: BillingCreditsJSON;
  plan: BillingPlanJSON;
  plan_period: BillingSubscriptionPlanPeriod;
  price_id: string;
  status: BillingSubscriptionStatus;
  created_at: number;
  period_start: number;
  /**
   * Period end is `null` for subscription items that are on the free plan.
   */
  period_end: number | null;
  canceled_at: number | null;
  past_due_at: number | null;
  is_free_trial: boolean;
  next_payment?: BillingSubscriptionItemNextPaymentJSON | null;
}
interface BillingSubscriptionNextPaymentJSON {
  amount: BillingMoneyAmountJSON;
  date: number;
  per_unit_totals?: BillingPerUnitTotalJSON[];
  totals?: BillingTotalsJSON;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingSubscriptionJSON extends ClerkResourceJSON {
  object: 'commerce_subscription';
  id: string;
  /**
   * Describes the details for the next payment cycle. It is `undefined` for subscription items that are cancelled or on the free plan, and `null` when there is no upcoming payment.
   */
  next_payment?: BillingSubscriptionNextPaymentJSON | null;
  /**
   * Due to the free plan subscription item, the top level subscription can either be `active` or `past_due`.
   */
  status: Extract<BillingSubscriptionStatus, 'active' | 'past_due'>;
  created_at: number;
  active_at: number;
  updated_at: number | null;
  past_due_at: number | null;
  subscription_items: BillingSubscriptionItemJSON[] | null;
  eligible_for_free_trial: boolean;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingCreditBalanceJSON {
  object: 'commerce_credit_balance';
  balance: BillingMoneyAmountJSON | null;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingCreditLedgerJSON {
  object: 'commerce_credit_ledger';
  id: string;
  amount: BillingMoneyAmountJSON;
  source_type: string;
  source_id: string;
  created_at: number;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingMoneyAmountJSON {
  amount: number;
  amount_formatted: string;
  currency: string;
  currency_symbol: string;
}
/**
 * Contains proration credit details including billing cycle information.
 */
interface BillingProrationCreditDetailJSON {
  amount: BillingMoneyAmountJSON;
  cycle_days_remaining: number;
  cycle_days_total: number;
  cycle_remaining_percent: number;
}
/**
 * Contains payer credit details including the available balance and the amount applied to this checkout.
 */
interface BillingPayerCreditJSON {
  remaining_balance: BillingMoneyAmountJSON;
  applied_amount: BillingMoneyAmountJSON;
}
/**
 * Unified credits breakdown for checkout totals. Can be used instead of `credit` field.
 */
interface BillingCreditsJSON {
  proration: BillingProrationCreditDetailJSON | null;
  payer: BillingPayerCreditJSON | null;
  total: BillingMoneyAmountJSON;
}
/**
 * Details about a prorated discount applied when adding a seat mid-cycle. The discount covers the part of the
 * billing period that has already passed, so the payer is only charged for the time remaining in the cycle.
 */
interface BillingProrationDiscountJSON {
  amount: BillingMoneyAmountJSON;
  cycle_days_passed: number;
  cycle_days_total: number;
  cycle_passed_percent: number;
}
/**
 * Discounts applied to the checkout, such as prorated discounts for mid-cycle seat additions.
 *
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingDiscountsJSON {
  /**
   * The prorated discount for the part of the billing period that has already passed when adding a seat mid-cycle.
   * Unlike the proration credit (which refunds the unused remainder of a plan you already paid for), this discount
   * means you are not charged for the portion of the new seat's cycle that has already elapsed.
   */
  proration: BillingProrationDiscountJSON | null;
  /**
   * The total of all discounts applied to the checkout.
   */
  total: BillingMoneyAmountJSON;
}
/**
 * Per-period renewal totals, describing what the subscription renewal charge will look like after the current checkout.
 * Unlike the top-level checkout totals (which only reflect the items actively being purchased),
 * this object contains the full renewal breakdown including all seats and the base plan fee.
 *
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingPeriodTotalsJSON {
  subtotal: BillingMoneyAmountJSON;
  base_fee: BillingMoneyAmountJSON;
  tax_total: BillingMoneyAmountJSON;
  grand_total: BillingMoneyAmountJSON;
  /**
   * Per-unit cost breakdown for the renewal period, covering all units purchased to date
   * (not just the ones being added in this checkout).
   */
  per_unit_totals?: BillingPerUnitTotalJSON[];
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingCheckoutTotalsJSON {
  grand_total: BillingMoneyAmountJSON;
  /**
   * The price of items actively being purchased in this checkout, before taxes and discounts.
   * When only adding seats mid-cycle, this reflects just the new seats and excludes the base plan fee and
   * seats that were already paid for.
   */
  subtotal: BillingMoneyAmountJSON;
  /**
   * The base plan fee portion of the totals, before per-unit charges and adjustments.
   */
  base_fee: BillingMoneyAmountJSON;
  tax_total: BillingMoneyAmountJSON;
  /**
   * Per-unit cost breakdown for items actively being purchased in this checkout (e.g., seats being added).
   * When only adding seats mid-cycle, this only covers the seats being added, not seats already paid for.
   * Omitted when the checkout is not seat-based.
   */
  per_unit_totals?: BillingPerUnitTotalJSON[];
  total_due_now: BillingMoneyAmountJSON;
  /**
   * Legacy credit field. Kept for backwards compatibility; prefer the unified `credits` breakdown.
   */
  credit: BillingMoneyAmountJSON | null;
  credits: BillingCreditsJSON | null;
  account_credit: BillingMoneyAmountJSON | null;
  past_due: BillingMoneyAmountJSON | null;
  total_due_after_free_trial: BillingMoneyAmountJSON | null;
  /**
   * Discounts applied to this checkout such as mid-cycle prorated seat discounts.
   */
  discounts: BillingDiscountsJSON | null;
  /**
   * The expected recurring payment for each future billing period.
   * Kept for backwards compatibility. Prefer `totals_due_per_period` for the full breakdown.
   */
  total_due_per_period: BillingMoneyAmountJSON;
  /**
   * Full renewal period totals after this checkout completes.
   * Contains the complete breakdown of what the next recurring charge will look like,
   * including all seats and the base plan fee.
   */
  totals_due_per_period: BillingPeriodTotalsJSON;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingStatementTotalsJSON {
  grand_total: BillingMoneyAmountJSON;
  subtotal: BillingMoneyAmountJSON;
  tax_total: BillingMoneyAmountJSON;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingCheckoutJSON extends ClerkResourceJSON {
  object: 'commerce_checkout';
  id: string;
  external_client_secret: string;
  external_gateway_id: string;
  payment_method?: BillingPaymentMethodJSON;
  plan: BillingPlanJSON;
  plan_period: BillingSubscriptionPlanPeriod;
  plan_period_start?: number;
  status: 'needs_confirmation' | 'completed';
  totals: BillingTotalsJSON;
  is_immediate_plan_change: boolean;
  free_trial_ends_at?: number;
  payer: BillingPayerJSON;
  needs_payment_method: boolean;
}
/**
 * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
 */
interface BillingPayerJSON extends ClerkResourceJSON {
  object: 'commerce_payer';
  id: string;
  created_at?: number;
  updated_at?: number;
  image_url?: string;
  user_id: string | null;
  email?: string | null;
  first_name?: string | null;
  last_name?: string | null;
  organization_id: string | null;
  organization_name?: string | null;
}
interface ApiKeyJSON extends ClerkResourceJSON {
  id: string;
  type: string;
  name: string;
  subject: string;
  scopes: string[];
  claims: Record<string, any> | null;
  revoked: boolean;
  revocation_reason: string | null;
  expired: boolean;
  expiration: number | null;
  created_by: string | null;
  description: string | null;
  /**
   * This property is only present in the response from `create()`.
   */
  secret?: string;
  last_used_at: number | null;
  created_at: number;
  updated_at: number;
}
//#endregion
export { ApiKeyJSON, AuthConfigJSON, BackupCodeJSON, BillingCheckoutJSON, BillingCheckoutTotalsJSON, BillingCreditBalanceJSON, BillingCreditLedgerJSON, BillingCreditsJSON, BillingDiscountsJSON, BillingInitializedPaymentMethodJSON, BillingMoneyAmountJSON, BillingPayerCreditJSON, BillingPayerJSON, BillingPaymentJSON, BillingPaymentMethodJSON, BillingPaymentTotalsJSON, BillingPerUnitTotalJSON, BillingPerUnitTotalTierJSON, BillingPeriodTotalsJSON, BillingPlanJSON, BillingPlanUnitPriceJSON, BillingPlanUnitPriceTierJSON, BillingPriceJSON, BillingProrationCreditDetailJSON, BillingProrationDiscountJSON, BillingStatementGroupJSON, BillingStatementJSON, BillingStatementTotalsJSON, BillingSubscriptionItemJSON, BillingSubscriptionItemNextPaymentJSON, BillingSubscriptionItemSeatsJSON, BillingSubscriptionJSON, BillingSubscriptionNextPaymentJSON, BillingTotalsJSON, ClerkResourceJSON, ClientJSON, ClientTrustState, DeletedObjectJSON, DisplayThemeJSON, EmailAddressJSON, EnterpriseAccountConnectionJSON, EnterpriseAccountJSON, EnvironmentJSON, ExternalAccountJSON, FeatureJSON, IdentificationLinkJSON, ImageJSON, LastAuthenticationStrategy, OrganizationDomainBulkOwnershipVerificationErrorJSON, OrganizationDomainJSON, OrganizationDomainOwnershipVerificationJSON, OrganizationDomainVerificationJSON, OrganizationDomainsBulkOwnershipVerificationJSON, OrganizationInvitationJSON, OrganizationJSON, OrganizationMembershipJSON, OrganizationMembershipRequestJSON, OrganizationSuggestionJSON, PartialWithClerkResource, PasskeyJSON, PermissionJSON, PhoneNumberJSON, ProtectCheckJSON, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, PublicOrganizationDataJSON, PublicUserDataJSON, RoleJSON, SessionActivityJSON, SessionJSON, SessionVerificationJSON, SessionWithActivitiesJSON, SignInFirstFactorJSON, SignInSecondFactorJSON, SignUpEnterpriseConnectionJSON, SignUpJSON, SignUpVerificationJSON, SignUpVerificationsJSON, TOTPJSON, TokenJSON, UserDataJSON, UserJSON, UserOrganizationInvitationJSON, VerificationJSON, WaitlistJSON, Web3WalletJSON };