@xopcai/xopc 0.0.397 → 0.0.398
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CIEGrioy.js → agent-avatar-dicebear-Q-lKLSrc.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CobxTBV_.js +1 -0
- package/dist/gateway/static/root/assets/agents-Bgmmue5K.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-BjGOUrAf.js → agents-admin-api-DvSe10zu.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DIJ0ii-n.js → app-management-settings-panel-CB_W2ano.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BGnyHS-p.js → appearance-settings-B-ppSGBm.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-3qUgsGui.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CR8FcRAa.js → archive-plugin-CeQrQ693.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BLInZo7N.js → automations-page-Cc9vZanv.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Bc4c_AEq.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DW9pu205.js → binary-plugins-BqaVBv1R.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-ClgTc5v8.js → block-editor-B4ij8nZi.js} +40 -40
- package/dist/gateway/static/root/assets/{browser-automation-inputs-Bn7kDuUB.js → browser-automation-inputs-DngvcZH9.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-CdqwXyYq.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-CJT0rB-I.js +3 -0
- package/dist/gateway/static/root/assets/{capabilities-CTfLd_UE.js → capabilities-glv1DeRI.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-C56VsP0Y.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DZiA8JIq.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-9ZG71-BO.js → capability-header-actions-Cu-ATcJq.js} +1 -1
- package/dist/gateway/static/root/assets/capability-links--dcwUjgv.js +1 -0
- package/dist/gateway/static/root/assets/channels-gIjZtYnV.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-x1W2_hwc.js → chat-terminal-dock-COdvmTgN.js} +2 -2
- package/dist/gateway/static/root/assets/computer-settings-page-C1XHsuI8.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-Kf8kaNm_.js → connector-service-page-Cv2bhnQ5.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-SmKItq0N.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-d5kiPUG0.js → date-picker-CCnqYwy0.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BcH76tQC.js → dependency-picker-nt5ruIio.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-B-925tPX.js → desktop-pet-Bn8xj1v3.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-3XJ4qR65.js → desktop-pet-settings-Cbl1J_VE.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-Tadg9co1.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-B-qZCjGR.js → directory-picker-path-field-DuE5ez1E.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BlQu1u6X.js → extension-debug-page-jsNxwqNi.js} +1 -1
- package/dist/gateway/static/root/assets/extension-page-N_rBjYX8.js +1 -0
- package/dist/gateway/static/root/assets/extension-settings-page-7qAdvlRB.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-Di9g6pE8.js → gateway-config-swr-DAir1JsW.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-2-o7qk92.js → gateway-realtime-dE0XrVAT.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-CPlVuu0d.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-ViqOhx_m.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BCUswcVy.js → gateway-startup-retry-CqyGHM2M.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-Czdbbi0H.js → highlighted-body-KQOG7T2V-XrkWdmrk.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-C_Xn_Kkz.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-DPFPJ2ps.js → image-generation-api-CmHdM2uL.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-Bwyotfbt.js → imports-page-B-dnvHP_.js} +1 -1
- package/dist/gateway/static/root/assets/index-DWzv8ZoO.css +1 -0
- package/dist/gateway/static/root/assets/{index-Dsp_gNdl.js → index-DvKDT-RQ.js} +11 -11
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C20gl-l7.js → keyboard-shortcuts-settings-mCs9cDgv.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-o0M_OSjC.js → local-app-workbench-page-B7AtlfWQ.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DoWJCmOq.js → local-apps-page-CIJE7jME.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-BjwlkAKA.js → local-session-drafts-fhip41-L.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Djl2FW6_.js → locale-store-Jnhw2WMv.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BFTL93RX.js → logs-page-HawXUKF2.js} +2 -2
- package/dist/gateway/static/root/assets/management-settings-DByEh6rq.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DyO7Q0Ms.js → markdown-view-B58RypQ4.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DLrTRF0a.js → media-plugins-B8BLxQgj.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-CZjPT7xE.js +1 -0
- package/dist/gateway/static/root/assets/messages-DBvKzlCl.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-hQHB5fCs.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BEusEk31.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-YTVWZ02-.js → page-context-capture-button-42bq8N6-.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-DPR5gzhf.js +1 -0
- package/dist/gateway/static/root/assets/plugin-details-dialog-D8dKKIY9.js +1 -0
- package/dist/gateway/static/root/assets/plugin-presentation-BrQpVvjC.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DzA__S54.js → preview-open-alternatives-DKyLVLpX.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DvlMKj0T.js → product-open-page-DcGH0AXN.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-qdFyo4NG.js → product-preview-content-Ck6OzP09.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BHoQ10Eo.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DYsq_OLJ.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BwR2CiR5.js → registry-api-BbUEMGcj.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CU3EChY0.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-C_VOMhLI.js → runtime-tools-api-D0xtCTXr.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BCHLh-KQ.js → runtime-tools-settings-panel-Bfs5zKDg.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CJvaVHkx.js → schema-form-BbI2BuSU.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-DbNNQps9.js → session-api-CAKgrbgz.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-DfVviLTK.js → session-manager-D_N7qha7.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CjB2GOTs.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-jbVx8gcF.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-B3eODxNv.js → settings-form-section-BfBBJlr-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-Dg86uCnr.js → settings-page-9yu4SN1j.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DhWB3feW.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DCy1f25V.js → share-preview-page-B6lQl5xb.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-UJGjdz3F.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-RisyPAMA.js → skill-api-y2m3k_R4.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Bk9FqsVa.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DLd4O-Fo.js +2 -0
- package/dist/gateway/static/root/assets/{style-CwMX73G7.js → style-C2ptQg95.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Cma37Pfm.js → system-settings-panel-DYzcLnVk.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-DLGtmHAH.js +2 -0
- package/dist/gateway/static/root/assets/{task-expandable-content-D3i_51Oc.js → task-expandable-content-HdEeV_0-.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-DC-kLysq.js → tracing-settings-page-DKQYmzFn.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-BgdhbR1L.js → tunnel-api-C2VY_HTy.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-CjzunQtj.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-iKvZ1pvC.js → use-autosave-BElgnGMt.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-DsOGCDTR.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CESbtuwM.js → voice-api-key-field-FVjX0qhn.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-Ceo_hqZC.js → voice-config-api-T3nM4buh.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-dtPpmYyh.js → work-discovery-overlay-B2S2NZuK.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DmFn3E_B.js → workflow-run-setup-panel-2Gq34KQk.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CjeFD3mk.js +6 -0
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DTZnabfg.js → xopc-cloud-account-card-BZMIZxWg.js} +1 -1
- package/dist/gateway/static/root/index.html +15 -15
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +8 -0
- package/dist/src/agent/agent-manager.js +3 -3
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/external-tools/cliProvider.js +2 -2
- package/dist/src/agent/external-tools/composio-provider.js +2 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent/workspace-runtime/registry.js +1 -1
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/service/action-executor.js +2 -2
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/browser/native-messaging-host.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +2 -2
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/channels/index.js +1 -1
- package/dist/src/channels/manager.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/agent-model-intents.js +1 -1
- package/dist/src/config/agent-profile.js +2 -2
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +2 -2
- package/dist/src/extensions/agent-plugins/branding.d.ts +6 -0
- package/dist/src/extensions/agent-plugins/branding.js +11 -1
- package/dist/src/extensions/agent-plugins/cli-authorization.d.ts +11 -0
- package/dist/src/extensions/agent-plugins/cli-authorization.js +11 -6
- package/dist/src/extensions/agent-plugins/inventory.d.ts +12 -0
- package/dist/src/extensions/agent-plugins/inventory.js +3 -2
- package/dist/src/extensions/agent-plugins/setup-contract.d.ts +20 -0
- package/dist/src/extensions/agent-plugins/setup-contract.js +20 -1
- package/dist/src/extensions/agent-plugins/setup.d.ts +8 -0
- package/dist/src/extensions/agent-plugins/setup.js +10 -5
- package/dist/src/extensions/agent-plugins/skill-catalog.d.ts +14 -0
- package/dist/src/extensions/agent-plugins/skill-catalog.js +95 -0
- package/dist/src/extensions/agent-plugins/store.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/hono/app.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/agent-plugins.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/browser-install.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/context-sources.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/service/marketplace-service.js +4 -2
- package/dist/src/gateway/service.js +9 -9
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/personal-agent/proactivity/service.js +1 -1
- package/dist/src/personal-agent/service.js +2 -2
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/routing/resolve-route.js +1 -1
- package/dist/src/routing/resolve-tui-session-key.js +1 -1
- package/dist/src/storage/sqlite/device-pairing-approval.js +1 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.js +1 -1
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CzKNVkRn.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-mpA9rwYd.js +0 -1
- package/dist/gateway/static/root/assets/agents-7VMa7Rzo.js +0 -77
- package/dist/gateway/static/root/assets/apps-page-CvqDUvof.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-DvTSHLt3.js +0 -6
- package/dist/gateway/static/root/assets/browser-automations-page-CJGBhDnv.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-tsi5W-cJ.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-page-CfbGk8q_.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BkO7QEyA.js +0 -8
- package/dist/gateway/static/root/assets/channels-D0CwJktG.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-D_b_bFVz.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DlpfL2Rc.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-12m5Z9-8.js +0 -1
- package/dist/gateway/static/root/assets/extension-page-CXxM1M62.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-AF5nvsPP.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DQ6-whg-.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-ABXvW_yL.js +0 -1
- package/dist/gateway/static/root/assets/home-page-LXGxGwVl.js +0 -2
- package/dist/gateway/static/root/assets/index-BKHxJaGD.css +0 -1
- package/dist/gateway/static/root/assets/management-settings-C52cuMg1.js +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-CPYJsRUJ.js +0 -1
- package/dist/gateway/static/root/assets/messages-DPxcWxfD.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-CNN41byS.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BsfBp_8z.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-N4KoCZYG.js +0 -1
- package/dist/gateway/static/root/assets/plugin-details-page-DcrrzQI-.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-y67s_fA8.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D5iYgi0O.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DeFF7Re-.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DZ93_D5M.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-F1WX7vxq.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-ruFzAArp.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DeIVZvpJ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Dwkm1Fof.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-UiTLsrFc.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-BKOF_kxS.js +0 -2
- package/dist/gateway/static/root/assets/usage-page-BSlFg3Xj.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-D4GB8QsM.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-DEtaRuxH.js +0 -6
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{d as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./external-link-DjqjBmc3.js";import{t as f}from"./eye-CABVeTq0.js";import{t as p}from"./plus-Q2yW6OE7.js";import{t as m}from"./x-B_N4OPjy.js";import{t as h}from"./messages-DPxcWxfD.js";import{t as g}from"./cn-0WouolD0.js";import{a as _,c as v,i as y,n as b,r as x}from"./locale-store-Djl2FW6_.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./dist-BGTk37IG.js";import{i as k}from"./vendor-swr-BIWyz7Rc.js";import{n as A,r as j}from"./gateway-config-swr-Di9g6pE8.js";import{n as M,t as N}from"./registry-api-BwR2CiR5.js";import{$i as P,$l as F,$s as I,Al as L,Ao as R,As as z,At as ee,Bt as B,Cn as V,Ct as H,Dn as U,Dt as te,En as W,Et as ne,F as re,Fc as G,Fn as K,Ft as ie,Fu as ae,G as oe,Gs as q,Gt as J,Ht as se,Hu as ce,I as le,Ic as ue,In as Y,Is as de,Js as fe,Jt as pe,Kd as me,Ks as he,Kt as ge,L as _e,Ls as ve,Lt as ye,Mt as be,Ns as xe,Nt as Se,Ot as Ce,Ps as we,Pt as Te,Rc as Ee,Rs as De,Rt as Oe,Sn as ke,St as Ae,Tf as je,Tn as Me,Tt as Ne,Ut as Pe,Vl as Fe,Vs as Ie,Vt as Le,Wc as X,Ws as Re,Wu as ze,Xl as Be,Xs as Ve,Xt as He,Ys as Ue,Yt as We,Za as Ge,_t as Ke,as as qe,bn as Je,bt as Ye,bu as Xe,dd as Ze,ds as Qe,ea as $e,ec as et,eo as tt,fs as Z,gl as nt,hu as rt,if as it,js as at,jt as ot,kl as st,kt as ct,mu as lt,ql as ut,qn as dt,qs as ft,qt as pt,sd as mt,sf as ht,ss as gt,su as _t,to as vt,us as yt,vs as bt,vt as xt,wf as St,wn as Ct,wt,xl as Tt,xn as Et,xt as Dt,yl as Ot,ys as kt,yt as At,zt as jt}from"./index-Dsp_gNdl.js";import{t as Mt}from"./number-input-DDeqHK-G.js";import{n as Nt,r as Pt}from"./settings-page-layout-Dx5S-Msc.js";import{n as Ft,t as It}from"./settings-form-section-B3eODxNv.js";import{n as Lt,t as Rt}from"./use-autosave-iKvZ1pvC.js";import{c as zt,f as Bt,i as Vt,l as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as Jt}from"./voice-config-api-Ceo_hqZC.js";import{t as Yt}from"./voice-api-key-field-CESbtuwM.js";import{a as Xt,i as Zt,n as Qt,o as $t,r as en,s as tn,t as nn}from"./image-generation-api-DPFPJ2ps.js";import{t as rn}from"./xopc-cloud-account-card-DTZnabfg.js";var an=n(),Q=e(t(),1),$=r(),on={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},sn=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function cn(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function ln(e){let t=e.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function un({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a,portalContainer:o,onPendingChange:s}){let c=on[i],[l,u]=(0,Q.useState)(``),[d,h]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`bearer`),[x,k]=(0,Q.useState)(`x-api-key`),[A,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(``),[I,R]=(0,Q.useState)(`/images/generations`),[z,ee]=(0,Q.useState)(`/images/edits`),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(``),[te,W]=(0,Q.useState)([cn()]),[ne,re]=(0,Q.useState)(``),[G,K]=(0,Q.useState)(),[ie,ae]=(0,Q.useState)(!1),[oe,q]=(0,Q.useState)(),[J,se]=(0,Q.useState)(),[ce,le]=(0,Q.useState)();(0,Q.useEffect)(()=>(s?.(!!G),()=>s?.(!1)),[G,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;u(n?.providerId??``),h(t?.name??``),v(n?.baseUrl??``),b(t?.auth.type??`bearer`),k(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),j(r?`••••••••••••`:``),N(t?.apiKeyUrl??``),F(t?.documentationUrl??``),R(t?.paths?.generations??`/images/generations`),ee(t?.paths?.edits??`/images/edits`),V(t?.network?.allowedHosts.join(`
|
|
4
|
-
`)??``),U(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
|
-
`)),W(t?.models.map(cn)??[cn()]),re(t?.defaultModel??``),se(void 0),K(void 0),ae(!1),q(void 0),le(void 0)},[r,e,n]);let ue=(0,Q.useMemo)(()=>te.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[te]),Y=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))},de=()=>{let e=l.trim(),t=te.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!d.trim()||!_.trim()||t.some(e=>!e.id))throw Error(c.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(c.duplicateModels);let n=ne||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(c.required);let r;try{r=ln(H)}catch{throw Error(c.invalidHeaders)}return{providerId:e,input:{baseUrl:_.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:d.trim(),...P.trim()?{documentationUrl:P.trim()}:{},...M.trim()?{apiKeyUrl:M.trim()}:{},defaultModel:n,auth:y===`header`?{type:`header`,headerName:x.trim()}:{type:y},paths:{...I.trim()?{generations:I.trim()}:{},...z.trim()?{edits:z.trim()}:{}},...B.trim()?{network:{allowedHosts:B.split(`
|
|
6
|
-
`).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},fe=async()=>{let e=de();return await Zt(e.providerId,e.input),y!==`none`&&A.trim()&&!we(A)&&await Xt(e.providerId,A.trim()),await a(e.providerId),e},pe=async()=>{K(`save`),q(void 0),se(void 0);try{await fe(),j(y===`none`?``:`••••••••••••`),se(c.saved)}catch(e){q(e instanceof Error?e.message:String(e))}finally{K(void 0)}},me=async()=>{K(`test`),q(void 0),se(void 0),le(void 0);try{let e=await fe();le((await $t(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),se(c.testReady)}catch(e){q(e instanceof Error?e.message:String(e))}finally{K(void 0)}},he=async()=>{if(n){if(!ie){ae(!0);return}K(`delete`),q(void 0);try{await nn(n.providerId),await a(),t(!1)}catch(e){q(e instanceof Error?e.message:String(e))}finally{K(void 0)}}};return(0,$.jsx)(O,{open:e,onOpenChange:e=>{G||t(e)},children:(0,$.jsxs)(T,{container:o,children:[(0,$.jsx)(S,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim`,kt)}),(0,$.jsxs)(E,{className:g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,bt),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(D,{className:`font-semibold text-fg`,children:n?c.editTitle:c.addTitle}),(0,$.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:c.intro})]}),(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:!!G,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":c.cancel,children:(0,$.jsx)(m,{className:`size-5`})})})]}),(0,$.jsxs)(`fieldset`,{disabled:!!G,className:`min-h-0 min-w-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.providerId,(0,$.jsx)(`input`,{value:l,disabled:!!n,onChange:e=>u(e.target.value),placeholder:`my-image-service`,className:sn}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.name,(0,$.jsx)(`input`,{value:d,onChange:e=>h(e.target.value),placeholder:`My Image Service`,className:sn})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.baseUrl,(0,$.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:`https://api.example.com/v1`,className:sn})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.auth,(0,$.jsx)(yt,{value:y,options:[{value:`bearer`,label:c.bearer},{value:`header`,label:c.header},{value:`none`,label:c.none}],placeholder:c.auth,allowEmpty:!1,onChange:e=>b(e),triggerClassName:`mt-1.5`})]}),y===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.headerName,(0,$.jsx)(`input`,{value:x,onChange:e=>k(e.target.value),className:sn})]}):null]}),y===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:c.apiKey}),M.trim()?(0,$.jsxs)(`a`,{href:M.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[c.openKeyPage,(0,$.jsx)(St,{className:`size-3.5`})]}):null]}),(0,$.jsx)(xe,{id:`custom-image-api-key`,value:A,onChange:e=>j(we(A)?e.replace(/^•+/,``):e),labels:{show:c.show,hide:c.hide,copy:c.copy,copied:c.copied},reveal:()=>pt(l).then(e=>e.apiKey),loadFailedLabel:c.revealFailed,notInConfigFile:c.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.apiKeyUrl,(0,$.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),placeholder:`https://…`,className:sn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.docsUrl,(0,$.jsx)(`input`,{value:P,onChange:e=>F(e.target.value),placeholder:`https://…`,className:sn})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:c.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.generationsPath,(0,$.jsx)(`input`,{value:I,onChange:e=>R(e.target.value),className:sn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.editsPath,(0,$.jsx)(`input`,{value:z,onChange:e=>ee(e.target.value),className:sn})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.allowedHosts,(0,$.jsx)(`textarea`,{value:B,onChange:e=>V(e.target.value),rows:2,placeholder:`127.0.0.1
|
|
7
|
-
image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.staticHeaders,(0,$.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.models}),(0,$.jsxs)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>W(e=>[...e,cn()]),children:[(0,$.jsx)(p,{className:`size-4`}),c.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.defaultModel,(0,$.jsx)(yt,{value:ne||ue[0]?.value||``,options:ue,placeholder:c.defaultModel,allowEmpty:!1,onChange:re,triggerClassName:`mt-1.5 max-w-sm`})]}),te.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>Y(t,{id:e.target.value}),placeholder:`image-1`,className:sn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>Y(t,{name:e.target.value}),className:sn})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>Y(t,{maxCount:e.target.value}),className:sn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>Y(t,{defaultCount:e.target.value}),className:sn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>Y(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:sn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.format,(0,$.jsx)(yt,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:c.format,allowEmpty:!0,onChange:e=>Y(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>Y(t,{supportsSize:e.target.checked})}),c.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>Y(t,{editEnabled:e.target.checked})}),c.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:te.length===1,onClick:()=>W(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(L,{className:`size-3.5`}),c.remove]})]})]},t))]}),ce?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(f,{className:`size-4`}),c.testReady]}),(0,$.jsx)(`img`,{src:ce,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,J?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:J}):null,oe?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:oe}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(X,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!G,onClick:()=>void he(),children:[G===`delete`?(0,$.jsx)(ze,{className:`size-4 animate-spin`}):(0,$.jsx)(L,{className:`size-4`}),ie?c.confirmDelete:c.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(X,{variant:`secondary`,disabled:!!G,children:c.cancel})}),(0,$.jsxs)(X,{variant:`secondary`,disabled:!!G,onClick:()=>void me(),children:[G===`test`?(0,$.jsx)(ze,{className:`size-4 animate-spin`}):null,G===`test`?c.testing:c.test]}),(0,$.jsxs)(X,{variant:`primary`,disabled:!!G,onClick:()=>void pe(),children:[G===`save`?(0,$.jsx)(ze,{className:`size-4 animate-spin`}):null,G===`save`?c.saving:c.save]})]})]})]})]})})}var dn=`••••••••••••`,fn={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function pn(){let e=await _(x(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function mn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function hn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function gn(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function _n(e){let t=(0,an.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(yt,{value:r,options:(n.options??[]).map(vn),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function vn(e){return{value:e.value,label:e.label}}function yn(){let e=(0,an.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ee,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(bn)}),(0,$.jsx)(Ee,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function bn(e,t){return(0,$.jsx)(Ee,{className:`h-24 rounded-xl`},t)}function xn({connectOnly:e=!1,onConnected:t,onPendingChange:n}={}){let r=b(e=>e.language),a=fn[r],o=!!v(e=>e.conversationId),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(``),[f,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({}),[y,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(n?.(y||C),()=>n?.(!1)),[y,C,n]);let[D,O]=(0,Q.useState)(),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(),{data:R,isLoading:z,error:ee,mutate:B}=k(o?x(`/api/image-generation/catalog`):null,en,{revalidateOnFocus:!1}),{data:V,isLoading:H,error:U,mutate:te}=k(o?x(`/api/image-generation/custom-providers`):null,Qt,{revalidateOnFocus:!1}),{data:W,isLoading:ne,error:re,mutate:G}=k(o?`default-image-generation`:null,pn,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!R||!W)return;let e=mn(W.model?.primary),t=R.find(t=>t.id===e)??R.find(e=>e.configured)??R[0];t&&(c(t.id),d(t.id===e&&hn(W.model?.primary)||t.defaultModel),m(t.configured?dn:``),g(gn(t)))},[W,R]);let K=R?.find(e=>e.id===s),ie=K?K.apiKeyUrl??ot(K.id,r)[0]?.href:void 0,ae=(0,Q.useMemo)(()=>(K?.models??[]).map(e=>({value:e,label:e})),[K?.models]),oe=W?.model?.primary,q=!!(K&&l&&(K.credentialMode!==`api-key`||K.configured||f.trim())&&K.configFields.every(e=>!e.required||h[e.key]?.trim()));if(!o)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.connect});if(z||H||ne)return(0,$.jsx)(yn,{});if(ee||U||re||!R||!V)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a.loadError});let J=e=>{c(e.id),d(e.defaultModel),m(e.configured?dn:``),g(gn(e)),O(void 0)},se=()=>{L(void 0),P(!0)},ce=()=>{let e=V.find(e=>e.providerId===K?.id);e&&(L(e),P(!0))},le=async n=>{let[r,i]=await Promise.all([te(),B()]);if(n&&i?.some(e=>e.id===n)){let a=i.find(e=>e.id===n);c(a.id),d(a.defaultModel),m(a.configured?dn:``),g(gn(a)),L(r?.find(e=>e.providerId===n)),e&&a.configured&&t?.()}},ue=async()=>{if(!(!K||!q)){S(!0),O(void 0),M(!1);try{if(e){f.trim()&&!we(f)&&await Xt(K.id,f.trim()),Object.keys(h).length&&await _(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:{[K.id]:h}})});let[e]=await Promise.all([B(),A()]);if(!e?.find(e=>e.id===K.id)?.configured)throw Error(r===`zh`?`连接尚未就绪,请先完成对应服务的授权或凭据设置。`:`Connection is not ready. Complete authorization or credentials first.`);M(!0),t?.();return}let n=await _(x(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:K.id,modelId:l,...f.trim()&&!we(f)?{apiKey:f.trim()}:{},providerConfig:Object.fromEntries(Object.entries(h).filter(([,e])=>e.trim()))})});if(!n.payload)throw Error(`Invalid setup response`);await Promise.all([G(n.payload.default,{revalidate:!1}),B(n.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),A()]),m(dn),M(!0)}catch(e){O(e instanceof Error?e.message:String(e))}finally{S(!1)}}};return(0,$.jsxs)(`div`,{ref:E,className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(Ze,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:e?r===`zh`?`连接图片来源,不修改默认模型,也不发送生成测试请求。`:`Connect image sources without changing defaults or sending generation tests.`:a.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:a.provider}),(0,$.jsxs)(X,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:se,children:[(0,$.jsx)(p,{className:`size-4`}),a.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:R.map(e=>{let t=e.id===s,n=e.id===mn(oe);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>J(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${t?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:a.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!n,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${n?``:`invisible`}`,children:a.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(u,{className:`size-3.5`}):(0,$.jsx)(mt,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?a.configured:a.needsKey]})]},e.id)})})]}),K?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[e?null:(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a.model,(0,$.jsx)(yt,{value:l,options:ae,placeholder:a.selectModel,allowEmpty:!1,onChange:d,triggerClassName:`mt-1.5`})]}),K.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(_n,{field:e,value:h[e.key]??``,onChange:t=>g(n=>({...n,[e.key]:t}))},e.key))]}),K.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(X,{variant:`secondary`,onClick:ce,children:[(0,$.jsx)(F,{className:`size-4`}),a.manageService]})}):null,K.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:a.apiKey}),ie?(0,$.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[a.getApiKey,(0,$.jsx)(St,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(xe,{id:`image-generation-api-key`,value:f,onChange:e=>m(we(f)?e.replace(/^•+/,``):e),placeholder:K.configured?a.existingKey:a.needsKey,labels:{show:a.show,hide:a.hide,copy:a.copy,copied:a.copied},reveal:()=>pt(K.id).then(e=>e.apiKey),loadFailedLabel:a.revealFailed,notInConfigFile:a.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},K.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:K.configured?a.savedKey:a.apiKeyHint})]}):null,K.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(ut,{className:`size-4`}),a.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:K.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(_n,{field:e,value:h[e.key]??``,onChange:t=>g(n=>({...n,[e.key]:t}))},e.key))})]}):null,j?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:e?r===`zh`?`连接已保存`:`Connection saved`:a.enabled}):null,D?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:D}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(X,{variant:`primary`,disabled:!q||y,onClick:()=>void ue(),children:[y?(0,$.jsx)(ze,{className:`size-4 animate-spin`}):(0,$.jsx)(u,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:e?y?r===`zh`?`保存中…`:`Saving…`:r===`zh`?`保存图片连接`:`Save image connection`:y?a.enabling:a.enable})]})]})})]}):null,(0,$.jsx)(un,{portalContainer:T?.closest(`[role="dialog"]`),onPendingChange:w,open:N,onOpenChange:P,provider:I,configured:!!(I&&R.find(e=>e.id===I.providerId)?.configured),language:r,onSaved:le})]})}function Sn({disabled:e=!1,modes:t,onPendingChange:n}){let r=b(e=>e.language),i=r===`zh`,[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>(n?.(a),()=>n?.(!1)),[a,n]);let[s,c]=(0,Q.useState)(``),{data:l,mutate:u,error:d}=k(x(`/api/voice/catalog`),async e=>{let t=await _(e);return Ue.parse(t.payload)}),f=i?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},p=async e=>{if(l){o(!0),c(``);try{let t=await _(x(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:l.revision,selection:e})}:{}});await u(Ue.parse(t.payload),!1),await A()}catch(e){c(e instanceof Error?e.message:String(e)),await u()}finally{o(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:i?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(X,{variant:`secondary`,disabled:a||e||!l,onClick:()=>void p(),children:i?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),s||d?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:s||String(d)}):null,l?(0,$.jsx)($.Fragment,{children:t.map(t=>{let n=l.selections.find(e=>e.mode===t),o=l.models.filter(e=>e.voice.modes.includes(t)),s=o.find(e=>e.id===n?.model),c=s?.voice.voices.filter(e=>Ve(e,t))??[],u=n?.voice??c.find(e=>e.id===s?.voice.defaultVoice)?.id??c[0]?.id??``;return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:f[t]}),(0,$.jsxs)(Qe,{className:`w-full`,value:n?.model??``,disabled:a||e||!o.length,onChange:e=>void p({mode:t,model:e.target.value}),children:[(0,$.jsx)(Z,{value:``,disabled:!0,children:i?`选择模型`:`Choose model`}),n&&!s?(0,$.jsxs)(Z,{value:n.model,disabled:!0,children:[n.model,` · `,i?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(Z,{value:e.id,children:$e(e,r)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无可用模型`:`No available model`})]}),s&&c.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:i?`音色`:`Voice`}),(0,$.jsxs)(Qe,{className:`w-full`,value:u,disabled:a||e,onChange:e=>void p({mode:t,model:s.id,voice:e.target.value}),children:[n?.voice&&!c.some(e=>e.id===n.voice)?(0,$.jsxs)(Z,{value:n.voice,disabled:!0,children:[n.voice,` · `,i?`当前场景不可用`:`Unavailable for this mode`]}):null,c.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[$e(e,r),e.gender?` · ${i?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),c.find(e=>e.id===u)?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.find(e=>e.id===u)?.description}):null]}):null]},t)})}):(0,$.jsx)(Ee,{className:`h-48 w-full`})]})}function Cn({v:e}){let t=I(e=>e.microphoneId),n=I(e=>e.setMicrophoneId),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let u=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(Qe,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(Z,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(Z,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(Z,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,$.jsx)(X,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}var wn=(0,Q.createContext)(null);function Tn(e){let t=(0,an.c)(18),n,r;t[0]===e?(n=t[1],r=t[2]):({to:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let[i]=o(),a=(0,Q.useContext)(wn),s,c;t[3]===r?(s=t[4],c=t[5]):(s=new URLSearchParams(r.split(`?`)[1]??``),c=V(s.get(`configure`)),t[3]=r,t[4]=s,t[5]=c);let u=c,d;t[6]!==a||t[7]!==n||t[8]!==s||t[9]!==u?(d=e=>{n.onClick?.(e),!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&a&&u&&s.get(`tab`)===`services`&&(e.preventDefault(),a(u))},t[6]=a,t[7]=n,t[8]=s,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==i||t[12]!==r?(f=Ct(r,i),t[11]=i,t[12]=r,t[13]=f):f=t[13];let p;return t[14]!==n||t[15]!==d||t[16]!==f?(p=(0,$.jsx)(l,{...n,onClick:d,to:f}),t[14]=n,t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function En(e){let t=(0,an.c)(19),{zh:n}=e,{data:r,error:i,mutate:a}=k(`voice-dictation-route`,Dn),o,s;t[0]===a?(o=t[1],s=t[2]):(o=()=>{let e=()=>{a()};return window.addEventListener(`voice-config-changed`,e),window.addEventListener(`config-reload`,e),()=>{window.removeEventListener(`voice-config-changed`,e),window.removeEventListener(`config-reload`,e)}},s=[a],t[0]=a,t[1]=o,t[2]=s),(0,Q.useEffect)(o,s);let c=n?`同时用于聊天听写`:`Also used for chat dictation`,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`h2`,{className:`font-medium text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`默认与录音识别共用模型。已有的独立听写设置会保留。`:`Dictation shares this recognition model. Existing separate dictation settings are preserved.`,d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`p`,{className:`text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==r||t[8]!==i||t[9]!==n?(f=!r&&!i?(0,$.jsx)(Ee,{className:`h-5 w-64 max-w-full`}):(0,$.jsx)(`p`,{role:i?`alert`:`status`,className:`text-fg-muted`,children:i?n?`暂时无法读取听写状态。`:`Dictation status could not be loaded.`:r?.mode===`recorded`?n?`当前使用 ${r.provider},点击完成后转为文字。`:`Using ${r.provider}. Choose Finish to transcribe.`:r?.mode===`streaming`?n?`当前使用流式识别${r.provider?` · ${r.provider}`:``}。`:`Using streaming recognition${r.provider?` · ${r.provider}`:``}.`:n?`听写未就绪,请检查识别模型或已有的流式配置。`:`Check the recognition model or existing streaming configuration.`}),t[7]=r,t[8]=i,t[9]=n,t[10]=f):f=t[10];let p;t[11]!==r?.mode||t[12]!==n?(p=r?.mode===`recorded`?null:(0,$.jsx)(Tn,{className:`inline-block text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=transcription`,children:n?`管理识别服务`:`Manage recognition services`}),t[11]=r?.mode,t[12]=n,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==d||t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-edge p-4 text-sm`,children:[l,d,f,p]}),t[14]=l,t[15]=d,t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function Dn(){return Re(AbortSignal.timeout(15e3))}function On({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(Ie)?.active??!1,[s,c]=(0,Q.useState)(`idle`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),p=(0,Q.useRef)(`idle`),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=e=>{p.current=e,c(e)},_=()=>{m.current?.(),m.current=null};(0,Q.useEffect)(()=>()=>m.current?.(),[]);async function v(e){_(),i?.({input:!1,output:!1}),h.current=!1,u(``),f(``),g(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>v(a.timeout),6e4);m.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function v(e){t.signal.aborted||(g(`error`),f(e),_())}async function y(){g(`playing`),l();try{let e=await Ht(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),g(`confirm`))})}catch(e){v(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new ft,await c.start(),t.signal.throwIfAborted()),!e){await y();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:et()}),t.signal.aborted){l();return}if(s=await fe.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&v(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),h.current=!0,n?y():(g(`passed`),i?.({input:!0,output:!1}),_()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&v(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await q.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new he(o.sampleRate,s.session.inputFormat.sampleRate),g(`listening`)}catch(e){if(t.signal.aborted){l();return}v(e instanceof Error?e.message:a.testFailed)}}let y=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(X,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(ze,{className:`size-4 animate-spin`}):(0,$.jsx)(ae,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)(rt,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(Fe,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,$.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,$.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,$.jsx)(`p`,{children:a.speakNow}):null,l?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,$.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{children:a.heardQuestion}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,$.jsx)(`p`,{children:h.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function kn(e){let t=(0,an.c)(78),{section:n,v:r,form:i,pending:a,onChange:o}=e,s=b(Pn),c=r.setup,l;t[0]===i?l=t[1]:(l=JSON.stringify(i),t[0]=i,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d={signature:u,input:!1,output:!1},t[2]=u,t[3]=d);let[f,p]=(0,Q.useState)(d);f.signature!==u&&p({signature:u,input:!1,output:!1});let m;t[4]!==a||t[5]!==u?(m=a?null:[`voice-realtime-status`,u],t[4]=a,t[5]=u,t[6]=m):m=t[6];let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!0},t[7]=h):h=t[7];let{data:g,error:_,isLoading:v}=k(m,qt,h),y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=x(`/api/voice/catalog`),t[8]=y):y=t[8];let{data:S}=k(y,Nn),C=i.voice.realtime,w=C.tts,T=w?.provider??g?.tts?.provider,E=g?.tts?.model,D;t[9]!==E||t[10]!==T?(D=T&&E?[`realtime-voices`,T,E]:null,t[9]=E,t[10]=T,t[11]=D):D=t[11];let O;t[12]!==E||t[13]!==T?(O=()=>Ut(T,E,`realtime`),t[12]=E,t[13]=T,t[14]=O):O=t[14];let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},t[15]=A):A=t[15];let{data:j}=k(D,O,A),M;t[16]===j?M=t[17]:(M=j===void 0?[]:j,t[16]=j,t[17]=M);let N=M,P=N,F;t[18]===N?F=t[19]:(F=N.filter(Mn),t[18]=N,t[19]=F);let I=F,L=C.defaultEngine===`omni`,R=L?C.omni?.voice??``:w?.voice??``,z;t[20]!==S?.models||t[21]!==L||t[22]!==I||t[23]!==C.omni||t[24]!==P?(z=L&&C.omni?.provider===`qwen-token-plan-cn`?[{id:C.omni.voice,name:C.omni.voice}]:L?C.omni?.provider===`xopc-cloud`?S?.models.find(e=>e.id===C.omni?.model)?.voice.voices.filter(jn)??[]:I.length?I:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(An):P,t[20]=S?.models,t[21]=L,t[22]=I,t[23]=C.omni,t[24]=P,t[25]=z):z=t[25];let ee=z,B=!!(g?.enabled&&g.stt),V=!!(g?.enabled&&g.tts),H;t[26]!==i||t[27]!==o||t[28]!==C?(H=e=>o({...i,voice:{...i.voice,realtime:{...C,...e}}}),t[26]=i,t[27]=o,t[28]=C,t[29]=H):H=t[29];let U=H,te;t[30]!==a||t[31]!==C.enabled||t[32]!==c.disabled||t[33]!==c.needsSetup||t[34]!==c.pending||t[35]!==c.unverified||t[36]!==c.verified||t[37]!==u||t[38]!==f.signature?(te=(e,t)=>C.enabled?a?c.pending:e?t&&f.signature===u?c.verified:c.unverified:c.needsSetup:c.disabled,t[30]=a,t[31]=C.enabled,t[32]=c.disabled,t[33]=c.needsSetup,t[34]=c.pending,t[35]=c.unverified,t[36]=c.verified,t[37]=u,t[38]=f.signature,t[39]=te):te=t[39];let W=te,ne;t[40]!==R||t[41]!==s||t[42]!==L||t[43]!==T||t[44]!==C.bargeIn||t[45]!==C.defaultEngine||t[46]!==C.enabled||t[47]!==C.omni||t[48]!==C.tts||t[49]!==c.bargeIn||t[50]!==c.defaultVoice||t[51]!==c.enable||t[52]!==c.voice||t[53]!==n||t[54]!==w||t[55]!==g?.tts||t[56]!==U||t[57]!==r.experience||t[58]!==r.realtime||t[59]!==ee?(ne=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:c.enable}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":C.enabled,className:`ui-checkbox`,checked:C.enabled,onChange:e=>U({enabled:e.target.checked})})]}),(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(Qe,{value:C.defaultEngine,className:ve,onChange:e=>U({defaultEngine:e.target.value}),children:[(0,$.jsx)(Z,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(Z,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[C.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:c.voice}),(0,$.jsxs)(Qe,{id:`realtime-voice`,className:`${ve} w-full sm:w-56`,value:R,disabled:L?!C.omni:!w&&!g?.tts,onChange:e=>{if(L&&C.omni){U({omni:{...C.omni,voice:e.target.value}});return}if(T===`alibaba`||T===`xopc-cloud`){let t={...C.tts,provider:T};e.target.value?t.voice=e.target.value:delete t.voice,U({tts:t})}},children:[L?null:(0,$.jsx)(Z,{value:``,children:c.defaultVoice}),R&&!ee.some(e=>e.id===R)?(0,$.jsx)(Z,{value:R,children:R}):null,ee.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[$e(e,s),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=ee.find(e=>e.id===R);return e&&`description`in e&&typeof e.description==`string`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[c.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":C.bargeIn,checked:C.bargeIn,className:`size-4 accent-accent`,onChange:e=>U({bargeIn:e.target.checked})})]})]}):null,t[40]=R,t[41]=s,t[42]=L,t[43]=T,t[44]=C.bargeIn,t[45]=C.defaultEngine,t[46]=C.enabled,t[47]=C.omni,t[48]=C.tts,t[49]=c.bargeIn,t[50]=c.defaultVoice,t[51]=c.enable,t[52]=c.voice,t[53]=n,t[54]=w,t[55]=g?.tts,t[56]=U,t[57]=r.experience,t[58]=r.realtime,t[59]=ee,t[60]=ne):ne=t[60];let re;t[61]!==B||t[62]!==V||t[63]!==_||t[64]!==v||t[65]!==a||t[66]!==n||t[67]!==u||t[68]!==g||t[69]!==W||t[70]!==r||t[71]!==f.input||t[72]!==f.output?(re=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[v?(0,$.jsx)(Ee,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,W(B,f.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,W(B&&V,f.input&&f.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,W(!!(g?.enabled&&g.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(On,{v:r,canListen:B,canSpeak:V,disabled:a||v||!!_,onVerified:e=>p({signature:u,...e})},`${u}:${JSON.stringify(g)}`)]}):null,t[61]=B,t[62]=V,t[63]=_,t[64]=v,t[65]=a,t[66]=n,t[67]=u,t[68]=g,t[69]=W,t[70]=r,t[71]=f.input,t[72]=f.output,t[73]=re):re=t[73];let G;return t[74]!==c.service||t[75]!==ne||t[76]!==re?(G=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":c.service,children:[ne,re]}),t[74]=c.service,t[75]=ne,t[76]=re,t[77]=G):G=t[77],G}function An(e){return{id:e,name:e}}function jn(e){return Ve(e,`conversation`)}function Mn(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Nn(e){return Ue.parse((await _(e)).payload)}function Pn(e){return e.language}function Fn(e){let t=(0,an.c)(19),{value:n,onChange:r}=e,i=b(In)===`zh`,a=i?`通话指令`:`Conversation instructions`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=i?`通话会接续当前会话。可在这里调整语气与回答方式。`:`Calls continue the current conversation. Adjust tone and response style here.`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s}),t[2]=s,t[3]=c);let l=i?`通话指令`:`Conversation instructions`,u;t[4]===l?u=t[5]:(u=(0,$.jsx)(`span`,{children:l}),t[4]=l,t[5]=u);let d;t[6]!==r||t[7]!==n?(d=e=>r({...n,instructions:e.target.value}),t[6]=r,t[7]=n,t[8]=d):d=t[8];let f;t[9]!==d||t[10]!==n.instructions?(f=(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,rows:3,maxLength:8e3,value:n.instructions,onChange:d}),t[9]=d,t[10]=n.instructions,t[11]=f):f=t[11];let p;t[12]!==u||t[13]!==f?(p=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[u,f]}),t[12]=u,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==o||t[16]!==c||t[17]!==p?(m=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[o,c,p]}),t[15]=o,t[16]=c,t[17]=p,t[18]=m):m=t[18],m}function In(e){return e.language}var Ln=de;function Rn(){return g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,De,`dark:border-edge`)}function zn(){return g(ve,de)}function Bn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Vn(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function Hn(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Un(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function Wn(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;default:return t.tts.providerHints.generic}}function Gn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Kn(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function qn(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Jn(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Yn(e){let t=(0,an.c)(4),[n,r]=(0,Q.useState)(0),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(Xn),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==e?(a=(0,$.jsx)(Zn,{...e,onReload:i},n),t[1]=n,t[2]=e,t[3]=a):a=t[3],a}function Xn(e){return e+1}function Zn({capability:e,onPendingChange:t,disabled:n=!1,onReload:r}){let i=b(e=>e.language),a=h(i).voiceSettings,o=I(e=>e.captions),s=I(e=>e.setCaptions),c=!!v(e=>e.conversationId),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useReducer)(Jn,{form:null,baseline:null}),p=d.form,m=d.baseline,[g,_]=(0,Q.useState)(null),y=(0,Q.useRef)(!1),S=(0,Q.useRef)({}),C=(0,Q.useRef)(p);C.current=p;let w=(0,Q.useRef)({parsed:null,models:void 0}),{data:T,error:E,isLoading:D,mutate:O}=j(c),{data:A,error:M,isLoading:N,mutate:P}=k(c?x(`/api/voice/models`):null,Gt,{revalidateOnFocus:!1}),{data:F,error:L,isLoading:R}=k(c?x(`/api/voice/providers`):null,Vt,{revalidateOnFocus:!1}),{data:z,error:ee,isLoading:B}=k(c?x(`/api/voice/stt-providers`):null,Wt,{revalidateOnFocus:!1}),V=(0,Q.useMemo)(()=>F?.providers??[],[F]),H=(0,Q.useMemo)(()=>z?.providers??[],[z]),te=(0,Q.useMemo)(()=>T?.payload?.config===void 0?null:Kt(T.payload.config),[T]),W=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]);c?te!==null&&A!==void 0&&!y.current&&(w.current.parsed!==te||w.current.models!==A)&&(w.current={parsed:te,models:A},S.current=Jt(T?.payload?.config),f({type:`sync`,value:te}),_(A)):(w.current.parsed!==null||w.current.models!==void 0)&&(w.current={parsed:null,models:void 0},f({type:`reset`}),_(null),y.current=!1);let ne=!!(c&&(te===null||A===void 0||F===void 0||z===void 0)&&(D||N||R||B)),re=E instanceof Error?E.message:E?String(E):M instanceof Error?M.message:M?String(M):L instanceof Error?L.message:L?String(L):ee instanceof Error?ee.message:ee?String(ee):null,G=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),K=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ie=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),ae=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,languageMode:e,...e===`auto`?{language:i}:{}}}:null})},[i]),oe=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),q=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),J=Rt({value:p,dirty:W,onSave:(0,Q.useCallback)(async t=>{try{let n=await zt(t,e,S.current[e]);S.current={...S.current,...n},f({type:`saved`,value:t}),y.current=!!(C.current&&JSON.stringify(C.current)!==JSON.stringify(t))}catch(e){throw Error(e instanceof Error?e.message:a.saveError)}},[a.saveError,e])});(0,Q.useEffect)(()=>{t?.(W||J.status===`saving`||l)},[W,J.status,l,t]),(0,Q.useEffect)(()=>()=>t?.(!1),[t]);let se=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:()=>e})},[]);if(!c)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})});if(ne)return(0,$.jsx)(U,{rows:4});if(!p||g===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:re??a.loadError}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>{O(),P()},children:a.retry})]});let ce=p.stt,le=p.tts,ue=p.voice.input.refinement,Y=Gn(a);return(0,$.jsxs)(`fieldset`,{disabled:n||l,className:`flex min-w-0 flex-col gap-4`,onBlurCapture:J.error?void 0:J.onBlurCapture,children:[(0,$.jsx)(Lt,{status:J.status,error:J.error}),J.error?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{variant:`secondary`,onClick:J.retry,children:i===`zh`?`重试保存`:`Retry saving`}),(0,$.jsx)(X,{variant:`ghost`,onClick:()=>{O().then(()=>r()).catch(()=>{})},children:i===`zh`?`重新加载(放弃未保存更改)`:`Reload and discard unsaved changes`})]}):null,e===`transcription`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{zh:i===`zh`}),(0,$.jsx)(er,{managedModel:!0,v:a,apiKeyLabels:Y,stt:ce,models:g,sttProviders:H,updateStt:G,updateSttFallback:K}),(0,$.jsx)($n,{v:a,voice:p.voice,updateLanguageMode:ae}),(0,$.jsxs)(`details`,{"data-voice-section":`input-processing`,className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[a.experience.inputProcessing,` · `,ue.mode===`off`?a.stt.refinementOff:ue.mode===`punctuation`?a.stt.refinementPunctuation:ue.mode===`light`?a.stt.refinementLight:a.setup.advanced]}),(0,$.jsxs)(`label`,{className:`mt-4 block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:a.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.stt.refinementDesc}),(0,$.jsxs)(Qe,{className:zn(),value:ue.mode,onChange:e=>ie({mode:e.target.value}),children:[(0,$.jsx)(Z,{value:`off`,children:a.stt.refinementOff}),(0,$.jsx)(Z,{value:`punctuation`,children:a.stt.refinementPunctuation}),(0,$.jsx)(Z,{value:`light`,children:a.stt.refinementLight}),ue.mode===`custom`?(0,$.jsx)(Z,{value:`custom`,children:a.setup.advanced}):null]})]})]}),ce.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`实时听写`:`Live dictation`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Sn,{modes:[`transcription.stream`],disabled:W||J.status===`saving`,onPendingChange:u})})]}):null]}):e===`speech`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nr,{managedModel:!0,v:a,apiKeyLabels:Y,tts:le,models:g,ttsProviders:V,updateTts:q}),(0,$.jsx)(Qn,{v:a,tts:le,updateTts:q})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{section:`listening`,v:a,form:p,pending:W||J.status===`saving`||!!J.error,onChange:se}),p.voice.realtime.defaultEngine===`omni`&&p.voice.realtime.omni?(0,$.jsx)(Fn,{value:p.voice.realtime.omni,onChange:e=>oe({omni:e})}):null,(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:a.experience.pace}),(0,$.jsxs)(Qe,{className:zn(),value:String(p.voice.realtime.silenceDurationMs),onChange:e=>oe({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(Z,{value:`800`,children:a.experience.fast}),(0,$.jsx)(Z,{value:`1200`,children:a.experience.standard}),(0,$.jsx)(Z,{value:`2000`,children:a.experience.relaxed}),[800,1200,2e3].includes(p.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(Z,{value:String(p.voice.realtime.silenceDurationMs),children:[p.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[a.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":o,className:`ui-checkbox`,checked:o,onChange:e=>s(e.target.checked)})]}),p.voice.realtime.defaultEngine===`agent`&&ce.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`语音助手输出`:`Assistant speech output`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Sn,{modes:[`speech.stream`],disabled:W||J.status===`saving`,onPendingChange:u})})]}):null,(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`麦克风、扬声器与诊断`:`Microphone, speakers and diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Cn,{v:a}),(0,$.jsx)(kn,{section:`diagnostics`,v:a,form:p,pending:W||J.status===`saving`||!!J.error,onChange:se})]})]})]})]})}function Qn(e){let t=(0,an.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=zn(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,$.jsx)(Z,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let d;t[7]===n.tts.triggerInbound?d=t[8]:(d=(0,$.jsx)(Z,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=d);let f;t[9]===n.tts.triggerAlways?f=t[10]:(f=(0,$.jsx)(Z,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=f);let p;t[11]===n.tts.triggerTagged?p=t[12]:(p=(0,$.jsx)(Z,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=p);let m;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==d||t[17]!==f||t[18]!==p||t[19]!==n.setup.readout?(m=(0,$.jsxs)(Qe,{"aria-label":o,className:s,value:c,onChange:l,children:[u,d,f,p]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d,t[17]=f,t[18]=p,t[19]=n.setup.readout,t[20]=m):m=t[20];let h;t[21]!==a||t[22]!==m?(h=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,m]}),t[21]=a,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.setup.readoutHint?g=t[25]:(g=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=g);let _;return t[26]!==h||t[27]!==g?(_=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[h,g]}),t[26]=h,t[27]=g,t[28]=_):_=t[28],_}function $n(e){let t=(0,an.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=zn(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let d;t[10]===n.language.auto?d=t[11]:(d=(0,$.jsx)(Z,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,$.jsx)(Z,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let p;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(p=(0,$.jsxs)(Qe,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=p):p=t[18];let m;return t[19]!==c||t[20]!==p?(m=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,p]})}),t[19]=c,t[20]=p,t[21]=m):m=t[21],m}function er(e){let t=(0,an.c)(65),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c,managedModel:l}=e,u=l===void 0?!1:l,d;if(t[0]!==o){let e=new Set;d=[];for(let t of o)e.has(t.id)||(e.add(t.id),d.push(t));t[0]=o,t[1]=d}else d=t[1];let f=d,p,m,h,_;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){p=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],_=p?.fields.find(tr),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=_}else p=t[6],m=t[7],h=t[8],_=t[9];let v=_,y=typeof h.model==`string`?h.model:void 0,b=y??(typeof v?.defaultValue==`string`?v.defaultValue:m[0]?.id),x;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(x=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=x):x=t[16];let S=x,C,w;t[17]!==y||t[18]!==b||t[19]!==u||t[20]!==v||t[21]!==S?(C=()=>{!u&&v&&b&&y!==b&&S({model:b})},w=[u,y,b,v,S],t[17]=y,t[18]=b,t[19]=u,t[20]=v,t[21]=S,t[22]=C,t[23]=w):(C=t[22],w=t[23]),(0,Q.useEffect)(C,w);let T;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(ae,{"aria-hidden":`true`,className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=T):T=t[24];let E;t[25]===n.stt.title?E=t[26]:(E=(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[25]=n.stt.title,t[26]=E);let D;t[27]===n.stt.enable?D=t[28]:(D=(0,$.jsx)(`span`,{children:n.stt.enable}),t[27]=n.stt.enable,t[28]=D);let O;t[29]===s?O=t[30]:(O=e=>s({enabled:e.target.checked}),t[29]=s,t[30]=O);let k;t[31]!==i.enabled||t[32]!==O?(k=(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:O}),t[31]=i.enabled,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==k||t[35]!==D?(A=(0,$.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[D,k]}),t[34]=k,t[35]=D,t[36]=A):A=t[36];let j;t[37]!==A||t[38]!==E?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[E,A]}),t[37]=A,t[38]=E,t[39]=j):j=t[39];let M;t[40]===n.stt.description?M=t[41]:(M=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[40]=n.stt.description,t[41]=M);let N;t[42]!==j||t[43]!==M?(N=(0,$.jsxs)(`div`,{className:`mb-4`,children:[j,M]}),t[42]=j,t[43]=M,t[44]=N):N=t[44];let P;t[45]!==p?.fields||t[46]!==r||t[47]!==b||t[48]!==u||t[49]!==m||t[50]!==f||t[51]!==h||t[52]!==i.enabled||t[53]!==i.fallback?.enabled||t[54]!==i.provider||t[55]!==S||t[56]!==s||t[57]!==c||t[58]!==n?(P=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u?null:(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,Ln),children:[(0,$.jsx)(ur,{children:n.stt.provider}),(0,$.jsx)(Qe,{"aria-label":n.stt.provider,className:zn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[Hn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(rr,{managedModel:u,kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:b,apiKeyLabels:r,onPatch:S})]}),i.provider===`alibaba`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.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,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]})]}):null,t[45]=p?.fields,t[46]=r,t[47]=b,t[48]=u,t[49]=m,t[50]=f,t[51]=h,t[52]=i.enabled,t[53]=i.fallback?.enabled,t[54]=i.provider,t[55]=S,t[56]=s,t[57]=c,t[58]=n,t[59]=P):P=t[59];let F;t[60]===P?F=t[61]:(F=(0,$.jsx)(`div`,{className:`space-y-4`,children:P}),t[60]=P,t[61]=F);let I;return t[62]!==N||t[63]!==F?(I=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[N,F]}),t[62]=N,t[63]=F,t[64]=I):I=t[64],I}function tr(e){return e.key===`model`}function nr({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,managedModel:o=!1}){let[s,c]=(0,Q.useState)(e.tts.test.sampleText),[l,u]=(0,Q.useState)({status:`idle`}),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useCallback)(()=>{p.current?.abort(),p.current=null,d.current?.pause(),d.current=null,f.current&&=(URL.revokeObjectURL(f.current),null)},[]),h=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),_=h.find(e=>e.id===n.provider),v=n.providers?.[n.provider]??{},y=r?.tts?.[n.provider]?.length?r.tts[n.provider]:_?.models??[],b=_?.fields.find(e=>e.key===`model`),x=_?.fields.find(e=>e.key===`voice`),S=typeof v.model==`string`?v.model:void 0,C=S??(typeof b?.defaultValue==`string`?b.defaultValue:y[0]?.id),w=y.find(e=>e.id===C),T=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:_?.voices??[],{data:E=[]}=k(C?`voice:tts:${n.provider}:${C}`:null,()=>Ut(n.provider,C??``),{revalidateOnFocus:!1}),D=E.length>0?E:T,O=typeof v.voice==`string`?v.voice:void 0,A=O??D.find(e=>e.id===w?.tts?.defaultVoice)?.id??(typeof x?.defaultValue==`string`?x.defaultValue:D[0]?.id),j=(_?.fields??[]).filter(e=>(e.key!==`speed`||w?.tts?.speed!==!1)&&(e.key!==`instructions`||w?.tts?.instructions!==!1)),M=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{if(o)return;let e={};b&&C&&S!==C&&(e.model=C),x&&A&&O!==A&&(e.voice=A),Object.keys(e).length>0&&M(e)},[o,S,O,C,A,b,M,x]),(0,Q.useEffect)(()=>()=>m(),[m]);let N=(0,Q.useCallback)(e=>{a({provider:e}),u({status:`idle`})},[a]),P=(0,Q.useCallback)(async()=>{let t=s.trim();if(!t){u({status:`error`,message:e.tts.test.emptyText});return}m();let r=new AbortController;p.current=r,u({status:`loading`});try{let i=await Bt({text:t,provider:n.provider,providerConfig:v,...C?{model:C}:{},...A?{voice:A}:{}},r.signal);if(r.signal.aborted)return;let a=Vn(i.audio,i.mimeType);f.current=a;let o=new Audio(a);d.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,Bn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>u({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>u({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),u({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;m(),u({status:`error`,message:e instanceof Error?e.message:String(e)})}},[C,A,v,m,s,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Tt,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:o?null:(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,Ln),children:[(0,$.jsx)(ur,{children:e.tts.provider}),(0,$.jsx)(Qe,{"aria-label":e.tts.provider,className:zn(),value:n.provider,onChange:e=>N(e.target.value),children:h.map(t=>(0,$.jsx)(Z,{value:t.id,children:Un(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[_?.configured?e.tts.configured:_?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${_.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,_?.description??Wn(n.provider,e)]})]})}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(rr,{managedModel:o,kind:`tts`,providerId:n.provider,fields:j,providerSlice:v,models:y,voices:D,currentModel:C,currentVoice:A,apiKeyLabels:t,onPatch:M,resetVoiceOnModelChange:!0})}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(X,{type:`button`,variant:`primary`,onClick:()=>void P(),disabled:l.status===`loading`,className:`h-9`,children:[l.status===`loading`?(0,$.jsx)(ze,{className:`size-4 animate-spin`}):(0,$.jsx)(rt,{className:`size-4`}),l.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,onClick:()=>{m(),u(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:l.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(Fe,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:g(Rn(),`mt-3 min-h-20 resize-y`),value:s,onChange:e=>c(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[s.length,`/1000`]}),l.status===`playing`||l.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[l.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,l.summary]}):null,l.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:l.message}):null]})]})]})]})})]})}function rr(e){let t=(0,an.c)(48),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:c,currentVoice:l,apiKeyLabels:u,onPatch:d,resetVoiceOnModelChange:f,managedModel:p}=e,m;t[0]===s?m=t[1]:(m=s===void 0?[]:s,t[0]=s,t[1]=m);let _=m,v=f===void 0?!1:f,y=p===void 0?!1:p,x=b(sr),S;t[2]===x?S=t[3]:(S=h(x),t[2]=x,t[3]=S);let C=S.voiceSettings,w=y,T=or,E=ar,D,O,k;if(t[4]!==u||t[5]!==c||t[6]!==l||t[7]!==i||t[8]!==n||t[9]!==x||t[10]!==y||t[11]!==o||t[12]!==d||t[13]!==r||t[14]!==a||t[15]!==v||t[16]!==w||t[17]!==C||t[18]!==_){let e;t[22]===w?e=t[23]:(e=e=>!w||e.key!==`model`&&!E(e),t[22]=w,t[23]=e);let s=i.filter(e),f;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>!T(e),t[24]=f):f=t[24];let p=s.filter(f),m;t[25]!==u||t[26]!==c||t[27]!==l||t[28]!==n||t[29]!==x||t[30]!==y||t[31]!==o||t[32]!==d||t[33]!==r||t[34]!==a||t[35]!==v||t[36]!==C||t[37]!==_?(m=e=>e.map(e=>y&&e.key===`model`?null:e.key===`apiKey`?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,Ln),children:[(0,$.jsx)(ur,{htmlFor:`voice-${n}-${r}-api-key`,children:C.stt.apiKey}),(0,$.jsx)(Yt,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>d({apiKey:e}),labels:u,placeholder:e.placeholder}),e.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.description}):null]},e.key):e.key===`model`&&o.length>0?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,Ln),children:[(0,$.jsx)(ur,{htmlFor:`voice-${n}-${r}-model`,children:C.stt.model}),(0,$.jsx)(Qe,{id:`voice-${n}-${r}-model`,className:zn(),value:c??``,onChange:e=>d({model:e.target.value,...v?{voice:void 0}:{}}),children:o.map(ir)})]},e.key):e.key===`voice`&&_.length>0?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,Ln),children:[(0,$.jsx)(ur,{htmlFor:`voice-${n}-${r}-voice`,children:C.tts.voice}),(0,$.jsxs)(Qe,{id:`voice-${n}-${r}-voice`,className:zn(),value:l??``,onChange:e=>d({voice:e.target.value}),children:[l&&!_.some(e=>e.id===l)?(0,$.jsxs)(Z,{value:l,children:[l,` · unavailable`]}):null,_.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[$e(e,x),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),_.find(e=>e.id===l)?.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:_.find(e=>e.id===l)?.description}):null]},e.key):(0,$.jsx)(cr,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:Kn(a,e),onChange:t=>d({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Ln},e.key)),t[25]=u,t[26]=c,t[27]=l,t[28]=n,t[29]=x,t[30]=y,t[31]=o,t[32]=d,t[33]=r,t[34]=a,t[35]=v,t[36]=C,t[37]=_,t[38]=m):m=t[38];let h=m;t[39]!==i||t[40]!==n||t[41]!==x||t[42]!==w?(D=w&&i.some(E)?(0,$.jsx)(Tn,{className:`text-sm text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=${n===`stt`?`transcription`:`speech`}`,children:x===`zh`?`管理服务连接`:`Manage service connection`}):null,t[39]=i,t[40]=n,t[41]=x,t[42]=w,t[43]=D):D=t[43],O=h(s.filter(T)),k=p.length?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:C.experience.providerOptions}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:h(p)})]}):null,t[4]=u,t[5]=c,t[6]=l,t[7]=i,t[8]=n,t[9]=x,t[10]=y,t[11]=o,t[12]=d,t[13]=r,t[14]=a,t[15]=v,t[16]=w,t[17]=C,t[18]=_,t[19]=D,t[20]=O,t[21]=k}else D=t[19],O=t[20],k=t[21];let A;return t[44]!==D||t[45]!==O||t[46]!==k?(A=(0,$.jsxs)($.Fragment,{children:[D,O,k]}),t[44]=D,t[45]=O,t[46]=k,t[47]=A):A=t[47],A}function ir(e){return(0,$.jsx)(Z,{value:e.id,children:e.name},e.id)}function ar(e){return e.secret||e.type===`password`||[`apiKey`,`baseUrl`,`region`,`groupId`].includes(e.key)}function or(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function sr(e){return e.language}function cr(e){let t=(0,an.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?e=t[1]:(e=g(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,$.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(qn(r,e.target.checked)),t[9]=r,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=g(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]!==r.label||t[22]!==s?(d=(0,$.jsx)(ur,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=d):d=t[23];let f;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(f=r.type===`select`?(0,$.jsx)(Qe,{id:s,className:zn(),value:l,required:r.required,onChange:e=>a(qn(r,e.target.value)),children:(r.options??[]).map(lr)}):r.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:g(Rn(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(qn(r,e.target.value))}):r.type===`password`?(0,$.jsx)(xe,{id:s,className:o,value:l,onChange:e=>a(qn(r,e)),placeholder:r.placeholder,labels:z}):r.type===`number`?(0,$.jsx)(Mt,{id:s,className:Rn(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(qn(r,e.target.value))}):(0,$.jsx)(`input`,{id:s,className:Rn(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(qn(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=f):f=t[29];let p;t[30]===c?p=t[31]:(p=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=p);let m;return t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f,p]}),t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=m):m=t[36],m}function lr(e){return(0,$.jsx)(Z,{value:e.id,children:e.name},e.id)}function ur(e){let t=(0,an.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function dr(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function fr(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=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map((e,t)=>{let n=e&&typeof e==`object`?e:{},r=n.type,i=r===`brave`||r===`tavily`||r===`bing`||r===`searxng`||r===`deepseek`?r:`brave`;return{clientKey:`search-provider-${t}`,type:i,apiKey:typeof n.apiKey==`string`?n.apiKey:``,url:typeof n.url==`string`?n.url:``,disabled:n.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function pr(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.type===`deepseek`)&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await _(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),A()}async function mr(e){let t=await _(x(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function hr(e){let t=(0,an.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function gr(){return g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,De,`dark:border-edge`)}function _r(){return g(ve,de)}var vr=[`brave`,`tavily`,`bing`,`searxng`,`deepseek`];function yr(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var br=tt();function xr(){let e=h(b(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!v(e=>e.conversationId),[i,a]=(0,Q.useReducer)(br,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:d,error:f,isLoading:m,mutate:_}=j(r);vt({enabled:r,parsed:(0,Q.useMemo)(()=>d?.payload?.config===void 0?null:fr(d.payload.config),[d]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let y=!!(r&&m&&d===void 0&&!f),x=f instanceof Error?f.message:f?String(f):null,S=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),C=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),w=Rt({value:o,dirty:S,onSave:(0,Q.useCallback)(async e=>{try{await pr(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!r)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(y)return(0,$.jsx)(U,{rows:3});if(!o)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x??t.loadError}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let T=dr(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:w.onBlurCapture,children:[w.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w.error}):null,(0,$.jsxs)(It,{children:[(0,$.jsx)(Ft,{icon:lt,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(Lt,{status:w.status,error:w.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(me,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:g(`rounded-full px-2 py-0.5 text-[11px] font-medium`,T?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:T?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:T?t.cloudOverriddenHint:t.cloudAutomaticHint})]})]}),(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Sr,{row:n,providerIndex:r,labels:t,secretLabels:at(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,C({providers:t})},onRemove:()=>{C({providers:o.providers.filter((e,t)=>t!==r)})}},n.clientKey??r)),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>C({providers:[...o.providers,yr()]}),children:[(0,$.jsx)(p,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(It,{children:[(0,$.jsx)(Ft,{icon:ut,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(hr,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(Qe,{className:_r(),value:o.regionMode,onChange:e=>C({regionMode:e.target.value}),children:[(0,$.jsx)(Z,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(Z,{value:`cn`,children:t.regionCn}),(0,$.jsx)(Z,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(oe,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(hr,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(Mt,{type:`number`,min:1,max:50,className:gr(),value:o.maxResults,onChange:e=>C({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.sectionBlocklist,` · `,o.blocklistEnabled?o.blocklistDomains.length:0]}),(0,$.jsxs)(It,{children:[(0,$.jsx)(Ft,{icon:Be,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>C({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(hr,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:g(gr(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
8
|
-
`),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{C({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})}):null]})]})]})]})}function Sr(e){let t=(0,an.c)(56),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>mr(r).then(Cr),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=g(_r(),`min-w-[8rem]`),t[2]=u):u=t[2];let d=n.type,f;t[3]!==o||t[4]!==n?(f=e=>o({...n,type:e.target.value,url:``,apiKey:``}),t[3]=o,t[4]=n,t[5]=f):f=t[5];let p;t[6]===i.providerTypes?p=t[7]:(p=vr.map(e=>(0,$.jsx)(Z,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=p);let m;t[8]!==n.type||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(Qe,{className:u,value:d,onChange:f,children:p}),t[8]=n.type,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==o||t[13]!==n?(h=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=h):h=t[14];let _;t[15]!==n.disabled||t[16]!==h?(_=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:h}),t[15]=n.disabled,t[16]=h,t[17]=_):_=t[17];let v;t[18]!==i.disabled||t[19]!==_?(v=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,i.disabled]}),t[18]=i.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(L,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===s?b=t[23]:(b=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:y}),t[22]=s,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==m?(S=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[m,x]}),t[27]=x,t[28]=m,t[29]=S):S=t[29];let C;t[30]!==i.deepseekUrlDesc||t[31]!==i.deepseekUrlLabel||t[32]!==i.urlDesc||t[33]!==i.urlLabel||t[34]!==o||t[35]!==n?(C=n.type===`searxng`||n.type===`deepseek`?(0,$.jsx)(hr,{label:n.type===`deepseek`?i.deepseekUrlLabel:i.urlLabel,description:n.type===`deepseek`?i.deepseekUrlDesc:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:gr(),value:n.url,placeholder:n.type===`deepseek`?`https://api.deepseek.com`:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.deepseekUrlDesc,t[31]=i.deepseekUrlLabel,t[32]=i.urlDesc,t[33]=i.urlLabel,t[34]=o,t[35]=n,t[36]=C):C=t[36];let w;t[37]!==o||t[38]!==n?(w=e=>o({...n,apiKey:e}),t[37]=o,t[38]=n,t[39]=w):w=t[39];let T;t[40]!==i.keyPlaceholder||t[41]!==i.keyPlaceholderMasked||t[42]!==i.saveError||t[43]!==l||t[44]!==n.apiKey||t[45]!==a||t[46]!==w?(T=(0,$.jsx)(xe,{value:n.apiKey,onChange:w,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[40]=i.keyPlaceholder,t[41]=i.keyPlaceholderMasked,t[42]=i.saveError,t[43]=l,t[44]=n.apiKey,t[45]=a,t[46]=w,t[47]=T):T=t[47];let E;t[48]!==i.apiKeyDesc||t[49]!==i.apiKeyLabel||t[50]!==T?(E=(0,$.jsx)(hr,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:T}),t[48]=i.apiKeyDesc,t[49]=i.apiKeyLabel,t[50]=T,t[51]=E):E=t[51];let D;return t[52]!==S||t[53]!==C||t[54]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[S,C,E]}),t[52]=S,t[53]=C,t[54]=E,t[55]=D):D=t[55],D}function Cr(e){return e.apiKey??null}function wr(e,t,n=[]){return e.filter(e=>!n.includes(e.providerId)&&e.uses.some(e=>e.id===t&&e.choices.length>0))}function Tr(e){let t=(0,an.c)(75),{use:n,data:r,language:i,labels:a,onSaved:o,inline:s,onPendingChange:c,onEditingChange:l}=e,u=s===void 0?!1:s,d=i===`zh`,[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(!1),g;t[0]===c?g=t[1]:(g=e=>{h(e),c?.(e)},t[0]=c,t[1]=g);let _=g,v=n===`transcription`?`stt`:n===`speech`?`tts`:void 0,y,b,x;if(t[2]!==r.builtinRows||t[3]!==r.cards||t[4]!==r.customConfig?.providers||t[5]!==r.loading||t[6]!==n){let e=new Set(r.cards.filter(e=>!Ne(e.id)||!!r.customConfig?.providers?.[e.id]).map(Pr));y=[...new Set([...r.builtinRows.map(Nr),...e])].filter(t=>!Ne(t)||e.has(t)).sort(),b=k,x=r.loading?null:[`capability-service-connections`,n,y.join(`,`)],t[2]=r.builtinRows,t[3]=r.cards,t[4]=r.customConfig?.providers,t[5]=r.loading,t[6]=n,t[7]=y,t[8]=b,t[9]=x}else y=t[7],b=t[8],x=t[9];let S;t[10]!==y||t[11]!==n||t[12]!==v?(S=async()=>{let e=v===`stt`?await Wt():v===`tts`?await Vt():void 0,t=e?.providers.filter(Mr).map(jr),r=e?.providers.filter(Ar).map(kr)??[],i=t?y.filter(e=>t.includes(e)):y,a=await Promise.allSettled(i.map(Te));return{services:wr(a.flatMap(Or),n,r),failed:a.some(Dr)}},t[10]=y,t[11]=n,t[12]=v,t[13]=S):S=t[13];let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[14]=C):C=t[14];let{data:w,error:T,isLoading:E,mutate:D}=b(x,S,C),O;t[15]===w?.services?O=t[16]:(O=new Set(w?.services.map(Er)),t[15]=w?.services,t[16]=O);let A=O,j,M;if(t[17]!==l||t[18]!==f?(j=()=>(l?.(!!f),()=>l?.(!1)),M=[f,l],t[17]=l,t[18]=f,t[19]=j,t[20]=M):(j=t[19],M=t[20]),(0,Q.useEffect)(j,M),f&&u){let e;if(t[21]!==r.builtinRows||t[22]!==f){let n;t[24]===f?n=t[25]:(n=e=>e.id===f,t[24]=f,t[25]=n),e=r.builtinRows.find(n),t[21]=r.builtinRows,t[22]=f,t[23]=e}else e=t[23];let a;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>p(void 0),t[26]=a):a=t[26];let s;t[27]!==D||t[28]!==o?(s=()=>{D(),p(void 0),o()},t[27]=D,t[28]=o,t[29]=s):s=t[29];let c;return t[30]!==i||t[31]!==f||t[32]!==_||t[33]!==e||t[34]!==s||t[35]!==n?(c=(0,$.jsx)(`section`,{className:`overflow-hidden rounded-xl border border-edge`,children:(0,$.jsx)(Dt,{inline:!0,providerId:f,row:e,targetUse:n,language:i,onPendingChange:_,onDone:a,onApplied:s},f)}),t[30]=i,t[31]=f,t[32]=_,t[33]=e,t[34]=s,t[35]=n,t[36]=c):c=t[36],c}let N=d?`选择服务`:`Choose a service`,P;t[37]===N?P=t[38]:(P=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:N}),t[37]=N,t[38]=P);let F;t[39]!==r.loading||t[40]!==E?(F=r.loading||E?(0,$.jsx)(Ee,{className:`h-24 w-full`}):null,t[39]=r.loading,t[40]=E,t[41]=F):F=t[41];let I;t[42]!==w?.failed||t[43]!==T||t[44]!==D||t[45]!==d?(I=T||w?.failed?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:[d?`部分服务目录暂时不可用。`:`Some service catalogs are unavailable.`,(0,$.jsx)(X,{variant:`ghost`,onClick:()=>void D(),children:d?`重试`:`Retry`})]}):null,t[42]=w?.failed,t[43]=T,t[44]=D,t[45]=d,t[46]=I):I=t[46];let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=[!0,!1],t[47]=L):L=t[47];let R;t[48]!==m||t[49]!==w?.services||t[50]!==d?(R=L.map(e=>{let t=w?.services.filter(t=>t.configured===e)??[];return t.length?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:e?d?`已连接`:`Connected`:d?`添加服务`:`Add a service`}),t.map(t=>(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:()=>p(t.providerId),className:`flex min-h-14 w-full items-center justify-between gap-3 rounded-lg px-3 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg`,children:W(t.providerId,t.profile.name,d)}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm text-accent-fg`,children:e?d?`选择`:`Choose`:d?`连接`:`Connect`})]},t.providerId))]},String(e)):null}),t[48]=m,t[49]=w?.services,t[50]=d,t[51]=R):R=t[51];let z;t[52]!==w||t[53]!==d?(z=w&&!w.services.length&&!w.failed?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无支持此能力的模型服务。`:`No model services currently support this capability.`}):null,t[52]=w,t[53]=d,t[54]=z):z=t[54];let ee=d?`仅列出支持${Et[n][0]}的服务。`:`Only compatible services are shown. Reuse saved credentials, then return to select a model.`,B;t[55]===ee?B=t[56]:(B=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ee}),t[55]=ee,t[56]=B);let V;t[57]!==r.builtinRows||t[58]!==r.customConfig||t[59]!==A||t[60]!==a||t[61]!==i||t[62]!==D||t[63]!==o||t[64]!==f||t[65]!==n?(V=f?(0,$.jsx)(At,{open:!0,initialProviderId:f,initialUse:n,connectOnly:!0,onOpenChange:e=>{e||p(void 0)},builtinRows:r.builtinRows.filter(e=>A.has(e.id)),customConfig:r.customConfig,labels:a,language:i,onSaved:()=>{D(),p(void 0),o()}},f):null,t[57]=r.builtinRows,t[58]=r.customConfig,t[59]=A,t[60]=a,t[61]=i,t[62]=D,t[63]=o,t[64]=f,t[65]=n,t[66]=V):V=t[66];let H;return t[67]!==P||t[68]!==F||t[69]!==I||t[70]!==R||t[71]!==z||t[72]!==B||t[73]!==V?(H=(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[P,F,I,R,z,B,V]}),t[67]=P,t[68]=F,t[69]=I,t[70]=R,t[71]=z,t[72]=B,t[73]=V,t[74]=H):H=t[74],H}function Er(e){return e.providerId}function Dr(e){return e.status===`rejected`}function Or(e){return e.status===`fulfilled`?[e.value]:[]}function kr(e){return e.id}function Ar(e){return e.diagnostics.requiresApiKey}function jr(e){return e.id}function Mr(e){return!e.diagnostics.requiresApiKey}function Nr(e){return e.id}function Pr(e){return e.id}function Fr({zh:e,kind:t,modelServiceIds:n,onSaved:r,onPendingChange:i}){let{data:a,error:o,mutate:s}=k([`native-voice-connections`,t??`all`,n.join(`,`)],async()=>{let[e,r]=await Promise.all([t===`tts`?Promise.resolve({providers:[]}):Wt(),t===`stt`?Promise.resolve({providers:[]}):Vt()]);return[...e.providers.map(e=>({...e,kind:`stt`})),...r.providers.map(e=>({...e,kind:`tts`}))].filter(e=>e.diagnostics.requiresApiKey||!n.includes(e.id))}),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(!1),[h,g]=(0,Q.useState)(``);(0,Q.useEffect)(()=>(i?.(f),()=>i?.(!1)),[f,i]);let v=a?.find(e=>`${e.kind}:${e.id}`===c),y=v?.fields.filter(e=>e.secret||e.type===`password`||[`baseUrl`,`region`,`groupId`].includes(e.key))??[],b=async()=>{if(!(!v||m.current)){m.current=!0,p(!0),g(``);try{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()).map(([e,t])=>[e,t.trim()]));Object.keys(t).length&&await _(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({[v.kind]:{providers:{[v.id]:t}}})});let[n]=await Promise.all([s(),He()]);if(!n?.find(e=>e.kind===v.kind&&e.id===v.id)?.configured)throw Error(e?`连接尚未就绪,请补齐所需凭据。`:`Connection is not ready. Complete the required credentials.`);d({}),r()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m.current=!1,p(!1)}}};return a&&!a.length?null:(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e?`其他语音服务与本地语音`:`Other voice services and local speech`}),(0,$.jsxs)(`section`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`stt`?e?`其他识别服务`:`Other recognition services`:t===`tts`?e?`其他合成服务与本地语音`:`Other synthesis services and local speech`:e?`语音 API 与本地语音`:`Voice APIs and local speech`}),!a&&!o?(0,$.jsx)(Ee,{className:`h-20 w-full`}):null,o?(0,$.jsxs)(`p`,{role:`alert`,children:[e?`语音服务加载失败`:`Could not load voice services`,(0,$.jsx)(X,{variant:`ghost`,onClick:()=>void s(),children:e?`重试`:`Retry`})]}):null,(0,$.jsxs)(Qe,{value:c,disabled:f,"aria-label":e?`语音服务接入`:`Connect voice service`,onChange:e=>{l(e.target.value),d({}),g(``)},children:[(0,$.jsx)(Z,{value:``,children:e?`选择语音来源`:`Choose a voice source`}),a?.map(n=>(0,$.jsxs)(Z,{value:`${n.kind}:${n.id}`,children:[n.displayName,t?``:` · ${n.kind.toUpperCase()}`,n.configured?e?` · 已连接`:` · Connected`:``]},`${n.kind}:${n.id}`))]}),v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:v.diagnostics.requiresApiKey?e?`此服务使用独立的 API Key。保存连接后,可在“模型与参数”中选用。`:`This service uses its own API key. Save the connection, then choose it in Model and parameters.`:e?`此来源无需 API Key,可返回能力设置选择。`:`No API key needed. Choose this source in capability settings.`}),y.map(t=>(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:t.label}),t.secret||t.type===`password`?(0,$.jsx)(xe,{labels:z,value:u[t.key]??``,onChange:e=>d(n=>({...n,[t.key]:e})),disabled:f}):t.options?.length?(0,$.jsxs)(Qe,{value:u[t.key]??``,disabled:f,onChange:e=>d(n=>({...n,[t.key]:e.target.value})),children:[(0,$.jsx)(Z,{value:``,children:e?`保留现有值`:`Keep existing`}),t.options.map(e=>(0,$.jsx)(Z,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel p-2`,value:u[t.key]??``,disabled:f,placeholder:t.placeholder,onChange:e=>d(n=>({...n,[t.key]:e.target.value}))})]},t.key)),h?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:h}):null,(0,$.jsx)(X,{disabled:f||!v.configured&&v.diagnostics.requiresApiKey&&!Object.values(u).some(e=>e.trim()),onClick:()=>void b(),children:f?e?`保存中…`:`Saving…`:e?`保存连接`:`Save connection`})]}):null]})]})}function Ir(e){let t=(0,an.c)(40),{label:n,value:r,currentLabel:i,options:a,loading:o,disabled:s,zh:c,onConnect:l,onSelect:u}=e,[d,f]=(0,Q.useState)(``),p;if(t[0]!==a||t[1]!==d){let e=d.trim().toLowerCase().split(/\s+/).filter(Boolean);p=a.filter(t=>{let n=`${t.label} ${t.group} ${t.value} ${t.searchText??``}`.toLowerCase();return e.every(e=>n.includes(e))}),t[0]=a,t[1]=d,t[2]=p}else p=t[2];let m=p,h;if(t[3]!==a||t[4]!==r){let e;t[6]===r?e=t[7]:(e=e=>e.value===r,t[6]=r,t[7]=e),h=a.find(e),t[3]=a,t[4]=r,t[5]=h}else h=t[5];let g=h,_;t[8]!==a||t[9]!==g?.group||t[10]!==r?(_=g?.group??a.find(e=>e.value.split(`/`)[0]===r?.split(`/`)[0])?.group,t[8]=a,t[9]=g?.group,t[10]=r,t[11]=_):_=t[11];let v=_,y;t[12]!==i||t[13]!==g?.label||t[14]!==r||t[15]!==c?(y=g?.label??(r?.endsWith(`/default`)?c?`默认模型`:`Default model`:i??r),t[12]=i,t[13]=g?.label,t[14]=r,t[15]=c,t[16]=y):y=t[16];let b=y,x=v?`${b} · ${v}`:b;if(!o&&!a.length){let e=`${c?`连接`:`Connect`} ${n}`,r=c?`连接服务以启用`:`Connect a service to enable`,i;return t[17]!==s||t[18]!==l||t[19]!==e||t[20]!==r?(i=(0,$.jsx)(X,{variant:`secondary`,className:`min-h-11 w-full sm:justify-start`,"aria-label":e,disabled:s,onClick:l,children:r}),t[17]=s,t[18]=l,t[19]=e,t[20]=r,t[21]=i):i=t[21],i}let S=r??``,C=c?`选择模型`:`Choose a model`,w=`${c?`选择`:`Select`} ${n}`,T=c?`搜索模型或服务`:`Search models or services`,E=m.length?void 0:c?`没有可用模型`:`No available models`,D;t[22]!==s||t[23]!==m||t[24]!==o||t[25]!==b||t[26]!==u||t[27]!==d||t[28]!==x||t[29]!==S||t[30]!==C||t[31]!==w||t[32]!==T||t[33]!==E?(D=(0,$.jsx)(yt,{value:S,options:m,selectedLabel:b,title:x,placeholder:C,ariaLabel:w,allowEmpty:!1,disabled:s,loading:o,onChange:u,searchPlaceholder:T,searchValue:d,onSearchChange:f,statusMessage:E,triggerClassName:`min-h-11`}),t[22]=s,t[23]=m,t[24]=o,t[25]=b,t[26]=u,t[27]=d,t[28]=x,t[29]=S,t[30]=C,t[31]=w,t[32]=T,t[33]=E,t[34]=D):D=t[34];let O;t[35]===v?O=t[36]:(O=v?(0,$.jsx)(`p`,{className:`px-1 text-xs text-fg-muted`,children:v}):null,t[35]=v,t[36]=O);let k;return t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],k}function Lr({data:e,zh:t,onChange:n,onSettings:r,onlyUse:i,disabled:a=!1,onPendingChange:o}){let{data:s,error:c,mutate:l}=k(`settings-agent-defaults`,K),{data:u}=j(!0),{data:d,isLoading:f,error:p,mutate:m}=k(`model-capability-media-sources`,async()=>{let e=await Promise.allSettled([Vt(),Wt(),en()]);return{ids:[...new Set(e.flatMap(e=>e.status===`fulfilled`?(Array.isArray(e.value)?e.value:e.value.providers).filter(e=>e.configured).map(e=>e.id):[]))],failed:e.some(e=>e.status===`rejected`)}}),h=[...new Set([...e.cards.filter(t=>t.configured&&(!Ne(t.id)||!!e.customConfig?.providers?.[t.id])).map(e=>e.id),...d?.ids??[]])].sort(),{data:g,isLoading:_,mutate:v}=k(e.loading?null:[`model-use-choices`,...h],async()=>{let e=await Promise.allSettled(h.map(Te));return{previews:e.flatMap(e=>e.status===`fulfilled`&&e.value.configured?[e.value]:[]),failed:e.some(e=>e.status===`rejected`)}},{revalidateOnFocus:!1}),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),C=(0,Q.useRef)(!1),w=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>o?.(!1),[o]);let T=async(e,t)=>{if(C.current||a)return;let n=g?.previews.find(n=>n.uses.some(n=>n.id===e&&n.choices.some(e=>e.id===t)));if(!n)return;C.current=!0,o?.(!0),b(e),S(null);let r={mode:`replace`,selected:[e],overrides:{[e]:t}};try{let t=await ie(n.providerId,r);await Se(n.providerId,r,t.revision),await Promise.all([l(),v()]),S({use:e})}catch(t){S({use:e,error:t instanceof Error?t.message:String(t)}),Promise.allSettled([l(),v()])}finally{C.current=!1,b(null),o?.(!1),requestAnimationFrame(()=>w.current?.querySelector(`[data-capability="${e}"] button[aria-label]`)?.focus())}},E=u?.payload?.config?Kt(u.payload.config):void 0;if(!s&&!c)return(0,$.jsx)(Ee,{className:`h-48 w-full rounded-xl`});if(c)return(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[t?`模型用途加载失败`:`Could not load model uses`,(0,$.jsx)(X,{variant:`ghost`,onClick:()=>void l(),children:t?`重试`:`Retry`})]});let D=s.defaults.models,O=D.background?.primary??D.chat.primary,A=e.builtinRows.find(e=>e.id===O.split(`/`)[0])?.setupProfile?.interactiveOnly!==!0,M=g?.previews[0]?.uses.find(e=>e.id===`background`),N=M?M.current:A?O:void 0,P=[{id:`chat`,label:t?`对话与任务`:`Chat and tasks`,ref:D.chat.primary},{id:`vision`,label:t?`看图`:`Image understanding`,ref:D.imageUnderstanding?.primary},{id:`image`,label:t?`画图`:`Image generation`,ref:D.imageGeneration?.primary},{id:`background`,label:t?`后台任务`:`Background tasks`,ref:N,inherited:!D.background&&!!N},{id:`transcription`,label:t?`录音与听写`:`Recording and dictation`,ref:E?.stt.enabled?`${E.stt.provider}/${E.stt.providers?.[E.stt.provider]?.model??`default`}`:void 0},{id:`speech`,label:t?`语音合成`:`Speech synthesis`,ref:E?.tts.enabled?`${E.tts.provider}/${E.tts.providers?.[E.tts.provider]?.model??`default`}`:void 0},{id:`conversation`,label:t?`实时语音对话`:`Realtime conversation`,ref:E?.voice.realtime.enabled?E.voice.realtime.defaultEngine===`omni`&&E.voice.realtime.omni?`${E.voice.realtime.omni.provider}/${E.voice.realtime.omni.model}`:E.voice.realtime.defaultEngine===`agent`?`agent`:void 0:void 0}];return(0,$.jsxs)(`section`,{ref:w,className:`@container min-w-0`,children:[(0,$.jsx)(`h2`,{className:i?`mb-2 text-sm font-semibold text-fg`:`sr-only`,children:i?t?`当前模型`:`Current model`:t?`能力总览`:`Capabilities`}),(0,$.jsx)(`div`,{className:i?`space-y-4`:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:Je.filter(e=>!i||e.uses.includes(i)).map(o=>(0,$.jsxs)(`section`,{className:i?`min-w-0`:`min-w-0 border-t border-edge first:border-t-0`,children:[i?null:(0,$.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-inset/55 px-4 py-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:o.label[+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.uses[0]===`chat`?t?`基础能力`:`Core capability`:t?`按需启用`:`Optional`})]}),(0,$.jsx)(`div`,{className:i?`divide-y divide-edge-subtle`:`divide-y divide-edge-subtle px-4`,children:o.uses.filter(e=>!i||e===i).map(o=>{let s=P.find(e=>e.id===o),c=Rr(g?.previews??[],s.id,t),l=s.id===`conversation`&&E?.voice.realtime.enabled&&E.voice.realtime.defaultEngine===`agent`?t?`语音助手 · 使用对话、听写和语音输出配置`:`Voice assistant · Uses chat, dictation and voice output`:s.ref?e.allModels.find(e=>e.id===s.ref)?.name??s.ref:void 0;return(0,$.jsx)(`div`,{"data-capability":s.id,children:(0,$.jsxs)(`div`,{className:i?`py-2`:`grid grid-cols-1 items-center gap-x-3 gap-y-2 py-3 @min-[40rem]:gap-x-4 ${r?`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_auto]`:`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)]`}`,children:[(0,$.jsxs)(`div`,{className:i?`hidden`:`col-start-1 row-start-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:Et[s.id][+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:s.ref?c.some(e=>e.value===s.ref||s.ref?.endsWith(`/default`)&&e.value.split(`/`)[0]===s.ref.split(`/`)[0])||s.ref===`agent`?null:t?`待连接`:`Connection needed`:t?`未配置`:`Not set up`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:Me[s.id][+!t]}),s.inherited?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t?`继承默认对话`:`Inherits chat default`}):null]}),(0,$.jsxs)(`div`,{className:i?`w-full min-w-0 space-y-1`:`row-start-2 w-full min-w-0 space-y-1 @min-[40rem]:col-span-1 @min-[40rem]:col-start-2 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Ir,{label:Et[s.id][+!t],value:s.ref,currentLabel:l,options:c,loading:e.loading||_||f,disabled:y!==null||a,zh:t,onConnect:()=>n(s.id),onSelect:e=>{e!==s.ref&&T(s.id,e)}}),y===s.id?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`正在切换…`:`Switching…`}):null,x?.use===s.id?(0,$.jsx)(`div`,{role:x.error?`alert`:`status`,className:`text-xs text-fg-muted`,children:x.error?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-danger`,children:t?`未能切换模型,请重试。`:`Could not switch models. Please retry.`}),(0,$.jsxs)(`details`,{className:`mt-1`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:t?`查看详情`:`Show details`}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:x.error})]})]}):t?`已切换`:`Model changed`}):null]}),r&&(c.length>0||_||f)?(0,$.jsxs)(`div`,{className:`row-start-3 flex flex-wrap items-center justify-end gap-1 @min-[40rem]:col-start-3 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(X,{variant:`ghost`,disabled:y!==null||a,onClick:()=>r(s.id),children:t?`设置`:`Settings`}),(0,$.jsx)(X,{variant:`ghost`,disabled:y!==null||a,onClick:()=>n(s.id),children:t?`管理服务`:`Manage services`})]}):null]})},s.id)})})]},o.uses[0]))}),(!r||i)&&(g?.failed||d?.failed||p)?(0,$.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:[t?`部分服务的模型加载失败`:`Some model services could not be loaded`,(0,$.jsx)(X,{variant:`ghost`,onClick:()=>void Promise.all([m(),v()]),children:t?`重试`:`Retry`})]}):null,i||r?null:(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t?`快速与复杂任务模型随对话配置;音色、流式听写及电脑操作可在详细设置中调整。`:`Fast and complex task models follow chat setup. Voices, streaming dictation and Computer Use have detailed settings.`})]})}function Rr(e,t,n=!1){return e.flatMap(e=>e.uses.find(e=>e.id===t)?.choices.map(t=>({value:t.id,label:t.name,group:W(e.providerId,e.profile.name,n),searchText:e.profile.name}))??[])}function zr(e){let t=(0,an.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=b(Vr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:Ce(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(Br),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let _=h,v;t[3]!==u.computerUse||t[4]!==u.contextWindow||t[5]!==u.id||t[6]!==u.input||t[7]!==u.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(v=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),u.computerUse&&!u.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),p(e),e.size===0},t[3]=u.computerUse,t[4]=u.contextWindow,t[5]=u.id,t[6]=u.input,t[7]=u.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=v):v=t[11];let y=v,x;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(x=()=>{if(!y())return;let e=(u.id||``).trim();a({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=x):x=t[16];let S=x,C=u,T;t[17]===C?T=t[18]:(T=ne(C),t[17]=C,t[18]=T);let E=T,O=r?s.addModelTitle:s.editModelTitle,k;t[19]===O?k=t[20]:(k=(0,$.jsx)(D,{className:`text-base font-semibold text-fg`,children:O}),t[19]=O,t[20]=k);let A;t[21]!==s.modelProviderLabel||t[22]!==i?(A=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=A):A=t[23];let j;t[24]!==k||t[25]!==A?(j=(0,$.jsxs)(`div`,{children:[k,A]}),t[24]=k,t[25]=A,t[26]=j):j=t[26];let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=g(G,`p-1.5 hover:bg-surface-base`),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(m,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:M,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let F;t[31]!==j||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[j,P]}),t[31]=j,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=I):I=t[34];let L;t[35]===s.modelId?L=t[36]:(L=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,I]}),t[35]=s.modelId,t[36]=L);let R;t[37]===f?R=t[38]:(R=g(H(),f.has(`id`)&&`border-red-500`),t[37]=f,t[38]=R);let z=u.id||``,ee;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>_(`id`,e.target.value),t[39]=ee):ee=t[39];let B=!r,V;t[40]!==R||t[41]!==z||t[42]!==B?(V=(0,$.jsx)(`input`,{className:R,value:z,onChange:ee,placeholder:`e.g. llama3.1:8b`,disabled:B}),t[40]=R,t[41]=z,t[42]=B,t[43]=V):V=t[43];let U;t[44]===f?U=t[45]:(U=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[44]=f,t[45]=U);let W;t[46]!==L||t[47]!==V||t[48]!==U?(W=(0,$.jsxs)(`div`,{children:[L,V,U]}),t[46]=L,t[47]=V,t[48]=U,t[49]=W):W=t[49];let re;t[50]===s.displayName?re=t[51]:(re=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=re);let K;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(K=H(),t[52]=K):K=t[52];let ie=u.name||``,ae;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>_(`name`,e.target.value),t[53]=ae):ae=t[53];let oe;t[54]===ie?oe=t[55]:(oe=(0,$.jsx)(`input`,{className:K,value:ie,onChange:ae}),t[54]=ie,t[55]=oe);let q;t[56]!==re||t[57]!==oe?(q=(0,$.jsxs)(`div`,{children:[re,oe]}),t[56]=re,t[57]=oe,t[58]=q):q=t[58];let J;t[59]===s.inputTypes?J=t[60]:(J=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=J);let se;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(se=te(),t[61]=se):se=t[61];let ce;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>_(`input`,wt(e.target.value)),t[62]=ce):ce=t[62];let le;t[63]===s?le=t[64]:(le=Ae.map(e=>(0,$.jsx)(Z,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=le);let ue;t[65]!==E||t[66]!==le?(ue=(0,$.jsx)(Qe,{className:se,value:E,onChange:ce,children:le}),t[65]=E,t[66]=le,t[67]=ue):ue=t[67];let Y;t[68]!==J||t[69]!==ue?(Y=(0,$.jsxs)(`div`,{children:[J,ue]}),t[68]=J,t[69]=ue,t[70]=Y):Y=t[70];let de=u.reasoning||!1,fe;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>_(`reasoning`,e.target.checked),t[71]=fe):fe=t[71];let pe;t[72]===de?pe=t[73]:(pe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:de,onChange:fe}),t[72]=de,t[73]=pe);let me;t[74]!==s.reasoning||t[75]!==pe?(me=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[pe,s.reasoning]}),t[74]=s.reasoning,t[75]=pe,t[76]=me):me=t[76];let he;t[77]!==Y||t[78]!==me?(he=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Y,me]}),t[77]=Y,t[78]=me,t[79]=he):he=t[79];let ge;t[80]===s.contextWindow?ge=t[81]:(ge=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=ge);let _e;t[82]===f?_e=t[83]:(_e=g(H(),f.has(`contextWindow`)&&`border-red-500`),t[82]=f,t[83]=_e);let ve=u.contextWindow??128e3,ye;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>_(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=ye):ye=t[84];let be;t[85]!==_e||t[86]!==ve?(be=(0,$.jsx)(Mt,{type:`number`,min:1,className:_e,value:ve,onChange:ye}),t[85]=_e,t[86]=ve,t[87]=be):be=t[87];let xe;t[88]===f?xe=t[89]:(xe=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[88]=f,t[89]=xe);let Se;t[90]!==ge||t[91]!==be||t[92]!==xe?(Se=(0,$.jsxs)(`div`,{children:[ge,be,xe]}),t[90]=ge,t[91]=be,t[92]=xe,t[93]=Se):Se=t[93];let we;t[94]===s.maxOutputTokens?we=t[95]:(we=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=we);let Te;t[96]===f?Te=t[97]:(Te=g(H(),f.has(`maxTokens`)&&`border-red-500`),t[96]=f,t[97]=Te);let Ee=u.maxTokens??16384,De;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(De=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=De):De=t[98];let Oe;t[99]!==Te||t[100]!==Ee?(Oe=(0,$.jsx)(Mt,{type:`number`,min:1,className:Te,value:Ee,onChange:De}),t[99]=Te,t[100]=Ee,t[101]=Oe):Oe=t[101];let ke;t[102]===f?ke=t[103]:(ke=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[102]=f,t[103]=ke);let je;t[104]!==we||t[105]!==Oe||t[106]!==ke?(je=(0,$.jsxs)(`div`,{children:[we,Oe,ke]}),t[104]=we,t[105]=Oe,t[106]=ke,t[107]=je):je=t[107];let Me;t[108]!==Se||t[109]!==je?(Me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Se,je]}),t[108]=Se,t[109]=je,t[110]=Me):Me=t[110];let Ne;t[111]===s.costSection?Ne=t[112]:(Ne=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Ne);let Pe;t[113]===s.costInput?Pe=t[114]:(Pe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Pe);let Fe;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=H(),t[115]=Fe):Fe=t[115];let Ie=u.cost?.input??0,Le;t[116]===u.cost?Le=t[117]:(Le=e=>_(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[116]=u.cost,t[117]=Le);let Re;t[118]!==Ie||t[119]!==Le?(Re=(0,$.jsx)(Mt,{type:`number`,step:`any`,min:0,className:Fe,value:Ie,onChange:Le}),t[118]=Ie,t[119]=Le,t[120]=Re):Re=t[120];let ze;t[121]!==Pe||t[122]!==Re?(ze=(0,$.jsxs)(`div`,{children:[Pe,Re]}),t[121]=Pe,t[122]=Re,t[123]=ze):ze=t[123];let Be;t[124]===s.costOutput?Be=t[125]:(Be=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=Be);let Ve;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=H(),t[126]=Ve):Ve=t[126];let He=u.cost?.output??0,Ue;t[127]===u.cost?Ue=t[128]:(Ue=e=>_(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[127]=u.cost,t[128]=Ue);let We;t[129]!==He||t[130]!==Ue?(We=(0,$.jsx)(Mt,{type:`number`,step:`any`,min:0,className:Ve,value:He,onChange:Ue}),t[129]=He,t[130]=Ue,t[131]=We):We=t[131];let Ge;t[132]!==Be||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{children:[Be,We]}),t[132]=Be,t[133]=We,t[134]=Ge):Ge=t[134];let Ke;t[135]!==ze||t[136]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[ze,Ge]}),t[135]=ze,t[136]=Ge,t[137]=Ke):Ke=t[137];let qe;t[138]!==Ne||t[139]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Ne,Ke]}),t[138]=Ne,t[139]=Ke,t[140]=qe):qe=t[140];let Je;t[141]!==W||t[142]!==q||t[143]!==he||t[144]!==Me||t[145]!==qe?(Je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[W,q,he,Me,qe]}),t[141]=W,t[142]=q,t[143]=he,t[144]=Me,t[145]=qe,t[146]=Je):Je=t[146];let Ye=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,Xe;t[147]===Ye?Xe=t[148]:(Xe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ye}),t[147]=Ye,t[148]=Xe);let Ze=c?`电脑控制协议`:`Computer Use protocol`,$e=u.computerUse?.profile??``,et;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(et=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=et):et=t[149];let tt=c?`未声明`:`Not declared`,nt;t[150]===tt?nt=t[151]:(nt=(0,$.jsx)(Z,{value:``,children:tt}),t[150]=tt,t[151]=nt);let rt,it,at;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(rt=(0,$.jsx)(Z,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),it=(0,$.jsx)(Z,{value:`structured-tools-v1`,children:`structured-tools-v1`}),at=(0,$.jsx)(Z,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[152]=rt,t[153]=it,t[154]=at):(rt=t[152],it=t[153],at=t[154]);let ot;t[155]!==Ze||t[156]!==$e||t[157]!==nt?(ot=(0,$.jsxs)(Qe,{"aria-label":Ze,value:$e,onChange:et,children:[nt,rt,it,at]}),t[155]=Ze,t[156]=$e,t[157]=nt,t[158]=ot):ot=t[158];let st=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,ct;t[159]===st?ct=t[160]:(ct=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:st}),t[159]=st,t[160]=ct);let lt;t[161]===f?lt=t[162]:(lt=f.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:f.get(`computerUse`)}),t[161]=f,t[162]=lt);let ut;t[163]!==ot||t[164]!==ct||t[165]!==lt?(ut=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[ot,ct,lt]}),t[163]=ot,t[164]=ct,t[165]=lt,t[166]=ut):ut=t[166];let dt;t[167]!==Xe||t[168]!==ut?(dt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Xe,ut]}),t[167]=Xe,t[168]=ut,t[169]=dt):dt=t[169];let ft;t[170]!==Je||t[171]!==dt?(ft=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Je,dt]}),t[170]=Je,t[171]=dt,t[172]=ft):ft=t[172];let pt;t[173]===s.cancel?pt=t[174]:(pt=(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,children:s.cancel})}),t[173]=s.cancel,t[174]=pt);let mt=r?s.addModelConfirm:s.saveModelConfirm,ht;t[175]!==S||t[176]!==mt?(ht=(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:S,children:mt}),t[175]=S,t[176]=mt,t[177]=ht):ht=t[177];let gt;t[178]!==pt||t[179]!==ht?(gt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[pt,ht]}),t[178]=pt,t[179]=ht,t[180]=gt):gt=t[180];let _t;return t[181]!==F||t[182]!==ft||t[183]!==gt?(_t=(0,$.jsxs)($.Fragment,{children:[F,ft,gt]}),t[181]=F,t[182]=ft,t[183]=gt,t[184]=_t):_t=t[184],_t}function Br(){return new Map}function Vr(e){return e.language}function Hr(e){let t=(0,an.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(S,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim`,kt)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,bt,`overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(zr,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(T,{children:[l,(0,$.jsx)(E,{className:u,onOpenAutoFocus:Ur,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(O,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function Ur(e){return e.preventDefault()}function Wr(e){let t=(0,an.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>pt(n).then(Gr),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(xe,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Gr(e){return e.apiKey??null}function Kr(e){let t=(0,an.c)(23),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),v;t[0]===r?v=t[1]:(v=e=>{e||(_(null),m(!1)),r(e)},t[0]=r,t[1]=v);let y=v,b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(S,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,kt)}),t[2]=b):b=t[2];let x,C,w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{f.current=document.activeElement instanceof HTMLElement?document.activeElement:null},C=e=>{f.current?.isConnected&&(e.preventDefault(),f.current.focus({preventScroll:!0}))},w=g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,bt),t[3]=x,t[4]=C,t[5]=w):(x=t[3],C=t[4],w=t[5]);let D;t[6]!==c||t[7]!==o||t[8]!==s||t[9]!==y||t[10]!==a||t[11]!==l||t[12]!==u||t[13]!==r||t[14]!==d||t[15]!==i||t[16]!==p||t[17]!==h?(D=(0,$.jsxs)(T,{children:[b,(0,$.jsx)(E,{onOpenAutoFocus:x,onCloseAutoFocus:C,className:w,children:h?(0,$.jsx)(Ye,{target:h,zh:u===`zh`,onDone:()=>y(!1)}):!a&&p?(0,$.jsx)(Dt,{providerId:i,existingConnection:!0,row:o.find(e=>e.id===i),language:u,onApplied:d,onBack:()=>m(!1),onDone:()=>y(!1)}):a?(0,$.jsx)(Jr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>_({providerId:i,modelIds:[e]})}):(0,$.jsx)(qr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onQuickSetup:()=>m(!0)})})]}),t[6]=c,t[7]=o,t[8]=s,t[9]=y,t[10]=a,t[11]=l,t[12]=u,t[13]=r,t[14]=d,t[15]=i,t[16]=p,t[17]=h,t[18]=D):D=t[18];let k;return t[19]!==y||t[20]!==n||t[21]!==D?(k=(0,$.jsx)(O,{open:n,onOpenChange:y,children:D}),t[19]=y,t[20]=n,t[21]=D,t[22]=k):k=t[22],k}function qr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o,onQuickSetup:s}){let c=t.find(t=>t.id===e),f=ee[e],p=n.filter(t=>t.provider===e),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(c?.apiKey??``),[x,S]=(0,Q.useState)(!1),[C,T]=(0,Q.useState)(!1),[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),j=h(i).providersSettings,M=c?.supportsApiKey!==!1,N=c?.supportsOAuth===!0,P=c?.authMode===`oauth`&&c.authStatus===`connected`,F=c?.configured===!0&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[I,R]=(0,Q.useState)(null),[z,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(`idle`),[te,W]=(0,Q.useState)(null),[ne,G]=(0,Q.useState)(null),[K,ie]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(``),q=(0,Q.useRef)(null),Y=(0,Q.useRef)(null),de=H===`waiting`||H===`waiting_code`,fe=(0,Q.useMemo)(()=>ot(e,i),[e,i]),pe=y!==(c?.apiKey??``),me=async()=>{let t=y.trim();if(!(!t||!M||J(t))){S(!0),O(null);try{await ge({[e]:t}),T(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){O(e instanceof Error?e.message:r.saveError)}finally{S(!1)}}};(0,Q.useEffect)(()=>{if(!I||!de)return;let e=window.setInterval(()=>{(async()=>{try{let t=await jt(I);t.status===`waiting_auth`||t.status===`waiting_code`?(U(t.status===`waiting_code`?`waiting_code`:`waiting`),V(t.message??null),W(t.authUrl??null),G(t.instructions??null),ie(t.deviceCode??null),t.authUrl&&t.authUrl!==Y.current&&(Y.current=t.authUrl,le(t.authUrl,q.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),re(q.current),q.current=null,U(`success`),V(t.message??j.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),re(q.current),q.current=null,U(`error`),V(t.error??t.message??j.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[I,de,a,o,j.revokeFailed,j.saved]),(0,Q.useEffect)(()=>()=>{I&&Oe(I).catch(()=>{})},[I]),(0,Q.useEffect)(()=>()=>{re(q.current),q.current=null},[]);let he=async()=>{try{await Pe(e),o(),a()}catch{}},ve=async()=>{re(q.current),q.current=_e(),Y.current=null,U(`waiting`),V(j.oauthStarting),W(null),G(null),ie(null),O(null);try{R((await Le(e)).sessionId)}catch(e){re(q.current),q.current=null,U(`error`),V(e instanceof Error?e.message:j.revokeFailed)}},xe=async()=>{if(I){try{await ye(I)}catch{}re(q.current),q.current=null,Y.current=null,U(`idle`),V(null),R(null),W(null),G(null),ie(null)}},Se=async()=>{if(!(!I||!ae.trim()))try{await se(I,ae.trim()),oe(``),V(j.oauthProcessingCode)}catch(e){U(`error`),V(e instanceof Error?e.message:j.revokeFailed)}},Ce=async()=>{try{await B(e),o(),a()}catch(e){O(e instanceof Error?e.message:j.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(D,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ue.press),children:(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[s?(0,$.jsx)(X,{variant:`secondary`,onClick:s,children:i===`zh`?`配置模型用途`:`Configure model uses`}):null,f?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.description}):null,c?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:c.baseUrl})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,M?(0,$.jsx)(Wr,{providerId:e,inputId:`manage-api-key`,value:y,onChange:e=>{b(e),T(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):c?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),c?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,N?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:j.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:P?j.sourceOauth:j.oauthHint})]}),P?(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void Ce(),children:j.revoke}):(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:de,onClick:()=>void ve(),children:[de?(0,$.jsx)(ze,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),j.oauth]})]}),z?(0,$.jsx)(`p`,{className:g(`text-xs`,H===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:z}):null,H===`waiting`||H===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[te?(0,$.jsxs)(`a`,{href:te,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),j.openAuthPage]}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void xe(),children:j.cancelOAuth})]}):null,ne?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}):null,K?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:j.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:K}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.deviceCodeHint})]}):null,H===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&void Se(),placeholder:j.pasteRedirectUrl,className:g(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,De)}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void Se(),children:j.submitCode})]}):null]}):null,fe.length>0&&M?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:fe.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[be(e,r),(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0})]},e))}):null,p.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,p.length,`)`]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:_,onChange:e=>v(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:p.filter(e=>!_||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[$e(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),E?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[F?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>A(!0),children:[(0,$.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:M&&pe&&!J(y.trim())?(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!y.trim()||x||C,onClick:()=>void me(),children:C?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):x?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ze,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Ge,{open:k,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void he(),onCancel:()=>A(!1)})]})}function Jr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=h(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[_,v]=(0,Q.useState)(c?.models??[]),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[C,T]=(0,Q.useState)(!1),[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(null),R=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:J(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},z=async()=>{let e=R({models:_,modelDiscovery:{enabled:x}});if(e){T(!0),O(null);try{await ct(e),a(),i()}catch(e){O(e instanceof Error?e.message:n.saveError)}finally{T(!1)}}},ee=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await ct({providers:r}),a(),i()}catch{}},B=(e,t)=>{I({model:e,isNew:t}),P(!0)},V=async e=>{if(!F)return;let t=F.isNew&&!_.some(t=>t.id===e.id),r=F.isNew?[..._,e]:_.map(t=>t.id===e.id?e:t);v(r);let i=R({models:r});if(i)try{await ct(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){O(e instanceof Error?e.message:n.saveError)}},H=async e=>{let t=_.filter(t=>t.id!==e);v(t),M(null);let r=R({models:t});if(r)try{await ct(r),a()}catch(e){O(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ue.press),children:(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),className:g(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,De)})]}),(0,$.jsx)(Wr,{providerId:e,inputId:`manage-custom-api-key`,value:d,onChange:f,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[s.modelsSection,_.length>0?` (${_.length})`:``]}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>B(null,!0),children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),s.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y,onChange:e=>b(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),_.filter(e=>!y||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:_.filter(e=>!y||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ue.press),onClick:()=>B(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(Xe,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,ue.press),onClick:()=>M(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(L,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),E?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>A(!0),children:[(0,$.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:C,onClick:()=>void z(),children:C?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ze,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Ge,{open:k,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void ee(),onCancel:()=>A(!1)}),(0,$.jsx)(Ge,{open:j!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,j??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{j&&H(j)},onCancel:()=>M(null)}),(0,$.jsx)(Hr,{open:N,onOpenChange:e=>{P(e),e||I(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void V(e),m:s})]})}var Yr=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],Xr=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,Zr={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function Qr(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function $r(e){let t=(0,an.c)(38),{draft:n,setDraft:r,zh:i,capability:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=k(N,M,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l=c,u=i?Zr.zh:Zr.en,d;t[3]!==n||t[4]!==r?(d=(e,t)=>{let i={...n.models.intents};t?i[e]=Qr(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[3]=n,t[4]=r,t[5]=d):d=t[5];let f=d,p;t[6]!==a||t[7]!==n||t[8]!==l||t[9]!==s.error||t[10]!==s.isLoading||t[11]!==r||t[12]!==i?(p=a===`chat`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:(0,$.jsx)(oe,{title:i?`模型回退`:`Model fallbacks`,summary:i?`已配置 ${n.models.chat.fallbacks.length} 个备用模型。`:`${n.models.chat.fallbacks.length} fallback models configured.`,children:(0,$.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,$.jsx)(tn,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:l,loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}})})})})}):null,t[6]=a,t[7]=n,t[8]=l,t[9]=s.error,t[10]=s.isLoading,t[11]=r,t[12]=i,t[13]=p):p=t[13];let m;t[14]!==a||t[15]!==n||t[16]!==r||t[17]!==i?(m=a===`image`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:n.models.imageGeneration?(0,$.jsx)(oe,{title:i?`图片执行策略`:`Image execution policy`,summary:i?`当前超时与回退策略继续生效。`:`The current timeout and fallback policy remains active.`,children:(0,$.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,$.jsx)(Mt,{allowEmpty:!0,type:`number`,min:1,className:`${Xr} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,$.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,$.jsx)(R,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,role:`group`,"aria-label":i?`服务商自动回退`:`Automatic provider fallback`,children:[!0,!1].map(e=>(0,$.jsx)(X,{"aria-pressed":n.models.imageGeneration?.autoProviderFallback===e,variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]})}):null}):null,t[14]=a,t[15]=n,t[16]=r,t[17]=i,t[18]=m):m=t[18];let h;t[19]!==a||t[20]!==n||t[21]!==l||t[22]!==s.error||t[23]!==s.isLoading||t[24]!==r||t[25]!==i?(h=a===`vision`&&n.models.imageUnderstanding?(0,$.jsx)(oe,{title:i?`模型回退`:`Model fallbacks`,summary:i?`主模型不可用时使用已配置的备用模型。`:`Use configured fallback models when the primary is unavailable.`,children:(0,$.jsx)(tn,{primary:n.models.imageUnderstanding.primary,value:n.models.imageUnderstanding.fallbacks,models:l.filter(ei),loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,imageUnderstanding:{...n.models.imageUnderstanding,fallbacks:e}}})})}):null,t[19]=a,t[20]=n,t[21]=l,t[22]=s.error,t[23]=s.isLoading,t[24]=r,t[25]=i,t[26]=h):h=t[26];let g;t[27]!==a||t[28]!==u||t[29]!==n||t[30]!==f||t[31]!==i?(g=a===`chat`?(0,$.jsx)(oe,{title:i?`任务模型路由`:`Task model routing`,summary:i?`已配置 ${Object.keys(n.models.intents).length} 类任务路由;其他任务使用默认模型。`:`${Object.keys(n.models.intents).length} task routes configured; other tasks use the default model.`,children:(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i?`按任务选择模型`:`Route by task`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`}),(0,$.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:Yr.map(e=>(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:u[e][0]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u[e][1]})]}),(0,$.jsx)(P,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${u[e][0]}模型`:`${u[e][0]} model`,onChange:t=>f(e,t)})]},e))})]})}):null,t[27]=a,t[28]=u,t[29]=n,t[30]=f,t[31]=i,t[32]=g):g=t[32];let _;return t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-5`,children:[p,m,h,g]}),t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37],_}function ei(e){return e.vision}function ti(e){let t=(0,an.c)(9),{data:n,error:r}=k(`settings-agent-defaults`,K);if(r&&!n){let e=String(r),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[0]=e,t[1]=n),n}if(!n){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ee,{className:`h-32 rounded-xl`}),t[2]=e):e=t[2],e}let i;t[3]===n.defaults.models?i=t[4]:(i=JSON.stringify(n.defaults.models),t[3]=n.defaults.models,t[4]=i);let a;return t[5]!==n.defaults||t[6]!==e||t[7]!==i?(a=(0,$.jsx)(ni,{...e,initial:n.defaults},i),t[5]=n.defaults,t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function ni(e){let t=(0,an.c)(36),{initial:n,capability:r,zh:i,disabled:a,onPendingChange:o}=e,s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[c,l]=(0,Q.useState)(s),u;t[2]===n?u=t[3]:(u=()=>structuredClone(n),t[2]=n,t[3]=u);let[d,f]=(0,Q.useState)(u),p;t[4]===c.models?p=t[5]:(p=JSON.stringify(c.models),t[4]=c.models,t[5]=p);let m;t[6]===d.models?m=t[7]:(m=JSON.stringify(d.models),t[6]=d.models,t[7]=m);let h=p!==m,g;t[8]!==n.models||t[9]!==i?(g=async e=>{let t=await K();if(JSON.stringify(t.defaults.models)!==JSON.stringify(n.models))throw Error(i?`模型设置已变化,请刷新后重试。`:`Model settings changed. Refresh before retrying.`);f((await Y({...t.defaults,models:e.models},{scope:`models`,expectedModels:n.models})).defaults),await He()},t[8]=n.models,t[9]=i,t[10]=g):g=t[10];let _=g,v;t[11]!==h||t[12]!==c||t[13]!==_?(v={value:c,dirty:h,onSave:_,delayMs:0},t[11]=h,t[12]=c,t[13]=_,t[14]=v):v=t[14];let y=Rt(v),b=h||y.status===`saving`||!!y.error,x,S;t[15]!==o||t[16]!==b?(x=()=>(o(b),()=>o(!1)),S=[b,o],t[15]=o,t[16]=b,t[17]=x,t[18]=S):(x=t[17],S=t[18]),(0,Q.useEffect)(x,S);let C=a||y.status===`saving`,w;t[19]!==y.error||t[20]!==y.status?(w=(0,$.jsx)(Lt,{status:y.status,error:y.error}),t[19]=y.error,t[20]=y.status,t[21]=w):w=t[21];let T;t[22]!==y.error||t[23]!==y.retry||t[24]!==i?(T=y.error?(0,$.jsx)(X,{variant:`secondary`,onClick:y.retry,children:i?`重试保存`:`Retry saving`}):null,t[22]=y.error,t[23]=y.retry,t[24]=i,t[25]=T):T=t[25];let E;t[26]!==r||t[27]!==c||t[28]!==i?(E=(0,$.jsx)($r,{capability:r,draft:c,setDraft:l,zh:i}),t[26]=r,t[27]=c,t[28]=i,t[29]=E):E=t[29];let D;return t[30]!==y.onBlurCapture||t[31]!==w||t[32]!==T||t[33]!==E||t[34]!==C?(D=(0,$.jsxs)(`fieldset`,{disabled:C,onBlurCapture:y.onBlurCapture,className:`min-w-0 space-y-3`,children:[w,T,E]}),t[30]=y.onBlurCapture,t[31]=w,t[32]=T,t[33]=E,t[34]=C,t[35]=D):D=t[35],D}function ri(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function ii(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`模型与能力`:`Models and capabilities`,href:`/settings/capabilities/models`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:dt(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function ai(e,t){switch(e){case`computer-use`:return{guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{guidance:t?`选择语音识别服务,或安装自管 STT 扩展`:`Choose a speech-to-text service or install a self-managed STT extension`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function oi(){let e=await y(x(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function si(){let e=await y(x(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function ci({showCapabilities:e=!0}={}){let t=b(e=>e.language)===`zh`,{data:n,error:r,isLoading:i}=k(We,oi,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:a}=k(pe,si,{revalidateOnFocus:!1}),[o,s]=(0,Q.useState)(!1),[c,d]=(0,Q.useState)(null),f=Object.values(n?.sources??{}),p=f.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),m=(n?.references??[]).filter(e=>e.availability===`unavailable`),h=n?.sync.lastSuccessAt??Math.max(0,...f.map(e=>e.lastSuccessAt)),_=!!r,v=n?.sync.sourceErrors??{},S=[...n?.sync.lastError?[[`catalog`,n.sync.lastError]]:[],...Object.entries(v),...c?[[`refresh`,c]]:[],...r instanceof Error?[[`load`,r.message]]:[]],C=n?.sync.lastAttemptAt??h,w=Object.entries(a?.capabilities??{}).filter(([e])=>e!==`computer-use`||qe()),T=w.some(([,e])=>{let t=ri(e);return t===`degraded`||t===`misconfigured`}),E=w.filter(([,e])=>ri(e)===`ready`).length,D=(0,Q.useRef)(null);if((0,Q.useEffect)(()=>{T&&!i&&D.current?.setAttribute(`open`,``)},[T,i]),i)return(0,$.jsx)(Ee,{className:`h-24 w-full rounded-2xl`});let O=async()=>{s(!0),d(null);try{let e=await y(x(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await He()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[e?(0,$.jsxs)(`details`,{ref:D,className:`group`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[T?(0,$.jsx)(st,{className:`size-4 text-amber-500`,"aria-hidden":!0}):E===w.length&&w.length>0?(0,$.jsx)(u,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(it,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:t?`${E}/${w.length} 项已配置,不影响基础聊天功能`:`${E} of ${w.length} configured · Not required for chat`})]}),(0,$.jsx)(ht,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),a?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(a.capabilities).map(([e,n])=>{if(e===`computer-use`&&!qe())return null;let r=e===`vision`?t?`图片理解`:`Vision`:e===`image-generation`?t?`图片生成`:`Image generation`:e===`computer-use`?t?`电脑控制模型`:`Computer use model`:e.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=ri(n),o=a===`degraded`||a===`misconfigured`,s=ai(e,t),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?e===`computer-use`?t?`已配置`:`Configured`:t?`可用`:`Ready`:a===`off`?t?`已关闭`:`Off`:a===`not-configured`?t?`未配置`:`Not configured`:a===`degraded`?t?`正在使用备用方案`:`Using fallback`:t?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:n.primary?`${n.primary.provider}/${n.primary.model}`:void 0,children:n.primary?`${i?t?`自动`:`Auto`:t?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a===`not-configured`?t?`可稍后按需配置`:`Set up later if needed`:t?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?t?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]}),u={"aria-label":o?`${r}:${s.action}`:`${t?`配置`:`Configure`} ${r}`,className:g(`rounded-lg bg-surface-base/45 px-3 py-3 text-left transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`)};if(e===`computer-use`)return(0,$.jsx)(l,{to:`/settings/computer-use`,...u,children:c},e);let d={vision:`vision`,"image-generation":`image`,stt:`transcription`,tts:`speech`}[e];return(0,$.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,...u,onClick:()=>nt(d,o?`services`:`settings`),children:c},e)})}):null]}):null,m.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:m.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let n=!!v[e.ref.split(`/`)[0]??``],r=ii(e.locations[0]??``,t);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(st,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[e.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:n?t?`暂时无法验证`:`Temporarily unverified`:t?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[n?t?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:t?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,C?` · ${t?`最近检测`:`Last checked`} ${new Date(C).toLocaleString()}`:``]}),e.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[t?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(X,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:o,onClick:()=>void O(),children:[o?(0,$.jsx)(ze,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(_t,{className:`size-3.5`,"aria-hidden":!0}),o?t?`检测中…`:`Checking…`:t?`重新检测`:`Check again`]}),(0,$.jsx)(X,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:r.href,children:[(0,$.jsx)(Ot,{className:`size-3.5`,"aria-hidden":!0}),e.suggestedRef?t?`更换模型`:`Replace model`:t?`调整配置`:`Adjust configuration`]})}),(0,$.jsxs)(`details`,{className:`group/references`,children:[(0,$.jsxs)(`summary`,{className:`touch-target inline-flex cursor-pointer list-none items-center gap-1 rounded-xl px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[t?`查看 ${e.locations.length} 处引用`:`View ${e.locations.length} ${e.locations.length===1?`reference`:`references`}`,(0,$.jsx)(ht,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:e.locations.map(e=>{let n=ii(e,t);return(0,$.jsx)(`li`,{children:(0,$.jsx)(l,{className:`inline-flex rounded px-1.5 py-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:n.href,title:e,children:n.label})},e)})})]})]})]})})()},e.ref))}):null,_||c?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:_?t?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:t?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):null,(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:t?`高级诊断`:`Advanced diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:t?`${f.length} 个来源,${p} 个可用模型${h?` · 最近同步 ${new Date(h).toLocaleString()}`:``}`:`${f.length} sources, ${p} available models${h?` · Last synced ${new Date(h).toLocaleString()}`:``}`}),S.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg bg-surface-base/45 p-2 font-mono text-[11px] leading-5`,"aria-label":t?`同步错误详情`:`Sync error details`,children:S.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}):null]}),(0,$.jsxs)(X,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:o,onClick:()=>void O(),children:[o?(0,$.jsx)(ze,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(_t,{className:`size-4`,"aria-hidden":!0}),o?t?`刷新中…`:`Refreshing…`:t?`刷新目录`:`Refresh catalog`]})]})]})]})}function li(e){let t=(0,an.c)(167),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{inlineUse:r,inlineView:i,onViewChange:u,onPendingChange:d}=n,f=i===void 0?`settings`:i,p=b(pi),m=p===`zh`,g;t[2]===p?g=t[3]:(g=h(p),t[2]=p,t[3]=g);let _=g.capabilitiesSettings,{capability:v}=s(),[y,x]=o(),{state:S}=a(),C;t[4]===y?C=t[5]:(C=ke(y.get(`returnTo`)),t[4]=y,t[5]=C);let w=C,[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),F=j||N||k,[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(null),ee=(0,Q.useRef)(null),B=xt(),H=fi,U,te;t[6]!==d||t[7]!==F?(U=()=>(d?.(F),()=>d?.(!1)),te=[F,d],t[6]=d,t[7]=F,t[8]=U,t[9]=te):(U=t[8],te=t[9]),(0,Q.useEffect)(U,te);let W,ne;t[10]!==v||t[11]!==r||t[12]!==S||t[13]!==y||t[14]!==x?(W=()=>{if(r||v!==`models`)return;let e=V(y.get(`configure`));if(!e&&y.get(`add`)!==`1`)return;let t=window.setTimeout(()=>{e?nt(e,y.get(`tab`)===`services`?`services`:`settings`):L(!0);let t=new URLSearchParams(y);t.delete(`configure`),t.delete(`tab`),t.delete(`add`),x(t,{replace:!0,state:S})},0);return()=>window.clearTimeout(t)},ne=[v,r,y,x,S],t[10]=v,t[11]=r,t[12]=S,t[13]=y,t[14]=x,t[15]=W,t[16]=ne):(W=t[15],ne=t[16]),(0,Q.useEffect)(W,ne);let re;t[17]!==r||t[18]!==u||t[19]!==F?(re=e=>{if(!F){if(!r){nt(e,`services`);return}u?.(`services`),E(void 0)}},t[17]=r,t[18]=u,t[19]=F,t[20]=re):re=t[20];let G=re,K;t[21]===u?K=t[22]:(K=e=>{H(),u?.(`settings`),E(e)},t[21]=u,t[22]=K);let ie=K;if(r){let e=f===`services`,n=N||k,i;t[23]!==r||t[24]!==G||t[25]!==B||t[26]!==n||t[27]!==m?(i=(0,$.jsx)(Lr,{data:B,zh:m,onlyUse:r,disabled:n,onPendingChange:M,onChange:G}),t[23]=r,t[24]=G,t[25]=B,t[26]=n,t[27]=m,t[28]=i):i=t[28];let a;t[29]!==e||t[30]!==i?(a=(0,$.jsx)(`div`,{hidden:e,children:i}),t[29]=e,t[30]=i,t[31]=a):a=t[31];let o;t[32]!==T||t[33]!==r||t[34]!==f||t[35]!==m?(o=T===r&&f===`settings`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:m?`服务设置已保存`:`Service settings saved`}):null,t[32]=T,t[33]=r,t[34]=f,t[35]=m,t[36]=o):o=t[36];let s=f!==`services`,c;t[37]!==ie||t[38]!==r?(c=()=>ie(r),t[37]=ie,t[38]=r,t[39]=c):c=t[39];let l;t[40]!==_.addProviderDialog||t[41]!==r||t[42]!==p||t[43]!==B||t[44]!==c?(l=(0,$.jsx)(Tr,{inline:!0,onEditingChange:O,use:r,data:B,language:p,labels:_.addProviderDialog,onPendingChange:A,onSaved:c},r),t[40]=_.addProviderDialog,t[41]=r,t[42]=p,t[43]=B,t[44]=c,t[45]=l):l=t[45];let u;t[46]!==ie||t[47]!==D||t[48]!==r||t[49]!==B||t[50]!==m?(u=r===`transcription`||r===`speech`?(0,$.jsx)(`div`,{hidden:D,children:(0,$.jsx)(Fr,{kind:r===`transcription`?`stt`:`tts`,modelServiceIds:B.builtinRows.map(di),zh:m,onPendingChange:A,onSaved:()=>ie(r)},r)}):null,t[46]=ie,t[47]=D,t[48]=r,t[49]=B,t[50]=m,t[51]=u):u=t[51];let d;t[52]!==ie||t[53]!==r?(d=r===`image`?(0,$.jsx)(xn,{connectOnly:!0,onPendingChange:A,onConnected:()=>ie(r)}):null,t[52]=ie,t[53]=r,t[54]=d):d=t[54];let h;t[55]!==k||t[56]!==s||t[57]!==l||t[58]!==u||t[59]!==d?(h=(0,$.jsxs)(`fieldset`,{hidden:s,disabled:k,className:`min-w-0 space-y-3`,children:[l,u,d]}),t[55]=k,t[56]=s,t[57]=l,t[58]=u,t[59]=d,t[60]=h):h=t[60];let g=f===`services`,v;t[61]!==k||t[62]!==r||t[63]!==j?(v=r===`transcription`||r===`speech`||r===`conversation`?(0,$.jsx)(Yn,{capability:r,onPendingChange:P,disabled:j||k},r):null,t[61]=k,t[62]=r,t[63]=j,t[64]=v):v=t[64];let y;t[65]!==k||t[66]!==r||t[67]!==j||t[68]!==m?(y=r===`chat`||r===`vision`||r===`image`?(0,$.jsx)(ti,{capability:r,zh:m,disabled:j||k,onPendingChange:P}):null,t[65]=k,t[66]=r,t[67]=j,t[68]=m,t[69]=y):y=t[69];let b;t[70]!==r||t[71]!==m?(b=r===`background`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m?`使用所选模型执行自动化、定时和无人值守任务。此设置不会启用任务,也不会自动改用其他计费服务。`:`Use the selected model for automations, schedules and unattended tasks. This does not enable tasks or automatically switch billing services.`}):null,t[70]=r,t[71]=m,t[72]=b):b=t[72];let x;t[73]!==g||t[74]!==v||t[75]!==y||t[76]!==b?(x=(0,$.jsxs)(`div`,{hidden:g,className:`space-y-4`,children:[v,y,b]}),t[73]=g,t[74]=v,t[75]=y,t[76]=b,t[77]=x):x=t[77];let S;t[78]!==G||t[79]!==o||t[80]!==h||t[81]!==x?(S=(0,$.jsxs)(wn.Provider,{value:G,children:[o,h,x]}),t[78]=G,t[79]=o,t[80]=h,t[81]=x,t[82]=S):S=t[82];let C;return t[83]!==a||t[84]!==S?(C=(0,$.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[a,S]}),t[83]=a,t[84]=S,t[85]=C):C=t[85],C}if(v===`search`){let e;t[86]===p?e=t[87]:(e=h(p),t[86]=p,t[87]=e);let n;t[88]===e.nav.settingsSearch?n=t[89]:(n=(0,$.jsx)(Nt,{title:e.nav.settingsSearch}),t[88]=e.nav.settingsSearch,t[89]=n);let r;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(xr,{}),t[90]=r):r=t[90];let i;return t[91]===n?i=t[92]:(i=(0,$.jsxs)(Pt,{children:[n,r]}),t[91]=n,t[92]=i),i}if(v!==`models`){let e;return t[93]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(c,{to:`/settings/capabilities/models`,replace:!0}),t[93]=e):e=t[93],e}let ae=m?`模型与能力`:`Models and capabilities`,oe=m?`按用途选择模型,在设置中调整参数与服务连接。`:`Choose models by purpose. Adjust parameters and connections in settings.`,q;t[94]===p?q=t[95]:(q=gt(p,`configuration`),t[94]=p,t[95]=q);let J;t[96]!==_.docsLink||t[97]!==q?(J=(0,$.jsx)(`a`,{href:q,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center rounded-lg px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_.docsLink}),t[96]=_.docsLink,t[97]=q,t[98]=J):J=t[98];let se;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{ee.current?.scrollIntoView?.({block:`start`}),ee.current?.focus({preventScroll:!0})},t[99]=se):se=t[99];let ce=m?`服务账户`:`Service accounts`,le;t[100]!==F||t[101]!==ce?(le=(0,$.jsx)(X,{variant:`secondary`,disabled:F,onClick:se,children:ce}),t[100]=F,t[101]=ce,t[102]=le):le=t[102];let ue;t[103]!==J||t[104]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[J,le]}),t[103]=J,t[104]=le,t[105]=ue):ue=t[105];let Y;t[106]!==ae||t[107]!==oe||t[108]!==ue?(Y=(0,$.jsx)(Nt,{title:ae,subtitle:oe,actions:ue}),t[106]=ae,t[107]=oe,t[108]=ue,t[109]=Y):Y=t[109];let de;t[110]!==w||t[111]!==m?(de=w?(0,$.jsx)(l,{to:w,className:`text-sm text-accent-fg hover:underline`,children:m?`返回`:`Back`}):null,t[110]=w,t[111]=m,t[112]=de):de=t[112];let fe;t[113]===F?fe=t[114]:(fe=e=>{F||nt(e)},t[113]=F,t[114]=fe);let pe;t[115]!==G||t[116]!==B||t[117]!==F||t[118]!==fe||t[119]!==m?(pe=(0,$.jsx)(Lr,{data:B,zh:m,disabled:F,onPendingChange:M,onChange:G,onSettings:fe}),t[115]=G,t[116]=B,t[117]=F,t[118]=fe,t[119]=m,t[120]=pe):pe=t[120];let me=m?`连接的服务`:`Connected services`,he;t[121]===me?he=t[122]:(he=(0,$.jsx)(`h2`,{id:`model-services-heading`,className:`text-base font-semibold text-fg`,children:me}),t[121]=me,t[122]=he);let ge=m?`在这里管理账户和密钥;各项能力的模型与参数在上方调整。`:`Manage accounts and keys here. Choose models and adjust capability settings above.`,_e;t[123]===ge?_e=t[124]:(_e=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ge}),t[123]=ge,t[124]=_e);let ve;t[125]!==he||t[126]!==_e?(ve=(0,$.jsxs)(`div`,{children:[he,_e]}),t[125]=he,t[126]=_e,t[127]=ve):ve=t[127];let ye;t[128]!==_.xopcCloudAccount||t[129]!==B.cards?(ye=B.cards.some(ui)?(0,$.jsx)(rn,{labels:_.xopcCloudAccount}):null,t[128]=_.xopcCloudAccount,t[129]=B.cards,t[130]=ye):ye=t[130];let be,xe;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>L(!0),xe=(e,t)=>z({providerId:e,isCustom:t}),t[131]=be,t[132]=xe):(be=t[131],xe=t[132]);let Se;t[133]!==_.connectedProviders||t[134]!==B?(Se=(0,$.jsx)(Ke,{labels:_.connectedProviders,data:B,onAdd:be,onManage:xe}),t[133]=_.connectedProviders,t[134]=B,t[135]=Se):Se=t[135];let Ce;t[136]===B.cards.length?Ce=t[137]:(Ce=B.cards.length>0?(0,$.jsx)(ci,{showCapabilities:!1}):null,t[136]=B.cards.length,t[137]=Ce);let we;t[138]===m?we=t[139]:(we=qe()?(0,$.jsx)(l,{className:`inline-block text-sm text-accent-fg hover:underline`,to:`/settings/computer-use`,children:m?`电脑操作设置`:`Computer use settings`}):null,t[138]=m,t[139]=we);let Te;t[140]!==ve||t[141]!==ye||t[142]!==Se||t[143]!==Ce||t[144]!==we?(Te=(0,$.jsxs)(`section`,{ref:ee,tabIndex:-1,"aria-labelledby":`model-services-heading`,className:`space-y-4 scroll-mt-4 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[ve,ye,Se,Ce,we]}),t[140]=ve,t[141]=ye,t[142]=Se,t[143]=Ce,t[144]=we,t[145]=Te):Te=t[145];let Ee;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>{H(),L(!1)},t[146]=Ee):Ee=t[146];let De;t[147]!==I||t[148]!==_.addProviderDialog||t[149]!==p||t[150]!==B.builtinRows||t[151]!==B.customConfig?(De=(0,$.jsx)(At,{open:I,connectOnly:!0,onOpenChange:L,builtinRows:B.builtinRows,customConfig:B.customConfig,labels:_.addProviderDialog,language:p,onSaved:Ee}),t[147]=I,t[148]=_.addProviderDialog,t[149]=p,t[150]=B.builtinRows,t[151]=B.customConfig,t[152]=De):De=t[152];let Oe;t[153]!==_.manageProviderDialog||t[154]!==p||t[155]!==R||t[156]!==B.allModels||t[157]!==B.builtinRows||t[158]!==B.customConfig?(Oe=R?(0,$.jsx)(Kr,{open:!0,onOpenChange:e=>{e||z(null)},providerId:R.providerId,isCustom:R.isCustom,builtinRows:B.builtinRows,customConfig:B.customConfig,allModels:B.allModels,labels:_.manageProviderDialog,language:p,onSaved:H}):null,t[153]=_.manageProviderDialog,t[154]=p,t[155]=R,t[156]=B.allModels,t[157]=B.builtinRows,t[158]=B.customConfig,t[159]=Oe):Oe=t[159];let Ae;return t[160]!==Y||t[161]!==de||t[162]!==pe||t[163]!==Te||t[164]!==De||t[165]!==Oe?(Ae=(0,$.jsxs)(Pt,{children:[Y,de,pe,Te,De,Oe]}),t[160]=Y,t[161]=de,t[162]=pe,t[163]=Te,t[164]=De,t[165]=Oe,t[166]=Ae):Ae=t[166],Ae}function ui(e){return e.id===`xopc-cloud`&&!e.isCustom}function di(e){return e.id}function fi(){He()}function pi(e){return e.language}export{li as CapabilitiesSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-DPxcWxfD.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-Djl2FW6_.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{$l as C,Fc as w,G as T,Gn as E,On as D,Rc as O,Rn as k,Un as A,Vi as j,Wc as M,Wn as N,Wu as P,Xa as F,kl as I,ms as L,of as R,ou as z,so as ee,uo as te,us as ne,uu as re,vs as ie,ys as ae,zl as oe}from"./index-Dsp_gNdl.js";import{t as se}from"./browser-BLJWD7WI.js";import{r as ce}from"./settings-page-layout-Dx5S-Msc.js";import{t as le}from"./schema-form-CJvaVHkx.js";var B=e(t(),1),V=n();async function ue(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function de(){return m(`/api/channels/status`)}var fe=ue;function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(se(),1),H=r();async function U(e){let t=await f(m(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function he({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let s=(0,B.useMemo)(()=>pe(e),[e]),c=(0,B.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,d]=(0,B.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,B.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let f=(0,B.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});d(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){d(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,B.useEffect)(()=>{let t=K(u.payload,e.id);if(!t){d(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return d(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,B.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||d(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,u.poll]);let p=s?.[1].label??(e.configured?n.reconnect:n.connect),m=e.actions?.[`doctor.run`]?.label??n.diagnose,h=G(u.payload),g=K(u.payload,e.id),_=g?u.generatedQr:q(u.payload),v=s?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),y=u.payload?.type===`form`?u.payload:null,b=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,H.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:l(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,H.jsxs)(M,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(s[0]),children:[u.busy?(0,H.jsx)(P,{className:`size-4 animate-spin`}):(0,H.jsx)(re,{className:`size-4`}),p]}):null,e.actions?.[`doctor.run`]?(0,H.jsxs)(M,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void f(`doctor.run`),children:[(0,H.jsx)(oe,{className:`size-4`}),m]}):null]})]}),h?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:h}):null,u.error?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,v?(0,H.jsxs)(`div`,{className:l(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,H.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,H.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,H.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,H.jsx)(O,{className:`size-48 rounded-md`})})}),(0,H.jsxs)(`div`,{className:l(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,H.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,H.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,H.jsx)(O,{className:`h-4 w-48 max-w-full`}),(0,H.jsx)(O,{className:`h-4 w-36 max-w-full`})]}),g?(0,H.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,H.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,H.jsx)(a,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,H.jsx)(`span`,{className:u.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:u.payload.message??(u.payload.ok?n.complete:n.failed)})]}):null,y?(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsx)(le,{schema:y.schema,values:u.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:u.busy,labels:c}),(0,H.jsx)(M,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(y.submitAction,u.formDraft),children:n.saveSetup})]}):null,b?(0,H.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ge=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function _e(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ve(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ge,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function ye(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function be(e,t,n){let r=ye(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function xe(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,ie):l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,ie,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Se(e){let t=(0,V.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:S}=e,C=m===void 0?!1:m,T=n===`drawer`,[E,D]=(0,B.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,H.jsx)(h,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ae)}),t[0]=O):O=t[0];let k;t[1]!==n||t[2]!==C?(k=xe(n,C),t[1]=n,t[2]=C,t[3]=k):k=t[3];let A;t[4]===c?A=t[5]:(A=c?(0,H.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=A);let j;t[6]===u?j=t[7]:(j=u?(0,H.jsx)(g,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=j);let N;t[8]!==d||t[9]!==o||t[10]!==S||t[11]!==T||t[12]!==a?(N=T?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,H.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(M,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,H.jsx)(s,{className:`size-5`,strokeWidth:1.75})})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:l(w,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,H.jsx)(s,{className:`size-4`})})}),S]}),t[8]=d,t[9]=o,t[10]=S,t[11]=T,t[12]=a,t[13]=N):N=t[13];let P=T?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=l(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==f||t[17]!==F?(I=(0,H.jsx)(`div`,{className:F,children:f}),t[16]=f,t[17]=F,t[18]=I):I=t[18];let R;t[19]!==p||t[20]!==E||t[21]!==A||t[22]!==j||t[23]!==N||t[24]!==I?(R=(0,H.jsxs)(L,{layer:`modal`,portalContainer:E,children:[A,j,N,I,p]}),t[19]=p,t[20]=E,t[21]=A,t[22]=j,t[23]=N,t[24]=I,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==k?(z=(0,H.jsxs)(v,{children:[O,(0,H.jsx)(y,{ref:D,className:k,onOpenAutoFocus:Ce,children:R})]}),t[26]=R,t[27]=k,t[28]=z):z=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==z?(ee=(0,H.jsx)(x,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=ee):ee=t[32],ee}function Ce(e){return e.preventDefault()}var we=(0,B.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,H.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,H.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Te(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,H.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,H.jsx)(M,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,H.jsx)(M,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,H.jsx)(M,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,H.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Ee(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function De(e){return(await u(Ee(e))).payload?.channels??[]}function Oe(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Ee(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>De(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=S(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var ke=`channels-status`;function Ae(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function je(e){let t=t=>e(t.detail);return window.addEventListener(ke,t),()=>window.removeEventListener(ke,t)}function Me(e,t){let n=(0,V.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return je(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,B.useEffect)(i,a)}function Ne(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Pe(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Fe=[`enabled`],Ie=`max-w-7xl`,Le=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Re(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function We(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(X(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Fe.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Fe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Q(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,B.useState)(!1),r=(0,B.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,H.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,H.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,H.jsx)(te,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,H.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,H.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,V.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,H.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,H.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,H.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,H.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,H.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,H.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,H.jsx)(P,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,H.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,H.jsxs)(M,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,H.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function it(e){return(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,H.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:o,canManageConnection:s,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?a:n===`stopped`||n===`needs_setup`?R:P,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,H.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=He(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,H.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let E=i||r,D;t[22]===i?D=t[23]:(D=i?(0,H.jsx)(P,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=D);let O=i?c.checkingConnection:c.checkConnection,k;t[24]!==d||t[25]!==E||t[26]!==D||t[27]!==O?(k=(0,H.jsxs)(M,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:d,children:[D,O]}),t[24]=d,t[25]=E,t[26]=D,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(A=n===`stopped`?(0,H.jsxs)(M,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,H.jsx)(P,{className:`size-4 animate-spin`}):(0,H.jsx)(z,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=A):A=t[35];let j;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==o?(j=s?(0,H.jsx)(M,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:o?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=o,t[43]=j):j=t[43];let N;t[44]!==k||t[45]!==A||t[46]!==j?(N=(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[k,A,j]}),t[44]=k,t[45]=A,t[46]=j,t[47]=N):N=t[47];let F;return t[48]!==T||t[49]!==N?(F=(0,H.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,N]})}),t[48]=T,t[49]=N,t[50]=F):F=t[50],F}function st(e){let t=(0,V.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,H.jsx)(I,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,H.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,H.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,H.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,H.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,H.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,H.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct({channelId:e,onHeaderActionChange:t}){let n=p(e=>e.language),r=c(n),a=d(e=>!!e.conversationId),s=i(),u=E(e),h=Oe(a,n),g=h.entries,{data:_,mutate:v,isValidating:y}=S(a?de():null,fe,{revalidateOnFocus:!0}),{data:b,mutate:x}=S(a?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),w=b?.channels??{},O=b?.bindings??[],{data:M}=S(a?`channel-routing-agents`:null,ee,{revalidateOnFocus:!1}),P=(0,B.useMemo)(()=>g.find(e=>e.id===u),[u,g]),F=P?Be(P):null,{data:I,mutate:L}=S(a&&F?Ne(F):null,()=>Pe(F)),[R,z]=(0,B.useState)(null),[te,re]=(0,B.useState)(!1),[ie,ae]=(0,B.useState)(null),[oe,se]=(0,B.useState)(null),[V,ue]=(0,B.useState)(!1),[me,U]=(0,B.useState)(null),[W,G]=(0,B.useState)(null),K=R??I??{},q=r.channelsSettings,ge=(0,B.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),J=(0,B.useMemo)(()=>qe(ge,Fe),[ge]),ye=(0,B.useMemo)(()=>We(P),[P]),xe=(0,B.useMemo)(()=>Ge(J,ye),[ye,J]),Ce=(0,B.useMemo)(()=>qe(J,ye),[ye,J]),Ee=(0,B.useMemo)(()=>Je(xe),[xe]),De=P?W??_e(O,P.id):``,ke=(0,B.useMemo)(()=>(M?.items??[]).map(e=>{let t=k(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[M?.items,r.agentsSettings]),je=M?.items.find(e=>e.id===M.defaultId),ze=je?k(je,r.agentsSettings):M?.defaultId??``,He=(0,B.useMemo)(()=>({defaultBooleanLabel:q.schemaBooleanDefault,unsupportedArrayType:q.schemaUnsupportedArrayType,arrayAddPlaceholder:q.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>q.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[q]),X=(0,B.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Z=_!==void 0,Ke=(0,B.useCallback)(e=>be(e,X.get(e.id),Z),[X,Z]),Q=(0,B.useCallback)(async()=>{await Promise.all([h.mutate(),v()])},[h,v]);Me((0,B.useCallback)(e=>{let t=Ae(e);t&&v(t,!1)},[v]),a);let Ye=(0,B.useMemo)(()=>a?{secondary:(0,H.jsx)(we,{ch:q,refreshing:h.isValidating||y,saveOk:!1,onRefresh:()=>void Q()})}:null,[h.isValidating,q,a,y,Q]);(0,B.useLayoutEffect)(()=>(t?.(Ye),()=>t?.(null)),[Ye,t]);let Xe=(0,B.useCallback)(e=>{s(N(e)),z(null),G(null),U(null)},[s]),Ze=(0,B.useCallback)(()=>{s(A),z(null),G(null),U(null)},[s]),Qe=(0,B.useCallback)(async e=>{se(e.id),U(null);try{let t=await f(m(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{se(null)}},[Q]);(0,B.useEffect)(()=>{G(null),ue(!1)},[P?.id]);let $e=(0,B.useCallback)(async()=>{if(!P||!R&&W===null)return!1;let e=Be(P);re(!0),U(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...W===null?{}:{bindings:ve(O,P.id,W)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await L(R,!1),await x(),await h.mutate(),z(null),G(null),!0}catch(e){return U(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[P,W,O,h,R,x,L]),et=(0,B.useCallback)(async e=>{let t=Y(e),n=Be(e),r=P?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Xe(e.id);return}ae(e.id),U(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await x(),await v(),P?.id===e.id&&(await L(),z(null))}catch(e){U(e instanceof Error?e.message:String(e))}finally{ae(null)}},[P?.id,h,R,x,L,v,Xe]),$=P?.ui?.modal,it=$?.placement!==`replace-config`,at=P?Ke(P):`checking`,ct=P?!Y(P).ready||V:!1;return a?(0,H.jsxs)(ce,{gap:`gap-4`,className:Ie,padding:Le,children:[h.isLoading?(0,H.jsx)(D,{sections:2}):h.error?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,H.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,H.jsx)(rt,{entry:e,config:w[Be(e)]?.config,runtime:Ke(e),busy:ie===e.id,restarting:oe===e.id,ch:q,onOpen:()=>Xe(e.id),onToggle:()=>void et(e),onRestart:()=>void Qe(e)},e.id))}),me?(0,H.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:me}):null,(0,H.jsx)(Se,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Ze()},closeAriaLabel:q.close,srTitle:P?.label??q.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,H.jsx)(Te,{ch:q,dirty:!!R||W!==null,saving:te,onCancel:Ze,onDiscard:()=>{z(null),G(null)},onSave:$e}):null,children:P?(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(tt,{entry:P}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,H.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(at)),children:Ve(at,q)})]}),(0,H.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(P).ready&&pe(P)?.[1].result===`qr`?q.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,H.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[q.docs,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,H.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(P).enabled?q.enabledLabel:q.disabledLabel}),(0,H.jsx)(nt,{checked:Y(P).enabled,disabled:ie===P.id,label:q.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void et(P)})]})]})}),(0,H.jsx)(ot,{runtime:at,restarting:oe===P.id,checking:y,showConnectionOptions:V,canManageConnection:Y(P).ready&&$?.placement!==`replace-config`,ch:q,onRestart:()=>void Qe(P),onCheck:()=>void Q(),onManageConnection:()=>ue(e=>!e)}),(0,H.jsx)(st,{entry:P,ch:q}),ct&&$?.placement!==`replace-config`?(0,H.jsx)(he,{entry:P,locale:n,messages:q,compact:!0,onChanged:async()=>{await L(),await Q(),await x()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,H.jsx)(j,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:K}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,H.jsx)(j,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:K}}):null,it&&Ee?(0,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.basicConfiguration}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.basicConfigurationHint})]}),(0,H.jsx)(le,{schema:xe,values:K,onChange:e=>z(e),disabled:te,labels:He})]}):null,(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(C,{className:`size-4 text-fg-muted`}),q.messageHandling]}),(0,H.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.agentRouting}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.messageHandlingHint})]}),(0,H.jsx)(ne,{value:De,options:ke,placeholder:q.agentRoutingSelect,emptyLabel:q.agentRoutingDefault.replace(`{{agent}}`,ze||q.agentRoutingSelect),ariaLabel:q.agentRouting,disabled:te||!M,onChange:e=>G(e)})]})]}),it&&Je(Ce)?(0,H.jsx)(T,{title:q.advancedConfiguration,summary:q.messageHandlingHint,children:(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(C,{className:`size-4 text-fg-muted`}),q.advancedConfiguration]}),(0,H.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,H.jsx)(le,{schema:Ce,values:K,onChange:e=>z(e),disabled:te,labels:He})})]})}):null,me?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:me}):null]}):null})]}):(0,H.jsx)(ce,{gap:`gap-3`,className:Ie,padding:Le,children:(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q.tokenRequired})})}export{ct as ChannelsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./messages-DPxcWxfD.js";import{a as c,n as l,r as u}from"./locale-store-Djl2FW6_.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{r as f}from"./gateway-config-swr-Di9g6pE8.js";import{n as p,t as m}from"./registry-api-BwR2CiR5.js";import{$i as h,Fn as g,In as _,Mu as v,Rc as y,Vl as b,Wc as x,Xl as S,as as C,ju as w,xd as ee}from"./index-Dsp_gNdl.js";import{n as T,r as E}from"./settings-page-layout-Dx5S-Msc.js";var D=n(),O=e(t(),1),k=r();function te({zh:e}){let t=s(e?`zh`:`en`).computerSettings,n=d(`settings-agent-defaults`,g),r=d(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,c]=(0,O.useState)(a),[l,u]=(0,O.useState)(!1),[f,v]=(0,O.useState)(``),[b,S]=(0,O.useState)(!1);(0,O.useEffect)(()=>{c(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{u(!0),v(``),S(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await g(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await _({...e.defaults,models:r});await n.mutate(i,!1),S(!0)}catch(e){v(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,k.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,k.jsx)(y,{className:`h-52 w-full rounded-xl`}):n.error?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,k.jsx)(x,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,k.jsx)(y,{className:`h-11 w-full rounded-lg`}):(0,k.jsx)(h,{value:o,onChange:e=>{c(e),S(!1)},disabled:l,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`})}),(0,k.jsx)(x,{variant:`primary`,disabled:l||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel})]}),(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:t.modelDataUse}),(0,k.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,k.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),b&&(0,k.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!C&&!r.isLoading&&!r.error&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,k.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,k.jsx)(x,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),f&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:f})]})]})}function A(e){let t=(0,D.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,k.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,k.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,k.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,k.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,k.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function j(){let e=(0,D.c)(2),t=l(M)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,k.jsx)(N,{zh:t}),e[0]=t,e[1]=n),n}function M(e){return e.language}function N({zh:e}){let t=s(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:l}=f(!0),d=n?.payload?.config,[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(``),[_,D]=(0,O.useState)(!1),[j,M]=(0,O.useState)(null),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(null),[ne,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),[re,H]=(0,O.useState)(!1),U=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,W=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,O.useEffect)(()=>{if(!U)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await U.status();e||(M(t),P(!1))}catch{e||(M(null),P(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[U]),(0,O.useEffect)(()=>{if(!U?.access)return;let e=!1;return U.access().then(t=>{e||(I(t),L(!1))}).catch(()=>{e||L(!0)}),()=>{e=!0}},[U]);let G=async e=>{m(!0),g(``);try{await e()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},ie=e=>G(async()=>{C()&&(await c(u(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),ae=async()=>{g(``),D(!1);try{await U?.stop(),D(!0),U&&M(await U.status())}catch(e){g(e instanceof Error?e.message:String(e))}},K=j?.session?.status??`idle`,q=t.states[K]??K,J=C()&&d?.computer?.enabled===!0,oe=j?.controlPaused?t.pausedNotice:J?j?.connected?`${t.connected} · ${q}`:j?t.disconnected:t.checking:t.disabled,Y=!U||N||j?.reenrollmentRequired===!0||!!(j?.error||j?.session?.errorCode)||j!=null&&(!j.permissions.accessibility||j.permissions.screenRecording!==`granted`),X=j?.permissions.accessibility===!0&&j.permissions.screenRecording===`granted`&&!j.reenrollmentRequired,Z=F?.apps.filter(e=>F.authorizedAppIds.includes(e.appId))??[],Q=F?.apps.filter(e=>!F.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(R.toLocaleLowerCase()))??[],$=(0,k.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),U?N?(0,k.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):j?X&&!re?(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(S,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,k.jsx)(x,{onClick:()=>H(!0),children:t.viewDetails})})}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.device,description:(0,k.jsxs)(`span`,{"aria-live":`polite`,children:[j.connected?t.connected:t.disconnected,` · `,q]}),children:j.reenrollmentRequired&&(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{M(await U.reenroll())})},children:t.reenroll})}),W&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(A,{icon:(0,k.jsx)(S,{className:`size-5`}),title:t.accessibility,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.accessibility?t.granted:t.notGranted}),!j.permissions.accessibility&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{G(()=>W.requestAccessibility())},children:t.openSettings})]}),(0,k.jsxs)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.screen,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.screenRecording===`granted`?t.granted:t.notGranted}),j.permissions.screenRecording!==`granted`&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{G(()=>W.requestScreen())},children:t.openSettings})]})]}),X&&(0,k.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,k.jsx)(x,{variant:`ghost`,onClick:()=>H(!1),children:t.hideDetails})})]}):(0,k.jsx)(`div`,{"aria-label":t.checking,children:(0,k.jsx)(y,{className:`h-20 w-full rounded-xl`})}):(0,k.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(j?.error||j?.session?.errorCode)&&(0,k.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:j.error||j.session?.errorCode})]});return(0,k.jsxs)(E,{gap:`gap-7`,children:[(0,k.jsx)(T,{title:t.title,subtitle:t.subtitle,meta:(0,k.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:U&&(0,k.jsxs)(x,{onClick:()=>{ae()},children:[(0,k.jsx)(b,{className:`size-3.5`}),t.stop]})}),h&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:h}),_&&(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,k.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!d&&!l?(0,k.jsx)(y,{className:`h-32 w-full rounded-xl`}):l?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(l),` `,(0,k.jsx)(x,{onClick:()=>{G(()=>r())},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(w,{className:`size-5`}),title:t.desktop,description:(0,k.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:p||!C(),onClick:()=>{ie(d?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),j?.controlPaused&&(0,k.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{U&&M(await U.resume()),D(!1)})},children:t.resume})})]})]}),Y&&$,U?.access&&(0,k.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!F?.allowAllApps&&(0,k.jsxs)(x,{disabled:p,"aria-expanded":B,"aria-controls":B?`computer-app-picker`:void 0,onClick:()=>{V(e=>!e),z(``)},children:[B?(0,k.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,k.jsx)(o,{className:`size-4`,"aria-hidden":!0}),B?t.doneAdding:t.addApp]})]}),F?(0,k.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(w,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":F.allowAllApps===!0,disabled:p,onClick:()=>{G(async()=>{I(await U.setAllAppAccess(!F.allowAllApps)),V(!1)})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${F.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${F.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!F.allowAllApps&&(0,k.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,k.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`ghost`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!1);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):ne?(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,k.jsx)(y,{className:`h-20 w-full rounded-xl`}),B&&!F?.allowAllApps&&(0,k.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{"aria-label":t.searchApps,value:R,onChange:e=>z(e.target.value),placeholder:t.searchApps,className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{I(await U.access()),L(!1)})},children:t.refreshApps})]}),F&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,k.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`secondary`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!0);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:F.appsBusy?t.appsBusy:F.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,k.jsx)(te,{zh:e}),!Y&&$,(0,k.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(ee,{className:`size-5`}),title:t.browser,description:d?d.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,k.jsx)(x,{asChild:!0,children:(0,k.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,k.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{j as ComputerSettingsPage,N as ComputerSettingsPanel};
|