@xopcai/xopc 0.0.415 → 0.0.417
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- 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-BKnEwsOO.js} +2914 -1381
- 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 +502 -348
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/activity-YogQEteU.js +1 -0
- package/dist/gateway/static/root/assets/activity-store-DnqOM8GN.js +1 -0
- package/dist/gateway/static/root/assets/agent-avatar-dicebear-1UABT2KS.js +1 -0
- package/dist/gateway/static/root/assets/agent-avatar-display-Cy50vjbq.js +2 -0
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-V4NX_cWz.js +1 -0
- package/dist/gateway/static/root/assets/agent-display-names-Bje7vfSn.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CQ5LLDMO.js +1 -0
- package/dist/gateway/static/root/assets/agents-O7mago-m.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-B1p-ghg9.js → agents-admin-api-CyjykMEh.js} +2 -2
- package/dist/gateway/static/root/assets/agents-app-path-ciChvpCS.js +1 -0
- package/dist/gateway/static/root/assets/api-C1dxxDZx.js +1 -0
- package/dist/gateway/static/root/assets/api-Ddrs70xV.js +1 -0
- package/dist/gateway/static/root/assets/app-chrome-BeB4KgOf.js +1 -0
- package/dist/gateway/static/root/assets/app-link-CytZ5zkp.js +1 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-C1Zs-eha.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-lIfGokbz.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-CUvtsRYD.js +1 -0
- package/dist/gateway/static/root/assets/archive-Dz0hferG.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Ch7wolHE.js → archive-plugin-n5lPr79c.js} +1 -1
- package/dist/gateway/static/root/assets/arrow-left-D880xG-P.js +1 -0
- package/dist/gateway/static/root/assets/arrow-right-DSSvoX71.js +1 -0
- package/dist/gateway/static/root/assets/arrow-up-D5ZtR1QT.js +1 -0
- package/dist/gateway/static/root/assets/arrow-up-right-T72JbQ1Q.js +1 -0
- package/dist/gateway/static/root/assets/{attachment-preview-renderer-wzIchDSv.js → attachment-preview-renderer-DdOEgexg.js} +3 -3
- package/dist/gateway/static/root/assets/{attachment-process-heavy-Db4nTY5N.js → attachment-process-heavy-DGZZ-M85.js} +2 -2
- package/dist/gateway/static/root/assets/automation-api-Bld8blNl.js +1 -0
- package/dist/gateway/static/root/assets/automation-display-BcfZOQTC.js +2 -0
- package/dist/gateway/static/root/assets/{automations-page-DK7AU79v.js → automations-page-oLsNzu_6.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BgtYY2Mm.js +8 -0
- package/dist/gateway/static/root/assets/beta-badge-BnzdzIEl.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B4HcHYsC.js → binary-plugins-D9VW7dWP.js} +2 -2
- package/dist/gateway/static/root/assets/{block-editor-BQAWEZF-.js → block-editor-C477bTtO.js} +23 -23
- package/dist/gateway/static/root/assets/book-open-CCGtrT3R.js +1 -0
- package/dist/gateway/static/root/assets/bot-DjLkhyZL.js +1 -0
- package/dist/gateway/static/root/assets/box-DvYoGszj.js +1 -0
- package/dist/gateway/static/root/assets/braces-Cfmtagno.js +1 -0
- package/dist/gateway/static/root/assets/brand-logo-CgT9zQfr.js +1 -0
- package/dist/gateway/static/root/assets/briefcase-business-BsoCaI_t.js +1 -0
- package/dist/gateway/static/root/assets/browser-BLJWD7WI.js +8 -0
- package/dist/gateway/static/root/assets/{browser-automation-inputs-D6AccXaA.js → browser-automation-inputs-CCiYXxmh.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-DIUNY94X.js +3 -0
- package/dist/gateway/static/root/assets/browser-control-api-Y3fvmeBk.js +6 -0
- package/dist/gateway/static/root/assets/browser-notification-delivery-DmE2FgGc.js +1 -0
- package/dist/gateway/static/root/assets/browser-settings-page-DjkGahlz.js +3 -0
- package/dist/gateway/static/root/assets/{button-aIC072nz.js → button-CnRSIP6m.js} +1 -1
- package/dist/gateway/static/root/assets/calendar-clock-D-quYVPe.js +1 -0
- package/dist/gateway/static/root/assets/calendar-days-hw_Y-g-s.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-DAyA681v.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-DRVXLssH.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-DFW4Y0x8.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-uOHSMQPZ.js +8 -0
- package/dist/gateway/static/root/assets/capability-header-actions-CTUCuBlW.js +1 -0
- package/dist/gateway/static/root/assets/capability-icon-DVoZxEgW.js +1 -0
- package/dist/gateway/static/root/assets/capability-links-DzQWK1Fh.js +1 -0
- package/dist/gateway/static/root/assets/channels-D2a69dSt.js +1 -0
- package/dist/gateway/static/root/assets/channels-routes-r2g-9DdC.js +1 -0
- package/dist/gateway/static/root/assets/chat-agents-api-D5nR_JVe.js +1 -0
- package/dist/gateway/static/root/assets/chat-chart-block-K2t333qv.js +2 -0
- package/dist/gateway/static/root/assets/chat-page-CG38tCHE.js +71 -0
- package/dist/gateway/static/root/assets/chat-page-zQeUaawJ.css +1 -0
- package/dist/gateway/static/root/assets/chat-terminal-dock-CkFG6mA3.js +35 -0
- package/dist/gateway/static/root/assets/chevron-left-DqFhpbvK.js +1 -0
- package/dist/gateway/static/root/assets/chevron-right-BweFrslA.js +1 -0
- package/dist/gateway/static/root/assets/chunk-D32TOXHM-DQIy-Baq.js +156 -0
- package/dist/gateway/static/root/assets/chunk-KS7C4IRE-CiwuuyV8.js +4 -0
- package/dist/gateway/static/root/assets/circle-BoO4YvTx.js +1 -0
- package/dist/gateway/static/root/assets/circle-alert-BEjgurr2.js +1 -0
- package/dist/gateway/static/root/assets/circle-pause-CN9jYH2s.js +1 -0
- package/dist/gateway/static/root/assets/circle-x-DFsCKeya.js +1 -0
- package/dist/gateway/static/root/assets/clock-3-DnrAnuyZ.js +1 -0
- package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +1 -0
- package/dist/gateway/static/root/assets/cloud-credits-B-nbtkqv.js +1 -0
- package/dist/gateway/static/root/assets/code-xml-DJtYhZUF.js +1 -0
- package/dist/gateway/static/root/assets/coins-DjP27vUx.js +1 -0
- package/dist/gateway/static/root/assets/command-palette-api-Do_66X1B.js +1 -0
- package/dist/gateway/static/root/assets/composer-payload-handoff-BU3B-C26.js +1 -0
- package/dist/gateway/static/root/assets/computer-settings-page-DBxOcMko.js +1 -0
- package/dist/gateway/static/root/assets/confirm-dialog-XGclfBqe.js +1 -0
- package/dist/gateway/static/root/assets/connected-providers-grid-Dmnu2zle.js +1 -0
- package/dist/gateway/static/root/assets/connector-filters-Cfcx9EA2.js +1 -0
- package/dist/gateway/static/root/assets/connector-service-page-rWpnchb3.js +1 -0
- package/dist/gateway/static/root/assets/connectors-api-DIBG72k4.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-DT_WrC1y.js +1 -0
- package/dist/gateway/static/root/assets/constants-DBtMsXdW.js +1 -0
- package/dist/gateway/static/root/assets/copy-text-row-CYIv7RfP.js +1 -0
- package/dist/gateway/static/root/assets/cpu-B247669f.js +1 -0
- package/dist/gateway/static/root/assets/database-CjjeZfRG.js +1 -0
- package/dist/gateway/static/root/assets/date-picker-CE-cZFCU.js +1 -0
- package/dist/gateway/static/root/assets/dependency-picker-7SpSfDSg.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-lorocS9j.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-narrative-CS8qJpNO.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-settings-CEcohlZq.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-sprite-Bd-aOI7N.js → desktop-pet-sprite-D5YYq2zC.js} +1 -1
- package/dist/gateway/static/root/assets/dev-view-store-57HgVuZ6.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-CLCPuf4R.js +1 -0
- package/dist/gateway/static/root/assets/directory-picker-path-field-D4jMhpka.js +1 -0
- package/dist/gateway/static/root/assets/discussion-annotation-sync-BKjf9gWe.js +1 -0
- package/dist/gateway/static/root/assets/dist-CaUuvp8-.js +1 -0
- package/dist/gateway/static/root/assets/dist-DNCdG_qB.js +1 -0
- package/dist/gateway/static/root/assets/dist-DfWfZ9iu.js +1 -0
- package/dist/gateway/static/root/assets/dist-DusecO_p.js +1 -0
- package/dist/gateway/static/root/assets/docx-preview-CnIClbYi.js +20 -0
- package/dist/gateway/static/root/assets/earth-BMhZtzcj.js +1 -0
- package/dist/gateway/static/root/assets/echarts-runtime-QSmTlXOu.js +18 -0
- package/dist/gateway/static/root/assets/electron-env-DHOGevH3.js +1 -0
- package/dist/gateway/static/root/assets/extension-debug-page-BsK2LMXQ.js +1 -0
- package/dist/gateway/static/root/assets/extension-iframe-host-Dhkk5JV2.js +1 -0
- package/dist/gateway/static/root/assets/extension-marketplace-api-CVJPqJOB.js +1 -0
- package/dist/gateway/static/root/assets/extension-page-Brps2XDP.js +1 -0
- package/dist/gateway/static/root/assets/extension-paths-DvuaZJuy.js +1 -0
- package/dist/gateway/static/root/assets/extension-provider-Byrd8Sor.js +1 -0
- package/dist/gateway/static/root/assets/extension-settings-page-CHY68DpG.js +1 -0
- package/dist/gateway/static/root/assets/file-BqMS_3DT.js +1 -0
- package/dist/gateway/static/root/assets/file-archive-DanfQJNe.js +1 -0
- package/dist/gateway/static/root/assets/file-preview-surface-BlprUrIs.js +1 -0
- package/dist/gateway/static/root/assets/file-text-D12HbeVy.js +1 -0
- package/dist/gateway/static/root/assets/file-tree-CFlZnV3Y.js +1 -0
- package/dist/gateway/static/root/assets/file-tree-utils-DJs1faGv.js +1 -0
- package/dist/gateway/static/root/assets/files-BNL4kkSB.js +1 -0
- package/dist/gateway/static/root/assets/floating-ui.dom-seOukHzT.js +1 -0
- package/dist/gateway/static/root/assets/folder-CN-pC3XL.js +1 -0
- package/dist/gateway/static/root/assets/folder-kanban-CpLlFI1o.js +1 -0
- package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-fQKBHBi1.js → gateway-config-swr-BAmUhiP1.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-CsykKL4l.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-DQqMBruB.js +1 -0
- package/dist/gateway/static/root/assets/gateway-restart-Ch128Lrr.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-BA5-Uuwx.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Cfwxof4k.js → gateway-startup-retry-CtUB3g6N.js} +1 -1
- package/dist/gateway/static/root/assets/gauge-C78eD2BA.js +1 -0
- package/dist/gateway/static/root/assets/git-branch-Dh9uxTot.js +1 -0
- package/dist/gateway/static/root/assets/global-defaults-api-CINf-C6a.js +2 -0
- package/dist/gateway/static/root/assets/heart-Cp4rgrqn.js +1 -0
- package/dist/gateway/static/root/assets/highlight-code-BH65IIbJ.js +1 -0
- package/dist/gateway/static/root/assets/highlighted-body-KQOG7T2V-DKGma5wI.js +1 -0
- package/dist/gateway/static/root/assets/history-DXH_9jsE.js +1 -0
- package/dist/gateway/static/root/assets/home-page-DaMFBYo1.js +2 -0
- package/dist/gateway/static/root/assets/image-Cwyalflz.js +1 -0
- package/dist/gateway/static/root/assets/image-generation-api-I_JgLL_m.js +1 -0
- package/dist/gateway/static/root/assets/imports-page-BWShtGRQ.js +1 -0
- package/dist/gateway/static/root/assets/index-BpCi0TdG.js +11 -0
- package/dist/gateway/static/root/assets/index-DY2Y83b9.css +1 -0
- package/dist/gateway/static/root/assets/index.module-Cd9ENXfk.js +1 -0
- package/dist/gateway/static/root/assets/info-CDrmIZhb.js +1 -0
- package/dist/gateway/static/root/assets/install-connector-dialog-DU1Tz7B3.js +1 -0
- package/dist/gateway/static/root/assets/interaction-BdhHBbYa.js +1 -0
- package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +1 -0
- package/dist/gateway/static/root/assets/{jszip.min-DT31yWkU.js → jszip.min-Dj17eJqX.js} +1 -1
- package/dist/gateway/static/root/assets/key-round-DWbpyU2U.js +1 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CdM4BQwp.js +1 -0
- package/dist/gateway/static/root/assets/languages-zXtNocoy.js +2 -0
- package/dist/gateway/static/root/assets/laptop-CI3hBVrl.js +1 -0
- package/dist/gateway/static/root/assets/layers-mJW7JJKm.js +1 -0
- package/dist/gateway/static/root/assets/layout-grid-CEVZdVFU.js +1 -0
- package/dist/gateway/static/root/assets/list-checks-BbsExAoq.js +1 -0
- package/dist/gateway/static/root/assets/list-filter-COkzTdOz.js +1 -0
- package/dist/gateway/static/root/assets/list-todo-CTVRto8O.js +1 -0
- package/dist/gateway/static/root/assets/list-tree-B0OMswgM.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-qPflPuQD.js +1 -0
- package/dist/gateway/static/root/assets/local-apps-Ck6kACsY.js +1 -0
- package/dist/gateway/static/root/assets/local-apps-page-CxyRVfjD.js +1 -0
- package/dist/gateway/static/root/assets/local-session-drafts-B9ZPwotC.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-B7s2Hb35.js → locale-store-lIXD1FMw.js} +1 -1
- package/dist/gateway/static/root/assets/lock-keyhole-DEK5kH0u.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-CbY1N-zi.js +2 -0
- package/dist/gateway/static/root/assets/loopi-C09I2mNj.css +1 -0
- package/dist/gateway/static/root/assets/loopi-CNtmi9FU.js +1 -0
- package/dist/gateway/static/root/assets/management-settings-Diy12JfQ.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-editor-phTQ0mox.js → markdown-editor-BuuGlcfG.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-C-DHb3Io.css +1 -0
- package/dist/gateway/static/root/assets/markdown-view-CJt-i2Dp.js +324 -0
- package/dist/gateway/static/root/assets/{media-plugins-DYQDjCVQ.js → media-plugins-D_bR23mA.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-Ur99GwOg.js +1 -0
- package/dist/gateway/static/root/assets/mermaid-render-oOellPHt.js +134 -0
- package/dist/gateway/static/root/assets/message-circle-Badhj-4D.js +1 -0
- package/dist/gateway/static/root/assets/message-square-fVE7Ghj1.js +1 -0
- package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +1 -0
- package/dist/gateway/static/root/assets/{messages-BYq0cPbn.js → messages-DRR9N3HC.js} +1 -1
- package/dist/gateway/static/root/assets/messages-square-BckAJrEW.js +1 -0
- package/dist/gateway/static/root/assets/mic-CuUb7zc-.js +1 -0
- package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +1 -0
- package/dist/gateway/static/root/assets/mobile-pair-qr-CuIbmw5x.js +1 -0
- package/dist/gateway/static/root/assets/model-selector-DCYA_ntf.js +1 -0
- package/dist/gateway/static/root/assets/models-hub-cache-za2fWJLg.js +1 -0
- package/dist/gateway/static/root/assets/monitor-Af5eAvF7.js +1 -0
- package/dist/gateway/static/root/assets/mouse-pointer-2-DZ51Onvj.js +1 -0
- package/dist/gateway/static/root/assets/navigation-BkjnOw30.js +1 -0
- package/dist/gateway/static/root/assets/network-BUQLY1BV.js +1 -0
- package/dist/gateway/static/root/assets/new-session-preferences-gb411vZP.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-DBs1yHLy.js +5 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-CivkB6LB.js +1 -0
- package/dist/gateway/static/root/assets/notes-api-C_458rv5.js +1 -0
- package/dist/gateway/static/root/assets/notes-page-DL3c-41a.js +8 -0
- package/dist/gateway/static/root/assets/number-input-El7Szeln.js +1 -0
- package/dist/gateway/static/root/assets/oauth-api-C3X9FLYw.js +1 -0
- package/dist/gateway/static/root/assets/oauth-authorization-window-o6URRos4.js +1 -0
- package/dist/gateway/static/root/assets/oauth-provider-connect-H81se_3n.js +1 -0
- package/dist/gateway/static/root/assets/package-wATCyihJ.js +1 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-BkAlQ7cB.js +1 -0
- package/dist/gateway/static/root/assets/page-context-draft-ClLgaOaD.js +1 -0
- package/dist/gateway/static/root/assets/page-header-store-DH8K0xii.js +1 -0
- package/dist/gateway/static/root/assets/page-tabs-oeTY7z3_.js +1 -0
- package/dist/gateway/static/root/assets/panel-left-C8MqSXRZ.js +1 -0
- package/dist/gateway/static/root/assets/panel-right-CFGrHTsD.js +1 -0
- package/dist/gateway/static/root/assets/paperclip-f1HujQY1.js +1 -0
- package/dist/gateway/static/root/assets/pause-DuPxgSxk.js +1 -0
- package/dist/gateway/static/root/assets/{pdf-D4PI9qAw.js → pdf-EQHMWEbX.js} +3 -3
- package/dist/gateway/static/root/assets/pdf-runtime-JnUAvfIa.js +2 -0
- package/dist/gateway/static/root/assets/{pdf.worker.min-B4E34YdZ.js → pdf.worker.min-bpyjgR8v.js} +7 -7
- package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +1 -0
- package/dist/gateway/static/root/assets/personal-avatar-BLtHt8fV.js +1 -0
- package/dist/gateway/static/root/assets/personal-avatar-BUCb7OiW.css +1 -0
- package/dist/gateway/static/root/assets/personal-page-B5DP3lO-.js +1 -0
- package/dist/gateway/static/root/assets/personal-proactivity-DaRnbB1f.js +1 -0
- package/dist/gateway/static/root/assets/personal-settings-panel-DjDc5Kaz.js +1 -0
- package/dist/gateway/static/root/assets/phone-dependencies-card-DISHarj8.js +1 -0
- package/dist/gateway/static/root/assets/phone-model-picker-u8YIQCgo.js +1 -0
- package/dist/gateway/static/root/assets/phone-settings-page-el3pT0PD.js +1 -0
- package/dist/gateway/static/root/assets/phone-workspace-store-fhnZrgy_.js +1 -0
- package/dist/gateway/static/root/assets/pin-off-BMRv-Kxr.js +1 -0
- package/dist/gateway/static/root/assets/play-kxZvpBg8.js +1 -0
- package/dist/gateway/static/root/assets/plug-DKYPEgkR.js +1 -0
- package/dist/gateway/static/root/assets/plug-zap-L8NMe3Sv.js +1 -0
- package/dist/gateway/static/root/assets/plugin-details-dialog-CTBs1Jde.js +1 -0
- package/dist/gateway/static/root/assets/plus-Q2yW6OE7.js +1 -0
- package/dist/gateway/static/root/assets/popover-select-DniHw2dy.js +1 -0
- package/dist/gateway/static/root/assets/power-ZI-pBczI.js +1 -0
- package/dist/gateway/static/root/assets/power-off-CwwQ7Gp7.js +1 -0
- package/dist/gateway/static/root/assets/preference-select-fields-D7oluyHN.js +1 -0
- package/dist/gateway/static/root/assets/preload-helper-Czpn1I53.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-CY_hjK4b.js +1 -0
- package/dist/gateway/static/root/assets/product-automation-feedback-DsUSqCOX.js +7 -0
- package/dist/gateway/static/root/assets/product-delivery-BU_H84jL.js +1 -0
- package/dist/gateway/static/root/assets/product-navigation-Co8pLbDP.js +1 -0
- package/dist/gateway/static/root/assets/product-open-page-xn9G4hSI.js +1 -0
- package/dist/gateway/static/root/assets/product-preview-content-DcoK-iZe.js +1 -0
- package/dist/gateway/static/root/assets/product-preview-modal-Ruw9WSKK.js +2 -0
- package/dist/gateway/static/root/assets/project-detail-page-BKvWLiMw.js +7 -0
- package/dist/gateway/static/root/assets/project-understanding-BCQr0AZ_.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-D4g7bB7X.js +1 -0
- package/dist/gateway/static/root/assets/providers-api-CzVkFKFg.js +1 -0
- package/dist/gateway/static/root/assets/puzzle-BptcPjKI.js +1 -0
- package/dist/gateway/static/root/assets/recording-upload-0jxahBMo.js +1 -0
- package/dist/gateway/static/root/assets/refresh-button-bU_0NarN.js +1 -0
- package/dist/gateway/static/root/assets/refresh-cw-BRlGaq2w.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BcfoLEna.js → registry-api-n8TwtJ_j.js} +2 -2
- package/dist/gateway/static/root/assets/remote-access-hub-cZpBi4Rk.js +1 -0
- package/dist/gateway/static/root/assets/rotate-ccw-JM1TBLpp.js +1 -0
- package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +1 -0
- package/dist/gateway/static/root/assets/route-preload-B5UiReO7.js +2 -0
- package/dist/gateway/static/root/assets/runtime-health-D2TDFLLq.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-DesqGCnE.js → runtime-tools-api-D-8KjYK6.js} +1 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-MKlLFuow.js +1 -0
- package/dist/gateway/static/root/assets/save-DRDABU--.js +1 -0
- package/dist/gateway/static/root/assets/schema-form-v4N4lawq.js +1 -0
- package/dist/gateway/static/root/assets/schemas-CCWMleym.js +55 -0
- package/dist/gateway/static/root/assets/search-DA7gz22f.js +1 -0
- package/dist/gateway/static/root/assets/secret-input-BQvFXqzz.js +1 -0
- package/dist/gateway/static/root/assets/secret-input-labels-B5Jl5HqK.js +1 -0
- package/dist/gateway/static/root/assets/segmented-styles-Cqb91xsn.js +1 -0
- package/dist/gateway/static/root/assets/send-1f1Ntw6E.js +1 -0
- package/dist/gateway/static/root/assets/server-BlHCBjiE.js +1 -0
- package/dist/gateway/static/root/assets/service-recommendation-list-B1xuVT3N.js +1 -0
- package/dist/gateway/static/root/assets/{session-api-DdQnMwkl.js → session-api-CsCoI2im.js} +1 -1
- package/dist/gateway/static/root/assets/session-channel-icon-SsY70Z6t.js +1 -0
- package/dist/gateway/static/root/assets/session-identity-label-B7sgG1PE.js +1 -0
- package/dist/gateway/static/root/assets/session-manager-5l9q0cd5.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-DsLw2aMD.js +1 -0
- package/dist/gateway/static/root/assets/settings-2-D-csvaET.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-B5lQeVNi.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-section-BqoVSko2.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-draft-Dy10ldo8.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-num14vSv.js +1 -0
- package/dist/gateway/static/root/assets/settings-loading-skeleton-BTqvr_Fw.js +1 -0
- package/dist/gateway/static/root/assets/settings-mode-store-CBsJ-Qg2.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-DROUGyJl.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-header-Bv-kQFTm.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-DHP6MrrL.js +1 -0
- package/dist/gateway/static/root/assets/settings-uiTATseT.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-MJE3B_LX.js +1 -0
- package/dist/gateway/static/root/assets/share-link-dialog-BJHRQVKC.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-Bsrv_zOQ.js +2 -0
- package/dist/gateway/static/root/assets/shares-api-rtWVHA_d.js +1 -0
- package/dist/gateway/static/root/assets/shares-settings-CfIRv4uX.js +1 -0
- package/dist/gateway/static/root/assets/shield-B1sI_cxl.js +1 -0
- package/dist/gateway/static/root/assets/shield-check-BU58siTV.js +1 -0
- package/dist/gateway/static/root/assets/shield-off-2jsucUds.js +1 -0
- package/dist/gateway/static/root/assets/side-chat-shortcut-BIw-1TTD.js +1 -0
- package/dist/gateway/static/root/assets/skill-api-B_W1K3sv.js +1 -0
- package/dist/gateway/static/root/assets/skill-api-utils-C7V4JVXM.js +1 -0
- package/dist/gateway/static/root/assets/skill-list-api-BzlKXPsE.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-Cff2GgZb.js +1 -0
- package/dist/gateway/static/root/assets/skill-wire-pattern-BPpeIcCi.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DtBloYeU.js +2 -0
- package/dist/gateway/static/root/assets/sliders-horizontal-DqsYor6I.js +1 -0
- package/dist/gateway/static/root/assets/sliding-tab-list-DuQyViqe.js +1 -0
- package/dist/gateway/static/root/assets/smartphone-DSSsQFqA.js +1 -0
- package/dist/gateway/static/root/assets/{source-workspace-editor-BIvi89Zx.js → source-workspace-editor-kxosllTu.js} +1 -1
- package/dist/gateway/static/root/assets/sparkles-DHlfQFAF.js +1 -0
- package/dist/gateway/static/root/assets/specialists-xbB3xL9e.js +1 -0
- package/dist/gateway/static/root/assets/square-DMK_fB-3.js +1 -0
- package/dist/gateway/static/root/assets/square-pen-B8FsvqNu.js +1 -0
- package/dist/gateway/static/root/assets/square-terminal-K87bylpZ.js +1 -0
- package/dist/gateway/static/root/assets/star-BUWJqJ5c.js +1 -0
- package/dist/gateway/static/root/assets/stethoscope-DRqTAtjD.js +1 -0
- package/dist/gateway/static/root/assets/sticky-note-fzP7NAJq.js +1 -0
- package/dist/gateway/static/root/assets/store-SzD1Jvgm.js +1 -0
- package/dist/gateway/static/root/assets/system-settings-panel-BeQeUUMH.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-Drrv-Hp0.js +2 -0
- package/dist/gateway/static/root/assets/task-result-evidence-D1Kyskm_.js +1 -0
- package/dist/gateway/static/root/assets/tasks-DRmd6sWt.js +1 -0
- package/dist/gateway/static/root/assets/terminal-oKqqZdiG.js +1 -0
- package/dist/gateway/static/root/assets/terminal-panel-store-5Fzctajw.js +1 -0
- package/dist/gateway/static/root/assets/theme-store-DW45fWYQ.js +1 -0
- package/dist/gateway/static/root/assets/timer-rCwGHjuO.js +1 -0
- package/dist/gateway/static/root/assets/tool-friendly-title-DGmi7rCQ.js +1 -0
- package/dist/gateway/static/root/assets/tracing-settings-page-B12u5D9A.js +1 -0
- package/dist/gateway/static/root/assets/trash-2-DusmjVPV.js +1 -0
- package/dist/gateway/static/root/assets/triangle-alert-2JXFNNKU.js +1 -0
- package/dist/gateway/static/root/assets/tunnel-api-DGO56LQU.js +1 -0
- package/dist/gateway/static/root/assets/understanding-activity-store-CTe6TFB0.js +1 -0
- package/dist/gateway/static/root/assets/understanding-refresh-store-mE9OKG6q.js +1 -0
- package/dist/gateway/static/root/assets/unlink-BEuthaaq.js +1 -0
- package/dist/gateway/static/root/assets/upload-rrb46c3c.js +1 -0
- package/dist/gateway/static/root/assets/usage-page-Ud2U9UG1.js +1 -0
- package/dist/gateway/static/root/assets/use-async-resource-BHFGZCY2.js +1 -0
- package/dist/gateway/static/root/assets/use-autosave-Cs2Ga_Y_.js +1 -0
- package/dist/gateway/static/root/assets/use-composer-attachments-BCbMj-MN.js +2 -0
- package/dist/gateway/static/root/assets/use-directory-picker-C4p7AgWY.js +1 -0
- package/dist/gateway/static/root/assets/use-file-preview-expanded-DSpCRXUW.js +2 -0
- package/dist/gateway/static/root/assets/use-media-query-ady-FgjK.js +1 -0
- package/dist/gateway/static/root/assets/use-personal-profile-BHL2AxWU.js +1 -0
- package/dist/gateway/static/root/assets/use-workspace-tree-CnmPZrpx.js +1 -0
- package/dist/gateway/static/root/assets/user-model-page-p5iPfnwl.js +2 -0
- package/dist/gateway/static/root/assets/user-round-C9jxPhMR.js +1 -0
- package/dist/gateway/static/root/assets/{vendor-codemirror-Qdcjid65.js → vendor-codemirror-aCQ0FcJT.js} +8 -8
- package/dist/gateway/static/root/assets/{vendor-swr-BIWyz7Rc.js → vendor-swr-CdRzEUwF.js} +1 -1
- package/dist/gateway/static/root/assets/video-B6V0GFss.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-3gyc2UV3.js +1 -0
- package/dist/gateway/static/root/assets/voice-call-context-BM2A4bLz.js +1 -0
- package/dist/gateway/static/root/assets/{voice-config-api-BkUlN7GH.js → voice-config-api-Cda2uBIC.js} +1 -1
- package/dist/gateway/static/root/assets/voice-input-shortcut-events-DtYHsPLF.js +1 -0
- package/dist/gateway/static/root/assets/voice-transcribe-api-TInEfIYo.js +1 -0
- package/dist/gateway/static/root/assets/volume-2-BSJhAY97.js +1 -0
- package/dist/gateway/static/root/assets/wand-sparkles-CkSL-3Fy.js +1 -0
- package/dist/gateway/static/root/assets/{with-selector-aYPsXwdl.js → with-selector-xonYxPoM.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-Dqu5CQCS.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-p-8ciZ0i.js +1 -0
- package/dist/gateway/static/root/assets/working-directory-picker-modal-DHl2cZY1.js +1 -0
- package/dist/gateway/static/root/assets/workspace-api-CtDbI6T7.js +2 -0
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-B94Q2nN8.js +1 -0
- package/dist/gateway/static/root/assets/workspace-file-preview-dialog-CTIbUfKb.js +1 -0
- package/dist/gateway/static/root/assets/workspace-open-location-menu-BwxouqdZ.js +1 -0
- package/dist/gateway/static/root/assets/wrench-DFb4r8bH.js +1 -0
- package/dist/gateway/static/root/assets/x-B_N4OPjy.js +1 -0
- package/dist/gateway/static/root/assets/{xlsx-CKkngM-o.js → xlsx-Cl_0CZaL.js} +11 -11
- package/dist/gateway/static/root/assets/xml-_d7dTN2Q.js +3 -0
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-CFb-23rS.js +1 -0
- package/dist/gateway/static/root/assets/zap-dximCGjy.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 +267 -46
- 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/activity/emitter.js +1 -2
- package/dist/src/activity/service.js +1 -2
- package/dist/src/agent/agent-manager.d.ts +5 -0
- package/dist/src/agent/agent-manager.js +16 -6
- package/dist/src/agent/background-review/run-background-review.js +2 -3
- package/dist/src/agent/context/execution-context.js +1 -2
- package/dist/src/agent/context/execution-scope.js +1 -2
- package/dist/src/agent/context/project-context.js +1 -2
- package/dist/src/agent/embedded/agent-profile-context.js +1 -2
- package/dist/src/agent/embedded/run-turn.js +2 -4
- package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js +1 -2
- package/dist/src/agent/embedded/tool-search-extension.js +14 -1
- package/dist/src/agent/external-tools/cliProvider.js +3 -4
- package/dist/src/agent/external-tools/composio-provider.js +3 -4
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/memory/compaction-promotion.js +1 -2
- package/dist/src/agent/orchestration/research-checkpoint.js +26 -31
- package/dist/src/agent/prompt/response-language.js +1 -2
- package/dist/src/agent/prompt/service-prompt-builder.js +3 -6
- package/dist/src/agent/prompt/system-prompt.js +1 -2
- package/dist/src/agent/service/direct-turn-helpers.js +1 -2
- package/dist/src/agent/service/process-direct-streaming.js +1 -2
- package/dist/src/agent/service/webchat-tts.js +1 -2
- package/dist/src/agent/service.d.ts +1 -0
- package/dist/src/agent/service.js +8 -3
- package/dist/src/agent/service.types.d.ts +3 -0
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
- package/dist/src/agent/tool-manuals/computer.js +2 -0
- package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
- package/dist/src/agent/tool-manuals/phone.js +14 -4
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +2 -0
- package/dist/src/agent/tool-manuals/xopc-configuration.js +29 -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/delegate-tool.js +2 -4
- package/dist/src/agent/tools/factory.d.ts +4 -0
- package/dist/src/agent/tools/factory.js +23 -9
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/personal-task-tool.js +1 -2
- package/dist/src/agent/tools/phone-use-tool.d.ts +2 -0
- package/dist/src/agent/tools/phone-use-tool.js +79 -4
- package/dist/src/agent/tools/research-checkpoint-tool.js +1 -2
- 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 +5 -2
- package/dist/src/agent/tools/xopc-use-tool.js +47 -6
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/repository.js +3 -4
- package/dist/src/agent-catalog/test-support.js +1 -2
- package/dist/src/agent-matching/selection-repository.js +1 -2
- package/dist/src/automations/capabilities/drafts.js +3 -5
- package/dist/src/bootstrap/application-state.js +1 -2
- package/dist/src/browser/automations/repository.js +1 -2
- 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/native-messaging-host.js +2 -4
- package/dist/src/browser/providers/browser-ext-install.js +3 -2
- package/dist/src/browser/providers/realtime-extension.js +1 -2
- package/dist/src/browser/recordings/service.js +1 -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 +157 -0
- package/dist/src/browser/setup/service.js +433 -0
- package/dist/src/browser/setup/types.d.ts +38 -0
- package/dist/src/browser/setup/types.js +1 -0
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-previews/store.js +1 -2
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/automation-integrity.js +1 -2
- package/dist/src/cli/commands/doctor/checks/database-relations.js +1 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +2 -3
- package/dist/src/cli/commands/doctor/checks/node-version.js +6 -6
- package/dist/src/cli/commands/doctor/checks/session-integrity.js +1 -2
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/gateway/shared.js +1 -2
- package/dist/src/cli/commands/history.js +1 -2
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/commands/project.js +1 -2
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/diagnostics.d.ts +7 -7
- package/dist/src/computer/diagnostics.js +8 -2
- package/dist/src/computer/errors.js +9 -1
- package/dist/src/computer/evaluation.d.ts +4 -4
- package/dist/src/computer/keyboard.d.ts +1 -1
- package/dist/src/computer/keyboard.js +10 -2
- package/dist/src/computer/model-adapter.js +27 -7
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/gateway-bind.js +1 -2
- package/dist/src/config/schema.d.ts +7 -0
- package/dist/src/connectors/cli/lifecycle.js +1 -2
- package/dist/src/connectors/composio-managed-events.js +1 -2
- package/dist/src/connectors/connected-source-ingestion.js +1 -2
- package/dist/src/connectors/connected-source-understanding.js +3 -5
- package/dist/src/connectors/content-enrichment.js +1 -2
- package/dist/src/connectors/learning-coordinator.js +2 -3
- package/dist/src/connectors/runtime-adapter-registry.js +1 -2
- package/dist/src/daemon/constants.js +9 -14
- package/dist/src/daemon/index.js +1 -4
- package/dist/src/daemon/install-plan.js +1 -2
- package/dist/src/daemon/launchd.js +1 -2
- package/dist/src/daemon/schtasks.js +1 -2
- package/dist/src/daemon/service-audit.js +1 -2
- package/dist/src/daemon/service.js +1 -2
- package/dist/src/daemon/systemd.js +1 -2
- package/dist/src/discussions/analyzer.d.ts +3 -3
- package/dist/src/endpoint-tools/runtime.js +1 -2
- package/dist/src/execution-environments/local-worktree-manager.js +1 -1
- package/dist/src/execution-environments/subject.js +1 -2
- package/dist/src/extensions/agent-plugins/branding.js +2 -1
- package/dist/src/extensions/agent-plugins/cli-authorization.js +2 -1
- package/dist/src/extensions/agent-plugins/contained-path.d.ts +1 -0
- package/dist/src/extensions/agent-plugins/contained-path.js +29 -0
- package/dist/src/extensions/agent-plugins/mcp-adapter.js +2 -1
- package/dist/src/extensions/agent-plugins/resources.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +3 -2
- package/dist/src/extensions/agent-plugins/source-catalog.js +1 -1
- package/dist/src/extensions/agent-plugins/store.js +2 -1
- package/dist/src/extensions/agent-plugins/validation.d.ts +1 -2
- package/dist/src/extensions/agent-plugins/validation.js +3 -26
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/client-ip.js +1 -2
- package/dist/src/gateway/file-space-service.js +1 -2
- package/dist/src/gateway/global-defaults-admin.js +1 -1
- package/dist/src/gateway/hono/app.js +2 -4
- package/dist/src/gateway/hono/middleware/auth.js +3 -6
- package/dist/src/gateway/hono/middleware/logger.js +1 -2
- package/dist/src/gateway/hono/middleware/public-device-rate-limit.js +1 -2
- package/dist/src/gateway/hono/middleware/scopes.js +1 -2
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +1 -2
- package/dist/src/gateway/hono/oauth-async.js +1 -2
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/browser-session.js +1 -2
- 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 +4 -7
- package/dist/src/gateway/hono/routes/cli-connectors.js +1 -2
- package/dist/src/gateway/hono/routes/composer-history.js +1 -2
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -2
- package/dist/src/gateway/hono/routes/connectors.js +9 -11
- package/dist/src/gateway/hono/routes/context-sources.js +1 -2
- package/dist/src/gateway/hono/routes/device-pairing-approval.js +2 -4
- package/dist/src/gateway/hono/routes/device-push.js +1 -2
- package/dist/src/gateway/hono/routes/devices.js +4 -8
- package/dist/src/gateway/hono/routes/discussions.js +1 -2
- package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -2
- package/dist/src/gateway/hono/routes/home.js +2 -3
- package/dist/src/gateway/hono/routes/interaction-state.js +1 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/memory-learning.js +1 -2
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/personal-agent.js +1 -2
- package/dist/src/gateway/hono/routes/phone-dependencies.js +2 -7
- package/dist/src/gateway/hono/routes/phone-setup.d.ts +7 -0
- package/dist/src/gateway/hono/routes/phone-setup.js +231 -0
- package/dist/src/gateway/hono/routes/phone-wireless.d.ts +4 -0
- package/dist/src/gateway/hono/routes/phone-wireless.js +63 -0
- package/dist/src/gateway/hono/routes/phone.js +119 -28
- package/dist/src/gateway/hono/routes/projects.js +3 -4
- package/dist/src/gateway/hono/routes/public-gateway.js +4 -3
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +2 -4
- package/dist/src/gateway/hono/routes/shares.js +2 -4
- package/dist/src/gateway/hono/routes/tasks.js +2 -3
- package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -2
- package/dist/src/gateway/hono/routes/user-model.js +1 -2
- package/dist/src/gateway/host.js +4 -9
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/index.js +2 -6
- package/dist/src/gateway/listen.js +1 -2
- package/dist/src/gateway/next-turn-suggestions/service.js +1 -2
- package/dist/src/gateway/next-turn-suggestions/snapshot.js +1 -2
- package/dist/src/gateway/provider-model-setup.js +1 -1
- package/dist/src/gateway/rate-limit/auth-policy.js +11 -7
- package/dist/src/gateway/rate-limit/buckets.js +220 -211
- package/dist/src/gateway/rate-limit/env-flags.js +1 -4
- package/dist/src/gateway/rate-limit/index.js +4 -13
- package/dist/src/gateway/runtime-config.js +2 -4
- package/dist/src/gateway/security/audit.js +1 -2
- package/dist/src/gateway/security/browser-session.js +1 -2
- package/dist/src/gateway/security/device-request-proof.d.ts +1 -2
- package/dist/src/gateway/security/device-request-proof.js +2 -4
- package/dist/src/gateway/security/gateway-scopes.js +2 -6
- package/dist/src/gateway/security/index.js +1 -4
- package/dist/src/gateway/security/loopback.js +6 -7
- package/dist/src/gateway/service/agent-runner.js +2 -4
- package/dist/src/gateway/service/app-context-access.js +1 -2
- package/dist/src/gateway/service/config-coordinator.d.ts +4 -0
- package/dist/src/gateway/service/run-gateway-agent.js +2 -4
- package/dist/src/gateway/service/session-input-coordinator.js +3 -6
- package/dist/src/gateway/service.d.ts +5 -0
- package/dist/src/gateway/service.js +64 -22
- package/dist/src/gateway/session-context-summary.js +2 -4
- package/dist/src/gateway/tailscale-auth.js +1 -2
- package/dist/src/gateway/ws-security.js +1 -2
- package/dist/src/gateway/xopc-cloud-capability-setup.js +8 -2
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/imports/importService.js +1 -1
- package/dist/src/infra/rate-limit/failure-limiter.js +90 -78
- package/dist/src/infra/rate-limit/index.js +3 -11
- package/dist/src/infra/rate-limit/keyed-store.js +47 -52
- package/dist/src/infra/rate-limit/rate-limiter.js +58 -55
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-service-refresh.js +1 -2
- package/dist/src/knowledge/chunks.js +1 -4
- package/dist/src/knowledge/connected-knowledge-pipeline.js +3 -6
- package/dist/src/knowledge/ingestion-service.js +1 -2
- package/dist/src/knowledge-memory/repository.js +1 -2
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/local-apps/store.js +1 -2
- package/dist/src/media/session-references.js +1 -2
- package/dist/src/memory-learning/forget-capture.js +1 -2
- package/dist/src/memory-learning/forgotten-history.js +3 -6
- package/dist/src/memory-learning/service.js +1 -2
- package/dist/src/memory-learning/source-learning.js +3 -3
- package/dist/src/memory-learning/task-receipts.js +1 -2
- package/dist/src/memory-learning/work-candidate.d.ts +29 -0
- package/dist/src/memory-learning/work-candidate.js +31 -0
- package/dist/src/memory-learning/work-capture.d.ts +2 -29
- package/dist/src/memory-learning/work-capture.js +2 -30
- package/dist/src/memory-maintenance/service.js +1 -2
- package/dist/src/notes/agent-context.js +1 -2
- package/dist/src/notes/attachment-ref.js +4 -8
- package/dist/src/notes/note-attachment-sync.js +1 -2
- package/dist/src/notes/note-index-meta.js +7 -14
- package/dist/src/notes/note-markdown.js +7 -13
- package/dist/src/notes/service.js +3 -6
- package/dist/src/notes/store.js +2 -4
- package/dist/src/notifications/clarification.js +1 -2
- package/dist/src/notifications/service.js +1 -2
- package/dist/src/personal-agent/proactivity/repository.js +1 -2
- package/dist/src/personal-agent/proactivity/service.js +1 -2
- package/dist/src/personal-agent/prompt-context.js +1 -2
- package/dist/src/personal-agent/reply-composer.js +4 -5
- package/dist/src/personal-agent/repository.js +1 -2
- package/dist/src/personal-agent/request-delivery.js +1 -2
- package/dist/src/personal-agent/result-extraction.js +71 -71
- package/dist/src/personal-agent/service.js +2 -3
- package/dist/src/phone/adb-command.d.ts +1 -0
- package/dist/src/phone/adb-command.js +12 -0
- package/dist/src/phone/adb-driver.d.ts +6 -2
- package/dist/src/phone/adb-driver.js +45 -21
- package/dist/src/phone/cloud-adb-connection.d.ts +34 -0
- package/dist/src/phone/cloud-adb-connection.js +324 -0
- package/dist/src/phone/cloud-adb-writable.d.ts +3 -0
- package/dist/src/phone/cloud-adb-writable.js +21 -0
- package/dist/src/phone/cloud-adb.d.ts +3 -32
- package/dist/src/phone/cloud-adb.js +3 -259
- package/dist/src/phone/cloud-key-permissions.d.ts +2 -0
- package/dist/src/phone/cloud-key-permissions.js +66 -0
- package/dist/src/phone/cloud-phones.js +2 -1
- package/dist/src/phone/cloud-scrcpy.d.ts +1 -1
- package/dist/src/phone/cloud-scrcpy.js +3 -2
- package/dist/src/phone/contracts.d.ts +197 -1
- package/dist/src/phone/contracts.js +55 -6
- package/dist/src/phone/foreground.d.ts +1 -0
- package/dist/src/phone/foreground.js +18 -0
- package/dist/src/phone/live-state.d.ts +2 -0
- package/dist/src/phone/live-state.js +5 -0
- package/dist/src/phone/model-adapter.d.ts +65 -4
- package/dist/src/phone/model-adapter.js +157 -48
- 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 +2 -2
- package/dist/src/phone/reliability.js +19 -6
- package/dist/src/phone/repository.d.ts +4 -1
- package/dist/src/phone/repository.js +12 -1
- package/dist/src/phone/runtime.d.ts +79 -3
- package/dist/src/phone/runtime.js +861 -93
- package/dist/src/phone/scrcpy.js +3 -2
- 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 +101 -0
- package/dist/src/phone/setup/service.js +296 -0
- package/dist/src/phone/task-feedback.d.ts +4 -0
- package/dist/src/phone/task-feedback.js +47 -0
- package/dist/src/phone/ui-dump-binary.d.ts +1 -0
- package/dist/src/phone/ui-dump-binary.js +4 -0
- package/dist/src/phone/wireless.d.ts +80 -0
- package/dist/src/phone/wireless.js +244 -0
- package/dist/src/projects/capabilities/write.js +1 -2
- package/dist/src/projects/project-service.js +1 -2
- package/dist/src/projects/workspace.js +1 -2
- package/dist/src/providers/presentation.js +2 -2
- package/dist/src/providers/xopc-cloud-model-source.js +6 -2
- package/dist/src/realtime/runtime.d.ts +3 -0
- package/dist/src/realtime/runtime.js +16 -3
- package/dist/src/remote-access/exposure-guards.js +1 -2
- package/dist/src/runtime-tools/archive.js +1 -1
- package/dist/src/runtime-tools/catalog.d.ts +1 -1
- package/dist/src/runtime-tools/catalog.js +2 -2
- package/dist/src/session/config-store.js +1 -2
- package/dist/src/session/init-session-turn.js +1 -2
- package/dist/src/session/resolve-session.js +1 -2
- package/dist/src/session/store.js +2 -4
- package/dist/src/share/share-rate-limit.js +1 -2
- package/dist/src/share/share-url.js +1 -2
- package/dist/src/share/site-share-router.js +1 -2
- package/dist/src/storage/sqlite/activity-repository.js +2 -6
- package/dist/src/storage/sqlite/browser-tab-binding-repository.js +2 -6
- package/dist/src/storage/sqlite/clarification-wait-repository.js +9 -14
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +3 -8
- package/dist/src/storage/sqlite/composer-input-history-repository.js +3 -8
- package/dist/src/storage/sqlite/config-repository.js +5 -9
- package/dist/src/storage/sqlite/connector-learning-repository.js +2 -6
- package/dist/src/storage/sqlite/connector-sync-policy-repository.js +2 -6
- package/dist/src/storage/sqlite/context-evidence-repository.js +3 -8
- package/dist/src/storage/sqlite/context-extraction-repository.js +3 -8
- package/dist/src/storage/sqlite/device-access-repository.js +16 -23
- package/dist/src/storage/sqlite/device-pairing-approval.js +2 -6
- package/dist/src/storage/sqlite/device-pairing-repository.js +5 -10
- package/dist/src/storage/sqlite/endpoint-principal-repository.js +2 -6
- package/dist/src/storage/sqlite/endpoint-session-binding-repository.js +2 -6
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +2 -6
- package/dist/src/storage/sqlite/gateway-identity-repository.js +2 -6
- package/dist/src/storage/sqlite/home-attention-repository.js +2 -6
- package/dist/src/storage/sqlite/index.js +40 -72
- package/dist/src/storage/sqlite/interaction-state-repository.js +4 -10
- package/dist/src/storage/sqlite/knowledge-repository.js +3 -8
- package/dist/src/storage/sqlite/note-agent-context-repository.js +2 -6
- package/dist/src/storage/sqlite/notes-repository.js +4 -9
- package/dist/src/storage/sqlite/research-checkpoint-repository.js +3 -8
- package/dist/src/storage/sqlite/schema.d.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +7 -7
- package/dist/src/storage/sqlite/schema.sql +10 -0
- package/dist/src/storage/sqlite/session-creation-repository.js +2 -4
- package/dist/src/storage/sqlite/session-task-plan-repository.js +9 -14
- package/dist/src/storage/sqlite/session-turn-replace-repository.js +5 -9
- package/dist/src/storage/sqlite/sidebar-layout-repository.js +9 -14
- package/dist/src/storage/sqlite/transcript-repository.js +6 -10
- package/dist/src/storage/sqlite/upgrades/260_browser_setup.sql +9 -0
- package/dist/src/storage/sqlite/user-people-repository.js +3 -8
- package/dist/src/storage/sqlite/user-trust-repository.js +4 -9
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.js +1 -1
- package/dist/src/tasks/execution-context.js +1 -2
- package/dist/src/tasks/home-query-service.js +1 -2
- package/dist/src/tasks/task-allocation-repository.js +1 -2
- package/dist/src/tasks/task-context-assembler.js +1 -2
- package/dist/src/tasks/task-handoff.js +2 -4
- package/dist/src/tasks/task-instruction-sequence.d.ts +1 -0
- package/dist/src/tasks/task-instruction-sequence.js +7 -0
- package/dist/src/tasks/task-language.js +1 -2
- package/dist/src/tasks/task-research-result.d.ts +1 -2
- package/dist/src/tasks/task-research-result.js +1 -3
- package/dist/src/tasks/task-result-delivery-repository.js +1 -1
- package/dist/src/tasks/task-result-delivery-service.js +3 -3
- package/dist/src/tasks/task-run-coordinator.js +3 -3
- package/dist/src/tasks/task-run-dispatcher.js +1 -2
- package/dist/src/tasks/task-value-metrics-service.js +1 -2
- package/dist/src/tui/backends/embedded-backend.js +2 -3
- package/dist/src/tui/tui-commands.js +1 -2
- package/dist/src/tunnel/registration-proof.js +1 -2
- package/dist/src/tunnel/tunnel-rate-limit.js +1 -2
- package/dist/src/user-context/access-policy.js +1 -2
- package/dist/src/user-context/domain.js +13 -18
- package/dist/src/user-context/extraction/registry.js +1 -2
- package/dist/src/user-context/interaction-state.js +1 -4
- package/dist/src/user-context/relationship-continuity.js +1 -2
- package/dist/src/user-context/sources/consent-repository.js +1 -2
- package/dist/src/user-context/sources/index.js +1 -1
- package/dist/src/user-context/trust-policy.js +8 -13
- package/dist/src/user-model/action-rule-suggestions.js +1 -2
- package/dist/src/user-model/bootstrap.js +1 -2
- package/dist/src/user-model/capture/executor.js +2 -4
- package/dist/src/user-model/capture/semantic.d.ts +1 -1
- package/dist/src/user-model/capture/semantic.js +1 -1
- package/dist/src/user-model/domain.js +30 -35
- package/dist/src/user-model/goals.js +1 -2
- package/dist/src/user-model/index.js +1 -4
- package/dist/src/user-model/observation-repository.js +1 -2
- package/dist/src/user-model/repository.js +1 -2
- package/dist/src/user-model/usage-policy.js +1 -2
- package/dist/src/voice/realtime/memory-context.js +1 -2
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/work-discovery/service.js +4 -6
- package/package.json +8 -8
- package/skills/tools/configure-xopc/SKILL.md +54 -0
- package/skills/tools/configure-xopc/references/browser/acceptance.md +32 -0
- package/skills/tools/configure-xopc/references/browser/chrome-extension.md +23 -0
- package/skills/tools/configure-xopc/references/browser/overview.md +19 -0
- package/skills/tools/configure-xopc/references/browser/permissions.md +23 -0
- package/skills/tools/configure-xopc/references/browser/troubleshooting.md +24 -0
- package/skills/tools/configure-xopc/references/phone/acceptance.md +27 -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 +21 -0
- package/skills/tools/configure-xopc/references/phone/overview.md +25 -0
- package/skills/tools/configure-xopc/references/phone/troubleshooting.md +27 -0
- package/skills/tools/configure-xopc/references/scene-index.md +12 -0
- package/dist/gateway/static/root/assets/agent-avatar-dicebear-CJFwitU2.js +0 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DclyJr1N.js +0 -1
- package/dist/gateway/static/root/assets/agents-jhErNtzi.js +0 -77
- package/dist/gateway/static/root/assets/app-management-settings-panel-DgwqNi5i.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-C0wJfFyz.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-C0LcnI4h.js +0 -1
- package/dist/gateway/static/root/assets/automation-display-BFN7zWBg.js +0 -2
- package/dist/gateway/static/root/assets/automations-workspace-CBxiV34x.js +0 -8
- package/dist/gateway/static/root/assets/browser-automations-page-vJIrTxdi.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-in5Roh_E.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-BlxF36t-.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-CiGx8wpQ.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-a8kqjzQu.js +0 -8
- package/dist/gateway/static/root/assets/capability-header-actions-D4Yq35fD.js +0 -1
- package/dist/gateway/static/root/assets/channels-C_CxcjKT.js +0 -1
- package/dist/gateway/static/root/assets/chat-terminal-dock-zdMySdMm.js +0 -36
- package/dist/gateway/static/root/assets/chunk-KS7C4IRE-BvcCCgTW.js +0 -4
- package/dist/gateway/static/root/assets/cloud-credits-BMYMiiNn.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-C5Z6Jr0p.js +0 -1
- package/dist/gateway/static/root/assets/connector-service-page-Cxus0qrZ.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DCBO2CxK.js +0 -1
- package/dist/gateway/static/root/assets/constants-DeXt1mV-.js +0 -1
- package/dist/gateway/static/root/assets/date-picker-DuyyD6jz.js +0 -1
- package/dist/gateway/static/root/assets/dependency-picker-BZN72rrk.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-BtvTIDCi.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-BcyP7Z6v.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-Ctbgr50F.js +0 -1
- package/dist/gateway/static/root/assets/directory-picker-path-field-DOusKz-O.js +0 -1
- package/dist/gateway/static/root/assets/dist-C3DSFZCi.js +0 -1
- package/dist/gateway/static/root/assets/dist-CI_fqRk-.js +0 -1
- package/dist/gateway/static/root/assets/docx-preview-CajIk2FR.js +0 -20
- package/dist/gateway/static/root/assets/echarts-runtime-tcHc9TOS.js +0 -18
- package/dist/gateway/static/root/assets/electron-env-Dit0bHgy.js +0 -1
- package/dist/gateway/static/root/assets/extension-debug-page-Bt4FwsFu.js +0 -1
- package/dist/gateway/static/root/assets/extension-page-0vsxX3FB.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-5Pt5_ELc.js +0 -1
- package/dist/gateway/static/root/assets/files-Bw4SBGdM.js +0 -1
- package/dist/gateway/static/root/assets/floating-ui.dom-B7uQOZZW.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-DkWCHVzI.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-Bx9KCID-.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-BsVOcmV5.js +0 -1
- package/dist/gateway/static/root/assets/highlight-code-C8eS9949.js +0 -1
- package/dist/gateway/static/root/assets/highlighted-body-KQOG7T2V-Cbk7eMlg.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BZDZnmyc.js +0 -2
- package/dist/gateway/static/root/assets/image-generation-api-CAS8QVla.js +0 -1
- package/dist/gateway/static/root/assets/imports-page-BCLBYzV1.js +0 -1
- package/dist/gateway/static/root/assets/index-Bys6njTY.js +0 -710
- package/dist/gateway/static/root/assets/index-Vsf0bj5e.css +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CM_kt5XN.js +0 -1
- package/dist/gateway/static/root/assets/languages-byq_L2Ae.js +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-Dk87jtcc.js +0 -1
- package/dist/gateway/static/root/assets/local-apps-page-BTSOChhk.js +0 -1
- package/dist/gateway/static/root/assets/local-apps-yys1VChX.js +0 -1
- package/dist/gateway/static/root/assets/local-session-drafts-iGX_6O0O.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-D3gVdm8S.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-BQNYFE4J.js +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-ChweJKTv.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CYKwUCte.js +0 -5
- package/dist/gateway/static/root/assets/note-image-lightbox-BTSZb9ZT.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-CJ5nhWfL.js +0 -8
- package/dist/gateway/static/root/assets/number-input-DDeqHK-G.js +0 -1
- package/dist/gateway/static/root/assets/page-context-capture-button-DVn_dU83.js +0 -1
- package/dist/gateway/static/root/assets/pdf-runtime-DU_sMPjG.js +0 -2
- package/dist/gateway/static/root/assets/personal-page-DcW14lqn.js +0 -1
- package/dist/gateway/static/root/assets/personal-proactivity-BJcZ3Yhi.js +0 -1
- package/dist/gateway/static/root/assets/personal-settings-panel-C16Iqe7X.js +0 -1
- package/dist/gateway/static/root/assets/phone-dependencies-card-D3l9uPFM.js +0 -1
- package/dist/gateway/static/root/assets/phone-model-picker-DOv38vBn.js +0 -1
- package/dist/gateway/static/root/assets/phone-settings-page-DUHp1q_9.js +0 -1
- package/dist/gateway/static/root/assets/plugin-details-dialog-BpfgDlVa.js +0 -1
- package/dist/gateway/static/root/assets/popover-select-DGKUpVsz.js +0 -1
- package/dist/gateway/static/root/assets/preload-helper-zJ_50EbN.js +0 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-RlHk76TI.js +0 -1
- package/dist/gateway/static/root/assets/product-delivery-BqNm-8S5.js +0 -1
- package/dist/gateway/static/root/assets/product-open-page-Dh-HqLrE.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-content-c3K-4DWc.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-GD8TxKad.js +0 -7
- package/dist/gateway/static/root/assets/projects-page-B8HAt9sD.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-D3el7lHK.js +0 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Dbskk6RG.js +0 -1
- package/dist/gateway/static/root/assets/schema-form-CXO1B1k4.js +0 -1
- package/dist/gateway/static/root/assets/schemas-CObaziC7.js +0 -64
- package/dist/gateway/static/root/assets/session-manager-CA1NkTR_.js +0 -16
- package/dist/gateway/static/root/assets/sessions-page-07liaSHH.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BGjU8rfN.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-BQxKmbbJ.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-DvVMpKiA.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-header-CYpuTXUW.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-layout-B20AfmFG.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DKo_VTx-.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-XgZk8Oa1.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-BODFqK8k.js +0 -1
- package/dist/gateway/static/root/assets/skill-api-CV-WT2hj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Ce6OUk2C.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-B7ehOIML.js +0 -2
- package/dist/gateway/static/root/assets/specialists-4bkS5rZ4.js +0 -1
- package/dist/gateway/static/root/assets/system-settings-panel-CxJkZRT4.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CxRR0QuW.js +0 -2
- package/dist/gateway/static/root/assets/task-result-evidence-D-gGKNX9.js +0 -1
- package/dist/gateway/static/root/assets/tasks-TVRjEggr.js +0 -1
- package/dist/gateway/static/root/assets/tracing-settings-page-CQw3G-FB.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-B2HnCi0U.js +0 -1
- package/dist/gateway/static/root/assets/usage-page-uUEkO38r.js +0 -1
- package/dist/gateway/static/root/assets/use-autosave-Dc0nwUpX.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-ICUutbKL.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-BSWXZkGa.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-H3cdwq3l.js +0 -1
- package/dist/gateway/static/root/assets/xopc-cloud-account-card-CvT_W6YS.js +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-CdRzEUwF.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{f as a,l as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as u}from"./arrow-right-DSSvoX71.js";import{t as d}from"./arrow-up-right-T72JbQ1Q.js";import{t as f}from"./chevron-right-BweFrslA.js";import{n as p,r as m,t as h}from"./popover-select-DniHw2dy.js";import{t as g}from"./circle-check-C23XjkUj.js";import{C as _,D as v,E as y,O as b,S as x,T as S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,m as N,n as P,o as F,p as I,r as L,s as R,t as z,u as B,v as V,w as ee,x as te,y as H}from"./connected-providers-grid-Dmnu2zle.js";import{t as U}from"./cloud-C4-yfnnk.js";import{t as W}from"./external-link-DjqjBmc3.js";import{t as G}from"./secret-input-BQvFXqzz.js";import{t as ne}from"./eye-CABVeTq0.js";import{t as K}from"./image-Cwyalflz.js";import{t as re}from"./key-round-DWbpyU2U.js";import{t as q}from"./loader-circle-CifKLtgG.js";import{t as ie}from"./mic-CuUb7zc-.js";import{t as J}from"./pencil-DmIY3Oa-.js";import{t as ae}from"./play-kxZvpBg8.js";import{t as oe}from"./plug-DKYPEgkR.js";import{t as se}from"./plus-Q2yW6OE7.js";import{t as ce}from"./refresh-cw-BRlGaq2w.js";import{t as le}from"./settings-2-D-csvaET.js";import{t as ue}from"./shield-check-BU58siTV.js";import{t as de}from"./sliders-horizontal-DqsYor6I.js";import{t as fe}from"./square-DMK_fB-3.js";import{t as pe}from"./trash-2-DusmjVPV.js";import{t as me}from"./triangle-alert-2JXFNNKU.js";import{t as he}from"./volume-2-BSJhAY97.js";import{t as ge}from"./wrench-DFb4r8bH.js";import{t as _e}from"./x-B_N4OPjy.js";import{t as ve}from"./messages-DRR9N3HC.js";import{t as Y}from"./cn-0WouolD0.js";import{a as ye,i as be,l as xe,n as Se,o as Ce}from"./locale-store-lIXD1FMw.js";import{i as X}from"./vendor-swr-CdRzEUwF.js";import{t as Z}from"./button-CnRSIP6m.js";import{t as we}from"./skeleton-BI5TyibZ.js";import{a as Te,i as Ee,n as De,o as Oe,r as ke,s as Ae,t as je}from"./dist-DfWfZ9iu.js";import{i as Me,o as Ne}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{d as Pe,f as Fe,i as Ie,l as Le,p as Re,r as ze,t as Be,u as Ve}from"./voice-transcribe-api-TInEfIYo.js";import{a as He,c as Ue,i as We,m as Ge,n as Ke,p as qe,u as Je}from"./schemas-CCWMleym.js";import{n as Ye,t as Xe}from"./interaction-BdhHBbYa.js";import{n as Ze,r as Qe}from"./gateway-config-swr-BAmUhiP1.js";import{n as $e,t as et}from"./registry-api-n8TwtJ_j.js";import{t as tt}from"./voice-call-context-BM2A4bLz.js";import{a as nt,o as rt,s as it}from"./form-field-width-DJw_jULe.js";import{n as at}from"./is-masked-secret-DOkL5b_X.js";import{n as ot,t as st}from"./secret-input-labels-B5Jl5HqK.js";import{a as ct}from"./navigation-BkjnOw30.js";import{t as lt}from"./electron-env-DHOGevH3.js";import{t as ut}from"./sliding-tab-list-DuQyViqe.js";import{n as dt,t as ft}from"./settings-form-draft-Dy10ldo8.js";import{t as pt}from"./confirm-dialog-XGclfBqe.js";import{n as mt,r as ht}from"./model-selector-DCYA_ntf.js";import{n as gt}from"./agents-app-path-ciChvpCS.js";import{n as _t,t as vt}from"./global-defaults-api-CINf-C6a.js";import{t as yt}from"./settings-loading-skeleton-BTqvr_Fw.js";import{i as bt,r as xt,t as St}from"./models-hub-cache-za2fWJLg.js";import{a as Ct,r as wt,s as Tt,t as Et}from"./providers-api-CzVkFKFg.js";import{a as Dt,i as Ot,n as kt,o as At,r as jt,t as Mt}from"./oauth-api-C3X9FLYw.js";import{t as Nt}from"./settings-advanced-section-BqoVSko2.js";import{n as Pt,r as Ft,t as It}from"./oauth-authorization-window-o6URRos4.js";import{t as Lt}from"./number-input-El7Szeln.js";import{n as Rt,t as zt}from"./settings-page-header-Bv-kQFTm.js";import"./settings-page-layout-DHP6MrrL.js";import{n as Bt,t as Vt}from"./settings-form-section-num14vSv.js";import{n as Ht,t as Ut}from"./use-autosave-Cs2Ga_Y_.js";import{c as Wt,f as Gt,i as Kt,l as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt,u as $t}from"./voice-config-api-Cda2uBIC.js";import{t as en}from"./voice-api-key-field-3gyc2UV3.js";import{a as tn,i as nn,n as rn,o as an,r as on,s as sn,t as cn}from"./image-generation-api-I_JgLL_m.js";import{t as ln}from"./xopc-cloud-account-card-CFb-23rS.js";var un=qe({"zh-CN":Ge().min(1).optional(),en:Ge().min(1).optional()}),dn=Ke([`transcription`,`transcription.stream`,`speech`,`speech.stream`,`conversation`]),fn=qe({protocolVersion:Ue(1),serviceVersion:Je().int().positive(),modes:We(dn),transport:Ue(`websocket-pcm`),inputFormat:qe({encoding:Ue(`pcm_s16le`),sampleRate:Ue(16e3),channels:Ue(1)}),outputFormat:qe({encoding:Ue(`pcm_s16le`),sampleRate:Ue(24e3),channels:Ue(1)}),turnDetection:We(Ue(`server_vad`)),bargeIn:He(),tools:He(),resumable:Ue(!1),voices:We(qe({id:Ge().min(1),name:Ge(),displayNames:un.optional(),languages:We(Ge()),gender:Ke([`female`,`male`]).optional(),style:Ge().optional(),description:Ge().optional(),modes:We(dn).optional()})),defaultVoice:Ge().min(1).optional(),limits:qe({maxFrameBytes:Je().int().positive().max(65536),maxSessionSeconds:Je().int().positive()})});function pn(e,t){return e.modes===void 0||e.modes.includes(t)}var mn=qe({mode:dn,model:Ge().min(1).max(200),voice:Ge().min(1).max(200).optional()}),hn=qe({revision:Ge().min(1),catalogVersion:Ge().nullable(),selections:We(mn),models:We(qe({id:Ge(),name:Ge(),displayNames:un.optional(),voice:fn}))}),gn=n(),Q=e(t(),1),$=r(),_n={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},vn=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function yn(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function bn(e){let t=e.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function xn({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a,portalContainer:o,onPendingChange:s}){let c=_n[i],[l,u]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(`bearer`),[y,b]=(0,Q.useState)(`x-api-key`),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(`/images/generations`),[k,A]=(0,Q.useState)(`/images/edits`),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)([yn()]),[L,R]=(0,Q.useState)(``),[z,B]=(0,Q.useState)(),[V,ee]=(0,Q.useState)(!1),[te,H]=(0,Q.useState)(),[U,W]=(0,Q.useState)(),[K,re]=(0,Q.useState)();(0,Q.useEffect)(()=>(s?.(!!z),()=>s?.(!1)),[z,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;u(n?.providerId??``),p(t?.name??``),g(n?.baseUrl??``),v(t?.auth.type??`bearer`),b(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),S(r?`••••••••••••`:``),w(t?.apiKeyUrl??``),E(t?.documentationUrl??``),O(t?.paths?.generations??`/images/generations`),A(t?.paths?.edits??`/images/edits`),M(t?.network?.allowedHosts.join(`
|
|
4
|
+
`)??``),P(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
|
+
`)),I(t?.models.map(yn)??[yn()]),R(t?.defaultModel??``),W(void 0),B(void 0),ee(!1),H(void 0),re(void 0)},[r,e,n]);let ie=(0,Q.useMemo)(()=>F.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[F]),J=(e,t)=>{I(n=>n.map((n,r)=>r===e?{...n,...t}:n))},ae=()=>{let e=l.trim(),t=F.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!f.trim()||!m.trim()||t.some(e=>!e.id))throw Error(c.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(c.duplicateModels);let n=L||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(c.required);let r;try{r=bn(N)}catch{throw Error(c.invalidHeaders)}return{providerId:e,input:{baseUrl:m.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:f.trim(),...T.trim()?{documentationUrl:T.trim()}:{},...C.trim()?{apiKeyUrl:C.trim()}:{},defaultModel:n,auth:_===`header`?{type:`header`,headerName:y.trim()}:{type:_},paths:{...D.trim()?{generations:D.trim()}:{},...k.trim()?{edits:k.trim()}:{}},...j.trim()?{network:{allowedHosts:j.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},oe=async()=>{let e=ae();return await nn(e.providerId,e.input),_!==`none`&&x.trim()&&!at(x)&&await tn(e.providerId,x.trim()),await a(e.providerId),e},ce=async()=>{B(`save`),H(void 0),W(void 0);try{await oe(),S(_===`none`?``:`••••••••••••`),W(c.saved)}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(void 0)}},le=async()=>{B(`test`),H(void 0),W(void 0),re(void 0);try{let e=await oe(),t=await an(e.providerId,e.input.imageGeneration.defaultModel);re(t.images[0]?.dataUrl),W(c.testReady)}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(void 0)}},ue=async()=>{if(n){if(!V){ee(!0);return}B(`delete`),H(void 0);try{await cn(n.providerId),await a(),t(!1)}catch(e){H(e instanceof Error?e.message:String(e))}finally{B(void 0)}}};return(0,$.jsx)(je,{open:e,onOpenChange:e=>{z||t(e)},children:(0,$.jsxs)(Oe,{container:o,children:[(0,$.jsx)(Te,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Ne)}),(0,$.jsxs)(ke,{className:Y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,Me),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ae,{className:`font-semibold text-fg`,children:n?c.editTitle:c.addTitle}),(0,$.jsx)(Ee,{className:`mt-1 text-sm text-fg-muted`,children:c.intro})]}),(0,$.jsx)(De,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:!!z,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":c.cancel,children:(0,$.jsx)(_e,{className:`size-5`})})})]}),(0,$.jsxs)(`fieldset`,{disabled:!!z,className:`min-h-0 min-w-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.providerId,(0,$.jsx)(`input`,{value:l,disabled:!!n,onChange:e=>u(e.target.value),placeholder:`my-image-service`,className:vn}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.name,(0,$.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`My Image Service`,className:vn})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.baseUrl,(0,$.jsx)(`input`,{value:m,onChange:e=>g(e.target.value),placeholder:`https://api.example.com/v1`,className:vn})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.auth,(0,$.jsx)(h,{value:_,options:[{value:`bearer`,label:c.bearer},{value:`header`,label:c.header},{value:`none`,label:c.none}],placeholder:c.auth,allowEmpty:!1,onChange:e=>v(e),triggerClassName:`mt-1.5`})]}),_===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.headerName,(0,$.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),className:vn})]}):null]}),_===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:c.apiKey}),C.trim()?(0,$.jsxs)(`a`,{href:C.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[c.openKeyPage,(0,$.jsx)(d,{className:`size-3.5`})]}):null]}),(0,$.jsx)(G,{id:`custom-image-api-key`,value:x,onChange:e=>S(at(x)?e.replace(/^•+/,``):e),labels:{show:c.show,hide:c.hide,copy:c.copy,copied:c.copied},reveal:()=>Tt(l).then(e=>e.apiKey),loadFailedLabel:c.revealFailed,notInConfigFile:c.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.apiKeyUrl,(0,$.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),placeholder:`https://…`,className:vn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.docsUrl,(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),placeholder:`https://…`,className:vn})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:c.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.generationsPath,(0,$.jsx)(`input`,{value:D,onChange:e=>O(e.target.value),className:vn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.editsPath,(0,$.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),className:vn})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.allowedHosts,(0,$.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),rows:2,placeholder:`127.0.0.1
|
|
7
|
+
image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.staticHeaders,(0,$.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.models}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>I(e=>[...e,yn()]),children:[(0,$.jsx)(se,{className:`size-4`}),c.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.defaultModel,(0,$.jsx)(h,{value:L||ie[0]?.value||``,options:ie,placeholder:c.defaultModel,allowEmpty:!1,onChange:R,triggerClassName:`mt-1.5 max-w-sm`})]}),F.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>J(t,{id:e.target.value}),placeholder:`image-1`,className:vn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>J(t,{name:e.target.value}),className:vn})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>J(t,{maxCount:e.target.value}),className:vn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>J(t,{defaultCount:e.target.value}),className:vn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>J(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:vn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.format,(0,$.jsx)(h,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:c.format,allowEmpty:!0,onChange:e=>J(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>J(t,{supportsSize:e.target.checked})}),c.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>J(t,{editEnabled:e.target.checked})}),c.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:F.length===1,onClick:()=>I(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(pe,{className:`size-3.5`}),c.remove]})]})]},t))]}),K?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(ne,{className:`size-4`}),c.testReady]}),(0,$.jsx)(`img`,{src:K,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,U?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:U}):null,te?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:te}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(Z,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!z,onClick:()=>void ue(),children:[z===`delete`?(0,$.jsx)(q,{className:`size-4 animate-spin`}):(0,$.jsx)(pe,{className:`size-4`}),V?c.confirmDelete:c.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(De,{asChild:!0,children:(0,$.jsx)(Z,{variant:`secondary`,disabled:!!z,children:c.cancel})}),(0,$.jsxs)(Z,{variant:`secondary`,disabled:!!z,onClick:()=>void le(),children:[z===`test`?(0,$.jsx)(q,{className:`size-4 animate-spin`}):null,z===`test`?c.testing:c.test]}),(0,$.jsxs)(Z,{variant:`primary`,disabled:!!z,onClick:()=>void ce(),children:[z===`save`?(0,$.jsx)(q,{className:`size-4 animate-spin`}):null,z===`save`?c.saving:c.save]})]})]})]})]})})}var Sn=`••••••••••••`,Cn={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function wn(){let e=await Ce(be(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function Tn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function En(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Dn(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function On(e){let t=(0,gn.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(h,{value:r,options:(n.options??[]).map(kn),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function kn(e){return{value:e.value,label:e.label}}function An(){let e=(0,gn.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(we,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(jn)}),(0,$.jsx)(we,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function jn(e,t){return(0,$.jsx)(we,{className:`h-24 rounded-xl`},t)}function Mn({connectOnly:e=!1,onConnected:t,onPendingChange:n}={}){let r=Se(e=>e.language),a=Cn[r],o=!!xe(e=>e.conversationId),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,_]=(0,Q.useState)({}),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(n?.(v||b),()=>n?.(!1)),[v,b,n]);let[w,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(),{data:N,isLoading:P,error:F,mutate:I}=X(o?be(`/api/image-generation/catalog`):null,on,{revalidateOnFocus:!1}),{data:L,isLoading:R,error:z,mutate:B}=X(o?be(`/api/image-generation/custom-providers`):null,rn,{revalidateOnFocus:!1}),{data:V,isLoading:ee,error:te,mutate:H}=X(o?`default-image-generation`:null,wn,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!N||!V)return;let e=Tn(V.model?.primary),t=N.find(t=>t.id===e)??N.find(e=>e.configured)??N[0];t&&(c(t.id),u(t.id===e&&En(V.model?.primary)||t.defaultModel),p(t.configured?Sn:``),_(Dn(t)))},[V,N]);let U=N?.find(e=>e.id===s),W=U?U.apiKeyUrl??A(U.id,r)[0]?.href:void 0,ne=(0,Q.useMemo)(()=>(U?.models??[]).map(e=>({value:e,label:e})),[U?.models]),ie=V?.model?.primary,J=!!(U&&l&&(U.credentialMode!==`api-key`||U.configured||f.trim())&&U.configFields.every(e=>!e.required||m[e.key]?.trim()));if(!o)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.connect});if(P||R||ee)return(0,$.jsx)(An,{});if(F||z||te||!N||!L)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a.loadError});let ae=e=>{c(e.id),u(e.defaultModel),p(e.configured?Sn:``),_(Dn(e)),T(void 0)},oe=()=>{M(void 0),k(!0)},ce=()=>{let e=L.find(e=>e.providerId===U?.id);e&&(M(e),k(!0))},ue=async n=>{let[r,i]=await Promise.all([B(),I()]);if(n&&i?.some(e=>e.id===n)){let a=i.find(e=>e.id===n);c(a.id),u(a.defaultModel),p(a.configured?Sn:``),_(Dn(a)),M(r?.find(e=>e.providerId===n)),e&&a.configured&&t?.()}},fe=async()=>{if(!(!U||!J)){y(!0),T(void 0),D(!1);try{if(e){f.trim()&&!at(f)&&await tn(U.id,f.trim()),Object.keys(m).length&&await Ce(be(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:{[U.id]:m}})});let[e]=await Promise.all([I(),Ze()]);if(!e?.find(e=>e.id===U.id)?.configured)throw Error(r===`zh`?`连接尚未就绪,请先完成对应服务的授权或凭据设置。`:`Connection is not ready. Complete authorization or credentials first.`);D(!0),t?.();return}let n=await Ce(be(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:U.id,modelId:l,...f.trim()&&!at(f)?{apiKey:f.trim()}:{},providerConfig:Object.fromEntries(Object.entries(m).filter(([,e])=>e.trim()))})});if(!n.payload)throw Error(`Invalid setup response`);await Promise.all([H(n.payload.default,{revalidate:!1}),I(n.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-CdRzEUwF.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),Ze()]),p(Sn),D(!0)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}};return(0,$.jsxs)(`div`,{ref:C,className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(K,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:e?r===`zh`?`连接图片来源,不修改默认模型,也不发送生成测试请求。`:`Connect image sources without changing defaults or sending generation tests.`:a.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:a.provider}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:oe,children:[(0,$.jsx)(se,{className:`size-4`}),a.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:N.map(e=>{let t=e.id===s,n=e.id===Tn(ie);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ae(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${t?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:a.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!n,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${n?``:`invisible`}`,children:a.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(g,{className:`size-3.5`}):(0,$.jsx)(re,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?a.configured:a.needsKey]})]},e.id)})})]}),U?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[e?null:(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a.model,(0,$.jsx)(h,{value:l,options:ne,placeholder:a.selectModel,allowEmpty:!1,onChange:u,triggerClassName:`mt-1.5`})]}),U.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(On,{field:e,value:m[e.key]??``,onChange:t=>_(n=>({...n,[e.key]:t}))},e.key))]}),U.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`secondary`,onClick:ce,children:[(0,$.jsx)(le,{className:`size-4`}),a.manageService]})}):null,U.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:a.apiKey}),W?(0,$.jsxs)(`a`,{href:W,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[a.getApiKey,(0,$.jsx)(d,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(G,{id:`image-generation-api-key`,value:f,onChange:e=>p(at(f)?e.replace(/^•+/,``):e),placeholder:U.configured?a.existingKey:a.needsKey,labels:{show:a.show,hide:a.hide,copy:a.copy,copied:a.copied},reveal:()=>Tt(U.id).then(e=>e.apiKey),loadFailedLabel:a.revealFailed,notInConfigFile:a.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},U.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:U.configured?a.savedKey:a.apiKeyHint})]}):null,U.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(de,{className:`size-4`}),a.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:U.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(On,{field:e,value:m[e.key]??``,onChange:t=>_(n=>({...n,[e.key]:t}))},e.key))})]}):null,E?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:e?r===`zh`?`连接已保存`:`Connection saved`:a.enabled}):null,w?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:w}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`primary`,disabled:!J||v,onClick:()=>void fe(),children:[v?(0,$.jsx)(q,{className:`size-4 animate-spin`}):(0,$.jsx)(g,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:e?v?r===`zh`?`保存中…`:`Saving…`:r===`zh`?`保存图片连接`:`Save image connection`:v?a.enabling:a.enable})]})]})})]}):null,(0,$.jsx)(xn,{portalContainer:S?.closest(`[role="dialog"]`),onPendingChange:x,open:O,onOpenChange:k,provider:j,configured:!!(j&&N.find(e=>e.id===j.providerId)?.configured),language:r,onSaved:ue})]})}function Nn({disabled:e=!1,modes:t,onPendingChange:n}){let r=Se(e=>e.language),i=r===`zh`,[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>(n?.(a),()=>n?.(!1)),[a,n]);let[s,c]=(0,Q.useState)(``),{data:l,mutate:u,error:d}=X(be(`/api/voice/catalog`),async e=>{let t=await Ce(e);return hn.parse(t.payload)}),f=i?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},h=async e=>{if(l){o(!0),c(``);try{let t=await Ce(be(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:l.revision,selection:e})}:{}});await u(hn.parse(t.payload),!1),await Ze()}catch(e){c(e instanceof Error?e.message:String(e)),await u()}finally{o(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:i?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(Z,{variant:`secondary`,disabled:a||e||!l,onClick:()=>void h(),children:i?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),s||d?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:s||String(d)}):null,l?(0,$.jsx)($.Fragment,{children:t.map(t=>{let n=l.selections.find(e=>e.mode===t),o=l.models.filter(e=>e.voice.modes.includes(t)),s=o.find(e=>e.id===n?.model),c=s?.voice.voices.filter(e=>pn(e,t))??[],u=n?.voice??c.find(e=>e.id===s?.voice.defaultVoice)?.id??c[0]?.id??``;return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:f[t]}),(0,$.jsxs)(p,{className:`w-full`,value:n?.model??``,disabled:a||e||!o.length,onChange:e=>void h({mode:t,model:e.target.value}),children:[(0,$.jsx)(m,{value:``,disabled:!0,children:i?`选择模型`:`Choose model`}),n&&!s?(0,$.jsxs)(m,{value:n.model,disabled:!0,children:[n.model,` · `,i?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(m,{value:e.id,children:ht(e,r)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无可用模型`:`No available model`})]}),s&&c.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:i?`音色`:`Voice`}),(0,$.jsxs)(p,{className:`w-full`,value:u,disabled:a||e,onChange:e=>void h({mode:t,model:s.id,voice:e.target.value}),children:[n?.voice&&!c.some(e=>e.id===n.voice)?(0,$.jsxs)(m,{value:n.voice,disabled:!0,children:[n.voice,` · `,i?`当前场景不可用`:`Unavailable for this mode`]}):null,c.map(e=>(0,$.jsxs)(m,{value:e.id,children:[ht(e,r),e.gender?` · ${i?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),c.find(e=>e.id===u)?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.find(e=>e.id===u)?.description}):null]}):null]},t)})}):(0,$.jsx)(we,{className:`h-48 w-full`})]})}function Pn({v:e}){let t=Pe(e=>e.microphoneId),n=Pe(e=>e.setMicrophoneId),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let u=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(p,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(m,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(m,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(m,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,$.jsx)(Z,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}var Fn=(0,Q.createContext)(null);function In(e){let t=(0,gn.c)(18),n,r;t[0]===e?(n=t[1],r=t[2]):({to:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let[i]=s(),a=(0,Q.useContext)(Fn),o,c;t[3]===r?(o=t[4],c=t[5]):(o=new URLSearchParams(r.split(`?`)[1]??``),c=_(o.get(`configure`)),t[3]=r,t[4]=o,t[5]=c);let u=c,d;t[6]!==a||t[7]!==n||t[8]!==o||t[9]!==u?(d=e=>{n.onClick?.(e),!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&a&&u&&o.get(`tab`)===`services`&&(e.preventDefault(),a(u))},t[6]=a,t[7]=n,t[8]=o,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==i||t[12]!==r?(f=ee(r,i),t[11]=i,t[12]=r,t[13]=f):f=t[13];let p;return t[14]!==n||t[15]!==d||t[16]!==f?(p=(0,$.jsx)(l,{...n,onClick:d,to:f}),t[14]=n,t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function Ln(e){let t=(0,gn.c)(19),{zh:n}=e,{data:r,error:i,mutate:a}=X(`voice-dictation-route`,Rn),o,s;t[0]===a?(o=t[1],s=t[2]):(o=()=>{let e=()=>{a()};return window.addEventListener(`voice-config-changed`,e),window.addEventListener(`config-reload`,e),()=>{window.removeEventListener(`voice-config-changed`,e),window.removeEventListener(`config-reload`,e)}},s=[a],t[0]=a,t[1]=o,t[2]=s),(0,Q.useEffect)(o,s);let c=n?`同时用于聊天听写`:`Also used for chat dictation`,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`h2`,{className:`font-medium text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`默认与录音识别共用模型。已有的独立听写设置会保留。`:`Dictation shares this recognition model. Existing separate dictation settings are preserved.`,d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`p`,{className:`text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==r||t[8]!==i||t[9]!==n?(f=!r&&!i?(0,$.jsx)(we,{className:`h-5 w-64 max-w-full`}):(0,$.jsx)(`p`,{role:i?`alert`:`status`,className:`text-fg-muted`,children:i?n?`暂时无法读取听写状态。`:`Dictation status could not be loaded.`:r?.mode===`recorded`?n?`当前使用 ${r.provider},点击完成后转为文字。`:`Using ${r.provider}. Choose Finish to transcribe.`:r?.mode===`streaming`?n?`当前使用流式识别${r.provider?` · ${r.provider}`:``}。`:`Using streaming recognition${r.provider?` · ${r.provider}`:``}.`:n?`听写未就绪,请检查识别模型或已有的流式配置。`:`Check the recognition model or existing streaming configuration.`}),t[7]=r,t[8]=i,t[9]=n,t[10]=f):f=t[10];let p;t[11]!==r?.mode||t[12]!==n?(p=r?.mode===`recorded`?null:(0,$.jsx)(In,{className:`inline-block text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=transcription`,children:n?`管理识别服务`:`Manage recognition services`}),t[11]=r?.mode,t[12]=n,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==d||t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-edge p-4 text-sm`,children:[l,d,f,p]}),t[14]=l,t[15]=d,t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function Rn(){return Be(AbortSignal.timeout(15e3))}function zn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(tt)?.active??!1,[s,c]=(0,Q.useState)(`idle`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),p=(0,Q.useRef)(`idle`),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=e=>{p.current=e,c(e)},_=()=>{m.current?.(),m.current=null};(0,Q.useEffect)(()=>()=>m.current?.(),[]);async function v(e){_(),i?.({input:!1,output:!1}),h.current=!1,u(``),f(``),g(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>v(a.timeout),6e4);m.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function v(e){t.signal.aborted||(g(`error`),f(e),_())}async function y(){g(`playing`),l();try{let e=await qt(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),g(`confirm`))})}catch(e){v(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new Le,await c.start(),t.signal.throwIfAborted()),!e){await y();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:Fe()}),t.signal.aborted){l();return}if(s=await Ve.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&v(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),h.current=!0,n?y():(g(`passed`),i?.({input:!0,output:!1}),_()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&v(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await ze.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new Ie(o.sampleRate,s.session.inputFormat.sampleRate),g(`listening`)}catch(e){if(t.signal.aborted){l();return}v(e instanceof Error?e.message:a.testFailed)}}let y=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(q,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)(ae,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(fe,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,$.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,$.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,$.jsx)(`p`,{children:a.speakNow}):null,l?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,$.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{children:a.heardQuestion}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,$.jsx)(`p`,{children:h.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function Bn(e){let t=(0,gn.c)(78),{section:n,v:r,form:i,pending:a,onChange:o}=e,s=Se(Gn),c=r.setup,l;t[0]===i?l=t[1]:(l=JSON.stringify(i),t[0]=i,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d={signature:u,input:!1,output:!1},t[2]=u,t[3]=d);let[f,h]=(0,Q.useState)(d);f.signature!==u&&h({signature:u,input:!1,output:!1});let g;t[4]!==a||t[5]!==u?(g=a?null:[`voice-realtime-status`,u],t[4]=a,t[5]=u,t[6]=g):g=t[6];let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!0},t[7]=_):_=t[7];let{data:v,error:y,isLoading:b}=X(g,Qt,_),x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=be(`/api/voice/catalog`),t[8]=x):x=t[8];let{data:S}=X(x,Wn),C=i.voice.realtime,w=C.tts,T=w?.provider??v?.tts?.provider,E=v?.tts?.model,D;t[9]!==E||t[10]!==T?(D=T&&E?[`realtime-voices`,T,E]:null,t[9]=E,t[10]=T,t[11]=D):D=t[11];let O;t[12]!==E||t[13]!==T?(O=()=>Jt(T,E,`realtime`),t[12]=E,t[13]=T,t[14]=O):O=t[14];let k;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(k={revalidateOnFocus:!1},t[15]=k):k=t[15];let{data:A}=X(D,O,k),j;t[16]===A?j=t[17]:(j=A===void 0?[]:A,t[16]=A,t[17]=j);let M=j,N=M,P;t[18]===M?P=t[19]:(P=M.filter(Un),t[18]=M,t[19]=P);let F=P,I=C.defaultEngine===`omni`,L=I?C.omni?.voice??``:w?.voice??``,R;t[20]!==S?.models||t[21]!==I||t[22]!==F||t[23]!==C.omni||t[24]!==N?(R=I&&C.omni?.provider===`qwen-token-plan-cn`?[{id:C.omni.voice,name:C.omni.voice}]:I?C.omni?.provider===`xopc-cloud`?S?.models.find(e=>e.id===C.omni?.model)?.voice.voices.filter(Hn)??[]:F.length?F:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(Vn):N,t[20]=S?.models,t[21]=I,t[22]=F,t[23]=C.omni,t[24]=N,t[25]=R):R=t[25];let z=R,B=!!(v?.enabled&&v.stt),V=!!(v?.enabled&&v.tts),ee;t[26]!==i||t[27]!==o||t[28]!==C?(ee=e=>o({...i,voice:{...i.voice,realtime:{...C,...e}}}),t[26]=i,t[27]=o,t[28]=C,t[29]=ee):ee=t[29];let te=ee,H;t[30]!==a||t[31]!==C.enabled||t[32]!==c.disabled||t[33]!==c.needsSetup||t[34]!==c.pending||t[35]!==c.unverified||t[36]!==c.verified||t[37]!==u||t[38]!==f.signature?(H=(e,t)=>C.enabled?a?c.pending:e?t&&f.signature===u?c.verified:c.unverified:c.needsSetup:c.disabled,t[30]=a,t[31]=C.enabled,t[32]=c.disabled,t[33]=c.needsSetup,t[34]=c.pending,t[35]=c.unverified,t[36]=c.verified,t[37]=u,t[38]=f.signature,t[39]=H):H=t[39];let U=H,W;t[40]!==L||t[41]!==s||t[42]!==I||t[43]!==T||t[44]!==C.bargeIn||t[45]!==C.defaultEngine||t[46]!==C.enabled||t[47]!==C.omni||t[48]!==C.tts||t[49]!==c.bargeIn||t[50]!==c.defaultVoice||t[51]!==c.enable||t[52]!==c.voice||t[53]!==n||t[54]!==w||t[55]!==v?.tts||t[56]!==te||t[57]!==r.experience||t[58]!==r.realtime||t[59]!==z?(W=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:c.enable}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":C.enabled,className:`ui-checkbox`,checked:C.enabled,onChange:e=>te({enabled:e.target.checked})})]}),(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(p,{value:C.defaultEngine,className:rt,onChange:e=>te({defaultEngine:e.target.value}),children:[(0,$.jsx)(m,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(m,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[C.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:c.voice}),(0,$.jsxs)(p,{id:`realtime-voice`,className:`${rt} w-full sm:w-56`,value:L,disabled:I?!C.omni:!w&&!v?.tts,onChange:e=>{if(I&&C.omni){te({omni:{...C.omni,voice:e.target.value}});return}if(T===`alibaba`||T===`xopc-cloud`){let t={...C.tts,provider:T};e.target.value?t.voice=e.target.value:delete t.voice,te({tts:t})}},children:[I?null:(0,$.jsx)(m,{value:``,children:c.defaultVoice}),L&&!z.some(e=>e.id===L)?(0,$.jsx)(m,{value:L,children:L}):null,z.map(e=>(0,$.jsxs)(m,{value:e.id,children:[ht(e,s),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=z.find(e=>e.id===L);return e&&`description`in e&&typeof e.description==`string`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[c.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":C.bargeIn,checked:C.bargeIn,className:`size-4 accent-accent`,onChange:e=>te({bargeIn:e.target.checked})})]})]}):null,t[40]=L,t[41]=s,t[42]=I,t[43]=T,t[44]=C.bargeIn,t[45]=C.defaultEngine,t[46]=C.enabled,t[47]=C.omni,t[48]=C.tts,t[49]=c.bargeIn,t[50]=c.defaultVoice,t[51]=c.enable,t[52]=c.voice,t[53]=n,t[54]=w,t[55]=v?.tts,t[56]=te,t[57]=r.experience,t[58]=r.realtime,t[59]=z,t[60]=W):W=t[60];let G;t[61]!==B||t[62]!==V||t[63]!==y||t[64]!==b||t[65]!==a||t[66]!==n||t[67]!==u||t[68]!==v||t[69]!==U||t[70]!==r||t[71]!==f.input||t[72]!==f.output?(G=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[b?(0,$.jsx)(we,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,U(B,f.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,U(B&&V,f.input&&f.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,U(!!(v?.enabled&&v.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(zn,{v:r,canListen:B,canSpeak:V,disabled:a||b||!!y,onVerified:e=>h({signature:u,...e})},`${u}:${JSON.stringify(v)}`)]}):null,t[61]=B,t[62]=V,t[63]=y,t[64]=b,t[65]=a,t[66]=n,t[67]=u,t[68]=v,t[69]=U,t[70]=r,t[71]=f.input,t[72]=f.output,t[73]=G):G=t[73];let ne;return t[74]!==c.service||t[75]!==W||t[76]!==G?(ne=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":c.service,children:[W,G]}),t[74]=c.service,t[75]=W,t[76]=G,t[77]=ne):ne=t[77],ne}function Vn(e){return{id:e,name:e}}function Hn(e){return pn(e,`conversation`)}function Un(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Wn(e){return hn.parse((await Ce(e)).payload)}function Gn(e){return e.language}function Kn(e){let t=(0,gn.c)(19),{value:n,onChange:r}=e,i=Se(qn)===`zh`,a=i?`通话指令`:`Conversation instructions`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=i?`通话会接续当前会话。可在这里调整语气与回答方式。`:`Calls continue the current conversation. Adjust tone and response style here.`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s}),t[2]=s,t[3]=c);let l=i?`通话指令`:`Conversation instructions`,u;t[4]===l?u=t[5]:(u=(0,$.jsx)(`span`,{children:l}),t[4]=l,t[5]=u);let d;t[6]!==r||t[7]!==n?(d=e=>r({...n,instructions:e.target.value}),t[6]=r,t[7]=n,t[8]=d):d=t[8];let f;t[9]!==d||t[10]!==n.instructions?(f=(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,rows:3,maxLength:8e3,value:n.instructions,onChange:d}),t[9]=d,t[10]=n.instructions,t[11]=f):f=t[11];let p;t[12]!==u||t[13]!==f?(p=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[u,f]}),t[12]=u,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==o||t[16]!==c||t[17]!==p?(m=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[o,c,p]}),t[15]=o,t[16]=c,t[17]=p,t[18]=m):m=t[18],m}function qn(e){return e.language}var Jn=nt;function Yn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,it,`dark:border-edge`)}function Xn(){return Y(rt,nt)}function Zn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Qn(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function $n(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function er(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function tr(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;default:return t.tts.providerHints.generic}}function nr(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function rr(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type!==`boolean`&&``:t.defaultValue}function ir(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function ar(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function or(e){let t=(0,gn.c)(4),[n,r]=(0,Q.useState)(0),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(sr),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==e?(a=(0,$.jsx)(cr,{...e,onReload:i},n),t[1]=n,t[2]=e,t[3]=a):a=t[3],a}function sr(e){return e+1}function cr({capability:e,onPendingChange:t,disabled:n=!1,onReload:r}){let i=Se(e=>e.language),a=ve(i).voiceSettings,o=Pe(e=>e.captions),s=Pe(e=>e.setCaptions),c=!!xe(e=>e.conversationId),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useReducer)(ar,{form:null,baseline:null}),h=d.form,g=d.baseline,[_,v]=(0,Q.useState)(null),y=(0,Q.useRef)(!1),b=(0,Q.useRef)({}),x=(0,Q.useRef)(h);x.current=h;let S=(0,Q.useRef)({parsed:null,models:void 0}),{data:C,error:w,isLoading:T,mutate:E}=Qe(c),{data:D,error:O,isLoading:k,mutate:A}=X(c?be(`/api/voice/models`):null,Xt,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=X(c?be(`/api/voice/providers`):null,Kt,{revalidateOnFocus:!1}),{data:P,error:F,isLoading:I}=X(c?be(`/api/voice/stt-providers`):null,Yt,{revalidateOnFocus:!1}),L=(0,Q.useMemo)(()=>j?.providers??[],[j]),R=(0,Q.useMemo)(()=>P?.providers??[],[P]),z=(0,Q.useMemo)(()=>C?.payload?.config===void 0?null:Zt(C.payload.config),[C]),B=(0,Q.useMemo)(()=>!h||!g?!1:JSON.stringify(h)!==JSON.stringify(g),[h,g]);c?z!==null&&D!==void 0&&!y.current&&(S.current.parsed!==z||S.current.models!==D)&&(S.current={parsed:z,models:D},b.current=$t(C?.payload?.config),f({type:`sync`,value:z}),v(D)):(S.current.parsed!==null||S.current.models!==void 0)&&(S.current={parsed:null,models:void 0},f({type:`reset`}),v(null),y.current=!1);let V=!!(c&&(z===null||D===void 0||j===void 0||P===void 0)&&(T||k||N||I)),ee=w instanceof Error?w.message:w?String(w):O instanceof Error?O.message:O?String(O):M instanceof Error?M.message:M?String(M):F instanceof Error?F.message:F?String(F):null,te=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),H=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),U=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),W=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,languageMode:e,...e===`auto`?{language:i}:{}}}:null})},[i]),G=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),ne=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),K=Ut({value:h,dirty:B,onSave:(0,Q.useCallback)(async t=>{try{let n=await Wt(t,e,b.current[e]);b.current={...b.current,...n},f({type:`saved`,value:t}),y.current=!!(x.current&&JSON.stringify(x.current)!==JSON.stringify(t))}catch(e){throw Error(e instanceof Error?e.message:a.saveError)}},[a.saveError,e])});(0,Q.useEffect)(()=>{t?.(B||K.status===`saving`||l)},[B,K.status,l,t]),(0,Q.useEffect)(()=>()=>t?.(!1),[t]);let re=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:()=>e})},[]);if(!c)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})});if(V)return(0,$.jsx)(yt,{rows:4});if(!h||_===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ee??a.loadError}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>{E(),A()},children:a.retry})]});let q=h.stt,ie=h.tts,J=h.voice.input.refinement,ae=nr(a);return(0,$.jsxs)(`fieldset`,{disabled:n||l,className:`flex min-w-0 flex-col gap-4`,onBlurCapture:K.error?void 0:K.onBlurCapture,children:[(0,$.jsx)(Ht,{status:K.status,error:K.error}),K.error?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Z,{variant:`secondary`,onClick:K.retry,children:i===`zh`?`重试保存`:`Retry saving`}),(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>{E().then(()=>r()).catch(()=>{})},children:i===`zh`?`重新加载(放弃未保存更改)`:`Reload and discard unsaved changes`})]}):null,e===`transcription`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ln,{zh:i===`zh`}),(0,$.jsx)(dr,{managedModel:!0,v:a,apiKeyLabels:ae,stt:q,models:_,sttProviders:R,updateStt:te,updateSttFallback:H}),(0,$.jsx)(ur,{v:a,voice:h.voice,updateLanguageMode:W}),(0,$.jsxs)(`details`,{"data-voice-section":`input-processing`,className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[a.experience.inputProcessing,` · `,J.mode===`off`?a.stt.refinementOff:J.mode===`punctuation`?a.stt.refinementPunctuation:J.mode===`light`?a.stt.refinementLight:a.setup.advanced]}),(0,$.jsxs)(`label`,{className:`mt-4 block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:a.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.stt.refinementDesc}),(0,$.jsxs)(p,{className:Xn(),value:J.mode,onChange:e=>U({mode:e.target.value}),children:[(0,$.jsx)(m,{value:`off`,children:a.stt.refinementOff}),(0,$.jsx)(m,{value:`punctuation`,children:a.stt.refinementPunctuation}),(0,$.jsx)(m,{value:`light`,children:a.stt.refinementLight}),J.mode===`custom`?(0,$.jsx)(m,{value:`custom`,children:a.setup.advanced}):null]})]})]}),q.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`实时听写`:`Live dictation`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Nn,{modes:[`transcription.stream`],disabled:B||K.status===`saving`,onPendingChange:u})})]}):null]}):e===`speech`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pr,{managedModel:!0,v:a,apiKeyLabels:ae,tts:ie,models:_,ttsProviders:L,updateTts:ne}),(0,$.jsx)(lr,{v:a,tts:ie,updateTts:ne})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Bn,{section:`listening`,v:a,form:h,pending:B||K.status===`saving`||!!K.error,onChange:re}),h.voice.realtime.defaultEngine===`omni`&&h.voice.realtime.omni?(0,$.jsx)(Kn,{value:h.voice.realtime.omni,onChange:e=>G({omni:e})}):null,(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:a.experience.pace}),(0,$.jsxs)(p,{className:Xn(),value:String(h.voice.realtime.silenceDurationMs),onChange:e=>G({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(m,{value:`800`,children:a.experience.fast}),(0,$.jsx)(m,{value:`1200`,children:a.experience.standard}),(0,$.jsx)(m,{value:`2000`,children:a.experience.relaxed}),[800,1200,2e3].includes(h.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(m,{value:String(h.voice.realtime.silenceDurationMs),children:[h.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[a.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":o,className:`ui-checkbox`,checked:o,onChange:e=>s(e.target.checked)})]}),h.voice.realtime.defaultEngine===`agent`&&q.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`语音助手输出`:`Assistant speech output`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Nn,{modes:[`speech.stream`],disabled:B||K.status===`saving`,onPendingChange:u})})]}):null,(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`麦克风、扬声器与诊断`:`Microphone, speakers and diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Pn,{v:a}),(0,$.jsx)(Bn,{section:`diagnostics`,v:a,form:h,pending:B||K.status===`saving`||!!K.error,onChange:re})]})]})]})]})}function lr(e){let t=(0,gn.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=Xn(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,$.jsx)(m,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let d;t[7]===n.tts.triggerInbound?d=t[8]:(d=(0,$.jsx)(m,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=d);let f;t[9]===n.tts.triggerAlways?f=t[10]:(f=(0,$.jsx)(m,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=f);let h;t[11]===n.tts.triggerTagged?h=t[12]:(h=(0,$.jsx)(m,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=h);let g;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==d||t[17]!==f||t[18]!==h||t[19]!==n.setup.readout?(g=(0,$.jsxs)(p,{"aria-label":o,className:s,value:c,onChange:l,children:[u,d,f,h]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d,t[17]=f,t[18]=h,t[19]=n.setup.readout,t[20]=g):g=t[20];let _;t[21]!==a||t[22]!==g?(_=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,g]}),t[21]=a,t[22]=g,t[23]=_):_=t[23];let v;t[24]===n.setup.readoutHint?v=t[25]:(v=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=v);let y;return t[26]!==_||t[27]!==v?(y=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function ur(e){let t=(0,gn.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=Xn(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let d;t[10]===n.language.auto?d=t[11]:(d=(0,$.jsx)(m,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,$.jsx)(m,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let h;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(h=(0,$.jsxs)(p,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function dr(e){let t=(0,gn.c)(65),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c,managedModel:l}=e,u=l!==void 0&&l,d;if(t[0]!==o){let e=new Set;d=[];for(let t of o)e.has(t.id)||(e.add(t.id),d.push(t));t[0]=o,t[1]=d}else d=t[1];let f=d,h,g,_,v;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){h=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],_=e,g=a?.stt?.[i.provider]?.length?a.stt[i.provider]:h?.models??[],v=h?.fields.find(fr),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=h,t[7]=g,t[8]=_,t[9]=v}else h=t[6],g=t[7],_=t[8],v=t[9];let y=v,b=typeof _.model==`string`?_.model:void 0,x=b??(typeof y?.defaultValue==`string`?y.defaultValue:g[0]?.id),S;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(S=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=S):S=t[16];let C=S,w,T;t[17]!==b||t[18]!==x||t[19]!==u||t[20]!==y||t[21]!==C?(w=()=>{!u&&y&&x&&b!==x&&C({model:x})},T=[u,b,x,y,C],t[17]=b,t[18]=x,t[19]=u,t[20]=y,t[21]=C,t[22]=w,t[23]=T):(w=t[22],T=t[23]),(0,Q.useEffect)(w,T);let E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ie,{"aria-hidden":`true`,className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=E):E=t[24];let D;t[25]===n.stt.title?D=t[26]:(D=(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[E,n.stt.title]}),t[25]=n.stt.title,t[26]=D);let O;t[27]===n.stt.enable?O=t[28]:(O=(0,$.jsx)(`span`,{children:n.stt.enable}),t[27]=n.stt.enable,t[28]=O);let k;t[29]===s?k=t[30]:(k=e=>s({enabled:e.target.checked}),t[29]=s,t[30]=k);let A;t[31]!==i.enabled||t[32]!==k?(A=(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:k}),t[31]=i.enabled,t[32]=k,t[33]=A):A=t[33];let j;t[34]!==A||t[35]!==O?(j=(0,$.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[O,A]}),t[34]=A,t[35]=O,t[36]=j):j=t[36];let M;t[37]!==j||t[38]!==D?(M=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[D,j]}),t[37]=j,t[38]=D,t[39]=M):M=t[39];let N;t[40]===n.stt.description?N=t[41]:(N=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[40]=n.stt.description,t[41]=N);let P;t[42]!==M||t[43]!==N?(P=(0,$.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[42]=M,t[43]=N,t[44]=P):P=t[44];let F;t[45]!==h?.fields||t[46]!==r||t[47]!==x||t[48]!==u||t[49]!==g||t[50]!==f||t[51]!==_||t[52]!==i.enabled||t[53]!==i.fallback?.enabled||t[54]!==i.provider||t[55]!==C||t[56]!==s||t[57]!==c||t[58]!==n?(F=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u?null:(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jn),children:[(0,$.jsx)(xr,{children:n.stt.provider}),(0,$.jsx)(p,{"aria-label":n.stt.provider,className:Xn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(m,{value:e.id,children:[$n(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(mr,{managedModel:u,kind:`stt`,providerId:i.provider,fields:h?.fields??[],providerSlice:_,models:g,currentModel:x,apiKeyLabels:r,onPatch:C})]}),i.provider===`alibaba`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]})]}):null,t[45]=h?.fields,t[46]=r,t[47]=x,t[48]=u,t[49]=g,t[50]=f,t[51]=_,t[52]=i.enabled,t[53]=i.fallback?.enabled,t[54]=i.provider,t[55]=C,t[56]=s,t[57]=c,t[58]=n,t[59]=F):F=t[59];let I;t[60]===F?I=t[61]:(I=(0,$.jsx)(`div`,{className:`space-y-4`,children:F}),t[60]=F,t[61]=I);let L;return t[62]!==P||t[63]!==I?(L=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[P,I]}),t[62]=P,t[63]=I,t[64]=L):L=t[64],L}function fr(e){return e.key===`model`}function pr({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,managedModel:o=!1}){let[s,c]=(0,Q.useState)(e.tts.test.sampleText),[l,u]=(0,Q.useState)({status:`idle`}),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),h=(0,Q.useRef)(null),g=(0,Q.useCallback)(()=>{h.current?.abort(),h.current=null,d.current?.pause(),d.current=null,f.current&&=(URL.revokeObjectURL(f.current),null)},[]),_=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),v=_.find(e=>e.id===n.provider),y=n.providers?.[n.provider]??{},b=r?.tts?.[n.provider]?.length?r.tts[n.provider]:v?.models??[],x=v?.fields.find(e=>e.key===`model`),S=v?.fields.find(e=>e.key===`voice`),C=typeof y.model==`string`?y.model:void 0,w=C??(typeof x?.defaultValue==`string`?x.defaultValue:b[0]?.id),T=b.find(e=>e.id===w),E=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:v?.voices??[],{data:D=[]}=X(w?`voice:tts:${n.provider}:${w}`:null,()=>Jt(n.provider,w??``),{revalidateOnFocus:!1}),O=D.length>0?D:E,k=typeof y.voice==`string`?y.voice:void 0,A=k??O.find(e=>e.id===T?.tts?.defaultVoice)?.id??(typeof S?.defaultValue==`string`?S.defaultValue:O[0]?.id),j=(v?.fields??[]).filter(e=>(e.key!==`speed`||T?.tts?.speed!==!1)&&(e.key!==`instructions`||T?.tts?.instructions!==!1)),M=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{if(o)return;let e={};x&&w&&C!==w&&(e.model=w),S&&A&&k!==A&&(e.voice=A),Object.keys(e).length>0&&M(e)},[o,C,k,w,A,x,M,S]),(0,Q.useEffect)(()=>()=>g(),[g]);let N=(0,Q.useCallback)(e=>{a({provider:e}),u({status:`idle`})},[a]),P=(0,Q.useCallback)(async()=>{let t=s.trim();if(!t){u({status:`error`,message:e.tts.test.emptyText});return}g();let r=new AbortController;h.current=r,u({status:`loading`});try{let i=await Gt({text:t,provider:n.provider,providerConfig:y,...w?{model:w}:{},...A?{voice:A}:{}},r.signal);if(r.signal.aborted)return;let a=Qn(i.audio,i.mimeType);f.current=a;let o=new Audio(a);d.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,Zn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>u({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>u({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),u({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;g(),u({status:`error`,message:e instanceof Error?e.message:String(e)})}},[w,A,y,g,s,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(he,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:o?null:(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jn),children:[(0,$.jsx)(xr,{children:e.tts.provider}),(0,$.jsx)(p,{"aria-label":e.tts.provider,className:Xn(),value:n.provider,onChange:e=>N(e.target.value),children:_.map(t=>(0,$.jsx)(m,{value:t.id,children:er(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[v?.configured?e.tts.configured:v?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${v.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,v?.description??tr(n.provider,e)]})]})}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(mr,{managedModel:o,kind:`tts`,providerId:n.provider,fields:j,providerSlice:y,models:b,voices:O,currentModel:w,currentVoice:A,apiKeyLabels:t,onPatch:M,resetVoiceOnModelChange:!0})}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`primary`,onClick:()=>void P(),disabled:l.status===`loading`,className:`h-9`,children:[l.status===`loading`?(0,$.jsx)(q,{className:`size-4 animate-spin`}):(0,$.jsx)(ae,{className:`size-4`}),l.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,onClick:()=>{g(),u(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:l.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(fe,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:Y(Yn(),`mt-3 min-h-20 resize-y`),value:s,onChange:e=>c(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[s.length,`/1000`]}),l.status===`playing`||l.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[l.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,l.summary]}):null,l.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:l.message}):null]})]})]})]})})]})}function mr(e){let t=(0,gn.c)(48),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:c,currentVoice:l,apiKeyLabels:u,onPatch:d,resetVoiceOnModelChange:f,managedModel:h}=e,g;t[0]===s?g=t[1]:(g=s===void 0?[]:s,t[0]=s,t[1]=g);let _=g,v=f!==void 0&&f,y=h!==void 0&&h,b=Se(vr),x;t[2]===b?x=t[3]:(x=ve(b),t[2]=b,t[3]=x);let S=x.voiceSettings,C=y,w=_r,T=gr,E,D,O;if(t[4]!==u||t[5]!==c||t[6]!==l||t[7]!==i||t[8]!==n||t[9]!==b||t[10]!==y||t[11]!==o||t[12]!==d||t[13]!==r||t[14]!==a||t[15]!==v||t[16]!==C||t[17]!==S||t[18]!==_){let e;t[22]===C?e=t[23]:(e=e=>!C||e.key!==`model`&&!T(e),t[22]=C,t[23]=e);let s=i.filter(e),f;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>!w(e),t[24]=f):f=t[24];let h=s.filter(f),g;t[25]!==u||t[26]!==c||t[27]!==l||t[28]!==n||t[29]!==b||t[30]!==y||t[31]!==o||t[32]!==d||t[33]!==r||t[34]!==a||t[35]!==v||t[36]!==S||t[37]!==_?(g=e=>e.map(e=>y&&e.key===`model`?null:e.key===`apiKey`?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jn),children:[(0,$.jsx)(xr,{htmlFor:`voice-${n}-${r}-api-key`,children:S.stt.apiKey}),(0,$.jsx)(en,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>d({apiKey:e}),labels:u,placeholder:e.placeholder}),e.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.description}):null]},e.key):e.key===`model`&&o.length>0?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jn),children:[(0,$.jsx)(xr,{htmlFor:`voice-${n}-${r}-model`,children:S.stt.model}),(0,$.jsx)(p,{id:`voice-${n}-${r}-model`,className:Xn(),value:c??``,onChange:e=>d({model:e.target.value,...v?{voice:void 0}:{}}),children:o.map(hr)})]},e.key):e.key===`voice`&&_.length>0?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Jn),children:[(0,$.jsx)(xr,{htmlFor:`voice-${n}-${r}-voice`,children:S.tts.voice}),(0,$.jsxs)(p,{id:`voice-${n}-${r}-voice`,className:Xn(),value:l??``,onChange:e=>d({voice:e.target.value}),children:[l&&!_.some(e=>e.id===l)?(0,$.jsxs)(m,{value:l,children:[l,` · unavailable`]}):null,_.map(e=>(0,$.jsxs)(m,{value:e.id,children:[ht(e,b),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),_.find(e=>e.id===l)?.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:_.find(e=>e.id===l)?.description}):null]},e.key):(0,$.jsx)(yr,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:rr(a,e),onChange:t=>d({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Jn},e.key)),t[25]=u,t[26]=c,t[27]=l,t[28]=n,t[29]=b,t[30]=y,t[31]=o,t[32]=d,t[33]=r,t[34]=a,t[35]=v,t[36]=S,t[37]=_,t[38]=g):g=t[38];let x=g;t[39]!==i||t[40]!==n||t[41]!==b||t[42]!==C?(E=C&&i.some(T)?(0,$.jsx)(In,{className:`text-sm text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=${n===`stt`?`transcription`:`speech`}`,children:b===`zh`?`管理服务连接`:`Manage service connection`}):null,t[39]=i,t[40]=n,t[41]=b,t[42]=C,t[43]=E):E=t[43],D=x(s.filter(w)),O=h.length?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:S.experience.providerOptions}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:x(h)})]}):null,t[4]=u,t[5]=c,t[6]=l,t[7]=i,t[8]=n,t[9]=b,t[10]=y,t[11]=o,t[12]=d,t[13]=r,t[14]=a,t[15]=v,t[16]=C,t[17]=S,t[18]=_,t[19]=E,t[20]=D,t[21]=O}else E=t[19],D=t[20],O=t[21];let k;return t[44]!==E||t[45]!==D||t[46]!==O?(k=(0,$.jsxs)($.Fragment,{children:[E,D,O]}),t[44]=E,t[45]=D,t[46]=O,t[47]=k):k=t[47],k}function hr(e){return(0,$.jsx)(m,{value:e.id,children:e.name},e.id)}function gr(e){return e.secret||e.type===`password`||[`apiKey`,`baseUrl`,`region`,`groupId`].includes(e.key)}function _r(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function vr(e){return e.language}function yr(e){let t=(0,gn.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?e=t[1]:(e=Y(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,$.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(ir(r,e.target.checked)),t[9]=r,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=Y(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]!==r.label||t[22]!==s?(d=(0,$.jsx)(xr,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=d):d=t[23];let f;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(f=r.type===`select`?(0,$.jsx)(p,{id:s,className:Xn(),value:l,required:r.required,onChange:e=>a(ir(r,e.target.value)),children:(r.options??[]).map(br)}):r.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:Y(Yn(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(ir(r,e.target.value))}):r.type===`password`?(0,$.jsx)(G,{id:s,className:o,value:l,onChange:e=>a(ir(r,e)),placeholder:r.placeholder,labels:st}):r.type===`number`?(0,$.jsx)(Lt,{id:s,className:Yn(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(ir(r,e.target.value))}):(0,$.jsx)(`input`,{id:s,className:Yn(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(ir(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=f):f=t[29];let m;t[30]===c?m=t[31]:(m=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=m);let h;return t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,f,m]}),t[32]=u,t[33]=d,t[34]=f,t[35]=m,t[36]=h):h=t[36],h}function br(e){return(0,$.jsx)(m,{value:e.id,children:e.name},e.id)}function xr(e){let t=(0,gn.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function Sr(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Cr(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map((e,t)=>{let n=e&&typeof e==`object`?e:{},r=n.type,i=r===`brave`||r===`tavily`||r===`bing`||r===`searxng`||r===`deepseek`?r:`brave`;return{clientKey:`search-provider-${t}`,type:i,apiKey:typeof n.apiKey==`string`?n.apiKey:``,url:typeof n.url==`string`?n.url:``,disabled:n.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function wr(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return(e.type===`searxng`||e.type===`deepseek`)&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await Ce(be(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Ze()}async function Tr(e){let t=await Ce(be(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Er(e){let t=(0,gn.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Dr(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,it,`dark:border-edge`)}function Or(){return Y(rt,nt)}var kr=[`brave`,`tavily`,`bing`,`searxng`,`deepseek`];function Ar(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var jr=ft();function Mr(){let e=ve(Se(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!xe(e=>e.conversationId),[i,a]=(0,Q.useReducer)(jr,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:d,error:f,isLoading:h,mutate:g}=Qe(r);dt({enabled:r,parsed:(0,Q.useMemo)(()=>d?.payload?.config===void 0?null:Cr(d.payload.config),[d]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let _=!!(r&&h&&d===void 0&&!f),v=f instanceof Error?f.message:f?String(f):null,y=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),b=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),x=Ut({value:o,dirty:y,onSave:(0,Q.useCallback)(async e=>{try{await wr(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!r)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(_)return(0,$.jsx)(yt,{rows:3});if(!o)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:v??t.loadError}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>void g(),children:n.refresh})]});let S=Sr(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:x.onBlurCapture,children:[x.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x.error}):null,(0,$.jsxs)(Vt,{children:[(0,$.jsx)(Bt,{icon:oe,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(Ht,{status:x.status,error:x.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(U,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:Y(`rounded-full px-2 py-0.5 text-[11px] font-medium`,S?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:S?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:S?t.cloudOverriddenHint:t.cloudAutomaticHint})]})]}),(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Nr,{row:n,providerIndex:r,labels:t,secretLabels:ot(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,b({providers:t})},onRemove:()=>{b({providers:o.providers.filter((e,t)=>t!==r)})}},n.clientKey??r)),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>b({providers:[...o.providers,Ar()]}),children:[(0,$.jsx)(se,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(Vt,{children:[(0,$.jsx)(Bt,{icon:de,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Er,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(p,{className:Or(),value:o.regionMode,onChange:e=>b({regionMode:e.target.value}),children:[(0,$.jsx)(m,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(m,{value:`cn`,children:t.regionCn}),(0,$.jsx)(m,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(Nt,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(Er,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(Lt,{type:`number`,min:1,max:50,className:Dr(),value:o.maxResults,onChange:e=>b({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.sectionBlocklist,` · `,o.blocklistEnabled?o.blocklistDomains.length:0]}),(0,$.jsxs)(Vt,{children:[(0,$.jsx)(Bt,{icon:ue,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>b({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(Er,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:Y(Dr(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
8
|
+
`),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{let t=e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]});b({blocklistDomains:t})}})}):null]})]})]})]})}function Nr(e){let t=(0,gn.c)(56),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Tr(r).then(Pr),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Or(),`min-w-[8rem]`),t[2]=u):u=t[2];let d=n.type,f;t[3]!==o||t[4]!==n?(f=e=>o({...n,type:e.target.value,url:``,apiKey:``}),t[3]=o,t[4]=n,t[5]=f):f=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=kr.map(e=>(0,$.jsx)(m,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==f||t[10]!==h?(g=(0,$.jsx)(p,{className:u,value:d,onChange:f,children:h}),t[8]=n.type,t[9]=f,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==o||t[13]!==n?(_=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=_):_=t[14];let v;t[15]!==n.disabled||t[16]!==_?(v=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==i.disabled||t[19]!==v?(y=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[v,i.disabled]}),t[18]=i.disabled,t[19]=v,t[20]=y):y=t[20];let b;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(pe,{className:`size-4`}),t[21]=b):b=t[21];let x;t[22]===s?x=t[23]:(x=(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:b}),t[22]=s,t[23]=x);let S;t[24]!==x||t[25]!==y?(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,x]}),t[24]=x,t[25]=y,t[26]=S):S=t[26];let C;t[27]!==S||t[28]!==g?(C=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,S]}),t[27]=S,t[28]=g,t[29]=C):C=t[29];let w;t[30]!==i.deepseekUrlDesc||t[31]!==i.deepseekUrlLabel||t[32]!==i.urlDesc||t[33]!==i.urlLabel||t[34]!==o||t[35]!==n?(w=n.type===`searxng`||n.type===`deepseek`?(0,$.jsx)(Er,{label:n.type===`deepseek`?i.deepseekUrlLabel:i.urlLabel,description:n.type===`deepseek`?i.deepseekUrlDesc:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Dr(),value:n.url,placeholder:n.type===`deepseek`?`https://api.deepseek.com`:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.deepseekUrlDesc,t[31]=i.deepseekUrlLabel,t[32]=i.urlDesc,t[33]=i.urlLabel,t[34]=o,t[35]=n,t[36]=w):w=t[36];let T;t[37]!==o||t[38]!==n?(T=e=>o({...n,apiKey:e}),t[37]=o,t[38]=n,t[39]=T):T=t[39];let E;t[40]!==i.keyPlaceholder||t[41]!==i.keyPlaceholderMasked||t[42]!==i.saveError||t[43]!==l||t[44]!==n.apiKey||t[45]!==a||t[46]!==T?(E=(0,$.jsx)(G,{value:n.apiKey,onChange:T,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[40]=i.keyPlaceholder,t[41]=i.keyPlaceholderMasked,t[42]=i.saveError,t[43]=l,t[44]=n.apiKey,t[45]=a,t[46]=T,t[47]=E):E=t[47];let D;t[48]!==i.apiKeyDesc||t[49]!==i.apiKeyLabel||t[50]!==E?(D=(0,$.jsx)(Er,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:E}),t[48]=i.apiKeyDesc,t[49]=i.apiKeyLabel,t[50]=E,t[51]=D):D=t[51];let O;return t[52]!==C||t[53]!==w||t[54]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[C,w,D]}),t[52]=C,t[53]=w,t[54]=D,t[55]=O):O=t[55],O}function Pr(e){return e.apiKey??null}function Fr(e,t,n=[]){return e.filter(e=>!n.includes(e.providerId)&&e.uses.some(e=>e.id===t&&e.choices.length>0))}function Ir(e){let t=(0,gn.c)(75),{use:n,data:r,language:i,labels:a,onSaved:o,inline:s,onPendingChange:c,onEditingChange:l}=e,u=s!==void 0&&s,d=i===`zh`,[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(!1),g;t[0]===c?g=t[1]:(g=e=>{h(e),c?.(e)},t[0]=c,t[1]=g);let _=g,v=n===`transcription`?`stt`:n===`speech`?`tts`:void 0,b,x,S;if(t[2]!==r.builtinRows||t[3]!==r.cards||t[4]!==r.customConfig?.providers||t[5]!==r.loading||t[6]!==n){let e=new Set(r.cards.filter(e=>!M(e.id)||!!r.customConfig?.providers?.[e.id]).map(Gr));b=[...new Set([...r.builtinRows.map(Wr),...e])].filter(t=>!M(t)||e.has(t)).sort(),x=X,S=r.loading?null:[`capability-service-connections`,n,b.join(`,`)],t[2]=r.builtinRows,t[3]=r.cards,t[4]=r.customConfig?.providers,t[5]=r.loading,t[6]=n,t[7]=b,t[8]=x,t[9]=S}else b=t[7],x=t[8],S=t[9];let C;t[10]!==b||t[11]!==n||t[12]!==v?(C=async()=>{let e=v===`stt`?await Yt():v===`tts`?await Kt():void 0,t=e?.providers.filter(Ur).map(Hr),r=e?.providers.filter(Vr).map(Br)??[],i=t?b.filter(e=>t.includes(e)):b,a=await Promise.allSettled(i.map(V));return{services:Fr(a.flatMap(zr),n,r),failed:a.some(Rr)}},t[10]=b,t[11]=n,t[12]=v,t[13]=C):C=t[13];let T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T={revalidateOnFocus:!1},t[14]=T):T=t[14];let{data:E,error:D,isLoading:O,mutate:k}=x(S,C,T),A;t[15]===E?.services?A=t[16]:(A=new Set(E?.services.map(Lr)),t[15]=E?.services,t[16]=A);let j=A,N,P;if(t[17]!==l||t[18]!==f?(N=()=>(l?.(!!f),()=>l?.(!1)),P=[f,l],t[17]=l,t[18]=f,t[19]=N,t[20]=P):(N=t[19],P=t[20]),(0,Q.useEffect)(N,P),f&&u){let e;if(t[21]!==r.builtinRows||t[22]!==f){let n;t[24]===f?n=t[25]:(n=e=>e.id===f,t[24]=f,t[25]=n),e=r.builtinRows.find(n),t[21]=r.builtinRows,t[22]=f,t[23]=e}else e=t[23];let a;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>p(void 0),t[26]=a):a=t[26];let s;t[27]!==k||t[28]!==o?(s=()=>{k(),p(void 0),o()},t[27]=k,t[28]=o,t[29]=s):s=t[29];let c;return t[30]!==i||t[31]!==f||t[32]!==_||t[33]!==e||t[34]!==s||t[35]!==n?(c=(0,$.jsx)(`section`,{className:`overflow-hidden rounded-xl border border-edge`,children:(0,$.jsx)(w,{inline:!0,providerId:f,row:e,targetUse:n,language:i,onPendingChange:_,onDone:a,onApplied:s},f)}),t[30]=i,t[31]=f,t[32]=_,t[33]=e,t[34]=s,t[35]=n,t[36]=c):c=t[36],c}let F=d?`选择服务`:`Choose a service`,I;t[37]===F?I=t[38]:(I=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:F}),t[37]=F,t[38]=I);let R;t[39]!==r.loading||t[40]!==O?(R=r.loading||O?(0,$.jsx)(we,{className:`h-24 w-full`}):null,t[39]=r.loading,t[40]=O,t[41]=R):R=t[41];let z;t[42]!==E?.failed||t[43]!==D||t[44]!==k||t[45]!==d?(z=D||E?.failed?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:[d?`部分服务目录暂时不可用。`:`Some service catalogs are unavailable.`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void k(),children:d?`重试`:`Retry`})]}):null,t[42]=E?.failed,t[43]=D,t[44]=k,t[45]=d,t[46]=z):z=t[46];let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=[!0,!1],t[47]=B):B=t[47];let ee;t[48]!==m||t[49]!==E?.services||t[50]!==d?(ee=B.map(e=>{let t=E?.services.filter(t=>t.configured===e)??[];return t.length?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:e?d?`已连接`:`Connected`:d?`添加服务`:`Add a service`}),t.map(t=>(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:()=>p(t.providerId),className:`flex min-h-14 w-full items-center justify-between gap-3 rounded-lg px-3 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg`,children:y(t.providerId,t.profile.name,d)}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm text-accent-fg`,children:e?d?`选择`:`Choose`:d?`连接`:`Connect`})]},t.providerId))]},String(e)):null}),t[48]=m,t[49]=E?.services,t[50]=d,t[51]=ee):ee=t[51];let H;t[52]!==E||t[53]!==d?(H=E&&!E.services.length&&!E.failed?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无支持此能力的模型服务。`:`No model services currently support this capability.`}):null,t[52]=E,t[53]=d,t[54]=H):H=t[54];let U=d?`仅列出支持${te[n][0]}的服务。`:`Only compatible services are shown. Reuse saved credentials, then return to select a model.`,W;t[55]===U?W=t[56]:(W=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:U}),t[55]=U,t[56]=W);let G;t[57]!==r.builtinRows||t[58]!==r.customConfig||t[59]!==j||t[60]!==a||t[61]!==i||t[62]!==k||t[63]!==o||t[64]!==f||t[65]!==n?(G=f?(0,$.jsx)(L,{open:!0,initialProviderId:f,initialUse:n,connectOnly:!0,onOpenChange:e=>{e||p(void 0)},builtinRows:r.builtinRows.filter(e=>j.has(e.id)),customConfig:r.customConfig,labels:a,language:i,onSaved:()=>{k(),p(void 0),o()}},f):null,t[57]=r.builtinRows,t[58]=r.customConfig,t[59]=j,t[60]=a,t[61]=i,t[62]=k,t[63]=o,t[64]=f,t[65]=n,t[66]=G):G=t[66];let ne;return t[67]!==I||t[68]!==R||t[69]!==z||t[70]!==ee||t[71]!==H||t[72]!==W||t[73]!==G?(ne=(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[I,R,z,ee,H,W,G]}),t[67]=I,t[68]=R,t[69]=z,t[70]=ee,t[71]=H,t[72]=W,t[73]=G,t[74]=ne):ne=t[74],ne}function Lr(e){return e.providerId}function Rr(e){return e.status===`rejected`}function zr(e){return e.status===`fulfilled`?[e.value]:[]}function Br(e){return e.id}function Vr(e){return e.diagnostics.requiresApiKey}function Hr(e){return e.id}function Ur(e){return!e.diagnostics.requiresApiKey}function Wr(e){return e.id}function Gr(e){return e.id}function Kr({zh:e,kind:t,modelServiceIds:n,onSaved:r,onPendingChange:i}){let{data:a,error:o,mutate:s}=X([`native-voice-connections`,t??`all`,n.join(`,`)],async()=>{let[e,r]=await Promise.all([t===`tts`?Promise.resolve({providers:[]}):Yt(),t===`stt`?Promise.resolve({providers:[]}):Kt()]);return[...e.providers.map(e=>({...e,kind:`stt`})),...r.providers.map(e=>({...e,kind:`tts`}))].filter(e=>e.diagnostics.requiresApiKey||!n.includes(e.id))}),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[f,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(!1),[_,v]=(0,Q.useState)(``);(0,Q.useEffect)(()=>(i?.(f),()=>i?.(!1)),[f,i]);let y=a?.find(e=>`${e.kind}:${e.id}`===c),b=y?.fields.filter(e=>e.secret||e.type===`password`||[`baseUrl`,`region`,`groupId`].includes(e.key))??[],x=async()=>{if(!(!y||g.current)){g.current=!0,h(!0),v(``);try{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()).map(([e,t])=>[e,t.trim()]));Object.keys(t).length&&await Ce(be(`/api/config`),{method:`PATCH`,body:JSON.stringify({[y.kind]:{providers:{[y.id]:t}}})});let[n]=await Promise.all([s(),bt()]);if(!n?.find(e=>e.kind===y.kind&&e.id===y.id)?.configured)throw Error(e?`连接尚未就绪,请补齐所需凭据。`:`Connection is not ready. Complete the required credentials.`);d({}),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g.current=!1,h(!1)}}};return a&&!a.length?null:(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e?`其他语音服务与本地语音`:`Other voice services and local speech`}),(0,$.jsxs)(`section`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`stt`?e?`其他识别服务`:`Other recognition services`:t===`tts`?e?`其他合成服务与本地语音`:`Other synthesis services and local speech`:e?`语音 API 与本地语音`:`Voice APIs and local speech`}),!a&&!o?(0,$.jsx)(we,{className:`h-20 w-full`}):null,o?(0,$.jsxs)(`p`,{role:`alert`,children:[e?`语音服务加载失败`:`Could not load voice services`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void s(),children:e?`重试`:`Retry`})]}):null,(0,$.jsxs)(p,{value:c,disabled:f,"aria-label":e?`语音服务接入`:`Connect voice service`,onChange:e=>{l(e.target.value),d({}),v(``)},children:[(0,$.jsx)(m,{value:``,children:e?`选择语音来源`:`Choose a voice source`}),a?.map(n=>(0,$.jsxs)(m,{value:`${n.kind}:${n.id}`,children:[n.displayName,t?``:` · ${n.kind.toUpperCase()}`,n.configured?e?` · 已连接`:` · Connected`:``]},`${n.kind}:${n.id}`))]}),y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:y.diagnostics.requiresApiKey?e?`此服务使用独立的 API Key。保存连接后,可在“模型与参数”中选用。`:`This service uses its own API key. Save the connection, then choose it in Model and parameters.`:e?`此来源无需 API Key,可返回能力设置选择。`:`No API key needed. Choose this source in capability settings.`}),b.map(t=>(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:t.label}),t.secret||t.type===`password`?(0,$.jsx)(G,{labels:st,value:u[t.key]??``,onChange:e=>d(n=>({...n,[t.key]:e})),disabled:f}):t.options?.length?(0,$.jsxs)(p,{value:u[t.key]??``,disabled:f,onChange:e=>d(n=>({...n,[t.key]:e.target.value})),children:[(0,$.jsx)(m,{value:``,children:e?`保留现有值`:`Keep existing`}),t.options.map(e=>(0,$.jsx)(m,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel p-2`,value:u[t.key]??``,disabled:f,placeholder:t.placeholder,onChange:e=>d(n=>({...n,[t.key]:e.target.value}))})]},t.key)),_?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:_}):null,(0,$.jsx)(Z,{disabled:f||!y.configured&&y.diagnostics.requiresApiKey&&!Object.values(u).some(e=>e.trim()),onClick:()=>void x(),children:f?e?`保存中…`:`Saving…`:e?`保存连接`:`Save connection`})]}):null]})]})}function qr(e){let t=(0,gn.c)(40),{label:n,value:r,currentLabel:i,options:a,loading:o,disabled:s,zh:c,onConnect:l,onSelect:u}=e,[d,f]=(0,Q.useState)(``),p;if(t[0]!==a||t[1]!==d){let e=d.trim().toLowerCase().split(/\s+/).filter(Boolean);p=a.filter(t=>{let n=`${t.label} ${t.group} ${t.value} ${t.searchText??``}`.toLowerCase();return e.every(e=>n.includes(e))}),t[0]=a,t[1]=d,t[2]=p}else p=t[2];let m=p,g;if(t[3]!==a||t[4]!==r){let e;t[6]===r?e=t[7]:(e=e=>e.value===r,t[6]=r,t[7]=e),g=a.find(e),t[3]=a,t[4]=r,t[5]=g}else g=t[5];let _=g,v;t[8]!==a||t[9]!==_?.group||t[10]!==r?(v=_?.group??a.find(e=>e.value.split(`/`)[0]===r?.split(`/`)[0])?.group,t[8]=a,t[9]=_?.group,t[10]=r,t[11]=v):v=t[11];let y=v,b;t[12]!==i||t[13]!==_?.label||t[14]!==r||t[15]!==c?(b=_?.label??(r?.endsWith(`/default`)?c?`默认模型`:`Default model`:i??r),t[12]=i,t[13]=_?.label,t[14]=r,t[15]=c,t[16]=b):b=t[16];let x=b,S=y?`${x} · ${y}`:x;if(!o&&!a.length){let e=`${c?`连接`:`Connect`} ${n}`,r=c?`连接服务以启用`:`Connect a service to enable`,i;return t[17]!==s||t[18]!==l||t[19]!==e||t[20]!==r?(i=(0,$.jsx)(Z,{variant:`secondary`,className:`min-h-11 w-full sm:justify-start`,"aria-label":e,disabled:s,onClick:l,children:r}),t[17]=s,t[18]=l,t[19]=e,t[20]=r,t[21]=i):i=t[21],i}let C=r??``,w=c?`选择模型`:`Choose a model`,T=`${c?`选择`:`Select`} ${n}`,E=c?`搜索模型或服务`:`Search models or services`,D=m.length?void 0:c?`没有可用模型`:`No available models`,O;t[22]!==s||t[23]!==m||t[24]!==o||t[25]!==x||t[26]!==u||t[27]!==d||t[28]!==S||t[29]!==C||t[30]!==w||t[31]!==T||t[32]!==E||t[33]!==D?(O=(0,$.jsx)(h,{value:C,options:m,selectedLabel:x,title:S,placeholder:w,ariaLabel:T,allowEmpty:!1,disabled:s,loading:o,onChange:u,searchPlaceholder:E,searchValue:d,onSearchChange:f,statusMessage:D,triggerClassName:`min-h-11`}),t[22]=s,t[23]=m,t[24]=o,t[25]=x,t[26]=u,t[27]=d,t[28]=S,t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D,t[34]=O):O=t[34];let k;t[35]===y?k=t[36]:(k=y?(0,$.jsx)(`p`,{className:`px-1 text-xs text-fg-muted`,children:y}):null,t[35]=y,t[36]=k);let A;return t[37]!==O||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[O,k]}),t[37]=O,t[38]=k,t[39]=A):A=t[39],A}function Jr({data:e,zh:t,onChange:n,onSettings:r,onlyUse:i,disabled:a=!1,onPendingChange:o}){let{data:s,error:c,mutate:l}=X(`settings-agent-defaults`,vt),{data:u}=Qe(!0),{data:d,isLoading:f,error:p,mutate:m}=X(`model-capability-media-sources`,async()=>{let e=await Promise.allSettled([Kt(),Yt(),on()]);return{ids:[...new Set(e.flatMap(e=>e.status===`fulfilled`?(Array.isArray(e.value)?e.value:e.value.providers).filter(e=>e.configured).map(e=>e.id):[]))],failed:e.some(e=>e.status===`rejected`)}}),h=[...new Set([...e.cards.filter(t=>t.configured&&(!M(t.id)||!!e.customConfig?.providers?.[t.id])).map(e=>e.id),...d?.ids??[]])].sort(),{data:g,isLoading:_,mutate:v}=X(e.loading?null:[`model-use-choices`,...h],async()=>{let e=await Promise.allSettled(h.map(V));return{previews:e.flatMap(e=>e.status===`fulfilled`&&e.value.configured?[e.value]:[]),failed:e.some(e=>e.status===`rejected`)}},{revalidateOnFocus:!1}),[y,b]=(0,Q.useState)(null),[x,w]=(0,Q.useState)(null),E=(0,Q.useRef)(!1),D=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>o?.(!1),[o]);let O=async(e,t)=>{if(E.current||a)return;let n=g?.previews.find(n=>n.uses.some(n=>n.id===e&&n.choices.some(e=>e.id===t)));if(!n)return;E.current=!0,o?.(!0),b(e),w(null);let r={mode:`replace`,selected:[e],overrides:{[e]:t}};try{let t=await H(n.providerId,r);await C(n.providerId,r,t.revision),await Promise.all([l(),v()]),w({use:e})}catch(t){w({use:e,error:t instanceof Error?t.message:String(t)}),Promise.allSettled([l(),v()])}finally{E.current=!1,b(null),o?.(!1),requestAnimationFrame(()=>D.current?.querySelector(`[data-capability="${e}"] button[aria-label]`)?.focus())}},k=u?.payload?.config?Zt(u.payload.config):void 0;if(!s&&!c)return(0,$.jsx)(we,{className:`h-48 w-full rounded-xl`});if(c)return(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[t?`模型用途加载失败`:`Could not load model uses`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void l(),children:t?`重试`:`Retry`})]});let A=s.defaults.models,j=A.background?.primary??A.chat.primary,N=e.builtinRows.find(e=>e.id===j.split(`/`)[0])?.setupProfile?.interactiveOnly!==!0,P=g?.previews[0]?.uses.find(e=>e.id===`background`),F=P?P.current:N?j:void 0,I=[{id:`chat`,label:t?`对话与任务`:`Chat and tasks`,ref:A.chat.primary},{id:`vision`,label:t?`看图`:`Image understanding`,ref:A.imageUnderstanding?.primary},{id:`image`,label:t?`画图`:`Image generation`,ref:A.imageGeneration?.primary},{id:`background`,label:t?`后台任务`:`Background tasks`,ref:F,inherited:!A.background&&!!F},{id:`transcription`,label:t?`录音与听写`:`Recording and dictation`,ref:k?.stt.enabled?`${k.stt.provider}/${k.stt.providers?.[k.stt.provider]?.model??`default`}`:void 0},{id:`speech`,label:t?`语音合成`:`Speech synthesis`,ref:k?.tts.enabled?`${k.tts.provider}/${k.tts.providers?.[k.tts.provider]?.model??`default`}`:void 0},{id:`conversation`,label:t?`实时语音对话`:`Realtime conversation`,ref:k?.voice.realtime.enabled?k.voice.realtime.defaultEngine===`omni`&&k.voice.realtime.omni?`${k.voice.realtime.omni.provider}/${k.voice.realtime.omni.model}`:k.voice.realtime.defaultEngine===`agent`?`agent`:void 0:void 0}];return(0,$.jsxs)(`section`,{ref:D,className:`@container min-w-0`,children:[(0,$.jsx)(`h2`,{className:i?`mb-2 text-sm font-semibold text-fg`:`sr-only`,children:i?t?`当前模型`:`Current model`:t?`能力总览`:`Capabilities`}),(0,$.jsx)(`div`,{className:i?`space-y-4`:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:T.filter(e=>!i||e.uses.includes(i)).map(o=>(0,$.jsxs)(`section`,{className:i?`min-w-0`:`min-w-0 border-t border-edge first:border-t-0`,children:[i?null:(0,$.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-inset/55 px-4 py-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:o.label[+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.uses[0]===`chat`?t?`基础能力`:`Core capability`:t?`按需启用`:`Optional`})]}),(0,$.jsx)(`div`,{className:i?`divide-y divide-edge-subtle`:`divide-y divide-edge-subtle px-4`,children:o.uses.filter(e=>!i||e===i).map(o=>{let s=I.find(e=>e.id===o),c=Yr(g?.previews??[],s.id,t),l=s.id===`conversation`&&k?.voice.realtime.enabled&&k.voice.realtime.defaultEngine===`agent`?t?`语音助手 · 使用对话、听写和语音输出配置`:`Voice assistant · Uses chat, dictation and voice output`:s.ref?e.allModels.find(e=>e.id===s.ref)?.name??s.ref:void 0;return(0,$.jsx)(`div`,{"data-capability":s.id,children:(0,$.jsxs)(`div`,{className:i?`py-2`:`grid grid-cols-1 items-center gap-x-3 gap-y-2 py-3 @min-[40rem]:gap-x-4 ${r?`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_auto]`:`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)]`}`,children:[(0,$.jsxs)(`div`,{className:i?`hidden`:`col-start-1 row-start-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:te[s.id][+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:s.ref?c.some(e=>e.value===s.ref||s.ref?.endsWith(`/default`)&&e.value.split(`/`)[0]===s.ref.split(`/`)[0])||s.ref===`agent`?null:t?`待连接`:`Connection needed`:t?`未配置`:`Not set up`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:S[s.id][+!t]}),s.inherited?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t?`继承默认对话`:`Inherits chat default`}):null]}),(0,$.jsxs)(`div`,{className:i?`w-full min-w-0 space-y-1`:`row-start-2 w-full min-w-0 space-y-1 @min-[40rem]:col-span-1 @min-[40rem]:col-start-2 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(qr,{label:te[s.id][+!t],value:s.ref,currentLabel:l,options:c,loading:e.loading||_||f,disabled:y!==null||a,zh:t,onConnect:()=>n(s.id),onSelect:e=>{e!==s.ref&&O(s.id,e)}}),y===s.id?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`正在切换…`:`Switching…`}):null,x?.use===s.id?(0,$.jsx)(`div`,{role:x.error?`alert`:`status`,className:`text-xs text-fg-muted`,children:x.error?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-danger`,children:t?`未能切换模型,请重试。`:`Could not switch models. Please retry.`}),(0,$.jsxs)(`details`,{className:`mt-1`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:t?`查看详情`:`Show details`}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:x.error})]})]}):t?`已切换`:`Model changed`}):null]}),r&&(c.length>0||_||f)?(0,$.jsxs)(`div`,{className:`row-start-3 flex flex-wrap items-center justify-end gap-1 @min-[40rem]:col-start-3 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Z,{variant:`ghost`,disabled:y!==null||a,onClick:()=>r(s.id),children:t?`设置`:`Settings`}),(0,$.jsx)(Z,{variant:`ghost`,disabled:y!==null||a,onClick:()=>n(s.id),children:t?`管理服务`:`Manage services`})]}):null]})},s.id)})})]},o.uses[0]))}),(!r||i)&&(g?.failed||d?.failed||p)?(0,$.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:[t?`部分服务的模型加载失败`:`Some model services could not be loaded`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Promise.all([m(),v()]),children:t?`重试`:`Retry`})]}):null,i||r?null:(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t?`快速与复杂任务模型随对话配置;音色、流式听写及电脑操作可在详细设置中调整。`:`Fast and complex task models follow chat setup. Voices, streaming dictation and Computer Use have detailed settings.`})]})}function Yr(e,t,n=!1){return e.flatMap(e=>e.uses.find(e=>e.id===t)?.choices.map(t=>({value:t.id,label:t.name,group:y(e.providerId,e.profile.name,n),searchText:e.profile.name}))??[])}function Xr(e){let t=(0,gn.c)(205),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=Se(Qr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:O(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,h]=(0,Q.useState)(Zr),g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{d(n=>({...n,[e]:t})),h(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=g):g=t[2];let _=g,v;t[3]!==u.computerUse||t[4]!==u.contextWindow||t[5]!==u.id||t[6]!==u.input||t[7]!==u.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(v=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),u.computerUse&&!u.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),h(e),e.size===0},t[3]=u.computerUse,t[4]=u.contextWindow,t[5]=u.id,t[6]=u.input,t[7]=u.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=v):v=t[11];let y=v,b;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim(),t={...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}};a(t),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=b):b=t[16];let x=b,S=u,C;t[17]===S?C=t[18]:(C=B(S),t[17]=S,t[18]=C);let w=C,T=r?s.addModelTitle:s.editModelTitle,k;t[19]===T?k=t[20]:(k=(0,$.jsx)(Ae,{className:`text-base font-semibold text-fg`,children:T}),t[19]=T,t[20]=k);let A;t[21]!==s.modelProviderLabel||t[22]!==i?(A=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=A):A=t[23];let j;t[24]!==k||t[25]!==A?(j=(0,$.jsxs)(`div`,{children:[k,A]}),t[24]=k,t[25]=A,t[26]=j):j=t[26];let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(Xe,`p-1.5 hover:bg-surface-base`),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(_e,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(De,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:M,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let I;t[31]!==j||t[32]!==P?(I=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[j,P]}),t[31]=j,t[32]=P,t[33]=I):I=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=L):L=t[34];let z;t[35]===s.modelId?z=t[36]:(z=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,L]}),t[35]=s.modelId,t[36]=z);let V;t[37]===f?V=t[38]:(V=Y(R(),f.has(`id`)&&`border-red-500`),t[37]=f,t[38]=V);let ee=u.id||``,te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>_(`id`,e.target.value),t[39]=te):te=t[39];let H=!r,U;t[40]!==V||t[41]!==ee||t[42]!==H?(U=(0,$.jsx)(`input`,{className:V,value:ee,onChange:te,placeholder:`e.g. llama3.1:8b`,disabled:H}),t[40]=V,t[41]=ee,t[42]=H,t[43]=U):U=t[43];let W;t[44]===f?W=t[45]:(W=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[44]=f,t[45]=W);let G;t[46]!==z||t[47]!==U||t[48]!==W?(G=(0,$.jsxs)(`div`,{children:[z,U,W]}),t[46]=z,t[47]=U,t[48]=W,t[49]=G):G=t[49];let ne;t[50]===s.displayName?ne=t[51]:(ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=ne);let K;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(K=R(),t[52]=K):K=t[52];let re=u.name||``,q;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>_(`name`,e.target.value),t[53]=q):q=t[53];let ie;t[54]===re?ie=t[55]:(ie=(0,$.jsx)(`input`,{className:K,value:re,onChange:q}),t[54]=re,t[55]=ie);let J;t[56]!==ne||t[57]!==ie?(J=(0,$.jsxs)(`div`,{children:[ne,ie]}),t[56]=ne,t[57]=ie,t[58]=J):J=t[58];let ae;t[59]===s.inputTypes?ae=t[60]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=ae);let oe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(oe=D(),t[61]=oe):oe=t[61];let se;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>_(`input`,E(e.target.value)),t[62]=se):se=t[62];let ce;t[63]===s?ce=t[64]:(ce=F.map(e=>(0,$.jsx)(m,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=ce);let le;t[65]!==w||t[66]!==ce?(le=(0,$.jsx)(p,{className:oe,value:w,onChange:se,children:ce}),t[65]=w,t[66]=ce,t[67]=le):le=t[67];let ue;t[68]!==ae||t[69]!==le?(ue=(0,$.jsxs)(`div`,{children:[ae,le]}),t[68]=ae,t[69]=le,t[70]=ue):ue=t[70];let de=u.reasoning||!1,fe;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(fe=e=>_(`reasoning`,e.target.checked),t[71]=fe):fe=t[71];let pe;t[72]===de?pe=t[73]:(pe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:de,onChange:fe}),t[72]=de,t[73]=pe);let me;t[74]!==s.reasoning||t[75]!==pe?(me=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[pe,s.reasoning]}),t[74]=s.reasoning,t[75]=pe,t[76]=me):me=t[76];let he;t[77]!==ue||t[78]!==me?(he=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ue,me]}),t[77]=ue,t[78]=me,t[79]=he):he=t[79];let ge;t[80]===s.contextWindow?ge=t[81]:(ge=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=ge);let ve;t[82]===f?ve=t[83]:(ve=Y(R(),f.has(`contextWindow`)&&`border-red-500`),t[82]=f,t[83]=ve);let ye=u.contextWindow??128e3,be;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>_(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=be):be=t[84];let xe;t[85]!==ve||t[86]!==ye?(xe=(0,$.jsx)(Lt,{type:`number`,min:1,className:ve,value:ye,onChange:be}),t[85]=ve,t[86]=ye,t[87]=xe):xe=t[87];let Ce;t[88]===f?Ce=t[89]:(Ce=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[88]=f,t[89]=Ce);let X;t[90]!==ge||t[91]!==xe||t[92]!==Ce?(X=(0,$.jsxs)(`div`,{children:[ge,xe,Ce]}),t[90]=ge,t[91]=xe,t[92]=Ce,t[93]=X):X=t[93];let we;t[94]===s.maxOutputTokens?we=t[95]:(we=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=we);let Te;t[96]===f?Te=t[97]:(Te=Y(R(),f.has(`maxTokens`)&&`border-red-500`),t[96]=f,t[97]=Te);let Ee=u.maxTokens??16384,Oe;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=Oe):Oe=t[98];let ke;t[99]!==Te||t[100]!==Ee?(ke=(0,$.jsx)(Lt,{type:`number`,min:1,className:Te,value:Ee,onChange:Oe}),t[99]=Te,t[100]=Ee,t[101]=ke):ke=t[101];let je;t[102]===f?je=t[103]:(je=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[102]=f,t[103]=je);let Me;t[104]!==we||t[105]!==ke||t[106]!==je?(Me=(0,$.jsxs)(`div`,{children:[we,ke,je]}),t[104]=we,t[105]=ke,t[106]=je,t[107]=Me):Me=t[107];let Ne;t[108]!==X||t[109]!==Me?(Ne=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[X,Me]}),t[108]=X,t[109]=Me,t[110]=Ne):Ne=t[110];let Pe;t[111]===s.costSection?Pe=t[112]:(Pe=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Pe);let Fe;t[113]===s.costInput?Fe=t[114]:(Fe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Fe);let Ie;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=R(),t[115]=Ie):Ie=t[115];let Le=u.cost?.input??0,Re;t[116]===u.cost?Re=t[117]:(Re=e=>_(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[116]=u.cost,t[117]=Re);let ze;t[118]!==Le||t[119]!==Re?(ze=(0,$.jsx)(Lt,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[118]=Le,t[119]=Re,t[120]=ze):ze=t[120];let Be;t[121]!==Fe||t[122]!==ze?(Be=(0,$.jsxs)(`div`,{children:[Fe,ze]}),t[121]=Fe,t[122]=ze,t[123]=Be):Be=t[123];let Ve;t[124]===s.costOutput?Ve=t[125]:(Ve=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=Ve);let He;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(He=R(),t[126]=He):He=t[126];let Ue=u.cost?.output??0,We;t[127]===u.cost?We=t[128]:(We=e=>_(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[127]=u.cost,t[128]=We);let Ge;t[129]!==Ue||t[130]!==We?(Ge=(0,$.jsx)(Lt,{type:`number`,step:`any`,min:0,className:He,value:Ue,onChange:We}),t[129]=Ue,t[130]=We,t[131]=Ge):Ge=t[131];let Ke;t[132]!==Ve||t[133]!==Ge?(Ke=(0,$.jsxs)(`div`,{children:[Ve,Ge]}),t[132]=Ve,t[133]=Ge,t[134]=Ke):Ke=t[134];let qe;t[135]!==Be||t[136]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Be,Ke]}),t[135]=Be,t[136]=Ke,t[137]=qe):qe=t[137];let Je;t[138]!==Pe||t[139]!==qe?(Je=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Pe,qe]}),t[138]=Pe,t[139]=qe,t[140]=Je):Je=t[140];let Ye;t[141]!==G||t[142]!==J||t[143]!==he||t[144]!==Ne||t[145]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[G,J,he,Ne,Je]}),t[141]=G,t[142]=J,t[143]=he,t[144]=Ne,t[145]=Je,t[146]=Ye):Ye=t[146];let Ze=c?`高级:手机操作协议`:`Advanced: Phone Use protocol`,Qe;t[147]===Ze?Qe=t[148]:(Qe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ze}),t[147]=Ze,t[148]=Qe);let $e=c?`手机操作协议`:`Phone Use protocol`,et=u.phoneUse?.profile??``,tt;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(tt=e=>_(`phoneUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=tt):tt=t[149];let nt=c?`未声明`:`Not declared`,rt;t[150]===nt?rt=t[151]:(rt=(0,$.jsx)(m,{value:``,children:nt}),t[150]=nt,t[151]=rt);let it,at;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,$.jsx)(m,{value:`autoglm-phone-v1`,children:`AutoGLM Phone`}),at=(0,$.jsx)(m,{value:`structured-phone-v1`,children:`Structured Phone`}),t[152]=it,t[153]=at):(it=t[152],at=t[153]);let ot;t[154]!==$e||t[155]!==et||t[156]!==rt?(ot=(0,$.jsxs)(p,{"aria-label":$e,value:et,onChange:tt,children:[rt,it,at]}),t[154]=$e,t[155]=et,t[156]=rt,t[157]=ot):ot=t[157];let st=c?`需要图片输入与 OpenAI Chat Completions API;配置后在手机控制中选择。`:`Requires image input and an OpenAI Chat Completions API. Select the model in Phone Use settings.`,ct;t[158]===st?ct=t[159]:(ct=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:st}),t[158]=st,t[159]=ct);let lt;t[160]!==ot||t[161]!==ct?(lt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[ot,ct]}),t[160]=ot,t[161]=ct,t[162]=lt):lt=t[162];let ut;t[163]!==Qe||t[164]!==lt?(ut=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Qe,lt]}),t[163]=Qe,t[164]=lt,t[165]=ut):ut=t[165];let dt=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,ft;t[166]===dt?ft=t[167]:(ft=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:dt}),t[166]=dt,t[167]=ft);let pt=c?`电脑控制协议`:`Computer Use protocol`,mt=u.computerUse?.profile??``,ht;t[168]===Symbol.for(`react.memo_cache_sentinel`)?(ht=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[168]=ht):ht=t[168];let gt=c?`未声明`:`Not declared`,_t;t[169]===gt?_t=t[170]:(_t=(0,$.jsx)(m,{value:``,children:gt}),t[169]=gt,t[170]=_t);let vt,yt,bt;t[171]===Symbol.for(`react.memo_cache_sentinel`)?(vt=(0,$.jsx)(m,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),yt=(0,$.jsx)(m,{value:`structured-tools-v1`,children:`structured-tools-v1`}),bt=(0,$.jsx)(m,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[171]=vt,t[172]=yt,t[173]=bt):(vt=t[171],yt=t[172],bt=t[173]);let xt;t[174]!==pt||t[175]!==mt||t[176]!==_t?(xt=(0,$.jsxs)(p,{"aria-label":pt,value:mt,onChange:ht,children:[_t,vt,yt,bt]}),t[174]=pt,t[175]=mt,t[176]=_t,t[177]=xt):xt=t[177];let St=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,Ct;t[178]===St?Ct=t[179]:(Ct=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:St}),t[178]=St,t[179]=Ct);let wt;t[180]===f?wt=t[181]:(wt=f.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:f.get(`computerUse`)}),t[180]=f,t[181]=wt);let Tt;t[182]!==xt||t[183]!==Ct||t[184]!==wt?(Tt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[xt,Ct,wt]}),t[182]=xt,t[183]=Ct,t[184]=wt,t[185]=Tt):Tt=t[185];let Et;t[186]!==Tt||t[187]!==ft?(Et=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[ft,Tt]}),t[186]=Tt,t[187]=ft,t[188]=Et):Et=t[188];let Dt;t[189]!==Et||t[190]!==Ye||t[191]!==ut?(Dt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Ye,ut,Et]}),t[189]=Et,t[190]=Ye,t[191]=ut,t[192]=Dt):Dt=t[192];let Ot;t[193]===s.cancel?Ot=t[194]:(Ot=(0,$.jsx)(De,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`secondary`,children:s.cancel})}),t[193]=s.cancel,t[194]=Ot);let kt=r?s.addModelConfirm:s.saveModelConfirm,At;t[195]!==x||t[196]!==kt?(At=(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:x,children:kt}),t[195]=x,t[196]=kt,t[197]=At):At=t[197];let jt;t[198]!==Ot||t[199]!==At?(jt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Ot,At]}),t[198]=Ot,t[199]=At,t[200]=jt):jt=t[200];let Mt;return t[201]!==Dt||t[202]!==jt||t[203]!==I?(Mt=(0,$.jsxs)($.Fragment,{children:[I,Dt,jt]}),t[201]=Dt,t[202]=jt,t[203]=I,t[204]=Mt):Mt=t[204],Mt}function Zr(){return new Map}function Qr(e){return e.language}function $r(e){let t=(0,gn.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Te,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Ne)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,Me,`overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(Xr,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(Oe,{children:[l,(0,$.jsx)(ke,{className:u,onOpenAutoFocus:ei,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(je,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function ei(e){return e.preventDefault()}function ti(e){let t=(0,gn.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Tt(n).then(ni),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(G,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function ni(e){return e.apiKey??null}function ri(e){let t=(0,gn.c)(23),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),_;t[0]===r?_=t[1]:(_=e=>{e||(g(null),m(!1)),r(e)},t[0]=r,t[1]=_);let v=_,y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Te,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ne)}),t[2]=y):y=t[2];let b,x,S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{f.current=document.activeElement instanceof HTMLElement?document.activeElement:null},x=e=>{f.current?.isConnected&&(e.preventDefault(),f.current.focus({preventScroll:!0}))},S=Y(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,Me),t[3]=b,t[4]=x,t[5]=S):(b=t[3],x=t[4],S=t[5]);let C;t[6]!==c||t[7]!==o||t[8]!==s||t[9]!==v||t[10]!==a||t[11]!==l||t[12]!==u||t[13]!==r||t[14]!==d||t[15]!==i||t[16]!==p||t[17]!==h?(C=(0,$.jsxs)(Oe,{children:[y,(0,$.jsx)(ke,{onOpenAutoFocus:b,onCloseAutoFocus:x,className:S,children:h?(0,$.jsx)(j,{target:h,zh:u===`zh`,onDone:()=>v(!1)}):!a&&p?(0,$.jsx)(w,{providerId:i,existingConnection:!0,row:o.find(e=>e.id===i),language:u,onApplied:d,onBack:()=>m(!1),onDone:()=>v(!1)}):a?(0,$.jsx)(ai,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>g({providerId:i,modelIds:[e]})}):(0,$.jsx)(ii,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onQuickSetup:()=>m(!0)})})]}),t[6]=c,t[7]=o,t[8]=s,t[9]=v,t[10]=a,t[11]=l,t[12]=u,t[13]=r,t[14]=d,t[15]=i,t[16]=p,t[17]=h,t[18]=C):C=t[18];let T;return t[19]!==v||t[20]!==n||t[21]!==C?(T=(0,$.jsx)(je,{open:n,onOpenChange:v,children:C}),t[19]=v,t[20]=n,t[21]=C,t[22]=T):T=t[22],T}function ii({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o,onQuickSetup:s}){let c=t.find(t=>t.id===e),u=N[e],d=n.filter(t=>t.provider===e),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(c?.apiKey??``),[_,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),E=ve(i).providersSettings,D=c?.supportsApiKey!==!1,O=c?.supportsOAuth===!0,j=c?.authMode===`oauth`&&c.authStatus===`connected`,M=c?.configured===!0&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[P,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(`idle`),[B,V]=(0,Q.useState)(null),[ee,te]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[G,ne]=(0,Q.useState)(``),K=(0,Q.useRef)(null),re=(0,Q.useRef)(null),ie=R===`waiting`||R===`waiting_code`,J=(0,Q.useMemo)(()=>A(e,i),[e,i]),ae=m!==(c?.apiKey??``),oe=async()=>{let t=m.trim();if(!(!t||!D||wt(t))){y(!0),C(null);try{await Ct({[e]:t}),x(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){C(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,Q.useEffect)(()=>{if(!P||!ie)return;let e=window.setInterval(()=>{(async()=>{try{let t=await jt(P);t.status===`waiting_auth`||t.status===`waiting_code`?(z(t.status===`waiting_code`?`waiting_code`:`waiting`),L(t.message??null),V(t.authUrl??null),te(t.instructions??null),U(t.deviceCode??null),t.authUrl&&t.authUrl!==re.current&&(re.current=t.authUrl,Pt(t.authUrl,K.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),It(K.current),K.current=null,z(`success`),L(t.message??E.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),It(K.current),K.current=null,z(`error`),L(t.error??t.message??E.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ie,a,o,E.revokeFailed,E.saved]),(0,Q.useEffect)(()=>()=>{P&&kt(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{It(K.current),K.current=null},[]);let se=async()=>{try{await Et(e),o(),a()}catch{}},ce=async()=>{It(K.current),K.current=Ft(),re.current=null,z(`waiting`),L(E.oauthStarting),V(null),te(null),U(null),C(null);try{let t=await Dt(e);F(t.sessionId)}catch(e){It(K.current),K.current=null,z(`error`),L(e instanceof Error?e.message:E.revokeFailed)}},le=async()=>{if(P){try{await Mt(P)}catch{}It(K.current),K.current=null,re.current=null,z(`idle`),L(null),F(null),V(null),te(null),U(null)}},ue=async()=>{if(!(!P||!G.trim()))try{await At(P,G.trim()),ne(``),L(E.oauthProcessingCode)}catch(e){z(`error`),L(e instanceof Error?e.message:E.revokeFailed)}},de=async()=>{try{await Ot(e),o(),a()}catch(e){C(e instanceof Error?e.message:E.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(Ae,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(De,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ye.press),children:(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[s?(0,$.jsx)(Z,{variant:`secondary`,onClick:s,children:i===`zh`?`配置模型用途`:`Configure model uses`}):null,u?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,c?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:c.baseUrl})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,D?(0,$.jsx)(ti,{providerId:e,inputId:`manage-api-key`,value:m,onChange:e=>{h(e),x(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):c?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),c?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(W,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,O?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:E.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:j?E.sourceOauth:E.oauthHint})]}),j?(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void de(),children:E.revoke}):(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ie,onClick:()=>void ce(),children:[ie?(0,$.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),E.oauth]})]}),I?(0,$.jsx)(`p`,{className:Y(`text-xs`,R===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:I}):null,R===`waiting`||R===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[B?(0,$.jsxs)(`a`,{href:B,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(W,{className:`size-4`,"aria-hidden":!0}),E.openAuthPage]}):null,(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>void le(),children:E.cancelOAuth})]}):null,ee?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ee}):null,H?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:E.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:H}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:E.deviceCodeHint})]}):null,R===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:G,onChange:e=>ne(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ue(),placeholder:E.pasteRedirectUrl,className:Y(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,it)}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,onClick:()=>void ue(),children:E.submitCode})]}):null]}):null,J.length>0&&D?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:J.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[k(e,r),(0,$.jsx)(W,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:f,onChange:e=>p(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.filter(e=>!f||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[ht(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),S?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[M?(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>T(!0),children:[(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:D&&ae&&!wt(m.trim())?(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:!m.trim()||_||b,onClick:()=>void oe(),children:b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(pt,{open:w,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void se(),onCancel:()=>T(!1)})]})}function ai({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=ve(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[p,m]=(0,Q.useState)(c?.models??[]),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),j=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:wt(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},M=async()=>{let e=j({models:p,modelDiscovery:{enabled:_}});if(e){b(!0),S(null);try{await I(e),a(),i()}catch(e){S(e instanceof Error?e.message:n.saveError)}finally{b(!1)}}},N=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await I({providers:r}),a(),i()}catch{}},P=(e,t)=>{A({model:e,isNew:t}),O(!0)},F=async e=>{if(!k)return;let t=k.isNew&&!p.some(t=>t.id===e.id),r=k.isNew?[...p,e]:p.map(t=>t.id===e.id?e:t);m(r);let i=j({models:r});if(i)try{await I(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){S(e instanceof Error?e.message:n.saveError)}},L=async e=>{let t=p.filter(t=>t.id!==e);m(t),E(null);let r=j({models:t});if(r)try{await I(r),a()}catch(e){S(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ae,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(De,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ye.press),children:(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),className:Y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,it)})]}),(0,$.jsx)(ti,{providerId:e,inputId:`manage-custom-api-key`,value:d,onChange:f,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[s.modelsSection,p.length>0?` (${p.length})`:``]}),(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>P(null,!0),children:[(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),s.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:h,onChange:e=>g(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),p.filter(e=>!h||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.filter(e=>!h||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ye.press),onClick:()=>P(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(J,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Ye.press),onClick:()=>E(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>w(!0),children:[(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:y,onClick:()=>void M(),children:y?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(pt,{open:C,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void N(),onCancel:()=>w(!1)}),(0,$.jsx)(pt,{open:T!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,T??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{T&&L(T)},onCancel:()=>E(null)}),(0,$.jsx)($r,{open:D,onOpenChange:e=>{O(e),e||A(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void F(e),m:s})]})}var oi=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],si=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,ci={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function li(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function ui(e){let t=(0,gn.c)(38),{draft:n,setDraft:r,zh:i,capability:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=X(et,$e,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l=c,u=i?ci.zh:ci.en,d;t[3]!==n||t[4]!==r?(d=(e,t)=>{let i={...n.models.intents};t?i[e]=li(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[3]=n,t[4]=r,t[5]=d):d=t[5];let f=d,p;t[6]!==a||t[7]!==n||t[8]!==l||t[9]!==s.error||t[10]!==s.isLoading||t[11]!==r||t[12]!==i?(p=a===`chat`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:(0,$.jsx)(Nt,{title:i?`模型回退`:`Model fallbacks`,summary:i?`已配置 ${n.models.chat.fallbacks.length} 个备用模型。`:`${n.models.chat.fallbacks.length} fallback models configured.`,children:(0,$.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,$.jsx)(sn,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:l,loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}})})})})}):null,t[6]=a,t[7]=n,t[8]=l,t[9]=s.error,t[10]=s.isLoading,t[11]=r,t[12]=i,t[13]=p):p=t[13];let m;t[14]!==a||t[15]!==n||t[16]!==r||t[17]!==i?(m=a===`image`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:n.models.imageGeneration?(0,$.jsx)(Nt,{title:i?`图片执行策略`:`Image execution policy`,summary:i?`当前超时与回退策略继续生效。`:`The current timeout and fallback policy remains active.`,children:(0,$.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,$.jsx)(Lt,{allowEmpty:!0,type:`number`,min:1,className:`${si} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,$.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,$.jsx)(ut,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,role:`group`,"aria-label":i?`服务商自动回退`:`Automatic provider fallback`,children:[!0,!1].map(e=>(0,$.jsx)(Z,{"aria-pressed":n.models.imageGeneration?.autoProviderFallback===e,variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]})}):null}):null,t[14]=a,t[15]=n,t[16]=r,t[17]=i,t[18]=m):m=t[18];let h;t[19]!==a||t[20]!==n||t[21]!==l||t[22]!==s.error||t[23]!==s.isLoading||t[24]!==r||t[25]!==i?(h=a===`vision`&&n.models.imageUnderstanding?(0,$.jsx)(Nt,{title:i?`模型回退`:`Model fallbacks`,summary:i?`主模型不可用时使用已配置的备用模型。`:`Use configured fallback models when the primary is unavailable.`,children:(0,$.jsx)(sn,{primary:n.models.imageUnderstanding.primary,value:n.models.imageUnderstanding.fallbacks,models:l.filter(di),loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,imageUnderstanding:{...n.models.imageUnderstanding,fallbacks:e}}})})}):null,t[19]=a,t[20]=n,t[21]=l,t[22]=s.error,t[23]=s.isLoading,t[24]=r,t[25]=i,t[26]=h):h=t[26];let g;t[27]!==a||t[28]!==u||t[29]!==n||t[30]!==f||t[31]!==i?(g=a===`chat`?(0,$.jsx)(Nt,{title:i?`任务模型路由`:`Task model routing`,summary:i?`已配置 ${Object.keys(n.models.intents).length} 类任务路由;其他任务使用默认模型。`:`${Object.keys(n.models.intents).length} task routes configured; other tasks use the default model.`,children:(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i?`按任务选择模型`:`Route by task`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`}),(0,$.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:oi.map(e=>(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:u[e][0]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u[e][1]})]}),(0,$.jsx)(mt,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${u[e][0]}模型`:`${u[e][0]} model`,onChange:t=>f(e,t)})]},e))})]})}):null,t[27]=a,t[28]=u,t[29]=n,t[30]=f,t[31]=i,t[32]=g):g=t[32];let _;return t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-5`,children:[p,m,h,g]}),t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37],_}function di(e){return e.vision}function fi(e){let t=(0,gn.c)(9),{data:n,error:r}=X(`settings-agent-defaults`,vt);if(r&&!n){let e=String(r),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[0]=e,t[1]=n),n}if(!n){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(we,{className:`h-32 rounded-xl`}),t[2]=e):e=t[2],e}let i;t[3]===n.defaults.models?i=t[4]:(i=JSON.stringify(n.defaults.models),t[3]=n.defaults.models,t[4]=i);let a;return t[5]!==n.defaults||t[6]!==e||t[7]!==i?(a=(0,$.jsx)(pi,{...e,initial:n.defaults},i),t[5]=n.defaults,t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function pi(e){let t=(0,gn.c)(36),{initial:n,capability:r,zh:i,disabled:a,onPendingChange:o}=e,s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[c,l]=(0,Q.useState)(s),u;t[2]===n?u=t[3]:(u=()=>structuredClone(n),t[2]=n,t[3]=u);let[d,f]=(0,Q.useState)(u),p;t[4]===c.models?p=t[5]:(p=JSON.stringify(c.models),t[4]=c.models,t[5]=p);let m;t[6]===d.models?m=t[7]:(m=JSON.stringify(d.models),t[6]=d.models,t[7]=m);let h=p!==m,g;t[8]!==n.models||t[9]!==i?(g=async e=>{let t=await vt();if(JSON.stringify(t.defaults.models)!==JSON.stringify(n.models))throw Error(i?`模型设置已变化,请刷新后重试。`:`Model settings changed. Refresh before retrying.`);let r=await _t({...t.defaults,models:e.models},{scope:`models`,expectedModels:n.models});f(r.defaults),await bt()},t[8]=n.models,t[9]=i,t[10]=g):g=t[10];let _=g,v;t[11]!==h||t[12]!==c||t[13]!==_?(v={value:c,dirty:h,onSave:_,delayMs:0},t[11]=h,t[12]=c,t[13]=_,t[14]=v):v=t[14];let y=Ut(v),b=h||y.status===`saving`||!!y.error,x,S;t[15]!==o||t[16]!==b?(x=()=>(o(b),()=>o(!1)),S=[b,o],t[15]=o,t[16]=b,t[17]=x,t[18]=S):(x=t[17],S=t[18]),(0,Q.useEffect)(x,S);let C=a||y.status===`saving`,w;t[19]!==y.error||t[20]!==y.status?(w=(0,$.jsx)(Ht,{status:y.status,error:y.error}),t[19]=y.error,t[20]=y.status,t[21]=w):w=t[21];let T;t[22]!==y.error||t[23]!==y.retry||t[24]!==i?(T=y.error?(0,$.jsx)(Z,{variant:`secondary`,onClick:y.retry,children:i?`重试保存`:`Retry saving`}):null,t[22]=y.error,t[23]=y.retry,t[24]=i,t[25]=T):T=t[25];let E;t[26]!==r||t[27]!==c||t[28]!==i?(E=(0,$.jsx)(ui,{capability:r,draft:c,setDraft:l,zh:i}),t[26]=r,t[27]=c,t[28]=i,t[29]=E):E=t[29];let D;return t[30]!==y.onBlurCapture||t[31]!==w||t[32]!==T||t[33]!==E||t[34]!==C?(D=(0,$.jsxs)(`fieldset`,{disabled:C,onBlurCapture:y.onBlurCapture,className:`min-w-0 space-y-3`,children:[w,T,E]}),t[30]=y.onBlurCapture,t[31]=w,t[32]=T,t[33]=E,t[34]=C,t[35]=D):D=t[35],D}function mi(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function hi(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`模型与能力`:`Models and capabilities`,href:`/settings/capabilities/models`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:gt(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function gi(e,t){switch(e){case`computer-use`:return{guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{guidance:t?`选择语音识别服务,或安装自管 STT 插件`:`Choose a speech-to-text service or install a self-managed STT plugin`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function _i(){let e=await ye(be(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function vi(){let e=await ye(be(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function yi({showCapabilities:e=!0}={}){let t=Se(e=>e.language)===`zh`,{data:n,error:r,isLoading:i}=X(xt,_i,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:a}=X(St,vi,{revalidateOnFocus:!1}),[o,s]=(0,Q.useState)(!1),[c,d]=(0,Q.useState)(null),p=Object.values(n?.sources??{}),m=p.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),h=(n?.references??[]).filter(e=>e.availability===`unavailable`),_=n?.sync.lastSuccessAt??Math.max(0,...p.map(e=>e.lastSuccessAt)),v=!!r,y=n?.sync.sourceErrors??{},x=[...n?.sync.lastError?[[`catalog`,n.sync.lastError]]:[],...Object.entries(y),...c?[[`refresh`,c]]:[],...r instanceof Error?[[`load`,r.message]]:[]],S=n?.sync.lastAttemptAt??_,C=Object.entries(a?.capabilities??{}).filter(([e])=>e!==`computer-use`||lt()),w=C.some(([,e])=>{let t=mi(e);return t===`degraded`||t===`misconfigured`}),T=C.filter(([,e])=>mi(e)===`ready`).length,E=(0,Q.useRef)(null);if((0,Q.useEffect)(()=>{w&&!i&&E.current?.setAttribute(`open`,``)},[w,i]),i)return(0,$.jsx)(we,{className:`h-24 w-full rounded-2xl`});let D=async()=>{s(!0),d(null);try{let e=await ye(be(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await bt()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[e?(0,$.jsxs)(`details`,{ref:E,className:`group`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[w?(0,$.jsx)(me,{className:`size-4 text-amber-500`,"aria-hidden":!0}):T===C.length&&C.length>0?(0,$.jsx)(g,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(b,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:t?`${T}/${C.length} 项已配置,不影响基础聊天功能`:`${T} of ${C.length} configured · Not required for chat`})]}),(0,$.jsx)(f,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),a?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(a.capabilities).map(([e,n])=>{if(e===`computer-use`&&!lt())return null;let r=e===`vision`?t?`图片理解`:`Vision`:e===`image-generation`?t?`图片生成`:`Image generation`:e===`computer-use`?t?`电脑控制模型`:`Computer use model`:e.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=mi(n),o=a===`degraded`||a===`misconfigured`,s=gi(e,t),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?e===`computer-use`?t?`已配置`:`Configured`:t?`可用`:`Ready`:a===`off`?t?`已关闭`:`Off`:a===`not-configured`?t?`未配置`:`Not configured`:a===`degraded`?t?`正在使用备用方案`:`Using fallback`:t?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:n.primary?`${n.primary.provider}/${n.primary.model}`:void 0,children:n.primary?`${i?t?`自动`:`Auto`:t?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a===`not-configured`?t?`可稍后按需配置`:`Set up later if needed`:t?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?t?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(u,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]}),d={"aria-label":o?`${r}:${s.action}`:`${t?`配置`:`Configure`} ${r}`,className:Y(`rounded-lg bg-surface-base/45 px-3 py-3 text-left transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`)};if(e===`computer-use`)return(0,$.jsx)(l,{to:`/settings/computer-use`,...d,children:c},e);let f={vision:`vision`,"image-generation":`image`,stt:`transcription`,tts:`speech`}[e];return(0,$.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,...d,onClick:()=>Re(f,o?`services`:`settings`),children:c},e)})}):null]}):null,h.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:h.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let n=e.ref.split(`/`)[0]??``,r=!!y[n],i=hi(e.locations[0]??``,t);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[e.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:r?t?`暂时无法验证`:`Temporarily unverified`:t?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r?t?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:t?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,S?` · ${t?`最近检测`:`Last checked`} ${new Date(S).toLocaleString()}`:``]}),e.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[t?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(Z,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:o,onClick:()=>void D(),children:[o?(0,$.jsx)(q,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),o?t?`检测中…`:`Checking…`:t?`重新检测`:`Check again`]}),(0,$.jsx)(Z,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:i.href,children:[(0,$.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),e.suggestedRef?t?`更换模型`:`Replace model`:t?`调整配置`:`Adjust configuration`]})}),(0,$.jsxs)(`details`,{className:`group/references`,children:[(0,$.jsxs)(`summary`,{className:`touch-target inline-flex cursor-pointer list-none items-center gap-1 rounded-xl px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[t?`查看 ${e.locations.length} 处引用`:`View ${e.locations.length} ${e.locations.length===1?`reference`:`references`}`,(0,$.jsx)(f,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:e.locations.map(e=>{let n=hi(e,t);return(0,$.jsx)(`li`,{children:(0,$.jsx)(l,{className:`inline-flex rounded px-1.5 py-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:n.href,title:e,children:n.label})},e)})})]})]})]})})()},e.ref))}):null,v||c?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:v?t?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:t?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):null,(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:t?`高级诊断`:`Advanced diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:t?`${p.length} 个来源,${m} 个可用模型${_?` · 最近同步 ${new Date(_).toLocaleString()}`:``}`:`${p.length} sources, ${m} available models${_?` · Last synced ${new Date(_).toLocaleString()}`:``}`}),x.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg bg-surface-base/45 p-2 font-mono text-[11px] leading-5`,"aria-label":t?`同步错误详情`:`Sync error details`,children:x.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}):null]}),(0,$.jsxs)(Z,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:o,onClick:()=>void D(),children:[o?(0,$.jsx)(q,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),o?t?`刷新中…`:`Refreshing…`:t?`刷新目录`:`Refresh catalog`]})]})]})]})}function bi(e){let t=(0,gn.c)(167),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{inlineUse:r,inlineView:i,onViewChange:u,onPendingChange:d}=n,f=i===void 0?`settings`:i,p=Se(wi),m=p===`zh`,h;t[2]===p?h=t[3]:(h=ve(p),t[2]=p,t[3]=h);let g=h.capabilitiesSettings,{capability:v}=a(),[y,b]=s(),{state:S}=o(),C;t[4]===y?C=t[5]:(C=x(y.get(`returnTo`)),t[4]=y,t[5]=C);let w=C,[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(!1),I=j||N||k,[R,B]=(0,Q.useState)(!1),[V,ee]=(0,Q.useState)(null),te=(0,Q.useRef)(null),H=P(),U=Ci,W,G;t[6]!==d||t[7]!==I?(W=()=>(d?.(I),()=>d?.(!1)),G=[I,d],t[6]=d,t[7]=I,t[8]=W,t[9]=G):(W=t[8],G=t[9]),(0,Q.useEffect)(W,G);let ne,K;t[10]!==v||t[11]!==r||t[12]!==S||t[13]!==y||t[14]!==b?(ne=()=>{if(r||v!==`models`)return;let e=_(y.get(`configure`));if(!e&&y.get(`add`)!==`1`)return;let t=window.setTimeout(()=>{e?Re(e,y.get(`tab`)===`services`?`services`:`settings`):B(!0);let t=new URLSearchParams(y);t.delete(`configure`),t.delete(`tab`),t.delete(`add`),b(t,{replace:!0,state:S})},0);return()=>window.clearTimeout(t)},K=[v,r,y,b,S],t[10]=v,t[11]=r,t[12]=S,t[13]=y,t[14]=b,t[15]=ne,t[16]=K):(ne=t[15],K=t[16]),(0,Q.useEffect)(ne,K);let re;t[17]!==r||t[18]!==u||t[19]!==I?(re=e=>{if(!I){if(!r){Re(e,`services`);return}u?.(`services`),E(void 0)}},t[17]=r,t[18]=u,t[19]=I,t[20]=re):re=t[20];let q=re,ie;t[21]===u?ie=t[22]:(ie=e=>{U(),u?.(`settings`),E(e)},t[21]=u,t[22]=ie);let J=ie;if(r){let e=f===`services`,n=N||k,i;t[23]!==r||t[24]!==q||t[25]!==H||t[26]!==n||t[27]!==m?(i=(0,$.jsx)(Jr,{data:H,zh:m,onlyUse:r,disabled:n,onPendingChange:M,onChange:q}),t[23]=r,t[24]=q,t[25]=H,t[26]=n,t[27]=m,t[28]=i):i=t[28];let a;t[29]!==e||t[30]!==i?(a=(0,$.jsx)(`div`,{hidden:e,children:i}),t[29]=e,t[30]=i,t[31]=a):a=t[31];let o;t[32]!==T||t[33]!==r||t[34]!==f||t[35]!==m?(o=T===r&&f===`settings`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:m?`服务设置已保存`:`Service settings saved`}):null,t[32]=T,t[33]=r,t[34]=f,t[35]=m,t[36]=o):o=t[36];let s=f!==`services`,c;t[37]!==J||t[38]!==r?(c=()=>J(r),t[37]=J,t[38]=r,t[39]=c):c=t[39];let l;t[40]!==g.addProviderDialog||t[41]!==r||t[42]!==p||t[43]!==H||t[44]!==c?(l=(0,$.jsx)(Ir,{inline:!0,onEditingChange:O,use:r,data:H,language:p,labels:g.addProviderDialog,onPendingChange:A,onSaved:c},r),t[40]=g.addProviderDialog,t[41]=r,t[42]=p,t[43]=H,t[44]=c,t[45]=l):l=t[45];let u;t[46]!==J||t[47]!==D||t[48]!==r||t[49]!==H||t[50]!==m?(u=r===`transcription`||r===`speech`?(0,$.jsx)(`div`,{hidden:D,children:(0,$.jsx)(Kr,{kind:r===`transcription`?`stt`:`tts`,modelServiceIds:H.builtinRows.map(Si),zh:m,onPendingChange:A,onSaved:()=>J(r)},r)}):null,t[46]=J,t[47]=D,t[48]=r,t[49]=H,t[50]=m,t[51]=u):u=t[51];let d;t[52]!==J||t[53]!==r?(d=r===`image`?(0,$.jsx)(Mn,{connectOnly:!0,onPendingChange:A,onConnected:()=>J(r)}):null,t[52]=J,t[53]=r,t[54]=d):d=t[54];let h;t[55]!==k||t[56]!==s||t[57]!==l||t[58]!==u||t[59]!==d?(h=(0,$.jsxs)(`fieldset`,{hidden:s,disabled:k,className:`min-w-0 space-y-3`,children:[l,u,d]}),t[55]=k,t[56]=s,t[57]=l,t[58]=u,t[59]=d,t[60]=h):h=t[60];let _=f===`services`,v;t[61]!==k||t[62]!==r||t[63]!==j?(v=r===`transcription`||r===`speech`||r===`conversation`?(0,$.jsx)(or,{capability:r,onPendingChange:F,disabled:j||k},r):null,t[61]=k,t[62]=r,t[63]=j,t[64]=v):v=t[64];let y;t[65]!==k||t[66]!==r||t[67]!==j||t[68]!==m?(y=r===`chat`||r===`vision`||r===`image`?(0,$.jsx)(fi,{capability:r,zh:m,disabled:j||k,onPendingChange:F}):null,t[65]=k,t[66]=r,t[67]=j,t[68]=m,t[69]=y):y=t[69];let b;t[70]!==r||t[71]!==m?(b=r===`background`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m?`使用所选模型执行自动化、定时和无人值守任务。此设置不会启用任务,也不会自动改用其他计费服务。`:`Use the selected model for automations, schedules and unattended tasks. This does not enable tasks or automatically switch billing services.`}):null,t[70]=r,t[71]=m,t[72]=b):b=t[72];let x;t[73]!==_||t[74]!==v||t[75]!==y||t[76]!==b?(x=(0,$.jsxs)(`div`,{hidden:_,className:`space-y-4`,children:[v,y,b]}),t[73]=_,t[74]=v,t[75]=y,t[76]=b,t[77]=x):x=t[77];let S;t[78]!==q||t[79]!==o||t[80]!==h||t[81]!==x?(S=(0,$.jsxs)(Fn.Provider,{value:q,children:[o,h,x]}),t[78]=q,t[79]=o,t[80]=h,t[81]=x,t[82]=S):S=t[82];let C;return t[83]!==a||t[84]!==S?(C=(0,$.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[a,S]}),t[83]=a,t[84]=S,t[85]=C):C=t[85],C}if(v===`search`){let e;t[86]===p?e=t[87]:(e=ve(p),t[86]=p,t[87]=e);let n;t[88]===e.nav.settingsSearch?n=t[89]:(n=(0,$.jsx)(zt,{title:e.nav.settingsSearch}),t[88]=e.nav.settingsSearch,t[89]=n);let r;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Mr,{}),t[90]=r):r=t[90];let i;return t[91]===n?i=t[92]:(i=(0,$.jsxs)(Rt,{children:[n,r]}),t[91]=n,t[92]=i),i}if(v!==`models`){let e;return t[93]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(c,{to:`/settings/capabilities/models`,replace:!0}),t[93]=e):e=t[93],e}let ae=m?`模型与能力`:`Models and capabilities`,oe=m?`按用途选择模型,在设置中调整参数与服务连接。`:`Choose models by purpose. Adjust parameters and connections in settings.`,se;t[94]===p?se=t[95]:(se=ct(p,`configuration`),t[94]=p,t[95]=se);let ce;t[96]!==g.docsLink||t[97]!==se?(ce=(0,$.jsx)(`a`,{href:se,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center rounded-lg px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g.docsLink}),t[96]=g.docsLink,t[97]=se,t[98]=ce):ce=t[98];let le;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{te.current?.scrollIntoView?.({block:`start`}),te.current?.focus({preventScroll:!0})},t[99]=le):le=t[99];let ue=m?`服务账户`:`Service accounts`,de;t[100]!==I||t[101]!==ue?(de=(0,$.jsx)(Z,{variant:`secondary`,disabled:I,onClick:le,children:ue}),t[100]=I,t[101]=ue,t[102]=de):de=t[102];let fe;t[103]!==ce||t[104]!==de?(fe=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ce,de]}),t[103]=ce,t[104]=de,t[105]=fe):fe=t[105];let pe;t[106]!==ae||t[107]!==oe||t[108]!==fe?(pe=(0,$.jsx)(zt,{title:ae,subtitle:oe,actions:fe}),t[106]=ae,t[107]=oe,t[108]=fe,t[109]=pe):pe=t[109];let me;t[110]!==w||t[111]!==m?(me=w?(0,$.jsx)(l,{to:w,className:`text-sm text-accent-fg hover:underline`,children:m?`返回`:`Back`}):null,t[110]=w,t[111]=m,t[112]=me):me=t[112];let he;t[113]===I?he=t[114]:(he=e=>{I||Re(e)},t[113]=I,t[114]=he);let ge;t[115]!==q||t[116]!==H||t[117]!==I||t[118]!==he||t[119]!==m?(ge=(0,$.jsx)(Jr,{data:H,zh:m,disabled:I,onPendingChange:M,onChange:q,onSettings:he}),t[115]=q,t[116]=H,t[117]=I,t[118]=he,t[119]=m,t[120]=ge):ge=t[120];let _e=m?`连接的服务`:`Connected services`,Y;t[121]===_e?Y=t[122]:(Y=(0,$.jsx)(`h2`,{id:`model-services-heading`,className:`text-base font-semibold text-fg`,children:_e}),t[121]=_e,t[122]=Y);let ye=m?`在这里管理账户和密钥;各项能力的模型与参数在上方调整。`:`Manage accounts and keys here. Choose models and adjust capability settings above.`,be;t[123]===ye?be=t[124]:(be=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ye}),t[123]=ye,t[124]=be);let xe;t[125]!==Y||t[126]!==be?(xe=(0,$.jsxs)(`div`,{children:[Y,be]}),t[125]=Y,t[126]=be,t[127]=xe):xe=t[127];let Ce;t[128]!==g.xopcCloudAccount||t[129]!==H.cards?(Ce=H.cards.some(xi)?(0,$.jsx)(ln,{labels:g.xopcCloudAccount}):null,t[128]=g.xopcCloudAccount,t[129]=H.cards,t[130]=Ce):Ce=t[130];let X,we;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(X=()=>B(!0),we=(e,t)=>ee({providerId:e,isCustom:t}),t[131]=X,t[132]=we):(X=t[131],we=t[132]);let Te;t[133]!==g.connectedProviders||t[134]!==H?(Te=(0,$.jsx)(z,{labels:g.connectedProviders,data:H,onAdd:X,onManage:we}),t[133]=g.connectedProviders,t[134]=H,t[135]=Te):Te=t[135];let Ee;t[136]===H.cards.length?Ee=t[137]:(Ee=H.cards.length>0?(0,$.jsx)(yi,{showCapabilities:!1}):null,t[136]=H.cards.length,t[137]=Ee);let De;t[138]===m?De=t[139]:(De=lt()?(0,$.jsx)(l,{className:`inline-block text-sm text-accent-fg hover:underline`,to:`/settings/computer-use`,children:m?`电脑操作设置`:`Computer use settings`}):null,t[138]=m,t[139]=De);let Oe;t[140]!==xe||t[141]!==Ce||t[142]!==Te||t[143]!==Ee||t[144]!==De?(Oe=(0,$.jsxs)(`section`,{ref:te,tabIndex:-1,"aria-labelledby":`model-services-heading`,className:`space-y-4 scroll-mt-4 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[xe,Ce,Te,Ee,De]}),t[140]=xe,t[141]=Ce,t[142]=Te,t[143]=Ee,t[144]=De,t[145]=Oe):Oe=t[145];let ke;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>{U(),B(!1)},t[146]=ke):ke=t[146];let Ae;t[147]!==R||t[148]!==g.addProviderDialog||t[149]!==p||t[150]!==H.builtinRows||t[151]!==H.customConfig?(Ae=(0,$.jsx)(L,{open:R,connectOnly:!0,onOpenChange:B,builtinRows:H.builtinRows,customConfig:H.customConfig,labels:g.addProviderDialog,language:p,onSaved:ke}),t[147]=R,t[148]=g.addProviderDialog,t[149]=p,t[150]=H.builtinRows,t[151]=H.customConfig,t[152]=Ae):Ae=t[152];let je;t[153]!==g.manageProviderDialog||t[154]!==p||t[155]!==V||t[156]!==H.allModels||t[157]!==H.builtinRows||t[158]!==H.customConfig?(je=V?(0,$.jsx)(ri,{open:!0,onOpenChange:e=>{e||ee(null)},providerId:V.providerId,isCustom:V.isCustom,builtinRows:H.builtinRows,customConfig:H.customConfig,allModels:H.allModels,labels:g.manageProviderDialog,language:p,onSaved:U}):null,t[153]=g.manageProviderDialog,t[154]=p,t[155]=V,t[156]=H.allModels,t[157]=H.builtinRows,t[158]=H.customConfig,t[159]=je):je=t[159];let Me;return t[160]!==pe||t[161]!==me||t[162]!==ge||t[163]!==Oe||t[164]!==Ae||t[165]!==je?(Me=(0,$.jsxs)(Rt,{children:[pe,me,ge,Oe,Ae,je]}),t[160]=pe,t[161]=me,t[162]=ge,t[163]=Oe,t[164]=Ae,t[165]=je,t[166]=Me):Me=t[166],Me}function xi(e){return e.id===`xopc-cloud`&&!e.isCustom}function Si(e){return e.id}function Ci(){bt()}function wi(e){return e.language}export{bi as CapabilitiesSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./search-DA7gz22f.js";import{t as a}from"./button-CnRSIP6m.js";import{a as o,i as s,o as c,s as l}from"./dist-CaUuvp8-.js";import{t as u}from"./use-media-query-ady-FgjK.js";var d=n(),f=e(t(),1),p=r(),m=(0,f.memo)(function(e){let t=(0,d.c)(8),{value:n,onChange:r,placeholder:a,ariaLabel:o}=e,s=o===void 0?a:o,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,p.jsx)(i,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=c):c=t[0];let l;t[1]===r?l=t[2]:(l=e=>r(e.currentTarget.value),t[1]=r,t[2]=l);let u;return t[3]!==s||t[4]!==a||t[5]!==l||t[6]!==n?(u=(0,p.jsxs)(`label`,{className:`relative flex h-11 min-w-0 w-full cursor-text items-center rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-fg shadow-none focus-within:border-accent/60 focus-within:ring-2 focus-within:ring-accent/30 md:h-9`,children:[c,(0,p.jsx)(`input`,{type:`search`,"aria-label":s,enterKeyHint:`search`,value:n,onChange:l,placeholder:a,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent text-base leading-normal text-fg caret-current placeholder:text-fg-muted focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 md:text-sm`})]}),t[3]=s,t[4]=a,t[5]=l,t[6]=n,t[7]=u):u=t[7],u});function h(e){let t=(0,d.c)(8),{contribution:n}=e,r=u(`(min-width: 768px)`),f;t[0]!==n||t[1]!==r?(f=n?.search?r?(0,p.jsx)(`div`,{className:`min-w-0 max-w-60 flex-1`,children:n.search}):(0,p.jsxs)(c,{children:[(0,p.jsx)(l,{asChild:!0,children:(0,p.jsx)(a,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":n.searchLabel,title:n.searchLabel,children:(0,p.jsx)(i,{className:`size-4`,"aria-hidden":!0})})}),(0,p.jsx)(o,{children:(0,p.jsx)(s,{align:`end`,sideOffset:8,className:`z-50 w-[min(20rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover`,children:n.search})})]}):null,t[0]=n,t[1]=r,t[2]=f):f=t[2];let m=n?.secondary,h=n?.primary,g=n?.overflow,_;return t[3]!==f||t[4]!==m||t[5]!==h||t[6]!==g?(_=(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2 xl:w-[27rem] 2xl:w-[31rem]`,children:[f,m,h,g]}),t[3]=f,t[4]=m,t[5]=h,t[6]=g,t[7]=_):_=t[7],_}export{m as n,h as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-0WouolD0.js";var a=n(),o=e(t(),1),s=r();function c(e){let t=(0,a.c)(12),{iconUrl:n,fallback:r,className:c}=e,[l,u]=(0,o.useState)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>u(!1),t[0]=d):d=t[0];let f;t[1]===n?f=t[2]:(f=[n],t[1]=n,t[2]=f),(0,o.useEffect)(d,f);let p;t[3]===c?p=t[4]:(p=i(`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-edge bg-white`,c),t[3]=c,t[4]=p);let m;t[5]!==r||t[6]!==l||t[7]!==n?(m=n&&!l?(0,s.jsx)(`img`,{src:n,alt:``,loading:`lazy`,draggable:!1,className:`size-8 object-contain`,onError:()=>u(!0)}):(0,s.jsx)(r,{className:`size-5 text-fg-muted`,"aria-hidden":!0}),t[5]=r,t[6]=l,t[7]=n,t[8]=m):m=t[8];let h;return t[9]!==p||t[10]!==m?(h=(0,s.jsx)(`span`,{className:p,children:m}),t[9]=p,t[10]=m,t[11]=h):h=t[11],h}export{c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,n,r=!1,i){let[a,o]=t(n,i).split(`?`),s=new URLSearchParams(o);return s.set(`plugin`,e),r?s.set(`connect`,`1`):s.delete(`connect`),`${a}?${s}`}function t(e,t){return t&&/^\/capabilities\/(skills|connectors|extensions)(?:\?|$)/.test(t)&&!/[\\#\r\n]/.test(t)?t:e===`connections`?`/capabilities/connectors?tab=connected`:e===`skills`?`/capabilities/skills?tab=installed&source=plugin`:`/capabilities/extensions?tab=user`}function n(e,t){return`/chat/new?${new URLSearchParams({draft:t?`请帮我使用${e}插件。`:`Help me use the ${e} plugin.`,projectScope:`none`})}`}export{n,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{s as a,t as o}from"./popover-select-DniHw2dy.js";import{t as s}from"./circle-alert-BEjgurr2.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./session-channel-icon-SsY70Z6t.js";import{i as f,n as p,r as m,t as h}from"./channels-routes-r2g-9DdC.js";import{t as g}from"./rotate-ccw-JM1TBLpp.js";import{t as _}from"./settings-2-D-csvaET.js";import{t as v}from"./stethoscope-DRqTAtjD.js";import{t as y}from"./triangle-alert-2JXFNNKU.js";import{t as b}from"./x-B_N4OPjy.js";import{t as x}from"./messages-DRR9N3HC.js";import{t as S}from"./cn-0WouolD0.js";import{a as C,i as w,l as T,n as E,o as D}from"./locale-store-lIXD1FMw.js";import{i as O}from"./vendor-swr-CdRzEUwF.js";import{t as k}from"./button-CnRSIP6m.js";import{t as A}from"./skeleton-BI5TyibZ.js";import{a as j,i as M,n as N,o as P,r as F,s as I,t as L}from"./dist-DfWfZ9iu.js";import{i as R,o as ee}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as te}from"./interaction-BdhHBbYa.js";import{t as ne}from"./chat-agents-api-D5nR_JVe.js";import{t as re}from"./refresh-button-bU_0NarN.js";import{t as ie}from"./extension-iframe-host-Dhkk5JV2.js";import{n as ae}from"./agent-display-names-Bje7vfSn.js";import{n as oe}from"./settings-loading-skeleton-BTqvr_Fw.js";import{t as se}from"./browser-BLJWD7WI.js";import{t as ce}from"./settings-advanced-section-BqoVSko2.js";import{n as le}from"./settings-page-header-Bv-kQFTm.js";import"./settings-page-layout-DHP6MrrL.js";import{t as ue}from"./schema-form-v4N4lawq.js";var z=e(t(),1),B=n();async function de(){return(await D(w(`/api/channels/status`))).payload?.channels||[]}function fe(){return w(`/api/channels/status`)}var pe=de;function me(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var V=e(se(),1),H=r();async function U(e){let t=await C(w(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function he({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,z.useMemo)(()=>me(e),[e]),o=(0,z.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[s,d]=(0,z.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,z.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let p=(0,z.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});d(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){d(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,z.useEffect)(()=>{let t=K(s.payload,e.id);if(!t){d(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return d(e=>e.generatedQr?{...e,generatedQr:null}:e),V.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,z.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||d(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let m=a?.[1].label??(e.configured?n.reconnect:n.connect),h=e.actions?.[`doctor.run`]?.label??n.diagnose,g=G(s.payload),_=K(s.payload,e.id),y=_?s.generatedQr:q(s.payload),b=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),x=s.payload?.type===`form`?s.payload:null,C=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,H.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:S(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,H.jsxs)(k,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void p(a[0]),children:[s.busy?(0,H.jsx)(u,{className:`size-4 animate-spin`}):(0,H.jsx)(f,{className:`size-4`}),m]}):null,e.actions?.[`doctor.run`]?(0,H.jsxs)(k,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void p(`doctor.run`),children:[(0,H.jsx)(v,{className:`size-4`}),h]}):null]})]}),g?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,s.error?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,b?(0,H.jsxs)(`div`,{className:S(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,H.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:y?(0,H.jsx)(`img`,{src:y,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,H.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,H.jsx)(A,{className:`size-48 rounded-md`})})}),(0,H.jsxs)(`div`,{className:S(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[y?(0,H.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,H.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,H.jsx)(A,{className:`h-4 w-48 max-w-full`}),(0,H.jsx)(A,{className:`h-4 w-36 max-w-full`})]}),_?(0,H.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,H.jsx)(l,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,H.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,H.jsx)(c,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,H.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,x?(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsx)(ue,{schema:x.schema,values:s.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,H.jsx)(k,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void p(x.submitAction,s.formDraft),children:n.saveSetup})]}):null,C?(0,H.jsx)(`div`,{className:`mt-4 space-y-2`,children:C.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ge=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function _e(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ve(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ge,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function ye(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function be(e,t,n){let r=ye(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function xe(e,t=!1){return e===`drawer`?S(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,R):S(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,R,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Se(e){let t=(0,B.c)(33),{presentation:n,open:r,onOpenChange:i,title:o,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p!==void 0&&p,g=n===`drawer`,[_,v]=(0,z.useState)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,H.jsx)(j,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=y):y=t[0];let x;t[1]!==n||t[2]!==h?(x=xe(n,h),t[1]=n,t[2]=h,t[3]=x):x=t[3];let C;t[4]===c?C=t[5]:(C=c?(0,H.jsx)(I,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=C);let w;t[6]===l?w=t[7]:(w=l?(0,H.jsx)(M,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=w);let T;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==g||t[12]!==o?(T=g?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[o?(0,H.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:o}):null,s?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,H.jsx)(N,{asChild:!0,children:(0,H.jsx)(k,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,H.jsx)(b,{className:`size-5`,strokeWidth:1.75})})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(N,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:S(te,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,H.jsx)(b,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=g,t[12]=o,t[13]=T):T=t[13];let E=g?`p-4`:`p-6`,D;t[14]===E?D=t[15]:(D=S(`min-h-0 flex-1 overflow-y-auto`,E),t[14]=E,t[15]=D);let O;t[16]!==d||t[17]!==D?(O=(0,H.jsx)(`div`,{className:D,children:d}),t[16]=d,t[17]=D,t[18]=O):O=t[18];let A;t[19]!==f||t[20]!==_||t[21]!==C||t[22]!==w||t[23]!==T||t[24]!==O?(A=(0,H.jsxs)(a,{layer:`modal`,portalContainer:_,children:[C,w,T,O,f]}),t[19]=f,t[20]=_,t[21]=C,t[22]=w,t[23]=T,t[24]=O,t[25]=A):A=t[25];let R;t[26]!==A||t[27]!==x?(R=(0,H.jsxs)(P,{children:[y,(0,H.jsx)(F,{ref:v,className:x,onOpenAutoFocus:Ce,children:A})]}),t[26]=A,t[27]=x,t[28]=R):R=t[28];let ne;return t[29]!==i||t[30]!==r||t[31]!==R?(ne=(0,H.jsx)(L,{open:r,onOpenChange:i,children:R}),t[29]=i,t[30]=r,t[31]=R,t[32]=ne):ne=t[32],ne}function Ce(e){return e.preventDefault()}var we=(0,z.memo)(function(e){let t=(0,B.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,H.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,H.jsx)(re,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Te(e){let t=(0,B.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0||c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,H.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,H.jsx)(k,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,H.jsx)(k,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,H.jsx)(k,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,H.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-overlay px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Ee(e){return w(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function De(e){return(await D(Ee(e))).payload?.channels??[]}function Oe(e,t){let n=(0,B.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Ee(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>De(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=O(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var ke=`channels-status`;function Ae(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function je(e){let t=t=>e(t.detail);return window.addEventListener(ke,t),()=>window.removeEventListener(ke,t)}function Me(e,t){let n=(0,B.c)(4),r=t===void 0||t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return je(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,z.useEffect)(i,a)}function Ne(e){return e?w(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Pe(e){return(await D(w(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Fe=[`enabled`],Ie=`max-w-7xl`,Le=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Re(){let e=await D(w(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function We(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(X(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Fe.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Fe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Q(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=me(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=me(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,z.useState)(!1),r=(0,z.useMemo)(()=>!e.ui?.icon||t?null:new URL(w(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,H.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,H.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,H.jsx)(d,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,B.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=S(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=S(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,H.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,H.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function rt(e){let t=(0,B.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:l,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==l||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?l:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let u;t[19]===n?u=t[20]:(u=(0,H.jsx)(tt,{entry:n}),t[19]=n,t[20]=u);let f;t[21]===n.label?f=t[22]:(f=(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=f);let x;t[23]===i?x=t[24]:(x=S(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=x);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==x||t[29]!==C?(w=(0,H.jsx)(`span`,{className:x,children:C}),t[28]=x,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==f?(T=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[f,w]}),t[31]=w,t[32]=f,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==u?(E=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[u,T]}),t[34]=T,t[35]=u,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==l||t[42]!==p.enabled||t[43]!==O?(k=(0,H.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:l}),t[40]=a,t[41]=l,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,H.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,H.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=l,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,H.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,H.jsx)(u,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,H.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,H.jsxs)(k,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,H.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function it(e){return(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,H.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,B.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:l,onRestart:d,onCheck:f,onManageConnection:p}=e,m=n===`running`?c:n===`stopped`||n===`needs_setup`?s:u,h=n===`running`&&`text-emerald-600 dark:text-emerald-400`,_=n===`stopped`&&`text-red-600 dark:text-red-400`,v=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,y=n===`disabled`&&`text-fg-muted`,b=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,x;t[0]!==h||t[1]!==_||t[2]!==v||t[3]!==y||t[4]!==b?(x=S(`mt-0.5 size-5 shrink-0`,h,_,v,y,b),t[0]=h,t[1]=_,t[2]=v,t[3]=y,t[4]=b,t[5]=x):x=t[5];let C;t[6]!==m||t[7]!==x?(C=(0,H.jsx)(m,{className:x}),t[6]=m,t[7]=x,t[8]=C):C=t[8];let w;t[9]===l.connectionStatus?w=t[10]:(w=(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=w);let T;t[11]!==l||t[12]!==n?(T=He(n,l),t[11]=l,t[12]=n,t[13]=T):T=t[13];let E;t[14]===T?E=t[15]:(E=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:T}),t[14]=T,t[15]=E);let D;t[16]!==E||t[17]!==w?(D=(0,H.jsxs)(`div`,{children:[w,E]}),t[16]=E,t[17]=w,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==C?(O=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[C,D]}),t[19]=D,t[20]=C,t[21]=O):O=t[21];let A=i||r,j;t[22]===i?j=t[23]:(j=i?(0,H.jsx)(u,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=j);let M=i?l.checkingConnection:l.checkConnection,N;t[24]!==f||t[25]!==A||t[26]!==j||t[27]!==M?(N=(0,H.jsxs)(k,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:A,onClick:f,children:[j,M]}),t[24]=f,t[25]=A,t[26]=j,t[27]=M,t[28]=N):N=t[28];let P;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==d||t[33]!==r||t[34]!==n?(P=n===`stopped`?(0,H.jsxs)(k,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:d,children:[r?(0,H.jsx)(u,{className:`size-4 animate-spin`}):(0,H.jsx)(g,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=d,t[33]=r,t[34]=n,t[35]=P):P=t[35];let F;t[36]!==o||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==p||t[41]!==r||t[42]!==a?(F=o?(0,H.jsx)(k,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:p,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=o,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=p,t[41]=r,t[42]=a,t[43]=F):F=t[43];let I;t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[N,P,F]}),t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==O||t[49]!==I?(L=(0,H.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[O,I]})}),t[48]=O,t[49]=I,t[50]=L):L=t[50],L}function st(e){let t=(0,B.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,H.jsx)(y,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,H.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,H.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,H.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,H.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,H.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,H.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct({channelId:e,onHeaderActionChange:t}){let n=E(e=>e.language),r=x(n),a=T(e=>!!e.conversationId),s=i(),c=m(e),u=Oe(a,n),d=u.entries,{data:f,mutate:g,isValidating:v}=O(a?fe():null,pe,{revalidateOnFocus:!0}),{data:y,mutate:b}=O(a?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),D=y?.channels??{},k=y?.bindings??[],{data:A}=O(a?`channel-routing-agents`:null,ne,{revalidateOnFocus:!1}),j=(0,z.useMemo)(()=>d.find(e=>e.id===c),[c,d]),M=j?Be(j):null,{data:N,mutate:P}=O(a&&M?Ne(M):null,()=>Pe(M)),[F,I]=(0,z.useState)(null),[L,R]=(0,z.useState)(!1),[ee,te]=(0,z.useState)(null),[re,se]=(0,z.useState)(null),[B,de]=(0,z.useState)(!1),[V,U]=(0,z.useState)(null),[W,G]=(0,z.useState)(null),K=F??N??{},q=r.channelsSettings,ge=(0,z.useMemo)(()=>j?.configSchema??{type:`object`,properties:{}},[j?.configSchema]),J=(0,z.useMemo)(()=>qe(ge,Fe),[ge]),ye=(0,z.useMemo)(()=>We(j),[j]),xe=(0,z.useMemo)(()=>Ge(J,ye),[ye,J]),Ce=(0,z.useMemo)(()=>qe(J,ye),[ye,J]),Ee=(0,z.useMemo)(()=>Je(xe),[xe]),De=j?W??_e(k,j.id):``,ke=(0,z.useMemo)(()=>(A?.items??[]).map(e=>{let t=ae(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[A?.items,r.agentsSettings]),je=A?.items.find(e=>e.id===A.defaultId),ze=je?ae(je,r.agentsSettings):A?.defaultId??``,He=(0,z.useMemo)(()=>({defaultBooleanLabel:q.schemaBooleanDefault,unsupportedArrayType:q.schemaUnsupportedArrayType,arrayAddPlaceholder:q.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>q.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[q]),X=(0,z.useMemo)(()=>new Map((f??[]).map(e=>[e.name,e])),[f]),Z=f!==void 0,Ke=(0,z.useCallback)(e=>be(e,X.get(e.id),Z),[X,Z]),Q=(0,z.useCallback)(async()=>{await Promise.all([u.mutate(),g()])},[u,g]);Me((0,z.useCallback)(e=>{let t=Ae(e);t&&g(t,!1)},[g]),a);let Ye=(0,z.useMemo)(()=>a?{secondary:(0,H.jsx)(we,{ch:q,refreshing:u.isValidating||v,saveOk:!1,onRefresh:()=>void Q()})}:null,[u.isValidating,q,a,v,Q]);(0,z.useLayoutEffect)(()=>(t?.(Ye),()=>t?.(null)),[Ye,t]);let Xe=(0,z.useCallback)(e=>{s(p(e)),I(null),G(null),U(null)},[s]),Ze=(0,z.useCallback)(()=>{s(h),I(null),G(null),U(null)},[s]),Qe=(0,z.useCallback)(async e=>{se(e.id),U(null);try{let t=await C(w(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{se(null)}},[Q]);(0,z.useEffect)(()=>{G(null),de(!1)},[j?.id]);let $e=(0,z.useCallback)(async()=>{if(!j||!F&&W===null)return!1;let e=Be(j);R(!0),U(null);try{let t=await C(w(`/api/config`),{method:`PATCH`,body:JSON.stringify({...F?{channels:{[e]:F}}:{},...W===null?{}:{bindings:ve(k,j.id,W)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return F&&await P(F,!1),await b(),await u.mutate(),I(null),G(null),!0}catch(e){return U(e instanceof Error?e.message:String(e)),!1}finally{R(!1)}},[j,W,k,u,F,b,P]),et=(0,z.useCallback)(async e=>{let t=Y(e),n=Be(e),r=j?.id===e.id?F:null;if(!t.enabled&&!t.ready&&!r){Xe(e.id);return}te(e.id),U(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await C(w(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await u.mutate(),await b(),await g(),j?.id===e.id&&(await P(),I(null))}catch(e){U(e instanceof Error?e.message:String(e))}finally{te(null)}},[j?.id,u,F,b,P,g,Xe]),$=j?.ui?.modal,it=$?.placement!==`replace-config`,at=j?Ke(j):`checking`,ct=j?!Y(j).ready||B:!1;return a?(0,H.jsxs)(le,{gap:`gap-4`,className:Ie,padding:Le,children:[u.isLoading?(0,H.jsx)(oe,{sections:2}):u.error?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,H.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:d.map(e=>(0,H.jsx)(rt,{entry:e,config:D[Be(e)]?.config,runtime:Ke(e),busy:ee===e.id,restarting:re===e.id,ch:q,onOpen:()=>Xe(e.id),onToggle:()=>void et(e),onRestart:()=>void Qe(e)},e.id))}),V?(0,H.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:V}):null,(0,H.jsx)(Se,{presentation:`modal`,open:!!j,onOpenChange:e=>{e||Ze()},closeAriaLabel:q.close,srTitle:j?.label??q.selectChannel,srDescription:j?.description,wide:!0,footer:j?(0,H.jsx)(Te,{ch:q,dirty:!!F||W!==null,saving:L,onCancel:Ze,onDiscard:()=>{I(null),G(null)},onSave:$e}):null,children:j?(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(tt,{entry:j}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:j.label}),(0,H.jsx)(`span`,{className:S(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(at)),children:Ve(at,q)})]}),(0,H.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(j).ready&&me(j)?.[1].result===`qr`?q.scanLoginHint.replace(`{{channel}}`,j.label):j.description}),j.docsPath?(0,H.jsxs)(`a`,{href:j.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[q.docs,(0,H.jsx)(l,{className:`size-3.5`})]}):null]})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,H.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(j).enabled?q.enabledLabel:q.disabledLabel}),(0,H.jsx)(nt,{checked:Y(j).enabled,disabled:ee===j.id,label:q.toggleChannel.replace(`{{channel}}`,j.label),onToggle:()=>void et(j)})]})]})}),(0,H.jsx)(ot,{runtime:at,restarting:re===j.id,checking:v,showConnectionOptions:B,canManageConnection:Y(j).ready&&$?.placement!==`replace-config`,ch:q,onRestart:()=>void Qe(j),onCheck:()=>void Q(),onManageConnection:()=>de(e=>!e)}),(0,H.jsx)(st,{entry:j,ch:q}),ct&&$?.placement!==`replace-config`?(0,H.jsx)(he,{entry:j,locale:n,messages:q,compact:!0,onChanged:async()=>{await P(),await Q(),await b()}},j.id):null,$?.entrypoint&&$.placement===`before-config`?(0,H.jsx)(ie,{extensionId:j.extensionId,extensionName:j.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:j.id,entry:j,config:K}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,H.jsx)(ie,{extensionId:j.extensionId,extensionName:j.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:j.id,entry:j,config:K}}):null,it&&Ee?(0,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.basicConfiguration}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.basicConfigurationHint})]}),(0,H.jsx)(ue,{schema:xe,values:K,onChange:e=>I(e),disabled:L,labels:He})]}):null,(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(_,{className:`size-4 text-fg-muted`}),q.messageHandling]}),(0,H.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.agentRouting}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.messageHandlingHint})]}),(0,H.jsx)(o,{value:De,options:ke,placeholder:q.agentRoutingSelect,emptyLabel:q.agentRoutingDefault.replace(`{{agent}}`,ze||q.agentRoutingSelect),ariaLabel:q.agentRouting,disabled:L||!A,onChange:e=>G(e)})]})]}),it&&Je(Ce)?(0,H.jsx)(ce,{title:q.advancedConfiguration,summary:q.messageHandlingHint,children:(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(_,{className:`size-4 text-fg-muted`}),q.advancedConfiguration]}),(0,H.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,H.jsx)(ue,{schema:Ce,values:K,onChange:e=>I(e),disabled:L,labels:He})})]})}):null,V?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:V}):null]}):null})]}):(0,H.jsx)(le,{gap:`gap-3`,className:Ie,padding:Le,children:(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q.tokenRequired})})}export{ct as ChannelsSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),n=`/capabilities/channels`;function r(e){return`${n}/${encodeURIComponent(e.trim().toLowerCase())}`}function i(e){return e?.trim().toLowerCase()||null}export{t as i,r as n,i as r,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t}from"./locale-store-lIXD1FMw.js";import{t as n}from"./gateway-config-swr-BAmUhiP1.js";var r=null;async function i(){return r||(r=a().finally(()=>{r=null}),r)}async function a(){let r=await e(t(`/api/agents`));if(r.ok){let e=await r.json();if(e.ok&&e.payload?.defaultId&&Array.isArray(e.payload.agents)){let t=e.payload.defaultId.trim().toLowerCase(),n=e.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:(e.effective?.skills?.mode===`selected`?e.effective.skills.include??[]:[]).filter(e=>typeof e==`string`&&!!e.trim())}));if(n.length>0)return{defaultId:t,items:n}}}let i=(await n()).payload?.config?.agents,a=(i?.defaultId??`main`).trim().toLowerCase(),o=(Array.isArray(i?.list)?i.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase()}));return o.length===0?{defaultId:a,items:[{id:a}]}:{defaultId:a,items:o}}export{i as t};
|