import AppKit import CodexBarCore import CodexBarMacroSupport import Foundation import SwiftUI @ProviderImplementationRegistration struct MiniMaxProviderImplementation: ProviderImplementation { let id: UsageProvider = .minimax @MainActor func settingsPickers(context: ProviderSettingsContext) -> [ProviderSettingsPickerDescriptor] { let cookieBinding = Binding( get: { context.settings.minimaxCookieSource.rawValue }, set: { raw in context.settings.minimaxCookieSource = ProviderCookieSource(rawValue: raw) ?? .auto }) let cookieOptions: [ProviderSettingsPickerOption] = [ ProviderSettingsPickerOption( id: ProviderCookieSource.auto.rawValue, title: ProviderCookieSource.auto.displayName), ProviderSettingsPickerOption( id: ProviderCookieSource.manual.rawValue, title: ProviderCookieSource.manual.displayName), ] let cookieSubtitle: () -> String? = { switch context.settings.minimaxCookieSource { case .auto: "Automatic imports browser cookies and local storage tokens." case .manual: "Paste a Cookie header or cURL capture from the Coding Plan page." case .off: "MiniMax cookies are disabled." } } return [ ProviderSettingsPickerDescriptor( id: "minimax-cookie-source", title: "Cookie source", subtitle: "Automatic imports browser cookies and local storage tokens.", dynamicSubtitle: cookieSubtitle, binding: cookieBinding, options: cookieOptions, isVisible: nil, onChange: nil), ] } @MainActor func settingsFields(context: ProviderSettingsContext) -> [ProviderSettingsFieldDescriptor] { [ ProviderSettingsFieldDescriptor( id: "minimax-cookie", title: "", subtitle: "", kind: .secure, placeholder: "Cookie: …", binding: context.stringBinding(\.minimaxCookieHeader), actions: [ ProviderSettingsActionDescriptor( id: "minimax-open-dashboard", title: "Open Coding Plan", style: .link, isVisible: nil, perform: { if let url = URL( string: "https://platform.minimax.io/user-center/payment/coding-plan?cycle_type=3") { NSWorkspace.shared.open(url) } }), ], isVisible: { context.settings.minimaxCookieSource == .manual }, onActivate: { context.settings.ensureMiniMaxCookieLoaded() }), ] } }