@xopcai/xopc 0.0.301 → 0.0.302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-sCQ2ErNm.js → activity-store-DCi5rh4e.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-L6Vh9fL1.js → agent-avatar-dicebear-C0zP6W2B.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D0ITeUFb.js +1 -0
- package/dist/gateway/static/root/assets/{agents-CjwnFadx.js → agents-DcfWhk2S.js} +1 -1
- package/dist/gateway/static/root/assets/{api-pwK0DxZJ.js → api-CAV9PN9i.js} +1 -1
- package/dist/gateway/static/root/assets/api-fPapljyb.js +1 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-U3yDRzKF.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-ZFjV_opr.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-FgMHY1Pr.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BT7OnQyy.js → archive-plugin-MaKWrpgC.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CQGhCfVn.js → attachment-load-IfqbP2BN.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CHeFkkKk.js → automations-page-CeI2NGSO.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-B_-VM4Va.js → automations-workspace-DxaiBwrD.js} +3 -3
- package/dist/gateway/static/root/assets/{binary-plugins-D_8pZaqQ.js → binary-plugins-jvQ6FaBZ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-m48cnmng.js → block-editor-B7U3qlB3.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-jciex8-r.js → browser-automation-inputs-BGT0xoTv.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-ct9dHGJF.js → browser-automations-page-DvLAwoiQ.js} +1 -1
- package/dist/gateway/static/root/assets/browser-settings-page-CHrfg3BX.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DpYDPk_o.js +8 -0
- package/dist/gateway/static/root/assets/{channels-settings-BeDwuVtH.js → channels-settings-DMq-NBUQ.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-Cz3X8Gfa.js → channels-status-swr-C_icwbWj.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Bn_th7oe.js → chat-terminal-dock-BtL71IOs.js} +1 -1
- package/dist/gateway/static/root/assets/computer-settings-page-Bu6ZJtmS.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-page-D9xCnhbY.js → connectors-page-LsEiI9L5.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-C0ogAVG7.js → cron-expression-B25FHn4w.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-HtU776kx.js → date-picker-CzVHO7z9.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DvDdN4Xu.js → dependency-picker-BNugauiZ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-BWi5FE7D.js → desktop-pet-DTy_3-OY.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-CXfnejTb.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-CxKwfncn.js +1 -0
- package/dist/gateway/static/root/assets/extension-debug-page-C3F7RiGW.js +1 -0
- package/dist/gateway/static/root/assets/{extension-page-DxotmtcG.js → extension-page-C0jhcCT_.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-CNvJQkrr.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-COJzzscc.js → gateway-config-swr-D5AM8cyQ.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-CQTcIvlZ.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-211-jptU.js → gateway-startup-retry-CSJWdnFs.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DAHqGRKZ.js → heartbeat-settings-Cd1VJsHe.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BU59mAGQ.js → home-page-B_uyfCGq.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-sO31fQr_.js → image-generation-api-BNh604hw.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BQ4HTIVc.js → imports-page-DXNfRmk9.js} +1 -1
- package/dist/gateway/static/root/assets/index-BAqVpc1H.css +1 -0
- package/dist/gateway/static/root/assets/index-hlU8MUEz.js +79 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CgW5_XVP.js +1 -0
- package/dist/gateway/static/root/assets/{local-app-workbench-page-BtEQDQeQ.js → local-app-workbench-page-C4h3qDRL.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-BrEO9hz5.js → local-apps-page-DyrFxW3G.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DuG-kbsP.js → locale-store-DLK05Y1a.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-Goy_QHfL.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DC67VTpr.js → management-settings-DgQyGEpR.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-B1q2w6W_.js → markdown-view-B8maDRWh.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DdoSox1I.js → media-plugins-5DakFba_.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BYbx4OuI.js → messages-C9h8SImu.js} +3 -3
- package/dist/gateway/static/root/assets/note-detail-panel-lcZby9NY.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-CDGPPI-W.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-B_I0YuTK.js → page-tabs-DzJpglJJ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives--5Zt1oSs.js → preview-open-alternatives-Dj6LJsuQ.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-BBJZB2RV.js → proactive-page-CwudBdrQ.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CKFPKr0A.js → product-open-page-CujZXOea.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CyAf_sK-.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-BUsI5G7U.js → projects-page-BW5m_HhZ.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BDgFNu05.js → registry-api-BMFL4vis.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-B4JgwB0s.js +1 -0
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DV554qyN.js +5 -0
- package/dist/gateway/static/root/assets/{schema-form-CuIDQtYN.js → schema-form-Bh2Er67B.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-D5SmvlQ1.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DDALROy_.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-BsdM7P1d.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-BBG4jliE.js → settings-page-3yEAqoME.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-layout-X1x-2Cp9.js +1 -0
- package/dist/gateway/static/root/assets/{setup-status-panel-DXqDeXNi.js → setup-status-panel-BOHNZ-S3.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-DbE7gsDd.js → share-preview-page-wV056nz2.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-io4NzfJL.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CERFaxLj.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Dh33NKoP.js → skills-page-CtwUqvsE.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-BNz7GQvw.js → skills-page.utils-dHBD7YqU.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C3L8_KEq.js → system-settings-panel-lItR5Kah.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CCKc67a-.js +1 -0
- package/dist/gateway/static/root/assets/theme-store-KfFEGMlp.js +1 -0
- package/dist/gateway/static/root/assets/tunnel-api-DPyLgmWw.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-DSrlXbBg.js → use-autosave-DO50_g_S.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CcnGgH1n.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-9P97T0CT.js → voice-api-key-field-k7tWLXzM.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DJvwbFbz.js → voice-config-api-bZqN8-UF.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CoVHgrQY.js → work-discovery-overlay-BHI6gO_u.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BR-S_IGS.js → workflow-run-setup-panel-jEMtNIG8.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-CX4bcAD-.js +6 -0
- package/dist/gateway/static/root/index.html +10 -10
- package/dist/package.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/connectors/auth-provider-registry.js +1 -1
- package/dist/src/connectors/connected-source-ingestion.js +1 -1
- package/dist/src/connectors/connection-recovery-service.js +1 -1
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/gateway/automation-agent-session.js +6 -2
- package/dist/src/gateway/heartbeat/service.js +2 -2
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +3 -3
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/storage/sqlite/session-repository.js +9 -0
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C22DdeJ6.js +0 -1
- package/dist/gateway/static/root/assets/api-BjlN9GPQ.js +0 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-BPanjQB6.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-CUWA2E_f.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-D8hP1XhF.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-DNX0BZFM.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-nvCpR13B.js +0 -8
- package/dist/gateway/static/root/assets/computer-model-settings-BOObauzH.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-BicG-IvN.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-CptAwdZd.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-C8BiZYwP.js +0 -1
- package/dist/gateway/static/root/assets/extension-debug-page-nRRdMurF.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BK2t7aFl.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-rIGo_jeB.js +0 -1
- package/dist/gateway/static/root/assets/index-54o0AGdj.js +0 -79
- package/dist/gateway/static/root/assets/index-R89i_XYi.css +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-BSgsIe7E.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-DhXIIoc0.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-panel-CCIA4VbP.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-C8JeFMSH.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-DeTeDel1.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DSGwCc4h.js +0 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-BY9oD7eN.js +0 -5
- package/dist/gateway/static/root/assets/sessions-page-zAeJa1Ae.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BG4EILeB.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-C4D1p0xR.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-layout-CsUQKRq0.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BN_O6Dwt.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Sq-IWawl.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CJ1WpRpN.js +0 -1
- package/dist/gateway/static/root/assets/theme-store-JzZVUvEh.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-GLzwLaUZ.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-CX9eizCN.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-ea-j18xi.js +0 -6
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{d as a,h as o,p as s,r as c,t as l}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as u,r as d,t as f}from"./popover-select-DldSX8GX.js";import{t as p}from"./circle-check-C23XjkUj.js";import{t as m}from"./external-link-DjqjBmc3.js";import{t as h}from"./globe-DSSGFWFn.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./plus-Q2yW6OE7.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./cn-JdwAhgNB.js";import{a as b,c as x,i as S,n as C,r as w}from"./locale-store-DuG-kbsP.js";import{t as T}from"./messages-BYbx4OuI.js";import{a as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./dist-BGTk37IG.js";import{i as N}from"./vendor-swr-BIWyz7Rc.js";import{t as P}from"./button-CGlRPNzi.js";import{n as F,r as I}from"./gateway-config-swr-COJzzscc.js";import{t as L}from"./skeleton-BwbyijEw.js";import{i as R,o as z}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as B}from"./electron-env-Dit0bHgy.js";import{n as V,t as H}from"./registry-api-BDgFNu05.js";import{At as U,B as W,Bo as G,Co as K,Ct as q,Dt as ee,Et as te,Fo as J,Ft as ne,Go as Y,H as re,Ho as ie,Ic as ae,Io as oe,It as X,Jc as se,Jo as ce,Ju as le,Ko as ue,Lo as de,Lt as fe,Mo as pe,Mt as me,Nt as he,Nu as ge,Oc as _e,Oo as ve,Ot as ye,Pl as be,Pt as xe,Q as Se,Qs as Ce,Qu as we,Rl as Te,Rt as Ee,Sc as De,Sn as Oe,St as ke,To as Ae,Ts as je,Tt as Me,Uc as Ne,Uo as Pe,V as Fe,Wc as Ie,Wo as Le,X as Re,Yo as ze,Z as Be,Zu as Ve,_t as He,ac as Ue,bt as We,cl as Ge,ct as Ke,cu as qe,dt as Je,ft as Ye,gc as Xe,gl as Ze,gt as Qe,ht as $e,ia as et,jc as tt,jo as nt,jt as rt,ko as it,lt as at,mt as ot,oa as st,oc as ct,ot as lt,pt as ut,sa as dt,st as ft,ut as pt,vi as mt,vt as ht,wo as gt,ws as _t,wt as vt,yt,yu as bt}from"./index-54o0AGdj.js";import{n as xt,r as St}from"./settings-page-layout-CsUQKRq0.js";import{n as Ct,t as wt}from"./settings-form-section-C4D1p0xR.js";import{t as Tt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as Et,t as Dt}from"./use-autosave-DSrlXbBg.js";import{a as Ot,c as kt,d as At,f as jt,h as Mt,i as Nt,l as Pt,n as Ft,o as It,p as Lt,r as Rt,t as zt,u as Bt}from"./voice-config-api-DJvwbFbz.js";import{t as Vt}from"./voice-api-key-field-9P97T0CT.js";import{t as Ht}from"./page-tabs-B_I0YuTK.js";import{t as Ut}from"./settings-advanced-gate-BG4EILeB.js";import{a as Wt,i as Gt,n as Kt,o as qt,r as Jt,t as Yt}from"./image-generation-api-sO31fQr_.js";import{t as Xt}from"./computer-model-settings-BOObauzH.js";var Z=n(),Q=e(t(),1),$=r(),Zt={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 必须使用“名称: 值”格式,每行一个。`}},Qt=`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 $t(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 en(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 tn({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Zt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`bearer`),[b,x]=(0,Q.useState)(`x-api-key`),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[N,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(`/images/generations`),[B,V]=(0,Q.useState)(`/images/edits`),[H,U]=(0,Q.useState)(``),[W,G]=(0,Q.useState)(``),[K,q]=(0,Q.useState)([$t()]),[ee,te]=(0,Q.useState)(``),[J,ne]=(0,Q.useState)(),[Y,re]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)(),[oe,X]=(0,Q.useState)(),[se,ce]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),p(n?.baseUrl??``),h(t?.auth.type??`bearer`),x(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),C(r?`••••••••••••`:``),T(t?.apiKeyUrl??``),F(t?.documentationUrl??``),L(t?.paths?.generations??`/images/generations`),V(t?.paths?.edits??`/images/edits`),U(t?.network?.allowedHosts.join(`
|
|
4
|
-
`)??``),G(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
|
-
`)),q(t?.models.map($t)??[$t()]),te(t?.defaultModel??``),X(void 0),ne(void 0),re(!1),ae(void 0),ce(void 0)},[r,e,n]);let le=(0,Q.useMemo)(()=>K.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[K]),ue=(e,t)=>{q(n=>n.map((n,r)=>r===e?{...n,...t}:n))},de=()=>{let e=s.trim(),t=K.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!d.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=ee||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=en(W)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...N.trim()?{documentationUrl:N.trim()}:{},...w.trim()?{apiKeyUrl:w.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:b.trim()}:{type:m},paths:{...I.trim()?{generations:I.trim()}:{},...B.trim()?{edits:B.trim()}:{}},...H.trim()?{network:{allowedHosts:H.split(`
|
|
6
|
-
`).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},fe=async()=>{let e=de();return await Gt(e.providerId,e.input),m!==`none`&&S.trim()&&!pe(S)&&await Wt(e.providerId,S.trim()),await a(e.providerId),e},me=async()=>{ne(`save`),ae(void 0),X(void 0);try{await fe(),C(m===`none`?``:`••••••••••••`),X(o.saved)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{ne(void 0)}},he=async()=>{ne(`test`),ae(void 0),X(void 0),ce(void 0);try{let e=await fe();ce((await qt(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),X(o.testReady)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{ne(void 0)}},ge=async()=>{if(n){if(!Y){re(!0);return}ne(`delete`),ae(void 0);try{await Yt(n.providerId),await a(),t(!1)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{ne(void 0)}}};return(0,$.jsx)(M,{open:e,onOpenChange:t,children:(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),(0,$.jsxs)(A,{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-panel shadow-popover`,R),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)(j,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-subtle hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(v,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-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:o.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:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Qt}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`My Image Service`,className:Qt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:d,onChange:e=>p(e.target.value),placeholder:`https://api.example.com/v1`,className:Qt})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(f,{value:m,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>h(e),triggerClassName:`mt-1.5`})]}),m===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),className:Qt})]}):null]}),m===`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:o.apiKey}),w.trim()?(0,$.jsxs)(`a`,{href:w.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(Ve,{className:`size-3.5`})]}):null]}),(0,$.jsx)(nt,{id:`custom-image-api-key`,value:S,onChange:e=>C(pe(S)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>xe(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.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:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`https://…`,className:Qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:N,onChange:e=>F(e.target.value),placeholder:`https://…`,className:Qt})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.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:[o.generationsPath,(0,$.jsx)(`input`,{value:I,onChange:e=>L(e.target.value),className:Qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:B,onChange:e=>V(e.target.value),className:Qt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:H,onChange:e=>U(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:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:W,onChange:e=>G(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:o.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:o.models}),(0,$.jsxs)(P,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>q(e=>[...e,$t()]),children:[(0,$.jsx)(_,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(f,{value:ee||le[0]?.value||``,options:le,placeholder:o.defaultModel,allowEmpty:!1,onChange:te,triggerClassName:`mt-1.5 max-w-sm`})]}),K.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:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>ue(t,{id:e.target.value}),placeholder:`image-1`,className:Qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>ue(t,{name:e.target.value}),className:Qt})]})]}),(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:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>ue(t,{maxCount:e.target.value}),className:Qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>ue(t,{defaultCount:e.target.value}),className:Qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>ue(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(f,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>ue(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=>ue(t,{supportsSize:e.target.checked})}),o.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=>ue(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:K.length===1,onClick:()=>q(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)(ct,{className:`size-3.5`}),o.remove]})]})]},t))]}),se?(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)(qe,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:se,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,oe?(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:oe}):null,ie?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:ie}):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)(P,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!J,onClick:()=>void ge(),children:[J===`delete`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(ct,{className:`size-4`}),Y?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(P,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(P,{variant:`secondary`,disabled:!!J,onClick:()=>void he(),children:[J===`test`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):null,J===`test`?o.testing:o.test]}),(0,$.jsxs)(P,{variant:`primary`,disabled:!!J,onClick:()=>void me(),children:[J===`save`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):null,J===`save`?o.saving:o.save]})]})]})]})]})})}var nn=`••••••••••••`,rn={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 an(){let e=await b(w(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function on(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function sn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function cn(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function ln(e){let t=(0,Z.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)(f,{value:r,options:(n.options??[]).map(un),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 un(e){return{value:e.value,label:e.label}}function dn(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(L,{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(fn)}),(0,$.jsx)(L,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function fn(e,t){return(0,$.jsx)(L,{className:`h-24 rounded-xl`},t)}function pn(){let e=C(e=>e.language),t=rn[e],n=!!x(e=>e.conversationId),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[m,h]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(),[S,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(),{data:A,isLoading:j,error:M,mutate:I}=N(n?w(`/api/image-generation/catalog`):null,Jt,{revalidateOnFocus:!1}),{data:L,isLoading:R,error:z,mutate:B}=N(n?w(`/api/image-generation/custom-providers`):null,Kt,{revalidateOnFocus:!1}),{data:V,isLoading:H,error:U,mutate:W}=N(n?`default-image-generation`:null,an,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!A||!V)return;let e=on(V.model?.primary),t=A.find(t=>t.id===e)??A.find(e=>e.configured)??A[0];t&&(a(t.id),s(t.id===e&&sn(V.model?.primary)||t.defaultModel),l(t.configured?nn:``),d(cn(t)))},[V,A]);let G=A?.find(e=>e.id===r),K=G?G.apiKeyUrl??Be(G.id,e)[0]?.href:void 0,q=(0,Q.useMemo)(()=>(G?.models??[]).map(e=>({value:e,label:e})),[G?.models]),ee=V?.model?.primary,te=!!(G&&o&&(G.credentialMode!==`api-key`||G.configured||c.trim())&&G.configFields.every(e=>!e.required||u[e.key]?.trim()));if(!n)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(j||R||H)return(0,$.jsx)(dn,{});if(M||z||U||!A||!L)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let J=e=>{a(e.id),s(e.defaultModel),l(e.configured?nn:``),d(cn(e)),y(void 0)},ne=()=>{k(void 0),D(!0)},Y=()=>{let e=L.find(e=>e.providerId===G?.id);e&&(k(e),D(!0))},re=async e=>{let[t,n]=await Promise.all([B(),I()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);a(r.id),s(r.defaultModel),l(r.configured?nn:``),d(cn(r)),k(t?.find(t=>t.providerId===e))}},ie=async()=>{if(!(!G||!te)){h(!0),y(void 0),T(!1);try{let e=await b(w(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:G.id,modelId:o,...c.trim()&&!pe(c)?{apiKey:c.trim()}:{},providerConfig:Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()))})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([W(e.payload.default,{revalidate:!1}),I(e.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),F()]),l(nn),T(!0)}catch(e){y(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base 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)(Te,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.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:t.provider}),(0,$.jsxs)(P,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:ne,children:[(0,$.jsx)(_,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:A.map(e=>{let n=e.id===r,i=e.id===on(ee);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>J(e),className:`min-h-24 rounded-xl border p-4 text-left transition-colors ${n?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-base hover:border-edge-strong`}`,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-subtle px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.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)(p,{className:`size-3.5`}):(0,$.jsx)(be,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),G?(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(f,{value:o,options:q,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),G.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(ln,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),G.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(P,{variant:`secondary`,onClick:Y,children:[(0,$.jsx)(_e,{className:`size-4`}),t.manageService]})}):null,G.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:t.apiKey}),K?(0,$.jsxs)(`a`,{href:K,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(Ve,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(nt,{id:`image-generation-api-key`,value:c,onChange:e=>l(pe(c)?e.replace(/^•+/,``):e),placeholder:G.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>xe(G.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},G.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:G.configured?t.savedKey:t.apiKeyHint})]}):null,G.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-subtle 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`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:G.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(ln,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,S?(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:t.enabled}):null,v?(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:v}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(P,{variant:`primary`,disabled:!te||m,onClick:()=>void ie(),children:[m?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(p,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:m?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(tn,{open:E,onOpenChange:D,provider:O,configured:!!(O&&A.find(e=>e.id===O.providerId)?.configured),language:e,onSaved:re})]})}function mn({disabled:e=!1}){let t=C(e=>e.language)===`zh`,[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),{data:o,mutate:s,error:c}=N(w(`/api/voice/catalog`),async e=>{let t=await b(e);return ue.parse(t.payload)}),l=t?{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`},f=async e=>{if(o){r(!0),a(``);try{let t=await b(w(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:o.revision,selection:e})}:{}});await s(ue.parse(t.payload),!1),await F()}catch(e){a(e instanceof Error?e.message:String(e)),await s()}finally{r(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-edge p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:t?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(P,{variant:`secondary`,disabled:n||e||!o,onClick:()=>void f(),children:t?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`各设备共用此 Gateway 的模型设置,修改在下次调用生效。仅显示支持对应场景的已发布模型。`:`Devices share this gateway’s selections. Changes apply to the next call. Only published models supporting each mode are shown.`}),i||c?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:i||String(c)}):null,o?Object.keys(l).map(r=>{let i=o.selections.find(e=>e.mode===r),a=o.models.filter(e=>e.voice.modes.includes(r)),s=a.find(e=>e.id===i?.model);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:l[r]}),(0,$.jsxs)(u,{className:`w-full`,value:i?.model??``,disabled:n||e||!a.length,onChange:e=>void f({mode:r,model:e.target.value}),children:[(0,$.jsx)(d,{value:``,disabled:!0,children:t?`选择模型`:`Choose model`}),i&&!s?(0,$.jsxs)(d,{value:i.model,disabled:!0,children:[i.model,` · `,t?`不可用`:`Unavailable`]}):null,a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))]}),a.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t?`暂无可用模型`:`No available model`})]}),s&&s.voice.voices.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:t?`音色`:`Voice`}),(0,$.jsx)(u,{className:`w-full`,value:i?.voice??``,disabled:n||e,onChange:e=>void f({mode:r,model:s.id,voice:e.target.value}),children:s.voice.voices.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]}):null]},r)}):(0,$.jsx)(L,{className:`h-48 w-full`})]})}function hn({v:e}){let t=ce(e=>e.microphoneId),n=ce(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 f=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 border border-edge p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(u,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(d,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(d,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(d,{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)(P,{variant:`secondary`,disabled:s,onClick:()=>void f(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}function gn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(G)?.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),_=e=>{p.current=e,c(e)},v=()=>{m.current?.(),m.current=null};(0,Q.useEffect)(()=>()=>m.current?.(),[]);async function y(e){v(),i?.({input:!1,output:!1}),h.current=!1,u(``),f(``),_(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(()=>g(a.timeout),6e4);m.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function g(e){t.signal.aborted||(_(`error`),f(e),v())}async function y(){_(`playing`),l();try{let e=await jt(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),_(`confirm`))})}catch(e){g(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:ze()}),t.signal.aborted){l();return}if(s=await Y.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&g(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():(_(`passed`),i?.({input:!0,output:!1}),v()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&g(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await ie.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new Pe(o.sampleRate,s.session.inputFormat.sampleRate),_(`listening`)}catch(e){if(t.signal.aborted){l();return}g(e instanceof Error?e.message:a.testFailed)}}let b=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(P,{type:`button`,variant:`primary`,disabled:o||r||!t||b,onClick:()=>void y(!0),children:[b?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(Ge,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,disabled:o||r||!n||b,onClick:()=>void y(!1),children:[(0,$.jsx)(Ie,{className:`size-4`}),e.tts.test.play]}),b?(0,$.jsxs)(P,{type:`button`,variant:`ghost`,onClick:()=>{v(),_(`idle`)},children:[(0,$.jsx)(Xe,{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)(P,{type:`button`,variant:`secondary`,onClick:()=>{v(),i?.({input:h.current,output:!0}),_(`passed`)},children:a.heard}),(0,$.jsx)(P,{type:`button`,variant:`ghost`,onClick:()=>{v(),_(`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 _n(e,t){return{...e,stt:{...e.stt,enabled:!0,provider:t},voice:{...e.voice,realtime:{...e.voice.realtime,enabled:!0,tts:e.voice.realtime.tts?.provider===t?e.voice.realtime.tts:{provider:t,...t===`alibaba`?{voice:`Cherry`}:{}},omni:e.voice.realtime.omni?.provider===t?e.voice.realtime.omni:t===`xopc-cloud`?void 0:{provider:t,model:`qwen3-omni-flash-realtime`,voice:e.voice.realtime.omni?.voice??`Cherry`,instructions:e.voice.realtime.omni?.instructions??`Keep replies conversational and concise.`}}}}}function vn(e){let t=(0,Z.c)(117),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,f=r.setup,[p,m]=(0,Q.useState)(!1),h;t[0]===i?h=t[1]:(h=JSON.stringify(i),t[0]=i,t[1]=h);let g=h,_;t[2]===g?_=t[3]:(_={signature:g,input:!1,output:!1},t[2]=g,t[3]=_);let[v,y]=(0,Q.useState)(_);v.signature!==g&&y({signature:g,input:!1,output:!1});let b;t[4]!==a||t[5]!==g?(b=a?null:[`voice-realtime-status`,g],t[4]=a,t[5]=g,t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!0},t[7]=x):x=t[7];let{data:S,error:C,isLoading:T}=N(b,Rt,x),E;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=w(`/api/voice/catalog`),t[8]=E):E=t[8];let{data:D}=N(E,Cn),O=i.voice.realtime,k=i.stt.provider,A=O.tts,j=A?.provider??S?.tts?.provider,M=S?.tts?.model,F;t[9]!==M||t[10]!==j?(F=j&&M?[`realtime-voices`,j,M]:null,t[9]=M,t[10]=j,t[11]=F):F=t[11];let I;t[12]!==M||t[13]!==j?(I=()=>Nt(j,M,`realtime`),t[12]=M,t[13]=j,t[14]=I):I=t[14];let R;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},t[15]=R):R=t[15];let{data:z}=N(F,I,R),B;t[16]===z?B=t[17]:(B=z===void 0?[]:z,t[16]=z,t[17]=B);let V=B,H;t[18]!==j||t[19]!==V?(H=j===`alibaba`?V.filter(Sn):V,t[18]=j,t[19]=V,t[20]=H):H=t[20];let U=H,W=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,G;t[21]!==W||t[22]!==s?(G=!!W||s.some(xn),t[21]=W,t[22]=s,t[23]=G):G=t[23];let K=G,q=O.defaultEngine===`omni`,ee=q?O.omni?.voice??``:A?.voice??S?.tts?.voice??``,te;t[24]!==D?.models||t[25]!==q||t[26]!==O.omni?.model||t[27]!==O.omni?.provider||t[28]!==U?(te=q?O.omni?.provider===`xopc-cloud`?D?.models.find(e=>e.id===O.omni?.model)?.voice.voices??[]:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(bn):U,t[24]=D?.models,t[25]=q,t[26]=O.omni?.model,t[27]=O.omni?.provider,t[28]=U,t[29]=te):te=t[29];let J=te,ne=!!(S?.enabled&&S.stt),Y=!!(S?.enabled&&S.tts),re;t[30]!==i||t[31]!==c||t[32]!==O?(re=e=>c({...i,voice:{...i.voice,realtime:{...O,...e}}}),t[30]=i,t[31]=c,t[32]=O,t[33]=re):re=t[33];let ie=re,ae;t[34]!==i||t[35]!==c?(ae=e=>c(_n(i,e)),t[34]=i,t[35]=c,t[36]=ae):ae=t[36];let X=ae,se;t[37]!==a||t[38]!==O.enabled||t[39]!==f.disabled||t[40]!==f.needsSetup||t[41]!==f.pending||t[42]!==f.unverified||t[43]!==f.verified||t[44]!==g||t[45]!==v.signature?(se=(e,t)=>O.enabled?a?f.pending:e?t&&v.signature===g?f.verified:f.unverified:f.needsSetup:f.disabled,t[37]=a,t[38]=O.enabled,t[39]=f.disabled,t[40]=f.needsSetup,t[41]=f.pending,t[42]=f.unverified,t[43]=f.verified,t[44]=g,t[45]=v.signature,t[46]=se):se=t[46];let ce=se,le;t[47]!==o||t[48]!==X||t[49]!==p||t[50]!==C||t[51]!==i||t[52]!==W||t[53]!==K||t[54]!==c||t[55]!==a||t[56]!==k||t[57]!==O.defaultEngine||t[58]!==O.enabled||t[59]!==f.changeKey||t[60]!==f.configureConversation||t[61]!==f.customProvider||t[62]!==f.edgeHint||t[63]!==f.enable||t[64]!==f.finishSetup||t[65]!==f.hosted||t[66]!==f.hostedAccountHint||t[67]!==f.hostedHint||t[68]!==f.keyConfigured||t[69]!==f.keyHint||t[70]!==f.manageAccount||t[71]!==f.outputHint||t[72]!==f.ownKey||t[73]!==f.ownKeyHint||t[74]!==f.service||t[75]!==f.statusError||t[76]!==n||t[77]!==A||t[78]!==S?.tts||t[79]!==ie||t[80]!==r.experience||t[81]!==r.stt?(le=n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge pb-4`,children:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.enabled,className:`size-4 accent-accent`,checked:O.enabled,onChange:e=>{e.target.checked?X(k===`alibaba`?`alibaba`:`xopc-cloud`):ie({enabled:!1})}}),f.enable]})}),C?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:f.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:f.service}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`xopc-cloud`,`alibaba`].map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg border border-edge px-3 py-3 text-sm text-fg has-checked:border-accent/60`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`realtime-service`,value:e,checked:k===e,onChange:()=>X(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?f.hosted:f.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?f.hostedHint:f.ownKeyHint})]})]},e))})]}),k!==`alibaba`&&k!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:f.customProvider.replace(`{provider}`,k)}):null,k===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:K&&!p?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:f.keyConfigured}),(0,$.jsx)(P,{type:`button`,variant:`ghost`,onClick:()=>m(!0),children:f.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(Vt,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:W,labels:{...o,maskedHelp:``},onChange:e=>c({...i,stt:{...i.stt,providers:{...i.stt.providers,alibaba:{...i.stt.providers?.alibaba,apiKey:e}}}})}),(0,$.jsx)(`p`,{className:`text-fg-muted`,children:f.keyHint})]})}):null,k===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[f.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:f.manageAccount})]}):null,!A&&!a&&!S?.tts&&(k===`alibaba`||k===`xopc-cloud`)?(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3 text-xs`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:f.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?f.edgeHint:f.outputHint}),(0,$.jsx)(P,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>X(k),children:f.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(u,{value:O.defaultEngine,className:oe,onChange:e=>ie({defaultEngine:e.target.value}),children:[(0,$.jsx)(d,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(d,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[O.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=X,t[49]=p,t[50]=C,t[51]=i,t[52]=W,t[53]=K,t[54]=c,t[55]=a,t[56]=k,t[57]=O.defaultEngine,t[58]=O.enabled,t[59]=f.changeKey,t[60]=f.configureConversation,t[61]=f.customProvider,t[62]=f.edgeHint,t[63]=f.enable,t[64]=f.finishSetup,t[65]=f.hosted,t[66]=f.hostedAccountHint,t[67]=f.hostedHint,t[68]=f.keyConfigured,t[69]=f.keyHint,t[70]=f.manageAccount,t[71]=f.outputHint,t[72]=f.ownKey,t[73]=f.ownKeyHint,t[74]=f.service,t[75]=f.statusError,t[76]=n,t[77]=A,t[78]=S?.tts,t[79]=ie,t[80]=r.experience,t[81]=r.stt,t[82]=le):le=t[82];let ue;t[83]!==ee||t[84]!==q||t[85]!==j||t[86]!==O.bargeIn||t[87]!==O.omni||t[88]!==O.tts||t[89]!==f.bargeIn||t[90]!==f.defaultVoice||t[91]!==f.voice||t[92]!==n||t[93]!==A||t[94]!==S?.tts||t[95]!==ie||t[96]!==r.realtime||t[97]!==J?(ue=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(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:f.voice}),(0,$.jsxs)(u,{id:`realtime-voice`,className:`${oe} w-full sm:w-56`,value:ee,disabled:q?!O.omni:!A&&!S?.tts,onChange:e=>{if(q&&O.omni){ie({omni:{...O.omni,voice:e.target.value}});return}(j===`alibaba`||j===`xopc-cloud`)&&ie({tts:{...O.tts,provider:j,...e.target.value?{voice:e.target.value}:{}},...O.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...O.omni,voice:e.target.value}}:{}})},children:[q?null:(0,$.jsx)(d,{value:``,children:f.defaultVoice}),ee&&!J.some(e=>e.id===ee)?(0,$.jsx)(d,{value:ee,children:ee}):null,J.map(yn)]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[f.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":O.bargeIn,checked:O.bargeIn,className:`size-4 accent-accent`,onChange:e=>ie({bargeIn:e.target.checked})})]})]}):null,t[83]=ee,t[84]=q,t[85]=j,t[86]=O.bargeIn,t[87]=O.omni,t[88]=O.tts,t[89]=f.bargeIn,t[90]=f.defaultVoice,t[91]=f.voice,t[92]=n,t[93]=A,t[94]=S?.tts,t[95]=ie,t[96]=r.realtime,t[97]=J,t[98]=ue):ue=t[98];let de;t[99]!==ne||t[100]!==Y||t[101]!==C||t[102]!==T||t[103]!==a||t[104]!==n||t[105]!==g||t[106]!==S||t[107]!==ce||t[108]!==r||t[109]!==v.input||t[110]!==v.output?(de=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[T?(0,$.jsx)(L,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,ce(ne,v.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,ce(ne&&Y,v.input&&v.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,ce(!!(S?.enabled&&S.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(gn,{v:r,canListen:ne,canSpeak:Y,disabled:a||T||!!C,onVerified:e=>y({signature:g,...e})},`${g}:${JSON.stringify(S)}`)]}):null,t[99]=ne,t[100]=Y,t[101]=C,t[102]=T,t[103]=a,t[104]=n,t[105]=g,t[106]=S,t[107]=ce,t[108]=r,t[109]=v.input,t[110]=v.output,t[111]=de):de=t[111];let fe;return t[112]!==f.service||t[113]!==le||t[114]!==ue||t[115]!==de?(fe=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl border border-edge bg-surface-panel p-4 sm:p-5`,"aria-label":f.service,children:[le,ue,de]}),t[112]=f.service,t[113]=le,t[114]=ue,t[115]=de,t[116]=fe):fe=t[116],fe}function yn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function bn(e){return{id:e,name:e}}function xn(e){return e.id===`alibaba`&&e.configured}function Sn(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Cn(e){return ue.parse((await b(e)).payload)}function wn(e){let t=(0,Z.c)(22),{value:n,onChange:r}=e,i=C(En)===`zh`,a;t[0]===i?a=t[1]:(a=(e,t)=>i?t:e,t[0]=i,t[1]=a);let o=a,s;t[2]!==r||t[3]!==n?(s=e=>{n&&r({...n,...e})},t[2]=r,t[3]=n,t[4]=s):s=t[4];let c=s,l;t[5]===o?l=t[6]:(l=o(`Natural conversation · advanced`,`自然对话 · 高级设置`),t[5]=o,t[6]=l);let f;t[7]===l?f=t[8]:(f=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:l}),t[7]=l,t[8]=f);let p;t[9]===o?p=t[10]:(p=o(`Calls continue the same session using recent history. Service and credentials are shared with voice setup; override them here only when needed.`,`通话会接续同一会话的近期历史。默认共用语音服务与凭据,仅在需要独立配置时修改。`),t[9]=o,t[10]=p);let m;t[11]===p?m=t[12]:(m=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p}),t[11]=p,t[12]=m);let h;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(h=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Connection`,`连接方式`)}),(0,$.jsx)(u,{value:n.provider,onChange:e=>r({model:n.model,voice:n.voice,instructions:n.instructions,provider:e.target.value}),children:(0,$.jsxs)(d,{value:`alibaba`,children:[`DashScope · `,o(`Your API key`,`自有 API Key`)]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.provider===`xopc-cloud`?o(`Uses your XOPC sign-in and the platform’s published Omni route and credits.`,`使用 XOPC 登录授权、平台发布的 Omni 路由和额度。`):o(`Leave empty to use the shared voice service credential.`,`留空使用语音服务中已配置的凭据。`)}),(0,$.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.model}),n.provider===`alibaba`?(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:`API Key`}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,type:`password`,autoComplete:`new-password`,value:n.apiKey??``,onChange:e=>c({apiKey:e.target.value})})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Endpoint override (optional)`,`自定义服务地址(可选)`)}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:n.baseUrl??``,placeholder:n.provider===`alibaba`?`wss://dashscope.aliyuncs.com/api-ws/v1/realtime`:`https://router.xopc.ai/v1`,onChange:e=>c({baseUrl:e.target.value.trim()||void 0})})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Voice`,`音色`)}),(0,$.jsx)(u,{value:n.voice,onChange:e=>c({voice:e.target.value}),children:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(Tn)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Conversation instructions`,`聊天指令`)}),(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,rows:3,maxLength:8e3,value:n.instructions,onChange:e=>c({instructions:e.target.value})})]})]}):(0,$.jsx)(P,{variant:`secondary`,onClick:()=>r({provider:`alibaba`,model:`qwen3-omni-flash-realtime`,voice:`Cherry`,instructions:`You are a friendly voice companion. You cannot execute tools.`}),children:o(`Configure natural conversation`,`配置自然聊天`)}),t[13]=o,t[14]=r,t[15]=c,t[16]=n,t[17]=h):h=t[17];let g;return t[18]!==f||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[f,m,h]}),t[18]=f,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function Tn(e){return(0,$.jsx)(d,{value:e,children:e},e)}function En(e){return e.language}var Dn=J;function On(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de,`dark:border-edge`)}function kn(){return y(oe,J)}function An(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function jn(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 Mn(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Nn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Pn(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Fn(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;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function In(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Ln(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function Rn(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 zn(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 Bn(){let e=C(e=>e.language),t=T(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=Oe(),a=ce(e=>e.captions),o=ce(e=>e.setCaptions),s=!!x(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(zn,{form:null,baseline:null}),f=c.form,p=c.baseline,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(f);_.current=f;let v=(0,Q.useRef)({parsed:null,models:void 0}),{data:y,error:b,isLoading:S,mutate:E}=I(s),{data:D,error:O,isLoading:k,mutate:A}=N(s?w(`/api/voice/models`):null,Ot,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:F}=N(s?w(`/api/voice/providers`):null,It,{revalidateOnFocus:!1}),{data:L,error:R,isLoading:z}=N(s?w(`/api/voice/stt-providers`):null,kt,{revalidateOnFocus:!1}),B=(0,Q.useMemo)(()=>j?.providers??[],[j]),V=(0,Q.useMemo)(()=>L?.providers??[],[L]),H=(0,Q.useMemo)(()=>y?.payload?.config===void 0?null:Bt(y.payload.config),[y]),U=(0,Q.useMemo)(()=>!f||!p?!1:JSON.stringify(f)!==JSON.stringify(p),[f,p]);s?H!==null&&D!==void 0&&!g.current&&(v.current.parsed!==H||v.current.models!==D)&&(v.current={parsed:H,models:D},l({type:`sync`,value:H}),h(D)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},l({type:`reset`}),h(null),g.current=!1);let W=!!(s&&(H===null||D===void 0||j===void 0||L===void 0)&&(S||k||F||z)),G=b instanceof Error?b.message:b?String(b):O instanceof Error?O.message:O?String(O):M instanceof Error?M.message:M?String(M):R instanceof Error?R.message:R?String(R):null,K=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),q=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ee=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),te=(0,Q.useCallback)(t=>{g.current=!0,l({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),J=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),ne=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),Y=Dt({value:f,dirty:U,onSave:(0,Q.useCallback)(async e=>{let n=p?.stt.provider!==`xopc-local`&&e.stt.provider===`xopc-local`;try{await At(e),n&&window.dispatchEvent(new Event(zt)),l({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[p?.stt.provider,t.saveError])}),re=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:()=>e})},[]);if(!s)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(W)return(0,$.jsx)(Tt,{rows:4});if(!f||m===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:G??t.loadError}),(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>{E(),A()},children:t.retry})]});let ie=f.stt,ae=f.tts,oe=f.voice.input.refinement,X=In(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:Y.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(Et,{status:Y.status,error:Y.error})}),Y.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Y.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.setup.advanced,className:`flex flex-wrap gap-2`,children:[`listening`,`input`,`devices`,`service`,...i?[`diagnostics`]:[]].map(e=>(0,$.jsx)(P,{variant:n===e?`secondary`:`ghost`,"aria-pressed":n===e,onClick:()=>r(e),children:t.experience[e]},e))}),n===`listening`||n===`service`||n===`diagnostics`?(0,$.jsx)(vn,{section:n,v:t,form:f,pending:U||Y.status===`saving`||!!Y.error,apiKeyLabels:X,sttProviders:V,onChange:re}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vn,{v:t,voice:f.voice,updateLanguageMode:te}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-fg`,children:[t.experience.pace,(0,$.jsxs)(u,{className:kn(),value:String(f.voice.realtime.silenceDurationMs),onChange:e=>J({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(d,{value:`800`,children:t.experience.fast}),(0,$.jsx)(d,{value:`1200`,children:t.experience.standard}),(0,$.jsx)(d,{value:`2000`,children:t.experience.relaxed}),[800,1200,2e3].includes(f.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(d,{value:String(f.voice.realtime.silenceDurationMs),children:[f.voice.realtime.silenceDurationMs,` ms`]})]})]})]}):null,n===`input`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":a,className:`ui-checkbox`,checked:a,onChange:e=>o(e.target.checked)})]}),(0,$.jsxs)(`label`,{className:`space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:t.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.stt.refinementDesc}),(0,$.jsxs)(u,{className:kn(),value:oe.mode,onChange:e=>ee({mode:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:t.stt.refinementOff}),(0,$.jsx)(d,{value:`punctuation`,children:t.stt.refinementPunctuation}),(0,$.jsx)(d,{value:`light`,children:t.stt.refinementLight}),oe.mode===`custom`?(0,$.jsx)(d,{value:`custom`,children:t.setup.advanced}):null]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.setup.readout,` · `,ae.enabled?Pn(ae.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Kn,{v:t,apiKeyLabels:X,tts:ae,models:m,ttsProviders:B,updateTts:ne})]})]}):null,n===`devices`?(0,$.jsx)(hn,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mn,{disabled:U||Y.status===`saving`}),f.voice.realtime.enabled&&f.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(wn,{value:f.voice.realtime.omni,onChange:e=>J({omni:e})}):null,(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(Hn,{v:t,apiKeyLabels:X,stt:ie,models:m,sttProviders:V,updateStt:K,updateSttFallback:q}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})]})]}):null]})}function Vn(e){let t=(0,Z.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=kn(),t[7]=l):l=t[7];let f;t[8]===i?f=t[9]:(f=e=>i(e.target.value),t[8]=i,t[9]=f);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(d,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,$.jsx)(d,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==f||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(u,{className:l,value:r.languageMode,onChange:f,children:[p,m]}),t[14]=f,t[15]=p,t[16]=m,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-2xl bg-surface-base 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 Hn(e){let t=(0,Z.c)(58),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c}=e,l;if(t[0]!==o){let e=new Set;l=[];for(let t of o)e.has(t.id)||(e.add(t.id),l.push(t));t[0]=o,t[1]=l}else l=t[1];let f=l,p,m,h,g;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){p=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],g=p?.fields.find(Un),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=g}else p=t[6],m=t[7],h=t[8],g=t[9];let _=g,v=typeof h.model==`string`?h.model:void 0,b=v??(typeof _?.defaultValue==`string`?_.defaultValue:m[0]?.id),x;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(x=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=x):x=t[16];let S=x,C,w;t[17]!==v||t[18]!==b||t[19]!==_||t[20]!==S?(C=()=>{_&&b&&v!==b&&S({model:b})},w=[v,b,_,S],t[17]=v,t[18]=b,t[19]=_,t[20]=S,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Q.useEffect)(C,w);let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ge,{className:`size-4 text-accent`,strokeWidth:1.75}),t[23]=T):T=t[23];let E;t[24]===n.stt.title?E=t[25]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[24]=n.stt.title,t[25]=E);let D;t[26]===n.stt.description?D=t[27]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[26]=n.stt.description,t[27]=D);let O;t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=O):O=t[30];let k;t[31]===s?k=t[32]:(k=e=>s({enabled:e}),t[31]=s,t[32]=k);let A;t[33]!==i.enabled||t[34]!==k||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(A=(0,$.jsx)(Jn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:k}),t[33]=i.enabled,t[34]=k,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=A):A=t[37];let j;t[38]!==p?.fields||t[39]!==r||t[40]!==b||t[41]!==m||t[42]!==f||t[43]!==h||t[44]!==i.enabled||t[45]!==i.fallback?.enabled||t[46]!==i.provider||t[47]!==S||t[48]!==s||t[49]!==c||t[50]!==n?(j=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,Dn),children:[(0,$.jsx)(Zn,{children:n.stt.provider}),(0,$.jsx)(u,{className:kn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(d,{value:e.id,children:[Mn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(qn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:b,apiKeyLabels:r,onPatch:S})]}),i.provider===`xopc-local`?(0,$.jsx)(Gn,{v:n}):null,(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[38]=p?.fields,t[39]=r,t[40]=b,t[41]=m,t[42]=f,t[43]=h,t[44]=i.enabled,t[45]=i.fallback?.enabled,t[46]=i.provider,t[47]=S,t[48]=s,t[49]=c,t[50]=n,t[51]=j):j=t[51];let M;t[52]!==A||t[53]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[A,j]}),t[52]=A,t[53]=j,t[54]=M):M=t[54];let N;return t[55]!==M||t[56]!==O?(N=(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[O,M]}),t[55]=M,t[56]=O,t[57]=N):N=t[57],N}function Un(e){return e.key===`model`}function Wn(e){return`${Math.round(e/1024/1024)} MB`}function Gn({v:e}){let{data:t,error:n,mutate:r}=N(w(`/api/voice/local/status`),Ft,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=()=>void r();return window.addEventListener(zt,e),()=>window.removeEventListener(zt,e)},[r]);let c=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await Pt(e.id):await Lt(e.id),await r()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel/60 p-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,t?.runtime.ready===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:t.runtime.error??`Local voice runtime is unavailable`}):null,t?.decoder?.available===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-amber-700 dark:text-amber-300`,children:t.decoder.error??`Compressed audio decoding is unavailable`}):null,o?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:o}):null,(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,$.jsxs)(`div`,{className:y(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[Wn(t.approximateBytes),` · `,t.description]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,$.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,$.jsx)(P,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(g,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function Kn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a}){let[o,s]=(0,Q.useState)(e.tts.test.sampleText),[c,l]=(0,Q.useState)({status:`idle`}),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useCallback)(()=>{m.current?.abort(),m.current=null,f.current?.pause(),f.current=null,p.current&&=(URL.revokeObjectURL(p.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),b=n.providers?.[n.provider]??{},x=r?.tts?.[n.provider]?.length?r.tts[n.provider]:v?.models??[],S=v?.fields.find(e=>e.key===`model`),C=v?.fields.find(e=>e.key===`voice`),w=typeof b.model==`string`?b.model:void 0,T=w??(typeof S?.defaultValue==`string`?S.defaultValue:x[0]?.id),E=x.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:v?.voices??[],{data:O=[]}=N(T?`voice:tts:${n.provider}:${T}`:null,()=>Nt(n.provider,T??``),{revalidateOnFocus:!1}),k=O.length>0?O:D,A=typeof b.voice==`string`?b.voice:void 0,j=A??k.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof C?.defaultValue==`string`?C.defaultValue:k[0]?.id),M=(v?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),F=!!v?.diagnostics.requiresApiKey,I=!!v?.configured||!F,L=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{let e={};S&&T&&w!==T&&(e.model=T),C&&j&&A!==j&&(e.voice=j),Object.keys(e).length>0&&L(e)},[w,A,T,j,S,L,C]),(0,Q.useEffect)(()=>()=>h(),[h]);let R=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),z=(0,Q.useCallback)(async()=>{let t=o.trim();if(!t){l({status:`error`,message:e.tts.test.emptyText});return}h();let r=new AbortController;m.current=r,l({status:`loading`});try{let i=await Mt({text:t,provider:n.provider,providerConfig:b,...T?{model:T}:{},...j?{voice:j}:{}},r.signal);if(r.signal.aborted)return;let a=jn(i.audio,i.mimeType);p.current=a;let o=new Audio(a);f.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,An(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>l({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>l({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),l({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;h(),l({status:`error`,message:e instanceof Error?e.message:String(e)})}},[T,j,b,h,o,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base 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)(Ce,{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,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Jn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onChange:e=>a({enabled:e})}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,Dn),children:[(0,$.jsx)(Zn,{children:e.tts.trigger}),(0,$.jsxs)(u,{className:kn(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(d,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(d,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(d,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,Dn),children:[(0,$.jsx)(Zn,{children:e.tts.provider}),(0,$.jsx)(u,{className:kn(),value:n.provider,onChange:e=>R(e.target.value),children:_.map(t=>(0,$.jsx)(d,{value:t.id,children:Nn(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??Fn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!I||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(qn,{kind:`tts`,providerId:n.provider,fields:M,providerSlice:b,models:x,voices:k,currentModel:T,currentVoice:j,apiKeyLabels:t,onPatch:L,resetVoiceOnModelChange:!0})})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(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)(P,{type:`button`,variant:`primary`,onClick:()=>void z(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(g,{className:`size-4 animate-spin`}):(0,$.jsx)(Ie,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,onClick:()=>{h(),l(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:c.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(Xe,{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(On(),`mt-3 min-h-20 resize-y`),value:o,onChange:e=>s(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:[o.length,`/1000`]}),c.status===`playing`||c.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[c.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,c.summary]}):null,c.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:c.message}):null]})]})]}):null]})]})}function qn({kind:e,providerId:t,fields:n,providerSlice:r,models:i,voices:a=[],currentModel:o,currentVoice:s,apiKeyLabels:c,onPatch:l,resetVoiceOnModelChange:f=!1}){return n.map(n=>n.key===`apiKey`?(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,Dn),children:[(0,$.jsx)(Zn,{children:n.label}),(0,$.jsx)(Vt,{kind:e,providerId:t,fieldId:`voice-${e}-${t}-api-key`,value:typeof r.apiKey==`string`?r.apiKey:``,onChange:e=>l({apiKey:e}),labels:c,placeholder:n.placeholder}),n.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.description}):null]},n.key):n.key===`model`&&i.length>0?(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,Dn),children:[(0,$.jsx)(Zn,{children:n.label}),(0,$.jsx)(u,{className:kn(),value:o??``,onChange:e=>l({model:e.target.value,...f?{voice:void 0}:{}}),children:i.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):n.key===`voice`&&a.length>0?(0,$.jsxs)(`div`,{className:y(`flex flex-col gap-1.5`,Dn),children:[(0,$.jsx)(Zn,{children:n.label}),(0,$.jsx)(u,{className:kn(),value:s??``,onChange:e=>l({voice:e.target.value}),children:a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):(0,$.jsx)(Yn,{field:n,value:Ln(r,n),onChange:e=>l({[n.key]:e}),className:n.type===`textarea`?`sm:col-span-2`:Dn},n.key))}function Jn(e){let t=(0,Z.c)(27),{checked:n,title:r,description:i,onChange:a}=e,o;t[0]!==n||t[1]!==a?(o=()=>a(!n),t[0]=n,t[1]=a,t[2]=o):o=t[2];let s=n?`bg-surface-panel text-fg`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,c;t[3]===s?c=t[4]:(c=y(`group flex w-full items-center justify-between gap-4 rounded-lg border border-edge px-3 py-3 text-left transition-colors`,de,s),t[3]=s,t[4]=c);let l;t[5]===r?l=t[6]:(l=(0,$.jsx)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:r}),t[5]=r,t[6]=l);let u;t[7]===i?u=t[8]:(u=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[7]=i,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,p;t[12]===f?p=t[13]:(p=y(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,f),t[12]=f,t[13]=p);let m=n?`translate-x-5`:`translate-x-0.5`,h;t[14]===m?h=t[15]:(h=y(`size-5 rounded-full bg-white shadow-surface transition-transform`,m),t[14]=m,t[15]=h);let g;t[16]===h?g=t[17]:(g=(0,$.jsx)(`span`,{className:h}),t[16]=h,t[17]=g);let _;t[18]!==g||t[19]!==p?(_=(0,$.jsx)(`span`,{className:p,"aria-hidden":!0,children:g}),t[18]=g,t[19]=p,t[20]=_):_=t[20];let v;return t[21]!==n||t[22]!==o||t[23]!==_||t[24]!==c||t[25]!==d?(v=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:o,className:c,children:[d,_]}),t[21]=n,t[22]=o,t[23]=_,t[24]=c,t[25]=d,t[26]=v):v=t[26],v}function Yn(e){let t=(0,Z.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?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`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(Rn(n,e.target.checked)),t[9]=n,t[10]=i,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 c=typeof r==`boolean`?``:String(r),l;t[19]===a?l=t[20]:(l=y(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(Zn,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(u,{id:o,className:kn(),value:c,required:n.required,onChange:e=>i(Rn(n,e.target.value)),children:(n.options??[]).map(Xn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:y(On(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(Rn(n,e.target.value))}):n.type===`password`?(0,$.jsx)(nt,{id:o,className:a,value:c,onChange:e=>i(Rn(n,e)),placeholder:n.placeholder,labels:ve}):(0,$.jsx)(`input`,{id:o,className:On(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(Rn(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==l||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[d,f,p]}),t[31]=l,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Xn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function Zn(e){let t=(0,Z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Qn(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=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function $n(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await b(w(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),F()}async function er(e){let t=await b(w(`/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 tr(e){let t=(0,Z.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 nr(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de,`dark:border-edge`)}function rr(){return y(oe,J)}var ir=[`brave`,`tavily`,`bing`,`searxng`];function ar(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var or=st();function sr(){let e=T(C(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!x(e=>e.conversationId),[i,a]=(0,Q.useReducer)(or,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let f=(0,Q.useRef)(null),{data:p,error:m,isLoading:h,mutate:g}=I(r);dt({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Qn(p.payload.config),[p]),dirty:c.current,trackedParsedRef:f,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&h&&p===void 0&&!m),b=m instanceof Error?m.message:m?String(m):null,S=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),w=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),E=Dt({value:o,dirty:S,onSave:(0,Q.useCallback)(async e=>{try{await $n(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])});return r?v?(0,$.jsx)(Tt,{rows:3}):o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,onBlurCapture:E.onBlurCapture,children:[E.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E.error}):null,(0,$.jsxs)(wt,{children:[(0,$.jsx)(Ct,{icon:tt,title:t.sectionRegion,trailing:(0,$.jsx)(Et,{status:E.status,error:E.error})}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(tr,{label:t.regionLabel,children:(0,$.jsxs)(u,{className:rr(),value:o.regionMode,onChange:e=>w({regionMode:e.target.value}),children:[(0,$.jsx)(d,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(d,{value:`cn`,children:t.regionCn}),(0,$.jsx)(d,{value:`global`,children:t.regionGlobal})]})})})]}),(0,$.jsx)(Ut,{children:(0,$.jsxs)(wt,{children:[(0,$.jsx)(Ct,{icon:le,title:t.sectionBlocklist}),(0,$.jsxs)(`div`,{className:`flex max-w-xl 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=>w({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})]})]}),(0,$.jsx)(tr,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:y(nr(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
8
|
-
`),placeholder:t.blocklistDomainsPlaceholder,disabled:!o.blocklistEnabled,onChange:e=>{w({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(wt,{children:[(0,$.jsx)(Ct,{icon:tt,title:t.sectionSearch}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(tr,{label:t.maxResultsLabel,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:nr(),value:o.maxResults,onChange:e=>w({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(cr,{row:n,providerIndex:r,labels:t,secretLabels:it(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,w({providers:t})},onRemove:()=>{w({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>w({providers:[...o.providers,ar()]}),children:[(0,$.jsx)(_,{className:`size-4`}),t.addProvider]})]})]})]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:b??t.loadError}),(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>void g(),children:n.refresh})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function cr(e){let t=(0,Z.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>er(r).then(lr),t[0]=r,t[1]=c);let l=c,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=y(rr(),`min-w-[8rem]`),t[2]=f):f=t[2];let p=n.type,m;t[3]!==o||t[4]!==n?(m=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=m):m=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=ir.map(e=>(0,$.jsx)(d,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==m||t[10]!==h?(g=(0,$.jsx)(u,{className:f,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,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:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=v):v=t[17];let b;t[18]!==i.disabled||t[19]!==v?(b=(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]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(ct,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===s?S=t[23]:(S=(0,$.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:x}),t[22]=s,t[23]=S);let C;t[24]!==S||t[25]!==b?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,S]}),t[24]=S,t[25]=b,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==g?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,C]}),t[27]=C,t[28]=g,t[29]=w):w=t[29];let T;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(T=n.type===`searxng`?(0,$.jsx)(tr,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:nr(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=T):T=t[34];let E;t[35]!==o||t[36]!==n?(E=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=E):E=t[37];let D;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==l||t[42]!==n.apiKey||t[43]!==a||t[44]!==E?(D=(0,$.jsx)(nt,{value:n.apiKey,onChange:E,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=l,t[42]=n.apiKey,t[43]=a,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(O=(0,$.jsx)(tr,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=O):O=t[49];let k;return t[50]!==w||t[51]!==T||t[52]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[w,T,O]}),t[50]=w,t[51]=T,t[52]=O,t[53]=k):k=t[53],k}function lr(e){return e.apiKey??null}var ur=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function dr(e){let t=new Map;for(let e of ur)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}var fr=`xopc-cloud`;function pr(e){let t=(0,Z.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={type:`pick`},t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(``),m;t[1]===r?m=t[2]:(m=e=>{e||window.setTimeout(()=>{d({type:`pick`}),p(``)},200),r(e)},t[1]=r,t[2]=m);let h=m,g;t[3]!==h||t[4]!==c?(g=()=>{c(),h(!1)},t[3]=h,t[4]=c,t[5]=g):g=t[5];let _=g,v;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,z)}),t[6]=v):v=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=y(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,R),t[7]=b):b=t[7];let x;t[8]!==i||t[9]!==a||t[10]!==_||t[11]!==o||t[12]!==s||t[13]!==f||t[14]!==u.presetKey||t[15]!==u.providerId||t[16]!==u.type?(x=(0,$.jsxs)(k,{children:[v,(0,$.jsx)(A,{className:b,children:u.type===`pick`?(0,$.jsx)(hr,{builtinRows:i,searchQuery:f,onSearchChange:p,labels:o,onPickBuiltin:e=>{let t=He(e);d(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>d({type:`custom`})}):u.type===`builtin`?(0,$.jsx)(yr,{providerId:u.providerId,builtinRows:i,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:_}):(0,$.jsx)(Sr,{initialPresetKey:u.presetKey,customConfig:a,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:_})})]}),t[8]=i,t[9]=a,t[10]=_,t[11]=o,t[12]=s,t[13]=f,t[14]=u.presetKey,t[15]=u.providerId,t[16]=u.type,t[17]=x):x=t[17];let S;return t[18]!==h||t[19]!==n||t[20]!==x?(S=(0,$.jsx)(M,{open:n,onOpenChange:h,children:x}),t[18]=h,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function mr(e){let t=(0,Z.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,je.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function hr(e){let t=(0,Z.c)(49),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,onPickBuiltin:o,onPickCustom:s}=e,c;t[0]===r?c=t[1]:(c=r.trim().toLowerCase(),t[0]=r,t[1]=c);let l=c,u;bb0:{if(!l){u=n;break bb0}let e;if(t[2]!==n||t[3]!==l){let r;t[5]===l?r=t[6]:(r=e=>{let t=Re[e.id]?.aliases??[];return e.id.toLowerCase().includes(l)||e.name.toLowerCase().includes(l)||t.some(e=>e.toLowerCase().includes(l))},t[5]=l,t[6]=r),e=n.filter(r),t[2]=n,t[3]=l,t[4]=e}else e=t[4];u=e}let d=u,f;t[7]===d?f=t[8]:(f=d.find(_r),t[7]=d,t[8]=f);let p=f,m;t[9]===d?m=t[10]:(m=dr(d.filter(gr)),t[9]=d,t[10]=m);let g=m,_;t[11]===a.step1Title?_=t[12]:(_=(0,$.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[11]=a.step1Title,t[12]=_);let v;t[13]===a.close?v=t[14]:(v=(0,$.jsx)(mr,{label:a.close}),t[13]=a.close,t[14]=v);let b;t[15]!==_||t[16]!==v?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[_,v]}),t[15]=_,t[16]=v,t[17]=b):b=t[17];let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(tt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=x):x=t[18];let S;t[19]===i?S=t[20]:(S=e=>i(e.target.value),t[19]=i,t[20]=S);let C=a.searchPlaceholder,w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=y(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,de),t[21]=w):w=t[21];let T;t[22]!==a.searchPlaceholder||t[23]!==r||t[24]!==S?(T=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[x,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:S,placeholder:C,autoComplete:`off`,className:w})]})}),t[22]=a.searchPlaceholder,t[23]=r,t[24]=S,t[25]=T):T=t[25];let E;t[26]!==a.recommended||t[27]!==o||t[28]!==p?(E=p?(0,$.jsxs)(`div`,{className:`mb-2`,children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.recommended}),(0,$.jsx)(vr,{row:p,onPick:o})]}):null,t[26]=a.recommended,t[27]=o,t[28]=p,t[29]=E):E=t[29];let D;t[30]!==a.addCustom||t[31]!==a.customDescription||t[32]!==s||t[33]!==l?(D=l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:y(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,je.press),children:[(0,$.jsx)(h,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.addCustom}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.customDescription})]}),(0,$.jsx)(ge,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[30]=a.addCustom,t[31]=a.customDescription,t[32]=s,t[33]=l,t[34]=D):D=t[34];let O;t[35]!==d.length||t[36]!==g||t[37]!==a.categories||t[38]!==a.noResults||t[39]!==o?(O=d.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:ur.map(e=>{let t=g.get(e)??[];return t.length===0?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:a.categories[e]??e}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,$.jsx)(vr,{row:e,onPick:o},e.id))})]},e)})}),t[35]=d.length,t[36]=g,t[37]=a.categories,t[38]=a.noResults,t[39]=o,t[40]=O):O=t[40];let k;t[41]!==E||t[42]!==D||t[43]!==O?(k=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[E,D,O]}),t[41]=E,t[42]=D,t[43]=O,t[44]=k):k=t[44];let A;return t[45]!==T||t[46]!==k||t[47]!==b?(A=(0,$.jsxs)($.Fragment,{children:[b,T,k]}),t[45]=T,t[46]=k,t[47]=b,t[48]=A):A=t[48],A}function gr(e){return e.id!==fr}function _r(e){return e.id===fr}function vr(e){let t=(0,Z.c)(12),{row:n,onPick:r}=e,i;t[0]!==r||t[1]!==n.id?(i=()=>r(n.id),t[0]=r,t[1]=n.id,t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=y(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,je.press),t[3]=a):a=t[3];let o;t[4]===n.name?o=t[5]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:n.name}),t[4]=n.name,t[5]=o);let s;t[6]===n.configured?s=t[7]:(s=n.configured?(0,$.jsx)(p,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null,t[6]=n.configured,t[7]=s);let c;return t[8]!==i||t[9]!==o||t[10]!==s?(c=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[o,s]}),t[8]=i,t[9]=o,t[10]=s,t[11]=c):c=t[11],c}function yr({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=Re[e],[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(null),b=T(r).providersSettings,x=it(b),S=(0,Q.useMemo)(()=>Be(e,r),[e,r]),C=o?.supportsApiKey!==!1,w=o?.supportsOAuth===!0,[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),[A,M]=(0,Q.useState)(`idle`),[N,F]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(``),H=(0,Q.useRef)(null),U=(0,Q.useRef)(null),G=A===`waiting`||A===`waiting_code`;(0,Q.useEffect)(()=>{if(!E||!G)return;let t=window.setInterval(()=>{(async()=>{try{let n=await vt(E);n.status===`waiting_auth`||n.status===`waiting_code`?(M(n.status===`waiting_code`?`waiting_code`:`waiting`),k(n.message??null),F(n.authUrl??null),L(n.instructions??null),z(n.deviceCode??null),n.authUrl&&n.authUrl!==U.current&&(U.current=n.authUrl,Fe(n.authUrl,H.current).catch(()=>{}))):n.status===`completed`?(window.clearInterval(t),W(H.current),H.current=null,e===`xopc-cloud`&&await Ee(),M(`success`),k(n.message??b.saved),window.setTimeout(a,600)):(n.status===`failed`||n.status===`cancelled`)&&(window.clearInterval(t),W(H.current),H.current=null,M(`error`),k(n.error??n.message??b.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(t)},[E,G,a,e,b.revokeFailed,b.saved]),(0,Q.useEffect)(()=>()=>{E&&q(E).catch(()=>{})},[E]),(0,Q.useEffect)(()=>()=>{W(H.current),H.current=null},[]);let K=async()=>{W(H.current),H.current=re(),U.current=null,M(`waiting`),k(b.oauthStarting),F(null),L(null),z(null),m(null);try{D((await te(e)).sessionId)}catch(e){W(H.current),H.current=null,M(`error`),k(e instanceof Error?e.message:b.revokeFailed)}},J=async()=>{if(E){try{await ke(E)}catch{}W(H.current),H.current=null,U.current=null,M(`idle`),k(null),D(null),F(null),L(null),z(null)}},ne=async()=>{if(!(!E||!B.trim()))try{await ee(E,B.trim()),V(``),k(b.oauthProcessingCode)}catch(e){M(`error`),k(e instanceof Error?e.message:b.revokeFailed)}},Y=async()=>{let t=c.trim();if(!(!t||!C)){d(!0),m(null);try{await me({[e]:t}),_(!0),window.setTimeout(a,600)}catch(e){m(e instanceof Error?e.message:n.saveError)}finally{d(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,je.press),"aria-label":n.back,children:(0,$.jsx)(ge,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(mr,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[s?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.description}):null,C?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(nt,{id:`builtin-api-key`,value:c,onChange:l,placeholder:n.apiKeyPlaceholder,labels:x,inputRef:v,onKeyDown:e=>{e.key===`Enter`&&Y()}})]}):null,w?(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:b.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:b.oauthHint})]}),(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:G,onClick:()=>void K(),children:[G?(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,b.oauth]})]}),O?(0,$.jsx)(`p`,{className:y(`text-xs`,A===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:O}):null,A===`waiting`||A===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N?(0,$.jsxs)(`a`,{href:N,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-white hover:bg-accent-hover`,children:[b.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>void J(),children:b.cancelOAuth})]}):null,I?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:I}):null,R?(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:b.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:R}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:b.deviceCodeHint})]}):null,A===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:B,onChange:e=>V(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ne(),placeholder:b.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`,de)}),(0,$.jsx)(P,{type:`button`,variant:`primary`,onClick:()=>void ne(),children:b.submitCode})]}):null]}):null,S.length>0&&C?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:S.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:[Se(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,f?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),C?(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:!c.trim()||u||h,onClick:()=>void Y(),children:h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):u?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function br(e=`custom`){if(e!==`custom`&&ut[e]){let t=ut[e].config;return{preset:e,providerId:yt(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function xr(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:ut[t.key]?br(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function Sr({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Q.useReducer)(xr,void 0,()=>br(e)),[c,l]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=it(T(r).providersSettings),{preset:h,providerId:b,baseUrl:x,api:S,apiKey:C,modelIds:w,error:E}=o,D=async()=>{let e=b.trim(),r=x.trim();if(!e){s({type:`setError`,value:n.providerIdRequired});return}if(!r){s({type:`setError`,value:n.baseUrlRequired});return}let i=w.map(e=>e.trim()).filter(Boolean);l(!0),s({type:`setError`,value:null});try{let n=t?.providers??{},o=h===`custom`?void 0:ut[h]?.config,s={...o??{},baseUrl:r,api:S,apiKey:C.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await Je({providers:{...n,[e]:s}}),a()}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{l(!1)}},O=async()=>{let e=b.trim()||yt(h)||`custom`,t=x.trim();if(!t){s({type:`setError`,value:n.baseUrlRequired});return}p(!0),s({type:`setError`,value:null});try{let r=h===`custom`?void 0:ut[h]?.config,i=(await Ke({providerId:e,baseUrl:t,apiKey:C.trim()||void 0,api:S,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));s({type:`setModelIds`,values:i}),i.length===0&&s({type:`setError`,value:n.discoverModelsHint})}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},k=b.trim()&&x.trim(),A=(S===`openai-completions`||S===`openai-responses`)&&x.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,je.press),"aria-label":n.back,children:(0,$.jsx)(ge,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(j,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)(mr,{label:n.close})]}),(0,$.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,$.jsxs)(u,{id:`custom-preset`,value:h,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:We(),children:[(0,$.jsx)(d,{value:`custom`,children:n.presetCustom}),ot.map(e=>(0,$.jsx)(d,{value:e.key,children:e.label},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,value:b,onChange:e=>s({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,de)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:x,onChange:e=>s({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,de)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,$.jsx)(u,{id:`custom-api-type`,value:S,onChange:e=>s({type:`setApi`,value:e.target.value}),className:We(),children:lt.map(e=>(0,$.jsx)(d,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(nt,{id:`custom-api-key`,value:C,onChange:e=>s({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,$.jsxs)(P,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!A||f,onClick:()=>void O(),children:[f?(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(tt,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),w.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>s({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:y(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,de)}),w.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:y(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,je.press),children:(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(P,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),E?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:!k||c,onClick:()=>void D(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Cr(){let e=(0,Z.c)(29),t=!!x(kr),{data:n,isLoading:r}=I(t),i;e[0]===t?i=e[1]:(i=t?w(`/api/providers/meta`):null,e[0]=t,e[1]=i);let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},e[2]=a):a=e[2];let{data:o,isLoading:s}=N(i,Or,a),c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},e[3]=c):c=e[3];let{data:l,isLoading:u}=N(t?H:null,Dr,c),d;e[4]===l?d=e[5]:(d=l===void 0?[]:l,e[4]=l,e[5]=d);let f=d,p;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[6]=p):p=e[6];let{data:m}=N(t?X:null,Er,p),h;bb0:{if(!o||n===void 0){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[7]=t):t=e[7],h=t;break bb0}let t;e[8]!==n?.payload?.config||e[9]!==o||e[10]!==f?(t=rt(o,he(n?.payload?.config),f),e[8]=n?.payload?.config,e[9]=o,e[10]=f,e[11]=t):t=e[11],h=t}let g=h,_;bb1:{if(!m){_=null;break bb1}let t;e[12]===m.config?t=e[13]:(t=pt(m.config),e[12]=m.config,e[13]=t),_=t}let v=_,y;if(e[14]!==g||e[15]!==v||e[16]!==o||e[17]!==f){y=[];let t=new Set((o??[]).filter(Tr).map(wr)),n;e[19]===v?n=e[20]:(n=new Set(v?Object.keys(v.providers):[]),e[19]=v,e[20]=n);let r=n;for(let e of g){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?v.providers[e.id]?.models?.length??0:f.filter(t=>t.provider===e.id).length;y.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(v){let t;e[21]===v.providers?t=e[22]:(t=Object.entries(v.providers),e[21]=v.providers,e[22]=t);for(let[e,n]of t)y.some(t=>t.id===e)||y.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[14]=g,e[15]=v,e[16]=o,e[17]=f,e[18]=y}else y=e[18];let b=y,S=r||s||u,C;return e[23]!==g||e[24]!==b||e[25]!==v||e[26]!==S||e[27]!==f?(C={cards:b,loading:S,builtinRows:g,customConfig:v,allModels:f},e[23]=g,e[24]=b,e[25]=v,e[26]=S,e[27]=f,e[28]=C):C=e[28],C}function wr(e){return e.id}function Tr(e){return e.configured}function Er(){return at()}function Dr(){return V()}async function Or(e){let{payload:t}=await(await fetch(e,{credentials:`same-origin`,redirect:`error`})).json();return t?.providers??[]}function kr(e){return e.conversationId}function Ar(e){let t=(0,Z.c)(16),{labels:n,data:r,onAdd:i,onManage:a}=e,{cards:o,loading:s}=r;if(s){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(L,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(Mr)})]}),t[1]=n):n=t[1],n}let c;if(t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==a){let e=o.filter(jr),r=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,s;t[7]===r?s=t[8]:(s=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[7]=r,t[8]=s);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(_,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==i?(u=(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:i,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=i,t[12]=u):u=t[12];let d;t[13]!==s||t[14]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[s,u]}),t[13]=s,t[14]=u,t[15]=d):d=t[15],c=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:i,children:[(0,$.jsx)(_,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,$.jsx)(Nr,{card:e,labels:n,onManage:()=>a(e.id,e.isCustom)},e.id))})]}),t[2]=o,t[3]=n,t[4]=i,t[5]=a,t[6]=c}else c=t[6];return c}function jr(e){return e.configured}function Mr(e){return(0,$.jsx)(L,{className:`h-32 rounded-2xl`},e)}function Nr(e){let t=(0,Z.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=y(`group relative flex flex-col justify-between rounded-2xl bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,je.pressCard),t[0]=a):a=t[0];let o;t[1]===n.name?o=t[2]:(o=(0,$.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=o);let s;t[3]!==n.isCustom||t[4]!==r.custom?(s=n.isCustom?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=s):s=t[5];let c;t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(p,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]===c?u=t[11]:(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,l]}),t[10]=c,t[11]=u);let d;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(d=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=d):d=t[15];let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d}),t[16]=d,t[17]=f);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(_e,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==f?(g=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[f,h]}),t[21]=h,t[22]=f,t[23]=g):g=t[23];let _;return t[24]!==i||t[25]!==g||t[26]!==u?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[u,g]}),t[24]=i,t[25]=g,t[26]=u,t[27]=_):_=t[27],_}function Pr(e){let t=(0,Z.c)(184),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=C(Ir)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:ft(``),t[0]=n,t[1]=l);let[f,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(Fr),g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=g):g=t[2];let _=g,b;t[3]!==f.computerUse||t[4]!==f.contextWindow||t[5]!==f.id||t[6]!==f.input||t[7]!==f.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(b=()=>{let e=new Map;return(f.id||``).trim()||e.set(`id`,s.modelIdRequired),f.contextWindow!==void 0&&f.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),f.maxTokens!==void 0&&f.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),f.computerUse&&!f.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑操作模型必须支持图片输入`:`Computer Use requires image input`),h(e),e.size===0},t[3]=f.computerUse,t[4]=f.contextWindow,t[5]=f.id,t[6]=f.input,t[7]=f.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=b):b=t[11];let x=b,S;t[12]!==f||t[13]!==o||t[14]!==a||t[15]!==x?(S=()=>{if(!x())return;let e=(f.id||``).trim();a({...f,id:e,name:f.name?.trim()||e,reasoning:f.reasoning||!1,input:f.input||[`text`],contextWindow:f.contextWindow??128e3,maxTokens:f.maxTokens??16384,cost:{input:f.cost?.input??0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}}),o()},t[12]=f,t[13]=o,t[14]=a,t[15]=x,t[16]=S):S=t[16];let w=S,T=f,E;t[17]===T?E=t[18]:(E=ht(T),t[17]=T,t[18]=E);let D=E,k=r?s.addModelTitle:s.editModelTitle,A;t[19]===k?A=t[20]:(A=(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:k}),t[19]=k,t[20]=A);let M;t[21]!==s.modelProviderLabel||t[22]!==i?(M=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]=M):M=t[23];let N;t[24]!==A||t[25]!==M?(N=(0,$.jsxs)(`div`,{children:[A,M]}),t[24]=A,t[25]=M,t[26]=N):N=t[26];let F;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(F=y(_t,`p-1.5 hover:bg-surface-base`),t[27]=F):F=t[27];let I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(v,{className:`size-4`}),t[28]=I):I=t[28];let L;t[29]===s.close?L=t[30]:(L=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:F,"aria-label":s.close,children:I})}),t[29]=s.close,t[30]=L);let R;t[31]!==N||t[32]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[N,L]}),t[31]=N,t[32]=L,t[33]=R):R=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=z):z=t[34];let B;t[35]===s.modelId?B=t[36]:(B=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,z]}),t[35]=s.modelId,t[36]=B);let V;t[37]===m?V=t[38]:(V=y($e(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=V);let H=f.id||``,U;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>_(`id`,e.target.value),t[39]=U):U=t[39];let W=!r,G;t[40]!==V||t[41]!==H||t[42]!==W?(G=(0,$.jsx)(`input`,{className:V,value:H,onChange:U,placeholder:`e.g. llama3.1:8b`,disabled:W}),t[40]=V,t[41]=H,t[42]=W,t[43]=G):G=t[43];let K;t[44]===m?K=t[45]:(K=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=K);let q;t[46]!==B||t[47]!==G||t[48]!==K?(q=(0,$.jsxs)(`div`,{children:[B,G,K]}),t[46]=B,t[47]=G,t[48]=K,t[49]=q):q=t[49];let ee;t[50]===s.displayName?ee=t[51]:(ee=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=ee);let te;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(te=$e(),t[52]=te):te=t[52];let J=f.name||``,ne;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>_(`name`,e.target.value),t[53]=ne):ne=t[53];let Y;t[54]===J?Y=t[55]:(Y=(0,$.jsx)(`input`,{className:te,value:J,onChange:ne}),t[54]=J,t[55]=Y);let re;t[56]!==ee||t[57]!==Y?(re=(0,$.jsxs)(`div`,{children:[ee,Y]}),t[56]=ee,t[57]=Y,t[58]=re):re=t[58];let ie;t[59]===s.inputTypes?ie=t[60]:(ie=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=ie);let ae;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(ae=We(),t[61]=ae):ae=t[61];let oe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>_(`input`,Qe(e.target.value)),t[62]=oe):oe=t[62];let X;t[63]===s?X=t[64]:(X=Ye.map(e=>(0,$.jsx)(d,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=X);let se;t[65]!==D||t[66]!==X?(se=(0,$.jsx)(u,{className:ae,value:D,onChange:oe,children:X}),t[65]=D,t[66]=X,t[67]=se):se=t[67];let ce;t[68]!==ie||t[69]!==se?(ce=(0,$.jsxs)(`div`,{children:[ie,se]}),t[68]=ie,t[69]=se,t[70]=ce):ce=t[70];let le=f.reasoning||!1,ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>_(`reasoning`,e.target.checked),t[71]=ue):ue=t[71];let de;t[72]===le?de=t[73]:(de=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[72]=le,t[73]=de);let fe;t[74]!==s.reasoning||t[75]!==de?(fe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,s.reasoning]}),t[74]=s.reasoning,t[75]=de,t[76]=fe):fe=t[76];let pe;t[77]!==ce||t[78]!==fe?(pe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,fe]}),t[77]=ce,t[78]=fe,t[79]=pe):pe=t[79];let me;t[80]===s.contextWindow?me=t[81]:(me=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=me);let he;t[82]===m?he=t[83]:(he=y($e(),m.has(`contextWindow`)&&`border-red-500`),t[82]=m,t[83]=he);let ge=f.contextWindow??128e3,_e;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>_(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=_e):_e=t[84];let ve;t[85]!==he||t[86]!==ge?(ve=(0,$.jsx)(`input`,{type:`number`,min:1,className:he,value:ge,onChange:_e}),t[85]=he,t[86]=ge,t[87]=ve):ve=t[87];let ye;t[88]===m?ye=t[89]:(ye=m.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`contextWindow`)}):null,t[88]=m,t[89]=ye);let be;t[90]!==me||t[91]!==ve||t[92]!==ye?(be=(0,$.jsxs)(`div`,{children:[me,ve,ye]}),t[90]=me,t[91]=ve,t[92]=ye,t[93]=be):be=t[93];let xe;t[94]===s.maxOutputTokens?xe=t[95]:(xe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=xe);let Se;t[96]===m?Se=t[97]:(Se=y($e(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=Se);let Ce=f.maxTokens??16384,we;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=we):we=t[98];let Te;t[99]!==Se||t[100]!==Ce?(Te=(0,$.jsx)(`input`,{type:`number`,min:1,className:Se,value:Ce,onChange:we}),t[99]=Se,t[100]=Ce,t[101]=Te):Te=t[101];let Ee;t[102]===m?Ee=t[103]:(Ee=m.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`maxTokens`)}):null,t[102]=m,t[103]=Ee);let De;t[104]!==xe||t[105]!==Te||t[106]!==Ee?(De=(0,$.jsxs)(`div`,{children:[xe,Te,Ee]}),t[104]=xe,t[105]=Te,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]!==be||t[109]!==De?(Oe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[be,De]}),t[108]=be,t[109]=De,t[110]=Oe):Oe=t[110];let ke;t[111]===s.costSection?ke=t[112]:(ke=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=ke);let Ae;t[113]===s.costInput?Ae=t[114]:(Ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ae);let je;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(je=$e(),t[115]=je):je=t[115];let Me=f.cost?.input??0,Ne;t[116]===f.cost?Ne=t[117]:(Ne=e=>_(`cost`,{...f.cost,input:parseFloat(e.target.value)||0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[116]=f.cost,t[117]=Ne);let Pe;t[118]!==Me||t[119]!==Ne?(Pe=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:je,value:Me,onChange:Ne}),t[118]=Me,t[119]=Ne,t[120]=Pe):Pe=t[120];let Fe;t[121]!==Ae||t[122]!==Pe?(Fe=(0,$.jsxs)(`div`,{children:[Ae,Pe]}),t[121]=Ae,t[122]=Pe,t[123]=Fe):Fe=t[123];let Ie;t[124]===s.costOutput?Ie=t[125]:(Ie=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=Ie);let Le;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Le=$e(),t[126]=Le):Le=t[126];let Re=f.cost?.output??0,ze;t[127]===f.cost?ze=t[128]:(ze=e=>_(`cost`,{...f.cost,input:f.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[127]=f.cost,t[128]=ze);let Be;t[129]!==Re||t[130]!==ze?(Be=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Le,value:Re,onChange:ze}),t[129]=Re,t[130]=ze,t[131]=Be):Be=t[131];let Ve;t[132]!==Ie||t[133]!==Be?(Ve=(0,$.jsxs)(`div`,{children:[Ie,Be]}),t[132]=Ie,t[133]=Be,t[134]=Ve):Ve=t[134];let He;t[135]!==Fe||t[136]!==Ve?(He=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Fe,Ve]}),t[135]=Fe,t[136]=Ve,t[137]=He):He=t[137];let Ue;t[138]!==ke||t[139]!==He?(Ue=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[ke,He]}),t[138]=ke,t[139]=He,t[140]=Ue):Ue=t[140];let Ge;t[141]!==q||t[142]!==re||t[143]!==pe||t[144]!==Oe||t[145]!==Ue?(Ge=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[q,re,pe,Oe,Ue]}),t[141]=q,t[142]=re,t[143]=pe,t[144]=Oe,t[145]=Ue,t[146]=Ge):Ge=t[146];let Ke=c?`高级:电脑操作协议`:`Advanced: Computer Use protocol`,qe;t[147]===Ke?qe=t[148]:(qe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ke}),t[147]=Ke,t[148]=qe);let Je=c?`电脑操作协议`:`Computer Use protocol`,Xe=f.computerUse?.profile??``,Ze;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=Ze):Ze=t[149];let et=c?`未声明`:`Not declared`,tt;t[150]===et?tt=t[151]:(tt=(0,$.jsx)(d,{value:``,children:et}),t[150]=et,t[151]=tt);let nt,rt;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,$.jsx)(d,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),rt=(0,$.jsx)(d,{value:`structured-tools-v1`,children:`structured-tools-v1`}),t[152]=nt,t[153]=rt):(nt=t[152],rt=t[153]);let it;t[154]!==Je||t[155]!==Xe||t[156]!==tt?(it=(0,$.jsxs)(u,{"aria-label":Je,value:Xe,onChange:Ze,children:[tt,nt,rt]}),t[154]=Je,t[155]=Xe,t[156]=tt,t[157]=it):it=t[157];let at=c?`仅适用于已适配的 OpenAI Chat Completions 视觉模型。声明协议不代表模型已通过效果验证。`:`For adapted OpenAI Chat Completions vision models only. Declaring a protocol does not certify model quality.`,ot;t[158]===at?ot=t[159]:(ot=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:at}),t[158]=at,t[159]=ot);let st;t[160]===m?st=t[161]:(st=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[160]=m,t[161]=st);let ct;t[162]!==it||t[163]!==ot||t[164]!==st?(ct=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[it,ot,st]}),t[162]=it,t[163]=ot,t[164]=st,t[165]=ct):ct=t[165];let lt;t[166]!==qe||t[167]!==ct?(lt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[qe,ct]}),t[166]=qe,t[167]=ct,t[168]=lt):lt=t[168];let ut;t[169]!==Ge||t[170]!==lt?(ut=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Ge,lt]}),t[169]=Ge,t[170]=lt,t[171]=ut):ut=t[171];let dt;t[172]===s.cancel?dt=t[173]:(dt=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(P,{type:`button`,variant:`secondary`,children:s.cancel})}),t[172]=s.cancel,t[173]=dt);let pt=r?s.addModelConfirm:s.saveModelConfirm,mt;t[174]!==w||t[175]!==pt?(mt=(0,$.jsx)(P,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:w,children:pt}),t[174]=w,t[175]=pt,t[176]=mt):mt=t[176];let gt;t[177]!==dt||t[178]!==mt?(gt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[dt,mt]}),t[177]=dt,t[178]=mt,t[179]=gt):gt=t[179];let vt;return t[180]!==R||t[181]!==ut||t[182]!==gt?(vt=(0,$.jsxs)($.Fragment,{children:[R,ut,gt]}),t[180]=R,t[181]=ut,t[182]=gt,t[183]=vt):vt=t[183],vt}function Fr(){return new Map}function Ir(e){return e.language}function Lr(e){let t=(0,Z.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)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,z)}),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`,R,`overflow-hidden rounded-xl border border-edge bg-surface-panel 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)(Pr,{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)(k,{children:[l,(0,$.jsx)(A,{className:u,onOpenAutoFocus:Rr,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(M,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function Rr(e){return e.preventDefault()}function zr(e){let t=(0,Z.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>xe(n).then(Br),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)(nt,{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 Br(e){return e.apiKey??null}function Vr(e){let t=(0,Z.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(E,{className:y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,z)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=y(`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-subtle bg-surface-base shadow-xl`,R),t[1]=p):p=t[1];let m;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==l||t[7]!==u||t[8]!==r||t[9]!==d||t[10]!==i?(m=(0,$.jsxs)(k,{children:[f,(0,$.jsx)(A,{className:p,children:a?(0,$.jsx)(Ur,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(Hr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=u,t[8]=r,t[9]=d,t[10]=i,t[11]=m):m=t[11];let h;return t[12]!==r||t[13]!==n||t[14]!==m?(h=(0,$.jsx)(M,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Hr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=Re[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(s?.apiKey??``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(!1),A=T(i).providersSettings,M=s?.supportsApiKey!==!1,N=s?.supportsOAuth===!0,F=s?.authMode===`oauth`&&s.authStatus===`connected`,I=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[L,R]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(null),[V,H]=(0,Q.useState)(`idle`),[G,K]=(0,Q.useState)(null),[J,ne]=(0,Q.useState)(null),[Y,ie]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(``),X=(0,Q.useRef)(null),se=(0,Q.useRef)(null),ce=V===`waiting`||V===`waiting_code`,le=(0,Q.useMemo)(()=>Be(e,i),[e,i]),ue=h!==(s?.apiKey??``),fe=async()=>{let t=h.trim();if(!(!t||!M||U(t))){x(!0),E(null);try{await me({[e]:t}),C(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){E(e instanceof Error?e.message:r.saveError)}finally{x(!1)}}};(0,Q.useEffect)(()=>{if(!L||!ce)return;let e=window.setInterval(()=>{(async()=>{try{let t=await vt(L);t.status===`waiting_auth`||t.status===`waiting_code`?(H(t.status===`waiting_code`?`waiting_code`:`waiting`),B(t.message??null),K(t.authUrl??null),ne(t.instructions??null),ie(t.deviceCode??null),t.authUrl&&t.authUrl!==se.current&&(se.current=t.authUrl,Fe(t.authUrl,X.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),W(X.current),X.current=null,H(`success`),B(t.message??A.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),W(X.current),X.current=null,H(`error`),B(t.error??t.message??A.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[L,ce,a,o,A.revokeFailed,A.saved]),(0,Q.useEffect)(()=>()=>{L&&q(L).catch(()=>{})},[L]),(0,Q.useEffect)(()=>()=>{W(X.current),X.current=null},[]);let pe=async()=>{try{await ye(e),o(),a()}catch{}},he=async()=>{W(X.current),X.current=re(),se.current=null,H(`waiting`),B(A.oauthStarting),K(null),ne(null),ie(null),E(null);try{R((await te(e)).sessionId)}catch(e){W(X.current),X.current=null,H(`error`),B(e instanceof Error?e.message:A.revokeFailed)}},ge=async()=>{if(L){try{await ke(L)}catch{}W(X.current),X.current=null,se.current=null,H(`idle`),B(null),R(null),K(null),ne(null),ie(null)}},_e=async()=>{if(!(!L||!ae.trim()))try{await ee(L,ae.trim()),oe(``),B(A.oauthProcessingCode)}catch(e){H(`error`),B(e instanceof Error?e.message:A.revokeFailed)}},ve=async()=>{try{await Me(e),o(),a()}catch(e){E(e instanceof Error?e.message:A.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)(j,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(O,{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`,je.press),children:(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[c?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.description}):null,s?.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:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,M?(0,$.jsx)(zr,{providerId:e,inputId:`manage-api-key`,value:h,onChange:e=>{_(e),C(!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}}):s?.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}),s?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(s.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)(m,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,N?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:A.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:F?A.sourceOauth:A.oauthHint})]}),F?(0,$.jsx)(P,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void ve(),children:A.revoke}):(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ce,onClick:()=>void he(),children:[ce?(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ze,{className:`size-3.5`,"aria-hidden":!0}),A.oauth]})]}),z?(0,$.jsx)(`p`,{className:y(`text-xs`,V===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:z}):null,V===`waiting`||V===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[G?(0,$.jsxs)(`a`,{href:G,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-white hover:bg-accent-hover`,children:[(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0}),A.openAuthPage]}):null,(0,$.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>void ge(),children:A.cancelOAuth})]}):null,J?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:J}):null,Y?(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:A.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:Y}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:A.deviceCodeHint})]}):null,V===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&void _e(),placeholder:A.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`,de)}),(0,$.jsx)(P,{type:`button`,variant:`primary`,onClick:()=>void _e(),children:A.submitCode})]}):null]}):null,le.length>0&&M?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:le.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:[Se(e,r),(0,$.jsx)(m,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.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,` (`,u.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:d,onChange:e=>f(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:u.filter(e=>!d||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:[mt(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[I?(0,$.jsxs)(P,{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:()=>k(!0),children:[(0,$.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:M&&ue&&!U(h.trim())?(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:!h.trim()||b||S,onClick:()=>void fe(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(et,{open:D,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void pe(),onCancel:()=>k(!1)})]})}function Ur({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=T(r).modelsSettings,s=t?.providers[e],[c,l]=(0,Q.useState)(s?.baseUrl??``),[u,d]=(0,Q.useState)(s?.apiKey??``),[f,p]=(0,Q.useState)(s?.models??[]),[m,h]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(null),[N,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),R=n=>{if(!t)return null;let r=u.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:U(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},z=async()=>{let e=R({models:f,modelDiscovery:{enabled:b}});if(e){C(!0),E(null);try{await Je(e),a(),i()}catch(e){E(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},B=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await Je({providers:r}),a(),i()}catch{}},V=(e,t)=>{L({model:e,isNew:t}),F(!0)},H=async e=>{if(!I)return;let t=I.isNew?[...f,e]:f.map(t=>t.id===e.id?e:t);p(t);let r=R({models:t});if(r)try{await Je(r),a()}catch(e){E(e instanceof Error?e.message:n.saveError)}},W=async e=>{let t=f.filter(t=>t.id!==e);p(t),M(null);let r=R({models:t});if(r)try{await Je(r),a()}catch(e){E(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)(j,{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)(O,{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`,je.press),children:(0,$.jsx)(v,{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:c,onChange:e=>l(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`,de)})]}),(0,$.jsx)(zr,{providerId:e,inputId:`manage-custom-api-key`,value:u,onChange:d,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:b,onChange:e=>x(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:[o.modelsSection,f.length>0?` (${f.length})`:``]}),(0,$.jsxs)(P,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>V(null,!0),children:[(0,$.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),o.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:m,onChange:e=>h(e.target.checked)}),r===`zh`?`仅电脑操作模型`:`Computer Use only`]}),f.filter(e=>!m||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:f.filter(e=>!m||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`,je.press),onClick:()=>V(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(se,{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`,je.press),onClick:()=>M(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(P,{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:()=>k(!0),children:[(0,$.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(P,{type:`button`,variant:`primary`,disabled:S,onClick:()=>void z(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(g,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(et,{open:D,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void B(),onCancel:()=>k(!1)}),(0,$.jsx)(et,{open:A!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,A??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{A&&W(A)},onCancel:()=>M(null)}),(0,$.jsx)(Lr,{open:N,onOpenChange:e=>{F(e),e||L(null)},providerId:e,model:I?.model??null,isNew:I?.isNew??!1,onSave:e=>void H(e),m:o})]})}function Wr(e,t){switch(e){case`computer-use`:return{href:`/settings/computer-use`,guidance:t?`选择兼容的电脑操作模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑操作`:`Configure computer use`};case`vision`:return{href:`${gt(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:gt(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:gt(`voice`),guidance:t?`选择语音识别服务,或安装本地语音模型`:`Choose a speech-to-text service or install a local voice model`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{href:gt(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function Gr(){let e=await S(w(`/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 Kr(){let e=await S(w(`/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 qr(){let e=C(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=N(fe,Gr,{revalidateOnFocus:!1}),{data:i}=N(ne,Kr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(L,{className:`h-24 w-full rounded-2xl`});let u=Object.values(t?.sources??{}),d=u.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),f=(t?.references??[]).filter(e=>e.availability===`unavailable`),m=t?.sync.lastSuccessAt??Math.max(0,...u.map(e=>e.lastSuccessAt)),h=s??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),_=Object.entries(i?.capabilities??{}).some(([e,t])=>(t.status===`degraded`||t.status===`unavailable`)&&(e!==`computer-use`||B()&&!!t.rejected?.length)),v=async()=>{o(!0),c(null);try{let e=await S(w(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await Ee()}catch(t){c(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{o(!1)}};return(0,$.jsxs)(`div`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h||f.length>0||_?(0,$.jsx)(Ue,{className:`size-4 text-amber-500`,"aria-hidden":!0}):(0,$.jsx)(p,{className:`size-4 text-emerald-500`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e?`模型目录同步`:`Model catalog sync`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e?`${u.length} 个来源,${d} 个可用模型${m?` · 最近同步 ${new Date(m).toLocaleString()}`:``}`:`${u.length} sources, ${d} available models${m?` · Last synced ${new Date(m).toLocaleString()}`:``}`})]}),(0,$.jsxs)(P,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,$.jsx)(g,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`立即刷新`:`Refresh now`]})]}),i?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:Object.entries(i.capabilities).map(([t,n])=>{if(t===`computer-use`&&!B())return null;let r=t===`vision`?e?`图片理解`:`Vision`:t===`image-generation`?e?`图片生成`:`Image generation`:t===`computer-use`?e?`电脑操作模型`:`Computer use model`:t.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=t===`computer-use`&&!n.primary&&!n.rejected?.length,o=!a&&(n.status===`degraded`||n.status===`unavailable`),s=Wr(t,e),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:n.status===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:n.status===`disabled`||a?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a?e?`未选择`:`Not selected`:n.status===`ready`?t===`computer-use`?e?`已配置`:`Configured`:e?`可用`:`Ready`:n.status===`disabled`?e?`已关闭`:`Off`:e?`需处理`:`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?e?`自动`:`Auto`:e?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a?e?`不继承聊天模型`:`Does not inherit chat model`:e?`无可用实现`:`No available implementation`}),o?(0,$.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?e?`当前配置不可用,正在使用备用方案。${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)(we,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return o||t===`computer-use`?(0,$.jsx)(l,{to:s.href,"aria-label":`${r}:${s.action}`,className:y(`rounded-xl border px-3 py-2 transition-colors`,o?`border-amber-400/40 bg-amber-500/5 hover:border-amber-400/70`:`border-edge-subtle bg-surface-panel hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:c},t):(0,$.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-2`,children:c},t)})}):null,f.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:f.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,h?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:h}):null]})}async function Jr(){return(await b(w(`/api/models/xopc-cloud/account-summary`))).payload}function Yr(e){let t=(0,Z.c)(93),{labels:n}=e,r=C(Xr)===`zh`?`zh-CN`:`en-US`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:6e4,revalidateOnFocus:!0},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,isValidating:c,mutate:l}=N(`/api/models/xopc-cloud/account-summary`,Jr,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(L,{className:`h-48 w-full rounded-2xl`}),t[1]=e):e=t[1],e}if(o||!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ue,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),t[2]=e):e=t[2];let r;t[3]===n.title?r=t[4]:(r=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=r);let i;t[5]===n.unavailable?i=t[6]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.unavailable}),t[5]=n.unavailable,t[6]=i);let a;t[7]!==r||t[8]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[e,(0,$.jsxs)(`div`,{children:[r,i]})]}),t[7]=r,t[8]=i,t[9]=a):a=t[9];let o;t[10]===l?o=t[11]:(o=()=>void l(),t[10]=l,t[11]=o);let s=c?`size-4 animate-spin`:`size-4`,u;t[12]===s?u=t[13]:(u=(0,$.jsx)(ae,{className:s,"aria-hidden":!0}),t[12]=s,t[13]=u);let d;t[14]!==c||t[15]!==n.retry||t[16]!==o||t[17]!==u?(d=(0,$.jsxs)(P,{type:`button`,variant:`secondary`,disabled:c,onClick:o,children:[u,n.retry]}),t[14]=c,t[15]=n.retry,t[16]=o,t[17]=u,t[18]=d):d=t[18];let f;return t[19]!==a||t[20]!==d?(f=(0,$.jsx)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[a,d]})}),t[19]=a,t[20]=d,t[21]=f):f=t[21],f}let u,d,f,p,h,g,_,v;if(t[22]!==a.balance.credits||t[23]!==a.usage.chargedCredits||t[24]!==a.usage.requests||t[25]!==a.usage.totalTokens||t[26]!==n.availableCredits||t[27]!==n.connected||t[28]!==n.title||t[29]!==n.usageSummary||t[30]!==r){let e=new Intl.NumberFormat(r);v=n.usageSummary.replace(`{{tokens}}`,e.format(a.usage.totalTokens)).replace(`{{credits}}`,e.format(a.usage.chargedCredits)).replace(`{{requests}}`,e.format(a.usage.requests)),_=`rounded-2xl border border-edge-subtle bg-surface-panel/40 p-5`,g=`flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between`,f=`min-w-0 flex-1`;let i;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(bt,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),t[39]=i):i=t[39];let o;t[40]===n.title?o=t[41]:(o=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[40]=n.title,t[41]=o);let s;t[42]===n.connected?s=t[43]:(s=(0,$.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n.connected}),t[42]=n.connected,t[43]=s),t[44]!==o||t[45]!==s?(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i,o,s]}),t[44]=o,t[45]=s,t[46]=p):p=t[46],t[47]===n.availableCredits?h=t[48]:(h=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.availableCredits}),t[47]=n.availableCredits,t[48]=h),u=`mt-1 text-3xl font-semibold tracking-tight text-fg`,d=e.format(a.balance.credits),t[22]=a.balance.credits,t[23]=a.usage.chargedCredits,t[24]=a.usage.requests,t[25]=a.usage.totalTokens,t[26]=n.availableCredits,t[27]=n.connected,t[28]=n.title,t[29]=n.usageSummary,t[30]=r,t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=h,t[36]=g,t[37]=_,t[38]=v}else u=t[31],d=t[32],f=t[33],p=t[34],h=t[35],g=t[36],_=t[37],v=t[38];let y;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[49]=y):y=t[49];let b;t[50]!==u||t[51]!==d?(b=(0,$.jsxs)(`p`,{className:u,children:[d,y]}),t[50]=u,t[51]=d,t[52]=b):b=t[52];let x;t[53]!==a.balance.credits||t[54]!==n.zeroBalance?(x=a.balance.credits===0?(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium text-danger`,children:n.zeroBalance}):null,t[53]=a.balance.credits,t[54]=n.zeroBalance,t[55]=x):x=t[55];let S;t[56]===n.recentUsage?S=t[57]:(S=(0,$.jsx)(`p`,{className:`mt-5 text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[56]=n.recentUsage,t[57]=S);let w;t[58]===v?w=t[59]:(w=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v}),t[58]=v,t[59]=w);let T;t[60]!==a.balance.updatedAt||t[61]!==n.updatedAt||t[62]!==r?(T=n.updatedAt.replace(`{{time}}`,new Date(a.balance.updatedAt).toLocaleString(r)),t[60]=a.balance.updatedAt,t[61]=n.updatedAt,t[62]=r,t[63]=T):T=t[63];let E;t[64]===T?E=t[65]:(E=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:T}),t[64]=T,t[65]=E);let D;t[66]!==b||t[67]!==x||t[68]!==S||t[69]!==w||t[70]!==E||t[71]!==f||t[72]!==p||t[73]!==h?(D=(0,$.jsxs)(`div`,{className:f,children:[p,h,b,x,S,w,E]}),t[66]=b,t[67]=x,t[68]=S,t[69]=w,t[70]=E,t[71]=f,t[72]=p,t[73]=h,t[74]=D):D=t[74];let O;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[75]=O):O=t[75];let k;t[76]!==a.links.purchase||t[77]!==n.purchase?(k=(0,$.jsx)(P,{asChild:!0,variant:`primary`,children:(0,$.jsxs)(`a`,{href:a.links.purchase,target:`_blank`,rel:`noreferrer`,children:[n.purchase,O]})}),t[76]=a.links.purchase,t[77]=n.purchase,t[78]=k):k=t[78];let A;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[79]=A):A=t[79];let j;t[80]!==a.links.details||t[81]!==n.details?(j=(0,$.jsx)(P,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,A]})}),t[80]=a.links.details,t[81]=n.details,t[82]=j):j=t[82];let M;t[83]!==k||t[84]!==j?(M=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[k,j]}),t[83]=k,t[84]=j,t[85]=M):M=t[85];let F;t[86]!==D||t[87]!==M||t[88]!==g?(F=(0,$.jsxs)(`div`,{className:g,children:[D,M]}),t[86]=D,t[87]=M,t[88]=g,t[89]=F):F=t[89];let I;return t[90]!==F||t[91]!==_?(I=(0,$.jsx)(`section`,{className:_,children:F}),t[90]=F,t[91]=_,t[92]=I):I=t[92],I}function Xr(e){return e.language}function Zr(e){return K.includes(e)}function Qr(){let e=(0,Z.c)(69),t=C(ti),n;e[0]===t?n=e[1]:(n=T(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesSettings,u=a(),[d,f]=o(),p;if(e[2]!==d){let t=d.get(`returnTo`);p=t?.startsWith(`/chat/`)?t:null,e[2]=d,e[3]=p}else p=e[3];let m=p,{capability:h}=s(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=Cr(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some(ei),e[4]=b.cards,e[5]=x);let S=x,w,E;e[6]!==h||e[7]!==d||e[8]!==f?(w=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;_(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},E=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=w,e[10]=E):(w=e[9],E=e[10]),(0,Q.useEffect)(w,E);let D;e[11]===i.tabs.models?D=e[12]:(D={id:`models`,icon:Ne,label:i.tabs.models},e[11]=i.tabs.models,e[12]=D);let O;e[13]===i.tabs.image?O=e[14]:(O={id:`image`,icon:Te,label:i.tabs.image},e[13]=i.tabs.image,e[14]=O);let k;e[15]!==D||e[16]!==O?(k=[D,O],e[15]=D,e[16]=O,e[17]=k):k=e[17];let A=k,j;e[18]===u?j=e[19]:(j=e=>u(gt(e)),e[18]=u,e[19]=j);let M=j,N=$r;if(!Zr(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:gt(`models`),replace:!0}),e[20]=t):t=e[20],t}let P=h===`models`||h===`image`,F=h===`voice`?r.nav.settingsVoice:h===`search`?r.nav.settingsSearch:r.nav.settingsModels,I;e[21]===t?I=e[22]:(I=Ae(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(xt,{title:F,docsLink:I,docsLabel:i.docsLink}),e[23]=i.docsLink,e[24]=F,e[25]=I,e[26]=L):L=e[26];let R;e[27]!==h||e[28]!==m||e[29]!==t?(R=h===`voice`&&m?(0,$.jsx)(l,{to:m,className:`text-sm text-accent-fg hover:underline`,children:t===`zh`?`返回对话`:`Return to conversation`}):null,e[27]=h,e[28]=m,e[29]=t,e[30]=R):R=e[30];let z;e[31]!==i.tabsAria||e[32]!==h||e[33]!==P||e[34]!==A||e[35]!==M?(z=P?(0,$.jsx)(Ht,{items:A,activeTab:h,onChange:M,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=A,e[35]=M,e[36]=z):z=e[36];let B=P?`tabpanel`:void 0,V=`capability-panel-${h}`,H=P?`capability-tab-${h}`:void 0,U;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==t||e[41]!==b||e[42]!==S?(U=h===`models`?(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(Yr,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(qr,{}),(0,$.jsx)(Xt,{zh:t===`zh`}),(0,$.jsx)(Ar,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})})]}):(0,$.jsx)(ni,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=t,e[41]=b,e[42]=S,e[43]=U):U=e[43];let W;e[44]!==B||e[45]!==V||e[46]!==H||e[47]!==U?(W=(0,$.jsx)(`div`,{role:B,id:V,"aria-labelledby":H,className:`flex min-w-0 flex-col gap-3 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:U}),e[44]=B,e[45]=V,e[46]=H,e[47]=U,e[48]=W):W=e[48];let G;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(G=(0,$.jsx)(pr,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:N}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=G):G=e[54];let K;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(K=v?(0,$.jsx)(Vr,{open:!0,onOpenChange:e=>{e||y(null)},providerId:v.providerId,isCustom:v.isCustom,builtinRows:b.builtinRows,customConfig:b.customConfig,allModels:b.allModels,labels:i.manageProviderDialog,language:t,onSaved:N}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=v,e[58]=b.allModels,e[59]=b.builtinRows,e[60]=b.customConfig,e[61]=K):K=e[61];let q;return e[62]!==L||e[63]!==R||e[64]!==z||e[65]!==W||e[66]!==G||e[67]!==K?(q=(0,$.jsxs)(St,{children:[L,R,z,W,G,K]}),e[62]=L,e[63]=R,e[64]=z,e[65]=W,e[66]=G,e[67]=K,e[68]=q):q=e[68],q}function $r(){Ee()}function ei(e){return e.id===`xopc-cloud`&&!e.isCustom}function ti(e){return e.language}function ni(e){let t=(0,Z.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pn,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(sr,{}),t[2]=e):e=t[2],e}}}export{Qr as CapabilitiesSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as i}from"./messages-BYbx4OuI.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{t as o}from"./button-CGlRPNzi.js";import{t as s}from"./skeleton-BwbyijEw.js";import{n as c,t as l}from"./registry-api-BDgFNu05.js";import{_i as u,dn as d,un as f}from"./index-54o0AGdj.js";var p=e(t(),1),m=n();function h({zh:e}){let t=i(e?`zh`:`en`).computerSettings,n=a(`settings-agent-defaults`,f),h=a(l,c),g=n.data?.defaults.models.computerUse?.primary??``,[_,v]=(0,p.useState)(g),[y,b]=(0,p.useState)(!1),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)(!1);(0,p.useEffect)(()=>{v(g)},[g]);let T=!_||h.data?.some(e=>e.id===_&&e.computerUse),E=async()=>{b(!0),S(``),w(!1);try{if(!T)throw Error(t.modelUnavailable);let e=await f(),r={...e.defaults.models};_?r.computerUse={primary:_,fallbacks:[]}:delete r.computerUse;let i=await d({...e.defaults,models:r});await n.mutate(i,!1),w(!0)}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}};return(0,m.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,m.jsx)(s,{className:`h-52 w-full rounded-xl`}):n.error?(0,m.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,m.jsx)(o,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,m.jsxs)(`div`,{className:`space-y-4 rounded-xl border border-edge p-4 sm:p-5`,children:[(0,m.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.modelDescription}),(0,m.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelScope}),h.isLoading?(0,m.jsx)(s,{className:`h-10 w-full rounded-lg`}):(0,m.jsx)(u,{value:_,onChange:e=>{v(e),w(!1)},disabled:y,capabilitiesFilter:`computer-use`,models:h.data??[],modelsError:h.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`}),!T&&!h.isLoading&&!h.error&&(0,m.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:t.modelUnavailable}),h.error&&(0,m.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[String(h.error),(0,m.jsx)(o,{onClick:()=>{h.mutate().catch(()=>{})},children:t.retry})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(o,{variant:`primary`,disabled:y||_===g||!T||!!h.error||h.isLoading,onClick:()=>{E()},children:t.saveModel}),(0,m.jsx)(o,{asChild:!0,variant:`ghost`,children:(0,m.jsx)(r,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),C&&(0,m.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:t.modelSaved})]}),x&&(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:x})]}),(0,m.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelPrivacy})]})}export{h as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./globe-DSSGFWFn.js";import{a as o,n as s,r as c}from"./locale-store-DuG-kbsP.js";import{t as l}from"./messages-BYbx4OuI.js";import{t as u}from"./button-CGlRPNzi.js";import{r as d}from"./gateway-config-swr-COJzzscc.js";import{t as f}from"./skeleton-BwbyijEw.js";import{Tc as p,al as m,gc as h,ol as g}from"./index-54o0AGdj.js";import{n as _,r as v}from"./settings-page-layout-CsUQKRq0.js";import{t as y}from"./computer-model-settings-BOObauzH.js";var b=n(),x=e(t(),1),S=r();function C(e){let t=(0,b.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,S.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl border border-edge bg-surface-base text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,S.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,S.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,S.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 p-4 sm:flex-nowrap sm:p-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function w(){let e=(0,b.c)(2),t=s(T)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,S.jsx)(E,{zh:t}),e[0]=t,e[1]=n),n}function T(e){return e.language}function E({zh:e}){let t=l(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:s}=d(!0),b=n?.payload?.config,[w,T]=(0,x.useState)(!1),[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(!1),P=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,F=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,x.useEffect)(()=>{if(!P)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await P.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[P]);let I=async e=>{T(!0),D(``);try{await e()}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(!1)}},L=e=>I(async()=>{await o(c(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r()}),R=async()=>{D(``),k(!1);try{await P?.stop(),k(!0),P&&j(await P.status())}catch(e){D(e instanceof Error?e.message:String(e))}},z=A?.session?.status??`idle`,B=t.states[z]??z;return(0,S.jsxs)(v,{gap:`gap-7`,children:[(0,S.jsx)(_,{title:t.title,subtitle:t.subtitle,meta:(0,S.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,S.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.experimental}),(0,S.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview})]}),(0,S.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:t.experimentalDescription})]}),actions:P&&(0,S.jsxs)(u,{onClick:()=>{R()},children:[(0,S.jsx)(h,{className:`size-3.5`}),t.stop]})}),E&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:E}),O&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),A?.controlPaused&&(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge p-4`,children:[(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.pausedNotice}),(0,S.jsx)(u,{disabled:w,onClick:()=>{I(async()=>{P&&j(await P.resume()),k(!1)})},children:t.resume})]}),(0,S.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,S.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!b&&!s?(0,S.jsx)(f,{className:`h-40 w-full rounded-xl`}):s?(0,S.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(s),` `,(0,S.jsx)(u,{onClick:()=>{I(()=>r())},children:t.retry})]}):(0,S.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge`,children:[(0,S.jsx)(C,{icon:(0,S.jsx)(m,{className:`size-5`}),title:t.desktop,description:t.desktopDescription,children:(0,S.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":b?.computer?.enabled===!0,disabled:w,onClick:()=>{L(b?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,S.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${b?.computer?.enabled?`bg-accent`:`bg-fg-muted/30`}`,children:(0,S.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${b?.computer?.enabled?`translate-x-5`:`translate-x-0`}`})})})}),(0,S.jsx)(C,{icon:(0,S.jsx)(p,{className:`size-5`}),title:t.fullControl,description:(0,S.jsxs)(S.Fragment,{children:[t.fullControlDescription,(0,S.jsx)(`span`,{className:`mt-1 block text-xs`,children:P?A?.fullControl?t.fullControlEnabled:t.fullControlDisabled:t.fullControlLocalOnly})]}),children:(0,S.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.fullControl,"aria-checked":A?.fullControl===!0,disabled:w||!P||!A||M,onClick:()=>{I(async()=>{P&&j(await P.setFullControl(A?.fullControl!==!0))})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,S.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${A?.fullControl?`bg-accent`:`bg-fg-muted/30`}`,children:(0,S.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${A?.fullControl?`translate-x-5`:`translate-x-0`}`})})})}),(0,S.jsx)(C,{icon:(0,S.jsx)(a,{className:`size-5`}),title:t.browser,description:(0,S.jsxs)(S.Fragment,{children:[t.browserDescription,(0,S.jsx)(`span`,{className:`mt-1 block text-xs`,children:b?.browser?.enabled?t.browserEnabled:t.browserDisabled})]}),children:(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})]}),(0,S.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[t.safety,` `,t.lockedDescription]})]}),(0,S.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,S.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),P?M?(0,S.jsx)(`p`,{role:`alert`,className:`rounded-xl border border-edge p-5 text-sm text-fg-muted`,children:t.nativeError}):A?(0,S.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge`,children:[(0,S.jsx)(C,{icon:(0,S.jsx)(g,{className:`size-5`}),title:t.device,description:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,B]}),A.reenrollmentRequired&&(0,S.jsx)(`p`,{className:`mt-1`,children:t.revoked})]}),children:A.reenrollmentRequired&&(0,S.jsx)(u,{disabled:w,onClick:()=>{I(async()=>{j(await P.reenroll())})},children:t.reenroll})}),F&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(C,{icon:(0,S.jsx)(p,{className:`size-5`}),title:t.accessibility,description:t.accessibilityDescription,children:[(0,S.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,S.jsx)(u,{disabled:w,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{I(()=>F.requestAccessibility())},children:t.openSettings})]}),(0,S.jsxs)(C,{icon:(0,S.jsx)(g,{className:`size-5`}),title:t.screen,description:t.screenDescription,children:[(0,S.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,S.jsx)(u,{disabled:w,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{I(()=>F.requestScreen())},children:t.openSettings})]})]})]}):(0,S.jsx)(`div`,{"aria-label":t.checking,children:(0,S.jsx)(f,{className:`h-52 w-full rounded-xl`})}):(0,S.jsx)(`p`,{className:`rounded-xl border border-edge p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,S.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]}),(0,S.jsx)(y,{zh:e})]})}export{w as ComputerSettingsPage,E as ComputerSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as a,r as o}from"./popover-select-DldSX8GX.js";import{t as s}from"./external-link-DjqjBmc3.js";import{t as c}from"./cn-JdwAhgNB.js";import{n as l}from"./locale-store-DuG-kbsP.js";import{t as u}from"./messages-BYbx4OuI.js";import{t as d}from"./skeleton-BwbyijEw.js";import{n as f}from"./electron-env-Dit0bHgy.js";import{Fc as p,Ic as m,Mu as h,Ts as g,Yc as _,Zs as v,ul as y}from"./index-54o0AGdj.js";import{t as b}from"./desktop-pet-sprite-DTqXSpqf.js";import{n as x,r as S}from"./settings-page-layout-CsUQKRq0.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=u(l(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!f()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(d,{className:`h-14 rounded-xl`}),(0,T.jsx)(d,{className:`h-14 rounded-xl`}),(0,T.jsx)(d,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(d,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),G=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,g.press),disabled:C,onClick:()=>void M(),children:[(0,T.jsx)(m,{className:c(`size-3.5`,C&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(v,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,g.press),onClick:B,children:[(0,T.jsx)(y,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.bondTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondDesc})]}),(0,T.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:e.bondSummary.replace(`{days}`,String(W)).replace(`{tasks}`,String(n.relationship.completedTaskCount))})]}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>V(t),children:[(0,T.jsx)(_,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:c(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,g.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(h,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,g.press),onClick:()=>H(t),children:[(0,T.jsx)(y,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void G(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&G()},onPointerUp:()=>void G()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})}),(0,T.jsx)(E,{title:e.proactiveTips,desc:e.proactiveTipsDesc,checked:n.prefs.proactiveTipsEnabled,disabled:C,onChange:e=>void N({proactiveTipsEnabled:e})}),(0,T.jsx)(E,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:C,onChange:e=>void N({interactionEnabled:e})}),(0,T.jsx)(E,{title:e.reducedMotion,desc:e.reducedMotionDesc,checked:n.prefs.reducedMotion,disabled:C,onChange:e=>void N({reducedMotion:e})}),(0,T.jsx)(E,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:C,onChange:e=>void N({clickThroughWhenIdle:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.behaviorModeDesc})]}),(0,T.jsxs)(a,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,onChange:e=>void N({behaviorMode:e.target.value}),children:[(0,T.jsx)(o,{value:`focus`,children:e.behaviorFocus}),(0,T.jsx)(o,{value:`companion`,children:e.behaviorCompanion}),(0,T.jsx)(o,{value:`playful`,children:e.behaviorPlayful})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:c(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,g.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(p,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{d as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-JdwAhgNB.js";import{n as d}from"./locale-store-DuG-kbsP.js";import{t as f}from"./messages-BYbx4OuI.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{n as y}from"./app-link-BiBXVEvp.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CGlRPNzi.js";import{t as S}from"./skeleton-BwbyijEw.js";import{i as ee,o as te}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{B as C,Ct as w,Et as T,H as E,Ml as D,Qc as O,Ui as k,V as A,wt as j,xc as M,xo as N}from"./index-54o0AGdj.js";import{_ as P,a as F,b as I,d as L,f as R,g as z,i as B,l as V,m as H,n as U,p as ne,r as W,s as G,t as K,u as re,y as ie}from"./tunnel-api-GLzwLaUZ.js";import{t as q}from"./browser-BLJWD7WI.js";var J=e(n(),1),Y=r(),ae=e(q(),1),X={width:216,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function oe(e){let t=await ae.toString(e,{...X,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var Z=i();function se(){let e=f(d(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=b(`tunnel-status`,U,{refreshInterval:1500}),[o,s]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[p,m]=(0,J.useState)(!0),[h,g]=(0,J.useState)(`idle`),[_,v]=(0,J.useState)(null),[ee,te]=(0,J.useState)(``),D=(0,J.useRef)(!0);(0,J.useEffect)(()=>(D.current=!0,()=>{D.current=!1}),[]);let O=async()=>{if(!r)return;if(r.consentRequired&&!o){u(!0);return}let e=r.registrationSecret?.configured?null:E(),t,n=!1;v(null);try{if(r.consentRequired&&await F(),!r.registrationSecret?.configured){g(`provisioning`);let r=!1;try{await B()}catch(e){if(!re(e))throw e;r=!0}if(r){g(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await T(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;D.current&&Date.now()<o;){let r=await j(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await A(a,e)||te(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!D.current)return;if(!s)throw Error(`Authorization expired`);await B()}await a()}if(!D.current)return;g(`starting`),await G(),p&&await W({autoStart:!0}),await a(),n=!0}catch(e){n=!0,D.current&&v(V(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{C(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&w(t).catch(()=>{})),D.current&&(g(`idle`),te(``))}};if(!r&&!i)return(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsx)(S,{className:`h-5 w-4/5`}),(0,Z.jsx)(S,{className:`h-24 w-full`})]});let k=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,Z.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:k?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),ee&&h===`authorizing`?(0,Z.jsx)(`a`,{href:ee,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,k?(0,Z.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,Z.jsx)(S,{className:`h-2 w-full`}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(l||r?.consentRequired)&&h===`idle`?(0,Z.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,Z.jsxs)(`details`,{open:l,className:`text-sm text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,Z.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,Z.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,Z.jsx)(`li`,{children:e},e))})]}),(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,_===`key-limit`?(0,Z.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,Z.jsxs)(x,{variant:`secondary`,className:`mt-3`,onClick:()=>void y(K),children:[t.manageTunnelKeys,(0,Z.jsx)(c,{className:`size-3`})]})]}):_||i||r?.state===`error`?(0,Z.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,Z.jsx)(x,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||k||l&&!o,onClick:()=>void O(),children:h===`authorizing`?t.authorizing:k?t.preparing:_?t.retry:t.enable}),i&&!r?(0,Z.jsx)(x,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var Q=t({DevicePairingWizard:()=>ce});function ce(e){let t=(0,Y.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,J.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,J.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,Z.jsx)(ue,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,Z.jsx)($,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,Z.jsx)(v,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function $(e){let t=(0,Y.c)(55),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=d(le),o;t[0]===a?o=t[1]:(o=f(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(p,{className:u(`fixed inset-0 bg-scrim backdrop-blur-[1px]`,te)}),t[2]=c):c=t[2];let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=u(`fixed left-1/2 top-1/2 flex h-[min(460px,calc(100dvh-48px))] w-[min(520px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover`,ee),t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=y):y=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(l,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[y,(0,Z.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let S;t[9]===s.chooseTitle?S=t[10]:(S=(0,Z.jsx)(_,{className:`text-xl font-semibold tracking-tight text-fg`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=S);let C;t[11]===s.chooseHint?C=t[12]:(C=(0,Z.jsx)(m,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=C);let w;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(D,{className:`size-5 text-accent`}),t[13]=w):w=t[13];let T;t[14]===s.localBrowserTitle?T=t[15]:(T=(0,Z.jsx)(`span`,{className:`mt-4 block text-sm font-semibold text-fg`,children:s.localBrowserTitle}),t[14]=s.localBrowserTitle,t[15]=T);let E;t[16]===s.localBrowserHint?E=t[17]:(E=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:s.localBrowserHint}),t[16]=s.localBrowserHint,t[17]=E);let k;t[18]!==r||t[19]!==T||t[20]!==E?(k=(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge bg-surface-base p-5 text-left hover:border-edge-strong hover:bg-surface-hover`,onClick:r,children:[w,T,E]}),t[18]=r,t[19]=T,t[20]=E,t[21]=k):k=t[21];let A;t[22]===n?A=t[23]:(A=()=>n(`mobile`),t[22]=n,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(M,{className:`size-5 text-accent`}),t[24]=j):j=t[24];let N;t[25]===s.mobileTitle?N=t[26]:(N=(0,Z.jsx)(`span`,{className:`mt-4 block text-sm font-semibold text-fg`,children:s.mobileTitle}),t[25]=s.mobileTitle,t[26]=N);let P;t[27]===s.mobileHint?P=t[28]:(P=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:s.mobileHint}),t[27]=s.mobileHint,t[28]=P);let F;t[29]!==A||t[30]!==N||t[31]!==P?(F=(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge bg-surface-base p-5 text-left hover:border-edge-strong hover:bg-surface-hover`,onClick:A,children:[j,N,P]}),t[29]=A,t[30]=N,t[31]=P,t[32]=F):F=t[32];let I;t[33]===n?I=t[34]:(I=()=>n(`browser`),t[33]=n,t[34]=I);let L;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(O,{className:`size-5 text-accent`}),t[35]=L):L=t[35];let R;t[36]===s.remoteBrowserTitle?R=t[37]:(R=(0,Z.jsx)(`span`,{className:`mt-4 block text-sm font-semibold text-fg`,children:s.remoteBrowserTitle}),t[36]=s.remoteBrowserTitle,t[37]=R);let z;t[38]===s.remoteBrowserHint?z=t[39]:(z=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:s.remoteBrowserHint}),t[38]=s.remoteBrowserHint,t[39]=z);let B;t[40]!==I||t[41]!==R||t[42]!==z?(B=(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge bg-surface-base p-5 text-left hover:border-edge-strong hover:bg-surface-hover`,onClick:I,children:[L,R,z]}),t[40]=I,t[41]=R,t[42]=z,t[43]=B):B=t[43];let V;t[44]!==k||t[45]!==F||t[46]!==B?(V=(0,Z.jsxs)(`div`,{className:`mt-7 grid gap-3 sm:grid-cols-3`,children:[k,F,B]}),t[44]=k,t[45]=F,t[46]=B,t[47]=V):V=t[47];let H;t[48]!==V||t[49]!==S||t[50]!==C?(H=(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-8 py-7`,children:[S,C,V]}),t[48]=V,t[49]=S,t[50]=C,t[51]=H):H=t[51];let U;return t[52]!==H||t[53]!==x?(U=(0,Z.jsxs)(h,{children:[c,(0,Z.jsxs)(g,{className:v,children:[x,H]})]}),t[52]=H,t[53]=x,t[54]=U):U=t[54],U}function le(e){return e.language}function ue({targetKind:e,onClose:t,onPaired:n}){let r=d(e=>e.language),i=f(r),a=i.endpointToolsSettings.deviceAccess,v=a.flow,[C,w]=(0,J.useState)(!1),T=b(C?`device-pairing-readiness`:null,z,{refreshInterval:1500}),[E,D]=(0,J.useState)(),[O,A]=(0,J.useState)(null),[j,M]=(0,J.useState)(!1),[F,B]=(0,J.useState)(Date.now()),[V,U]=(0,J.useState)(null),W=(0,J.useRef)(!0),G=(0,J.useRef)(null),K=(0,J.useRef)(!1),re=(0,J.useRef)(!1),q=b(E?[`device-pairing-setup`,E.id]:null,()=>P(E.id),{refreshInterval:1500}),Y=q.data?.request,ae=Y?.status===`completed`,X=ae&&Y.connectedAt!==void 0,Q=b(X&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),ce=E?.targetKind===`mobile`?E.universalLink:``,$=N(()=>oe(ce),[ce],{enabled:!!ce,initial:null,errorData:null}),le=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,ue=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,de=N(()=>oe(le),[le],{enabled:!C&&e===`mobile`,initial:null,errorData:null});(0,J.useEffect)(()=>{W.current=!0;let e=setInterval(()=>B(Date.now()),1e3);return()=>{W.current=!1,clearInterval(e),G.current&&L(G.current).catch(()=>{})}},[]);let fe=(0,J.useCallback)(async()=>{if(!K.current){K.current=!0,M(!0),A(null);try{G.current&&await L(G.current),G.current=null,D(void 0);let t=await R(e);if(t.kind===`ready`){if(!W.current){await L(t.setup.id);return}G.current=t.setup.id,D(t.setup)}else await T.mutate()}catch{W.current&&A(`create`)}finally{K.current=!1,W.current&&M(!1)}}},[T,e]);(0,J.useEffect)(()=>{T.data?.ready&&!E&&O!==`create`&&!K.current&&fe()},[T.data,E,O,fe]),(0,J.useEffect)(()=>{X&&!re.current&&(re.current=!0,n?.())},[X,n]);let pe=async e=>{if(Y){M(!0),A(null);try{await ne(Y,e),await q.mutate()}catch{A(`decision`),await q.mutate()}finally{W.current&&M(!1)}}},me=(0,J.useRef)(0);(0,J.useEffect)(()=>{q.data&&(me.current=q.data.serverTime-Date.now())},[q.data]);let he=F+me.current,ge=E&&he>=E.expiresAt&&!Y,_e=Y&&[`expired`,`rejected`,`cancelled`].includes(Y.status),ve=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},ye=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,be=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,xe=C?X?ve.success:Y?.status===`pending`?ve.allowTitle:ae||Y?.status===`approved`?v.waiting:E?ve.connect:v.title:ye,Se=O===`create`?v.createFailed:O===`decision`?v.decisionFailed:O===`background`?v.backgroundFailed:O===`download`?a.browserDownloadFailed:null,Ce=async()=>{M(!0),A(null);try{await H()}catch{A(`download`)}finally{W.current&&M(!1)}};return(0,Z.jsxs)(h,{children:[(0,Z.jsx)(p,{className:u(`fixed inset-0 bg-scrim backdrop-blur-[1px]`,te)}),(0,Z.jsxs)(g,{className:u(`fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover`,ee),children:[(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,Z.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,Z.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":v.cancel,onClick:t,children:(0,Z.jsx)(l,{className:`size-4`})})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[X?(0,Z.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,Z.jsx)(_,{className:`text-xl font-semibold tracking-tight text-fg`,children:xe}),(0,Z.jsx)(m,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:C?X?ve.successHint:ae?v.waitingForDevice:Y?Y.displayName:E?ve.connectHint:v.intro:be}),Se?(0,Z.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Se}):null,C&&T.error?(0,Z.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:v.readinessFailed}):null,C&&q.error?(0,Z.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:v.statusUnavailable}):null,C?T.data?X?(0,Z.jsxs)(Z.Fragment,{children:[Q.data?(0,Z.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,Z.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":Q.data.runInBackground??!1,disabled:!Q.data.backgroundSupported,checked:Q.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>Q.mutate(e.behavior)).catch(()=>A(`background`))}})]}):null,(0,Z.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):_e||ge?(0,Z.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ge||Y?.status===`expired`?v.expired:v.declined}),(0,Z.jsx)(x,{variant:`primary`,onClick:()=>void fe(),disabled:j,children:v.refresh})]}):Y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:v.scope}),(0,Z.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[Y.confirmationCode.slice(0,3),` `,Y.confirmationCode.slice(3)]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:v.compare}),(0,Z.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-2`,children:v.access}),(0,Z.jsx)(`p`,{children:v.accessHint})]})]}):E?.targetKind===`mobile`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`my-6 flex justify-center`,children:$.data?(0,Z.jsx)(`img`,{src:$.data,alt:a.qrAlt,width:216,height:216,className:`size-[216px] max-w-full rounded-lg bg-white`}):$.error?null:(0,Z.jsx)(S,{className:`size-[216px]`})}),$.error?(0,Z.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:v.qrFailed}):null,(0,Z.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:E.expiresAt-he<6e4?`${Math.max(0,Math.ceil((E.expiresAt-he)/1e3))}s`:v.valid}),$.error?(0,Z.jsx)(`div`,{className:`mt-5`,children:(0,Z.jsx)(k,{text:E.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,Z.jsxs)(`details`,{className:`mt-5 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-2`,children:v.fallback}),(0,Z.jsx)(k,{text:E.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})]})]}):E?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,Z.jsx)(`div`,{className:`mt-6`,children:(0,Z.jsx)(k,{text:E.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,Z.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:E.expiresAt-he<6e4?`${Math.max(0,Math.ceil((E.expiresAt-he)/1e3))}s`:v.valid})]}):T.data.ready?(0,Z.jsx)(`div`,{className:`mt-8`,children:(0,Z.jsx)(S,{className:`mx-auto size-[216px]`})}):(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[V===`tailscale`?(0,Z.jsx)(I,{embedded:!0}):V===`https`?(0,Z.jsx)(ie,{}):V===`choices`?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>U(`tailscale`),children:a.useTailscale}),(0,Z.jsx)(x,{variant:`secondary`,className:`w-full`,onClick:()=>U(`https`),children:a.useOwnHttps})]}):(0,Z.jsx)(se,{}),(0,Z.jsx)(x,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>U(V?null:`choices`),children:V?v.back:v.existing})]}):(0,Z.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,Z.jsx)(S,{className:`h-5 w-3/4`}),(0,Z.jsx)(S,{className:`h-40 w-full`})]}):e===`mobile`?(0,Z.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[de.data?(0,Z.jsx)(`img`,{src:de.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,Z.jsx)(S,{className:`size-36`}),(0,Z.jsxs)(x,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void y(le),children:[(0,Z.jsx)(c,{className:`size-4`}),a.mobileDownload]}),(0,Z.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,Z.jsxs)(`div`,{className:`mt-7`,children:[(0,Z.jsxs)(x,{variant:`secondary`,className:`w-full`,disabled:j,onClick:()=>void Ce(),children:[(0,Z.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,Z.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void y(ue),children:[a.browserInstallHelp,(0,Z.jsx)(c,{className:`size-3`})]})]})]}),!C||T.error||X||Y?.status===`pending`||O===`create`||O===`decision`?(0,Z.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:C?X?(0,Z.jsx)(x,{className:`w-full`,variant:`primary`,onClick:t,children:v.done}):Y?.status===`pending`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(x,{className:`w-full`,variant:`primary`,disabled:j,onClick:()=>void pe(`approve`),children:v.allow}),(0,Z.jsx)(x,{className:`w-full`,variant:`ghost`,disabled:j,onClick:()=>void pe(`reject`),children:v.cancel})]}):T.error?(0,Z.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>void T.mutate(),children:v.retry}):(0,Z.jsx)(x,{className:`w-full`,variant:`primary`,disabled:j,onClick:()=>void fe(),children:v.retry}):(0,Z.jsx)(x,{className:`w-full`,variant:`primary`,onClick:()=>{A(null),w(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{Q as n,ce as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-DuG-kbsP.js";import{t as i}from"./messages-BYbx4OuI.js";import{eo as a}from"./index-54o0AGdj.js";var o=t();e();var s=n();function c(){let e=(0,o.c)(44),t=r(d),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let c=n.extensionDebug,f=a(),p;e[2]===f?p=e[3]:(p=f.toSorted(u),e[2]=f,e[3]=p);let m=p,h;e[4]===c.title?h=e[5]:(h=(0,s.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:c.title}),e[4]=c.title,e[5]=h);let g;e[6]===c.subtitle?g=e[7]:(g=(0,s.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.subtitle}),e[6]=c.subtitle,e[7]=g);let _;e[8]!==h||e[9]!==g?(_=(0,s.jsxs)(`div`,{children:[h,g]}),e[8]=h,e[9]=g,e[10]=_):_=e[10];let v;e[11]===c.listHeading?v=e[12]:(v=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.listHeading}),e[11]=c.listHeading,e[12]=v);let y;e[13]===c.colId?y=e[14]:(y=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colId}),e[13]=c.colId,e[14]=y);let b;e[15]===c.colName?b=e[16]:(b=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colName}),e[15]=c.colName,e[16]=b);let x;e[17]===c.colPermissions?x=e[18]:(x=(0,s.jsx)(`th`,{className:`py-2`,children:c.colPermissions}),e[17]=c.colPermissions,e[18]=x);let S;e[19]!==y||e[20]!==b||e[21]!==x?(S=(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[19]=y,e[20]=b,e[21]=x,e[22]=S):S=e[22];let C;e[23]===m?C=e[24]:(C=m.map(l),e[23]=m,e[24]=C);let w;e[25]===C?w=e[26]:(w=(0,s.jsx)(`tbody`,{children:C}),e[25]=C,e[26]=w);let T;e[27]!==w||e[28]!==S?(T=(0,s.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[S,w]})}),e[27]=w,e[28]=S,e[29]=T):T=e[29];let E;e[30]!==T||e[31]!==v?(E=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[v,T]}),e[30]=T,e[31]=v,e[32]=E):E=e[32];let D;e[33]===c.futureHeading?D=e[34]:(D=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.futureHeading}),e[33]=c.futureHeading,e[34]=D);let O;e[35]===c.futureBody?O=e[36]:(O=(0,s.jsx)(`p`,{className:`mt-2`,children:c.futureBody}),e[35]=c.futureBody,e[36]=O);let k;e[37]!==D||e[38]!==O?(k=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-muted/50 p-4 text-sm text-fg-muted shadow-surface`,children:[D,O]}),e[37]=D,e[38]=O,e[39]=k):k=e[39];let A;return e[40]!==E||e[41]!==k||e[42]!==_?(A=(0,s.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[_,E,k]}),e[40]=E,e[41]=k,e[42]=_,e[43]=A):A=e[43],A}function l(e){return(0,s.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,s.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,s.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,s.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function u(e,t){return e.id.localeCompare(t.id)}function d(e){return e.language}export{c as ExtensionDebugPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o,r as s}from"./popover-select-DldSX8GX.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,i as d,n as f,r as p}from"./locale-store-DuG-kbsP.js";import{t as m}from"./messages-BYbx4OuI.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-CGlRPNzi.js";import{Fo as _,Io as v,Lo as y,Xr as b,eo as x}from"./index-54o0AGdj.js";import{t as S}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as C,t as w}from"./use-autosave-DSrlXbBg.js";import{c as T,d as E,s as D}from"./voice-config-api-DJvwbFbz.js";import{t as O}from"./voice-api-key-field-9P97T0CT.js";import{t as k}from"./schema-form-CuIDQtYN.js";var A=e(t(),1),j=n(),M=r();function N(e){let t=(0,j.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function P(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function F(){return c(v,_)}function I(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,y,`dark:border-edge`)}function L(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function R({providerId:e,voiceSettings:t,mutateVoice:n}){let r=m(f(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,l={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=h(p(`/api/voice/stt-providers`),T,{revalidateOnFocus:!1}),d=(0,A.useMemo)(()=>u?.providers.find(t=>t.id===e),[e,u]),g=d?.configured??!1,v=d?.models??[],y=v[0]?.id??d?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,A.useMemo)(()=>L(t,e,y),[y,e,t]),x=(0,A.useRef)(!1),[S,D]=(0,A.useState)(null),k=S??b,j=(0,A.useRef)(k);j.current=k;let P=b,R=w({value:k,dirty:k.apiKey!==P.apiKey||k.model!==P.model,onSave:(0,A.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await E(i),await n(i,!1),x.current=JSON.stringify(j.current)!==JSON.stringify(r),D(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),z=v.length>0?v:k.model?[{id:k.model,name:k.model}]:[];return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:R.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:R.status,error:R.error}),(0,M.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-xs font-medium`,g?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:g?a.configured:a.notConfigured})]})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(N,{children:i.stt.apiKey}),(0,M.jsx)(O,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:k.apiKey,onChange:e=>{x.current=!0,D(t=>({...t??b,apiKey:e}))},labels:l,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,M.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(N,{children:i.stt.model}),z.length>0?(0,M.jsx)(o,{className:F(),value:k.model,onChange:e=>{x.current=!0,D(t=>({...t??b,model:e.target.value})),R.saveNow({...k,model:e.target.value})},children:z.map(e=>(0,M.jsx)(s,{value:e.id,children:e.name},e.id))}):(0,M.jsx)(`input`,{className:I(),value:k.model,onChange:e=>{x.current=!0,D(t=>({...t??b,model:e.target.value}))}})]})]})]})}function z(e){let t=(0,j.c)(13),{extensionId:n}=e,r=f(V),i=u(B),a;t[0]===n?a=t[1]:(a=()=>l(p(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=h(i&&n?`ext-stt-detail-${n}`:null,a),c;t[2]===o?c=t[3]:(c=P(o),t[2]=o,t[3]=c);let d=c,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:g,mutate:_,isLoading:v}=h(i?`voice-settings-ext-stt`:null,D,m);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsx)(S,{rows:2}),t[5]=e):e=t[5],e}if(!d){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${d}`,b;return t[8]!==_||t[9]!==d||t[10]!==y||t[11]!==g?(b=(0,M.jsx)(R,{providerId:d,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=d,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function B(e){return!!e.conversationId}function V(e){return e.language}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U(e){let t={};if(e.type!==`object`||!H(e.properties))return t;for(let[n,r]of Object.entries(e.properties))H(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function W(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function G({extensionId:e}){let t=u(e=>!!e.conversationId),{data:n,error:r}=h(t&&e?`ext-detail-${e}`:null,()=>l(p(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=h(t&&e?`ext-cfg-${e}`:null,()=>l(p(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,c=(0,A.useMemo)(()=>s&&s.type===`object`?U(s):{},[s]),f=(0,A.useMemo)(()=>({...c,...i??{}}),[c,i]),[m,_]=(0,A.useReducer)(W,{localValues:{},isDirty:!1}),v=(0,A.useRef)(!1),y=(0,A.useRef)(m.localValues);y.current=m.localValues;let b=(0,A.useRef)(f);!v.current&&b.current!==f&&(b.current=f,_({type:`sync`,value:f}));let x=(0,A.useCallback)(e=>{v.current=!0,_({type:`change`,value:e})},[]),S=(0,A.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,_({type:`reset-defaults`,value:{...U(s)}}))},[s]),T=(0,A.useCallback)(async t=>{if(!e)return;let n=await d(p(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),_({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),E=w({value:m.localValues,dirty:m.isDirty,onSave:T});if(!t)return null;if(r||o){let e=r??o;return(0,M.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!s||s.type!==`object`?null:(0,M.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,onBlurCapture:E.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:E.status,error:E.error}),(0,M.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,M.jsx)(k,{schema:s,values:m.localValues,onChange:x})]})}function K(){let e=(0,j.c)(38),t=f(q),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=x();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(J,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let l,u,d;if(e[3]!==o||e[4]!==c||e[5]!==s){d=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),l=c.find(t),!l){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,M.jsx)(J,{message:t}),e[11]=t,e[12]=n),d=n;break bb0}let n=l.ui?.contributions?.settingsPanels;u=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=l,e[7]=u,e[8]=d}else l=e[6],u=e[7],d=e[8];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let p=u,h=!!(p&&l.ui),g=!!l.hasConfigSchema,_=l.kind===`media-provider`;if(!g&&!h&&!_){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,M.jsx)(J,{message:t}),e[13]=t,e[14]=n),n}let v=p?.title??`${l.name} Settings`,y;e[15]===v?y=e[16]:(y=(0,M.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:v}),e[15]=v,e[16]=y);let S;e[17]!==_||e[18]!==r?(S=_?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,M.jsx)(a,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[17]=_,e[18]=r,e[19]=S):S=e[19];let C;e[20]!==o||e[21]!==_?(C=_?(0,M.jsx)(z,{extensionId:o}):null,e[20]=o,e[21]=_,e[22]=C):C=e[22];let w;e[23]!==o||e[24]!==g?(w=g?(0,M.jsx)(G,{extensionId:o}):null,e[23]=o,e[24]=g,e[25]=w):w=e[25];let T;e[26]!==l.name||e[27]!==l.ui||e[28]!==o||e[29]!==h||e[30]!==p?(T=h&&p&&l.ui?(0,M.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,M.jsx)(b,{extensionId:o,extensionName:l.name,entrypoint:p.entrypoint,permissions:l.ui?.permissions,title:p.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=l.name,e[27]=l.ui,e[28]=o,e[29]=h,e[30]=p,e[31]=T):T=e[31];let E;return e[32]!==y||e[33]!==S||e[34]!==C||e[35]!==w||e[36]!==T?(E=(0,M.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[y,S,C,w,T]}),e[32]=y,e[33]=S,e[34]=C,e[35]=w,e[36]=T,e[37]=E):E=e[37],E}function q(e){return e.language}function J(e){let t=(0,j.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{K as ExtensionSettingsPage};
|