export interface ApiPage<TItem> {
    managerOperationScopePolicy?: ManagerRoleScopePolicy;
    bdLeaderInviteScopePolicy?: ManagerRoleScopePolicy;
    items: TItem[];
    page: number;
    pageSize: number;
    total: number;
}

export interface ManagerRoleScopePolicy {
    baseScope: "country" | "region" | "global";
    expandedScope: "country" | "region" | "global";
    regionExpansionConfigurable: boolean;
}

export interface ApiList<TItem> {
    items: TItem[];
    total: number;
}

export type EntityId = number | string;

export interface PageQuery {
    [key: string]: boolean | number | string | null | undefined;
    agency_id?: EntityId;
    agencyId?: EntityId;
    claimed_end_ms?: number | string;
    claimed_start_ms?: number | string;
    enabled?: boolean;
    displayScope?: string;
    keyword?: string;
    owner_user_keyword?: string;
    ownerUserKeyword?: string;
    page?: number;
    parent_bd_user_id?: EntityId;
    parent_leader_user_id?: EntityId;
    parentBdUserId?: EntityId;
    parentLeaderUserId?: EntityId;
    page_size?: number;
    pageSize?: number;
    region_id?: EntityId;
    regionId?: EntityId;
    role?: string;
    sort_by?: string;
    sort_direction?: string;
    sortBy?: string;
    sortDirection?: string;
    status?: string;
    team_id?: EntityId;
    teamId?: EntityId;
}

export interface IdName {
    id: number;
    name: string;
}

export type StatusKind = "active" | "disabled" | "error" | "locked" | "running" | "stopped" | "warning";
export type UserStatus = "active" | "disabled" | "locked";

export interface AdminUserDto {
    account: string;
    appScopeMode?: UserAppScopeMode;
    id: EntityId;
    lastLogin?: string;
    lastLoginMs?: number | null;
    mfa?: string;
    mfaEnabled?: boolean;
    name: string;
    role?: string;
    roleIds?: number[];
    status: UserStatus;
    team?: string;
    teamId?: EntityId;
    teamName?: string;
}

export type UserAppScopeMode = "all" | "selected" | "none";

export interface UserAppScopeDto {
    appCodes: string[];
    mode: UserAppScopeMode;
}

export interface TeamDto {
    children?: TeamDto[];
    createdAtMs?: number;
    description?: string;
    id: EntityId;
    name: string;
    parentId?: EntityId | null;
    parentName?: string;
    sort?: number;
    updatedAtMs?: number;
    userCount?: number;
}

export interface TeamPayload {
    description?: string;
    name: string;
    parentId?: EntityId | null;
    sort?: number;
}

export interface UserFinanceScopeDto {
    appCode: string;
    regionId: number;
    userId?: EntityId;
}

export interface FinanceScopeAssignmentDto {
    appCode: string;
    regionId: number;
    userId: EntityId;
    userName?: string;
    userAccount?: string;
    userStatus?: string;
}

export interface UserFormPayload {
    mfaEnabled?: boolean;
    name: string;
    password?: string;
    roleIds: number[];
    status: UserStatus;
    team?: string;
    teamId?: EntityId;
    username?: string;
}

export type UserUpdatePayload = Omit<UserFormPayload, "password" | "username">;

export interface ResetPasswordResultDto {
    initialPassword?: string;
}

export interface CreateUserResultDto {
    initialPassword?: string;
    user?: AdminUserDto;
}

export interface RoleDto {
    code: string;
    description?: string;
    id: number;
    name: string;
    permissions?: PermissionDto[];
}

export interface RolePayload {
    code: string;
    description?: string;
    name: string;
    permissionIds?: number[];
}

export interface PermissionDto {
    code: string;
    description?: string;
    id: number;
    kind: "api" | "button" | "menu";
    name: string;
}

export interface PermissionPayload {
    code: string;
    description?: string;
    kind: PermissionDto["kind"];
    name: string;
}

export interface MenuDto {
    children?: MenuDto[];
    code: string;
    icon?: string;
    id: number;
    label: string;
    parentId?: number | null;
    path?: string;
    permissionCode?: string;
    sort?: number;
    visible?: boolean;
}

export interface MenuPayload {
    code: string;
    icon?: string;
    label: string;
    parentId?: number | null;
    path?: string;
    permissionCode?: string;
    sort?: number;
    visible?: boolean;
}

export interface MenuSortItem {
    id: number;
    sort?: number;
}

export interface DashboardOverviewDto {
    activeUsers: number;
    disabledUsers: number;
    lockedUsers: number;
    logsToday: number;
    menuTotal: number;
    rolesTotal: number;
    series?: {
        operations?: number[];
        users?: number[];
    };
    updatedAt?: string;
    updatedAtMs?: number;
    usersTotal: number;
}

export interface DashboardUserDistributionItemDto {
    count: number;
    key: string;
    label: string;
}

export interface DashboardUserProfileOverviewDto {
    activeUsers: number;
    appCode: string;
    appVersionDistribution: DashboardUserDistributionItemDto[];
    genderDistribution: DashboardUserDistributionItemDto[];
    newUsers: number;
    totalUsers: number;
    updatedAtMs: number;
}

export interface DashboardUserProfileOverviewQuery {
    appCode: string;
    endMs: number;
    startMs: number;
    statTz: string;
}

export interface LogDto {
    action?: string;
    createdAt?: string;
    createdAtMs?: number;
    detail?: string;
    id: number;
    ip?: string;
    message?: string;
    resource?: string;
    status: string;
    username?: string;
}

export interface SessionDto {
    accessToken?: string;
    permissions?: string[];
    user?: {
        account?: string;
        id?: number;
        name?: string;
    };
}

export interface LoginPayload {
    password: string;
    username: string;
}

export interface ChangePasswordPayload {
    newPassword: string;
    oldPassword: string;
}

export interface CoinLedgerUserDto {
    avatar?: string;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    userId: string;
    username?: string;
}

export interface CoinLedgerEntryDto {
    amount: number;
    availableAfter: number;
    availableDelta: number;
    bizType?: string;
    commandId?: string;
    counterpartyUserId?: string;
    createdAtMs?: number;
    direction: "income" | "expense" | string;
    entryId: number;
    externalRef?: string;
    metadata?: Record<string, unknown>;
    roomId?: string;
    transactionId: string;
    user: CoinLedgerUserDto;
    userId: string;
}

export interface CoinSellerLedgerDto {
    amount: number;
    availableDelta: number;
    bizType?: string;
    commandId?: string;
    counterpartyUserId?: string;
    createdAtMs?: number;
    direction: "income" | "expense" | string;
    entryId: number;
    ledgerType?: string;
    metadata?: Record<string, unknown>;
    operator?: CoinAdjustmentOperatorDto;
    operatorUserId?: string;
    paidAmountMicro?: number;
    paidCurrencyCode?: string;
    receiver: CoinLedgerUserDto;
    reason?: string;
    seller: CoinLedgerUserDto;
    sellerBalanceAfter: number;
    stockType?: string;
    transactionId: string;
    transferUsdMinor?: number;
}

export interface HostWithdrawalDto {
    applicationId?: string;
    auditImageUrl?: string;
    auditRemark?: string;
    auditTransactionId?: string;
    coinAmount: number;
    commandId?: string;
    createdAtMs?: number;
    freezeTransactionId?: string;
    id: string;
    identity: string;
    metadata?: Record<string, unknown>;
    recordType: string;
    salaryAssetType: string;
    sellerUser?: CoinLedgerUserDto;
    sellerUserId?: string;
    sourceUser?: CoinLedgerUserDto;
    sourceUserId?: string;
    status: string;
    transactionId?: string;
    updatedAtMs?: number;
    usdMinorAmount: number;
    withdrawAddress?: string;
    withdrawMethod?: string;
}

export interface CoinAdjustmentOperatorDto {
    adminId?: string;
    name?: string;
    username?: string;
}

export interface CoinAdjustmentDto {
    amount: number;
    availableAfter: number;
    availableDelta: number;
    commandId?: string;
    createdAtMs?: number;
    direction: "income" | "expense" | string;
    entryId: number;
    operator?: CoinAdjustmentOperatorDto;
    operatorUserId?: string;
    reason?: string;
    remark?: string;
    transactionId: string;
    user: CoinLedgerUserDto;
    userId: string;
}

export interface CoinAdjustmentPayload {
    amount: number;
    commandId?: string;
    reason: string;
    remark: string;
    targetUserId: string;
}

export interface CoinAdjustmentCreateDto {
    amount: number;
    availableDelta: number;
    balanceAfter: number;
    reason?: string;
    remark?: string;
    transactionId: string;
    user: CoinLedgerUserDto;
}

export interface SalaryWalletDto {
    assetType: string;
    availableAmount: number;
    frozenAmount?: number;
    role: string;
    updatedAtMs?: number;
    userId: string;
}

export interface SalaryWalletOperatorDto {
    adminId?: string;
    name?: string;
    username?: string;
}

export interface SalaryWalletHistoryDto {
    amountMinor: number;
    assetType: string;
    availableAfter: number;
    availableDelta: number;
    bizType?: string;
    commandId?: string;
    counterpartyUserId?: string;
    createdAtMs?: number;
    direction: "income" | "expense" | string;
    entryId: number;
    externalRef?: string;
    frozenAfter?: number;
    frozenDelta?: number;
    metadata?: Record<string, unknown>;
    operator?: SalaryWalletOperatorDto;
    operatorUserId?: string;
    reason?: string;
    role: string;
    roomId?: string;
    transactionId: string;
    userId: string;
}

export interface SalaryWalletAdjustPayload {
    amountMinor: number;
    commandId?: string;
    reason: string;
    role: "host" | "agency" | "bd" | "bd_leader" | string;
    targetUserId: EntityId;
    type: "increase" | "decrease";
}

export interface SalaryWalletAdjustResultDto {
    amountMinor: number;
    assetType: string;
    balance: SalaryWalletDto;
    reason?: string;
    role: string;
    transactionId: string;
    userId: string;
}

export interface ReportUserDto {
    avatar?: string;
    defaultDisplayUserId?: string;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    userId?: string;
    username?: string;
}

export interface ReportRoomDto {
    coverUrl?: string;
    roomId?: string;
    roomShortId?: string;
    title?: string;
}

export interface ReportTargetDto {
    room?: ReportRoomDto;
    type: "user" | "room" | string;
    user?: ReportUserDto;
}

export interface ReportDto {
    createdAtMs?: number;
    imageUrls?: string[];
    reason?: string;
    reportId: string;
    reporterUserId?: string;
    reportType?: string;
    requestId?: string;
    roomId?: string;
    status?: string;
    target: ReportTargetDto;
    targetType: "user" | "room" | string;
    updatedAtMs?: number;
    userId?: string;
}

export interface RechargeBillDto {
    appCode?: string;
    coinAmount: number;
    commandId?: string;
    createdAtMs?: number;
    currencyCode?: string;
    exchangeCoinAmount?: number;
    exchangeUsdMinorAmount?: number;
    externalRef?: string;
    policyId?: number;
    policyVersion?: string;
    providerAmountMinor?: number;
    rechargeType?: string;
    sellerRegionId?: number;
    sellerUserId?: string;
    status?: string;
    targetRegionId?: number;
    transactionId: string;
    usdMinorAmount: number;
    user?: RechargeBillUserDto;
    userId: string;
    seller?: RechargeBillUserDto;
}

export interface RechargeBillUserDto {
    avatar?: string;
    countryCode?: string;
    countryDisplayName?: string;
    countryName?: string;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    userId?: string;
    username?: string;
}

export interface RechargeProductDto {
    amountMicro?: number;
    amountMinor?: number;
    amountUsdt: string;
    amountUsdtMicro: number;
    appCode?: string;
    audienceType?: "normal" | "coin_seller" | string;
    channel?: string;
    coinAmount: number;
    createdAtMs?: number;
    createdByUserId?: number;
    currencyCode?: string;
    description?: string;
    enabled: boolean;
    platform: "android" | "ios" | "web" | string;
    policyVersion?: string;
    productCode?: string;
    productId: number;
    productName: string;
    regionIds: number[];
    resourceAssetType?: string;
    sortOrder?: number;
    status?: "active" | "disabled" | string;
    updatedAtMs?: number;
    updatedByUserId?: number;
}

export interface RechargeProductPayload {
    amountUsdt: string;
    audienceType?: "normal" | "coin_seller";
    coinAmount: number;
    description?: string;
    enabled: boolean;
    platform: "android" | "ios" | "web";
    productName: string;
    regionIds: number[];
}

export interface ThirdPartyPaymentMethodDto {
    appCode?: string;
    countryCode?: string;
    countryName?: string;
    currencyCode?: string;
    logoUrl?: string;
    methodId: number;
    methodName?: string;
    payType?: string;
    payWay?: string;
    providerCode?: string;
    providerName?: string;
    status?: string;
    usdToCurrencyRate?: string;
    sortOrder?: number;
}

export interface ThirdPartyPaymentChannelDto {
    appCode?: string;
    methods?: ThirdPartyPaymentMethodDto[];
    providerCode: string;
    providerName: string;
    sortOrder?: number;
    status?: string;
}

export interface ThirdPartyPaymentRateSyncPayload {
    markupPercent: number;
}

export interface ThirdPartyPaymentMethodSyncPayload {
    providerCode?: string;
}

export interface ThirdPartyPaymentMethodSyncDto {
    createdCount: number;
    failedCountryCount?: number;
    fetchedCountryCount?: number;
    issues?: Array<{
        code?: string;
        countryCode?: string;
        currencyCode?: string;
        message?: string;
    }>;
    providerCode?: string;
    scannedCountryCount?: number;
    skippedCount?: number;
    updatedCount: number;
}

export interface TemporaryPaymentLinkDto {
    appCode?: string;
    audienceType?: string;
    coinAmount: number;
    countryCode?: string;
    createdAtMs?: number;
    currencyCode?: string;
    failureReason?: string;
    orderId: string;
    payType?: string;
    payUrl?: string;
    payWay?: string;
    paymentMethodId?: EntityId;
    productName?: string;
    providerAmountMinor?: number;
    providerCode?: string;
    providerOrderId?: string;
    status?: string;
    transactionId?: string;
    txHash?: string;
    updatedAtMs?: number;
    usdMinorAmount: number;
}

export interface FinanceCoinSellerRechargeOrderDto {
    appCode?: string;
    chain?: string;
    coinAmount: number;
    createdAtMs?: number;
    externalOrderNo?: string;
    failureReason?: string;
    grantStatus?: string;
    grantedAtMs?: number;
    grantedByName?: string;
    id: EntityId;
    operatorName?: string;
    orderDate?: string;
    providerAmountMinor?: number;
    providerCode?: string;
    providerCountryCode?: string;
    providerCurrencyCode?: string;
    providerOrderId?: string;
    providerPayloadJson?: string;
    providerPayType?: string;
    providerStatus?: string;
    receiveAddress?: string;
    remark?: string;
    status?: string;
    targetDisplayUserId?: string;
    targetUserId: string;
    usdAmount?: number | string;
    usdMinorAmount?: number;
    verifiedAtMs?: number;
    verifiedByName?: string;
    verifyStatus?: string;
    walletAmountDelta?: number;
    walletAssetType?: string;
    walletBalanceAfter?: number;
    walletCommandId?: string;
    walletTransactionId?: string;
}

export interface FinanceCoinSellerRechargeOrderPayload {
    appCode: string;
    chain?: string;
    coinAmount: number;
    externalOrderNo: string;
    providerAmountMinor?: number;
    providerCode: "mifapay" | "v5pay" | "usdt";
    providerCurrencyCode?: string;
    remark?: string;
    targetUserId: EntityId;
    usdAmount: number;
}

export interface FinanceCoinSellerRechargeReceiptVerificationPayload {
    appCode: string;
    chain?: string;
    externalOrderNo: string;
    providerAmountMinor?: number;
    providerCode: "mifapay" | "v5pay" | "usdt";
    providerCurrencyCode?: string;
    usdAmount?: number;
    usdMinorAmount?: number;
}

export interface FinanceCoinSellerRechargeReceiptVerificationDto {
    chain?: string;
    currencyCode?: string;
    externalOrderNo?: string;
    failureReason?: string;
    providerAmountMinor?: number;
    providerCode?: string;
    providerOrderId?: string;
    rawJson?: string;
    receiveAddress?: string;
    status?: string;
    verifiedAtMs?: number;
    verified: boolean;
}

export interface ThirdPartyPaymentRateSyncDto {
    missingCurrencies?: string[];
    rates?: Record<string, string>;
    skippedCount?: number;
    sourceNames?: string[];
    sources?: Array<{
        currencies?: string[];
        error?: string;
        name: string;
        success: boolean;
        url?: string;
    }>;
    updatedCount: number;
}

export interface AppVersionDto {
    appCode?: string;
    buildNumber: number;
    createdAtMs?: number;
    description?: string;
    downloadUrl: string;
    forceUpdate: boolean;
    id: number;
    platform: "android" | "ios" | string;
    updatedAtMs?: number;
    version: string;
}

export interface AppVersionPayload {
    buildNumber: number;
    description?: string;
    downloadUrl: string;
    forceUpdate: boolean;
    platform: "android" | "ios";
    version: string;
}

export interface BDProfileDto {
    agencyCount?: number;
    avatar?: string;
    createdAtMs?: number;
    createdByAvatar?: string;
    createdByDisplayUserId?: string;
    createdByUsername?: string;
    createdByUserId?: number;
    contact?: string;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    parentLeaderUserId?: string;
    parentLeaderDisplayUserId?: string;
    parentLeaderUsername?: string;
    parentLeaderAvatar?: string;
    positionAlias?: string;
    regionId?: number;
    regionName?: string;
    role?: string;
    salaryWallet?: SalaryWalletDto;
    status?: string;
    subBdCount?: number;
    updatedAtMs?: number;
    userId: string;
    username?: string;
}

export interface AgencyDto {
    activeHostCount?: number;
    agencyId: number;
    createdAtMs?: number;
    createdByUserId?: number;
    joinEnabled?: boolean;
    maxHosts?: number;
    name?: string;
    ownerAvatar?: string;
    contact?: string;
    ownerDisplayUserId?: string;
    ownerUsername?: string;
    ownerUserId?: string;
    parentBdAvatar?: string;
    parentBdDisplayUserId?: string;
    parentBdUsername?: string;
    parentBdUserId?: string;
    regionId?: number;
    regionName?: string;
    salaryWallet?: SalaryWalletDto;
    status?: string;
    updatedAtMs?: number;
}

export interface ManagerDto {
    avatar?: string;
    bdLeaderCount?: number;
    canAddAdmin?: boolean;
    canAddBdLeader?: boolean;
    canManageCrossRegion?: boolean;
    managerOperationBaseScope?: "country" | "region" | "global";
    managerOperationEffectiveScope?: "country" | "region" | "global";
    managerCrossRegionConfigurable?: boolean;
    canAddBdLeaderInRegion?: boolean;
    bdLeaderRegionExpansionConfigurable?: boolean;
    canAddSuperadmin?: boolean;
    canBlockUser?: boolean;
    canGrantAvatarFrame?: boolean;
    canGrantBadge?: boolean;
    canGrantVehicle?: boolean;
    canGrantVip?: boolean;
    canTransferUserCountry?: boolean;
    canUpdateUserLevel?: boolean;
    contact?: string;
    createdAtMs?: number;
    displayUserId?: string;
    lastInvitedAtMs?: number;
    regionId?: number;
    regionName?: string;
    status?: "active" | "disabled";
    updatedAtMs?: number;
    userId: string;
    username?: string;
}

export interface CreateManagerPayload {
    canAddAdmin?: boolean;
    canAddBdLeader?: boolean;
    canManageCrossRegion?: boolean;
    canAddBdLeaderInRegion?: boolean;
    canAddSuperadmin?: boolean;
    canBlockUser?: boolean;
    canGrantAvatarFrame?: boolean;
    canGrantBadge?: boolean;
    canGrantVehicle?: boolean;
    canGrantVip?: boolean;
    canTransferUserCountry?: boolean;
    canUpdateUserLevel?: boolean;
    contact?: string;
    targetUserId: string;
}

export interface UpdateManagerPayload {
    canAddAdmin?: boolean;
    canAddBdLeader?: boolean;
    canManageCrossRegion?: boolean;
    canAddBdLeaderInRegion?: boolean;
    canAddSuperadmin?: boolean;
    canBlockUser?: boolean;
    canGrantAvatarFrame?: boolean;
    canGrantBadge?: boolean;
    canGrantVehicle?: boolean;
    canGrantVip?: boolean;
    canTransferUserCountry?: boolean;
    canUpdateUserLevel?: boolean;
    contact?: string;
    status?: "active" | "disabled";
}

export interface HostProfileDto {
    avatar?: string;
    createdAtMs?: number;
    currentAgencyId?: number;
    currentAgencyName?: string;
    currentAgencyOwnerAvatar?: string;
    currentAgencyOwnerDisplayUserId?: string;
    currentAgencyOwnerUserId?: string;
    currentAgencyOwnerUsername?: string;
    contact?: string;
    currentMembershipId?: number;
    diamond?: number;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    firstBecameHostAtMs?: number;
    regionId?: number;
    regionName?: string;
    salaryWallet?: SalaryWalletDto;
    source?: string;
    status?: string;
    updatedAtMs?: number;
    userId: string;
    username?: string;
}

export interface CoinSellerDto {
    avatar?: string;
    canManageSubCoinSellers?: boolean;
    contact?: string;
    createdAtMs?: number;
    createdByUserId?: number;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    merchantAssetType?: string;
    merchantBalance?: number;
    regionId?: number;
    regionName?: string;
    status?: string;
    subCoinSellerCount?: number;
    totalRechargeUsdtMicro?: number;
    updatedAtMs?: number;
    userId: string;
    username?: string;
}

export interface CoinSellerSubApplicationUserDto {
    avatar?: string;
    displayUserId?: string;
    regionId?: number;
    regionName?: string;
    userId: string;
    username?: string;
}

export interface CoinSellerSubApplicationDto {
    applicationId: string;
    commandId?: string;
    createdAtMs?: number;
    parent: CoinSellerSubApplicationUserDto;
    relationId?: string;
    reviewedAtMs?: number;
    reviewedByAdminId?: string;
    reviewReason?: string;
    status: "pending" | "approved" | "rejected";
    target: CoinSellerSubApplicationUserDto;
    updatedAtMs?: number;
}

export interface CoinSellerSubApplicationReviewPayload {
    commandId: string;
    reason?: string;
}

export interface CoinSellerSubApplicationReviewApplicationDto {
    applicationId: string;
    commandId?: string;
    createdAtMs?: number;
    parentUserId: string;
    relationId?: string;
    reviewedAtMs?: number;
    reviewedByAdminId?: string;
    reviewReason?: string;
    status: "pending" | "approved" | "rejected";
    targetUserId: string;
    updatedAtMs?: number;
}

export interface CoinSellerSubRelationDto {
    childUserId: string;
    createdAtMs?: number;
    createdByUserId?: string;
    parentUserId: string;
    relationId: string;
    status: string;
    updatedAtMs?: number;
}

export interface CoinSellerSubApplicationReviewChildDto {
    avatar?: string;
    canManageSubCoinSellers?: boolean;
    contactInfo?: string;
    displayUserId?: string;
    merchantAssetType?: string;
    regionId?: number;
    regionName?: string;
    status?: string;
    updatedAtMs?: number;
    userId: string;
    username?: string;
}

export interface CoinSellerSubApplicationReviewResultDto {
    application?: CoinSellerSubApplicationReviewApplicationDto;
    child?: CoinSellerSubApplicationReviewChildDto;
    relation?: CoinSellerSubRelationDto;
}

export interface CoinSellerStockCreditPayload {
    coinAmount: number;
    commandId: string;
    reason?: string;
    rechargeAmount?: string;
    type: "usdt_purchase" | "coin_compensation";
}

export interface CoinSellerStockCreditDto {
    balanceAfter: number;
    coinAmount: number;
    countsAsSellerRecharge: boolean;
    createdAtMs: number;
    paidAmountMicro: number;
    paidCurrencyCode: string;
    sellerUserId: string;
    stockType: string;
    transactionId: string;
}

export interface CoinSellerStockDebitPayload {
    coinAmount: number;
    commandId: string;
    evidenceRef?: string;
    rechargeAmount: string;
    reason: string;
}

export interface CoinSellerStockDebitDto {
    availableDelta: number;
    balanceAfter: number;
    coinAmount: number;
    countsAsSellerRecharge?: boolean;
    createdAtMs?: number;
    paidAmountMicro?: number;
    paidCurrencyCode?: string;
    sellerUserId: string;
    stockType?: string;
    transactionId: string;
}

export interface CoinSellerSalaryRateTierDto {
    coinPerUsd: number;
    enabled?: boolean;
    maxUsd?: string;
    maxUsdMinor: number;
    minUsd?: string;
    minUsdMinor: number;
    regionId?: EntityId;
    sortOrder?: number;
    status?: string;
    updatedAtMs?: number;
}

export interface CoinSellerSalaryRatesDto {
    regionId: EntityId;
    tiers: CoinSellerSalaryRateTierDto[];
}

export interface CoinSellerSalaryRateTierPayload {
    coinPerUsd: number;
    enabled?: boolean;
    maxUsd?: string;
    maxUsdMinor?: number;
    minUsd?: string;
    minUsdMinor?: number;
    sortOrder?: number;
    status?: string;
}

export interface CoinSellerSalaryRatesPayload {
    tiers: CoinSellerSalaryRateTierPayload[];
}

export interface AppUserDto {
    age?: number;
    appVersion?: string;
    appVersionAtMs?: number;
    avatar?: string;
    balances?: AppUserAssetBalanceDto[];
    ban?: AppUserBanDto;
    birth?: string;
    buildNumber?: string;
    coin?: number;
    country?: string;
    countryDisplayName?: string;
    countryName?: string;
    createdAtMs?: number;
    defaultDisplayUserId?: string;
    devices?: AppUserDeviceDto[];
    diamond?: number;
    displayUserId?: string;
    equippedResources?: AppUserResourceDto[];
    gender?: string;
    lastActiveAtMs?: number;
    lastLoginAtMs?: number;
    lastLoginIp?: string;
    lastLoginIpAtMs?: number;
    lastLoginIpCountryCode?: string;
    lastOperatedAtMs?: number;
    lastOperator?: AppUserOperatorDto;
    levels?: AppUserLevelsDto;
    prettyDisplayUserId?: string;
    prettyId?: string;
    regionId?: number;
    regionName?: string;
    registerDevice?: string;
    registerDeviceId?: string;
    registerOsVersion?: string;
    resources?: AppUserResourceDto[];
    roles?: string[];
    status?: string;
    thirdPartyIdentities?: AppUserThirdPartyIdentityDto[];
    updatedAtMs?: number;
    userId: string;
    username?: string;
    vip?: AppUserVIPDto;
    cumulativeRechargeUsdMinor?: number;
}

export interface AppUserThirdPartyIdentityDto {
    provider: string;
    openid: string;
    unionId: string;
    createdAtMs: number;
}

export interface AppUserDeviceDto {
    deviceId: string;
    platform: string;
    deviceModel: string;
    manufacturer: string;
    osVersion: string;
    imei: string;
    appVersion: string;
    buildNumber: string;
    firstSeenAtMs: number;
    lastSeenAtMs: number;
}

export interface AppUserAccessTokenDto {
    accessToken: string;
    tokenType: string;
    expiresInSec: number;
    sessionId: string;
    deviceId: string;
    sessionLastHeartbeatAtMs: number;
}

export interface AppUserLevelDto {
    displayLevel: number;
    displayValue: number;
    expiresAtMs: number;
    realLevel: number;
    realTotalValue: number;
    startedAtMs: number;
    temporaryLevelId?: string;
    temporaryTargetLevel: number;
    track: "wealth" | "game" | "charm" | string;
}

export interface AppUserLevelsDto {
    charm: AppUserLevelDto;
    game: AppUserLevelDto;
    wealth: AppUserLevelDto;
}

export interface AppUserBanDto {
    active: boolean;
    expiresAtMs: number;
    id?: string;
    permanent: boolean;
    reason?: string;
    source?: "admin" | "manager" | "legacy" | string;
}

export interface AppUserOperatorDto {
    action?: string;
    adminId?: string;
    name?: string;
}

export interface AppUserAssetBalanceDto {
    assetType: string;
    availableAmount: number;
    frozenAmount: number;
    totalAmount: number;
    version: number;
    updatedAtMs: number;
}

export interface AppUserVIPDto {
    active: boolean;
    expiresAtMs: number;
    level: number;
    name?: string;
    startedAtMs: number;
    updatedAtMs: number;
}

export interface AppUserResourceDto {
    animationUrl?: string;
    assetUrl?: string;
    createdAtMs: number;
    effectiveAtMs: number;
    entitlementId: string;
    equipped: boolean;
    expiresAtMs: number;
    name: string;
    previewUrl?: string;
    quantity: number;
    remainingQuantity: number;
    resourceCode: string;
    resourceId: number;
    resourceType: string;
    sourceGrantId?: string;
    status: string;
    updatedAtMs: number;
}

export interface AppUserBriefDto {
    avatar?: string;
    defaultDisplayUserId?: string;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    userId: string;
    username?: string;
}

export interface AppUserBanOperatorDto {
    account?: string;
    adminId?: string;
    avatar?: string;
    defaultDisplayUserId?: string;
    displayUserId?: string;
    name?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    type: "admin" | "app_user" | "system" | string;
    userId?: string;
}

export interface AppUserBanRecordDto {
    createdAtMs?: number;
    id: number;
    newStatus?: string;
    oldStatus?: string;
    operator?: AppUserBanOperatorDto;
    reason?: string;
    requestId?: string;
    target: AppUserBriefDto;
}

export interface AppUserLoginLogDto {
    avatar?: string;
    blockReason?: string;
    blocked?: boolean;
    channel?: string;
    country?: string;
    createdAtMs?: number;
    defaultDisplayUserId?: string;
    displayUserId?: string;
    failureCode?: string;
    id: number;
    ipCountryCode?: string;
    loginIp?: string;
    loginType?: string;
    platform?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    provider?: string;
    regionId?: number;
    regionName?: string;
    requestId?: string;
    result?: string;
    riskHighlighted?: boolean;
    userId?: string;
    username?: string;
}

export interface AppUserUpdatePayload {
    avatar?: string;
    country?: string;
    gender?: string;
    username?: string;
}

export interface AppUserBanPayload {
    expires_at_ms: number;
    reason?: string;
}

export interface AppUserUnbanPayload {
    reason?: string;
}

export interface AppUserLevelAdjustmentPayload {
    adjustments: Array<{
        duration_days: number;
        level: number;
        track: "wealth" | "charm";
    }>;
    reason?: string;
}

export interface AppUserExportJobDto {
    jobId: number;
    snapshotAtMs: number;
    status: string;
}

export interface AppUserPasswordPayload {
    password: string;
}

export interface PrettyDisplayIDPoolDto {
    appCode?: string;
    createdAtMs?: number;
    createdByAdminId?: EntityId;
    levelTrack: string;
    maxLevel: number;
    minLevel: number;
    name: string;
    poolId: string;
    ruleConfigJson?: string;
    ruleType: string;
    sortOrder?: number;
    status: string;
    updatedAtMs?: number;
    updatedByAdminId?: EntityId;
}

export interface PrettyDisplayIDDto {
    appCode?: string;
    assignedAtMs?: number;
    assignedLeaseId?: string;
    assignedUser?: {
        avatar?: string;
        defaultDisplayUserId?: string;
        displayUserId?: string;
        prettyDisplayUserId?: string;
        prettyId?: string;
        userId?: EntityId;
        username?: string;
    };
    assignedUserId?: EntityId;
    createdAtMs?: number;
    createdByAdminId?: EntityId;
    displayUserId: string;
    generatedBatchId?: string;
    operator?: {
        account?: string;
        adminId?: EntityId;
        avatar?: string;
        displayUserId?: string;
        name?: string;
        source?: string;
        type?: string;
        userId?: EntityId;
        username?: string;
    };
    pool?: PrettyDisplayIDPoolDto | null;
    poolId?: string;
    prettyId: string;
    releaseReason?: string;
    releasedAtMs?: number;
    source: string;
    status: string;
    updatedAtMs?: number;
    updatedByAdminId?: EntityId;
}

export interface PrettyDisplayIDGenerationBatchDto {
    appCode?: string;
    batchId: string;
    createdAtMs?: number;
    generatedCount: number;
    operatorAdminId?: EntityId;
    poolId: string;
    requestId?: string;
    requestedCount: number;
    ruleConfigJson?: string;
    ruleType: string;
    skippedConflictCount: number;
    status: string;
    updatedAtMs?: number;
}

export interface PrettyDisplayIDPoolPayload {
    level_track: string;
    max_level: number;
    min_level: number;
    name: string;
    rule_config_json?: string;
    rule_type: string;
    sort_order?: number;
    status: string;
}

export interface GeneratePrettyDisplayIDsPayload {
    count: number;
    rule_config_json?: string;
    rule_type: string;
}

export interface GrantPrettyDisplayIDPayload {
    display_user_id: string;
    duration_ms?: number;
    reason?: string;
    target_user_id: EntityId;
}

export interface RecyclePrettyDisplayIDPayload {
    reason?: string;
}

export interface SetPrettyDisplayIDStatusPayload {
    reason?: string;
    status: string;
}

export interface AdminGrantPrettyDisplayIDResultDto {
    identity?: {
        defaultDisplayUserId?: string;
        displayUserId?: string;
        prettyDisplayUserId?: string;
        prettyId?: string;
        userId?: string;
    };
    leaseId?: string;
    prettyId: string;
}

export interface RoomDto {
    closeReason?: string;
    closedAtMs?: number;
    closedByAdminId?: number;
    closedByAdminName?: string;
    coverUrl?: string;
    createdAtMs?: number;
    heat?: number;
    mode?: string;
    occupiedSeatCount?: number;
    onlineCount?: number;
    owner?: RoomOwnerDto;
    ownerUserId?: string;
    regionName?: string;
    roomId: string;
    roomContribution?: number;
    roomShortId?: string;
    seatCount?: number;
    sortScore?: number;
    status?: string;
    title?: string;
    updatedAtMs?: number;
    visibleRegionId?: number;
}

export interface RoomPinRoomDto {
    coverUrl?: string;
    regionName?: string;
    roomId: string;
    roomShortId?: string;
    status?: string;
    title?: string;
    visibleRegionId?: number;
}

export interface RoomPinDto {
    cancelledAtMs?: number;
    cancelledByAdminId?: number;
    createdAtMs?: number;
    createdByAdminId?: number;
    expiresAtMs?: number;
    id: EntityId;
    pinType?: string;
    pinnedAtMs?: number;
    remainingMs?: number;
    room: RoomPinRoomDto;
    status?: string;
    updatedAtMs?: number;
    user?: RoomOwnerDto;
    weight?: number;
}

export interface RoomPinPayload {
    durationDays?: number;
    expiresAtMs?: number;
    pinType?: string;
    pinnedAtMs?: number;
    roomId: string;
    weight: number;
}

export interface RobotGiftRuleDto {
    giftIds?: string[];
    luckyGiftIds?: string[];
    luckyComboMax?: number;
    luckyComboMin?: number;
    luckyPauseMaxMs?: number;
    luckyPauseMinMs?: number;
    maxGiftSenders?: number;
    normalGiftIntervalMs?: number;
    normalGiftIntervalMinMs?: number;
    normalGiftIntervalMaxMs?: number;
    robotReplaceMaxMs?: number;
    robotReplaceMinMs?: number;
    robotStayMaxMs?: number;
    robotStayMinMs?: number;
}

export interface RobotRoomDto {
    appCode?: string;
    coverUrl?: string;
    createdAtMs?: number;
    createdByAdminId?: number;
    giftRule?: RobotGiftRuleDto;
    owner?: RoomOwnerDto;
    ownerRobotUserId?: string;
    regionName?: string;
    robots?: RoomOwnerDto[];
    robotUserIds?: string[];
    activeRobotCount?: number;
    seatCount?: number;
    roomId: string;
    roomShortId?: string;
    status?: string;
    title?: string;
    updatedAtMs?: number;
    visibleRegionId?: number;
}

export interface AvailableRoomRobotDto {
    lastUsedAtMs?: number;
    roomScene?: string;
    status?: string;
    usedCount?: number;
    user?: RoomOwnerDto;
    userId: string;
}

export interface RobotRoomPayload {
    candidateRobotUserIds: EntityId[];
    giftIds: string[];
    luckyComboMax: number;
    luckyComboMin: number;
    luckyGiftIds: string[];
    luckyPauseMaxMs: number;
    luckyPauseMinMs: number;
    maxGiftSenders: number;
    maxRobotCount: number;
    minRobotCount: number;
    normalGiftIntervalMs: number;
    ownerRobotUserId: EntityId;
    robotReplaceMaxMs: number;
    robotReplaceMinMs: number;
    robotStayMaxMs: number;
    robotStayMinMs: number;
    seatCount: number;
    roomAvatar?: string;
    roomName?: string;
    visibleRegionId?: EntityId;
}

export interface HumanRoomRobotConfigDto {
    candidateRoomMaxOnline?: number;
    countryLimitEnabled?: boolean;
    countryRules?: HumanRoomRobotCountryRuleDto[];
    enabled?: boolean;
    giftIds?: string[];
    luckyComboMax?: number;
    luckyComboMin?: number;
    luckyGiftIds?: string[];
    luckyPauseMaxMs?: number;
    luckyPauseMinMs?: number;
    maxGiftSenders?: number;
    normalGiftIntervalMs?: number;
    normalGiftIntervalMaxMs?: number;
    normalGiftIntervalMinMs?: number;
    robotReplaceMaxMs?: number;
    robotReplaceMinMs?: number;
    robotStayMaxMs?: number;
    robotStayMinMs?: number;
    roomFullStopOnline?: number;
    roomTargetMaxOnline?: number;
    roomTargetMinOnline?: number;
    superLuckyGiftIds?: string[];
    updatedAtMs?: number;
    updatedByAdminId?: number;
}

export interface HumanRoomRobotCountryRuleDto {
    allowedOwnerIds?: string[];
    countryCode: string;
    maxRoomCount: number;
}

export interface HumanRoomRobotConfigPayload {
    candidateRoomMaxOnline: number;
    countryLimitEnabled: boolean;
    countryRules: HumanRoomRobotCountryRuleDto[];
    enabled: boolean;
    giftIds: string[];
    luckyComboMax: number;
    luckyComboMin: number;
    luckyGiftIds: string[];
    luckyPauseMaxMs: number;
    luckyPauseMinMs: number;
    maxGiftSenders: number;
    normalGiftIntervalMs: number;
    normalGiftIntervalMinMs: number;
    normalGiftIntervalMaxMs: number;
    roomTargetMaxOnline: number;
    roomTargetMinOnline: number;
    robotReplaceMaxMs: number;
    robotReplaceMinMs: number;
    robotStayMaxMs: number;
    robotStayMinMs: number;
    roomFullStopOnline: number;
    superLuckyGiftIds: string[];
}

export interface RoomOwnerDto {
    avatar?: string;
    countryCode?: string;
    displayUserId?: string;
    prettyDisplayUserId?: string;
    prettyId?: string;
    userId?: string;
    username?: string;
    visibleRegionId?: number;
}

export interface RoomUpdatePayload {
    closeReason?: string;
    coverUrl?: string;
    description?: string;
    mode?: string;
    status?: string;
    title?: string;
    visibleRegionId?: number;
}

export interface RoomConfigDto {
    allowedSeatCounts: number[];
    candidateSeatCounts: number[];
    defaultSeatCount: number;
    updatedAtMs?: number;
}

export interface RoomConfigPayload {
    allowedSeatCounts: number[];
    defaultSeatCount: number;
}

export interface RoomWhitelistConfigDto {
    updatedAtMs?: number;
    userIds: EntityId[];
}

export interface RoomWhitelistPayload {
    userIds: EntityId[];
}

export interface UploadResultDto {
    content_type?: string;
    contentType?: string;
    object_key?: string;
    objectKey?: string;
    size_bytes?: number;
    sizeBytes?: number;
    url: string;
}

export interface AdminAppDto {
    appCode: string;
    appId: number;
    appName: string;
    createdAtMs?: number;
    logoUrl: string;
    packageName?: string;
    platform?: string;
    status?: string;
    updatedAtMs?: number;
}

export interface H5LinkConfigDto {
    appCode: string;
    key: string;
    label: string;
    updatedAtMs: number;
    url: string;
}

export interface H5LinkConfigPayload {
    key: string;
    label: string;
    url: string;
}

export interface H5LinkConfigUpdatePayload {
    items: H5LinkConfigPayload[];
}

export interface ExploreTabDto {
    appCode?: string;
    createdAtMs?: number;
    enabled: boolean;
    h5Url: string;
    id: number;
    sortOrder?: number;
    tab: string;
    updatedAtMs?: number;
}

export interface ExploreTabPayload {
    enabled: boolean;
    h5Url: string;
    sortOrder?: number;
    tab: string;
}

export interface AppBannerDto {
    appCode?: string;
    bannerType: "h5" | "app" | string;
    countryCode?: string;
    coverUrl: string;
    createdAtMs?: number;
    description?: string;
    displayScope?: "home" | "room" | "recharge" | "me" | string;
    displayScopes?: Array<"home" | "room" | "recharge" | "me" | string>;
    endsAtMs?: number;
    id: number;
    param?: string;
    platform: "android" | "ios" | string;
    regionId?: number;
    roomSmallImageUrl?: string;
    sortOrder?: number;
    startsAtMs?: number;
    status: "active" | "disabled" | "expired" | string;
    updatedAtMs?: number;
}

export interface AppBannerPayload {
    bannerType: "h5" | "app";
    countryCode?: string;
    coverUrl: string;
    description?: string;
    displayScope?: "home" | "room" | "recharge" | "me";
    displayScopes?: Array<"home" | "room" | "recharge" | "me">;
    endsAtMs?: number;
    param?: string;
    platform: "android" | "ios";
    regionId?: number;
    roomSmallImageUrl?: string;
    sortOrder?: number;
    startsAtMs?: number;
    status: "active" | "disabled" | "expired";
}

export interface AppSplashScreenDto {
    appCode?: string;
    countryCode?: string;
    coverUrl: string;
    createdAtMs?: number;
    description?: string;
    displayDurationMs?: number;
    endsAtMs?: number;
    id: number;
    param?: string;
    platform: "android" | "ios" | string;
    regionId?: number;
    sortOrder?: number;
    splashType: "h5" | "app" | string;
    startsAtMs?: number;
    status: "active" | "disabled" | "expired" | string;
    updatedAtMs?: number;
}

export interface AppSplashScreenPayload {
    countryCode?: string;
    coverUrl: string;
    description?: string;
    displayDurationMs?: number;
    endsAtMs?: number;
    param?: string;
    platform: "android" | "ios";
    regionId?: number;
    sortOrder?: number;
    splashType: "h5" | "app";
    startsAtMs?: number;
    status: "active" | "disabled" | "expired";
}

export interface AppPopupDto {
    appCode?: string;
    code: string;
    createdAtMs?: number;
    displayPeriodDays?: number;
    endsAtMs?: number;
    id: number;
    imageUrl?: string;
    jumpType: "h5" | "app" | string;
    jumpUrl: string;
    name: string;
    sortOrder?: number;
    startsAtMs?: number;
    status: "active" | "disabled" | "expired" | string;
    updatedAtMs?: number;
}

export interface AppPopupPayload {
    code: string;
    displayPeriodDays?: number;
    endsAtMs?: number;
    imageUrl?: string;
    jumpType: "h5" | "app";
    jumpUrl: string;
    name: string;
    sortOrder?: number;
    startsAtMs?: number;
    status: "active" | "disabled" | "expired";
}

export interface AgencyMembershipDto {
    agencyId?: number;
    createdAtMs?: number;
    endedAtMs?: number;
    endedByUserId?: number;
    endedReason?: string;
    hostUserId?: number;
    joinedAtMs?: number;
    membershipId: number;
    membershipType?: string;
    regionId?: number;
    status?: string;
    updatedAtMs?: number;
}

export interface CreateAgencyResultDto {
    agency?: AgencyDto;
    hostProfile?: HostProfileDto;
    membership?: AgencyMembershipDto;
}

export interface HostCommandPayload {
    commandId: string;
    reason?: string;
}

export interface CreateBDLeaderPayload extends HostCommandPayload {
    positionAlias?: string;
    targetUserId: string;
}

export interface BDLeaderPositionAliasPayload extends HostCommandPayload {
    positionAlias?: string;
}

export interface CreateBDPayload extends HostCommandPayload {
    parentLeaderUserId: string;
    targetUserId: string;
}

export interface BDStatusPayload extends HostCommandPayload {
    status: string;
}

export interface CreateCoinSellerPayload extends HostCommandPayload {
    canManageSubCoinSellers?: boolean;
    contact?: string;
    targetUserId: string;
}

export interface CoinSellerStatusPayload extends BDStatusPayload {
    canManageSubCoinSellers?: boolean;
    contact?: string;
}

export interface CreateAgencyPayload extends HostCommandPayload {
    joinEnabled: boolean;
    name: string;
    ownerUserId: string;
    parentBdUserId: string;
}

export interface AgencyHostAddPayload extends HostCommandPayload {
    targetUserId: string;
}

export interface AgencyJoinEnabledPayload extends HostCommandPayload {
    joinEnabled: boolean;
}

export interface AgencyStatusPayload extends HostCommandPayload {
    status: string;
}

export interface CountryDto {
    countryCode: string;
    countryDisplayName?: string;
    countryId: number;
    countryName?: string;
    createdAtMs?: number;
    enabled?: boolean;
    flag?: string;
    isoAlpha3?: string;
    isoNumeric?: string;
    phoneCountryCode?: string;
    sortOrder?: number;
    updatedAtMs?: number;
}

export interface CountryPayload {
    countryCode: string;
    countryDisplayName: string;
    countryName: string;
    enabled?: boolean;
    flag?: string;
    isoAlpha3?: string;
    isoNumeric?: string;
    phoneCountryCode?: string;
    sortOrder?: number;
}

export type CountryUpdatePayload = Omit<CountryPayload, "countryCode" | "enabled">;

export type CountryRenameCodePayload = Omit<CountryPayload, "enabled">;

export interface CountryCodeRenameJobDto {
    countryId: number;
    jobId: number;
    newCountryCode: string;
    oldCountryCode: string;
    status: string;
}

export interface AdminJobDto {
    artifactPath?: string;
    attempt?: number;
    createdAtMs?: number;
    createdBy?: number;
    createdByName?: string;
    error?: string;
    finishedAtMs?: number | null;
    id: number;
    maxAttempts?: number;
    payloadJson?: string;
    resultJson?: string;
    startedAtMs?: number | null;
    status: string;
    type: string;
    updatedAtMs?: number;
}

export interface RegionDto {
    countries?: string[];
    createdAtMs?: number;
    name: string;
    regionCode: string;
    regionId: number;
    sortOrder?: number;
    status?: string;
    updatedAtMs?: number;
}

export interface RegionPayload {
    countries?: string[];
    name: string;
    regionCode: string;
    sortOrder?: number;
}

export type RegionUpdatePayload = Omit<RegionPayload, "countries">;

export interface RegionCountriesPayload {
    countries: string[];
}

export interface SearchResultDto {
    id: EntityId;
    subtitle?: string;
    target?: string;
    title: string;
    type: string;
}
