/* Copyright (C) 2023-2026 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { parseCurrencyDisplayType } from '@/lib/currency' import { CheckinSettingsSection } from '../general/checkin-settings-section' import { PricingSection } from '../general/pricing-section' import { QuotaSettingsSection } from '../general/quota-settings-section' import { PaymentSettingsSection } from '../integrations/payment-settings-section' import { RatioSettingsCard } from '../models/ratio-settings-card' import type { BillingSettings } from '../types' import { createSectionRegistry } from '../utils/section-registry' const getModelDefaults = (settings: BillingSettings) => ({ ModelPrice: settings.ModelPrice, ModelRatio: settings.ModelRatio, CacheRatio: settings.CacheRatio, CreateCacheRatio: settings.CreateCacheRatio, CompletionRatio: settings.CompletionRatio, ImageRatio: settings.ImageRatio, AudioRatio: settings.AudioRatio, AudioCompletionRatio: settings.AudioCompletionRatio, ExposeRatioEnabled: settings.ExposeRatioEnabled, BillingMode: settings['billing_setting.billing_mode'], BillingExpr: settings['billing_setting.billing_expr'], }) const getGroupDefaults = (settings: BillingSettings) => ({ TopupGroupRatio: settings.TopupGroupRatio, GroupRatio: settings.GroupRatio, UserUsableGroups: settings.UserUsableGroups, GroupGroupRatio: settings.GroupGroupRatio, AutoGroups: settings.AutoGroups, DefaultUseAutoGroup: settings.DefaultUseAutoGroup, GroupSpecialUsableGroup: settings['group_ratio_setting.group_special_usable_group'], }) const BILLING_SECTIONS = [ { id: 'quota', titleKey: 'Quota Settings', descriptionKey: 'Configure user quota allocation and rewards', build: (settings: BillingSettings) => ( ), }, { id: 'currency', titleKey: 'Currency & Display', descriptionKey: 'Configure currency conversion and quota display options', build: (settings: BillingSettings) => ( ), }, { id: 'model-pricing', titleKey: 'Model Pricing', descriptionKey: 'Configure model pricing ratios and tool prices', build: (settings: BillingSettings) => ( ), }, { id: 'group-pricing', titleKey: 'Group Pricing', descriptionKey: 'Configure group ratios and group-specific pricing rules', build: (settings: BillingSettings) => ( ), }, { id: 'payment', titleKey: 'Payment Gateway', descriptionKey: 'Configure payment gateway integrations', build: (settings: BillingSettings) => ( ), }, { id: 'checkin', titleKey: 'Check-in Rewards', descriptionKey: 'Configure daily check-in rewards for users', build: (settings: BillingSettings) => ( ), }, ] as const export type BillingSectionId = (typeof BILLING_SECTIONS)[number]['id'] const billingRegistry = createSectionRegistry< BillingSectionId, BillingSettings >({ sections: BILLING_SECTIONS, defaultSection: 'quota', basePath: '/system-settings/billing', urlStyle: 'path', }) export const BILLING_SECTION_IDS = billingRegistry.sectionIds export const BILLING_DEFAULT_SECTION = billingRegistry.defaultSection export const getBillingSectionNavItems = billingRegistry.getSectionNavItems export const getBillingSectionContent = billingRegistry.getSectionContent