@xopcai/xopc 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/weixin/src/api/api.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/gateway/static/root/assets/{agents-B6s2BvpH.js → agents-BSNzJWbQ.js} +2 -2
- package/dist/gateway/static/root/assets/{agents-B6s2BvpH.js.map → agents-BSNzJWbQ.js.map} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BtsZ5ZPx.js → apps-page-BKk9SB4D.js} +2 -2
- package/dist/gateway/static/root/assets/{apps-page-BtsZ5ZPx.js.map → apps-page-BKk9SB4D.js.map} +1 -1
- package/dist/gateway/static/root/assets/attachment-load-DXcJLSWT.js +1 -0
- package/dist/gateway/static/root/assets/{channels-settings-BUfWBEVU.js → channels-settings-_J6cQN6G.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-settings-BUfWBEVU.js.map → channels-settings-_J6cQN6G.js.map} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-BR30M2YQ.js → chat-agents-api-DPb_0O8M.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-agents-api-BR30M2YQ.js.map → chat-agents-api-DPb_0O8M.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-page-CMTx0Mjz.js → cron-page-BUJOuuKX.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-page-CMTx0Mjz.js.map → cron-page-BUJOuuKX.js.map} +1 -1
- package/dist/gateway/static/root/assets/{cron-utils-BJma9IcD.js → cron-utils-Cn0YVg8x.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-utils-BJma9IcD.js.map → cron-utils-Cn0YVg8x.js.map} +1 -1
- package/dist/gateway/static/root/assets/electron-env-D9bm1FIu.js +2 -0
- package/dist/gateway/static/root/assets/electron-env-D9bm1FIu.js.map +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BCVoNSo6.js → extension-debug-page-DTz4O5Ua.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-BCVoNSo6.js.map → extension-debug-page-DTz4O5Ua.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-PWB-Pw2d.js → extension-iframe-host-Cs1Kde9o.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-iframe-host-PWB-Pw2d.js.map → extension-iframe-host-Cs1Kde9o.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D2tTklsD.js → extension-page-G52iX0Bo.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-page-D2tTklsD.js.map → extension-page-G52iX0Bo.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-BpHodVRj.js → extension-provider-CO2jxBA9.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-provider-BpHodVRj.js.map → extension-provider-CO2jxBA9.js.map} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BEu6Xw1Z.js → extension-settings-page-D9Ul8uSt.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-settings-page-BEu6Xw1Z.js.map → extension-settings-page-D9Ul8uSt.js.map} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-C7ZFPhNj.js → gateway-config-swr-Bc8SVD15.js} +2 -2
- package/dist/gateway/static/root/assets/{gateway-config-swr-C7ZFPhNj.js.map → gateway-config-swr-Bc8SVD15.js.map} +1 -1
- package/dist/gateway/static/root/assets/index-BXUJbteW.js +16 -0
- package/dist/gateway/static/root/assets/index-BXUJbteW.js.map +1 -0
- package/dist/gateway/static/root/assets/index-CQLMxWSA.css +2 -0
- package/dist/gateway/static/root/assets/{logs-page-BpsxYdcL.js → logs-page-5V25JkQY.js} +2 -2
- package/dist/gateway/static/root/assets/{logs-page-BpsxYdcL.js.map → logs-page-5V25JkQY.js.map} +1 -1
- package/dist/gateway/static/root/assets/{model-selector-BiiDq8Pk.js → model-selector-he3aQfme.js} +2 -2
- package/dist/gateway/static/root/assets/{model-selector-BiiDq8Pk.js.map → model-selector-he3aQfme.js.map} +1 -1
- package/dist/gateway/static/root/assets/navigation-DB9S-C6S.js +2 -0
- package/dist/gateway/static/root/assets/navigation-DB9S-C6S.js.map +1 -0
- package/dist/gateway/static/root/assets/page-header-store-DJHD9Ean.js +2 -0
- package/dist/gateway/static/root/assets/{page-header-store-HcRZK5CZ.js.map → page-header-store-DJHD9Ean.js.map} +1 -1
- package/dist/gateway/static/root/assets/{session-api-DxNaAkmX.js → session-api-n-4O5d9U.js} +2 -2
- package/dist/gateway/static/root/assets/{session-api-DxNaAkmX.js.map → session-api-n-4O5d9U.js.map} +1 -1
- package/dist/gateway/static/root/assets/{session-working-directory-control-CDH-Wk4E.js → session-working-directory-control-B6dHLvbr.js} +3 -3
- package/dist/gateway/static/root/assets/{session-working-directory-control-CDH-Wk4E.js.map → session-working-directory-control-B6dHLvbr.js.map} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-5PK75r1n.js → sessions-page-rBUfTdm3.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-5PK75r1n.js.map → sessions-page-rBUfTdm3.js.map} +1 -1
- package/dist/gateway/static/root/assets/settings-page-B3QrJm-E.js +2 -0
- package/dist/gateway/static/root/assets/settings-page-B3QrJm-E.js.map +1 -0
- package/dist/gateway/static/root/assets/{skill-api-CxbNlOD_.js → skill-api-vxtE8kI6.js} +2 -2
- package/dist/gateway/static/root/assets/{skill-api-CxbNlOD_.js.map → skill-api-vxtE8kI6.js.map} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Dd8ZzYJb.js → skills-page-D36_O2Ub.js} +2 -2
- package/dist/gateway/static/root/assets/{skills-page-Dd8ZzYJb.js.map → skills-page-D36_O2Ub.js.map} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CPTH77BE.js → theme-store-CmiSsYBd.js} +2 -2
- package/dist/gateway/static/root/assets/{theme-store-CPTH77BE.js.map → theme-store-CmiSsYBd.js.map} +1 -1
- package/dist/gateway/static/root/assets/url-CtSqjF9J.js +2 -0
- package/dist/gateway/static/root/assets/url-CtSqjF9J.js.map +1 -0
- package/dist/gateway/static/root/assets/{useTranslation-BEUWOMuh.js → useTranslation-DYORQ7x6.js} +2 -2
- package/dist/gateway/static/root/assets/{useTranslation-BEUWOMuh.js.map → useTranslation-DYORQ7x6.js.map} +1 -1
- package/dist/gateway/static/root/index.html +16 -16
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/image/index.d.ts +0 -1
- package/dist/src/agent/image/index.js +1 -2
- package/dist/src/agent/ipc/bus.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
- package/dist/src/agent/service.js +3 -3
- package/dist/src/agent/skills/hub-hash.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/tools/browser/tools.js +2 -2
- package/dist/src/agent/tools/browser/tools.js.map +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/image-tool.js +2 -2
- package/dist/src/agent/tools/image-tool.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +1 -1
- package/dist/src/agent/tools/index.js +2 -2
- package/dist/src/agent/tools/read.d.ts +0 -2
- package/dist/src/agent/tools/read.js +1 -3
- package/dist/src/agent/tools/read.js.map +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/channels/plugin-types.d.ts +14 -0
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/doctor/checks/channel-config.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/channel-config.js +113 -0
- package/dist/src/cli/commands/doctor/checks/channel-config.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/channel-plugins.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/channel-plugins.js +47 -0
- package/dist/src/cli/commands/doctor/checks/channel-plugins.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/config-health.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/config-health.js +82 -0
- package/dist/src/cli/commands/doctor/checks/config-health.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/cron-health.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/cron-health.js +116 -0
- package/dist/src/cli/commands/doctor/checks/cron-health.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/gateway-health.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/gateway-health.js +64 -0
- package/dist/src/cli/commands/doctor/checks/gateway-health.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/gateway-service.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/gateway-service.js +64 -0
- package/dist/src/cli/commands/doctor/checks/gateway-service.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/node-version.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/node-version.js +33 -0
- package/dist/src/cli/commands/doctor/checks/node-version.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/provider-auth.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +91 -0
- package/dist/src/cli/commands/doctor/checks/provider-auth.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/security-audit.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/security-audit.js +85 -0
- package/dist/src/cli/commands/doctor/checks/security-audit.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/session-integrity.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +118 -0
- package/dist/src/cli/commands/doctor/checks/session-integrity.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/state-integrity.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +99 -0
- package/dist/src/cli/commands/doctor/checks/state-integrity.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/version-check.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/version-check.js +71 -0
- package/dist/src/cli/commands/doctor/checks/version-check.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/workspace-status.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +73 -0
- package/dist/src/cli/commands/doctor/checks/workspace-status.js.map +1 -0
- package/dist/src/cli/commands/doctor/flow.d.ts +9 -0
- package/dist/src/cli/commands/doctor/flow.js +51 -0
- package/dist/src/cli/commands/doctor/flow.js.map +1 -0
- package/dist/src/cli/commands/doctor/format.d.ts +6 -0
- package/dist/src/cli/commands/doctor/format.js +61 -0
- package/dist/src/cli/commands/doctor/format.js.map +1 -0
- package/dist/src/cli/commands/doctor/index.js +44 -0
- package/dist/src/cli/commands/doctor/index.js.map +1 -0
- package/dist/src/cli/commands/doctor/types.d.ts +20 -0
- package/dist/src/cli/commands/doctor/types.js +1 -0
- package/dist/src/cli/commands/init.js +2 -2
- package/dist/src/cli/index.d.ts +1 -1
- package/dist/src/cli/index.js +1 -1
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/utils/init-workspace.js +1 -1
- package/dist/src/config/index.js +3 -3
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.d.ts +15 -15
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/profile.js +1 -1
- package/dist/src/config/schema.d.ts +0 -105
- package/dist/src/config/schema.js +3 -40
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/cron/executor.js +2 -2
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/launchd.js.map +1 -1
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/daemon/systemd.js.map +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/lib/static-ui.js +1 -1
- package/dist/src/gateway/hono/routes/doctor.d.ts +3 -0
- package/dist/src/gateway/hono/routes/doctor.js +35 -0
- package/dist/src/gateway/hono/routes/doctor.js.map +1 -0
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/index.js.map +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +2 -2
- package/dist/src/gateway/hono/sse.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/ports.js +98 -3
- package/dist/src/gateway/ports.js.map +1 -1
- package/dist/src/gateway/service.d.ts +0 -4
- package/dist/src/gateway/service.js +4 -23
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/routing/bindings.js +1 -1
- package/dist/src/routing/index.d.ts +1 -1
- package/dist/src/routing/index.js +2 -2
- package/dist/src/routing/index.js.map +1 -1
- package/dist/src/routing/resolve-route.js +1 -1
- package/dist/src/routing/session-key.d.ts +0 -5
- package/dist/src/routing/session-key.js +1 -27
- package/dist/src/routing/session-key.js.map +1 -1
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.js +2 -6
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/types.d.ts +0 -10
- package/dist/src/session/types.js.map +1 -1
- package/package.json +1 -2
- package/dist/gateway/static/root/assets/attachment-load-6pRlDPZ8.js +0 -1
- package/dist/gateway/static/root/assets/index-DBZ5eXW5.js +0 -16
- package/dist/gateway/static/root/assets/index-DBZ5eXW5.js.map +0 -1
- package/dist/gateway/static/root/assets/index-KsVMH-Jo.css +0 -2
- package/dist/gateway/static/root/assets/navigation-BpLKd2Ca.js +0 -2
- package/dist/gateway/static/root/assets/navigation-BpLKd2Ca.js.map +0 -1
- package/dist/gateway/static/root/assets/page-header-store-HcRZK5CZ.js +0 -2
- package/dist/gateway/static/root/assets/preference-select-fields-B4AJBqUY.js +0 -2
- package/dist/gateway/static/root/assets/preference-select-fields-B4AJBqUY.js.map +0 -1
- package/dist/gateway/static/root/assets/settings-page-BvSj0JqX.js +0 -2
- package/dist/gateway/static/root/assets/settings-page-BvSj0JqX.js.map +0 -1
- package/dist/gateway/static/root/assets/url-QmwQTJ-j.js +0 -2
- package/dist/gateway/static/root/assets/url-QmwQTJ-j.js.map +0 -1
- package/dist/src/acp/commands.d.ts +0 -11
- package/dist/src/acp/commands.js +0 -17
- package/dist/src/acp/commands.js.map +0 -1
- package/dist/src/acp/control-plane/identity-reconcile.d.ts +0 -36
- package/dist/src/acp/control-plane/identity-reconcile.js +0 -124
- package/dist/src/acp/control-plane/identity-reconcile.js.map +0 -1
- package/dist/src/acp/control-plane/index.d.ts +0 -10
- package/dist/src/acp/control-plane/index.js +0 -6
- package/dist/src/acp/control-plane/manager.d.ts +0 -86
- package/dist/src/acp/control-plane/manager.js +0 -502
- package/dist/src/acp/control-plane/manager.js.map +0 -1
- package/dist/src/acp/control-plane/manager.types.d.ts +0 -125
- package/dist/src/acp/control-plane/manager.types.js +0 -14
- package/dist/src/acp/control-plane/manager.types.js.map +0 -1
- package/dist/src/acp/control-plane/manager.utils.d.ts +0 -29
- package/dist/src/acp/control-plane/manager.utils.js +0 -46
- package/dist/src/acp/control-plane/manager.utils.js.map +0 -1
- package/dist/src/acp/control-plane/runtime-cache-manager.d.ts +0 -49
- package/dist/src/acp/control-plane/runtime-cache-manager.js +0 -155
- package/dist/src/acp/control-plane/runtime-cache-manager.js.map +0 -1
- package/dist/src/acp/control-plane/runtime-cache.d.ts +0 -45
- package/dist/src/acp/control-plane/runtime-cache.js +0 -58
- package/dist/src/acp/control-plane/runtime-cache.js.map +0 -1
- package/dist/src/acp/control-plane/runtime-options.d.ts +0 -30
- package/dist/src/acp/control-plane/runtime-options.js +0 -92
- package/dist/src/acp/control-plane/runtime-options.js.map +0 -1
- package/dist/src/acp/control-plane/session-actor-queue.d.ts +0 -22
- package/dist/src/acp/control-plane/session-actor-queue.js +0 -70
- package/dist/src/acp/control-plane/session-actor-queue.js.map +0 -1
- package/dist/src/acp/control-plane/session-lifecycle-manager.d.ts +0 -59
- package/dist/src/acp/control-plane/session-lifecycle-manager.js +0 -209
- package/dist/src/acp/control-plane/session-lifecycle-manager.js.map +0 -1
- package/dist/src/acp/control-plane/session-store.d.ts +0 -39
- package/dist/src/acp/control-plane/session-store.js +0 -149
- package/dist/src/acp/control-plane/session-store.js.map +0 -1
- package/dist/src/acp/control-plane/turn-manager.d.ts +0 -40
- package/dist/src/acp/control-plane/turn-manager.js +0 -134
- package/dist/src/acp/control-plane/turn-manager.js.map +0 -1
- package/dist/src/acp/event-mapper.d.ts +0 -48
- package/dist/src/acp/event-mapper.js +0 -94
- package/dist/src/acp/event-mapper.js.map +0 -1
- package/dist/src/acp/index.d.ts +0 -10
- package/dist/src/acp/index.js +0 -5
- package/dist/src/acp/meta.d.ts +0 -15
- package/dist/src/acp/meta.js +0 -36
- package/dist/src/acp/meta.js.map +0 -1
- package/dist/src/acp/routing-integration.d.ts +0 -37
- package/dist/src/acp/routing-integration.js +0 -58
- package/dist/src/acp/routing-integration.js.map +0 -1
- package/dist/src/acp/runtime/backends/index.d.ts +0 -4
- package/dist/src/acp/runtime/backends/index.js +0 -2
- package/dist/src/acp/runtime/backends/local.d.ts +0 -136
- package/dist/src/acp/runtime/backends/local.js +0 -603
- package/dist/src/acp/runtime/backends/local.js.map +0 -1
- package/dist/src/acp/runtime/error-text.d.ts +0 -16
- package/dist/src/acp/runtime/error-text.js +0 -40
- package/dist/src/acp/runtime/error-text.js.map +0 -1
- package/dist/src/acp/runtime/errors.d.ts +0 -31
- package/dist/src/acp/runtime/errors.js +0 -47
- package/dist/src/acp/runtime/errors.js.map +0 -1
- package/dist/src/acp/runtime/index.d.ts +0 -7
- package/dist/src/acp/runtime/index.js +0 -4
- package/dist/src/acp/runtime/registry.d.ts +0 -35
- package/dist/src/acp/runtime/registry.js +0 -85
- package/dist/src/acp/runtime/registry.js.map +0 -1
- package/dist/src/acp/runtime/session-identity.d.ts +0 -35
- package/dist/src/acp/runtime/session-identity.js +0 -134
- package/dist/src/acp/runtime/session-identity.js.map +0 -1
- package/dist/src/acp/runtime/types.d.ts +0 -214
- package/dist/src/acp/secret-file.d.ts +0 -7
- package/dist/src/acp/secret-file.js +0 -19
- package/dist/src/acp/secret-file.js.map +0 -1
- package/dist/src/acp/server.d.ts +0 -48
- package/dist/src/acp/server.js +0 -300
- package/dist/src/acp/server.js.map +0 -1
- package/dist/src/acp/session.d.ts +0 -29
- package/dist/src/acp/session.js +0 -30
- package/dist/src/acp/session.js.map +0 -1
- package/dist/src/acp/types.d.ts +0 -39
- package/dist/src/acp/types.js +0 -13
- package/dist/src/acp/types.js.map +0 -1
- package/dist/src/agent/image/describe-images.d.ts +0 -18
- package/dist/src/agent/image/describe-images.js +0 -19
- package/dist/src/agent/image/describe-images.js.map +0 -1
- package/dist/src/cli/commands/acp.d.ts +0 -4
- package/dist/src/cli/commands/acp.js +0 -200
- package/dist/src/cli/commands/acp.js.map +0 -1
- /package/dist/src/{acp/runtime/types.js → cli/commands/doctor/index.d.ts} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{i as t,t as n}from"./vendor-react-QAsRxa6t.js";import{l as r,n as i,o as a,r as o,s,t as c}from"./url-QmwQTJ-j.js";import{a as l,r as u}from"./vendor-swr-8rdcElid.js";import{r as d,t as f,u as p}from"./chunk-QFMPRPBF-DOYp8d2p.js";import{n as m,t as h}from"./cn-DPF56z7S.js";import{y as g}from"./settings-nav-state-BSa0kz44.js";import{a as _,c as v,d as y,f as b,h as x,l as S,m as C,o as ee,p as w,s as T,t as E,u as D}from"./preference-select-fields-B4AJBqUY.js";import{t as O}from"./check-CDc_K89l.js";import{t as te}from"./chevron-down-DUplxB5j.js";import{t as ne}from"./chevron-right-DmT4UtDa.js";import{s as k}from"./model-selector-BiiDq8Pk.js";import{a as A,n as re,o as ie,s as j}from"./navigation-BpLKd2Ca.js";import{t as ae}from"./external-link-DxIqSrRZ.js";import{i as M,n as N,r as oe}from"./gateway-config-swr-C7ZFPhNj.js";import{t as P}from"./info-Ccltk00r.js";import{t as se}from"./zap-C4SJDlFg.js";import{t as F}from"./loader-circle-B2bCE4iI.js";import{t as I}from"./plus-CBODkzSX.js";import{t as L}from"./refresh-cw-D7hzzeQ5.js";import{t as R}from"./search-DoMetBR0.js";import{t as z}from"./trash-2-D9v5oysq.js";import{a as B,i as ce,n as V,o as H,s as U,t as W}from"./dist-Db1dcLr9.js";import{t as G}from"./button-CRQ9eQGX.js";import{i as K,o as le,s as q}from"./form-field-width-BlpNwrfn.js";import{i as ue}from"./theme-store-CPTH77BE.js";import{a as de,i as fe,n as pe,o as me,r as he,t as ge}from"./dist-CpMMntuC.js";import{n as J}from"./interaction-C4gx-xSs.js";import{a as _e,p as ve,v as ye}from"./cron-utils-BJma9IcD.js";import{n as be,r as xe,t as Se}from"./agents-B6s2BvpH.js";var Y=n();function Ce(){return h(`rounded-xl border border-edge-subtle bg-surface-base px-4 py-1 sm:px-5`)}function we({scheme:e}){return e===`emerald`?(0,Y.jsxs)(`div`,{className:`flex h-10 w-full overflow-hidden rounded-md border border-edge-subtle`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 bg-[#0a0a0a] p-1.5`,children:[(0,Y.jsx)(`div`,{className:`h-1 w-8 rounded-full bg-[#134e2a]`}),(0,Y.jsx)(`div`,{className:`h-1 w-5 rounded-full bg-[#134e2a]`})]}),(0,Y.jsx)(`div`,{className:`w-1.5 bg-[#10b981]`}),(0,Y.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 bg-[#000000] p-1.5`,children:[(0,Y.jsx)(`div`,{className:`h-1 w-6 rounded-full bg-[#34d399]`}),(0,Y.jsx)(`div`,{className:`h-1 w-9 rounded-full bg-[#065f46]`}),(0,Y.jsx)(`div`,{className:`h-1 w-4 rounded-full bg-[#065f46]`})]})]}):(0,Y.jsxs)(`div`,{className:`flex h-10 w-full overflow-hidden rounded-md border border-edge-subtle`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 bg-[#f5f5f7] p-1.5`,children:[(0,Y.jsx)(`div`,{className:`h-1 w-8 rounded-full bg-[#d2d2d7]`}),(0,Y.jsx)(`div`,{className:`h-1 w-5 rounded-full bg-[#d2d2d7]`})]}),(0,Y.jsx)(`div`,{className:`w-1.5 bg-[#2563eb]`}),(0,Y.jsxs)(`div`,{className:`flex flex-1 flex-col gap-1 bg-[#ffffff] p-1.5`,children:[(0,Y.jsx)(`div`,{className:`h-1 w-6 rounded-full bg-[#1d1d1f]`}),(0,Y.jsx)(`div`,{className:`h-1 w-9 rounded-full bg-[#d2d2d7]`}),(0,Y.jsx)(`div`,{className:`h-1 w-4 rounded-full bg-[#d2d2d7]`})]})]})}var Te=[{value:`default`,labelKey:`colorSchemeDefault`},{value:`emerald`,labelKey:`colorSchemeLightGreen`}];function Ee(){let e=r(s(e=>e.language)).appearanceSettings,t=ue(e=>e.colorScheme),n=ue(e=>e.setColorScheme);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-edge-subtle py-3.5 last:border-b-0 sm:py-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:e.colorSchemeTitle}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:e.colorSchemeDescription})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3`,children:Te.map(({value:r,labelKey:i})=>{let a=t===r;return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":a,onClick:()=>n(r),className:h(`flex flex-col gap-2 rounded-xl border-2 p-2.5 text-left transition-[border-color,box-shadow] duration-150`,a?`border-accent shadow-[0_0_0_1px_var(--color-accent)]`:`border-edge-subtle hover:border-edge`),children:[(0,Y.jsx)(we,{scheme:r}),(0,Y.jsx)(`span`,{className:h(`text-xs font-medium leading-none`,a?`text-accent-fg`:`text-fg-muted`),children:e[i]})]},r)})})]})}function De(){let e=r(s(e=>e.language)).appearanceSettings;return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:e.pageTitle}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.subtitle})]}),(0,Y.jsxs)(`section`,{className:Ce(),"aria-labelledby":`pref-language-heading`,children:[(0,Y.jsx)(`h2`,{id:`pref-language-heading`,className:`sr-only`,children:e.languageTitle}),(0,Y.jsx)(E,{variant:`page`,sections:[`language`]})]}),(0,Y.jsxs)(`section`,{className:Ce(),"aria-labelledby":`pref-appearance-heading`,children:[(0,Y.jsx)(`h2`,{id:`pref-appearance-heading`,className:`sr-only`,children:e.themeTitle}),(0,Y.jsx)(E,{variant:`page`,sections:[`theme`,`font`]}),(0,Y.jsx)(Ee,{})]})]})}var X=e(t(),1);function Oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ke(e){let t=Oe(e)?e:{},n=Oe(t.gateway)?t.gateway:{},r=Oe(n.auth)?n.auth:{},i=r.mode===`none`||r.mode===`token`?r.mode:`token`;return{host:typeof n.host==`string`?n.host:``,port:typeof n.port==`number`?n.port:void 0,auth:{mode:i,token:typeof r.token==`string`?r.token:``}}}async function Ae(e){let t=e.auth.token.trim().length>0?{mode:e.auth.mode,token:e.auth.token}:{mode:e.auth.mode};await o(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{auth:t}})}),N()}function je(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function Me(){let e=s(e=>e.language),t=r(e),n=t.gatewaySettings,i=a(e=>e.token),o=a(e=>e.tokenExpired),c=a(e=>e.openTokenDialog),l=!!i,[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,w]=(0,X.useState)(!1),T=(0,X.useRef)(!1),{data:E,error:D,isLoading:O,mutate:te}=oe(l),ne=(0,X.useMemo)(()=>E?.payload?.config===void 0?null:structuredClone(ke(E.payload.config)),[E]);(0,X.useEffect)(()=>{if(!l){d(null),p(null),T.current=!1;return}ne!==null&&(T.current||(d(ne),p(structuredClone(ne)),y(!1)))},[l,ne]);let k=!!(l&&O&&E===void 0&&!D),A=D instanceof Error?D.message:D?String(D):null,ie=(0,X.useMemo)(()=>!u||!f?!1:JSON.stringify(u)!==JSON.stringify(f),[u,f]),j=(0,X.useCallback)(e=>{T.current=!0,d(t=>t?{...t,auth:{...t.auth,...e}}:null)},[]),M=(0,X.useCallback)(async()=>{if(!(!u||m)){h(!0),_(null),y(!1);try{await Ae(u),T.current=!1,p(structuredClone(u)),y(!0),window.setTimeout(()=>y(!1),2500)}catch(e){_(e instanceof Error?e.message:n.saveError)}finally{h(!1)}}},[u,m,n.saveError]),N=(0,X.useCallback)(async()=>{let e=u?.auth.token;e&&(await navigator.clipboard.writeText(e).catch(()=>{}),w(!0),window.setTimeout(()=>w(!1),2e3))},[u?.auth.token]);return l?k?(0,Y.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Y.jsx)(F,{className:`size-4 animate-spin`}),n.loading]})}):u?(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.gateway}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,Y.jsxs)(`a`,{href:re(e,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,Y.jsx)(ae,{className:`size-3.5`})]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[v?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,(0,Y.jsx)(G,{type:`button`,variant:`primary`,disabled:!ie||m,onClick:()=>void M(),children:m?n.saving:n.save})]})]}),o?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,Y.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>c(),children:n.updateToken})})]}):null,ie?(0,Y.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,g?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,u.auth.mode===`none`?(0,Y.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,Y.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Y.jsxs)(`div`,{className:`mb-5 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Y.jsx)(ee,{className:`size-4 text-accent`,strokeWidth:1.75}),t.settingsSections.gateway]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(u.host||u.port!=null)&&(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.listenHost}),(0,Y.jsx)(`div`,{className:`rounded-lg bg-surface-hover/80 px-3 py-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/50`,children:u.host||`—`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.listenPort}),(0,Y.jsx)(`div`,{className:`rounded-lg bg-surface-hover/80 px-3 py-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/50`,children:u.port==null?`—`:String(u.port)})]}),(0,Y.jsx)(`p`,{className:`sm:col-span-2 text-xs text-fg-subtle`,children:n.listenHint})]}),(0,Y.jsx)(Ne,{g:n,value:u.auth.token,show:b,copied:S,onToggleShow:()=>x(e=>!e),onCopy:()=>void N(),onChange:e=>j({token:e})}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>c(),children:n.changeToken})]})]})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??A??n.loadError}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>void te(),children:n.retry})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.gateway}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Ne({g:e,value:t,show:n,copied:r,onToggleShow:i,onCopy:a,onChange:o}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.accessToken}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(`input`,{className:h(je(),`min-w-0 flex-1 font-mono text-xs`),type:n?`text`:`password`,autoComplete:`off`,value:t,onChange:e=>o(e.target.value),placeholder:e.tokenPlaceholder}),t?(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:a,children:[r?(0,Y.jsx)(O,{className:`size-3.5`}):(0,Y.jsx)(j,{className:`size-3.5`}),r?e.copied:e.copy]}):null,(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:i,children:[n?(0,Y.jsx)(ie,{className:`size-3.5`}):(0,Y.jsx)(M,{className:`size-3.5`}),n?e.hide:e.show]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tokenHelp})]})}function Pe(){return c(`/api/channels/status`)}var Fe=ve;function Ie(){return c(`/api/workspace/heartbeat-md`)}async function Le(){let e=await o(Ie());return typeof e.payload?.content==`string`?e.payload.content:``}function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e){let t=Re(e)?e:{},n=Re(t.gateway)?t.gateway:{},r=Re(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=Re(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function Be(e){let t={enabled:e.enabled,intervalMs:e.intervalMs};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function Ve(e){await o(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:Be(e)}})}),N()}async function He(e){await o(c(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),l(Ie())}async function Ue(e){await o(c(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var We=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5],Ge=new Set(We);function Ke(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function qe(){return h(le,K)}function Je(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults;if(!n||typeof n!=`object`||Array.isArray(n))return``;let r=n.workspace;return typeof r==`string`?r:``}function Ye(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function Xe(){let e=s(e=>e.language),t=r(e),n=t.heartbeatSettings,i=!!a(e=>e.token),[o,c]=(0,X.useState)(null),[l,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(``),[m,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(!1),[y,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[ee,w]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,te]=(0,X.useState)(!1),[ne,k]=(0,X.useState)(!1),[A,ie]=(0,X.useState)(null),[j,M]=(0,X.useState)([]),{data:N,error:P,isLoading:se,mutate:I}=oe(i),{data:L,error:R,isLoading:z,mutate:B}=u(i?Ie():null,Le,{revalidateOnFocus:!1}),{data:ce=[]}=u(i?Pe():null,Fe,{revalidateOnFocus:!1}),V=(0,X.useMemo)(()=>Je(N?.payload?.config),[N]),H=(0,X.useMemo)(()=>ze(N?.payload?.config??{}),[N]),U=(0,X.useMemo)(()=>!o||!l?!1:JSON.stringify(o)!==JSON.stringify(l),[o,l]),W=(0,X.useMemo)(()=>f!==m,[f,m]);(0,X.useEffect)(()=>{if(!i){c(null),d(null);return}if(N!==void 0&&!U){let e=structuredClone(H);c(e),d(e),w(!1)}},[i,N,H,U]),(0,X.useEffect)(()=>{!i||L===void 0||W||(p(L),g(L),D(!1))},[i,L,W]);let K=P instanceof Error?P.message:P?String(P):R instanceof Error?R.message:R?String(R):null,le=!!(i&&(N===void 0||L===void 0)&&!K&&(se||z));(0,X.useEffect)(()=>{if(!i||!o){M([]);return}let e=o.target.trim();if(!e){M([]);return}let t=!1;return ye(e).then(e=>{t||M(e)}),()=>{t=!0}},[i,o?.target]);let q=(0,X.useCallback)(()=>{let e=o?.target?.trim();e&&ye(e).then(M)},[o?.target]),ue=(0,X.useCallback)(async()=>{te(!0),k(!1),ie(null);try{await Ue(),k(!0),window.setTimeout(()=>k(!1),3e3)}catch(e){ie(e instanceof Error?e.message:n.triggerError)}finally{te(!1)}},[n.triggerError]),de=(0,X.useCallback)(e=>{c(t=>t?{...t,...e}:null)},[]),fe=(0,X.useCallback)(async()=>{if(!(!o||_)){v(!0),C(null),w(!1);try{await Ve(o),d(structuredClone(o)),w(!0),window.setTimeout(()=>w(!1),2500)}catch(e){C(e instanceof Error?e.message:n.saveConfigError)}finally{v(!1)}}},[o,_,n.saveConfigError]),pe=(0,X.useCallback)(async()=>{if(!y){x(!0),C(null),D(!1);try{await He(f),g(f),D(!0),window.setTimeout(()=>D(!1),2500)}catch(e){C(e instanceof Error?e.message:n.saveDocError)}finally{x(!1)}}},[f,y,n.saveDocError]);return i?le?(0,Y.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Y.jsx)(F,{className:`size-4 animate-spin`}),n.loading]})}):o?(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Y.jsx)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.heartbeat}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,Y.jsxs)(`a`,{href:re(e,`heartbeat`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,Y.jsx)(ae,{className:`size-3.5`})]})]})}),V?(0,Y.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,Y.jsx)(`span`,{className:`font-mono text-fg-muted`,children:V})]}):null,S?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null,(0,Y.jsxs)(be,{children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Y.jsx)(b,{className:`size-4 text-accent`,strokeWidth:1.75}),n.configSection]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:O,onClick:()=>void ue(),children:[O?(0,Y.jsx)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(T,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),O?n.triggering:n.triggerNow]}),ne?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})]}),(0,Y.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:n.triggerHint}),A?(0,Y.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:A}):null,(0,Y.jsx)(Ze,{h:n,cron:t.cron,form:o,channels:ce,sessionChatIds:j,onRefreshChatIds:q,update:de,inputClassName:Ke,selectClassName:qe}),(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[ee?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.savedConfig}):null,(0,Y.jsx)(G,{type:`button`,variant:`primary`,disabled:!U||_,onClick:()=>void fe(),children:_?n.savingConfig:n.saveConfig}),U?(0,Y.jsx)(`span`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedConfig}):null]})]}),(0,Y.jsxs)(be,{children:[(0,Y.jsx)(`div`,{className:`mb-2 text-sm font-semibold text-fg`,children:n.docSection}),(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,Y.jsx)(`textarea`,{className:h(Ke(),`min-h-[12rem] resize-y font-mono text-xs leading-relaxed`),value:f,onChange:e=>p(e.target.value),spellCheck:!1,"aria-label":n.docSection}),(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[E?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.savedDoc}):null,(0,Y.jsx)(G,{type:`button`,variant:`primary`,disabled:!W||y,onClick:()=>void pe(),children:y?n.savingDoc:n.saveDoc}),W?(0,Y.jsx)(`span`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedDoc}):null]})]})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:S??K??n.loadError}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>{I(),B()},children:n.retry})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.heartbeat}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Ze({h:e,cron:t,form:n,channels:r,sessionChatIds:i,onRefreshChatIds:a,update:o,inputClassName:s,selectClassName:c}){let l=(0,X.useMemo)(()=>new Set(r.map(e=>e.name)),[r]),u=n.target.trim(),d=!!(u&&!l.has(u)),f=(0,X.useMemo)(()=>Ge.has(n.intervalMs)?String(n.intervalMs):``,[n.intervalMs]),[p,m]=(0,X.useState)(null),g=Math.max(1,Math.round(n.intervalMs/1e3)),_=p===null?String(g):p;return(0,X.useEffect)(()=>{m(null)},[n.intervalMs]),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.enabled,onChange:e=>o({enabled:e.target.checked})}),e.enable]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.interval}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:e.intervalSecondsLabel}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`input`,{type:`number`,min:1,step:1,className:h(s(),`min-w-0 flex-1`),value:_,onChange:e=>{let t=e.target.value;m(t);let n=parseInt(t,10);Number.isFinite(n)&&n>=1&&o({intervalMs:n*1e3})},onBlur:()=>{if(p===null)return;let e=parseInt(p,10);o(!Number.isFinite(e)||e<1?{intervalMs:1e3}:{intervalMs:e*1e3}),m(null)}}),(0,Y.jsxs)(`select`,{className:h(c(),`max-w-[11rem] shrink-0 text-xs`),value:f,onChange:e=>{let t=e.target.value;t&&(o({intervalMs:parseInt(t,10)}),m(null))},children:[(0,Y.jsx)(`option`,{value:``,children:e.intervalPresets.custom}),We.map(t=>(0,Y.jsx)(`option`,{value:String(t),children:Ye(t,e.intervalPresets)},t))]})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.intervalHintPreset}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.intervalHint})]}),(0,Y.jsxs)(`div`,{className:`border-t border-edge-subtle pt-4`,children:[(0,Y.jsx)(`div`,{className:`mb-2 text-sm font-medium text-fg`,children:e.deliveryTitle}),(0,Y.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:t.channel}),(0,Y.jsxs)(`select`,{className:c(),value:u,onChange:e=>{o({target:e.target.value.trim(),targetChatId:``})},children:[(0,Y.jsx)(`option`,{value:``,children:e.channelNone}),d?(0,Y.jsxs)(`option`,{value:u,children:[u,` (`,e.customChannelSuffix,`)`]}):null,r.map(e=>(0,Y.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name))]})]}),u?(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:t.recipient}),(0,Y.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:t.refreshRecipientHint,onClick:a,children:[(0,Y.jsx)(L,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t.refreshList]})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`input`,{type:`text`,className:h(s(),`min-w-0 flex-1`),value:n.targetChatId,onChange:e=>o({targetChatId:e.target.value}),placeholder:t.recipientPlaceholder,autoComplete:`off`}),(0,Y.jsxs)(`select`,{className:h(c(),`max-w-[10rem] shrink-0 text-xs`),value:n.targetChatId,onChange:e=>{let t=e.target.value;t&&o({targetChatId:t})},children:[(0,Y.jsx)(`option`,{value:``,children:t.selectRecipient}),i.length>0?i.map(e=>(0,Y.jsx)(`option`,{value:e.chatId,children:_e(e,t.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,Y.jsx)(`option`,{value:``,disabled:!0,children:t.noRecentChatsOption})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.length>0?t.enterManuallyOrSelect:t.noRecentChats})]}):null,(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.deliveryHint})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:e.prompt}),(0,Y.jsx)(`textarea`,{className:h(s(),`min-h-[4.5rem] resize-y font-mono text-xs`),value:n.prompt,onChange:e=>o({prompt:e.target.value}),placeholder:e.promptPlaceholder}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.promptHint})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:e.ackMaxChars}),(0,Y.jsx)(`input`,{type:`number`,min:1,className:s(),value:n.ackMaxChars===``?``:n.ackMaxChars,onChange:e=>{let t=e.target.value;if(t===``)o({ackMaxChars:``});else{let e=parseInt(t,10);o({ackMaxChars:Number.isFinite(e)?e:``})}},placeholder:e.ackDefaultPlaceholder}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.ackMaxCharsHint})]}),(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:n.isolatedSession,onChange:e=>o({isolatedSession:e.target.checked})}),(0,Y.jsxs)(`span`,{children:[e.isolatedSession,(0,Y.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:e.isolatedSessionHint})]})]}),(0,Y.jsxs)(`div`,{className:`border-t border-edge-subtle pt-4`,children:[(0,Y.jsx)(`div`,{className:`mb-2 text-sm font-medium text-fg`,children:e.activeHoursTitle}),n.activeHours?(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-xs text-fg`,children:e.activeStart}),(0,Y.jsx)(`input`,{className:s(),value:n.activeHours.start,onChange:e=>o({activeHours:{...n.activeHours,start:e.target.value}}),placeholder:`09:00`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-xs text-fg`,children:e.activeEnd}),(0,Y.jsx)(`input`,{className:s(),value:n.activeHours.end,onChange:e=>o({activeHours:{...n.activeHours,end:e.target.value}}),placeholder:`22:00`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`mb-1 text-xs text-fg`,children:e.activeTimezone}),(0,Y.jsx)(`input`,{className:s(),value:n.activeHours.timezone,onChange:e=>o({activeHours:{...n.activeHours,timezone:e.target.value}}),placeholder:`Asia/Shanghai`})]})]}):(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>o({activeHours:{start:`09:00`,end:`22:00`,timezone:``}}),children:e.addActiveHours}),n.activeHours?(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`text-xs`,onClick:()=>o({activeHours:null}),children:e.clearActiveHours})}):null,(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.activeHoursHint})]})]})}var Qe=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function $e(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function et(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function tt(){let e=await i(c(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error($e(t)||`HTTP ${e.status}`);return{...t.payload,config:et(t.payload.config)}}async function nt(e){let t=await i(c(`/api/models-json/validate`),{method:`POST`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error($e(n)||`HTTP ${t.status}`);return n.payload}async function rt(e){let t=await i(c(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error($e(n)||`HTTP ${t.status}`);return n.payload}async function it(){let e=await i(c(`/api/models-json/reload`),{method:`POST`}),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error($e(t)||`HTTP ${e.status}`);return t.payload}async function at(e){let t=await i(c(`/api/models-json/test-api-key`),{method:`POST`,body:JSON.stringify({value:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error($e(n)||`HTTP ${t.status}`);return n.payload}function ot(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}function st(e){return e.startsWith(`!`)}function ct(e){return/^[A-Z][A-Z0-9_]*$/.test(e)}function lt(e){return st(e)?`shell`:ct(e)?`env`:`literal`}function ut(e){return e?e.length<=8?`••••`:`${e.slice(0,4)}••••${e.slice(-4)}`:``}var dt={ollama:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`},lmstudio:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`},openrouter:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``},zhipuCn:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`},zaiGeneral:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`}};function ft(e){return e===`openrouter`?`openrouter`:e===`zhipuCn`?`zhipu-cn`:e===`zaiGeneral`?`zai`:e}var pt=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function Z(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function mt(){return h(le,K)}function ht(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function gt(e){return e===`text,image`?[`text`,`image`]:[`text`]}function _t(e,t,n){return{...e,providers:{...e.providers,[t]:{...e.providers[t],...n}}}}function vt(e,t){let n={...e.providers};return delete n[t],{...e,providers:n}}function yt(e,t,n){return{...e,providers:{...e.providers,[t]:n}}}function bt({open:e,onOpenChange:t,presetKey:n,onConfirm:r,m:i}){let[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(`custom`),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(`openai-completions`),[p,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(!e)return;v(null);let t=n||null;if(t&&dt[t]){let e=dt[t];c(t),u(e.baseUrl||``),f(e.api||`openai-completions`),g(e.apiKey??``),o(ft(t))}else c(`custom`),o(``),u(``),f(`openai-completions`),g(``)},[e,n]);let y=e=>{if(c(e),e===`custom`)return;let t=dt[e];t&&(u(t.baseUrl||``),f(t.api||`openai-completions`),g(t.apiKey??``),o(ft(e)))};return(0,Y.jsx)(H,{open:e,onOpenChange:t,children:(0,Y.jsxs)(B,{children:[(0,Y.jsx)(ce,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim`}),(0,Y.jsxs)(V,{className:h(`xopc-dialog-content fixed left-1/2 top-1/2 z-50 max-h-[min(90vh,640px)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(U,{className:`text-base font-semibold text-fg`,children:i.addProviderTitle}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:i.addProviderSubtitle})]}),(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,Y.jsx)(m,{className:`size-4`})})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:i.presetLabel}),(0,Y.jsxs)(`select`,{className:mt(),value:s,onChange:e=>y(e.target.value),children:[(0,Y.jsx)(`option`,{value:`custom`,children:i.presetCustom}),(0,Y.jsx)(`option`,{value:`ollama`,children:i.presetOllama}),(0,Y.jsx)(`option`,{value:`lmstudio`,children:i.presetLmStudio}),(0,Y.jsx)(`option`,{value:`openrouter`,children:i.presetOpenRouter}),(0,Y.jsx)(`option`,{value:`zhipuCn`,children:i.presetZhipuCn}),(0,Y.jsx)(`option`,{value:`zaiGeneral`,children:i.presetZaiGeneral})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[i.providerIdLabel,(0,Y.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,Y.jsx)(`input`,{className:Z(),value:a,onChange:e=>o(e.target.value),placeholder:i.providerIdPlaceholder})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:i.baseUrl}),(0,Y.jsx)(`input`,{className:Z(),value:l,onChange:e=>u(e.target.value),placeholder:`https://…`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:i.apiType}),(0,Y.jsx)(`select`,{className:mt(),value:d,onChange:e=>f(e.target.value),children:Qe.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:i.apiKey}),(0,Y.jsx)(`input`,{className:Z(),value:p,onChange:e=>g(e.target.value),placeholder:i.apiKeyPlaceholder})]}),_?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-red-600 dark:text-red-400`,children:[(0,Y.jsx)(C,{className:`size-3.5 shrink-0`}),_]}):null]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(G,{type:`button`,variant:`secondary`,children:i.cancel})}),(0,Y.jsx)(G,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:()=>{let e=a.trim();if(!e){v(i.providerIdRequired);return}v(null),r(e,{baseUrl:l.trim()||void 0,api:d,apiKey:p.trim()||void 0,models:[]}),t(!1)},children:i.addProviderConfirm})]})]})]})})}function xt({open:e,onOpenChange:t,providerId:n,model:r,isNew:i,onSave:a,m:o}){let[s,c]=(0,X.useState)(()=>ot(``)),[l,u]=(0,X.useState)(()=>new Map);(0,X.useEffect)(()=>{e&&(u(new Map),c(r?{...r}:ot(``)))},[e,r]);let d=(e,t)=>{c(n=>({...n,[e]:t})),u(t=>{let n=new Map(t);return n.delete(e),n})},f=()=>{let e=new Map;return(s.id||``).trim()||e.set(`id`,o.modelIdRequired),s.contextWindow!==void 0&&s.contextWindow<=0&&e.set(`contextWindow`,o.mustBePositive),s.maxTokens!==void 0&&s.maxTokens<=0&&e.set(`maxTokens`,o.mustBePositive),u(e),e.size===0},p=()=>{if(!f())return;let e=(s.id||``).trim();a({...s,id:e,name:s.name?.trim()||e,reasoning:s.reasoning||!1,input:s.input||[`text`],contextWindow:s.contextWindow??128e3,maxTokens:s.maxTokens??16384,cost:{input:s.cost?.input??0,output:s.cost?.output??0,cacheRead:s.cost?.cacheRead??0,cacheWrite:s.cost?.cacheWrite??0}}),t(!1)},g=ht(s);return(0,Y.jsx)(H,{open:e,onOpenChange:t,children:(0,Y.jsxs)(B,{children:[(0,Y.jsx)(ce,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim`}),(0,Y.jsxs)(V,{className:h(`xopc-dialog-content fixed left-1/2 top-1/2 z-50 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(U,{className:`text-base font-semibold text-fg`,children:i?o.addModelTitle:o.editModelTitle}),n?(0,Y.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[o.modelProviderLabel,`: `,n]}):null]}),(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":o.close,children:(0,Y.jsx)(m,{className:`size-4`})})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[o.modelId,(0,Y.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`})]}),(0,Y.jsx)(`input`,{className:h(Z(),l.has(`id`)&&`border-red-500`),value:s.id||``,onChange:e=>d(`id`,e.target.value),placeholder:`e.g. llama3.1:8b`,disabled:!i}),l.has(`id`)?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:l.get(`id`)}):null]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:o.displayName}),(0,Y.jsx)(`input`,{className:Z(),value:s.name||``,onChange:e=>d(`name`,e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:o.inputTypes}),(0,Y.jsx)(`select`,{className:mt(),value:g,onChange:e=>d(`input`,gt(e.target.value)),children:pt.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:o[e.labelKey]},e.value))})]}),(0,Y.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:s.reasoning||!1,onChange:e=>d(`reasoning`,e.target.checked)}),o.reasoning]})]}),(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:o.contextWindow}),(0,Y.jsx)(`input`,{type:`number`,min:1,className:h(Z(),l.has(`contextWindow`)&&`border-red-500`),value:s.contextWindow??128e3,onChange:e=>d(`contextWindow`,parseInt(e.target.value,10)||0)}),l.has(`contextWindow`)?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:l.get(`contextWindow`)}):null]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:o.maxOutputTokens}),(0,Y.jsx)(`input`,{type:`number`,min:1,className:h(Z(),l.has(`maxTokens`)&&`border-red-500`),value:s.maxTokens??16384,onChange:e=>d(`maxTokens`,parseInt(e.target.value,10)||0)}),l.has(`maxTokens`)?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:l.get(`maxTokens`)}):null]})]}),(0,Y.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[(0,Y.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:o.costSection}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:o.costInput}),(0,Y.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Z(),value:s.cost?.input??0,onChange:e=>d(`cost`,{...s.cost,input:parseFloat(e.target.value)||0,output:s.cost?.output??0,cacheRead:s.cost?.cacheRead??0,cacheWrite:s.cost?.cacheWrite??0})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:o.costOutput}),(0,Y.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Z(),value:s.cost?.output??0,onChange:e=>d(`cost`,{...s.cost,input:s.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:s.cost?.cacheRead??0,cacheWrite:s.cost?.cacheWrite??0})})]})]})]})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(G,{type:`button`,variant:`secondary`,children:o.cancel})}),(0,Y.jsx)(G,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:p,children:i?o.addModelConfirm:o.saveModelConfirm})]})]})]})})}function St(){let e=s(e=>e.language),t=r(e),n=t.modelsSettings,i=!!a(e=>e.token),[o,c]=(0,X.useState)({providers:{}}),[l,u]=(0,X.useState)({providers:{}}),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(),[_,v]=(0,X.useState)(!0),[y,b]=(0,X.useState)(!1),[S,ee]=(0,X.useState)(!1),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(!1),[j,N]=(0,X.useState)(null),[oe,P]=(0,X.useState)(()=>new Set),[R,B]=(0,X.useState)(!1),[ce,V]=(0,X.useState)(``),[H,U]=(0,X.useState)(null),[W,K]=(0,X.useState)(()=>new Set),[le,q]=(0,X.useState)(()=>new Map),[ue,de]=(0,X.useState)(!1),[fe,pe]=(0,X.useState)(null),[me,he]=(0,X.useState)(!1),[ge,_e]=(0,X.useState)(null),ve=(0,X.useCallback)(async e=>{let t=!e?.skipFullPageLoading;t&&v(!0),D(null);try{let e=await tt(),t=et(e.config);c(t),u(structuredClone(t)),f(e.path),m(e.loadError),N(null),k(!1)}catch(e){D(e instanceof Error?e.message:n.loadError),c({providers:{}}),u({providers:{}})}finally{t&&v(!1)}},[n.loadError]);(0,X.useEffect)(()=>{if(!i){v(!1);return}ve()},[i,ve]);let ye=(0,X.useMemo)(()=>JSON.stringify(o)!==JSON.stringify(l),[o,l]),be=(0,X.useMemo)(()=>{let e=Object.keys(o.providers),t=0;for(let e of Object.values(o.providers))t+=e.models?.length??0;return{providers:e.length,models:t}},[o.providers]),xe=e=>{P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Se=e=>{K(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ce=(0,X.useCallback)(()=>{V(JSON.stringify(o,null,2)),U(null)},[o]);(0,X.useEffect)(()=>{R&&Ce()},[R,Ce]);let we=()=>{try{c(et(JSON.parse(ce))),U(null)}catch{U(n.jsonParseError)}},Te=async()=>{ee(!0),D(null);try{N(await nt(o))}catch(e){D(e instanceof Error?e.message:n.validateError)}finally{ee(!1)}},Ee=async()=>{if(!y){b(!0),D(null),k(!1);try{await rt(o),u(structuredClone(o)),k(!0),N(null)}catch(e){D(e instanceof Error?e.message:n.saveError)}finally{b(!1)}}},De=async()=>{T(!0),D(null);try{await it(),await ve({skipFullPageLoading:!0})}catch(e){D(e instanceof Error?e.message:n.reloadError)}finally{T(!1)}},Oe=async(e,t)=>{try{let n=await at(t);q(t=>{let r=new Map(t);return r.set(e,n),r})}catch(t){q(n=>{let r=new Map(n);return r.set(e,{type:`error`,error:t instanceof Error?t.message:`Error`}),r})}},ke=(e=null)=>{pe(e),de(!0)},Ae=(e,t)=>{c(n=>yt(n,e,t)),P(t=>new Set(t).add(e))},je=e=>{window.confirm(n.removeProviderConfirm.replace(`{{id}}`,e))&&(c(t=>vt(t,e)),q(t=>{let n=new Map(t);return n.delete(e),n}))},Me=(e,t,n)=>{_e({providerId:e,model:t,isNew:n}),he(!0)};return i?(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-8`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.models}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.subtitle}),(0,Y.jsxs)(`a`,{href:re(e,`models`),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,Y.jsx)(ae,{className:`size-3.5`})]})]}),p?(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,role:`status`,children:[(0,Y.jsx)(C,{className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsxs)(`span`,{children:[n.loadFileWarning,`: `,p]})]}):null,d?(0,Y.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.filePath,`: `,(0,Y.jsx)(`code`,{className:`rounded bg-surface-base px-1 py-0.5 font-mono text-fg-muted`,children:d})]}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(G,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:()=>ke(null),disabled:_,children:[(0,Y.jsx)(I,{className:`mr-1 size-4`}),n.addProvider]}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`inline-flex min-h-9 min-w-[7.5rem] justify-center`,onClick:Te,disabled:_||S,children:S?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(F,{className:`mr-1 size-4 animate-spin`}),n.validating]}):n.validate}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`inline-flex min-h-9 min-w-[7.5rem] justify-center`,onClick:Ee,disabled:_||y||!ye,children:y?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(F,{className:`mr-1 size-4 animate-spin`}),n.saving]}):n.save}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`inline-flex min-h-9 min-w-[8.5rem] justify-center`,onClick:De,disabled:_||w,children:w?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(F,{className:`mr-1 size-4 animate-spin`}),n.reloading]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L,{className:`mr-1 size-4`}),n.reload]})}),(0,Y.jsx)(G,{type:`button`,variant:`ghost`,className:`text-fg-muted`,onClick:()=>{B(e=>!e),U(null)},children:R?n.hideJson:n.showJson}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-1.5 text-sm dark:border-edge`,children:[(0,Y.jsx)(`span`,{className:`text-fg-muted`,children:n.statsProviders.replace(`{{count}}`,String(be.providers))}),(0,Y.jsx)(`span`,{className:`text-fg-subtle`,children:`|`}),(0,Y.jsx)(`span`,{className:`text-fg-muted`,children:n.statsModels.replace(`{{count}}`,String(be.models))})]})]}),ye?(0,Y.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,O?(0,Y.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,role:`status`,children:n.saved}):null,E?(0,Y.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[(0,Y.jsx)(C,{className:`size-4 shrink-0`}),E]}):null,j&&j.errors.length>0?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50/80 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/30`,role:`status`,children:[(0,Y.jsx)(`p`,{className:`mb-1 text-sm font-medium text-amber-950 dark:text-amber-100`,children:j.valid?n.validationWarnings:n.validationErrors}),(0,Y.jsx)(`ul`,{className:`list-inside list-disc space-y-0.5 text-xs text-amber-900 dark:text-amber-200`,children:j.errors.map((e,t)=>(0,Y.jsxs)(`li`,{children:[e.path,`: `,e.message,` (`,e.severity,`)`]},`${e.path}-${t}`))})]}):null,_?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Y.jsx)(F,{className:`size-4 animate-spin`}),n.loading]}):R?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`textarea`,{className:h(Z(),`min-h-[320px] resize-y font-mono text-xs leading-relaxed`),value:ce,onChange:e=>V(e.target.value),spellCheck:!1}),H?(0,Y.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:H}):null,(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(G,{type:`button`,variant:`secondary`,onClick:Ce,children:n.jsonReset}),(0,Y.jsx)(G,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:we,children:n.jsonApply})]})]}):Object.keys(o.providers).length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel px-6 py-12 text-center dark:border-edge`,children:[(0,Y.jsx)(`div`,{className:`mb-4 flex size-14 items-center justify-center rounded-full border border-edge bg-surface-base dark:border-edge`,children:(0,Y.jsx)(g,{className:`size-7 text-accent`,strokeWidth:1.5})}),(0,Y.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-fg`,children:n.emptyTitle}),(0,Y.jsx)(`p`,{className:`mb-6 max-w-md text-sm text-fg-muted`,children:n.emptyDesc}),(0,Y.jsxs)(G,{type:`button`,className:`mb-6 bg-accent text-white hover:bg-accent/90`,onClick:()=>ke(null),children:[(0,Y.jsx)(I,{className:`mr-1 size-4`}),n.emptyCta]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:h(`inline-flex items-center gap-1.5 rounded-full border border-edge bg-surface-base px-3 py-1.5 text-xs text-fg hover:border-accent hover:text-accent dark:border-edge`,J.transition,J.focusRingBase),onClick:()=>ke(`ollama`),children:[(0,Y.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),n.presetOllama]}),(0,Y.jsxs)(`button`,{type:`button`,className:h(`inline-flex items-center gap-1.5 rounded-full border border-edge bg-surface-base px-3 py-1.5 text-xs text-fg hover:border-accent hover:text-accent dark:border-edge`,J.transition,J.focusRingBase),onClick:()=>ke(`openrouter`),children:[(0,Y.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),n.presetOpenRouter]}),(0,Y.jsxs)(`button`,{type:`button`,className:h(`inline-flex items-center gap-1.5 rounded-full border border-edge bg-surface-base px-3 py-1.5 text-xs text-fg hover:border-accent hover:text-accent dark:border-edge`,J.transition,J.focusRingBase),onClick:()=>ke(`lmstudio`),children:[(0,Y.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.presetLmStudio]}),(0,Y.jsxs)(`button`,{type:`button`,className:h(`inline-flex items-center gap-1.5 rounded-full border border-edge bg-surface-base px-3 py-1.5 text-xs text-fg hover:border-accent hover:text-accent dark:border-edge`,J.transition,J.focusRingBase),onClick:()=>ke(`zhipuCn`),children:[(0,Y.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),n.presetZhipuCn]}),(0,Y.jsxs)(`button`,{type:`button`,className:h(`inline-flex items-center gap-1.5 rounded-full border border-edge bg-surface-base px-3 py-1.5 text-xs text-fg hover:border-accent hover:text-accent dark:border-edge`,J.transition,J.focusRingBase),onClick:()=>ke(`zaiGeneral`),children:[(0,Y.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),n.presetZaiGeneral]})]})]}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:Object.entries(o.providers).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{let r=oe.has(e),i=t.models?.length??0,a=t.apiKey?lt(t.apiKey):null,o=le.get(e),s=W.has(e);return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-surface-base`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle bg-surface-hover/35 px-3 py-2 dark:border-edge-subtle`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-semibold text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>xe(e),children:[r?(0,Y.jsx)(te,{className:`size-4 shrink-0 text-fg-muted`}):(0,Y.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e}),i>0?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent px-2 py-0.5 text-[10px] font-medium text-white`,children:i}):null,a?(0,Y.jsx)(`span`,{className:h(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium`,a===`shell`&&`bg-blue-100 text-blue-800 dark:bg-blue-950 dark:text-blue-200`,a===`env`&&`bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200`,a===`literal`&&`bg-surface-hover text-fg-muted dark:bg-surface-active`),children:a===`shell`?n.badgeShell:a===`env`?n.badgeEnv:n.badgeLiteral}):null]}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-base hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 dark:hover:text-red-400`,onClick:()=>je(e),"aria-label":n.removeProvider,children:(0,Y.jsx)(z,{className:`size-4`})})]}),r?(0,Y.jsxs)(`div`,{className:`space-y-4 px-3 py-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:n.baseUrl}),(0,Y.jsx)(`input`,{className:Z(),value:t.baseUrl||``,onChange:t=>c(n=>_t(n,e,{baseUrl:t.target.value}))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:n.apiType}),(0,Y.jsx)(`select`,{className:mt(),value:t.api||`openai-completions`,onChange:t=>c(n=>_t(n,e,{api:t.target.value})),children:Qe.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:n.apiKey}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(`input`,{className:h(Z(),`min-w-0 flex-1`),type:s?`text`:`password`,autoComplete:`off`,value:t.apiKey||``,onChange:t=>{let n=t.target.value;c(t=>_t(t,e,{apiKey:n})),q(t=>{let n=new Map(t);return n.delete(e),n})},placeholder:n.apiKeyPlaceholder}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Se(e),children:s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ie,{className:`mr-1 size-3.5`}),n.hide]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{className:`mr-1 size-3.5`}),n.show]})}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>Oe(e,t.apiKey||``),children:n.testKey})]}),o?(0,Y.jsx)(`p`,{className:h(`mt-1 text-xs`,o.error?`text-red-600 dark:text-red-400`:`text-emerald-700 dark:text-emerald-400`),children:o.error?`${n.testError}: ${o.error}`:`${n.testOk} (${o.type}): ${ut(o.resolved||``)}`}):null,(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.apiKeyHint})]}),(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:t.authHeader||!1,onChange:t=>c(n=>_t(n,e,{authHeader:t.target.checked}))}),n.authHeader]}),(0,Y.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.modelsSection}),(0,Y.jsxs)(G,{type:`button`,variant:`primary`,className:`px-2 py-1 text-xs`,onClick:()=>Me(e,null,!0),children:[(0,Y.jsx)(I,{className:`mr-1 size-3.5`}),n.addModel]})]}),(t.models||[]).length===0?(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.modelsEmpty}):(0,Y.jsx)(`ul`,{className:`space-y-2`,children:(t.models||[]).map(t=>(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 dark:border-edge`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:t.id}),t.name&&t.name!==t.id?(0,Y.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:t.name}):null]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-panel hover:text-fg`,onClick:()=>Me(e,t,!1),"aria-label":n.editModel,children:(0,Y.jsx)(A,{className:`size-4`})}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-panel hover:text-red-600 dark:hover:text-red-400`,onClick:()=>{window.confirm(n.removeModelConfirm.replace(`{{id}}`,t.id))&&c(n=>{let r=n.providers[e];return r?_t(n,e,{models:(r.models||[]).filter(e=>e.id!==t.id)}):n})},"aria-label":n.removeModel,children:(0,Y.jsx)(z,{className:`size-4`})})]})]},t.id))})]})]}):null]},e)})}),(0,Y.jsx)(bt,{open:ue,onOpenChange:de,presetKey:fe,onConfirm:Ae,m:n}),(0,Y.jsx)(xt,{open:me,onOpenChange:e=>{he(e),e||_e(null)},providerId:ge?.providerId??null,model:ge?.model??null,isNew:ge?.isNew??!1,onSave:e=>{if(!ge)return;let{providerId:t,isNew:n}=ge;c(r=>{let i=r.providers[t];if(!i)return r;let a=i.models||[];return n?_t(r,t,{models:[...a,e]}):_t(r,t,{models:a.map(t=>t.id===e.id?e:t)})})},m:n})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.models}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Ct(){return{enabled:!1,provider:`alibaba`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},fallback:{enabled:!0,order:[`alibaba`,`openai`]}}}function wt(){return{enabled:!1,provider:`openai`,trigger:`always`,maxTextLength:4096,timeoutMs:3e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`}}}function Tt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Et(e){let t=Ct();if(!Tt(e))return t;let n=e.provider===`openai`?`openai`:`alibaba`,r=Tt(e.alibaba)?{...t.alibaba,...e.alibaba}:t.alibaba,i=Tt(e.openai)?{...t.openai,...e.openai}:t.openai,a=t.fallback??{enabled:!0,order:[`alibaba`,`openai`]};if(Tt(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>e===`alibaba`||e===`openai`):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,fallback:a}}function Dt(e){return e===`openai`||e===`alibaba`||e===`edge`||e===`minimax`}function Ot(e){let t=wt();if(!Tt(e))return t;let n=Dt(e.provider)?e.provider:`openai`,r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`always`;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,alibaba:Tt(e.alibaba)?{...t.alibaba,...e.alibaba}:t.alibaba,openai:Tt(e.openai)?{...t.openai,...e.openai}:t.openai,edge:Tt(e.edge)?{...t.edge,...e.edge}:t.edge,minimax:Tt(e.minimax)?{...t.minimax,...e.minimax}:t.minimax}}function kt(e){let t=Tt(e)?e:{};return{stt:Et(t.stt),tts:Ot(t.tts)}}async function At(e){await o(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:e.stt,tts:e.tts})}),N()}async function jt(){let e=await o(c(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}function Mt(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function Q(){return h(le,K)}var Nt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Pt=[{id:`whisper-1`,name:`Whisper-1`}],Ft=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],It=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Lt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],Rt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],zt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Bt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Vt=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}];function Ht(){let e=s(e=>e.language),t=r(e),n=t.voiceSettings,i=!!a(e=>e.token),[o,l]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(!1),{data:x,error:S,isLoading:C,mutate:ee}=oe(i),{data:w,error:T,isLoading:E,mutate:D}=u(i?c(`/api/voice/models`):null,jt,{revalidateOnFocus:!1}),O=(0,X.useMemo)(()=>x?.payload?.config===void 0?null:kt(x.payload.config),[x]),te=(0,X.useMemo)(()=>!o||!d?!1:JSON.stringify(o)!==JSON.stringify(d),[o,d]);(0,X.useEffect)(()=>{if(!i){l(null),f(null),m(null);return}O===null||w===void 0||te||(l(structuredClone(O)),f(structuredClone(O)),m(w),b(!1))},[i,O,w,te]);let ne=!!(i&&(O===null||w===void 0)&&(C||E)),k=S instanceof Error?S.message:S?String(S):T instanceof Error?T.message:T?String(T):null,A=(0,X.useCallback)(e=>{l(t=>t?{...t,stt:{...t.stt,...e}}:null)},[]),ie=(0,X.useCallback)(e=>{l(t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null)},[]),j=(0,X.useCallback)(e=>{l(t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null)},[]),M=(0,X.useCallback)(e=>{l(t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}})},[]),N=(0,X.useCallback)(e=>{l(t=>t?{...t,tts:{...t.tts,...e}}:null)},[]),P=(0,X.useCallback)(e=>{l(t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null)},[]),se=(0,X.useCallback)(e=>{l(t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null)},[]),I=(0,X.useCallback)(e=>{l(t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null)},[]),L=(0,X.useCallback)(e=>{l(t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null)},[]),R=(0,X.useCallback)(async()=>{if(!(!o||h)){g(!0),v(null),b(!1);try{await At(o);let e=structuredClone(o);f(e),l(e),b(!0),window.setTimeout(()=>b(!1),2500)}catch(e){v(e instanceof Error?e.message:n.saveError)}finally{g(!1)}}},[o,h,n.saveError]);if(!i)return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.voice}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]});if(ne)return(0,Y.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,Y.jsx)(F,{className:`size-4 animate-spin`}),n.loading]})});if(!o||p===null)return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_??k??n.loadError}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>{ee(),D()},children:n.retry})]});let z=o.stt,B=o.tts;return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.voice}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,Y.jsxs)(`a`,{href:re(e,`voice`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,Y.jsx)(ae,{className:`size-3.5`})]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[y?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,(0,Y.jsx)(G,{type:`button`,variant:`primary`,disabled:!te||h,onClick:()=>void R(),children:h?n.saving:n.save})]})]}),te?(0,Y.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,_?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_}):null,(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(Ut,{v:n,stt:z,models:p,updateStt:A,updateSttAlibaba:ie,updateSttOpenai:j,updateSttFallback:M}),(0,Y.jsx)(Wt,{v:n,tts:B,models:p,updateTts:N,updateTtsAlibaba:P,updateTtsOpenai:se,updateTtsEdge:I,updateTtsMinimax:L})]}),(0,Y.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Y.jsx)(`strong`,{className:`text-accent`,children:n.notes.title}),` `,n.notes.duration]}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:n.notes.envVars})]})]})}function Ut({v:e,stt:t,models:n,updateStt:r,updateSttAlibaba:i,updateSttOpenai:a,updateSttFallback:o}){let s=n?.stt?.alibaba?.length?n.stt.alibaba:Nt,c=n?.stt?.openai?.length?n.stt.openai:Pt;return(0,Y.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Y.jsxs)(`div`,{className:`mb-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Y.jsx)(v,{className:`size-4 text-accent`,strokeWidth:1.75}),e.stt.title]}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.description})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.enable}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.stt.enableDesc})]}),(0,Y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:t.enabled,onChange:e=>r({enabled:e.target.checked})})]}),t.enabled?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.provider}),(0,Y.jsxs)(`select`,{className:Q(),value:t.provider,onChange:e=>r({provider:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`alibaba`,children:e.stt.alibaba}),(0,Y.jsx)(`option`,{value:`openai`,children:e.stt.openai})]})]})}),t.provider===`alibaba`?(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.apiKey}),(0,Y.jsx)(`input`,{className:h(Mt(),`font-mono text-xs`),type:`password`,autoComplete:`off`,value:t.alibaba?.apiKey??``,onChange:e=>i({apiKey:e.target.value}),placeholder:`sk-...`}),(0,Y.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,` (DASHSCOPE_API_KEY)`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.model}),(0,Y.jsx)(`select`,{className:Q(),value:t.alibaba?.model??``,onChange:e=>i({model:e.target.value}),children:s.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.apiKey}),(0,Y.jsx)(`input`,{className:h(Mt(),`font-mono text-xs`),type:`password`,autoComplete:`off`,value:t.openai?.apiKey??``,onChange:e=>a({apiKey:e.target.value}),placeholder:`sk-...`}),(0,Y.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,` (OPENAI_API_KEY)`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.model}),(0,Y.jsx)(`select`,{className:Q(),value:t.openai?.model??``,onChange:e=>a({model:e.target.value}),children:c.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.fallback}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.stt.fallbackDesc})]}),(0,Y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:t.fallback?.enabled??!0,onChange:e=>o({enabled:e.target.checked})})]})]}):null]})]})}function Wt({v:e,tts:t,models:n,updateTts:r,updateTtsAlibaba:i,updateTtsOpenai:a,updateTtsEdge:o,updateTtsMinimax:s}){let c=t=>t===`off`?e.tts.triggerDescOff:t===`always`?e.tts.triggerDescAlways:t===`inbound`?e.tts.triggerDescInbound:t===`tagged`?e.tts.triggerDescTagged:``,l=n?.tts?.openai?.length?n.tts.openai:Ft,u=n?.ttsVoices?.openai?.length?n.ttsVoices.openai:It,d=n?.tts?.alibaba?.length?n.tts.alibaba:Lt,f=n?.ttsVoices?.alibaba?.length?n.ttsVoices.alibaba:Rt,p=n?.ttsVoices?.edge?.length?n.ttsVoices.edge:zt,m=n?.tts?.minimax?.length?n.tts.minimax:Bt,g=n?.ttsVoices?.minimax?.length?n.ttsVoices.minimax:Vt;return(0,Y.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Y.jsxs)(`div`,{className:`mb-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Y.jsx)(_,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.enable}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.tts.enableDesc})]}),(0,Y.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:t.enabled,onChange:e=>r({enabled:e.target.checked})})]}),t.enabled?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.tts.trigger}),(0,Y.jsxs)(`select`,{className:Q(),value:t.trigger,onChange:e=>r({trigger:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`off`,children:e.tts.triggerOff}),(0,Y.jsx)(`option`,{value:`always`,children:e.tts.triggerAlways}),(0,Y.jsx)(`option`,{value:`inbound`,children:e.tts.triggerInbound}),(0,Y.jsx)(`option`,{value:`tagged`,children:e.tts.triggerTagged})]}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c(t.trigger)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.tts.provider}),(0,Y.jsxs)(`select`,{className:Q(),value:t.provider,onChange:e=>r({provider:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`openai`,children:e.tts.providerOpenai}),(0,Y.jsx)(`option`,{value:`alibaba`,children:e.stt.alibaba}),(0,Y.jsx)(`option`,{value:`minimax`,children:`MiniMax`}),(0,Y.jsx)(`option`,{value:`edge`,children:e.tts.providerEdge})]})]})]}),t.provider===`openai`?(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Y.jsx)($,{children:e.stt.apiKey}),(0,Y.jsx)(`input`,{className:h(Mt(),`font-mono text-xs`),type:`password`,autoComplete:`off`,value:t.openai?.apiKey??``,onChange:e=>a({apiKey:e.target.value}),placeholder:`sk-...`}),(0,Y.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,` (OPENAI_API_KEY)`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.model}),(0,Y.jsx)(`select`,{className:Q(),value:t.openai?.model??``,onChange:e=>a({model:e.target.value}),children:l.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.tts.voice}),(0,Y.jsx)(`select`,{className:Q(),value:t.openai?.voice??``,onChange:e=>a({voice:e.target.value}),children:u.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):null,t.provider===`alibaba`?(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Y.jsx)($,{children:e.stt.apiKey}),(0,Y.jsx)(`input`,{className:h(Mt(),`font-mono text-xs`),type:`password`,autoComplete:`off`,value:t.alibaba?.apiKey??``,onChange:e=>i({apiKey:e.target.value}),placeholder:`sk-...`}),(0,Y.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,` (DASHSCOPE_API_KEY)`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.model}),(0,Y.jsx)(`select`,{className:Q(),value:t.alibaba?.model??``,onChange:e=>i({model:e.target.value}),children:d.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.tts.voice}),(0,Y.jsx)(`select`,{className:Q(),value:t.alibaba?.voice??``,onChange:e=>i({voice:e.target.value}),children:f.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):null,t.provider===`minimax`?(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Y.jsx)($,{children:e.stt.apiKey}),(0,Y.jsx)(`input`,{className:h(Mt(),`font-mono text-xs`),type:`password`,autoComplete:`off`,value:t.minimax?.apiKey??``,onChange:e=>s({apiKey:e.target.value}),placeholder:`eyJ...`}),(0,Y.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,` (MINIMAX_API_KEY)`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.stt.model}),(0,Y.jsx)(`select`,{className:Q(),value:t.minimax?.model??``,onChange:e=>s({model:e.target.value}),children:m.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.tts.voice}),(0,Y.jsx)(`select`,{className:Q(),value:t.minimax?.voice??``,onChange:e=>s({voice:e.target.value}),children:g.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}):null,t.provider===`edge`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)($,{children:e.tts.voice}),(0,Y.jsx)(`select`,{className:Q(),value:t.edge?.voice??``,onChange:e=>o({voice:e.target.value}),children:p.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null]}):null]})]})}function $({children:e}){return(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e})}function Gt(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(c)?c.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[]}}async function Kt(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await o(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n}}})}),N()}function qt(e){return e===`***`||e===`••••••••••••`}function Jt(e){if(!e||typeof e!=`object`||!(`providers`in e))return{};let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}function Yt(e,t,n){let r=new Set(n.map(e=>e.provider));return e.map(e=>({...e,configured:e.configured||r.has(e.id),apiKey:t[e.id]||(e.configured||r.has(e.id)?`***`:``)}))}async function Xt(e){await o(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({providers:e})}),Promise.all([N(),l(c(`/api/providers/meta`))])}async function Zt(e){return(await o(c(`/api/models-json/test-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({value:e})})).payload??{type:`literal`,error:`No response`}}function Qt({label:e,description:t,children:n}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e}),n,(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t})]})}function $t(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`)}function en(){return h(le,K)}var tn=[`brave`,`tavily`,`bing`,`searxng`];function nn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}function rn(){let e=s(e=>e.language),t=r(e),n=t.webSearchSettings,i=t.logs,o=!!a(e=>e.token),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),v=(0,X.useRef)(!1),{data:y,error:b,isLoading:x,mutate:S}=oe(o),C=(0,X.useMemo)(()=>y?.payload?.config===void 0?null:Gt(y.payload.config),[y]);(0,X.useEffect)(()=>{if(!o){l(null),d(null),v.current=!1;return}C!==null&&(v.current||(l(C),d(C)))},[o,C]);let ee=!!(o&&x&&y===void 0&&!b),w=b instanceof Error?b.message:b?String(b):null,T=(0,X.useMemo)(()=>!c||!u?!1:JSON.stringify(c)!==JSON.stringify(u),[c,u]),E=(0,X.useCallback)(e=>{v.current=!0,l(t=>t?{...t,...e}:null)},[]),D=(0,X.useCallback)(async()=>{if(!(!c||f)){p(!0),h(null),_(!1);try{await Kt(c),v.current=!1,_(!0),window.setTimeout(()=>_(!1),2500)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}},[c,f,n.saveError]);return o?ee?(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col items-center gap-3 px-4 py-8`,children:[(0,Y.jsx)(F,{className:`size-8 animate-spin text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading})]}):c?(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:n.title}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,Y.jsxs)(`a`,{href:re(e,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,Y.jsx)(ae,{className:`size-3.5`})]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[g?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,(0,Y.jsx)(G,{type:`button`,variant:`primary`,disabled:!T||f,onClick:()=>void D(),children:f?n.saving:n.save})]})]}),T?(0,Y.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,m?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Y.jsxs)(be,{children:[(0,Y.jsx)(xe,{icon:R,title:n.sectionRegion,subtitle:n.sectionRegionHint}),(0,Y.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Y.jsx)(Qt,{label:n.regionLabel,description:n.regionDesc,children:(0,Y.jsxs)(`select`,{className:en(),value:c.regionMode,onChange:e=>E({regionMode:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`auto`,children:n.regionAuto}),(0,Y.jsx)(`option`,{value:`cn`,children:n.regionCn}),(0,Y.jsx)(`option`,{value:`global`,children:n.regionGlobal})]})})})]}),(0,Y.jsxs)(be,{children:[(0,Y.jsx)(xe,{icon:R,title:n.sectionSearch,subtitle:n.sectionSearchHint}),(0,Y.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Y.jsx)(Qt,{label:n.maxResultsLabel,description:n.maxResultsDesc,children:(0,Y.jsx)(`input`,{type:`number`,min:1,max:50,className:$t(),value:c.maxResults,onChange:e=>E({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.providersTitle}),c.providers.map((e,t)=>(0,Y.jsx)(an,{row:e,labels:n,onChange:e=>{let n=[...c.providers];n[t]=e,E({providers:n})},onRemove:()=>{E({providers:c.providers.filter((e,n)=>n!==t)})}},t)),(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>E({providers:[...c.providers,nn()]}),children:[(0,Y.jsx)(I,{className:`size-4`}),n.addProvider]})]})]})]}),(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:n.footerHint})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??w??n.loadError}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>void S(),children:i.refresh})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function an({row:e,labels:t,onChange:n,onRemove:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel/60 p-4 dark:border-edge-subtle`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`select`,{className:h(en(),`min-w-[8rem]`),value:e.type,onChange:t=>n({...e,type:t.target.value,url:t.target.value===`searxng`?e.url:``}),children:tn.map(e=>(0,Y.jsx)(`option`,{value:e,children:t.providerTypes[e]},e))}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:e.disabled,onChange:t=>n({...e,disabled:t.target.checked})}),t.disabled]}),(0,Y.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:r,children:(0,Y.jsx)(z,{className:`size-4`})})]})]}),e.type===`searxng`?(0,Y.jsx)(Qt,{label:t.urlLabel,description:t.urlDesc,children:(0,Y.jsx)(`input`,{type:`url`,className:$t(),value:e.url,placeholder:`http://localhost:8080`,onChange:t=>n({...e,url:t.target.value})})}):null,(0,Y.jsx)(Qt,{label:t.apiKeyLabel,description:t.apiKeyDesc,children:(0,Y.jsx)(`input`,{type:`password`,autoComplete:`off`,className:$t(),value:qt(e.apiKey)?``:e.apiKey,placeholder:qt(e.apiKey)?t.keyPlaceholderMasked:t.keyPlaceholder,onChange:t=>n({...e,apiKey:t.target.value})})})]})}async function on(e){let t=await i(c(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function sn(e){let t=await i(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function cn(e,t){let n=await i(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function ln(e){let t=await i(c(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function un(e){let t=await i(c(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function dn(e){let t=await i(c(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}function fn(e,t){return e===`single`?t.getApiKey:e===`intl`?t.getApiKeyIntl:t.getApiKeyCn}var pn={openai:{apiKeyUrl:`https://platform.openai.com/api-keys`,pricingUrl:`https://openai.com/pricing`,docsUrl:`https://platform.openai.com/docs`,description:`The most widely used LLM provider. Powers ChatGPT.`,descriptionZh:`最广泛使用的 LLM 服务商,ChatGPT 背后的技术。`,bestFor:[`general`,`coding`,`vision`],freeTier:!1,freeTierNote:`Pay-as-you-go; new accounts may receive trial credits.`,aliases:[`chatgpt`,`gpt`,`gpt-4`,`gpt4`,`gpt-4o`,`gpt4o`],envVars:[`OPENAI_API_KEY`]},anthropic:{apiKeyUrl:`https://console.anthropic.com/settings/keys`,pricingUrl:`https://www.anthropic.com/pricing`,docsUrl:`https://docs.anthropic.com`,description:`Known for Claude — excellent at long documents, coding, and nuanced reasoning.`,descriptionZh:`Claude 系列模型,擅长长文档处理、代码和复杂推理。`,bestFor:[`long context`,`coding`,`reasoning`],freeTier:!1,aliases:[`claude`,`claude 3`,`claude sonnet`,`claude opus`,`claude haiku`],envVars:[`ANTHROPIC_OAUTH_TOKEN`,`ANTHROPIC_API_KEY`]},google:{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Google Gemini models — strong multimodal and long-context capabilities.`,descriptionZh:`Google Gemini 系列,多模态能力强,支持超长上下文。`,bestFor:[`multimodal`,`long context`,`general`],freeTier:!0,freeTierNote:`Free tier available via Google AI Studio.`,aliases:[`gemini`,`google gemini`,`bard`,`google ai`],envVars:[`GEMINI_API_KEY`,`GOOGLE_API_KEY`]},"google-vertex":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/vertex-ai/pricing`,docsUrl:`https://cloud.google.com/vertex-ai/docs`,description:`Google Vertex AI — enterprise-grade Gemini and other models on GCP.`,descriptionZh:`Google Vertex AI,企业级 GCP 托管模型,支持 Gemini 等。`,bestFor:[`enterprise`,`multimodal`,`compliance`],freeTier:!1,aliases:[`vertex`,`vertex ai`,`gcp`,`google cloud`],envVars:[`GOOGLE_CLOUD_PROJECT`,`GOOGLE_CLOUD_LOCATION`]},"google-gemini-cli":{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Gemini via CLI token — for users authenticated with the Gemini CLI tool.`,descriptionZh:`通过 Gemini CLI 令牌访问 Gemini,适合已安装 CLI 工具的用户。`,bestFor:[`general`,`multimodal`],freeTier:!0,freeTierNote:`Uses your existing Gemini CLI authentication.`,aliases:[`gemini cli`,`gemini-cli`],envVars:[`GEMINI_CLI_TOKEN`,`GOOGLE_TOKEN`]},"google-antigravity":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/pricing`,docsUrl:`https://cloud.google.com/docs`,description:`Google Antigravity — internal/experimental Google AI endpoint.`,descriptionZh:`Google Antigravity,Google 内部/实验性 AI 端点。`,bestFor:[`experimental`],freeTier:!1,aliases:[`antigravity`,`google antigravity`],envVars:[`ANTIGRAVITY_API_KEY`]},groq:{apiKeyUrl:`https://console.groq.com/keys`,pricingUrl:`https://groq.com/pricing/`,docsUrl:`https://console.groq.com/docs`,description:`Extremely fast inference — ideal for latency-sensitive applications.`,descriptionZh:`推理速度极快,适合对延迟敏感的场景。`,bestFor:[`speed`,`cheap`],freeTier:!0,freeTierNote:`Generous free tier with rate limits.`,aliases:[`groq`,`llama on groq`,`mixtral on groq`],envVars:[`GROQ_API_KEY`]},xai:{apiKeyUrl:`https://console.x.ai/`,pricingUrl:`https://x.ai/api`,docsUrl:`https://docs.x.ai/`,description:`xAI Grok models — real-time web access, strong reasoning.`,descriptionZh:`xAI Grok 系列,支持实时联网,推理能力强。`,bestFor:[`reasoning`,`real-time`],freeTier:!1,aliases:[`grok`,`xai`,`x.ai`],envVars:[`XAI_API_KEY`]},cerebras:{apiKeyUrl:`https://cloud.cerebras.ai/platform/`,pricingUrl:`https://cloud.cerebras.ai/platform/`,docsUrl:`https://inference-docs.cerebras.ai/`,description:`Ultra-fast inference on custom AI chips. Fastest Llama inference available.`,descriptionZh:`基于专用 AI 芯片的超快推理,Llama 推理速度业界最快。`,bestFor:[`speed`],freeTier:!0,freeTierNote:`Free tier available.`,aliases:[`cerebras`],envVars:[`CEREBRAS_API_KEY`]},mistral:{apiKeyUrl:`https://console.mistral.ai/api-keys/`,pricingUrl:`https://mistral.ai/technology/#pricing`,docsUrl:`https://docs.mistral.ai/`,description:`European open-weight models. Good balance of quality and cost.`,descriptionZh:`欧洲开源模型,质量与成本平衡好。`,bestFor:[`general`,`cheap`,`coding`],freeTier:!1,aliases:[`mistral`,`mixtral`,`codestral`],envVars:[`MISTRAL_API_KEY`]},openrouter:{apiKeyUrl:`https://openrouter.ai/keys`,pricingUrl:`https://openrouter.ai/models`,docsUrl:`https://openrouter.ai/docs`,description:`API gateway to 100+ models from many providers with a single key.`,descriptionZh:`统一 API 网关,一个 Key 访问 100+ 模型。`,bestFor:[`general`,`flexibility`],freeTier:!0,freeTierNote:`Some models are free; pay-per-use for others.`,aliases:[`openrouter`,`open router`],envVars:[`OPENROUTER_API_KEY`]},"azure-openai-responses":{apiKeyUrl:`https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI`,pricingUrl:`https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/`,docsUrl:`https://learn.microsoft.com/en-us/azure/ai-services/openai/`,description:`OpenAI models hosted on Azure. Enterprise SLA and data residency.`,descriptionZh:`Azure 托管的 OpenAI 模型,企业级 SLA 和数据合规。`,bestFor:[`enterprise`,`compliance`,`coding`],freeTier:!1,aliases:[`azure`,`azure openai`,`aoai`],envVars:[`AZURE_OPENAI_API_KEY`,`AZURE_OPENAI_BASE_URL`]},"amazon-bedrock":{apiKeyUrl:`https://console.aws.amazon.com/iam/home#/security_credentials`,pricingUrl:`https://aws.amazon.com/bedrock/pricing/`,docsUrl:`https://docs.aws.amazon.com/bedrock/`,description:`AWS-hosted models including Claude, Llama, Titan. Enterprise-grade.`,descriptionZh:`AWS 托管模型,包含 Claude、Llama 等,企业级可靠性。`,bestFor:[`enterprise`,`compliance`],freeTier:!1,aliases:[`bedrock`,`aws`,`amazon`],envVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`]},minimax:{apiKeyUrl:`https://platform.minimax.io/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimax.io/docs/guides/models-intro`,docsUrl:`https://platform.minimax.io/docs/guides/quickstart-preparation`,description:`MiniMax — Chinese multimodal model with strong text and audio capabilities.`,descriptionZh:`MiniMax,国产多模态模型,文本和音频能力强。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax`,`mini max`,`abab`],envVars:[`MINIMAX_API_KEY`]},"minimax-cn":{apiKeyUrl:`https://platform.minimaxi.com/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimaxi.com/document/Price`,docsUrl:`https://platform.minimaxi.com/document/Announcement`,description:`MiniMax (China endpoint) — domestic access for Chinese users.`,descriptionZh:`MiniMax 国内端点,国内用户直连访问。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax cn`,`minimax china`,`abab`],envVars:[`MINIMAX_CN_API_KEY`,`MINIMAX_API_KEY`]},"kimi-coding":{apiKeyUrl:`https://platform.moonshot.ai/console/api-keys`,apiKeyUrlCn:`https://platform.moonshot.cn/console/api-keys`,pricingUrl:`https://platform.moonshot.ai/docs/pricing/chat`,docsUrl:`https://platform.moonshot.ai/docs`,description:`Kimi Coding — Moonshot model optimized for code generation tasks.`,descriptionZh:`Kimi Coding,Moonshot 专为代码生成优化的模型。`,bestFor:[`coding`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`kimi coding`,`moonshot coding`,`kimi code`],envVars:[`KIMI_API_KEY`,`MOONSHOT_API_KEY`]},huggingface:{apiKeyUrl:`https://huggingface.co/settings/tokens`,pricingUrl:`https://huggingface.co/pricing`,docsUrl:`https://huggingface.co/docs/api-inference/`,description:`Access thousands of open-source models via Hugging Face Inference API.`,descriptionZh:`通过 Hugging Face 访问数千个开源模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,freeTierNote:`Free tier with rate limits.`,aliases:[`huggingface`,`hugging face`,`hf`],envVars:[`HF_TOKEN`,`HUGGINGFACE_TOKEN`]},opencode:{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode — AI coding assistant provider.`,descriptionZh:`OpenCode,AI 代码助手服务商。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode`,`open code`],envVars:[`OPENCODE_API_KEY`]},"opencode-go":{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode Go — AI coding assistant provider (Go variant).`,descriptionZh:`OpenCode Go,AI 代码助手服务商(Go 版本)。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode go`,`opencode-go`],envVars:[`OPENCODE_API_KEY`]},zai:{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`01.AI Yi models — strong multilingual capabilities.`,descriptionZh:`零一万物 Yi 系列模型,多语言能力强。`,bestFor:[`general`,`chinese`],freeTier:!1,aliases:[`yi`,`01.ai`,`zero one`,`零一万物`],envVars:[`ZAI_API_KEY`]},dashscope:{apiKeyUrl:`https://modelstudio.console.alibabacloud.com/`,apiKeyUrlCn:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/dashscope/`,description:"Alibaba DashScope — image generation, speech, and STT HTTP APIs (service id `dashscope`, not a pi-ai LLM provider).",descriptionZh:`阿里 DashScope:文生图、语音等 HTTP API(服务 id 为 dashscope,非 pi-ai 内置 LLM)。`,bestFor:[`image`,`speech`,`chinese`],freeTier:!0,aliases:[`dash scope`,`alibaba dashscope`],envVars:[`DASHSCOPE_API_KEY`]},"vercel-ai-gateway":{apiKeyUrl:`https://vercel.com/account/tokens`,pricingUrl:`https://vercel.com/pricing`,docsUrl:`https://vercel.com/docs/ai/ai-gateway`,description:`Vercel AI Gateway — route requests to multiple LLM providers via Vercel.`,descriptionZh:`Vercel AI Gateway,通过 Vercel 路由请求到多个 LLM 服务商。`,bestFor:[`flexibility`,`enterprise`],freeTier:!1,aliases:[`vercel gateway`,`vercel ai gateway`],envVars:[`AI_GATEWAY_API_KEY`,`VERCEL_AI_GATEWAY_API_KEY`]},"github-copilot":{apiKeyUrl:`https://github.com/settings/tokens`,pricingUrl:`https://github.com/features/copilot#pricing`,docsUrl:`https://docs.github.com/en/copilot`,description:`GitHub Copilot — use your GitHub token to access Copilot models.`,descriptionZh:`使用 GitHub 令牌访问 Copilot 模型。`,bestFor:[`coding`],freeTier:!0,freeTierNote:`Free for verified students and open-source maintainers.`,aliases:[`github copilot`,`copilot`,`github`],envVars:[`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`GITHUB_COPILOT_TOKEN`]}};function mn(e,t){let n=pn[e];if(!n)return[];let r=n.apiKeyUrl,i=n.apiKeyUrlCn;return r&&i?t===`zh`?[{href:i,kind:`cn`},{href:r,kind:`intl`}]:[{href:r,kind:`intl`},{href:i,kind:`cn`}]:r?[{href:r,kind:`single`}]:i?[{href:i,kind:`single`}]:[]}function hn({providerId:e,language:t}){let n=pn[e];if(!n)return null;let r=t===`zh`,i=r&&n.descriptionZh?n.descriptionZh:n.description;return i?(0,Y.jsxs)(de,{children:[(0,Y.jsx)(me,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-fg-subtle hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r?`${e} 详情`:`${e} info`,children:(0,Y.jsx)(P,{className:`size-3.5`,"aria-hidden":!0})})}),(0,Y.jsx)(fe,{children:(0,Y.jsxs)(he,{side:`right`,align:`start`,sideOffset:6,className:h(`z-50 w-64 rounded-xl border border-edge bg-surface-panel p-3 shadow-md`,`data-[state=open]:animate-in data-[state=closed]:animate-out`,`data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,`data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`),children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e}),(0,Y.jsx)(pe,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded p-0.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,"aria-label":r?`关闭`:`Close`,children:(0,Y.jsx)(m,{className:`size-3.5`,"aria-hidden":!0})})})]}),(0,Y.jsx)(`p`,{className:`mt-1.5 text-xs leading-relaxed text-fg-muted`,children:i}),n.bestFor&&n.bestFor.length>0?(0,Y.jsxs)(`div`,{className:`mt-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r?`适合场景`:`Best for`}),(0,Y.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:n.bestFor.map(e=>(0,Y.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-muted`,children:e},e))})]}):null,n.freeTier===void 0?null:(0,Y.jsxs)(`div`,{className:`mt-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r?`免费额度`:`Free tier`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.freeTier?n.freeTierNote??(r?`有免费额度`:`Available`):r?`无免费额度(按量付费)`:`None (pay-as-you-go)`})]}),n.pricingUrl||n.docsUrl?(0,Y.jsxs)(`div`,{className:`mt-2.5 flex gap-3`,children:[n.pricingUrl?(0,Y.jsxs)(`a`,{href:n.pricingUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-xs text-accent-fg hover:underline`,children:[r?`定价`:`Pricing`,(0,Y.jsx)(ae,{className:`size-3`,"aria-hidden":!0})]}):null,n.docsUrl?(0,Y.jsxs)(`a`,{href:n.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-xs text-accent-fg hover:underline`,children:[r?`文档`:`Docs`,(0,Y.jsx)(ae,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,(0,Y.jsx)(ge,{className:`fill-edge`})]})})]}):null}var gn=[`common`,`specialty`,`enterprise`,`oauth`];function _n(e){let t=new Map;for(let e of gn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function vn(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function yn(e,t){switch(t){case`agent`:return e.sourceAgent;case`gateway`:return e.sourceGateway;case`oauth`:return e.sourceOauth;case`env`:return e.sourceEnv;case`models_json`:return e.sourceModelsJson;default:return e.sourceNone}}function bn(){let e=s(e=>e.language),t=r(e),n=t.providersSettings,i=!!a(e=>e.token),[l,d]=(0,X.useState)({}),[p,m]=(0,X.useState)({}),[g,_]=(0,X.useState)(!1),[v,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,ee]=(0,X.useState)(()=>new Set([`common`])),[T,E]=(0,X.useState)(``),[D,O]=(0,X.useState)(!1),[ne,A]=(0,X.useState)(()=>new Set),ie=(0,X.useRef)(``),j=c(`/api/providers/meta`),ae=(0,X.useCallback)(async e=>(await o(e)).payload?.providers??[],[]),{data:M,error:N,isLoading:P,mutate:se}=oe(i),{data:F,error:I,isLoading:L,mutate:z}=u(i?j:null,ae,{revalidateOnFocus:!1}),{data:B,mutate:ce}=u(i?`gateway-configured-models`:null,()=>k(),{revalidateOnFocus:!1}),V=(0,X.useMemo)(()=>!F||M===void 0?null:Yt(F,Jt(M.payload?.config),B??[]),[F,M,B]),H=N instanceof Error?N.message:N?String(N):I instanceof Error?I.message:I?String(I):null,U=!!(i&&V===null&&(P||L)&&!H),W=(0,X.useMemo)(()=>JSON.stringify(l)!==JSON.stringify(p),[l,p]);(0,X.useEffect)(()=>{if(!W)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[W]),(0,X.useEffect)(()=>{if(!(!i||V===null)&&!W){let e={};for(let t of V)e[t.id]=t.apiKey;d(e),m({...e})}},[i,V,W]);let K=V??[],le=(0,X.useMemo)(()=>{let e=K,t=T.trim().toLowerCase();return t&&(e=e.filter(e=>{let n=pn[e.id]?.aliases??[];return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||n.some(e=>e.toLowerCase().includes(t))})),D&&(e=e.filter(e=>!e.configured)),e},[K,T,D]),ue=(0,X.useMemo)(()=>_n(le),[le]);(0,X.useEffect)(()=>{let e=ie.current;if(ie.current=T,T.trim()){let e=new Set;for(let t of gn)(ue.get(t)??[]).length>0&&e.add(t);ee(e);return}e.trim()&&ee(new Set([`common`]))},[T,ue]);let de=(0,X.useCallback)(async()=>{if(g)return;let e={};for(let t of Object.keys(l)){let n=l[t]?.trim()??``;!n||qt(n)||(e[t]=n)}if(Object.keys(e).length===0){m({...l}),S(`noChanges`),window.setTimeout(()=>S(null),2500);return}_(!0),b(null),S(null);try{await Xt(e),A(new Set(Object.keys(e)));let t=await ce(k(!0))??B??[],[n,r]=await Promise.all([se(),z()]),i=Array.isArray(r)?r:F??[],a=n??M;if(a?.payload){let e=Yt(i,Jt(a.payload.config),t),n={};for(let t of e)n[t.id]=t.apiKey;d(n),m({...n})}S(`saved`),window.setTimeout(()=>S(null),2500)}catch(e){b(e instanceof Error?e.message:n.saveError)}finally{_(!1)}},[M,l,F,B,se,z,ce,n.saveError,g]),fe=(0,X.useCallback)(()=>{d({...p}),b(null),S(null),A(new Set)},[p]),pe=e=>{ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},me=(0,X.useCallback)(()=>{se(),z()},[se,z]),he=!!(T.trim()||D);return i?U?(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,Y.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),(0,Y.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),(0,Y.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.logs.loading})]}):K.length===0?(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:[(0,Y.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-4 py-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.loadError}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v??H??n.empty})]}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>{se(),z()},children:t.logs.refresh})]}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.providers}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.rotateHint})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[x===`saved`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,x===`noChanges`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.noChangesSaved}):null,(0,Y.jsx)(G,{type:`button`,variant:`secondary`,disabled:!W||g,onClick:fe,children:n.discard}),(0,Y.jsx)(G,{type:`button`,variant:`primary`,disabled:!W||g,onClick:()=>void de(),children:g?n.saving:n.save})]})]}),W?(0,Y.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,(0,Y.jsxs)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:[n.intro,` `,(0,Y.jsx)(`a`,{href:re(e,`models`),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n.docsLink}),` · `,(0,Y.jsx)(f,{to:`/settings/models`,className:`font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n.modelsLink})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,Y.jsxs)(`div`,{className:`relative min-w-0 flex-1 sm:max-w-md`,children:[(0,Y.jsx)(R,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,value:T,onChange:e=>E(e.target.value),placeholder:n.searchPlaceholder,autoComplete:`off`,className:h(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,q,`dark:border-edge`),"aria-label":n.searchPlaceholder})]}),(0,Y.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg-muted`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:D,onChange:e=>O(e.target.checked),className:`size-4 rounded border-edge text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),n.unconfiguredOnly]}),he?(0,Y.jsx)(G,{type:`button`,variant:`ghost`,className:`h-9 w-fit self-start text-fg-muted`,onClick:()=>{E(``),O(!1)},children:n.clearFilters}):null]}),v?(0,Y.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:v}):null,le.length===0?(0,Y.jsxs)(`div`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-base px-4 py-8 text-center text-sm text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:n.noMatches}),(0,Y.jsx)(G,{type:`button`,variant:`secondary`,className:`mt-4`,onClick:()=>{E(``),O(!1)},children:n.clearFilters})]}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:gn.map(t=>{let r=ue.get(t)??[];if(r.length===0)return null;let i=C.has(t),a=r.filter(e=>e.configured).length,o=`providers-cat-${t}`;return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-2xl bg-surface-base`,children:[(0,Y.jsxs)(`button`,{type:`button`,id:`${o}-trigger`,"aria-expanded":i,"aria-controls":o,className:`flex w-full items-center justify-between gap-2 border-b border-edge-subtle px-4 py-3 text-left transition-colors hover:bg-surface-hover/60 dark:border-edge-subtle`,onClick:()=>pe(t),children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:n.categories[t]}),(0,Y.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.length})]}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[a>0?(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,Y.jsx)(w,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),vn(n.configuredCount,{count:String(a)})]}):null,(0,Y.jsx)(te,{className:h(`size-4 text-fg-subtle transition-transform`,i&&`rotate-180`),"aria-hidden":!0})]})]}),i?(0,Y.jsx)(`div`,{id:o,role:`region`,"aria-labelledby":`${o}-trigger`,className:`divide-y divide-edge-subtle`,children:r.map(t=>(0,Y.jsx)(`div`,{id:`provider-row-${t.id}`,children:(0,Y.jsx)(Sn,{row:t,value:l[t.id]??``,rowDirty:(l[t.id]??``)!==(p[t.id]??``),labels:n,language:e,onChange:(e,t)=>d(n=>({...n,[e]:t})),onReload:me,justSaved:ne.has(t.id),availableModels:B??[]})},t.id))}):null]},t)})})]}):(0,Y.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-10`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[(0,Y.jsx)(y,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:t.settingsSections.providers}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.needToken})]})]})})}function xn({envVar:e,labels:t}){let[n,r]=(0,X.useState)(!1),i=async()=>{try{await navigator.clipboard.writeText(e),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}};return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`code`,{className:`rounded bg-surface-hover px-1.5 py-0.5 font-mono text-[11px] text-fg-muted`,children:e}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void i(),className:`rounded p-0.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,title:n?t.copied:t.copy,"aria-label":n?t.copied:t.copy,children:n?(0,Y.jsx)(w,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Y.jsx)(j,{className:`size-3.5`,"aria-hidden":!0})})]})}function Sn({row:e,value:t,rowDirty:n,labels:r,language:i,onChange:a,onReload:o,justSaved:s,availableModels:c}){let[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),b=qt(t),x=b&&!d?``:t,ee=e.configured&&!b&&!!t,[T,E]=(0,X.useState)(!1),[O,ne]=(0,X.useState)(),[k,A]=(0,X.useState)(),[re,N]=(0,X.useState)(),[oe,se]=(0,X.useState)(),[I,L]=(0,X.useState)(),[R,z]=(0,X.useState)(``),[B,ce]=(0,X.useState)(!1),[V,H]=(0,X.useState)(null),[U,W]=(0,X.useState)(null),K=e.activeKeySource??`none`,le=(0,X.useMemo)(()=>mn(e.id,i),[e.id,i]);(0,X.useEffect)(()=>()=>{O&&un(O).catch(()=>{})},[O]),(0,X.useEffect)(()=>{if(!O||!T)return;let e=window.setInterval(()=>{(async()=>{try{let t=await sn(O);N(t.message),se(t.authUrl),L(t.instructions),t.status===`waiting_auth`||t.status===`waiting_code`?A(t.status===`waiting_code`?`waiting_code`:`waiting`):t.status===`completed`?(window.clearInterval(e),E(!1),A(`success`),N(t.message),window.setTimeout(()=>o(),800)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),E(!1),A(`error`),N(t.error||t.message||`OAuth failed`))}catch{}})()},1e3);return()=>window.clearInterval(e)},[O,T,o]);let ue=async()=>{E(!0),A(`waiting`),N(r.oauthStarting),ne(void 0),se(void 0),L(void 0);try{ne((await on(e.id)).sessionId)}catch(e){A(`error`),N(e instanceof Error?e.message:`OAuth failed`),E(!1)}},de=async()=>{if(O){try{await ln(O)}catch{}ne(void 0),E(!1),A(`idle`),N(void 0)}},fe=async()=>{if(!(!O||!R.trim()))try{await cn(O,R.trim()),z(``),N(r.oauthProcessingCode)}catch(e){A(`error`),N(e instanceof Error?e.message:`Failed`)}},pe=()=>{window.confirm(vn(r.revokeConfirm,{name:e.name}))&&(v(null),dn(e.id).then(()=>o()).catch(e=>v(e instanceof Error?e.message:r.revokeFailed)))},me=async()=>{if(!(!t||b))try{await navigator.clipboard.writeText(t),g(!0),window.setTimeout(()=>g(!1),2e3)}catch{}},he=async()=>{let e=t.trim();if(!(!e||qt(e))){ce(!0),H(null),W(null);try{let t=await Zt(e);if(t.error){W(!1),H(`${r.testFailed} ${t.error}`);return}W(!0),t.type===`env`?H(r.testOkEnv):t.type===`command`?H(r.testOkCommand):H(r.testOkLiteral)}catch(e){W(!1),H(e instanceof Error?e.message:r.testFailed)}finally{ce(!1)}}},ge=n?r.metaWillSave:e.configured?b?`${r.metaMasked} · ${r.runtimeLabelPrefix} ${yn(r,K)}`:`${r.runtimeLabelPrefix} ${yn(r,K)}`:r.metaNotConfigured,_e=`provider-details-${e.id}`;return(0,Y.jsxs)(`div`,{className:`bg-surface-panel`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-3 sm:px-4`,children:[(0,Y.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md bg-surface-hover/80 dark:bg-surface-hover/50`,"aria-hidden":!0,children:e.configured?(0,Y.jsx)(w,{className:`size-4 text-emerald-600 dark:text-emerald-400`}):(0,Y.jsx)(y,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.name}),(0,Y.jsx)(hn,{providerId:e.id,language:i}),(0,Y.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 font-mono text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:e.id}),(0,Y.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:e.category})]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:ge})]}),(0,Y.jsx)(G,{type:`button`,variant:`ghost`,className:`h-9 w-9 shrink-0 p-0`,"aria-expanded":l,"aria-controls":_e,"aria-label":r.expandRowDetails,onClick:()=>u(e=>!e),children:(0,Y.jsx)(te,{className:h(`size-4 transition-transform`,l&&`rotate-180`),"aria-hidden":!0})})]}),l?(0,Y.jsxs)(`div`,{id:_e,role:`region`,className:`space-y-3 border-t border-edge-subtle bg-surface-base/40 px-3 py-3 dark:bg-surface-base/20 sm:px-4`,children:[e.supportsApiKey===!1?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`relative flex flex-col gap-2 sm:flex-row sm:gap-2`,children:[(0,Y.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,Y.jsx)(`input`,{type:d||!b?`text`:`password`,className:h(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-3 pr-20 font-mono text-sm text-fg`,`placeholder:text-fg-subtle`,q,`dark:border-edge`),value:x,placeholder:b?r.placeholderOverride:e.configured?r.placeholderKeep:r.placeholderKey,disabled:T,onChange:t=>a(e.id,t.target.value),autoComplete:`off`,spellCheck:!1}),(0,Y.jsxs)(`div`,{className:`absolute right-1 top-1/2 flex -translate-y-1/2 gap-0.5`,children:[t&&!b?(0,Y.jsx)(`button`,{type:`button`,className:h(`rounded p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,J.transition,J.press,J.focusRingPanel),title:p?r.copied:r.copy,"aria-label":p?r.copied:r.copy,onClick:()=>void me(),children:p?(0,Y.jsx)(w,{className:`size-4`}):(0,Y.jsx)(j,{className:`size-4`})}):null,(0,Y.jsx)(`button`,{type:`button`,className:h(`rounded p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg disabled:opacity-40`,J.transition,J.press,J.focusRingPanel),title:d?r.hide:r.show,"aria-label":d?r.hide:r.show,disabled:b,onClick:()=>f(e=>!e),children:d?(0,Y.jsx)(ie,{className:`size-4`}):(0,Y.jsx)(M,{className:`size-4`})})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2 sm:shrink-0`,children:[(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`gap-1`,disabled:T||B||!t.trim()||qt(t),onClick:()=>void he(),children:[B?(0,Y.jsx)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,B?r.testingKey:r.testKey]}),e.supportsOAuth?ee?(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`gap-1 text-red-600 dark:text-red-400`,onClick:pe,children:[(0,Y.jsx)(S,{className:`size-4`,"aria-hidden":!0}),r.revoke]}):(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`gap-1`,disabled:T,onClick:()=>void ue(),children:[T?(0,Y.jsx)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(D,{className:`size-4`,"aria-hidden":!0}),r.oauth]}):null]})]}),V?(0,Y.jsx)(`p`,{className:h(`text-xs`,U===!1?`text-red-600 dark:text-red-400`:`text-fg-muted`),role:`status`,children:V}):null,le.length>0?(0,Y.jsx)(`div`,{className:`flex flex-col gap-1`,children:le.map(e=>(0,Y.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[fn(e.kind,r),(0,Y.jsx)(ae,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null]}),re?(0,Y.jsxs)(`div`,{className:h(`flex gap-2 rounded-md px-3 py-2 text-xs`,k===`error`?`border border-red-200 bg-red-50 text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`:`bg-surface-base text-fg-muted`),children:[k===`error`?(0,Y.jsx)(C,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}):k===`success`?(0,Y.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-emerald-600`,"aria-hidden":!0}):(0,Y.jsx)(P,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:re})]}):null,_?(0,Y.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:[(0,Y.jsx)(C,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:_})]}):null,(k===`waiting`||k===`waiting_code`)&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[oe?(0,Y.jsxs)(`a`,{href:oe,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,Y.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),r.openAuthPage]}):null,(0,Y.jsxs)(G,{type:`button`,variant:`secondary`,className:`gap-1`,onClick:()=>void de(),children:[(0,Y.jsx)(m,{className:`size-4`,"aria-hidden":!0}),r.cancelOAuth]})]}),I?(0,Y.jsxs)(`div`,{className:`flex gap-2 rounded-md bg-surface-hover/60 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/40`,children:[(0,Y.jsx)(P,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:I})]}):null,k===`waiting_code`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Y.jsx)(`input`,{type:`text`,className:h(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,q,`dark:border-edge`),value:R,placeholder:r.pasteRedirectUrl,onChange:e=>z(e.target.value),onKeyDown:e=>e.key===`Enter`&&void fe()}),(0,Y.jsx)(G,{type:`button`,variant:`primary`,className:`shrink-0`,onClick:()=>void fe(),children:r.submitCode})]}):null,b?(0,Y.jsxs)(`div`,{className:`flex gap-2 rounded-md bg-surface-hover/60 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/40`,children:[(0,Y.jsx)(P,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:K===`env`?r.envHint:r.maskedStoredHint})]}):null,e.supportsOAuth&&!b&&!ee?(0,Y.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.oauthHint}):null,s?(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-surface-hover/60 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/40`,children:[(0,Y.jsx)(w,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:(()=>{let t=c.filter(t=>t.provider===e.id);if(t.length===0)return r.savedNoModels;let n=t.slice(0,3).map(e=>e.name||e.id).join(`, `),i=t.length>3?`… (+${t.length-3})`:``;return`${t.length} ${r.savedModelsAvailable}: ${n}${i}`})()})]}):null,(pn[e.id]?.envVars??[]).length>0?(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer select-none list-none text-xs text-fg-subtle hover:text-fg-muted`,children:r.envVarAlt}),(0,Y.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-1`,children:(pn[e.id]?.envVars??[]).map(e=>(0,Y.jsx)(xn,{envVar:e,labels:r},e))})]}):null]}):null]})}var Cn=[`appearance`,`agent-defaults`,`providers`,`models`,`voice`,`gateway`,`heartbeat`,`search`];function wn(){let{section:e}=p(),t=s(e=>e.language),n=r(t);if(e===`agent`||e===`agents`)return(0,Y.jsx)(d,{to:`/agents`,replace:!0});if(!e||!Cn.includes(e))return(0,Y.jsx)(d,{to:`/settings/appearance`,replace:!0});let i=e,a=n.settingsSections[i];return i===`appearance`?(0,Y.jsx)(De,{}):i===`agent-defaults`?(0,Y.jsx)(Se,{}):i===`providers`?(0,Y.jsx)(bn,{}):i===`models`?(0,Y.jsx)(St,{}):i===`voice`?(0,Y.jsx)(Ht,{}):i===`gateway`?(0,Y.jsx)(Me,{}):i===`heartbeat`?(0,Y.jsx)(Xe,{}):i===`search`?(0,Y.jsx)(rn,{}):(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:a}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t===`zh`?`设置 · ${a}(即将推出)。`:`Settings · ${a} (coming soon).`})]})}export{wn as SettingsPage};
|
|
2
|
-
//# sourceMappingURL=settings-page-BvSj0JqX.js.map
|