@xopcai/xopc 0.0.414 → 0.0.416
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/_locales/en/messages.json +4 -1
- package/dist/browser-ext/_locales/zh_CN/messages.json +4 -1
- package/dist/browser-ext/dist/assets/{page-context-MuzjMBlJ.js → page-context-CVvmTWZb.js} +33 -9
- package/dist/browser-ext/dist/background.js +39 -10
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +22 -3
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-ClobpdW3.js → agent-avatar-dicebear-CufU7cqe.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DHDAcss8.js +1 -0
- package/dist/gateway/static/root/assets/agents-BV3dAoa0.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-CeBkHnl8.js → agents-admin-api-B1p-ghg9.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CLunLNGp.js → app-management-settings-panel-D4-n1uBg.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DBEgoE9g.js → appearance-settings-Cgn4eNsX.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BOYzD7Zz.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-JElK4Goq.js → archive-plugin-B4btCsiV.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CZ0UqwyU.js → automations-page-yb1EL_3N.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-J7LJ4RuV.js +8 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CXFawow6.js → binary-plugins-DQT9e258.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BoduwSYI.js → block-editor-B50rU9tL.js} +30 -30
- package/dist/gateway/static/root/assets/{browser-automation-inputs-D1pDgMJu.js → browser-automation-inputs-D6AccXaA.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-BiQz6lJA.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-W9kuxBbE.js +3 -0
- package/dist/gateway/static/root/assets/{capabilities-Bpeh6E22.js → capabilities-BlxF36t-.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-iXe87MdG.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CRLSXe7Z.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-BasrAWA0.js → capability-header-actions-BMnbzHms.js} +1 -1
- package/dist/gateway/static/root/assets/channels-CrRJkOKX.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CwQbzcZ_.js → chat-terminal-dock-Bd3af4gL.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-DNWeJKfF.js → computer-settings-page-DXfqy7xh.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-CxHgC5RM.js → connector-service-page-B-cw0CPU.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DbFxc0Fd.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-CXxLbLJb.js → date-picker-CqzXevH6.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DVuWMrSj.js → dependency-picker-pgT4Gyaf.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BDlg9g4s.js → desktop-pet-settings-Dy_-i2L8.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-KbVLtAlO.js → desktop-pet-zICeqw9c.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-ByGbxqkg.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-a7xEodzo.js → directory-picker-path-field-C-aQ7qoM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CHelH5u_.js → extension-debug-page-2NwpYkS5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CrVHmS9-.js → extension-page-y9J0z7_Q.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CiMybi0r.js → extension-settings-page-BtowusUh.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-DF_HV6NP.js → gateway-config-swr-fQKBHBi1.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-C52ghnBK.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-Bx9KCID-.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-BYSKzUMR.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B91CBTzO.js → gateway-startup-retry-Cfwxof4k.js} +1 -1
- package/dist/gateway/static/root/assets/highlight-code-Cz6eeDH5.js +1 -0
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-8ACAVktj.js → highlighted-body-KQOG7T2V-BiAa8HKC.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-Cd1BjYHj.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CVBaWmrV.js → image-generation-api-gBFro48x.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-C5IP3e6d.js → imports-page-BZQpXgjj.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cy16gQST.css +1 -0
- package/dist/gateway/static/root/assets/index-DRyGCING.js +710 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BhU6VYvd.js → keyboard-shortcuts-settings-CYunR34k.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-B_Ac1lly.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DcP1Bdlk.js → local-apps-page-w-J5bY02.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-DvmwiLUx.js → local-session-drafts-iGX_6O0O.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-JogcXC4J.js → locale-store-B7s2Hb35.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-Dnjvvx2i.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-w1EDwgLW.js +1 -0
- package/dist/gateway/static/root/assets/{media-plugins-BnPpcJ2J.js → media-plugins-CIx1koXw.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DISkHmEC.js +1 -0
- package/dist/gateway/static/root/assets/{messages-RzwPiQNL.js → messages-BYq0cPbn.js} +2 -2
- package/dist/gateway/static/root/assets/note-detail-panel-CNkxMTFU.js +5 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-D5GH2wuC.js +1 -0
- package/dist/gateway/static/root/assets/notes-page-DZgKqFBG.js +8 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-DusR2Itk.js +1 -0
- package/dist/gateway/static/root/assets/personal-page-CR5JFkQ9.js +1 -0
- package/dist/gateway/static/root/assets/personal-settings-panel-B7undvlr.js +1 -0
- package/dist/gateway/static/root/assets/phone-model-picker-fWDltRUJ.js +1 -0
- package/dist/gateway/static/root/assets/phone-settings-page-CsOirAiy.js +1 -0
- package/dist/gateway/static/root/assets/plugin-details-dialog-BOBVIB3j.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-FGqN-mQx.js → preview-open-alternatives-CMxjsKSw.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CwnHLfdL.js → product-open-page-CrlyJx5M.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-BD6k5hF9.js → product-preview-content-B-Jhzi7W.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DoYUbtcI.js +7 -0
- package/dist/gateway/static/root/assets/projects-page-xGQd9oAZ.js +1 -0
- package/dist/gateway/static/root/assets/refresh-cw-BRlGaq2w.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BGqSwITi.js → registry-api-BcfoLEna.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Gs0Xkws9.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-CSm5SpnR.js → runtime-tools-api-DesqGCnE.js} +1 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Bwg7U7TR.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-DoVn5jJK.js → schema-form-ByzTNR_C.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-DTxZyMta.js → session-api-DdQnMwkl.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-B2HDomj4.js → session-manager-B_h0jlLb.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-XzK1ftbR.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-D_8Mvnog.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Ce8vVv-9.js → settings-form-section-Brgd8IOV.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DP2w3ejC.js → settings-page-B6Mv02eg.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-header-BWyxJKOG.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-B20AfmFG.js → settings-page-layout-DLHcS-0T.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DSCj5yis.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DV4dKrmG.js → share-preview-page-DF8Of0aZ.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DXNPe4Tl.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-DTdejInH.js → skill-api-CKCDCHLq.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BH0WF6Br.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DFWMVRW4.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-DB-ttubV.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-BJY7c8wb.js +2 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-DIGSC4qF.js → task-result-evidence-B-vt1BgK.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-BaU8frtc.js → tracing-settings-page-Dt51Z_ws.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-BCcOUsqu.js → tunnel-api-Dok3t7Qe.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-lJym5G7F.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-C1X47WVb.js → use-autosave-D4EMIB-V.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-BXdNkITp.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-Bk4DQMTw.js → voice-api-key-field-CO3KuanA.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-D7xsWrdh.js → voice-config-api-BkUlN7GH.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B7_NmTB5.js → work-discovery-overlay-BJRtgQM3.js} +1 -1
- package/dist/gateway/static/root/assets/wrench-DFb4r8bH.js +1 -0
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-CS-_GxHV.js +1 -0
- package/dist/gateway/static/root/browser-setup-test.html +5 -0
- package/dist/gateway/static/root/browser-setup-test.js +7 -0
- package/dist/gateway/static/root/index.html +17 -14
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/browser-setup.js +6 -0
- package/dist/packages/gateway-contract/src/index.js +4 -0
- package/dist/packages/gateway-contract/src/phone-setup.js +6 -0
- package/dist/packages/realtime-client/src/index.js +1 -0
- package/dist/packages/realtime-protocol/src/index.js +1 -0
- package/dist/src/agent/agent-manager.d.ts +4 -0
- package/dist/src/agent/agent-manager.js +12 -1
- package/dist/src/agent/coding/workspace-revision.js +1 -1
- package/dist/src/agent/commands/command-registry.js +1 -1
- package/dist/src/agent/embedded/tool-search-extension.js +14 -1
- package/dist/src/agent/memory/context-recovery.d.ts +1 -1
- package/dist/src/agent/service.d.ts +1 -0
- package/dist/src/agent/service.js +5 -0
- package/dist/src/agent/service.types.d.ts +2 -0
- package/dist/src/agent/skills/installer.js +3 -3
- package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
- package/dist/src/agent/tool-manuals/phone.js +4 -2
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +2 -0
- package/dist/src/agent/tool-manuals/xopc-configuration.js +25 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +2 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +6 -2
- package/dist/src/agent/tools/factory.d.ts +3 -0
- package/dist/src/agent/tools/factory.js +11 -1
- package/dist/src/agent/tools/personal-task-tool.d.ts +1 -1
- package/dist/src/agent/tools/personal-task-tool.js +23 -21
- package/dist/src/agent/tools/phone-use-tool.d.ts +1 -0
- package/dist/src/agent/tools/phone-use-tool.js +29 -1
- package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -1
- package/dist/src/agent/tools/tool-manual-tool.js +3 -1
- package/dist/src/agent/tools/toolExposure.js +3 -0
- package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
- package/dist/src/agent/tools/xopc-use-tool.js +40 -2
- package/dist/src/backup/archive.js +2 -1
- package/dist/src/browser/drivers/browser-driver.d.ts +2 -2
- package/dist/src/browser/drivers/extension-driver.d.ts +2 -2
- package/dist/src/browser/drivers/extension-driver.js +6 -3
- package/dist/src/browser/providers/browser-ext-install.js +3 -2
- package/dist/src/browser/runtime/browser-runtime.d.ts +4 -1
- package/dist/src/browser/runtime/browser-runtime.js +29 -17
- package/dist/src/browser/setup/repository.d.ts +5 -0
- package/dist/src/browser/setup/repository.js +42 -0
- package/dist/src/browser/setup/service.d.ts +152 -0
- package/dist/src/browser/setup/service.js +404 -0
- package/dist/src/browser/setup/types.d.ts +38 -0
- package/dist/src/browser/setup/types.js +1 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +3 -3
- package/dist/src/cli/commands/extension-pack.js +1 -1
- package/dist/src/cli/commands/extension.js +2 -2
- package/dist/src/config/schema.d.ts +2 -0
- package/dist/src/extensions/install.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/browser-setup.d.ts +3 -0
- package/dist/src/gateway/hono/routes/browser-setup.js +114 -0
- package/dist/src/gateway/hono/routes/browser.d.ts +2 -1
- package/dist/src/gateway/hono/routes/browser.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/phone-dependencies.js +1 -1
- package/dist/src/gateway/hono/routes/phone-setup.d.ts +7 -0
- package/dist/src/gateway/hono/routes/phone-setup.js +162 -0
- package/dist/src/gateway/hono/routes/phone.js +11 -7
- package/dist/src/gateway/hono/routes/public-gateway.js +2 -0
- package/dist/src/gateway/provider-model-setup.js +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +2 -0
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/session-input-coordinator.js +1 -1
- package/dist/src/gateway/service.d.ts +5 -0
- package/dist/src/gateway/service.js +52 -7
- package/dist/src/gateway/xopc-cloud-capability-setup.js +7 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/infra/unhandled-rejections.js +2 -2
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/personal-agent/prompts.js +1 -1
- package/dist/src/phone/adb-driver.d.ts +8 -2
- package/dist/src/phone/adb-driver.js +124 -54
- package/dist/src/phone/cloud-adb.js +8 -0
- package/dist/src/phone/cloud-scrcpy.d.ts +3 -1
- package/dist/src/phone/cloud-scrcpy.js +17 -3
- package/dist/src/phone/contracts.d.ts +85 -0
- package/dist/src/phone/contracts.js +31 -5
- package/dist/src/phone/model-adapter.d.ts +141 -2
- package/dist/src/phone/model-adapter.js +176 -24
- package/dist/src/phone/numeric-entry.d.ts +31 -0
- package/dist/src/phone/numeric-entry.js +126 -0
- package/dist/src/phone/planning.d.ts +27 -0
- package/dist/src/phone/planning.js +79 -0
- package/dist/src/phone/recovery.d.ts +37 -0
- package/dist/src/phone/recovery.js +81 -0
- package/dist/src/phone/reliability.d.ts +7 -0
- package/dist/src/phone/reliability.js +66 -0
- package/dist/src/phone/repository.d.ts +1 -0
- package/dist/src/phone/repository.js +3 -0
- package/dist/src/phone/runtime.d.ts +8 -0
- package/dist/src/phone/runtime.js +387 -41
- package/dist/src/phone/scrcpy-text.d.ts +11 -0
- package/dist/src/phone/scrcpy-text.js +72 -0
- package/dist/src/phone/scrcpy.d.ts +5 -1
- package/dist/src/phone/scrcpy.js +48 -3
- package/dist/src/phone/semantic-controls.d.ts +13 -0
- package/dist/src/phone/semantic-controls.js +76 -0
- package/dist/src/phone/setup/service.d.ts +148 -0
- package/dist/src/phone/setup/service.js +251 -0
- package/dist/src/providers/presentation.js +2 -2
- package/dist/src/providers/xopc-cloud-model-source.js +6 -2
- package/dist/src/realtime/runtime.js +1 -1
- package/dist/src/storage/sqlite/connection.js +2 -2
- package/dist/src/storage/sqlite/offline-access.js +13 -7
- package/dist/src/storage/sqlite/schema-errors.d.ts +12 -0
- package/dist/src/storage/sqlite/schema-errors.js +21 -3
- package/dist/src/storage/sqlite/schema-upgrade.d.ts +4 -0
- package/dist/src/storage/sqlite/schema-upgrade.js +78 -0
- package/dist/src/storage/sqlite/schema.d.ts +4 -3
- package/dist/src/storage/sqlite/schema.js +14 -8
- package/dist/src/storage/sqlite/schema.sql +10 -0
- package/dist/src/storage/sqlite/upgrades/203_remove_retired_proactive_contracts.sql +70 -0
- package/dist/src/storage/sqlite/upgrades/204_home_intelligence.sql +78 -0
- package/dist/src/storage/sqlite/upgrades/205_agent_catalog.sql +66 -0
- package/dist/src/storage/sqlite/upgrades/206_home_advice_strategy_version.sql +2 -0
- package/dist/src/storage/sqlite/upgrades/207_user_model_policy_contract.sql +121 -0
- package/dist/src/storage/sqlite/upgrades/208_automation_management.sql +2 -0
- package/dist/src/storage/sqlite/upgrades/209_automation_event_hub.sql +48 -0
- package/dist/src/storage/sqlite/upgrades/210_remove_legacy_automation_timeout.sql +14 -0
- package/dist/src/storage/sqlite/upgrades/211_automation_result_deliveries.sql +16 -0
- package/dist/src/storage/sqlite/upgrades/212_automation_delivery_policy.sql +30 -0
- package/dist/src/storage/sqlite/upgrades/213_automation_reliability_contract.sql +188 -0
- package/dist/src/storage/sqlite/upgrades/214_ai_usage_ledger.sql +41 -0
- package/dist/src/storage/sqlite/upgrades/215_scene_execution_adapters.sql +6 -0
- package/dist/src/storage/sqlite/upgrades/216_remove_scene_model_usage.sql +1 -0
- package/dist/src/storage/sqlite/upgrades/217_remove_legacy_memory_tables.sql +4 -0
- package/dist/src/storage/sqlite/upgrades/218_core_relation_indexes.sql +26 -0
- package/dist/src/storage/sqlite/upgrades/219_json_contracts.sql +123 -0
- package/dist/src/storage/sqlite/upgrades/220_normalize_timestamps.sql +339 -0
- package/dist/src/storage/sqlite/upgrades/221_ai_usage_retention_index.sql +2 -0
- package/dist/src/storage/sqlite/upgrades/222_session_config_authority.sql +13 -0
- package/dist/src/storage/sqlite/upgrades/223_session_creation_receipts.sql +59 -0
- package/dist/src/storage/sqlite/upgrades/224_task_origin_links.sql +8 -0
- package/dist/src/storage/sqlite/upgrades/225_task_collaboration.sql +32 -0
- package/dist/src/storage/sqlite/upgrades/226_task_main_updates.sql +9 -0
- package/dist/src/storage/sqlite/upgrades/227_task_main_update_decisions.sql +8 -0
- package/dist/src/storage/sqlite/upgrades/228_task_main_agent_links.sql +14 -0
- package/dist/src/storage/sqlite/upgrades/229_task_criterion_reviews.sql +12 -0
- package/dist/src/storage/sqlite/upgrades/230_personal_agent_onboarding.sql +8 -0
- package/dist/src/storage/sqlite/upgrades/231_task_result_deliveries.sql +32 -0
- package/dist/src/storage/sqlite/upgrades/232_personal_requests.sql +28 -0
- package/dist/src/storage/sqlite/upgrades/233_observability_usage_links.sql +3 -0
- package/dist/src/storage/sqlite/upgrades/234_task_result_reply.sql +14 -0
- package/dist/src/storage/sqlite/upgrades/235_personal_conversation_priority.sql +3 -0
- package/dist/src/storage/sqlite/upgrades/236_personal_proactivity.sql +53 -0
- package/dist/src/storage/sqlite/upgrades/237_personal_strategy_versions.sql +18 -0
- package/dist/src/storage/sqlite/upgrades/238_browser_record_replay.sql +45 -0
- package/dist/src/storage/sqlite/upgrades/239_clarification_notifications.sql +26 -0
- package/dist/src/storage/sqlite/upgrades/240_device_settings.sql +5 -0
- package/dist/src/storage/sqlite/upgrades/241_device_grant_audit.sql +13 -0
- package/dist/src/storage/sqlite/upgrades/242_cloud_usage_receipts.sql +5 -0
- package/dist/src/storage/sqlite/upgrades/243_voice_opening_greetings.sql +12 -0
- package/dist/src/storage/sqlite/upgrades/244_device_request_proofs.sql +8 -0
- package/dist/src/storage/sqlite/upgrades/245_memory_learning.sql +125 -0
- package/dist/src/storage/sqlite/upgrades/246_personal_session_thinking.sql +22 -0
- package/dist/src/storage/sqlite/upgrades/247_agent_selection_records.sql +32 -0
- package/dist/src/storage/sqlite/upgrades/248_next_turn_suggestions.sql +20 -0
- package/dist/src/storage/sqlite/upgrades/249_task_allocations.sql +17 -0
- package/dist/src/storage/sqlite/upgrades/250_research_checkpoints.sql +15 -0
- package/dist/src/storage/sqlite/upgrades/251_personal_result_reads.sql +40 -0
- package/dist/src/storage/sqlite/upgrades/252_task_work_revisions.sql +15 -0
- package/dist/src/storage/sqlite/upgrades/253_discussion_processing_recovery.sql +20 -0
- package/dist/src/storage/sqlite/upgrades/254_discussion_annotations.sql +17 -0
- package/dist/src/storage/sqlite/upgrades/255_discussion_chapter_progress.sql +10 -0
- package/dist/src/storage/sqlite/upgrades/256_task_main_update_retries.sql +21 -0
- package/dist/src/storage/sqlite/upgrades/257_session_composer_history.sql +11 -0
- package/dist/src/storage/sqlite/upgrades/258_task_phase_changes.sql +20 -0
- package/dist/src/storage/sqlite/upgrades/259_personal_default_style.sql +10 -0
- package/dist/src/storage/sqlite/upgrades/260_browser_setup.sql +9 -0
- package/dist/src/storage/sqlite/windows-database-owners.js +33 -28
- package/dist/src/tasks/capabilities/relations.d.ts +2 -2
- package/dist/src/tui/clipboard-image.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/logger/index.js +1 -1
- package/dist/src/utils/logger.js +1 -1
- package/dist/src/work-discovery/probe.js +1 -1
- package/package.json +3 -3
- package/skills/tools/configure-xopc/SKILL.md +47 -0
- package/skills/tools/configure-xopc/references/browser/acceptance.md +31 -0
- package/skills/tools/configure-xopc/references/browser/chrome-extension.md +19 -0
- package/skills/tools/configure-xopc/references/browser/overview.md +22 -0
- package/skills/tools/configure-xopc/references/browser/permissions.md +25 -0
- package/skills/tools/configure-xopc/references/browser/troubleshooting.md +24 -0
- package/skills/tools/configure-xopc/references/phone/acceptance.md +25 -0
- package/skills/tools/configure-xopc/references/phone/aliyun.md +29 -0
- package/skills/tools/configure-xopc/references/phone/dependencies.md +18 -0
- package/skills/tools/configure-xopc/references/phone/local.md +19 -0
- package/skills/tools/configure-xopc/references/phone/models.md +18 -0
- package/skills/tools/configure-xopc/references/phone/overview.md +30 -0
- package/skills/tools/configure-xopc/references/phone/troubleshooting.md +24 -0
- package/skills/tools/configure-xopc/references/scene-index.md +12 -0
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-mf0jgEPE.js +0 -1
- package/dist/gateway/static/root/assets/agents-CKhZ4UYQ.js +0 -77
- package/dist/gateway/static/root/assets/apps-page-BZ_MaQJf.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-CHUDHNVL.js +0 -8
- package/dist/gateway/static/root/assets/browser-automations-page-DStDm9y1.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-6I4oetKt.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-page-C-EecWbS.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BQoCPk3x.js +0 -8
- package/dist/gateway/static/root/assets/channels-BKf_-Mdt.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CUBg8spT.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-PmP_vGem.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-DMAzNlm-.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-CoIgC1Al.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DnrQ28E2.js +0 -1
- package/dist/gateway/static/root/assets/highlight-code-AMjU04kR.js +0 -1
- package/dist/gateway/static/root/assets/home-page-pTwVME-g.js +0 -2
- package/dist/gateway/static/root/assets/index-BLL0wKRZ.css +0 -1
- package/dist/gateway/static/root/assets/index-ygkHNYyo.js +0 -710
- package/dist/gateway/static/root/assets/local-app-workbench-page-Cwl6EvuX.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CS3hcTOq.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-DC-Y_-GP.js +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-vckgHpON.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-C7u4dxEk.js +0 -5
- package/dist/gateway/static/root/assets/note-image-lightbox-jvqYtySx.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-Bs7F5Hpf.js +0 -8
- package/dist/gateway/static/root/assets/page-context-capture-button-DO_yhXS1.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-BexL2-PQ.js +0 -1
- package/dist/gateway/static/root/assets/personal-settings-panel-BKA4fbYH.js +0 -1
- package/dist/gateway/static/root/assets/phone-dependencies-card-ChFtdFhA.js +0 -1
- package/dist/gateway/static/root/assets/phone-model-picker-CZoIAQ1j.js +0 -1
- package/dist/gateway/static/root/assets/phone-settings-page-DRyK0nHH.js +0 -1
- package/dist/gateway/static/root/assets/plugin-details-dialog-B-N61jJH.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-DtKmFBml.js +0 -7
- package/dist/gateway/static/root/assets/projects-page-CFZIz9mc.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CWEc7W0m.js +0 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-q_oswAdV.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BuPqNxpd.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-QTVDCGJG.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-header-CYpuTXUW.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-ZmlE8jIE.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CtNxWqW-.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Egaf8PqZ.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-C6FKxf4J.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-Baxkhov7.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-C77-rpkt.js +0 -2
- package/dist/gateway/static/root/assets/usage-page-BFeIbpbi.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-u8zY5jea.js +0 -2
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-CJ_akAvc.js +0 -1
|
@@ -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{m as i,u as a}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{n as s,r as c,t as l}from"./popover-select-DGKUpVsz.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./ellipsis-0k4rZLoy.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./eye-CABVeTq0.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./messages-RzwPiQNL.js";import{t as g}from"./cn-0WouolD0.js";import{i as _,l as v,n as y,o as b}from"./locale-store-JogcXC4J.js";import{n as x}from"./copy-to-clipboard-HOJ79TWv.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-aIC072nz.js";import{t as w}from"./skeleton-BI5TyibZ.js";import{n as T,r as E}from"./gateway-config-swr-DF_HV6NP.js";import{n as D}from"./electron-env-Dit0bHgy.js";import{$o as O,Ad as k,B as A,Bc as j,Bn as M,Cs as N,Dl as P,Ds as F,E as I,Ed as L,Es as R,F as z,Fc as ee,Fl as B,Fu as te,G as V,H,Ha as ne,Hl as U,Hn as re,Ic as ie,Jc as ae,K as oe,Lc as W,M as se,N as ce,Qa as G,Qo as le,R as ue,Rc as K,Ss as de,T as fe,Tl as pe,Ts as me,U as q,Ul as J,Un as he,V as ge,Vc as _e,Vn as ve,W as Y,Xo as ye,Yo as be,Zo as xe,_s as Se,aa as Ce,bd as X,bs as we,ca as Te,cd as Ee,cl as De,cs as Oe,dd as ke,ds as Ae,es as je,fs as Me,hs as Ne,il as Pe,io as Fe,is as Ie,jd as Le,jl as Re,jo as Z,ks as ze,ls as Be,ms as Ve,na as He,ns as Ue,nu as We,oa as Ge,os as Ke,qc as qe,rs as Je,sa as Ye,ss as Xe,ts as Ze,ua as Qe,ul as $e,us as et,vo as tt,vs as nt,ws as rt,xd as it,xs as at,ys as ot,zc as st}from"./index-ygkHNYyo.js";import{n as ct,t as lt}from"./capability-header-actions-BasrAWA0.js";import{t as ut}from"./connector-service-page-CxHgC5RM.js";import{t as dt}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),ft=n(),$=r();function pt(e){let t=(0,ft.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,d,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(mt),m=e.slice(0,2),h=Math.max(0,e.length-m.length),_=o.connect,v;t[11]!==n||t[12]!==o?(v=q(n,o),t[11]=n,t[12]=o,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(C,{type:`button`,variant:`secondary`,className:g(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(We,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,p=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(ge,{connector:n}),t[18]=n,t[19]=S);let w;t[20]!==n||t[21]!==a?(w=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=w):w=t[22];let T;t[23]===b?T=t[24]:(T=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=T);let E;t[25]!==T||t[26]!==w?(E=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[w,T]}),t[25]=T,t[26]=w,t[27]=E):E=t[27];let D;t[28]!==E||t[29]!==S?(D=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,E]}),t[28]=E,t[29]=S,t[30]=D):D=t[30];let O;t[31]!==r||t[32]!==s?(O=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=O):O=t[33];let k;t[34]!==r||t[35]!==o.connectedBadge?(k=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(u,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=k):k=t[36];let A;t[37]!==O||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[37]=O,t[38]=k,t[39]=A):A=t[39],t[40]!==D||t[41]!==A?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,A]}),t[40]=D,t[41]=A,t[42]=l):l=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=m.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),h>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,h]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=d,t[9]=f,t[10]=p}else s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],p=t[10];let m;t[45]!==c||t[46]!==l||t[47]!==d||t[48]!==f?(m=(0,$.jsxs)(`div`,{className:c,children:[l,d,f]}),t[45]=c,t[46]=l,t[47]=d,t[48]=f,t[49]=m):m=t[49];let h;t[50]!==r||t[51]!==s?(h=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=h):h=t[52];let _;return t[53]!==p||t[54]!==m||t[55]!==h?(_=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[53]=p,t[54]=m,t[55]=h,t[56]=_):_=t[56],_}function mt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ht=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function gt(e,t){return t.some(t=>t.connectorId===e.id)}var _t=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function vt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:g(`size-10 shrink-0 rounded-xl`,_t)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:g(`h-4 min-w-0 flex-1`,_t)}),(0,$.jsx)(`div`,{className:g(`h-8 w-[4.5rem] shrink-0 rounded-lg`,_t)})]}),(0,$.jsx)(`div`,{className:g(`h-3 w-full`,_t)}),(0,$.jsx)(`div`,{className:g(`h-3 w-[88%]`,_t)})]})]})}),e[1]=n):n=e[1],n}function yt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(w,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(w,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(w,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(w,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(w,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var bt=[`understand`,`act`,`reach`];function xt(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function St(e){return xt(e)[0]??`act`}function Ct(e,t){let n=t?St(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function wt(e,t){return t.connectorCapabilityLabels[e]??e}function Tt(e,t){if(e.runtime.type===`mcp`)return Y(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return Y(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Et(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Dt(e){let t=(0,ft.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=q(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,d,f,p,m,h,_,v,y,b,x,S,w,T,E,D;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=xt(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(At),...(n.setup.config??[]).filter(kt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,C=n.capabilities.filter(Ot);f=ee,_=!0,t[27]===i?v=t[28]:(v=e=>{e||i()},t[27]=i,t[28]=v),d=j,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(st,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=h):h=t[29],l=W,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(p=g(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=p):p=t[30];let O;t[31]===n?O=t[32]:(O=(0,$.jsx)(ge,{connector:n,size:`lg`}),t[31]=n,t[32]=O);let k;t[33]===n.displayName?k=t[34]:(k=(0,$.jsx)(_e,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=k);let A;t[35]!==r||t[36]!==o.connectedBadge?(A=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(u,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=A):A=t[37];let M;t[38]!==k||t[39]!==A?(M=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[k,A]}),t[38]=k,t[39]=A,t[40]=M):M=t[40];let N;t[41]===c?N=t[42]:(N=(0,$.jsx)(K,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=N);let F;t[43]!==M||t[44]!==N?(F=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[M,N]}),t[43]=M,t[44]=N,t[45]=F):F=t[45];let I;t[46]!==O||t[47]!==F?(I=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[O,F]}),t[46]=O,t[47]=F,t[48]=I):I=t[48];let L;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(L=g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ze.focusRingPanel),t[49]=L):L=t[49];let R;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(qe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=R):R=t[50];let z;t[51]===o.modalClose?z=t[52]:(z=(0,$.jsx)(ie,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:L,"aria-label":o.modalClose,children:R})}),t[51]=o.modalClose,t[52]=z),t[53]!==I||t[54]!==z?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[I,z]}),t[53]=I,t[54]=z,t[55]=m):m=t[55],T=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,E=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let B;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(te,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=B):B=t[56];let V;t[57]===o.detailPermissions?V=t[58]:(V=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=V);let H;t[59]!==n||t[60]!==o?(H=Et(n,o),t[59]=n,t[60]=o,t[61]=H):H=t[61];let ne;t[62]===H?ne=t[63]:(ne=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:H}),t[62]=H,t[63]=ne);let U;t[64]!==V||t[65]!==ne?(U=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[B,(0,$.jsxs)(`div`,{children:[V,ne]})]}),t[64]=V,t[65]=ne,t[66]=U):U=t[66];let re;t[67]===o.connectorSetupTitle?re=t[68]:(re=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=re);let ae;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(ae=s.length?Y(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=ae):ae=t[72];let oe;t[73]===ae?oe=t[74]:(oe=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:ae}),t[73]=ae,t[74]=oe);let se;t[75]!==re||t[76]!==oe?(se=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[re,oe]}),t[75]=re,t[76]=oe,t[77]=se):se=t[77],t[78]!==U||t[79]!==se?(D=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[U,se]}),t[78]=U,t[79]=se,t[80]=D):D=t[80],S=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?w=t[82]:(w=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=w),y=`space-y-5 border-t border-edge-subtle px-4 py-4`;let ce;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),t[83]=ce):ce=t[83];let G;t[84]===o.connectorRuntimeTitle?G=t[85]:(G=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[ce,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=G);let le;t[86]!==n||t[87]!==o?(le=Tt(n,o),t[86]=n,t[87]=o,t[88]=le):le=t[88];let ue;t[89]===le?ue=t[90]:(ue=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:le}),t[89]=le,t[90]=ue),t[91]!==G||t[92]!==ue?(b=(0,$.jsxs)(`div`,{children:[G,ue]}),t[91]=G,t[92]=ue,t[93]=b):b=t[93],x=C.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:C.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:wt(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=l,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=w,t[21]=T,t[22]=E,t[23]=D}else l=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],w=t[20],T=t[21],E=t[22],D=t[23];let O;t[94]!==y||t[95]!==b||t[96]!==x?(O=(0,$.jsxs)(`div`,{className:y,children:[b,x]}),t[94]=y,t[95]=b,t[96]=x,t[97]=O):O=t[97];let k;t[98]!==O||t[99]!==S||t[100]!==w?(k=(0,$.jsxs)(`details`,{className:S,children:[w,O]}),t[98]=O,t[99]=S,t[100]=w,t[101]=k):k=t[101];let A;t[102]!==k||t[103]!==T||t[104]!==E||t[105]!==D?(A=(0,$.jsxs)(`div`,{className:T,children:[E,D,k]}),t[102]=k,t[103]=T,t[104]=E,t[105]=D,t[106]=A):A=t[106];let M;t[107]===o.modalClose?M=t[108]:(M=(0,$.jsx)(ie,{asChild:!0,children:(0,$.jsx)(C,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=M);let N;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(N=r?null:(0,$.jsxs)(C,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(We,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=N):N=t[114];let F;t[115]!==M||t[116]!==N?(F=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[M,N]}),t[115]=M,t[116]=N,t[117]=F):F=t[117];let I;t[118]!==l||t[119]!==p||t[120]!==m||t[121]!==A||t[122]!==F?(I=(0,$.jsxs)(l,{className:p,children:[m,A,F]}),t[118]=l,t[119]=p,t[120]=m,t[121]=A,t[122]=F,t[123]=I):I=t[123];let L;t[124]!==d||t[125]!==h||t[126]!==I?(L=(0,$.jsxs)(d,{children:[h,I]}),t[124]=d,t[125]=h,t[126]=I,t[127]=L):L=t[127];let R;return t[128]!==f||t[129]!==_||t[130]!==v||t[131]!==L?(R=(0,$.jsx)(f,{open:_,onOpenChange:v,children:L}),t[128]=f,t[129]=_,t[130]=v,t[131]=L,t[132]=R):R=t[132],R}function Ot(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function kt(e){return e.required}function At(e){return e.required}var jt=(0,Q.memo)(function(e){let t=(0,ft.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:s,addLabel:c,browseLabel:l,customLabel:u,serviceLabel:f,moreActionsLabel:p}=e,[h,_]=(0,Q.useState)(!1),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=g(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,ze.transition),t[0]=v):v=t[0];let y=v,b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(U,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=b):b=t[1];let x;t[2]===c?x=t[3]:(x=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:c}),t[2]=c,t[3]=x);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(o,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=S):S=t[4];let w;t[5]!==c||t[6]!==x?(w=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsxs)(C,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":c,children:[b,x,S]})}),t[5]=c,t[6]=x,t[7]=w):w=t[7];let T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)($e,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=T):T=t[8];let E;t[9]!==l||t[10]!==a?(E=(0,$.jsxs)(Ge,{className:y,onSelect:a,children:[T,l]}),t[9]=l,t[10]=a,t[11]=E):E=t[11];let D;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ae,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=D):D=t[12];let O;t[13]!==u||t[14]!==s?(O=(0,$.jsxs)(Ge,{className:y,onSelect:s,children:[D,u]}),t[13]=u,t[14]=s,t[15]=O):O=t[15];let k;t[16]!==E||t[17]!==O?(k=(0,$.jsx)(Ye,{children:(0,$.jsxs)(Ce,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[E,O]})}),t[16]=E,t[17]=O,t[18]=k):k=t[18];let A;t[19]!==k||t[20]!==w?(A=(0,$.jsxs)(Te,{children:[w,k]}),t[19]=k,t[20]=w,t[21]=A):A=t[21];let j;t[22]===h?j=t[23]:(j=(0,$.jsx)(ut,{open:h,onOpenChange:_,hideTrigger:!0}),t[22]=h,t[23]=j);let M;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[24]=M):M=t[24];let N;t[25]===p?N=t[26]:(N=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(C,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":p,title:p,children:M})}),t[25]=p,t[26]=N);let P;t[27]!==n||t[28]!==i||t[29]!==r?(P=n?(0,$.jsxs)(Ge,{className:y,disabled:r,onSelect:n,children:[r?(0,$.jsx)(m,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=P):P=t[30];let F,I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>_(!0),I=(0,$.jsx)(pe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=F,t[32]=I):(F=t[31],I=t[32]);let L;t[33]===f?L=t[34]:(L=(0,$.jsxs)(Ge,{className:y,onSelect:F,children:[I,f]}),t[33]=f,t[34]=L);let R;t[35]!==P||t[36]!==L?(R=(0,$.jsx)(Ye,{children:(0,$.jsxs)(Ce,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[P,L]})}),t[35]=P,t[36]=L,t[37]=R):R=t[37];let z;t[38]!==N||t[39]!==R?(z=(0,$.jsxs)(Te,{children:[N,R]}),t[38]=N,t[39]=R,t[40]=z):z=t[40];let ee;return t[41]!==A||t[42]!==j||t[43]!==z?(ee=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[A,j,z]}),t[41]=A,t[42]=j,t[43]=z,t[44]=ee):ee=t[44],ee});function Mt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Nt=/^([^:=]+)[:=](.*)$/;function Pt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return It(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Nt.exec(t);r&&n.push(Mt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Ft(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function It(e){if(!e||typeof e!=`object`)return[Mt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Mt(e),reference:t}:Mt(e,t==null?``:String(t)));return t.length>0?t:[Mt()]}function Lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Rt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function zt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function Bt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=Rt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Ft(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=zt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Ft(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Vt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:It(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Ht(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Ut(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Wt(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Vt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Ut(r.url),r})}function Gt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Kt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Lt(e)).map(([e,t])=>Vt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function qt(e){return Bt(e)}async function Jt(e,t){return(await b(_(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Yt(e,t,n,r){return(await b(_(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Bt(e)})})).payload}async function Xt(e,t){return(await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Zt(e){await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Qt(e,t=!1){let n=await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return T(),n.payload}async function $t(e){return(await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function en(e,t){return(await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function tn(e){await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function nn(e,t){await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function rn(e,t){return(await b(_(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function an(e){let t=await b(_(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function on(e){let t=await b(_(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return T(),t.payload}function sn(e){let t=(0,ft.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),b=(0,Q.useRef)(!1),x;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(x=()=>{let e=new AbortController,t=!0;return p(!0),h(``),d([]),(a?rn(a,e.signal):Jt(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=x):x=t[8];let S;t[9]!==a||t[10]!==v||t[11]!==n||t[12]!==o?(S=[n,a,v,o],t[9]=a,t[10]=v,t[11]=n,t[12]=o,t[13]=S):S=t[13],(0,Q.useEffect)(x,S);let w,T,E,D,O,k,A,M,N,P,F,I,L;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));E=ee,k=!0,t[52]===s?A=t[53]:(A=e=>{e||s()},t[52]=s,t[53]=A),T=j,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(st,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=O):O=t[54],w=W,t[55]===i?I=t[56]:(I=e=>{(b.current||i)&&e.preventDefault(),!b.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=I),L=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(_e,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let v;t[66]===h?v=t[67]:(v=(0,$.jsx)(K,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=v);let y;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>_(e.target.value),t[68]=y):y=t[68];let x;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(x=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:g,onChange:y,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=x):x=t[71];let S=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==v||t[74]!==x||t[75]!==S?(D=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,v,x,S]}),t[72]=p,t[73]=v,t[74]=x,t[75]=S,t[76]=D):D=t[76],M=`min-h-0 flex-1 overflow-y-auto p-5`,N=f,t[77]!==o.toolsTitle||t[78]!==u.length?(P=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=P):P=t[79],F=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(ln)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(C,{variant:`secondary`,onClick:()=>{b.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(C,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=w,t[37]=T,t[38]=E,t[39]=D,t[40]=O,t[41]=k,t[42]=A,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I,t[48]=L}else w=t[36],T=t[37],E=t[38],D=t[39],O=t[40],k=t[41],A=t[42],M=t[43],N=t[44],P=t[45],F=t[46],I=t[47],L=t[48];let R;t[80]!==M||t[81]!==N||t[82]!==P||t[83]!==F?(R=(0,$.jsx)(`div`,{className:M,"aria-busy":N,"aria-label":P,children:F}),t[80]=M,t[81]=N,t[82]=P,t[83]=F,t[84]=R):R=t[84];let z;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>y(cn),t[85]=z):z=t[85];let B;t[86]!==f||t[87]!==o.refreshTools?(B=(0,$.jsx)(C,{variant:`secondary`,disabled:f,onClick:z,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=B):B=t[88];let te;t[89]!==s||t[90]!==o.toolsDialogClose?(te=(0,$.jsx)(ie,{asChild:!0,children:(0,$.jsx)(C,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=te):te=t[91];let V;t[92]!==B||t[93]!==te?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[B,te]}),t[92]=B,t[93]=te,t[94]=V):V=t[94];let H;t[95]!==w||t[96]!==D||t[97]!==R||t[98]!==V||t[99]!==I||t[100]!==L?(H=(0,$.jsxs)(w,{onCloseAutoFocus:I,className:L,children:[D,R,V]}),t[95]=w,t[96]=D,t[97]=R,t[98]=V,t[99]=I,t[100]=L,t[101]=H):H=t[101];let ne;t[102]!==T||t[103]!==O||t[104]!==H?(ne=(0,$.jsxs)(T,{children:[O,H]}),t[102]=T,t[103]=O,t[104]=H,t[105]=ne):ne=t[105];let U;return t[106]!==E||t[107]!==k||t[108]!==A||t[109]!==ne?(U=(0,$.jsx)(E,{open:k,onOpenChange:A,children:ne}),t[106]=E,t[107]=k,t[108]=A,t[109]=ne,t[110]=U):U=t[110],U}function cn(e){return e+1}function ln(e){return(0,$.jsx)(w,{className:`h-24 w-full`},e)}function un(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function dn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=y(e=>e.language),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),_=e.displayName||e.id,v=un(e),b=e.extra.enabled===!1,x=b?L:t?u:X,S=e.transport===`stdio`?De:P,w=b?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,T=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(S,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:_,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:T?r.customLastChecked.replace(`{{time}}`,T):void 0,"aria-label":T?`${w} · ${r.customLastChecked.replace(`{{time}}`,T)}`:w,className:g(`inline-flex shrink-0 items-center gap-1`,!b&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),w]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:v,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:v})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(C,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(C,{ref:l,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:b,onClick:()=>c(!0),children:n.viewTools}),(0,$.jsxs)(Te,{children:[(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(C,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,_),title:r.customManage.replace(`{{name}}`,_),children:(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(Ye,{children:(0,$.jsx)(Ce,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(Ge,{onSelect:()=>p(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(Pe,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),m?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:m}):null,s?(0,$.jsx)(sn,{serverId:e.id,displayName:e.displayName,returnFocusTo:l.current,t:n,onClose:()=>c(!1),onConfigure:()=>{c(!1),i()}}):null,(0,$.jsx)(He,{open:f,title:r.removeConfirmTitle.replace(`{{name}}`,_),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>p(!1),onConfirm:()=>{p(!1),h(``),a().catch(()=>h(n.setupRemoveFailed))}})]})}function fn(e){let t=(0,ft.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a.customIntegrationsHint?f=t[8]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),t[12]=m):m=t[12];let h;t[13]!==a.customAdd||t[14]!==o?(h=(0,$.jsxs)(C,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[m,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=h):h=t[15];let g;t[16]!==p||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(_=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(dn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=_):_=t[25];let v;return t[26]!==a.customIntegrationsTitle||t[27]!==g||t[28]!==_?(v=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[g,_]}),t[26]=a.customIntegrationsTitle,t[27]=g,t[28]=_,t[29]=v):v=t[29],v}function pn(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function mn(e){let t=(0,ft.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,l=n.installationState===`preparing`,d=n.activationEligible===!1,f=n.authorizationStatus===`required`,p;t[4]!==d||t[5]!==n.readiness||t[6]!==f||t[7]!==l||t[8]!==c?(p=l?c(`准备未完成`,`Setup incomplete`):d?c(`已停用`,`Disabled`):f?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=d,t[5]=n.readiness,t[6]=f,t[7]=l,t[8]=c,t[9]=p):p=t[9];let m=p,h;t[10]!==d||t[11]!==f||t[12]!==l||t[13]!==c?(h=l?c(`继续安装`,`Continue setup`):!d&&f?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=d,t[11]=f,t[12]=l,t[13]=c,t[14]=h):h=t[14];let _=h,v;t[15]===n.setup?.authorizations?v=t[16]:(v=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=v);let y=v,b=y.length===1?y[0].title:n.name,x=l||!d&&(f||n.readiness===`blocked`||n.readiness===`degraded`),S=l?X:d?L:x?k:u,C=x&&`border-amber-500/25`,w;t[17]===C?w=t[18]:(w=g(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,C),t[17]=C,t[18]=w);let T=n.branding?.iconUrl,E;t[19]===T?E=t[20]:(E=(0,$.jsx)(z,{iconUrl:T,fallback:J,className:`size-9`}),t[19]=T,t[20]=E);let D;t[21]===b?D=t[22]:(D=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:b,children:b}),t[21]=b,t[22]=D);let O=x?`text-amber-700 dark:text-amber-300`:d?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,A;t[23]===O?A=t[24]:(A=g(`mt-1 inline-flex items-center gap-1 text-[11px]`,O),t[23]=O,t[24]=A);let j;t[25]===S?j=t[26]:(j=(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t[25]=S,t[26]=j);let M;t[27]!==m||t[28]!==A||t[29]!==j?(M=(0,$.jsxs)(`span`,{className:A,children:[j,m]}),t[27]=m,t[28]=A,t[29]=j,t[30]=M):M=t[30];let N;t[31]!==D||t[32]!==M?(N=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[D,M]}),t[31]=D,t[32]=M,t[33]=N):N=t[33];let P;t[34]!==N||t[35]!==E?(P=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[E,N]}),t[34]=N,t[35]=E,t[36]=P):P=t[36];let F=n.name,I;t[37]===c?I=t[38]:(I=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=I);let R;t[39]!==n.name||t[40]!==I?(R=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:F,children:[I,` · `,n.name]}),t[39]=n.name,t[40]=I,t[41]=R):R=t[41];let ee=x?`text-accent-fg`:`text-fg-muted`,B;t[42]===ee?B=t[43]:(B=g(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,ee),t[42]=ee,t[43]=B);let te;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(Le,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=te):te=t[44];let V;t[45]!==_||t[46]!==B?(V=(0,$.jsxs)(`span`,{className:B,children:[_,te]}),t[45]=_,t[46]=B,t[47]=V):V=t[47];let H;return t[48]!==i||t[49]!==P||t[50]!==R||t[51]!==V||t[52]!==w?(H=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:w,children:[P,R,V]}),t[48]=i,t[49]=P,t[50]=R,t[51]=V,t[52]=w,t[53]=H):H=t[53],H}function hn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function gn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?hn(t)-hn(e):e.isCurrentAuthorization?-1:1}function _n(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(gn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>gn(e.primary,t.primary))}var vn=g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Z);function yn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function bn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function xn(e,t,n){return e.status===`connected`?Y(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function Sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function Cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function wn({instance:e,t,onChanged:n}){let r=yn(e),i=y(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[l,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)([]),[h,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)([]),[x,S]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(null),[O,A]=(0,Q.useState)([]),[j,M]=(0,Q.useState)({}),[P,I]=(0,Q.useState)(`read`),[L,z]=(0,Q.useState)(!1),[ee,V]=(0,Q.useState)(null),[ne,U]=(0,Q.useState)(!1),[re,ie]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(null),[W,se]=(0,Q.useState)(!1),[ce,G]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(!1),K=(0,Q.useRef)(0),fe=(0,Q.useRef)(0),pe=(0,Q.useMemo)(()=>_n(a),[a]),q=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),J=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;z(!0),V(null);let t=++K.current;try{let e=(await Promise.allSettled([q(Oe()).then(e=>{t===K.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),se(!0))}),q(Ie(r)).then(e=>{t===K.current&&I(e)}),q(Je(r)).then(e=>{t===K.current&&(_(e.policy),b(e.agents))})])).find(e=>e.status===`rejected`);t===K.current&&e?.status===`rejected`&&V(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===K.current&&z(!1)}},[e.materialized,r,q]);(0,Q.useEffect)(()=>(J(),()=>{K.current++}),[J]);let he=(0,Q.useCallback)(async()=>{if(!r)return;let e=++fe.current;ue(!0),U(!1);let t=t=>n=>{e===fe.current&&t(n)},n=await Promise.allSettled([q(Be(r)).then(t(d)),q(et(20)).then(t(e=>p(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),q(Ke(r)).then(t(E)),q(Ue(r)).then(t(S))]);e===fe.current&&(U(n.some(e=>e.status===`rejected`)),ue(!1))},[r,q]);(0,Q.useEffect)(()=>(ce&&he(),()=>{fe.current++}),[ce,he]),(0,Q.useEffect)(()=>{let e=!1,t=_n(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return q(Ae()).then(t=>{e||A(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await q(Xe(e.accountId))])).then(t=>{e||M(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,q]);let ge=(0,Q.useCallback)(async i=>{if(!r)return;let a=D()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),z(!0),V(null);try{if(!D()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await ot(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(D()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await F(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),J()])}catch(e){V(H(e,t))}finally{a?.close(),z(!1)}},[e.connectorId,J,n,t,r]),_e=(0,Q.useCallback)(async t=>{z(!0),V(null);try{await me(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),J()])}catch(e){V(e instanceof Error?e.message:String(e))}finally{z(!1)}},[e.config,e.instanceId,J,n]),ve=async e=>{let t=D()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),V(null);try{let n=await Ze(e.id);if(n.authorizationUrl)if(D())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await J()}catch(e){t?.close(),V(e instanceof Error?e.message:String(e))}},ye=(0,Q.useCallback)(async e=>{if(r){I(e),V(null);try{await Se(r,e)}catch(e){V(e instanceof Error?e.message:String(e)),await J()}}},[J,r]),xe=(0,Q.useCallback)(async e=>{if(r){V(null);try{_(await rt(r,e))}catch(e){V(e instanceof Error?e.message:String(e))}}},[r]),Ce=(0,Q.useCallback)(e=>{if(!h)return;let t=h.allowedAgentIds.includes(e);t&&h.allowedAgentIds.length===1||xe({allowedAgentIds:t?h.allowedAgentIds.filter(t=>t!==e):[...h.allowedAgentIds,e]})},[xe,h]),X=(0,Q.useCallback)(async e=>{z(!0),V(null);try{await e(),await J()}catch(e){V(e instanceof Error?e.message:String(e))}finally{z(!1)}},[J]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let we=pe.filter(e=>e.primary.status===`active`).length,Te=we>0?t.composioAddAccount:t.composioConnectAccount,Ee=W&&we>0,De=T?.requiresCustomAuthConfig===!0,ke=T?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:g(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ee?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ee?(0,$.jsx)(u,{className:`size-3.5`}):(0,$.jsx)(k,{className:`size-3.5`}),Ee?t.connectionReady:W||ee?t.connectionNeedsSetup:t.connectionChecking]}),W&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:Y(t.composioAccountCount,{count:String(pe.length)})})]}),(0,$.jsxs)(C,{variant:`primary`,className:`shrink-0`,disabled:L,onClick:()=>void ge(),children:[L?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(te,{className:`size-4`}),Te]})]}),ee?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:ee}),(0,$.jsx)(C,{variant:`secondary`,disabled:L,onClick:()=>void J(),children:t.composioRetry})]}):null,x&&!Ee?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:xn(x,we,t)}),x.recovery===`none`?null:(0,$.jsx)(C,{variant:`secondary`,disabled:L,onClick:()=>void(x.recovery===`retry`?J():ge()),children:x.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,De&&ke.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,h?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:P===`read`?t.composioAccessReadHint:P===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(s,{value:P,onChange:e=>void ye(e.currentTarget.value),children:[(0,$.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),P===`admin`?(0,$.jsx)(c,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(s,{value:h.confirmationPolicy,onChange:e=>void xe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),h.confirmationPolicy===`never`?(0,$.jsx)(c,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void xe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),v.map(e=>(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Ce(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:h.selectedAccountIds===null,disabled:L,onChange:e=>void xe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),h.selectedAccountIds!==null&&pe.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:L,checked:h.selectedAccountIds.includes(e.accountId),onChange:t=>void xe({selectedAccountIds:t.currentTarget.checked?[...h.selectedAccountIds,e.accountId]:h.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),h.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),W&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y(t.composioAccountCount,{count:String(pe.length)})})]}),(0,$.jsxs)(C,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:L,onClick:()=>void J(),children:[(0,$.jsx)(B,{className:g(`size-3.5`,L&&`animate-spin`)}),t.refresh]})]}),pe.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:pe.map(e=>{let r=e.primary,a=O.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?j[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:g(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:Sn(r.status,t)}),a?(0,$.jsx)(`p`,{className:g(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:Y(t.connectorLearningStatus,{status:Cn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(C,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void ve(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(C,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:L,onClick:()=>oe(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(C,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:L,onClick:()=>void ge(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(C,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:L,onClick:()=>void X(()=>de(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(C,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:L,onClick:()=>void X(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await nt(r.accountId),await n?.()}),children:[(0,$.jsx)(B,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:L,checked:r.allowedAgentIds==null,onChange:e=>void X(()=>de(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&v.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:L,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;X(()=>de(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:L,onChange:e=>void X(()=>R(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(s,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:L,onChange:e=>void X(()=>R(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:g(vn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&X(()=>N(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(C,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:L,onClick:()=>ie(e.id),children:(0,$.jsx)(Pe,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(C,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:L,onClick:()=>void X(()=>Me(r.id)),children:(0,$.jsx)(B,{className:`size-4`})})})]})]})]},e.key)})}):L&&!W?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(w,{className:`h-16 w-full`}),(0,$.jsx)(w,{className:`h-16 w-full`})]}):W?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>G(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[le?(0,$.jsx)(w,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,ne?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(C,{variant:`ghost`,disabled:le,onClick:()=>void he(),children:t.composioRetry})]}):null,T?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:De?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(s,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:L,onChange:e=>void _e(e.currentTarget.value),children:[De?null:(0,$.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),De&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,ke.map(e=>(0,$.jsxs)(c,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:l.length?l.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[bn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:f.length?f.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(He,{open:ae!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=ae;oe(null),e&&X(()=>be(e))},onCancel:()=>oe(null)}),(0,$.jsx)(He,{open:re!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=re;ie(null),e&&X(()=>Ne(e))},onCancel:()=>ie(null)})]})}var Tn=g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Z);function En(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Dn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function On({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(()=>En(t,e)),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),E=t?.setup.config??[],D=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&E.length>0&&(t?.setup.secrets??[]).length===0,O=e.materialized.type===`mcp`,k=e.materialized.type===`composio`,A=e.materialized.type===`memorySource`,M=t?q(t,i):null,N=(0,Q.useCallback)(async()=>{S(!0),b(null);try{let t=await at(e.instanceId);T(t),t.ok||b(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{S(!1)}},[e.instanceId,r,i.healthStatusLabels]),P=(0,Q.useCallback)(async()=>{o(!0),b(null);try{await Ve(e.instanceId),await r(),n()}catch(e){b(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),F=(0,Q.useCallback)(async()=>{if(!(!t||!D)){u(!0),b(null);try{let n={};for(let e of t.setup.config??[]){let t=Dn(e.type,_[e.key]??``);t!==void 0&&(n[e.key]=t)}await me(e.instanceId,{config:n}),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[_,t,e.instanceId,r,D]),I=(0,Q.useCallback)(async()=>{f(!0),h(null),b(null);try{h((await we(e.connectorId)).recordIds.length),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e.connectorId,r]);return(0,$.jsxs)(ee,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(j,{children:[(0,$.jsx)(st,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(W,{className:g(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,k?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(ge,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(_e,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(K,{className:`mt-1 text-sm text-fg-muted`,children:M??(e.materialized.type===`mcp`?Y(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Y(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(ie,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ze.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(qe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[y?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:y}):null,O?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:w?.ok?Y(i.toolsAvailable,{count:String(w.toolCount)}):w?i.healthStatusLabels[w.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(C,{variant:`secondary`,"aria-busy":x,disabled:x||!e.enabled,onClick:()=>void N(),children:[x?(0,$.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),D?E.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>v(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,k?(0,$.jsx)(wn,{instance:e,t:i,onChanged:r}):null,A?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),M?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:M}):null,p===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:Y(i.connectedSourceSynced,{count:String(p)})})]}),(0,$.jsxs)(C,{disabled:d,onClick:()=>void I(),children:[d?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(ke,{className:`size-4`}),i.composioSyncNow]})]}),D?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:E.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>v(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!O&&!k&&!A?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(C,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(Pe,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(C,{variant:`secondary`,onClick:n,children:i.modalClose}),(O||A)&&D?(0,$.jsxs)(C,{variant:`primary`,disabled:l,onClick:()=>void F(),children:[l?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(Re,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(He,{open:s,title:Y(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),P()},onCancel:()=>{a||c(!1)}})]})}function kn(e){let t=(0,ft.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(V,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(On,{...e}),t[0]=e,t[1]=n),n}function An(e){let t=(0,ft.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=Ct(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,d;t[3]!==r||t[4]!==o?(d=r?q(r,o):null,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f=d,p,m,h,_,v,y,b,x,S;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){p=l===`ready`?{label:o.connectionReady,Icon:u,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:k,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:X,className:`text-fg-muted`},S=`button`;let e=l===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(m=g(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,ze.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=m):m=t[25],t[26]!==n||t[27]!==a?(h=()=>a(n),t[26]=n,t[27]=a,t[28]=h):h=t[28],b=`flex w-full min-w-0 items-start gap-3`,t[29]===r?x=t[30]:(x=(0,$.jsx)(ge,{connector:r,size:`sm`}),t[29]=r,t[30]=x),v=`min-w-0 flex-1`,t[31]===n.displayName?y=t[32]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=y),_=g(`mt-1 inline-flex items-center gap-1 text-[11px]`,p.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=p,t[15]=m,t[16]=h,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else p=t[14],m=t[15],h=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[33]===p.Icon?C=t[34]:(C=(0,$.jsx)(p.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=p.Icon,t[34]=C);let w;t[35]!==p.label||t[36]!==C||t[37]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,p.label]}),t[35]=p.label,t[36]=C,t[37]=_,t[38]=w):w=t[38];let T;t[39]!==w||t[40]!==v||t[41]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[39]=w,t[40]=v,t[41]=y,t[42]=T):T=t[42];let E;t[43]!==T||t[44]!==b||t[45]!==x?(E=(0,$.jsxs)(`div`,{className:b,children:[x,T]}),t[43]=T,t[44]=b,t[45]=x,t[46]=E):E=t[46];let D;t[47]===f?D=t[48]:(D=f?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:f,children:f}):null,t[47]=f,t[48]=D);let O;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Le,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=O):O=t[49];let A;t[50]===o.installedDetails?A=t[51]:(A=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,O]}),t[50]=o.installedDetails,t[51]=A);let j;return t[52]!==m||t[53]!==h||t[54]!==E||t[55]!==D||t[56]!==A||t[57]!==S?(j=(0,$.jsxs)(`button`,{type:S,className:m,onClick:h,children:[E,D,A]}),t[52]=m,t[53]=h,t[54]=E,t[55]=D,t[56]=A,t[57]=S,t[58]=j):j=t[58],j}function jn(e,t){return Gt()}function Mn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Mt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Nn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Mt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Mt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Pn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function Fn(){return g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Z)}function In({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:m=`Show value`,hideValueLabel:h=`Hide value`,allowPaste:_=!0}){let[v,y]=(0,Q.useState)(new Set),[b,S]=(0,Q.useState)(!1),w=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},T=()=>{d([...u,Mt()])},E=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Mt()])},D=async()=>{try{let e=await x();if(!e){S(!0);return}let t=Pt(e);if(!t?.length){S(!0);return}d(t)}catch{S(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),_?(0,$.jsxs)(C,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void D(),children:[(0,$.jsx)(it,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:g(Fn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>w(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:g(Fn(),`min-w-0 font-mono text-xs`),type:v.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>w(t,{value:e.target.value})}),(0,$.jsx)(C,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":v.has(e.clientKey)?h:m,onClick:()=>y(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:v.has(e.clientKey)?(0,$.jsx)(Ee,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>E(t),"aria-label":r,children:(0,$.jsx)(Pe,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:f}):null]},e.clientKey))}),(0,$.jsx)(He,{open:b,title:o,description:a,confirmLabel:s,onConfirm:()=>S(!1),onCancel:()=>S(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:g(`self-start text-sm text-accent hover:underline`,ze.press),onClick:T,children:[`+ `,n]})]})}var Ln=g(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Z);function Rn(e){let t=(0,ft.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=g(Ln,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let m;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(m=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=m):m=t[7];let h;t[8]!==i||t[9]!==m?(h=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,m]}),t[8]=i,t[9]=m,t[10]=h):h=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>l(zn),t[11]=_):_=t[11];let v;t[12]===c?v=t[13]:(v=c?(0,$.jsx)(Ee,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=v);let y=c?a.setupHideValue:a.setupShowValue,b;t[14]!==v||t[15]!==y?(b=(0,$.jsxs)(C,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:_,children:[v,y]}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;return t[17]!==b||t[18]!==h?(x=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[h,b]}),t[17]=b,t[18]=h,t[19]=x):x=t[19],x}function zn(e){return!e}function Bn(e){let t=(0,ft.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(In,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Vn(e){let t=(0,ft.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,l=i.setupAuthLabel,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=g(Ln,`mt-1.5`),t[0]=u):u=t[0];let d=n.mode,f;t[1]===r?f=t[2]:(f=e=>r({mode:e.target.value}),t[1]=r,t[2]=f);let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=p):p=t[3];let m;t[4]===i.setupAuthModes?m=t[5]:(m=p.map(e=>(0,$.jsx)(c,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=m);let h;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(h=a||n.mode===`existing`?(0,$.jsx)(c,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=h):h=t[9];let _;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==f||t[13]!==m||t[14]!==h?(_=(0,$.jsxs)(s,{"aria-label":l,className:u,value:d,onChange:f,children:[m,h]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=f,t[13]=m,t[14]=h,t[15]=_):_=t[15];let v;t[16]!==i.setupAuthLabel||t[17]!==_?(v=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,_]}),t[16]=i.setupAuthLabel,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(y=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=y):y=t[21];let b;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(b=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=b):b=t[24];let x;t[25]!==n.mode||t[26]!==i.setupExistingHint?(x=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=x):x=t[27];let S;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(S=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rn,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=S):S=t[32];let C;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(C=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:g(Ln,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(Rn,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=C):C=t[38];let w;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(w=n.mode===`headers`?(0,$.jsx)(Bn,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=w):w=t[43];let T;return t[44]!==v||t[45]!==y||t[46]!==b||t[47]!==x||t[48]!==S||t[49]!==C||t[50]!==w?(T=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[v,y,b,x,S,C,w]}),t[44]=v,t[45]=y,t[46]=b,t[47]=x,t[48]=S,t[49]=C,t[50]=w,t[51]=T):T=t[51],T}function Hn(e){let t=(0,ft.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Un({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>It(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Rt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(C,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Hn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Ln,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Ln,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(C,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(Pe,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(C,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(U,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Bn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Ft(e)??{})})}})]})}function Wn(e){let t=(0,ft.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:l}=e,u=a===void 0?`all`:a,d=o===void 0?!1:o,f=l===void 0?!1:l,p=u!==`advanced`,m=u!==`basic`,h;t[0]!==p||t[1]!==i||t[2]!==n||t[3]!==r?(h=p?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Ln,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Un,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Hn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Ln,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Hn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=p,t[1]=i,t[2]=n,t[3]=r,t[4]=h):h=t[4];let g;t[5]!==m||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==d||t[10]!==r?(g=m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Ln,readOnly:f,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Hn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Ln,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&d?(0,$.jsx)(Hn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Hn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(s,{"aria-label":r.exposureLabel,className:Ln,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(c,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Hn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(dt,{allowEmpty:!0,type:`number`,min:1,className:Ln,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=m,t[6]=f,t[7]=i,t[8]=n,t[9]=d,t[10]=r,t[11]=g):g=t[11];let _;return t[12]!==h||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14],_}function Gn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Kn(e,t){return JSON.stringify({id:e.id,config:qt(Nn(e,t))})}function qn(e,t){try{return Kn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Jn(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[o,l]=(0,Q.useState)(()=>Mn(e.initialRow)),[d,p]=(0,Q.useState)(`idle`),[h,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(),[S,w]=(0,Q.useState)(),[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)([]),[R,z]=(0,Q.useState)(`0`),[B,te]=(0,Q.useState)(0),[V,H]=(0,Q.useState)(``),[U,re]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)(!1),oe=e.mode===`edit`,[se,ce]=(0,Q.useState)(``),G=(0,Q.useRef)(void 0),[le]=(0,Q.useState)(()=>qn(e.initialRow,Mn(e.initialRow))),ue=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),de=(0,Q.useRef)(void 0),fe=(0,Q.useRef)(void 0),pe=(0,Q.useRef)(void 0),me=(0,Q.useRef)(null),q=(0,Q.useRef)(``),J=(0,Q.useRef)(!0),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),Y=(0,Q.useRef)(null),ye=(0,Q.useRef)(e.onSaved);ye.current=e.onSaved;let be=T?.state===`starting`||T?.state===`authorizing`,xe=d!==`idle`||be,Se=le!==qn(i,o),Ce=i.extra.enabled===!1,X=!v&&(Se||!!M.trim());(0,Q.useEffect)(()=>(J.current=!0,()=>{J.current=!1,de.current?.abort(),me.current?.close(),G.current&&Zt(G.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!X)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[X]),(0,Q.useEffect)(()=>{if(!b)return;let e=ve.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??Y.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!T||!be)return;let e=new AbortController;fe.current=e;let n;async function r(){try{let n=await en(G.current,e.signal);if(e.signal.aborted||(E(n),n.authorizationUrl&&q.current!==n.authorizationUrl&&(q.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&_(t.oauthOpenFailed):me.current&&!me.current.closed&&me.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){pe.current=void 0,me.current?.close(),w({state:`connected`,toolCount:n.toolCount}),_(``);return}if(n.state===`error`||n.state===`cancelled`){pe.current=void 0,me.current?.close(),_(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&O(!0);return}}catch{if(e.signal.aborted)return;we(),me.current?.close(),_(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[T?.id,be,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function we(){de.current?.abort(),fe.current?.abort(),G.current&&Zt(G.current).catch(()=>{}),G.current=void 0,ce(``),re(!1),w(void 0),E(void 0),_(``),x(void 0)}function Te(e){a(t=>({...t,...e})),we()}function Ee(e){l(t=>({...t,...e})),we()}function De(){d===`saving`||be||(d===`checking`&&(we(),p(`idle`)),X?ae(!0):e.onClose())}function Oe(){try{L(Wt(M)),z(`0`),F(``)}catch{F(t.setupImportError),L([])}}function ke(){let t=I[Number(R)];if(!t)return;let n={...t,id:ue.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...ue.current?{enabled:i.extra.enabled}:{}}};a(n),l(Mn(n)),we(),te(e=>e+1),A(!1),N(``),L([])}function Ae(e){function n(e,t){return x({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Ut(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(o.mode===`bearer`&&!o.token.trim().replace(/^Bearer\s*/i,``)||o.mode===`apiKey`&&(!o.apiKey.trim()||!o.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Pn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(o.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(o.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{qt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function je(){_(``),p(`checking`),q.current=``,window.electronAPI?.shell?.openExternalUrl||(me.current=window.open(`about:blank`,`_blank`),me.current&&(me.current.opener=null));try{let e=await $t(G.current);if(!J.current){me.current?.close(),G.current&&Zt(G.current).catch(()=>{});return}pe.current=e.id,E(e)}catch{me.current?.close(),J.current&&_(t.setupAuthFailed)}finally{J.current&&p(`idle`)}}async function Me(){let r=Nn(i,o);if(!Ae(r))return;let s=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==ue.current),c=new Set([...e.managedServerIds,...s.map(e=>e.id)]);if(r.id=ue.current||r.id.trim()||Ht(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){x({field:`advanced`,message:n.duplicateServerId});return}we(),p(`checking`);let l=new AbortController;de.current=l;try{let n=await Yt(r,ue.current||void 0,e.initialRow.extra,l.signal);if(!J.current||l.signal.aborted){Zt(n.id).catch(()=>{});return}G.current=n.id,a(r),ce(qn(r,o));let i=await Xt(n.id,l.signal);if(!J.current||l.signal.aborted)return;w(i),i.state===`error`&&_(Gn(i,t))}catch(e){J.current&&!l.signal.aborted&&_(e.status===409?t.setupConflict:Gn(e,t))}finally{J.current&&de.current===l&&p(`idle`)}}async function Ne(n=!1){if(!(!G.current||S?.state!==`connected`||se!==qn(i,o))){p(`saving`),_(``);try{let t=await Qt(G.current,n);G.current=void 0,await ye.current().catch(()=>{}),t?.reloadRequired?y(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(we(),_(t.setupConflict)):_(t.setupSaveFailed)}finally{J.current&&p(`idle`)}}}async function Pe(){fe.current?.abort();let e=G.current;pe.current=void 0,E(void 0),me.current?.close(),_(t.setupCancelled),p(`checking`);try{e&&await tn(e)}catch{J.current&&(we(),_(t.setupCancelled))}finally{J.current&&p(`idle`)}}async function Fe(){T?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(T.authorizationUrl)).ok||_(t.oauthOpenFailed):window.open(T.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Ie(){if(T)try{await nn(G.current,V),H(``),_(``)}catch{_(t.setupRedirectInvalid)}}let Le=!!G.current&&se===qn(i,o)&&(o.mode===`oauth`||o.mode===`auto`&&S?.state===`oauth_required`)&&S?.state!==`connected`,Re=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),Z=I[Number(R)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ee,{open:e.open,onOpenChange:e=>{e||De()},children:(0,$.jsxs)(j,{children:[(0,$.jsx)(st,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(W,{ref:he,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),he.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(_e,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(K,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:d===`saving`||be,onClick:De,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(qe,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[k?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(C,{variant:`ghost`,onClick:()=>A(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:g(Ln,`mt-1.5 min-h-40 font-mono text-xs`),value:M,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{N(e.target.value),L([]),F(``)}})]}),(0,$.jsx)(C,{variant:`secondary`,disabled:!M.trim(),onClick:Oe,children:t.setupImportPreview}),P?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:P}):null,Z?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(s,{"aria-label":t.setupImportChoose,className:g(Ln,`mt-1.5`),value:R,onChange:e=>z(e.target.value),children:I.map((e,t)=>(0,$.jsx)(c,{value:String(t),children:e.displayName||e.id||un(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Z.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,un(Z)]})]}):null]}):(0,$.jsxs)(`form`,{ref:ve,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Ut(i.url)}catch{x({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Me()},children:[(0,$.jsxs)(`fieldset`,{disabled:xe||v,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(ne,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(C,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>Te({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(C,{type:`button`,variant:`ghost`,onClick:()=>A(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Wn,{row:i,t,variant:`basic`,onUpdate:Te},`${i.transport}-${B}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Vn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:o,onChange:Ee,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:Y,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:D,onToggle:e=>O(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Wn,{row:i,t,variant:`advanced`,idReadOnly:oe,showOAuth:o.mode===`oauth`,onUpdate:Te}),i.transport===`streamable-http`&&o.mode!==`headers`&&o.mode!==`existing`?(0,$.jsx)(Bn,{additional:!0,headers:o.additionalHeaders,onChange:e=>Ee({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Re?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),v?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!k&&!v?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[d===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(m,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),d===`saving`?t.setupSaving:t.setupChecking]}),d===`idle`&&oe&&!Se&&!S&&!h&&!be?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Ce?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,S?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(u,{className:`size-4 shrink-0`,"aria-hidden":!0}),S.toolCount?t.setupConnected.replace(`{{count}}`,String(S.toolCount)):t.setupZeroTools]}),(0,$.jsx)(C,{ref:ge,variant:`secondary`,onClick:()=>re(!0),children:t.viewTools})]}):null,S?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,S?.state===`oauth_required`&&!be?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,be?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(m,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T?.authorizationUrl?(0,$.jsxs)(C,{variant:`secondary`,onClick:()=>void Fe(),children:[(0,$.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(C,{variant:`ghost`,onClick:()=>void Pe(),children:t.setupCancelAuth})]}),T?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Ln,value:V,onChange:e=>H(e.target.value)})]}),(0,$.jsx)(C,{className:`mt-2`,disabled:!V.trim(),onClick:()=>void Ie(),children:t.setupContinue})]}):null]}):null,h?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:h}),h!==t.setupSaveFailed&&d!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(C,{variant:`secondary`,disabled:d===`saving`||be,onClick:De,children:oe||v?t.setupClose:n.modalCancel}),v?null:k?(0,$.jsx)(C,{variant:`primary`,disabled:!Z,onClick:ke,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(C,{variant:S?.state===`connected`?`secondary`:`primary`,disabled:xe,onClick:()=>Le?void je():void Me(),children:Le?t.setupSignIn:t.setupTestConnection}),S?.state===`connected`&&se===qn(i,o)?(0,$.jsxs)($.Fragment,{children:[Ce?(0,$.jsx)(C,{variant:`secondary`,disabled:xe,onClick:()=>void Ne(!0),children:t.setupEnableSave}):null,(0,$.jsx)(C,{variant:`primary`,disabled:xe,"aria-busy":xe,onClick:()=>void Ne(),children:oe?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(He,{open:ie,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>ae(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),U?(0,$.jsx)(sn,{draftId:G.current,serverId:i.id,displayName:i.displayName,returnFocusTo:ge.current,t,onClose:()=>re(!1)}):null]})}var Yn=`recommended`,Xn=`builtin`,Zn=`composio`,Qn=`xopc-store`;function $n(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Yn:Xn}function er(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function tr(e){return ce(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function nr(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function rr({embedded:e=!1,onHeaderActionChange:t}){let n=G().filter(pn),r=y(e=>e.language),o=h(r),s=o.connectorsSettings,c=o.mcpSettings,u=v(e=>e.conversationId),d=!!u,f=a(),[p,_]=i(),b=p.get(`understanding`)===`1`,x=nr(p.get(`returnTo`)),w=!!p.get(`returnTo`)&&!b,T=p.get(`tab`),[D,k]=(0,Q.useState)(!b&&T===`connected`?`connected`:`discover`),{data:j}=S(d&&D===`discover`&&!b?[`service-recommendations`,r]:null,()=>I(r),{revalidateOnFocus:!1}),N=(0,Q.useMemo)(()=>new Set(j?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>se(e.id))??[]),[j]),P=(0,Q.useRef)(!1),[F,L]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[R,z]=(0,Q.useState)(!1),[ee,B]=(0,Q.useState)(!1),[te,V]=(0,Q.useState)(1),[H,U]=(0,Q.useState)(void 0),[ie,ae]=(0,Q.useState)(``),[W,ce]=(0,Q.useState)(b||w?p.get(`connector`)??``:``),[K,de]=(0,Q.useState)($n(b?`understanding`:`default`,r)),[pe,me]=(0,Q.useState)(`name`),[q,J]=(0,Q.useState)(b?`understand`:`all`),[ge,_e]=(0,Q.useState)(null),[Y,be]=(0,Q.useState)(null),[Se,Ce]=(0,Q.useState)(null),[X,we]=(0,Q.useState)(null),[Te,Ee]=(0,Q.useState)(null),[De,Oe]=(0,Q.useState)(null),{data:ke,mutate:Ae}=E(d),Me=ke?.payload?.config,Ne=(0,Q.useMemo)(()=>Me===void 0?null:Kt(Me),[Me]),Pe=Ne?.servers??[],Ie=F.instances.length+Pe.length+n.length,[Le,Re]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Re({}),!d||!Me)return;let e=new AbortController;return an(e.signal).then(t=>{e.signal.aborted||Re(t)}).catch(()=>{}),()=>e.abort()},[d,Me]);let Z=(0,Q.useCallback)(async()=>{if(!u){L({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}L(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([xe(),le()]);L(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){L({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[u]);(0,Q.useEffect)(()=>{Z()},[Z]),(0,Q.useEffect)(()=>{P.current||F.loading||d&&!Ne||(k(b?`discover`:Ie>0?`connected`:`discover`),P.current=!0)},[d,Ie,Ne,b,F.loading]),(0,Q.useEffect)(()=>{de(e=>e===`builtin`||e===`recommended`?$n(b?`understanding`:`default`,r):e)},[r,b]);let ze=(0,Q.useCallback)(e=>{P.current=!0,k(e)},[]),Be=(0,Q.useMemo)(()=>[{id:Zn,displayName:s.composioSourceName},{id:Qn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),Ve=(0,Q.useCallback)(async e=>{if(!d||K===`builtin`||K===`recommended`){L(e=>({...e,registryCatalog:[]})),V(1),U(void 0);return}let t=W.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=K===`all`?Be:Be.filter(e=>e.id===K);if(a.length!==0){z(!0),i?L(e=>({...e,error:null})):(V(1),U(void 0),L(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await ye({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await O({q:t||void 0,page:n,pageSize:24,sort:pe===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=er(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=tr(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));V(n),U(s),L(e=>({...e,registryCatalog:i?tr([...e.registryCatalog,...o]):o}))}catch(e){L(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{z(!1)}}},[pe,W,K,d,Be,r]);(0,Q.useEffect)(()=>{if(D!==`discover`||F.loading)return;if(K===`builtin`||K===`recommended`){L(e=>({...e,registryCatalog:[]})),V(1),U(void 0);return}let e=window.setTimeout(()=>{Ve()},W.trim()?350:0);return()=>window.clearTimeout(e)},[W,K,Ve,F.loading,D]);let He=(0,Q.useMemo)(()=>new Set(F.instances.map(e=>e.connectorId)),[F.instances]),Ue=(0,Q.useMemo)(()=>new Map([...F.catalog,...F.registryCatalog].map(e=>[e.id,e])),[F.catalog,F.registryCatalog]);(0,Q.useEffect)(()=>{if(F.loading)return;let e=p.get(`connector`),t=p.get(`instance`);if(!e&&!t)return;let n=F.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)P.current=!0,ae(``),Ce(n.instanceId),we(n),k(`connected`);else if(e){let t=Ue.get(e);if(!t)return;P.current=!0,de($n(b?`understanding`:`default`,r)),ce(``),be(t),k(`discover`)}let i=new URLSearchParams(p);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),_(i,{replace:!0})},[Ue,b,r,p,_,F.instances,F.loading]);let We=(0,Q.useCallback)(async e=>{B(!0),L(e=>({...e,error:null}));try{let t=await je(e);_e(oe(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){L(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{B(!1)}},[]);(0,Q.useEffect)(()=>{let e=p.get(`storeConnector`);if(!d||!e)return;let t=new URLSearchParams(p);t.delete(`storeConnector`),_(t,{replace:!0}),We(e)},[d,p,_,We]);let Ge=(0,Q.useMemo)(()=>new Set(F.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[F.instances]),Ke=(0,Q.useCallback)(async e=>{let t=await on(e);await Ae(),await Z(),t.reloadRequired&&L(e=>({...e,error:c.setupReloadRequired}))},[Z,Ae,c.setupReloadRequired]),qe=(0,Q.useCallback)(()=>{Oe({mode:`add`,row:jn(Pe,Ge)})},[Pe,Ge]),Je=Fe(e=>e.setPageHeader),Ye=Fe(e=>e.clearPageHeader),Xe=(0,Q.useMemo)(()=>({searchLabel:D===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(ct,{value:D===`connected`?ie:W,onChange:D===`connected`?ae:ce,placeholder:D===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(jt,{onRefresh:D===`connected`&&d?Z:void 0,refreshing:F.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>ze(`discover`),onAddCustomServer:qe,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[ie,s,W,d,r,Z,o.capabilitiesHub.moreActions,qe,ze,F.loading,D]);(0,Q.useLayoutEffect)(()=>e?(t?.(Xe),()=>t?.(null)):(Je({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:s.title})}),end:(0,$.jsx)(lt,{contribution:Xe})}),()=>Ye()),[Ye,s.title,e,Xe,t,Je]);let Ze=(0,Q.useMemo)(()=>F.instances.map(e=>({instance:e,value:Ct(e,Ue.get(e.connectorId))})),[Ue,F.instances]),Qe=(0,Q.useMemo)(()=>new Map(Ze.map(({instance:e,value:t})=>[e.instanceId,t])),[Ze]),$e=(0,Q.useMemo)(()=>F.instances.filter(e=>re(e,ie)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Qe.get(e.instanceId)?.state??`checking`,i=Qe.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[ie,Qe,F.instances]),et=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state===`needs_setup`),[Qe,$e]),nt=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state!==`needs_setup`),[Qe,$e]),rt=(0,Q.useMemo)(()=>Pe.filter(e=>M(e,ie)),[ie,Pe]),it=(0,Q.useMemo)(()=>{let e=ie.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[ie,n]),at=$e.length+rt.length+it.length,ot=(0,Q.useMemo)(()=>F.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&he(e)),[F.catalog]),st=(0,Q.useMemo)(()=>K===`recommended`?[]:K===`builtin`?ot:K===`all`?tr([...ot,...F.registryCatalog]):F.registryCatalog,[ot,K,F.registryCatalog]),ut=(0,Q.useMemo)(()=>{let e=b?st.filter(e=>e.understanding?.mode===`activity`):tr(st).filter(e=>!N.has(se(e.id)));return ve(q===`all`?e:e.filter(e=>xt(e).includes(q)),W,pe)},[pe,W,st,b,q,N]),dt=(0,Q.useMemo)(()=>bt.filter(e=>st.some(t=>xt(t).includes(e))),[st]);(0,Q.useEffect)(()=>{q!==`all`&&!dt.includes(q)&&J(`all`)},[dt,q]);let ft=D===`discover`&&K!==`builtin`&&!!(H&&te<H),mt=(0,Q.useMemo)(()=>F.instances.find(e=>e.instanceId===Se)??X,[Se,X,F.instances]),_t=(0,Q.useMemo)(()=>[{value:Yn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:s.discoverSourceAll},{value:Xn,label:s.discoverSourceBuiltin},...Be.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,Be,r]),St=[{id:`connected`,label:s.tabConnected,count:Ie},{id:`discover`,label:s.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:g(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[d?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),b?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(C,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>f(x),children:s.understandingSetupDone})]}):null,w?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(C,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>f(x),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(tt,{items:St,activeTab:D,onChange:ze,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),F.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:F.error}):null,D===`connected`&&d?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:F.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ht.slice(0,3).map(e=>(0,$.jsx)(yt,{},e))}):Ie===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(C,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>ze(`discover`),children:s.addFromCatalog})]}):at===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[et.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:et.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:et.map(e=>(0,$.jsx)(An,{instance:e,definition:Ue.get(e.connectorId),highlighted:e.instanceId===Te,onOpenDetails:e=>{Ee(null),Ce(e.instanceId),we(e)},t:s},e.instanceId))})]}):null,nt.length||it.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[nt.map(e=>(0,$.jsx)(An,{instance:e,definition:Ue.get(e.connectorId),highlighted:e.instanceId===Te,onOpenDetails:e=>{Ee(null),Ce(e.instanceId),we(e)},t:s},e.instanceId)),it.map(e=>(0,$.jsx)(mn,{extension:e,language:r,onOpen:()=>f(ue(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,rt.length||!ie.trim()?(0,$.jsx)(fn,{servers:rt,lastChecks:Le,t:c,cs:s,onAdd:qe,onEdit:e=>Oe({mode:`edit`,row:structuredClone(e)}),onRemove:Ke}):null]})}):null,D===`discover`&&d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b?null:(0,$.jsx)(ne,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...dt].map(e=>(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,q===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":q===e,onClick:()=>J(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:g(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,b?`grid-cols-1`:`grid-cols-2`),children:[b?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:K,options:_t,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:de})}),K===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:pe,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>me(e)})})]})]}),K===`recommended`?(0,$.jsx)(fe,{layout:`cards`,initialCount:6,query:W,onChanged:async()=>{await Z(),await Ae()}}):(F.loading||R)&&ut.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ht.map(e=>(0,$.jsx)(vt,{},e))}):ut.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[R?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":s.loading,children:(0,$.jsx)(m,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:ut.map(e=>(0,$.jsx)(pt,{connector:e,installed:He.has(e.id)||gt(e,F.instances),onInstall:e=>{if(e.source===`store`){We(e.id);return}_e(oe(e))},onOpenDetails:e.source===`store`?void 0:be,t:s},e.id))}),ft?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(C,{type:`button`,variant:`secondary`,disabled:R||ee,onClick:()=>void Ve({page:te+1,append:!0}),children:[R?(0,$.jsx)(m,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),ge?(0,$.jsx)(A,{draft:ge,onChange:_e,onClose:()=>_e(null),t:s,onInstalled:async e=>{await Z(),await Ae(),Ee(e.instanceId),ze(`connected`)}}):null,Y?(0,$.jsx)(Dt,{connector:Y,installed:He.has(Y.id)||gt(Y,F.instances),onClose:()=>be(null),onInstall:e=>_e(oe(e)),t:s}):null,mt?(0,$.jsx)(kn,{instance:mt,definition:Ue.get(mt.connectorId),onClose:()=>{Ce(null),we(null)},onChanged:Z,t:s,mcp:c}):null,De?(0,$.jsx)(Jn,{open:!0,mode:De.mode,initialRow:De.row,lastCheck:De.mode===`edit`?Le[De.row.id]:void 0,existingCustomServers:Pe,config:Me,managedServerIds:Ge,t:c,cs:s,onClose:()=>Oe(null),onSaved:async()=>{await Ae(),await Z(),ze(`connected`)}},`${De.mode}-${De.row.clientKey}`):null]})})}export{rr as ConnectorsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{u as a}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./messages-RzwPiQNL.js";import{t as u}from"./cn-0WouolD0.js";import{n as d}from"./locale-store-JogcXC4J.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./button-aIC072nz.js";import{t as m}from"./skeleton-BI5TyibZ.js";import{i as h,o as g}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{$l as _,At as v,Bc as y,Fc as b,Ii as x,L as S,Lc as C,Nc as w,Nt as T,Nu as E,Rc as D,Vc as O,bd as k,f as A,jd as j,jt as M,m as N,p as P,qc as ee,ro as te,yl as ne,zc as re}from"./index-ygkHNYyo.js";import{_ as ie,a as ae,d as F,f as oe,g as se,h as ce,i as I,l as L,m as le,n as R,p as ue,r as z,s as B,t as de,u as V,v as fe}from"./tunnel-api-BCcOUsqu.js";var H=e(n(),1),U=r(),W=e(S(),1),G={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function pe(e){let t=await W.toString(e,{...G,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var K=i();function me(){let e=l(d(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=f(`tunnel-status`,R,{refreshInterval:1500}),[o,s]=(0,H.useState)(!1),[u,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!0),[y,b]=(0,H.useState)(`idle`),[x,S]=(0,H.useState)(null),[C,E]=(0,H.useState)(``),D=(0,H.useRef)(!0);(0,H.useEffect)(()=>(D.current=!0,()=>{D.current=!1}),[]);let O=async()=>{if(!r)return;if(r.consentRequired&&!o){h(!0);return}let e=r.registrationSecret?.configured?null:N(),t,n=!1;S(null);try{if(r.consentRequired&&await ae(),!r.registrationSecret?.configured){b(`provisioning`);let r=!1;try{await I()}catch(e){if(!V(e))throw e;r=!0}if(r){b(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await T(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;D.current&&Date.now()<o;){let r=await M(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await P(a,e)||E(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!D.current)return;if(!s)throw Error(`Authorization expired`);await I()}await a()}if(!D.current)return;b(`starting`),await B(),g&&await z({autoStart:!0}),await a(),n=!0}catch(e){n=!0,D.current&&S(L(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{A(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&v(t).catch(()=>{})),D.current&&(b(`idle`),E(``))}};if(!r&&!i)return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(m,{className:`h-5 w-4/5`}),(0,K.jsx)(m,{className:`h-24 w-full`})]});let k=y===`provisioning`||y===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,K.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,K.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:k?t.preparingHint:y===`authorizing`?t.authorizing:t.enableHint}),C&&y===`authorizing`?(0,K.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,k?(0,K.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,K.jsx)(m,{className:`h-2 w-full`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(u||r?.consentRequired)&&y===`idle`?(0,K.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,K.jsxs)(`details`,{open:u,className:`text-sm text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,K.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,K.jsx)(`li`,{children:e},e))})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,x===`key-limit`?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,K.jsxs)(p,{variant:`secondary`,className:`mt-3`,onClick:()=>void w(de),children:[t.manageTunnelKeys,(0,K.jsx)(c,{className:`size-3`})]})]}):x||i||r?.state===`error`?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:g,disabled:y!==`idle`,onChange:e=>_(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,K.jsx)(p,{className:`w-full`,variant:`primary`,disabled:!r||y!==`idle`||k||u&&!o,onClick:()=>void O(),children:y===`authorizing`?t.authorizing:k?t.preparing:x?t.retry:t.enable}),i&&!r?(0,K.jsx)(p,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var q=t({DevicePairingWizard:()=>J});function J(e){let t=(0,U.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,H.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,H.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,K.jsx)(ge,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,K.jsx)(X,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,K.jsx)(b,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Y(e){let t=(0,U.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,K.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,K.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,K.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,K.jsxs)(`span`,{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]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(j,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,K.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function X(e){let t=(0,U.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=d(he),o;t[0]===a?o=t[1]:(o=l(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,K.jsx)(re,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,g)}),t[2]=c):c=t[2];let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=u(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,h),t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=p):p=t[4];let m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,K.jsx)(ee,{className:`size-4`}),t[5]=m):m=t[5];let v;t[6]!==s.cancel||t[7]!==i?(v=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[p,(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:m})]}),t[6]=s.cancel,t[7]=i,t[8]=v):v=t[8];let b;t[9]===s.chooseTitle?b=t[10]:(b=(0,K.jsx)(O,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=b);let x;t[11]===s.chooseHint?x=t[12]:(x=(0,K.jsx)(D,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=x);let S;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(S=(0,K.jsx)(Y,{icon:E,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=S):S=t[16];let w;t[17]===n?w=t[18]:(w=()=>n(`mobile`),t[17]=n,t[18]=w);let T;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==w?(T=(0,K.jsx)(Y,{icon:ne,title:s.mobileTitle,hint:s.mobileHint,onClick:w}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=w,t[22]=T):T=t[22];let k;t[23]===n?k=t[24]:(k=()=>n(`browser`),t[23]=n,t[24]=k);let A;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==k?(A=(0,K.jsx)(Y,{icon:_,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:k}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==T||t[30]!==A||t[31]!==S?(j=(0,K.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[S,T,A]}),t[29]=T,t[30]=A,t[31]=S,t[32]=j):j=t[32];let M;t[33]!==j||t[34]!==b||t[35]!==x?(M=(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[b,x,j]}),t[33]=j,t[34]=b,t[35]=x,t[36]=M):M=t[36];let N;return t[37]!==M||t[38]!==v?(N=(0,K.jsxs)(y,{children:[c,(0,K.jsxs)(C,{className:f,children:[v,M]})]}),t[37]=M,t[38]=v,t[39]=N):N=t[39],N}function he(e){return e.language}function ge({targetKind:e,onClose:t,onPaired:n}){let r=d(e=>e.language),i=l(r),a=i.endpointToolsSettings.deviceAccess,_=a.flow,[v,b]=(0,H.useState)(!1),S=f(v?`device-pairing-readiness`:null,ce,{refreshInterval:1500}),[T,E]=(0,H.useState)(),[A,M]=(0,H.useState)(null),[N,P]=(0,H.useState)(!1),[ne,ae]=(0,H.useState)(Date.now()),[I,L]=(0,H.useState)(null),R=(0,H.useRef)(!0),z=(0,H.useRef)(null),B=(0,H.useRef)(!1),de=(0,H.useRef)(!1),V=f(T?[`device-pairing-setup`,T.id]:null,()=>se(T.id),{refreshInterval:1500}),U=V.data?.request,W=U?.status===`completed`,G=W&&U.connectedAt!==void 0,q=f(G&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),J=T?.targetKind===`mobile`?T.universalLink:``,Y=te(()=>pe(J),[J],{enabled:!!J,initial:null,errorData:null}),X=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,he=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,ge=te(()=>pe(X),[X],{enabled:!v&&e===`mobile`,initial:null,errorData:null});(0,H.useEffect)(()=>{R.current=!0;let e=setInterval(()=>ae(Date.now()),1e3);return()=>{R.current=!1,clearInterval(e),z.current&&F(z.current).catch(()=>{})}},[]);let Z=(0,H.useCallback)(async()=>{if(!B.current){B.current=!0,P(!0),M(null);try{z.current&&await F(z.current),z.current=null,E(void 0);let t=await oe(e);if(t.kind===`ready`){if(!R.current){await F(t.setup.id);return}z.current=t.setup.id,E(t.setup)}else await S.mutate()}catch{R.current&&M(`create`)}finally{B.current=!1,R.current&&P(!1)}}},[S,e]);(0,H.useEffect)(()=>{S.data?.ready&&!T&&A!==`create`&&!B.current&&Z()},[S.data,T,A,Z]),(0,H.useEffect)(()=>{G&&!de.current&&(de.current=!0,n?.())},[G,n]);let _e=async e=>{if(U){P(!0),M(null);try{await ue(U,e),await V.mutate()}catch{M(`decision`),await V.mutate()}finally{R.current&&P(!1)}}},ve=(0,H.useRef)(0);(0,H.useEffect)(()=>{V.data&&(ve.current=V.data.serverTime-Date.now())},[V.data]);let Q=ne+ve.current,ye=T&&Q>=T.expiresAt&&!U,be=U&&[`expired`,`rejected`,`cancelled`].includes(U.status),xe=T?T.expiresAt-Q<6e4:!1,Se=T?xe?`${Math.max(0,Math.ceil((T.expiresAt-Q)/1e3))}s`:_.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=v?G?$.success:U?.status===`pending`?$.allowTitle:W||U?.status===`approved`?_.waiting:T?$.connect:_.title:Ce,Ee=A===`create`?_.createFailed:A===`decision`?_.decisionFailed:A===`background`?_.backgroundFailed:A===`download`?a.browserDownloadFailed:null,De=async()=>{P(!0),M(null);try{await le()}catch{M(`download`)}finally{R.current&&P(!1)}};return(0,K.jsxs)(y,{children:[(0,K.jsx)(re,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,g)}),(0,K.jsxs)(C,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,h),children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":_.cancel,onClick:t,children:(0,K.jsx)(ee,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[G?(0,K.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,K.jsx)(O,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,K.jsx)(D,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:v?G?$.successHint:W?_.waitingForDevice:U?U.displayName:T?$.connectHint:_.intro:we}),Ee?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,v&&S.error?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:_.readinessFailed}):null,v&&V.error?(0,K.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:_.statusUnavailable}):null,v?S.data?G?(0,K.jsxs)(K.Fragment,{children:[q.data?(0,K.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,K.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":q.data.runInBackground??!1,disabled:!q.data.backgroundSupported,checked:q.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>q.mutate(e.behavior)).catch(()=>M(`background`))}})]}):null,(0,K.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,K.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||U?.status===`expired`?_.expired:_.declined}),(0,K.jsx)(p,{variant:`primary`,onClick:()=>void Z(),disabled:N,children:_.refresh})]}):U?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:_.scope}),(0,K.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[U.confirmationCode.slice(0,3),` `,U.confirmationCode.slice(3)]}),(0,K.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:_.compare}),(0,K.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:_.access}),(0,K.jsx)(`p`,{children:_.accessHint})]})]}):T?.targetKind===`mobile`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,K.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,K.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Y.data?(0,K.jsx)(`img`,{src:Y.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Y.error?null:(0,K.jsx)(m,{className:`size-[240px] rounded-xl`})})}),Y.error?null:(0,K.jsxs)(`p`,{className:u(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,K.jsx)(k,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),Y.error?(0,K.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:_.qrFailed}):null,Y.error?(0,K.jsx)(`div`,{className:`mt-5`,children:(0,K.jsx)(x,{text:T.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,K.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(`span`,{children:_.fallback}),(0,K.jsx)(j,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,K.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,K.jsx)(x,{text:T.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):T?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(x,{text:T.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:T.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((T.expiresAt-Q)/1e3))}s`:_.valid})]}):S.data.ready?(0,K.jsx)(`div`,{className:`mt-8`,children:(0,K.jsx)(m,{className:`mx-auto size-[216px]`})}):(0,K.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[I===`tailscale`?(0,K.jsx)(fe,{embedded:!0}):I===`https`?(0,K.jsx)(ie,{}):I===`choices`?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(p,{variant:`secondary`,className:`w-full`,onClick:()=>L(`tailscale`),children:a.useTailscale}),(0,K.jsx)(p,{variant:`secondary`,className:`w-full`,onClick:()=>L(`https`),children:a.useOwnHttps})]}):(0,K.jsx)(me,{}),(0,K.jsx)(p,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>L(I?null:`choices`),children:I?_.back:_.existing})]}):(0,K.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,K.jsx)(m,{className:`h-5 w-3/4`}),(0,K.jsx)(m,{className:`h-40 w-full`})]}):e===`mobile`?(0,K.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[ge.data?(0,K.jsx)(`img`,{src:ge.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,K.jsx)(m,{className:`size-36`}),(0,K.jsxs)(p,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void w(X),children:[(0,K.jsx)(c,{className:`size-4`}),a.mobileDownload]}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,K.jsxs)(`div`,{className:`mt-7`,children:[(0,K.jsxs)(p,{variant:`secondary`,className:`w-full`,disabled:N,onClick:()=>void De(),children:[(0,K.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,K.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void w(he),children:[a.browserInstallHelp,(0,K.jsx)(c,{className:`size-3`})]})]})]}),!v||S.error||G||U?.status===`pending`||A===`create`||A===`decision`?(0,K.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:v?G?(0,K.jsx)(p,{className:`w-full`,variant:`primary`,onClick:t,children:_.done}):U?.status===`pending`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(p,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void _e(`approve`),children:_.allow}),(0,K.jsx)(p,{className:`w-full`,variant:`ghost`,disabled:N,onClick:()=>void _e(`reject`),children:_.cancel})]}):S.error?(0,K.jsx)(p,{className:`w-full`,variant:`primary`,onClick:()=>void S.mutate(),children:_.retry}):(0,K.jsx)(p,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void Z(),children:_.retry}):(0,K.jsx)(p,{className:`w-full`,variant:`primary`,onClick:()=>{M(null),b(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{q as n,J as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./locale-store-JogcXC4J.js";import{a as t,d as n,f as r,g as i,i as a,l as o,p as s,r as c,s as l,t as u,u as d,v as f}from"./schemas-CObaziC7.js";import{t as p}from"./gateway-realtime-store-CoIgC1Al.js";var ee={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`fileId`,`name`,`mimeType`,`size`,`sha256`],properties:{type:{const:`file`},fileId:{type:`string`,minLength:1,maxLength:160},name:{type:`string`,minLength:1,maxLength:255},mimeType:{type:`string`,minLength:1,maxLength:255},size:{type:`integer`,minimum:0},sha256:{type:`string`,pattern:`^[a-f0-9]{64}$`}}}},te={type:`object`,properties:{},additionalProperties:!1},m=d({purpose:u([`weather`,`nearby`]),precision:u([`approximate`,`precise`]),category:u([`restaurant`,`cafe`,`pharmacy`,`park`]).optional()}).strict().superRefine((e,t)=>{e.purpose===`nearby`!=(e.category!==void 0)&&t.addIssue({code:`custom`,message:`Category is required only for nearby queries`})}),h={type:`object`,additionalProperties:!1,required:[`purpose`,`precision`],properties:{purpose:{enum:[`weather`,`nearby`]},precision:{enum:[`approximate`,`precise`]},category:{enum:[`restaurant`,`cafe`,`pharmacy`,`park`]}},allOf:[{if:{properties:{purpose:{const:`nearby`}},required:[`purpose`]},then:{properties:{category:{}},required:[`category`]},else:{not:{properties:{category:{}},required:[`category`]}}}]};d({latitude:o().min(-90).max(90),longitude:o().min(-180).max(180),accuracyMeters:o().min(0).max(1e5),capturedAt:o().int().nonnegative(),precision:u([`approximate`,`precise`]),coordinateSystem:l(`WGS84`)}).strict();var g={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`latitude`,`longitude`,`accuracyMeters`,`capturedAt`,`precision`,`coordinateSystem`],properties:{latitude:{type:`number`,minimum:-90,maximum:90},longitude:{type:`number`,minimum:-180,maximum:180},accuracyMeters:{type:`number`,minimum:0,maximum:1e5},capturedAt:{type:`integer`,minimum:0},precision:{enum:[`approximate`,`precise`]},coordinateSystem:{const:`WGS84`}}}}}};function ne(e){return{name:`${e}.device.get_location`,title:`Use location once`,description:`With on-device consent, use one fresh WGS84 location for current weather (Open-Meteo) or nearby places (OpenStreetMap). Raw coordinates are consumed transiently by Gateway, never returned to the Agent or saved in history. Select approximate or precise; nearby requires a category. Each call requires new consent.`,inputSchema:h,outputSchema:g,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`location-read-once`],timeoutMs:9e4,maxConcurrency:1,supportsCancellation:!0,idempotent:!0,resultKinds:[`json`]}}var re=25*1024*1024,_=u([`web`,`desktop`,`mobile`,`browser`]),v=u([`foreground`,`background`]),ie=u([`read`,`write`,`destructive`]),y=u([`never`,`always`]),ae=u([`text`,`json`,`file`]),oe=u([`public`,`personal`]),b=s().min(1).max(160),se=s().min(32).max(160).regex(/^[A-Za-z0-9_-]+$/);t(`type`,[r({type:l(`endpoint`),endpointId:b}),r({type:l(`channel`),channel:s().min(1).max(64)}),r({type:l(`system`),source:u([`cli`,`automation`,`heartbeat`,`task`,`internal`,`task_update`])})]).options[0].extend({token:se});var ce=f(),x=o().int().nonnegative(),S=n(s(),i()),C=r({name:s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120),title:s().min(1).max(120),description:s().min(1).max(2e3),inputSchema:S,outputSchema:S,policyId:s().regex(/^[a-z][a-z0-9_.-]+$/).max(120),sensitivity:oe,effect:ie,confirmation:y,requiresForeground:a(),requiredPermissions:c(s().min(1).max(120)).max(20),timeoutMs:o().int().min(1e3).max(3e5),maxConcurrency:o().int().min(1).max(4),supportsCancellation:a(),idempotent:a(),resultKinds:c(ae).min(1).max(3)});r({principalId:b,displayName:s().min(1).max(120),kind:_,platform:s().min(1).max(80),publicKey:s().min(32).max(2048)}),r({endpointId:b});var w=s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120);r({jobId:f(),endpointId:b,capability:w,input:S,idempotencyKey:b,consentGrantId:b,createdAt:x,expiresAt:x}),r({jobId:f(),status:u([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),updatedAt:x,output:S.optional(),error:r({code:b,message:s().min(1).max(2e3)}).optional()}),r({eventId:f(),endpointId:b,subscriptionId:b,eventType:w,data:S,occurredAt:x});var le=r({principalId:b,endpointId:b,connectionInstanceId:f(),displayName:s().min(1).max(120),kind:_,platform:s().min(1).max(80),appVersion:s().min(1).max(80),availability:v,nonce:b,signedAt:x,signature:s().min(16).max(1024),tools:c(C).max(100)}),ue=r({invocationId:f(),toolCallId:b,toolName:C.shape.name,arguments:S,descriptorRevision:s().min(1).max(128),confirmationRequired:a(),deadlineAt:x,uploadGrant:r({path:s().startsWith(`/`).max(500),token:b,maxBytes:o().int().positive(),maxFiles:o().int().min(1).max(20),expiresAt:x}).optional()}),de=r({invocationId:f(),reason:s().min(1).max(500)}),T=r({invocationId:f()}),E=t(`type`,[r({type:l(`text`),text:s().max(256*1024)}),r({type:l(`json`),value:i()}),r({type:l(`file`),fileId:b,name:s().min(1).max(255),mimeType:s().min(1).max(255),size:o().int().nonnegative(),sha256:s().regex(/^[a-f0-9]{64}$/)})]),fe=u([`ENDPOINT_OFFLINE`,`ENDPOINT_NOT_FOREGROUND`,`ENDPOINT_DISCONNECTED`,`TOOL_NOT_FOUND`,`TOOL_REVISION_MISMATCH`,`INVALID_ARGUMENTS`,`PERMISSION_DENIED`,`USER_DENIED`,`TOOL_BUSY`,`TOOL_TIMEOUT`,`TOOL_CANCELLED`,`RESULT_TOO_LARGE`,`PROTOCOL_ERROR`]),D=(e,t)=>r({protocolVersion:l(2),messageId:ce,type:l(e),sentAt:x,payload:t}),O=t(`type`,[D(`endpoint.availability_changed`,r({availability:v})),D(`tool.received`,T),D(`tool.progress`,r({invocationId:f(),message:s().max(500).optional(),percent:o().min(0).max(100).optional()})),D(`tool.result`,r({invocationId:f(),content:c(E).min(1).max(20),details:S.optional()})),D(`tool.error`,r({invocationId:f(),code:fe,message:s().min(1).max(2e3)})),D(`tool.cancelled`,T)]),k=t(`type`,[D(`tool.invoke`,ue),D(`tool.cancel`,de)]),A={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`text`],properties:{type:{const:`text`},text:{type:`string`,maxLength:256*1024}}}};function j(e){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Canonical JSON only supports finite numbers`);return JSON.stringify(e)}if(typeof e!=`object`)throw Error(`Canonical JSON does not support ${typeof e}`);if(Array.isArray(e))return`[${e.map(j).join(`,`)}]`;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error(`Canonical JSON only supports plain objects`);let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${j(n[e])}`).join(`,`)}}`}function M(e){let{signature:t,...n}=e;return j(n)}var N={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`capturedAt`,`platform`,`systemVersion`,`locale`,`timezone`],properties:{capturedAt:{type:`integer`,minimum:0},platform:{type:`string`,minLength:1,maxLength:40},systemVersion:{type:`string`,maxLength:80},locale:{type:`string`,maxLength:80},timezone:{type:`string`,maxLength:80},online:{type:`boolean`}}}}}},P={type:`array`,minItems:1,maxItems:1,items:{type:`object`,additionalProperties:!1,required:[`type`,`value`],properties:{type:{const:`json`},value:{type:`object`,additionalProperties:!1,required:[`capturedAt`,`levelPercent`,`charging`],properties:{capturedAt:{type:`integer`,minimum:0},levelPercent:{type:[`number`,`null`],minimum:0,maximum:100},charging:{type:[`boolean`,`null`]}}}}}};function F(e,t){return{name:`${e}.device.get_${t}`,title:t===`power`?`Read this device’s battery`:`Read this device’s environment`,description:t===`power`?`Read a fresh battery sample from the device that sent this user message. Unknown readings are null.`:`Read bounded platform, system version, language and timezone from the device that sent this user message. No files, page content, network addresses or identifiers are collected.`,inputSchema:te,outputSchema:t===`power`?P:N,policyId:`public.background-read`,sensitivity:`public`,effect:`read`,confirmation:`never`,requiresForeground:!1,requiredPermissions:[],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!0,idempotent:!0,resultKinds:[`json`]}}var I=256*1024,L=15e3,R=45e3,z=[`realtime.capability-negotiation.v1`],B=u([`web`,`desktop`,`mobile`,`browser_extension`,`tui`,`mcp`]),V=s().min(1).max(512),pe=s().regex(/^[a-z][a-z0-9_.-]*$/).max(160),me=f(),he=o().int().nonnegative(),H=o().int().positive(),U=s().min(1).max(160),W=(e,t)=>d({protocolVersion:l(2),messageId:me,kind:l(e),sentAt:he,payload:t}),G=d({topic:V,afterSeq:o().int().nonnegative().optional(),view:l(`compact`).optional()});t(`kind`,[W(`realtime.hello`,d({ticket:s().min(32).max(512),clientId:s().min(1).max(160),clientKind:B,subscriptions:c(G).max(100).default([]),capabilities:c(U).max(64).optional(),endpoint:le.optional()})),W(`realtime.subscribe`,d({subscriptions:c(G).min(1).max(100)})),W(`realtime.unsubscribe`,d({topics:c(V).min(1).max(100)})),W(`realtime.ping`,d({})),W(`endpoint.message`,O)]);var ge=d({topic:V,seq:H,event:pe,data:i()}),_e=t(`kind`,[W(`realtime.ready`,d({connectionId:f(),heartbeatIntervalMs:l(L),heartbeatTimeoutMs:l(R),negotiatedCapabilities:c(U).max(64).optional(),endpoint:d({endpointId:s().min(1).max(160),turnToken:s().min(32).max(160)}).optional()})),W(`realtime.event`,ge),W(`realtime.subscribed`,d({topic:V,cursor:o().int().nonnegative()})),W(`realtime.gap`,d({topic:V,requestedSeq:o().int().nonnegative(),earliestSeq:H,recoverable:a()})),W(`realtime.pong`,d({})),W(`realtime.error`,d({code:s().min(1).max(80),message:s().min(1).max(500)})),W(`endpoint.message`,k)]);function ve(e){return _e.parse(e)}var K=class extends Error{retryable;constructor(e,t){super(e),this.retryable=t,this.name=`RealtimeConnectionError`}},ye=class extends Error{bytes;maxBytes;constructor(e,t){super(`Realtime client frame is ${e} bytes; maximum is ${t} bytes`),this.bytes=e,this.maxBytes=t,this.name=`RealtimeFrameTooLargeError`}};function be(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(e);if(ArrayBuffer.isView(e)){let t=Uint8Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return new TextDecoder().decode(t)}throw Error(`Realtime server sent a non-text frame`)}function xe(e){return e===1009||e===4400||e===4401||e===4409||e===4413}var Se=class{options;desiredSubscriptions=new Map;cursors=new Map;socket;reconnectTimer;heartbeatTimer;connectionTimer;ticketAbort;generation=0;reconnectAttempts=0;shouldReconnect=!1;ready=!1;lastServerMessageAt=0;endpointBinding;reconnectWhenSocketOpens=!1;offeredCapabilities=new Set;constructor(e){this.options=e}connect(){this.shouldReconnect||(this.shouldReconnect=!0,this.open(!1))}disconnect(){this.shouldReconnect=!1,this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client disconnected`),this.socket=void 0,this.options.onStateChange?.(`disconnected`)}reconnect(){this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client reconnecting`),this.socket=void 0,this.reconnectAttempts=0,this.shouldReconnect=!0,this.open(!0)}subscribe(e,t){this.desiredSubscriptions.set(e,t),t!==void 0&&this.cursors.set(e,t),this.ready&&this.sendSubscriptions([{topic:e,afterSeq:this.cursors.get(e)??t}])}unsubscribe(e){this.desiredSubscriptions.delete(e),this.ready&&this.send(this.clientMessage(`realtime.unsubscribe`,{topics:[e]}))}sendEndpointMessage(e){if(!this.ready)throw Error(`Realtime connection is not ready`);this.send(this.clientMessage(`endpoint.message`,e))}setEndpoint(e){this.endpointBinding=e,this.refreshEndpointConnection()}clearEndpoint(e){if(e&&this.endpointBinding!==e)return;let t=this.endpointBinding;this.endpointBinding=void 0,t?.onDisconnected?.(),this.refreshEndpointConnection()}refreshEndpointConnection(){if(this.shouldReconnect){if(this.socket?.readyState===0){this.reconnectWhenSocketOpens=!0;return}this.reconnect()}}async open(e){let t=++this.generation,n=this.options.connectionTimeoutMs??15e3,r=new AbortController;this.ticketAbort?.abort(),this.ticketAbort=r;let i,a=!1,o,s=(e,n=!0)=>{a||t!==this.generation||(a=!0,this.clearConnectionTimer(),r.abort(),this.ticketAbort===r&&(this.ticketAbort=void 0),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.clearHeartbeat(),this.socket===i&&(this.socket=void 0),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(4e3,e.slice(0,120))),this.shouldReconnect&&n?this.scheduleReconnect(e):this.shouldReconnect?(this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e)):this.options.onStateChange?.(`disconnected`))};this.connectionTimer=setTimeout(()=>s(`Realtime connection timed out`),n),this.options.onStateChange?.(e?`reconnecting`:`connecting`);try{let[e,n]=await Promise.all([this.options.issueTicket(r.signal),this.endpointBinding?.createHello()]),c=e.ticket;if(2<e.realtime.minVersion)throw new K(`CLIENT_UPDATE_REQUIRED`,!1);if(2>e.realtime.maxVersion)throw new K(`GATEWAY_UPDATE_REQUIRED`,!1);let l=z.filter(t=>e.realtime.capabilities.includes(t));if(a||!this.shouldReconnect||t!==this.generation)return;this.offeredCapabilities=new Set(l??[]),i=this.options.createWebSocket(this.options.getWebSocketUrl()),this.socket=i,i.onopen=()=>{if(t!==this.generation)return;if(this.reconnectWhenSocketOpens){this.reconnect();return}let e=[...this.desiredSubscriptions].map(([e,t])=>({topic:e,afterSeq:this.cursors.get(e)??t}));this.send(this.clientMessage(`realtime.hello`,{ticket:c,clientId:this.options.clientId,clientKind:this.options.clientKind,subscriptions:e,...l?.length?{capabilities:l}:{},...n?{endpoint:n}:{}}))},i.onmessage=e=>{if(t!==this.generation)return;let n=()=>{if(!(a||t!==this.generation))return this.handleServerMessage(be(e.data))};if(!o){try{let e=n();if(!e)return;let t=e.catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=t,t.finally(()=>{o===t&&(o=void 0)})}catch(e){s(e instanceof Error?e.message:`Invalid realtime server message`)}return}let r=o.then(n).catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=r,r.finally(()=>{o===r&&(o=void 0)})},i.onerror=()=>{},i.onclose=e=>{s(e.reason||`WebSocket closed (${e.code??0})`,!xe(e.code))}}catch(e){s(e instanceof Error?e.message:`Realtime connection failed`,!(e instanceof K)||e.retryable)}}handleServerMessage(e){let t=ve(JSON.parse(e));if(this.lastServerMessageAt=Date.now(),t.kind===`realtime.ready`){let e=t.payload.negotiatedCapabilities??[];if(e.some(e=>!this.offeredCapabilities.has(e)))throw Error(`Realtime server negotiated a capability the client did not offer`);this.ready=!0,this.reconnectAttempts=0,this.clearConnectionTimer(),this.ticketAbort=void 0,this.options.onStateChange?.(`connected`),this.options.onCapabilities?.(e),t.payload.endpoint&&this.endpointBinding?.onReady(t.payload.endpoint),this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{if(this.ready){if(Date.now()-this.lastServerMessageAt>=t.payload.heartbeatTimeoutMs){this.reconnect();return}this.send(this.clientMessage(`realtime.ping`,{}))}},t.payload.heartbeatIntervalMs)}else if(t.kind===`realtime.event`){let e=this.cursors.get(t.payload.topic);if(e!==void 0&&t.payload.seq<=e)return;this.options.onEvent?.(t.payload),this.cursors.set(t.payload.topic,t.payload.seq)}else if(t.kind===`realtime.subscribed`)this.cursors.set(t.payload.topic,t.payload.cursor),this.options.onSubscribed?.(t.payload);else if(t.kind===`realtime.gap`)return this.cursors.set(t.payload.topic,t.payload.earliestSeq-1),this.options.onGap?.(t.payload);else t.kind===`realtime.error`?this.options.onStateChange?.(`error`,t.payload.message):t.kind===`endpoint.message`&&(this.endpointBinding?.onMessage(t.payload),this.options.onEndpointMessage?.(t.payload))}sendSubscriptions(e){this.send(this.clientMessage(`realtime.subscribe`,{subscriptions:e}))}clientMessage(e,t){let n=this.options.createMessageId?.()??globalThis.crypto?.randomUUID?.();if(!n)throw Error(`RealtimeClient requires createMessageId when crypto.randomUUID is unavailable`);return{protocolVersion:2,messageId:n,kind:e,sentAt:Date.now(),payload:t}}send(e){if(!this.socket||this.socket.readyState!==1)return;let t=JSON.stringify(e),n=new TextEncoder().encode(t).byteLength;if(n>262144)throw new ye(n,I);this.socket.send(t)}scheduleReconnect(e){if(!this.shouldReconnect)return;this.reconnectAttempts+=1;let t=this.options.maxReconnectAttempts;if(t!==void 0&&this.reconnectAttempts>t){this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e);return}this.options.onStateChange?.(`reconnecting`,e);let n=Math.min(3e4,1e3*2**Math.min(this.reconnectAttempts-1,5)),r=Math.round(n*(.5+Math.random()*.5));this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.open(!0)},r)}clearHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}clearTimers(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.clearConnectionTimer(),this.ticketAbort?.abort(),this.ticketAbort=void 0,this.clearHeartbeat()}clearConnectionTimer(){this.connectionTimer&&clearTimeout(this.connectionTimer),this.connectionTimer=void 0}},Ce=500,q=null,J;function Y(e){J=e,q!==null&&clearTimeout(q),q=setTimeout(()=>{q=null;let e=J;J=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},Ce)}function we(e,t){if(e===`config.reload`){Y(t);return}window.dispatchEvent(new CustomEvent(e.replace(/[._]/g,`-`),{detail:t}))}var X=new Map,Z=new Map,Q,$;function Te(){let e=`xopc:realtime-client-id`,t=sessionStorage.getItem(e);if(t)return t;let n=crypto.randomUUID();return sessionStorage.setItem(e,n),n}function Ee(){let t=new URL(e(`/api/realtime/v1/ws`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function De(){let t=Te(),n=window.electronAPI?`desktop`:`web`,r=new Se({clientId:t,clientKind:n,getWebSocketUrl:Ee,issueTicket:async r=>{let i=await fetch(e(`/api/realtime/tickets`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t,clientKind:n,protocolVersion:2}),signal:r}),a=await i.json().catch(()=>null);if(!i.ok||!a?.payload?.ticket||!a.payload.realtime)throw Error(a?.error?.message??`Realtime ticket failed (${i.status})`);return{ticket:a.payload.ticket,realtime:a.payload.realtime}},createWebSocket:e=>new WebSocket(e),onStateChange:(e,t)=>{p({connectionState:e,error:t??null}),e===`connected`&&window.dispatchEvent(new CustomEvent(`gateway-realtime-connected`))},onEvent:e=>{(e.topic===`gateway`||e.topic===`sessions`)&&we(e.event,e.data);let t=Z.get(e.topic);(t===void 0||e.seq>t)&&Z.set(e.topic,e.seq);for(let t of X.get(e.topic)??[])if(!(t.cursor!==void 0&&e.seq<=t.cursor))try{t.listener.onEvent(e)}catch(e){console.error(`[realtime] topic listener failed:`,e)}finally{t.cursor=Math.max(t.cursor??0,e.seq)}},onGap:async e=>{window.dispatchEvent(new CustomEvent(`realtime-gap`,{detail:e}));let t=[...X.get(e.topic)??[]].filter(t=>!e.recoverable||t.cursor===void 0||t.cursor<e.earliestSeq-1),n=await Promise.allSettled(t.map(t=>t.listener.onGap?.(e)));for(let e of n)e.status===`rejected`&&console.error(`[realtime] topic gap handler failed:`,e.reason)}});Q?.disconnect(),Q=r,$&&r.setEndpoint($),r.subscribe(`gateway`,Z.get(`gateway`)),r.subscribe(`sessions`,Z.get(`sessions`));for(let e of X.keys())r.subscribe(e,Z.get(e));return p({connectionState:`connecting`,error:null}),r.connect(),()=>{Q===r&&(r.disconnect(),Q=void 0)}}function Oe(e){return $=e,Q?.setEndpoint(e),()=>{$===e&&($=void 0,Q?.clearEndpoint(e))}}function ke(e){Q?.sendEndpointMessage(e)}function Ae(){Q?.reconnect()}function je(e,t,n){let r=X.get(e)??new Set,i=r.size===0,a=Z.get(e),o={listener:t,cursor:n??a};if(r.add(o),X.set(e,r),i){let t=n??a;Z.set(e,t),Q?.subscribe(e,t)}else n!==void 0&&(a===void 0||n<a)&&Q?.subscribe(e,n);return()=>{let t=X.get(e);t?.delete(o),(!t||t.size===0)&&(X.delete(e),Z.delete(e),Q?.unsubscribe(e))}}export{je as a,A as c,M as d,E as f,ee as h,De as i,j as l,m,Ae as n,Y as o,ne as p,ke as r,re as s,Oe as t,F as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as e}from"./locale-store-JogcXC4J.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};
|
|
@@ -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{m as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{n as a,r as o}from"./popover-select-DGKUpVsz.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./messages-RzwPiQNL.js";import{t as l}from"./cn-0WouolD0.js";import{i as u,l as d,n as f,o as p}from"./locale-store-JogcXC4J.js";import{i as m,o as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-aIC072nz.js";import{t as _}from"./skeleton-BI5TyibZ.js";import{n as v,r as y}from"./gateway-config-swr-DF_HV6NP.js";import{Ad as b,Cl as x,Do as S,Eo as C,Fl as w,Fu as T,Lu as E,Ml as D,Nl as O,Nn as k,S as A,To as j,Wn as M,bl as N,bn as P,iu as F,jo as I,ks as L,ma as ee,na as te,rl as ne,vo as R,xl as z,yo as re}from"./index-ygkHNYyo.js";import{t as B}from"./number-input-DDeqHK-G.js";import{n as ie,t as ae}from"./settings-page-header-CYpuTXUW.js";import{t as oe}from"./settings-page-layout-B20AfmFG.js";import{n as se,t as ce}from"./settings-form-section-Ce8vVv-9.js";import{t as le}from"./settings-advanced-gate-QTVDCGJG.js";var V=e(t(),1),H=n(),U=18790,W={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return S(e)}async function ue(e){let t=await p(u(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function q(e){return K(e)?``:e.trim()}function de(e){return[...e].map(e=>e.trim()).sort()}function fe(e){return JSON.stringify({outboundProxy:e.outboundProxy,bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:q(e.auth.token),password:q(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:de(e.auth.trustedProxy.requiredHeaders),allowUsers:de(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:de(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function pe(e,t){return fe(e)!==fe(t)}async function me(e){return(await p(u(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function he(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function J(e){let t=G(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):W.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):W.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):W.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function ge(e){let t=G(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:Y(t.requiredHeaders,32),allowUsers:Y(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function _e(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function Y(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function ve(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function ye(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function be(e){try{let t=new URL(e.trim());return[`http:`,`https:`].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password&&!t.search&&!t.hash&&(!t.pathname||t.pathname===`/`)}catch{return!1}}function xe(e){let t=e.outboundProxy;if((t.mode===`custom`||t.url.trim())&&!be(t.url))return`Use an HTTP or HTTPS proxy origin without credentials, path, query or fragment.`;let n=ye(e);return n&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:n&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:n&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function Se(e){let t=G(e)?e:{},n=G(t.gateway)?t.gateway:{},r=G(n.auth)?n.auth:{},i=G(n.security)?n.security:{},a=G(t.update)?t.update:{},o=G(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[],u=ve(n.bind),d=typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,f=G(n.outboundProxy)?n.outboundProxy:{};return{outboundProxy:{mode:f.mode===`custom`||f.mode===`direct`?f.mode:`environment`,url:typeof f.url==`string`?f.url:``,noProxy:typeof f.noProxy==`string`?f.noProxy:``},bind:u,customBindHost:d,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):U,auth:{mode:he(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:J(r.rateLimit),trustedProxy:ge(r.trustedProxy)},corsOrigins:l,trustedProxies:Y(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:_e(n.channelConnectDeferMode),channelConnectDeferIds:Y(n.channelConnectDeferIds),channelConnectDeferSkipIds:Y(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function Ce(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!K(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!K(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function we(e){let t=xe(e);if(t)throw Error(t);await p(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{outboundProxy:e.outboundProxy,bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:Ce(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),v()}var X=r();function Te(e){let t=(0,H.c)(46),{value:n,onChange:r,g:i}=e,[s,c]=(0,V.useState)(!1),u;t[0]!==s||t[1]!==n.mode||t[2]!==n.url?(u=s&&n.mode===`custom`&&!be(n.url),t[0]=s,t[1]=n.mode,t[2]=n.url,t[3]=u):u=t[3];let d=u,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,I),t[4]=f):f=t[4];let p=f,m;t[5]===i.outboundProxyTitle?m=t[6]:(m=(0,X.jsx)(`h2`,{id:`outbound-proxy-title`,className:`text-sm font-semibold text-fg`,children:i.outboundProxyTitle}),t[5]=i.outboundProxyTitle,t[6]=m);let h;t[7]===i.outboundProxyHint?h=t[8]:(h=(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.outboundProxyHint}),t[7]=i.outboundProxyHint,t[8]=h);let g;t[9]===i.outboundProxyMode?g=t[10]:(g=(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-mode`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyMode}),t[9]=i.outboundProxyMode,t[10]=g);let _;t[11]!==r||t[12]!==n?(_=e=>r({...n,mode:e.target.value}),t[11]=r,t[12]=n,t[13]=_):_=t[13];let v;t[14]===i.outboundProxyEnvironment?v=t[15]:(v=(0,X.jsx)(o,{value:`environment`,children:i.outboundProxyEnvironment}),t[14]=i.outboundProxyEnvironment,t[15]=v);let y;t[16]===i.outboundProxyCustom?y=t[17]:(y=(0,X.jsx)(o,{value:`custom`,children:i.outboundProxyCustom}),t[16]=i.outboundProxyCustom,t[17]=y);let b;t[18]===i.outboundProxyDirect?b=t[19]:(b=(0,X.jsx)(o,{value:`direct`,children:i.outboundProxyDirect}),t[18]=i.outboundProxyDirect,t[19]=b);let x;t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==b||t[24]!==n.mode?(x=(0,X.jsxs)(a,{id:`outbound-proxy-mode`,value:n.mode,onChange:_,children:[v,y,b]}),t[20]=_,t[21]=v,t[22]=y,t[23]=b,t[24]=n.mode,t[25]=x):x=t[25];let S;t[26]!==x||t[27]!==g?(S=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[g,x]}),t[26]=x,t[27]=g,t[28]=S):S=t[28];let C;t[29]!==i.outboundProxyInvalid||t[30]!==i.outboundProxyUrl||t[31]!==d||t[32]!==r||t[33]!==n?(C=n.mode===`custom`&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-url`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyUrl}),(0,X.jsx)(`input`,{id:`outbound-proxy-url`,className:p,value:n.url,placeholder:`http://127.0.0.1:7897`,autoComplete:`off`,spellCheck:!1,"aria-invalid":d,"aria-describedby":d?`outbound-proxy-error`:void 0,onChange:e=>r({...n,url:e.target.value}),onBlur:()=>c(!0)}),d&&(0,X.jsx)(`p`,{id:`outbound-proxy-error`,role:`alert`,className:`text-xs text-danger`,children:i.outboundProxyInvalid})]}),t[29]=i.outboundProxyInvalid,t[30]=i.outboundProxyUrl,t[31]=d,t[32]=r,t[33]=n,t[34]=C):C=t[34];let w;t[35]!==i.outboundProxyBypass||t[36]!==i.outboundProxyBypassHint||t[37]!==r||t[38]!==n?(w=n.mode!==`direct`&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`label`,{htmlFor:`outbound-proxy-bypass`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyBypass}),(0,X.jsx)(`input`,{id:`outbound-proxy-bypass`,className:p,value:n.noProxy,placeholder:`.example.com,192.168.1.10`,autoComplete:`off`,spellCheck:!1,"aria-describedby":`outbound-proxy-bypass-hint`,onChange:e=>r({...n,noProxy:e.target.value})}),(0,X.jsx)(`p`,{id:`outbound-proxy-bypass-hint`,className:`text-xs text-fg-muted`,children:i.outboundProxyBypassHint})]}),t[35]=i.outboundProxyBypass,t[36]=i.outboundProxyBypassHint,t[37]=r,t[38]=n,t[39]=w):w=t[39];let T;return t[40]!==S||t[41]!==C||t[42]!==w||t[43]!==m||t[44]!==h?(T=(0,X.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,"aria-labelledby":`outbound-proxy-title`,children:[m,h,S,C,w]}),t[40]=S,t[41]=C,t[42]=w,t[43]=m,t[44]=h,t[45]=T):T=t[45],T}var Ee={critical:3,warn:2,info:1};function De(){return u(`/api/doctor?security=true`)}function Oe(e){return e.toSorted((e,t)=>Ee[t.severity]-Ee[e.severity]||e.checkId.localeCompare(t.checkId))}function ke(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=Oe((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function Ae(){return ke(await p(De()))}function je(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=f(Ne),o;t[0]===a?o=t[1]:(o=c(a),t[0]=a,t[1]=o);let l=o.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[De(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1},t[5]=d):d=t[5];let{data:p,error:v,isLoading:y,isValidating:b,mutate:S}=m(u,Me,d),C=p??null,T=v instanceof Error?v.message:v?String(v):null,E=y||b,D;t[6]===S?D=t[7]:(D=()=>{S(),h(De())},t[6]=S,t[7]=D);let O=D,k=!n||E,A;t[8]===E?A=t[9]:(A=E?(0,X.jsx)(s,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[8]=E,t[9]=A);let j;t[10]===l.securityAuditRefresh?j=t[11]:(j=(0,X.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=j);let M;t[12]!==O||t[13]!==k||t[14]!==A||t[15]!==j?(M=(0,X.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:k,onClick:O,children:[A,j]}),t[12]=O,t[13]=k,t[14]=A,t[15]=j,t[16]=M):M=t[16];let N;t[17]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==M?(N=(0,X.jsx)(se,{icon:x,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:M}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=M,t[20]=N):N=t[20];let P;t[21]===l.securityAuditSavedConfigHint?P=t[22]:(P=(0,X.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=P);let F;t[23]!==T||t[24]!==l.securityAuditLoadError?(F=T?(0,X.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,T]}):null,t[23]=T,t[24]=l.securityAuditLoadError,t[25]=F):F=t[25];let I;t[26]!==C||t[27]!==T||t[28]!==E?(I=!T&&E&&!C?(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,X.jsx)(_,{className:`h-11 w-full rounded-lg`}),(0,X.jsx)(_,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=C,t[27]=T,t[28]=E,t[29]=I):I=t[29];let L;t[30]!==C||t[31]!==l?(L=C?(0,X.jsx)(Pe,{g:l,audit:C}):null,t[30]=C,t[31]=l,t[32]=L):L=t[32];let ee;return t[33]!==N||t[34]!==P||t[35]!==F||t[36]!==I||t[37]!==L?(ee=(0,X.jsxs)(ce,{children:[N,P,F,I,L]}),t[33]=N,t[34]=P,t[35]=F,t[36]=I,t[37]=L,t[38]=ee):ee=t[38],ee}function Me(){return Ae()}function Ne(e){return e.language}function Pe(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,o,s,c,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Re(n,r.status,r.findings),d=`space-y-4`,c=l(`rounded-lg px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,s=`flex items-start gap-2`,i=a.icon,o=l(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=u,t[9]=d):(i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==o?(f=(0,X.jsx)(i,{className:o,"aria-hidden":!0}),t[10]=i,t[11]=o,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,X.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,X.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,X.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==s||t[21]!==f||t[22]!==h?(g=(0,X.jsxs)(`div`,{className:s,children:[f,h]}),t[20]=s,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==c||t[26]!==u?(_=(0,X.jsx)(`div`,{className:c,role:u,children:g}),t[24]=g,t[25]=c,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,X.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,X.jsx)(Ie,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,X.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,X.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Fe)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,X.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Fe(e){return(0,X.jsx)(`li`,{className:`font-mono`,children:e},e)}function Ie(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,o,s;if(t[0]!==r.severity){let e=Le(r.severity);s=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,o=`flex items-start gap-2`,i=e.icon,a=l(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=o,t[4]=s}else i=t[1],a=t[2],o=t[3],s=t[4];let c;t[5]!==i||t[6]!==a?(c=(0,X.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=c):c=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,X.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,X.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==o||t[26]!==c?(g=(0,X.jsxs)(`div`,{className:o,children:[c,h]}),t[24]=h,t[25]=o,t[26]=c,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==s?(_=(0,X.jsx)(`li`,{className:s,children:g}),t[28]=g,t[29]=s,t[30]=_):_=t[30],_}function Le(e){switch(e){case`critical`:return{icon:b,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:ne,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:E,iconClass:`text-fg-muted`}}}function Re(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:b,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`bg-red-50 text-red-950 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:ne,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`bg-amber-50 text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:E,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`bg-surface-base/55 text-fg`}:{icon:x,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`bg-emerald-50 text-emerald-950 dark:bg-emerald-950/40 dark:text-emerald-100`}}var ze=new Set([`security`,`advanced`]);function Be(e,t){return t===`advanced`?!0:!ze.has(e)}function Ve(e,t){return e.filter(e=>Be(e,t))}function He(){return`network`}function Ue(e,t){let n=(0,H.c)(5),r=k(We),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{Be(e,r)||t(He())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,V.useEffect)(i,a)}function We(e){return e.mode}function Z(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I,`dark:border-edge`)}var Ge=[`network`,`access`,`updates`,`security`,`proxy`,`advanced`],Ke={network:F,access:T,updates:w,security:z,proxy:D,advanced:N};function qe(e){return e&&Ge.includes(e)?e:`network`}function Je(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:t===`proxy`?e.outboundProxyTitle:e.tabAdvanced}function Ye(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:t===`proxy`?e.outboundProxyHint:e.advancedSectionHint}function Xe(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Ze={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Qe(){let e=d(e=>e.baseUrl),t=f(e=>e.language),n=c(t),r=n.gatewaySettings,[u,p]=i(),h=k(e=>e.mode),_=h===`advanced`,v=qe(u.get(`tab`)),x=(0,V.useMemo)(()=>Ve(Ge,h),[h]),S=(0,V.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]);Ue(v,S);let C=d(e=>e.conversationId),w=d(e=>e.tokenExpired),T=d(e=>e.openTokenDialog),E=!!C,[D,N]=(0,V.useReducer)(Xe,{form:null,baseline:null,appliedBaseline:null}),F=D.form,I=D.baseline,L=D.appliedBaseline,[ne,R]=(0,V.useReducer)(ee,Ze),{saving:z,error:oe,auditRefreshToken:se,restarting:ce,restartConfirmOpen:H}=ne,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:q,isLoading:de,mutate:fe}=y(E),he=m(E&&F?[`gateway-cors-origin-candidates`,F.port]:null,([,e])=>me(e),{revalidateOnFocus:!1}),J=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(Se(K.payload.config)),[K]);E?J!==null&&(G.current||(G.current=!0,N({type:`init-applied`,value:J})),!U.current&&W.current!==J&&(W.current=J,N({type:`sync`,value:J}),R({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,N({type:`reset`}),U.current=!1);let ge=!!(E&&de&&K===void 0&&!q),_e=q instanceof Error?q.message:q?String(q):null,Y=(0,V.useMemo)(()=>!F||!I?!1:JSON.stringify(F)!==JSON.stringify(I),[F,I]),ve=(0,V.useMemo)(()=>!I||!L?!1:pe(L,I),[L,I]),ye=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),be=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Ce=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Ee=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,bind:e})})},[]),De=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Oe=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,port:e})})},[]),ke=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ae=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Me=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Ne=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Fe=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Ie=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Le=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Re=(0,V.useCallback)(e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),ze=(0,V.useCallback)(async()=>{if(!F||z)return;let e=xe(F);if(e){R({type:`patch`,patch:{error:e}});return}R({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await we(F),U.current=!1,N({type:`saved`,value:F}),R({type:`patch`,patch:{saveOk:!0,auditRefreshToken:se+1}})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:r.saveError}})}finally{R({type:`patch`,patch:{saving:!1}})}},[F,z,r.saveError]),Be=(0,V.useCallback)(()=>{I&&(U.current=!1,N({type:`discard`}),R({type:`patch`,patch:{error:null,saveOk:!1}}))},[I]),He=j(r),We=(0,V.useCallback)(async()=>{if(!ce){R({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await M();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):R({type:`patch`,patch:{error:e.message||r.restartGatewayFailed}})}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{R({type:`patch`,patch:{restarting:!1}})}}},[ce,r.restartGatewayFailed]);return E?ge?(0,X.jsx)(ie,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,X.jsx)(P,{sections:3})}):F?(0,X.jsxs)(ie,{gap:`gap-6`,children:[(0,X.jsx)(ae,{title:n.settingsSections.gateway,docsLink:re(t,`gateway`),docsLabel:r.docsLink,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(g,{type:`button`,variant:`secondary`,disabled:!Y||z,onClick:Be,children:r.discard}),(0,X.jsx)(g,{type:`button`,variant:`primary`,disabled:!Y||z,onClick:()=>void ze(),children:z?r.saving:r.save})]})}),w?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-red-50 px-4 py-3 dark:bg-red-950/40`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,X.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:r.tokenExpired})]}),(0,X.jsx)(`div`,{children:(0,X.jsx)(g,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>T(),children:r.updateToken})})]}):null,oe?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:oe}):null,ve?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-amber-50 px-3 py-2 dark:bg-amber-950/40`,children:[(0,X.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:r.restartHint}),(0,X.jsxs)(g,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:ce,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[ce?(0,X.jsx)(s,{className:`size-3.5 animate-spin`}):(0,X.jsx)(O,{className:`size-3.5`}),r.restartGatewayButton]})]}):null,(0,X.jsx)(te,{open:H,title:r.restartGatewayButton,description:r.restartGatewayConfirm,confirmLabel:r.restartGatewayButton,cancelLabel:r.discard,destructive:!0,onConfirm:()=>void We(),onCancel:()=>R({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,X.jsx)(je,{enabled:E,refreshToken:se}),(0,X.jsx)($e,{g:r,activeTab:v,visibleTabs:x,onChange:S}),(0,X.jsxs)(Q,{g:r,id:`network`,activeTab:v,children:[(0,X.jsxs)(`section`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`zh`?`当前服务连接`:`Current service connection`}),(0,X.jsx)(`p`,{className:`break-all text-sm text-fg-muted`,children:e}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry}),(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>T(),children:r.updateToken}),(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:r.restartGatewayButton})]})]}),(0,X.jsxs)(A,{title:t===`zh`?`服务监听配置`:`Service listener configuration`,summary:`${F.bind} · ${F.port}`,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:r.bindMode}),(0,X.jsxs)(a,{id:`gateway-bind-mode`,className:Z(),value:F.bind,onChange:e=>Ee(e.target.value),children:[(0,X.jsx)(o,{value:`loopback`,children:r.bindLoopback}),_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{value:`lan`,children:r.bindLan}),(0,X.jsx)(o,{value:`auto`,children:r.bindAuto}),(0,X.jsx)(o,{value:`custom`,children:r.bindCustom}),(0,X.jsx)(o,{value:`tailnet`,children:r.bindTailnet})]}):null]})]}),F.bind===`custom`?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:r.customBindHost}),(0,X.jsx)(`input`,{id:`gateway-custom-bind-host`,className:l(Z(),`font-mono text-xs`),value:F.customBindHost,onChange:e=>De(e.target.value),placeholder:r.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:r.listenPort}),(0,X.jsx)(B,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:l(Z(),`font-mono text-xs`),value:F.port,onChange:e=>{let t=Number(e.target.value);Oe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):F.port)}})]})]}),(0,X.jsx)(le,{children:(0,X.jsx)(rt,{g:r,origins:F.corsOrigins,candidates:he.data??[],onChange:Ce})})]})]}),(0,X.jsxs)(Q,{g:r,id:`access`,activeTab:v,children:[F.auth.mode===`none`?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:r.authModeNone}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:r.authMode}),(0,X.jsxs)(a,{id:`gateway-auth-mode`,value:F.auth.mode,onChange:e=>ye({mode:e.target.value}),className:Z(),children:[(0,X.jsx)(o,{value:`token`,children:r.authModeToken}),(0,X.jsx)(o,{value:`password`,children:r.authModePassword}),_||F.auth.mode===`trusted-proxy`||F.auth.mode===`none`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{value:`trusted-proxy`,children:r.authModeTrustedProxy}),(0,X.jsx)(o,{value:`none`,children:r.authModeNoneLabel})]}):null]})]}),(0,X.jsx)(le,{children:F.auth.mode===`trusted-proxy`?(0,X.jsx)(tt,{g:r,form:F,onTrustedProxyChange:Fe,onTrustedProxiesChange:Pe,onAllowRealIpFallbackChange:Le}):null}),F.auth.mode===`token`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(st,{id:`gateway-access-token`,label:r.accessToken,help:r.tokenHelp,placeholder:r.tokenPlaceholder,value:F.auth.token,labels:He,reveal:()=>ue(`token`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>ye({token:e})}),(0,X.jsx)(g,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>T(),children:r.changeToken})]}):null,F.auth.mode===`password`?(0,X.jsx)(st,{id:`gateway-auth-password`,label:r.authPassword,help:r.authPasswordHelp,placeholder:r.authPasswordPlaceholder,value:F.auth.password,labels:He,reveal:()=>ue(`password`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>ye({password:e})}):null,(0,X.jsx)(le,{children:F.auth.mode===`none`?null:(0,X.jsx)(ot,{g:r,rateLimit:F.auth.rateLimit,onChange:ke})})]}),(0,X.jsxs)(Q,{g:r,id:`updates`,activeTab:v,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:r.updateChannel}),(0,X.jsxs)(a,{id:`gateway-update-channel`,value:F.updateChannel,onChange:e=>be(e.target.value),className:Z(),children:[(0,X.jsx)(o,{value:`stable`,children:r.channelStable}),_||F.updateChannel===`beta`?(0,X.jsx)(o,{value:`beta`,children:r.channelBeta}):null,_||F.updateChannel===`dev`?(0,X.jsx)(o,{value:`dev`,children:r.channelDev}):null]})]}),(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.updateAutoSection}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:F.updateCheckOnStart,onChange:e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.updateCheckOnStart}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateCheckOnStartHint})]})]}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:F.updateAutoEnabled,onChange:e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:r.updateAutoEnabled}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateAutoEnabledHint})]})]}),(0,X.jsx)(le,{children:(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:r.updateAutoStableDelayHours}),(0,X.jsx)(B,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!F.updateAutoEnabled,className:Z(),value:F.updateAutoStableDelayHours,onChange:e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableDelayHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:r.updateAutoStableJitterHours}),(0,X.jsx)(B,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!F.updateAutoEnabled,className:Z(),value:F.updateAutoStableJitterHours,onChange:e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableJitterHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:r.updateAutoBetaCheckIntervalHours}),(0,X.jsx)(B,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!F.updateAutoEnabled,className:Z(),value:F.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoBetaCheckIntervalHoursHint})]})]})})]})]}),(0,X.jsx)(Q,{g:r,id:`security`,activeTab:v,children:(0,X.jsx)(et,{g:r,form:F,onSecurityStrictChange:Ie,onDangerouslyAllowHostHeaderOriginFallbackChange:Re})}),(0,X.jsx)(Q,{g:r,id:`proxy`,activeTab:v,children:(0,X.jsx)(Te,{value:F.outboundProxy,g:r,onChange:e=>{U.current=!0,N({type:`set-form`,updater:t=>({...t,outboundProxy:e})})}})}),(0,X.jsx)(Q,{g:r,id:`advanced`,activeTab:v,children:(0,X.jsx)(nt,{g:r,form:F,onDeferModeChange:Ae,onDeferIdsChange:Me,onSkipIdsChange:Ne})})]}):(0,X.jsxs)(ie,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:oe??_e??r.loadError}),(0,X.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry})]}):(0,X.jsxs)(ie,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(ae,{title:n.settingsSections.gateway}),(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function $e(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Je(n,e),icon:Ke[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,X.jsx)(R,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Q(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Je(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ye(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,X.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,X.jsx)(oe,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,showHeading:!1,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function et(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,X.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,X.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,X.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function tt(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:o}=e,s=r.auth.trustedProxy,c;t[0]===n.authModeTrustedProxyHint?c=t[1]:(c=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=c);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=l(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==s.userHeader?(p=(0,X.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:s.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=s.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,X.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==s.requiredHeaders?(_=(0,X.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=s.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==s.allowUsers?(y=(0,X.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=s.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==s.allowLoopback?(x=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:s.allowLoopback,onChange:b}),t[37]=b,t[38]=s.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,X.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,X.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,X.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===o?D=t[58]:(D=e=>o(e.target.checked),t[57]=o,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,X.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,X.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==c||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[c,h,_,y,T,E,M]}),t[72]=c,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function nt(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.channelConnectDeferMode?l=t[1]:(l=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=l);let u=r.channelConnectDeferMode,d;t[2]===i?d=t[3]:(d=e=>i(e.target.value),t[2]=i,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=Z(),t[4]=f):f=t[4];let p;t[5]===n.channelConnectDeferModeAuto?p=t[6]:(p=(0,X.jsx)(o,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=p);let m;t[7]===n.channelConnectDeferModeOff?m=t[8]:(m=(0,X.jsx)(o,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=m);let h;t[9]===n.channelConnectDeferModeExplicit?h=t[10]:(h=(0,X.jsx)(o,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=h);let g;t[11]!==r.channelConnectDeferMode||t[12]!==d||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,X.jsxs)(a,{id:`gateway-channel-defer-mode`,value:u,onChange:d,className:f,children:[p,m,h]}),t[11]=r.channelConnectDeferMode,t[12]=d,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;t[17]===n.channelConnectDeferModeHint?_=t[18]:(_=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=_);let v;t[19]!==l||t[20]!==g||t[21]!==_?(v=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[l,g,_]}),t[19]=l,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==s?(y=r.channelConnectDeferMode===`explicit`?(0,X.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=s,t[30]=y):y=t[30];let b;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==c?(b=r.channelConnectDeferMode===`off`?null:(0,X.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=c,t[38]=b):b=t[38];let x;return t[39]!==v||t[40]!==y||t[41]!==b?(x=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[v,y,b]}),t[39]=v,t[40]=y,t[41]=b,t[42]=x):x=t[42],x}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:o,maxItems:s,onChange:c,children:u}=e,d;t[0]!==s||t[1]!==c||t[2]!==o?(d=e=>{let t=e.trim();!t||o.includes(t)||o.length>=s||c([...o,t])},t[0]=s,t[1]=c,t[2]=o,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==c||t[10]!==o?(h=o.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:l(`text-fg-muted hover:text-fg`,L.press),"aria-label":`Remove ${e}`,onClick:()=>c(o.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=c,t[10]=o,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=l(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let _=o.length>=s,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==a||t[16]!==_||t[17]!==v?(y=(0,X.jsx)(`input`,{className:g,placeholder:a,disabled:_,onKeyDown:v}),t[15]=a,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function rt(e){let t=(0,H.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,l,u,d,f,p,m,h,_;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=$,l=n.corsOrigins,u=n.corsOriginsHint,d=n.corsOriginsEmpty,f=n.corsOriginsPlaceholder,p=r,m=128,h=a,_=o.length>0?(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(at)}),(0,X.jsx)(g,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map(it)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h,t[19]=_}else c=t[11],l=t[12],u=t[13],d=t[14],f=t[15],p=t[16],m=t[17],h=t[18],_=t[19];let v;t[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(v=s?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=v):v=t[24];let y;return t[25]!==c||t[26]!==v||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==h||t[34]!==_?(y=(0,X.jsxs)(c,{title:l,hint:u,emptyText:d,placeholder:f,values:p,maxItems:m,onChange:h,children:[_,v]}),t[25]=c,t[26]=v,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=h,t[34]=_,t[35]=y):y=t[35],y}function it(e){return e.url}function at(e){return(0,X.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function ot(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,X.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,X.jsx)(B,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,X.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,X.jsx)(B,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,X.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,X.jsx)(B,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,X.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,X.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function st(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,X.jsx)(C,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{Qe as GatewaySettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_c as e,dc as t,fc as n,gc as r,hc as i,mc as a,pc as o,uc as s,vc as c}from"./index-ygkHNYyo.js";for(let[l,u]of Object.entries({bash:e,css:r,javascript:i,json:a,markdown:o,plaintext:n,typescript:t,xml:s}))c.registerLanguage(l,u);c.registerAliases([`html`],{languageName:`xml`}),c.registerAliases([`js`,`jsx`],{languageName:`javascript`}),c.registerAliases([`ts`,`tsx`],{languageName:`typescript`}),c.registerAliases([`sh`,`shell`,`zsh`],{languageName:`bash`}),c.registerAliases([`md`],{languageName:`markdown`});function l(e,t){return c.highlight(e,{language:c.getLanguage(t)?t:`plaintext`}).value}export{l as highlightCode};
|