@xopcai/xopc 0.0.166 → 0.0.167
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/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DkALQFJT.js → activity-store-DjEDu38T.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Tr2hgn4j.js → agent-avatar-dicebear-DQULz7qY.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CnzkBgKC.js +2 -0
- package/dist/gateway/static/root/assets/{api-DPIXEcIq.js → api-DwVCuPOb.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D7Nrbhez.js → app-management-settings-panel-DOjWALVF.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DNNbABFj.js → appearance-settings-C31COUIC.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-0zXIeywq.js → apps-page-lSC486eu.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CizqFy4G.js → archive-plugin-DQPvLqfx.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DU8KjTua.js → attachment-load-DwT1x1rc.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-3pqyIveW.js → automation-suggestion-card-ByYBiiMR.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DSz3xDsi.js → automations-page-iZTnc1YZ.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-CipUnsOr.js → binary-plugins-CRXiHoZS.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-XoEq6qiv.js → block-editor-CHO6ILiz.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-COYvq3y5.js → browser-settings-page-C-OOPZcJ.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-DRH995XI.js → browser-workflow-inputs-3UaarfXS.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-65edjhpz.js → browser-workflows-page-BFaa-N_D.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BayH0Uom.js +7 -0
- package/dist/gateway/static/root/assets/capability-presets-api-DdCHSzcA.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-JlhjAhT7.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-B5rLegwk.js → channel-recipient-api-BOkLI89e.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-D8nH0mve.js → channels-settings-C-Spmwr5.js} +1 -1
- package/dist/gateway/static/root/assets/channels-status-swr-ZrqadU60.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-n4Hg41iD.js → connector-logo-CbcC0T6i.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-jvRWZn3Y.js → connectors-page-DpDmJ3Nx.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-D4OzBOwm.js → desktop-pet-CR7RGQff.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CDGezbaf.js → desktop-pet-settings-BudmCcPE.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DmL4AUXQ.js → directory-picker-path-field-BLG2Oe6z.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-ClUcBKnd.js → dreaming-settings-BwBGC0SG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DsV_KUDM.js → extension-debug-page-Pr65_hLC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DJv_G1jY.js → extension-page-BuJDcoKn.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DUAlJ4CU.js → extension-settings-page-B3802tn5.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-SVYgzqv7.js → gateway-config-api-D-NVkfts.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-YL6f2C_F.js → gateway-settings-DIdsKVXv.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-ulwTJovP.js → gateway-startup-retry-qnEmj-vL.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-CJJe-4Co.js → goal-create-dialog-51j_DxgV.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-Da9VMWRd.js → goal-detail-page-CeqMr5GF.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-st_Itxa9.js → goals-config-api-BkVBh7ct.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-B6pC7PYZ.js → goals-page-lf3oM4Xa.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-BEZePZ5m.js → goals-settings-Cg7MJLvx.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DpeD9GQ9.js → heartbeat-settings-BV3kJOcX.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BhQMnKH1.js → index-B24B26og.js} +9 -9
- package/dist/gateway/static/root/assets/index-DfE2j0g8.css +1 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-B9K5rTZZ.js +1 -0
- package/dist/gateway/static/root/assets/{local-app-workbench-page-Ctia6lSG.js → local-app-workbench-page-ehzr9CBG.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DWF9rpWQ.js → local-apps-page-BBx6mfAD.js} +1 -1
- package/dist/gateway/static/root/assets/locale-store-tnRLWdx2.js +1 -0
- package/dist/gateway/static/root/assets/{logs-page-D3gL6vHX.js → logs-page-xuwEkusZ.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-BuduJ0Ev.js → markdown-split-DRDddIt8.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CLASZjhT.js → media-plugins-Dn3hxhOV.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-C96Zjb0V.js → messages-B1EG4gdu.js} +2 -4
- package/dist/gateway/static/root/assets/{notes-page-ve3XiBDF.js → notes-page-BtKHSb4z.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-oHU532lp.js → notes-workbench-DXGXn5XF.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-DU85jn98.js → page-tabs-P2BEd1D8.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CtchTuRQ.js → preview-open-alternatives-DrkjmW0F.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DFT6Fx6y.js → product-open-page-CGzMEowb.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Ceu0NoC1.js → project-detail-page-IiE2ddWb.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-CdpqOmO8.js → projects-page-DGOVhaYI.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-D1NKLyiR.js → remote-access-hub-l_y_Shgl.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-CmcrHpMc.js → save-bar-controls-BkGrufxl.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-DmIkP6JV.js → schedule-field-A8tDpL-9.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dkk9blN0.js → schema-form-N6_hDWgx.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CMj_JaOk.js → sessions-page-CAX4ipPv.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-eVlH9brU.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CuQzWvg5.js → settings-form-section-Bb6yYt5f.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-C5FNbyej.js → settings-loading-skeleton-Q_Vh6HEl.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-a-A2yTGE.js → settings-page-CjOtQpbR.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-MuXpamWD.js → settings-page-layout-CtESNNdx.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BUdh8FKY.js → setup-status-panel-CGxHXgJB.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BfzzmTgg.js → share-preview-page-C65IsFmd.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-8a9qnLF8.js → shares-settings-Ct3fcbHr.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-ElA5kabh.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-CmHj-CKY.js → skills-page-FeieOEn3.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CyhRkWMi.js → system-settings-panel-CdUl2I0D.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-D37XLD_C.js → theme-store-H9T49Iar.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-WEPp3HrB.js → time-picker-EkhqT3fS.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-Bi1uoxFR.js → typed-models-lib-5xRRUE9Y.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-DBh0dOC9.js → use-channel-catalog-UACJTyH0.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-BObEyiim.js → user-context-page-DHiRvd4i.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-Gvgodhec.js → voice-api-key-field-Bql0SPCp.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BHnjvGH1.js → work-discovery-page-BcmZux7y.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-CQ8ybkxx.js → work-item-detail-page-D94Q5zVD.js} +1 -1
- package/dist/gateway/static/root/assets/{work-page-D_U_En23.js → work-page-DdFBMDcB.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-B-Sk6gFn.js → workflow-run-setup-panel-Dow7ZztR.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DT0pzfkz.js → workflows-page-wOVSoduy.js} +1 -1
- package/dist/gateway/static/root/index.html +8 -8
- package/dist/package.js +1 -1
- package/dist/src/agent/image/generation/custom-openai-images-provider.d.ts +7 -0
- package/dist/src/agent/image/generation/custom-openai-images-provider.js +81 -0
- package/dist/src/agent/image/generation/{openai-compatible-image-provider.d.ts → openai-images-provider.d.ts} +10 -31
- package/dist/src/agent/image/generation/{openai-compatible-image-provider.js → openai-images-provider.js} +36 -23
- package/dist/src/agent/image/generation/provider-registry.d.ts +2 -0
- package/dist/src/agent/image/generation/provider-registry.js +50 -4
- package/dist/src/agent/image/generation/providers/openai.js +2 -2
- package/dist/src/agent/image/generation/runtime.js +5 -1
- package/dist/src/agent/image/generation/types.d.ts +11 -0
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/image-providers.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/image-providers.js +68 -0
- package/dist/src/cli/commands/doctor/flow.js +2 -0
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/models-json.d.ts +325 -0
- package/dist/src/config/models-json.js +139 -4
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/custom-image-providers.d.ts +89 -0
- package/dist/src/gateway/custom-image-providers.js +59 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +182 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +7 -1
- package/dist/src/gateway/service/config-coordinator.js +2 -0
- package/dist/src/gateway/service.js +2 -2
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/media-shared/http/index.d.ts +1 -1
- package/dist/src/media-shared/http/index.js +2 -2
- package/dist/src/media-shared/http/provider-http.d.ts +2 -0
- package/dist/src/media-shared/http/provider-http.js +43 -4
- package/dist/src/providers/model-reference-auditor.d.ts +1 -0
- package/dist/src/providers/model-reference-auditor.js +23 -13
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/agents-DZ69tC4K.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-LOQyfdsM.js +0 -2
- package/dist/gateway/static/root/assets/capability-presets-api-XL4h7dCK.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-KPJFkt1h.js +0 -2
- package/dist/gateway/static/root/assets/channels-status-swr-DZZq0upi.js +0 -1
- package/dist/gateway/static/root/assets/index-BXtJvaQl.css +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-fhssr2-J.js +0 -1
- package/dist/gateway/static/root/assets/locale-store-C_ax27uc.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DR9Q2ZyF.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-da5gLCer.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
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,l as a,r as o,t as s,u as c}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as l}from"./cn-JdwAhgNB.js";import{t as u}from"./messages-B1EG4gdu.js";import{l as d,n as f,o as p,r as m,s as h}from"./locale-store-tnRLWdx2.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{An as _,As as v,Bn as y,Bs as b,Bt as x,Cn as S,Dn as C,Ds as w,Ec as T,En as E,Es as D,Fc as O,Fn as k,Gl as A,Gn as j,Go as M,Hn as N,In as P,Is as ee,Jn as F,Jo as I,Js as L,Kl as R,Kn as z,Ko as B,Ln as V,Lr as te,Mn as ne,Ms as re,Mt as H,Nc as U,Nn as W,Ns as G,Nu as ie,On as K,Pc as ae,Pn as oe,Qo as q,Rn as se,Sl as ce,Sn as le,Ss as ue,Tn as de,Ts as fe,Un as pe,Uo as me,Vs as he,Vt as ge,Wn as _e,Wo as ve,Wr as ye,Xc as be,Xn as xe,Yn as Se,Yo as Ce,Ys as we,Zn as Te,Zo as Ee,_u as De,as as Oe,bn as ke,cs as J,dc as Ae,es as je,gc as Me,hu as Ne,jl as Pe,jn as Fe,js as Ie,jt as Le,ju as Re,kn as ze,ms as Be,no as Ve,oc as He,os as Y,ps as Ue,qn as We,qo as Ge,rl as X,ro as Ke,tl as qe,to as Je,tr as Ye,ts as Xe,vl as Ze,wn as Qe,ws as $e,xn as et,xs as tt,yc as nt,yn as rt,zc as it,zn as at,zt as ot}from"./index-B24B26og.js";import{n as st,r as ct}from"./settings-page-layout-CtESNNdx.js";import{t as lt}from"./settings-loading-skeleton-Q_Vh6HEl.js";import{c as ut,d as dt,i as ft,l as pt,n as mt,o as ht,r as gt,s as _t,t as vt,u as yt}from"./voice-api-key-field-Bql0SPCp.js";import{t as bt}from"./settings-advanced-gate-eVlH9brU.js";import{n as xt,t as St}from"./settings-form-section-Bb6yYt5f.js";import{t as Ct}from"./page-tabs-P2BEd1D8.js";import{n as wt,r as Tt,t as Et}from"./save-bar-controls-BkGrufxl.js";var Z=e(t(),1),Q=n();async function Dt(){let e=await h(m(`/api/image-generation/catalog`));if(!Array.isArray(e.payload?.providers))throw Error(`Invalid image provider catalog`);return e.payload.providers}async function Ot(){let e=await h(m(`/api/image-generation/custom-providers`));if(!Array.isArray(e.payload?.providers))throw Error(`Invalid custom image provider list`);return e.payload.providers}async function kt(e,t){await h(m(`/api/image-generation/custom-providers/${encodeURIComponent(e)}`),{method:`PUT`,body:JSON.stringify(t)})}async function At(e){await h(m(`/api/image-generation/custom-providers/${encodeURIComponent(e)}`),{method:`DELETE`})}async function jt(e,t){await h(m(`/api/image-generation/providers/${encodeURIComponent(e)}/credential`),{method:`PUT`,body:JSON.stringify({apiKey:t})})}async function Mt(e,t){let n=await h(m(`/api/image-generation/providers/${encodeURIComponent(e)}/test`),{method:`POST`,body:JSON.stringify({modelId:t})});if(!Array.isArray(n.payload?.images))throw Error(`Invalid image generation test response`);return{images:n.payload.images}}var $=r(),Nt={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 必须使用“名称: 值”格式,每行一个。`}},Pt=`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 Ft(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 It(e){let t=e.split(`
|
|
2
|
+
`).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 Lt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Nt[i],[s,c]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(`bearer`),[g,_]=(0,Z.useState)(`x-api-key`),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(`/images/generations`),[E,D]=(0,Z.useState)(`/images/edits`),[O,k]=(0,Z.useState)(``),[j,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)([Ft()]),[L,R]=(0,Z.useState)(``),[V,te]=(0,Z.useState)(),[ne,re]=(0,Z.useState)(!1),[H,W]=(0,Z.useState)(),[K,ae]=(0,Z.useState)();(0,Z.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),d(t?.name??``),p(n?.baseUrl??``),h(t?.auth.type??`bearer`),_(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),y(r?`••••••••••••`:``),x(t?.apiKeyUrl??``),C(t?.documentationUrl??``),T(t?.paths?.generations??`/images/generations`),D(t?.paths?.edits??`/images/edits`),k(t?.network?.allowedHosts.join(`
|
|
3
|
+
`)??``),N(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
4
|
+
`)),F(t?.models.map(Ft)??[Ft()]),R(t?.defaultModel??``),te(void 0),re(!1),W(void 0),ae(void 0)},[r,e,n]);let oe=(0,Z.useMemo)(()=>P.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[P]),q=(e,t)=>{F(n=>n.map((n,r)=>r===e?{...n,...t}:n))},se=()=>{let e=s.trim(),t=P.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!u.trim()||!f.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=L||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=It(j)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:f.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:u.trim(),...S.trim()?{documentationUrl:S.trim()}:{},...b.trim()?{apiKeyUrl:b.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:g.trim()}:{type:m},paths:{...w.trim()?{generations:w.trim()}:{},...E.trim()?{edits:E.trim()}:{}},...O.trim()?{network:{allowedHosts:O.split(`
|
|
5
|
+
`).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}}}))}}}},ce=async()=>{let e=se();return await kt(e.providerId,e.input),m!==`none`&&v.trim()&&!fe(v)&&await jt(e.providerId,v.trim()),await a(e.providerId),e},le=async()=>{te(`save`),W(void 0);try{await ce(),y(m===`none`?``:`••••••••••••`),Ee({type:`success`,title:o.saved})}catch(e){W(e instanceof Error?e.message:String(e))}finally{te(void 0)}},ue=async()=>{te(`test`),W(void 0),ae(void 0);try{let e=await ce();ae((await Mt(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),Ee({type:`success`,title:o.testReady})}catch(e){W(e instanceof Error?e.message:String(e))}finally{te(void 0)}},de=async()=>{if(n){if(!ne){re(!0);return}te(`delete`),W(void 0);try{await At(n.providerId),await a(),Ee({type:`success`,title:o.deleted}),t(!1)}catch(e){W(e instanceof Error?e.message:String(e))}finally{te(void 0)}}};return(0,$.jsx)(me,{open:e,onOpenChange:t,children:(0,$.jsxs)(I,{children:[(0,$.jsx)(Ge,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Be)}),(0,$.jsxs)(M,{className:l(`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`,Ue),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)(Ce,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(B,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(ve,{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)(ee,{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:Pt}),(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:u,onChange:e=>d(e.target.value),placeholder:`My Image Service`,className:Pt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`https://api.example.com/v1`,className:Pt})]}),(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)(Oe,{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:g,onChange:e=>_(e.target.value),className:Pt})]}):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}),b.trim()?(0,$.jsxs)(`a`,{href:b.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(ie,{className:`size-3.5`})]}):null]}),(0,$.jsx)($e,{id:`custom-image-api-key`,value:v,onChange:e=>y(fe(v)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>z(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:b,onChange:e=>x(e.target.value),placeholder:`https://…`,className:Pt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),placeholder:`https://…`,className:Pt})]})]}),(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:w,onChange:e=>T(e.target.value),className:Pt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),className:Pt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:O,onChange:e=>k(e.target.value),rows:2,placeholder:`127.0.0.1
|
|
6
|
+
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:j,onChange:e=>N(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)(G,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>F(e=>[...e,Ft()]),children:[(0,$.jsx)(U,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(Oe,{value:L||oe[0]?.value||``,options:oe,placeholder:o.defaultModel,allowEmpty:!1,onChange:R,triggerClassName:`mt-1.5 max-w-sm`})]}),P.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=>q(t,{id:e.target.value}),placeholder:`image-1`,className:Pt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>q(t,{name:e.target.value}),className:Pt})]})]}),(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=>q(t,{maxCount:e.target.value}),className:Pt})]}),(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=>q(t,{defaultCount:e.target.value}),className:Pt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>q(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Pt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(Oe,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>q(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=>q(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=>q(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:P.length===1,onClick:()=>F(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)(we,{className:`size-3.5`}),o.remove]})]})]},t))]}),K?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(A,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:K,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,H?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:H}):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)(G,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!V,onClick:()=>void de(),children:[V===`delete`?(0,$.jsx)(X,{className:`size-4 animate-spin`}):(0,$.jsx)(we,{className:`size-4`}),ne?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(G,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(G,{variant:`secondary`,disabled:!!V,onClick:()=>void ue(),children:[V===`test`?(0,$.jsx)(X,{className:`size-4 animate-spin`}):null,V===`test`?o.testing:o.test]}),(0,$.jsxs)(G,{variant:`primary`,disabled:!!V,onClick:()=>void le(),children:[V===`save`?(0,$.jsx)(X,{className:`size-4 animate-spin`}):null,V===`save`?o.saving:o.save]})]})]})]})]})})}var Rt=`••••••••••••`,zt={en:{title:`Image generation`,intro:`Choose an agent and image model, or connect an OpenAI Images service of your own.`,agent:`Agent`,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.`,region:`Service region`,cn:`China`,intl:`International`,advanced:`Custom endpoint`,baseUrl:`Base URL (optional)`,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.`,selectAgent:`Select an agent`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`为 Agent 选择图片模型,也可以连接你自己的 OpenAI Images 服务。`,agent:`Agent`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,region:`服务地域`,cn:`中国站`,intl:`国际站`,advanced:`自定义服务地址`,baseUrl:`Base URL(可选)`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectAgent:`选择 Agent`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function Bt(e){let t=await h(m(`/api/agents/${encodeURIComponent(e)}/image-generation`));if(!t.payload)throw Error(`Invalid agent image generation response`);return t.payload}function Vt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Ht(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Ut(e,t){return e===`minimax`?t===`cn`?`minimax-cn`:`minimax`:e===`dashscope`?t===`cn`?`dashscope-cn`:`dashscope-intl`:e}function Wt(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ke,{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(Gt)}),(0,$.jsx)(Ke,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function Gt(e,t){return(0,$.jsx)(Ke,{className:`h-24 rounded-xl`},t)}function Kt(){let e=f(e=>e.language),t=zt[e],n=u(e),r=!!d(e=>e.token),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[p,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(e===`zh`?`cn`:`intl`),[b,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(),{data:j,isLoading:M,error:N}=g(r?`image-generation-agents`:null,ye,{revalidateOnFocus:!1}),{data:P,isLoading:ee,error:F,mutate:I}=g(r?m(`/api/image-generation/catalog`):null,Dt,{revalidateOnFocus:!1}),{data:L,isLoading:R,error:B,mutate:V}=g(r?m(`/api/image-generation/custom-providers`):null,Ot,{revalidateOnFocus:!1});(0,Z.useEffect)(()=>{!j||i||a(j.defaultId||j.agents[0]?.id||``)},[i,j]);let{data:ne,isLoading:re,error:H,mutate:W}=g(r&&i?[`agent-image-generation`,i]:null,()=>Bt(i),{revalidateOnFocus:!1});(0,Z.useEffect)(()=>{if(!P||!ne)return;let e=Vt(ne.model?.primary),t=P.find(t=>t.id===e)??P.find(e=>e.configured)??P[0];t&&(s(t.id),l(t.id===e&&Ht(ne.model?.primary)||t.defaultModel),_(t.configured?Rt:``))},[ne,P]),(0,Z.useEffect)(()=>{E(void 0)},[i]);let K=P?.find(e=>e.id===o),ae=K?K.apiKeyUrl??x(Ut(K.id,v),e)[0]?.href:void 0,oe=(0,Z.useMemo)(()=>(j?.agents??[]).map(e=>({value:e.id,label:te(e,n.agentsSettings)})),[j?.agents,n.agentsSettings]),q=(0,Z.useMemo)(()=>(K?.models??[]).map(e=>({value:e,label:e})),[K?.models]),se=ne?.model?.primary,le=!!(i&&K&&c&&(K.credentialMode===`none`||K.configured||p.trim()));if(!r)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(M||ee||R||re)return(0,$.jsx)(Wt,{});if(N||F||B||H||!P||!j||!L)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let ue=e=>{s(e.id),l(e.defaultModel),_(e.configured?Rt:``),S(``),E(void 0)},de=()=>{A(void 0),O(!0)},pe=()=>{let e=L.find(e=>e.providerId===K?.id);e&&(A(e),O(!0))},me=async e=>{let[t,n]=await Promise.all([V(),I()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);s(r.id),l(r.defaultModel),_(r.configured?Rt:``),A(t?.find(t=>t.providerId===e))}},he=async()=>{if(!(!K||!le)){w(!0),E(void 0);try{let e=await h(m(`/api/agents/${encodeURIComponent(i)}/image-generation/setup`),{method:`POST`,body:JSON.stringify({providerId:K.id,modelId:c,...p.trim()&&!fe(p)?{apiKey:p.trim()}:{},...K.requiresRegion?{region:v}:{},...b.trim()?{baseUrl:b.trim()}:{}})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([W(e.payload.agent,{revalidate:!1}),I(e.payload.providers,{revalidate:!1})]),_(Rt),Ee({type:`success`,title:t.enabled})}catch(e){E(e instanceof Error?e.message:String(e))}finally{w(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`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)(ce,{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)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[t.agent,(0,$.jsx)(Oe,{value:i,options:oe,placeholder:t.selectAgent,allowEmpty:!1,onChange:a,triggerClassName:`mt-1.5 max-w-md`})]})]}),(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)(G,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:de,children:[(0,$.jsx)(U,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:P.map(e=>{let n=e.id===o,r=e.id===Vt(se);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ue(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":!r,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${r?``:`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===`none`?(0,$.jsx)(Ne,{className:`size-3.5`}):(0,$.jsx)(Ze,{className:`size-3.5`}),e.configured||e.credentialMode===`none`?t.configured:t.needsKey]})]},e.id)})})]}),K?(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)(Oe,{value:c,options:q,placeholder:t.selectModel,allowEmpty:!1,onChange:l,triggerClassName:`mt-1.5`})]}),K.requiresRegion?(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.region,(0,$.jsx)(Oe,{value:v,options:[{value:`cn`,label:t.cn},{value:`intl`,label:t.intl}],placeholder:t.region,allowEmpty:!1,onChange:e=>y(e),triggerClassName:`mt-1.5`})]}):null]}),K.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(G,{variant:`secondary`,onClick:pe,children:[(0,$.jsx)(Me,{className:`size-4`}),t.manageService]})}):null,K.credentialMode===`none`?null:(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}),ae?(0,$.jsxs)(`a`,{href:ae,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(ie,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)($e,{id:`image-generation-api-key`,value:p,onChange:e=>_(fe(p)?e.replace(/^•+/,``):e),placeholder:K.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>z(K.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},K.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:K.configured?t.savedKey:t.apiKeyHint})]}),(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)(Ae,{className:`size-4`}),t.advanced]}),(0,$.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-fg-muted`,children:[t.baseUrl,(0,$.jsx)(`input`,{value:b,onChange:e=>S(e.target.value),placeholder:`https://…`,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,$.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:T}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(G,{variant:`primary`,disabled:!le||C,onClick:()=>void he(),children:[C?(0,$.jsx)(X,{className:`size-4 animate-spin`}):(0,$.jsx)(Ne,{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:C?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Lt,{open:D,onOpenChange:O,provider:k,configured:!!(k&&P.find(e=>e.id===k.providerId)?.configured),language:e,onSaved:me})]})}var qt=v;function Jt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Yt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function Xt(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,re,`dark:border-edge`)}function Zt(){return l(Ie,v)}function Qt(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function $t(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}))}var en=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],tn=[{id:`whisper-1`,name:`Whisper-1`}],nn=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],rn=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],an=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],on=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],sn=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],cn=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],ln=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],un=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],dn=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function fn(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 pn(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 mn(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 hn(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 gn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function _n(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 vn(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 yn(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`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function bn(){let e=f(e=>e.language),t=u(e).voiceSettings,n=!!d(e=>e.token),[r,i]=(0,Z.useReducer)(yn,{form:null,baseline:null}),a=r.form,o=r.baseline,[s,c]=(0,Z.useState)(null),[l,p]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(null),v=(0,Z.useRef)(!1),y=(0,Z.useRef)({parsed:null,models:void 0}),{data:b,error:x,isLoading:S,mutate:C}=Ve(n),{data:w,error:T,isLoading:E,mutate:D}=g(n?m(`/api/voice/models`):null,gt,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:A}=g(n?m(`/api/voice/providers`):null,ft,{revalidateOnFocus:!1}),{data:j,error:M,isLoading:N}=g(n?m(`/api/voice/stt-providers`):null,ht,{revalidateOnFocus:!1}),P=(0,Z.useMemo)(()=>O?.providers??[],[O]),ee=(0,Z.useMemo)(()=>j?.providers??[],[j]),F=(0,Z.useMemo)(()=>b?.payload?.config===void 0?null:ut(b.payload.config),[b]),I=(0,Z.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);n?F!==null&&w!==void 0&&!v.current&&(y.current.parsed!==F||y.current.models!==w)&&(y.current={parsed:F,models:w},i({type:`sync`,value:F}),c(w)):(y.current.parsed!==null||y.current.models!==void 0)&&(y.current={parsed:null,models:void 0},i({type:`reset`}),c(null),v.current=!1);let L=!!(n&&(F===null||w===void 0||O===void 0||j===void 0)&&(S||E||A||N)),R=x instanceof Error?x.message:x?String(x):T instanceof Error?T.message:T?String(T):k instanceof Error?k.message:k?String(k):M instanceof Error?M.message:M?String(M):null,z=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),B=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),V=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),te=(0,Z.useCallback)(e=>{v.current=!0,i({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}}}}})},[]),ne=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),re=(0,Z.useCallback)(t=>{v.current=!0,i({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),H=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),U=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),W=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),ie=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,voice:e.voice!==void 0||e.lang!==void 0?{...t.voice,languageMode:`manual`}:t.voice,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),K=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ae=(0,Z.useCallback)(e=>{v.current=!0,i({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(wt({id:`voice`,dirty:I,saving:l,save:(0,Z.useCallback)(async()=>{if(!(!a||l)){p(!0),_(null);try{await pt(a),i({type:`saved`,value:a}),v.current=!1}catch(e){_(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[a,l,t.saveError]),discard:(0,Z.useCallback)(()=>{o&&(v.current=!1,i({type:`discard`}),_(null))},[o])}),!n)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(L)return(0,$.jsx)(lt,{rows:4});if(!a||s===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??R??t.loadError}),(0,$.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>{C(),D()},children:t.retry})]});let oe=a.stt,q=a.tts,se=a.voice.input.refinement,ce=gn(t);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(xn,{v:t,voice:a.voice,updateLanguageMode:re}),(0,$.jsx)(Sn,{v:t,stt:oe,tts:q}),(0,$.jsx)(wn,{v:t,apiKeyLabels:ce,stt:oe,models:s,sttProviders:ee,refinement:se,updateStt:z,updateSttAlibaba:B,updateSttOpenai:V,updateSttFallback:te,updateRefinement:ne}),(0,$.jsx)(Mn,{v:t,apiKeyLabels:ce,tts:q,models:s,ttsProviders:P,updateTts:H,updateTtsAlibaba:U,updateTtsOpenai:W,updateTtsEdge:ie,updateTtsMinimax:K,updateTtsLocalCli:ae})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,$.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,$.jsx)(`strong`,{className:`text-accent`,children:t.notes.title}),` `,t.notes.duration]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.notes.envVars})]})]})}function xn(e){let t=(0,Q.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=Zt(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let d;t[10]===n.language.auto?d=t[11]:(d=(0,$.jsx)(J,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,$.jsx)(J,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let p;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(p=(0,$.jsxs)(Y,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=p):p=t[18];let m;return t[19]!==c||t[20]!==p?(m=(0,$.jsx)(`section`,{className:`rounded-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,p]})}),t[19]=c,t[20]=p,t[21]=m):m=t[21],m}function Sn(e){let t=(0,Q.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,$.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${fn(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,$.jsx)(Cn,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?mn(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,$.jsx)(Cn,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${pn(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,$.jsx)(Cn,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,$.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,$.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function Cn(e){let t=(0,Q.c)(10),{label:n,value:r,ready:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o=i?`text-fg`:`text-fg-muted`,s;t[2]===o?s=t[3]:(s=l(`mt-1 text-sm font-medium`,o),t[2]=o,t[3]=s);let c;t[4]!==s||t[5]!==r?(c=(0,$.jsx)(`div`,{className:s,children:r}),t[4]=s,t[5]=r,t[6]=c):c=t[6];let u;return t[7]!==a||t[8]!==c?(u=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[a,c]}),t[7]=a,t[8]=c,t[9]=u):u=t[9],u}function wn(e){let t=(0,Q.c)(49),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,refinement:s,updateStt:c,updateSttAlibaba:u,updateSttOpenai:d,updateSttFallback:f,updateRefinement:p}=e,m=a?.stt?.alibaba?.length?a.stt.alibaba:en,h=a?.stt?.openai?.length?a.stt.openai:tn,g;if(t[0]!==o){let e=new Set;g=[];for(let t of o)e.has(t.id)||(e.add(t.id),g.push(t));t[0]=o,t[1]=g}else g=t[1];let _=g,v,y,b,x,S;if(t[2]!==m||t[3]!==r||t[4]!==a?.stt||t[5]!==h||t[6]!==_||t[7]!==s||t[8]!==i||t[9]!==p||t[10]!==c||t[11]!==u||t[12]!==f||t[13]!==d||t[14]!==n){let e=_.find(e=>e.id===i.provider),o=i.providers?.[i.provider],g=typeof o?.apiKey==`string`?o.apiKey:``,C=typeof o?.model==`string`?o.model:``,w={...i.provider===`alibaba`?i.alibaba??{}:{},...i.provider===`openai`?i.openai??{}:{},...o??{}},T=(e?.fields??[]).filter(kn),E;t[20]!==i.provider||t[21]!==i.providers||t[22]!==c?(E=e=>{c({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[20]=i.provider,t[21]=i.providers,t[22]=c,t[23]=E):E=t[23];let D=E;x=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(be,{className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=O):O=t[24];let k;t[25]===n.stt.title?k=t[26]:(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[O,n.stt.title]}),t[25]=n.stt.title,t[26]=k);let A;t[27]===n.stt.description?A=t[28]:(A=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[27]=n.stt.description,t[28]=A),t[29]!==k||t[30]!==A?(S=(0,$.jsxs)(`div`,{className:`mb-4`,children:[k,A]}),t[29]=k,t[30]=A,t[31]=S):S=t[31],v=`space-y-4`;let j;t[32]===c?j=t[33]:(j=e=>c({enabled:e}),t[32]=c,t[33]=j),t[34]!==i.enabled||t[35]!==j||t[36]!==n.overview.off||t[37]!==n.overview.ready||t[38]!==n.stt.enable||t[39]!==n.stt.enableDesc?(y=(0,$.jsx)(Nn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:j}),t[34]=i.enabled,t[35]=j,t[36]=n.overview.off,t[37]=n.overview.ready,t[38]=n.stt.enable,t[39]=n.stt.enableDesc,t[40]=y):y=t[40],b=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:n.stt.provider}),(0,$.jsx)(Y,{className:Zt(),value:i.provider,onChange:e=>c({provider:e.target.value}),children:_.map(e=>(0,$.jsxs)(J,{value:e.id,children:[fn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:n.stt.model}),i.provider===`xopc-local`?(0,$.jsx)(Y,{className:Zt(),value:C||`sensevoice-small`,onChange:e=>D({model:e.target.value}),children:(a?.stt?.[`xopc-local`]??[]).map(On)}):i.provider===`alibaba`?(0,$.jsx)(Y,{className:Zt(),value:i.alibaba?.model??``,onChange:e=>u({model:e.target.value}),children:m.map(Dn)}):i.provider===`openai`?(0,$.jsx)(Y,{className:Zt(),value:i.openai?.model??``,onChange:e=>d({model:e.target.value}),children:h.map(En)}):i.provider===`groq`?(0,$.jsx)(Y,{className:Zt(),value:C||nn[0].id,onChange:e=>D({model:e.target.value}),children:nn.map(Tn)}):(0,$.jsx)(`input`,{className:Xt(),value:C,onChange:e=>D({model:e.target.value}),placeholder:i.provider})]}),e?.diagnostics.requiresApiKey===!1?null:(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:n.stt.apiKey}),(0,$.jsx)(vt,{kind:`stt`,providerId:i.provider,fieldId:`voice-stt-${i.provider}-api-key`,value:i.provider===`alibaba`?i.alibaba?.apiKey??``:i.provider===`openai`?i.openai?.apiKey??``:g,onChange:e=>{i.provider===`alibaba`?u({apiKey:e}):i.provider===`openai`?d({apiKey:e}):D({apiKey:e})},labels:r,placeholder:i.provider===`groq`?`gsk_...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Jt(i.provider)?` ${Jt(i.provider)}`:``]})]})]}),T.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:T.map(e=>(0,$.jsx)(Pn,{field:e,value:_n(w,e),onChange:t=>D({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:qt},e.key))}):null,i.provider===`xopc-local`?(0,$.jsx)(jn,{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=>f({enabled:e.target.checked})})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.refinementDesc})]}),(0,$.jsxs)(Y,{className:Zt(),value:s.mode,onChange:e=>p({mode:e.target.value}),children:[(0,$.jsx)(J,{value:`off`,children:n.stt.refinementOff}),(0,$.jsx)(J,{value:`punctuation`,children:n.stt.refinementPunctuation}),(0,$.jsx)(J,{value:`light`,children:n.stt.refinementLight})]})]})]}):null,t[2]=m,t[3]=r,t[4]=a?.stt,t[5]=h,t[6]=_,t[7]=s,t[8]=i,t[9]=p,t[10]=c,t[11]=u,t[12]=f,t[13]=d,t[14]=n,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S}else v=t[15],y=t[16],b=t[17],x=t[18],S=t[19];let C;t[41]!==v||t[42]!==y||t[43]!==b?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b]}),t[41]=v,t[42]=y,t[43]=b,t[44]=C):C=t[44];let w;return t[45]!==x||t[46]!==S||t[47]!==C?(w=(0,$.jsxs)(`section`,{className:x,children:[S,C]}),t[45]=x,t[46]=S,t[47]=C,t[48]=w):w=t[48],w}function Tn(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function En(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function Dn(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function On(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function kn(e){return e.key!==`apiKey`&&e.key!==`model`}function An(e){return`${Math.round(e/1024/1024)} MB`}function jn({v:e}){let{data:t,error:n,mutate:r}=g(m(`/api/voice/local/status`),mt,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=(0,Z.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await _t(e.id):await yt(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,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:l(`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:[An(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)(G,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(X,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function Mn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,updateTtsAlibaba:o,updateTtsOpenai:s,updateTtsEdge:c,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:rn,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:an,m=r?.tts?.alibaba?.length?r.tts.alibaba:on,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:sn,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:cn,_=r?.tts?.minimax?.length?r.tts.minimax:ln,v=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:un,[y,x]=(0,Z.useState)(e.tts.test.sampleText),[S,C]=(0,Z.useState)({status:`idle`}),w=(0,Z.useRef)(null),T=(0,Z.useRef)(null),E=(0,Z.useCallback)(()=>{w.current?.pause(),w.current=null,T.current&&=(URL.revokeObjectURL(T.current),null)},[]),D=(0,Z.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]),k=D.find(e=>e.id===n.provider),A=n.providers?.[n.provider],j={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...A??{}},M=(k?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),N=!!k?.diagnostics.requiresApiKey,P=!!k?.configured||!N,ee=n.enabled?P?`ready`:`action`:`muted`,F=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,I=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,Z.useEffect)(()=>()=>E(),[E]);let L=(0,Z.useCallback)(e=>{a({provider:e}),C({status:`idle`})},[a]),R=(0,Z.useCallback)(async()=>{let t=y.trim();if(!t){C({status:`error`,message:e.tts.test.emptyText});return}E(),C({status:`loading`});try{let r=await dt({text:t,provider:n.provider,providerConfig:j,...F?{model:F}:{},...I?{voice:I}:{}}),i=$t(r.audio,r.mimeType);T.current=i;let a=new Audio(i);w.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,Qt(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>C({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>C({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),C({status:`playing`,summary:o})}catch(e){E(),C({status:`error`,message:e instanceof Error?e.message:String(e)})}},[F,I,j,E,y,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),z=(0,Z.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]),B=(0,Z.useCallback)((e,t)=>{let r={[e.key]:t};z(r),n.provider===`openai`&&e.key===`baseUrl`?s(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&c(r)},[n.provider,z,c,u,s]);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)(b,{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)(Nn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>a({enabled:e})}),(0,$.jsxs)(`div`,{className:l(`rounded-xl border px-3 py-2.5 text-sm`,ee===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:ee===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,$.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?P?`${e.tts.statusReady} ${pn(n.provider,e)}${I?` · ${I}`:``}`:`${e.tts.statusNeedsSetup} ${pn(n.provider,e)} · ${k?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:e.tts.trigger}),(0,$.jsxs)(Y,{className:Zt(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(J,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(J,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(J,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(J,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:e.tts.provider}),(0,$.jsx)(Y,{className:Zt(),value:n.provider,onChange:e=>L(e.target.value),children:D.map(t=>(0,$.jsx)(J,{value:t.id,children:pn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[k?.configured?e.tts.configured:k?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${k.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,k?.description??hn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!P||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,$.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:e.stt.apiKey}),(0,$.jsx)(vt,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?s({apiKey:e}):n.provider===`alibaba`?o({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Yt(n.provider)?` ${Yt(n.provider)}`:``]})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:e.stt.model}),(0,$.jsx)(Y,{className:Zt(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?s({model:e.target.value}):n.provider===`alibaba`?o({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,$.jsx)(J,{value:e.id,children:e.name},e.id))})]}),(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:e.tts.voice}),(0,$.jsx)(Y,{className:Zt(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?s({voice:e.target.value}):n.provider===`alibaba`?o({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:v).map(e=>(0,$.jsx)(J,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,$.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,qt),children:[(0,$.jsx)(In,{children:e.tts.voice}),(0,$.jsx)(Y,{className:Zt(),value:n.edge?.voice??``,onChange:e=>c({voice:e.target.value}),children:g.map(e=>(0,$.jsx)(J,{value:e.id,children:e.name},e.id))}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(In,{children:e.tts.localCli.preset}),(0,$.jsxs)(Y,{className:Zt(),value:``,onChange:e=>{let t=dn.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,$.jsx)(J,{value:``,children:e.tts.localCli.presetPlaceholder}),dn.map(e=>(0,$.jsx)(J,{value:e.id,children:e.id},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(In,{children:e.tts.localCli.command}),(0,$.jsx)(`input`,{className:l(Xt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(In,{children:e.tts.localCli.cwd}),(0,$.jsx)(`input`,{className:l(Xt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(In,{children:e.tts.localCli.outputFormat}),(0,$.jsxs)(Y,{className:Zt(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,$.jsx)(J,{value:`wav`,children:`wav`}),(0,$.jsx)(J,{value:`mp3`,children:`mp3`}),(0,$.jsx)(J,{value:`opus`,children:`opus`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(In,{children:e.tts.localCli.timeoutMs}),(0,$.jsx)(`input`,{className:Xt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,M.length>0?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:M.map(e=>(0,$.jsx)(Pn,{field:e,value:_n(j,e),onChange:t=>B(e,t),className:e.type===`textarea`?`sm:col-span-2`:qt},e.key))}):null]})]}),(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)(G,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:S.status===`loading`,className:`h-9`,children:[S.status===`loading`?(0,$.jsx)(X,{className:`size-4 animate-spin`}):(0,$.jsx)(O,{className:`size-4`}),S.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>{E(),C(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:S.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(He,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsx)(`textarea`,{className:l(Xt(),`mt-3 min-h-20 resize-y`),value:y,onChange:e=>x(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:[y.length,`/1000`]}),S.status===`playing`||S.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[S.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,S.summary]}):null,S.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:S.message}):null]})]})]}):null]})]})}function Nn(e){let t=(0,Q.c)(33),{checked:n,title:r,description:i,onLabel:a,offLabel:o,onChange:s}=e,c;t[0]!==n||t[1]!==s?(c=()=>s(!n),t[0]=n,t[1]=s,t[2]=c):c=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=l(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,re,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=l(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?a:o,h;t[7]!==p||t[8]!==m?(h=(0,$.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===i?_=t[14]:(_=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[13]=i,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,b;t[18]===y?b=t[19]:(b=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=b);let x=n?`translate-x-5`:`translate-x-0.5`,S;t[20]===x?S=t[21]:(S=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,x),t[20]=x,t[21]=S);let C;t[22]===S?C=t[23]:(C=(0,$.jsx)(`span`,{className:S}),t[22]=S,t[23]=C);let w;t[24]!==b||t[25]!==C?(w=(0,$.jsx)(`span`,{className:b,"aria-hidden":!0,children:C}),t[24]=b,t[25]=C,t[26]=w):w=t[26];let T;return t[27]!==n||t[28]!==c||t[29]!==v||t[30]!==w||t[31]!==d?(T=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:c,className:d,children:[v,w]}),t[27]=n,t[28]=c,t[29]=v,t[30]=w,t[31]=d,t[32]=T):T=t[32],T}function Pn(e){let t=(0,Q.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=l(`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 u;t[6]!==o||t[7]!==c?(u=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==i?(f=e=>i(vn(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let c=typeof r==`boolean`?``:String(r),u;t[19]===a?u=t[20]:(u=l(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(In,{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)(Y,{id:o,className:Zt(),value:c,required:n.required,onChange:e=>i(vn(n,e.target.value)),children:(n.options??[]).map(Fn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:l(Xt(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(vn(n,e.target.value))}):n.type===`password`?(0,$.jsx)($e,{id:o,className:a,value:c,onChange:e=>i(vn(n,e)),placeholder:n.placeholder,labels:tt}):(0,$.jsx)(`input`,{id:o,className:Xt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(vn(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]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Fn(e){return(0,$.jsx)(J,{value:e.id,children:e.name},e.id)}function In(e){let t=(0,Q.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 Ln(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 Rn(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 h(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Je()}async function zn(e){let t=await h(m(`/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 Bn(e){let t=(0,Q.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 Vn(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,re,`dark:border-edge`)}function Hn(){return l(Ie,v)}var Un=[`brave`,`tavily`,`bing`,`searxng`];function Wn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Gn=Le();function Kn(){let e=u(f(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!d(e=>e.token),[i,a]=(0,Z.useReducer)(Gn,{form:null,baseline:null}),o=i.form,s=i.baseline,[c,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(!1),_=(0,Z.useRef)(null),{data:v,error:y,isLoading:b,mutate:x}=Ve(r);H({enabled:r,parsed:(0,Z.useMemo)(()=>v?.payload?.config===void 0?null:Ln(v.payload.config),[v]),dirty:g.current,trackedParsedRef:_,dispatch:a,onResetDirty:()=>{g.current=!1}});let S=!!(r&&b&&v===void 0&&!y),C=y instanceof Error?y.message:y?String(y):null,w=(0,Z.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),T=(0,Z.useCallback)(e=>{g.current=!0,a({type:`patch`,patch:e})},[]);return wt({id:`search`,dirty:w,saving:c,save:(0,Z.useCallback)(async()=>{if(!(!o||c)){p(!0),h(null);try{await Rn(o),g.current=!1,a({type:`saved`,value:o})}catch(e){h(e instanceof Error?e.message:t.saveError)}finally{p(!1)}}},[o,c,t.saveError]),discard:(0,Z.useCallback)(()=>{s&&(g.current=!1,a({type:`discard`}),h(null))},[s])}),r?S?(0,$.jsx)(lt,{rows:3}):o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,$.jsxs)(St,{children:[(0,$.jsx)(xt,{icon:nt,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,$.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,$.jsx)(Bn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(Y,{className:Hn(),value:o.regionMode,onChange:e=>T({regionMode:e.target.value}),children:[(0,$.jsx)(J,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(J,{value:`cn`,children:t.regionCn}),(0,$.jsx)(J,{value:`global`,children:t.regionGlobal})]})})})]}),(0,$.jsx)(bt,{children:(0,$.jsxs)(St,{children:[(0,$.jsx)(xt,{icon:Re,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(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=>T({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)(Bn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:l(Vn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
7
|
+
`),placeholder:t.blocklistDomainsPlaceholder,disabled:!o.blocklistEnabled,onChange:e=>{T({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,$.jsxs)(St,{children:[(0,$.jsx)(xt,{icon:nt,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,$.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,$.jsx)(Bn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Vn(),value:o.maxResults,onChange:e=>T({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)(qn,{row:n,providerIndex:r,labels:t,secretLabels:ue(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,T({providers:t})},onRemove:()=>{T({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(G,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>T({providers:[...o.providers,Wn()]}),children:[(0,$.jsx)(U,{className:`size-4`}),t.addProvider]})]})]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??C??t.loadError}),(0,$.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>void x(),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 qn(e){let t=(0,Q.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>zn(r).then(Jn),t[0]=r,t[1]=c);let u=c,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=l(Hn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==o||t[4]!==n?(p=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=p):p=t[5];let m;t[6]===i.providerTypes?m=t[7]:(m=Un.map(e=>(0,$.jsx)(J,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,$.jsx)(Y,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==o||t[13]!==n?(g=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,$.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:g}),t[15]=n.disabled,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==i.disabled||t[19]!==_?(v=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,i.disabled]}),t[18]=i.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(we,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===s?b=t[23]:(b=(0,$.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:y}),t[22]=s,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==h?(S=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,x]}),t[27]=x,t[28]=h,t[29]=S):S=t[29];let C;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(C=n.type===`searxng`?(0,$.jsx)(Bn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Vn(),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]=C):C=t[34];let w;t[35]!==o||t[36]!==n?(w=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=w):w=t[37];let T;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==a||t[44]!==w?(T=(0,$.jsx)($e,{value:n.apiKey,onChange:w,placeholder:i.keyPlaceholder,labels:a,reveal:u,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=u,t[42]=n.apiKey,t[43]=a,t[44]=w,t[45]=T):T=t[45];let E;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==T?(E=(0,$.jsx)(Bn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:T}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=T,t[49]=E):E=t[49];let D;return t[50]!==S||t[51]!==C||t[52]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[S,C,E]}),t[50]=S,t[51]=C,t[52]=E,t[53]=D):D=t[53],D}function Jn(e){return e.apiKey??null}var Yn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Xn(e){let t=new Map;for(let e of Yn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Zn(e){let t=(0,Q.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Z.useState)(u),[p,m]=(0,Z.useState)(``),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{f({type:`pick`}),m(``)},200),r(e)},t[1]=r,t[2]=h);let g=h,v;t[3]!==g||t[4]!==c?(v=()=>{c(),g(!1)},t[3]=g,t[4]=c,t[5]=v):v=t[5];let y=v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Ge,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Be)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=l(`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`,Ue),t[7]=x):x=t[7];let S;t[8]!==i||t[9]!==a||t[10]!==y||t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(S=(0,$.jsxs)(I,{children:[b,(0,$.jsx)(M,{className:x,children:d.type===`pick`?(0,$.jsx)($n,{builtinRows:i,searchQuery:p,onSearchChange:m,labels:o,onPickBuiltin:e=>{let t=_(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,$.jsx)(er,{providerId:d.providerId,builtinRows:i,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:y}):(0,$.jsx)(rr,{initialPresetKey:d.presetKey,customConfig:a,labels:o,language:s,onBack:()=>f({type:`pick`}),onSaved:y})})]}),t[8]=i,t[9]=a,t[10]=y,t[11]=o,t[12]=s,t[13]=p,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=S):S=t[17];let C;return t[18]!==g||t[19]!==n||t[20]!==S?(C=(0,$.jsx)(me,{open:n,onOpenChange:g,children:S}),t[18]=g,t[19]=n,t[20]=S,t[21]=C):C=t[21],C}function Qn(e){let t=(0,Q.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function $n(e){let t=(0,Q.c)(42),{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 u=c,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=ot[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=Xn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===a.step1Title?h=t[10]:(h=(0,$.jsx)(Ce,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:a.step1Title}),t[9]=a.step1Title,t[10]=h);let g;t[11]===a.close?g=t[12]:(g=(0,$.jsx)(Qn,{label:a.close}),t[11]=a.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(nt,{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[16]=v):v=t[16];let y;t[17]===i?y=t[18]:(y=e=>i(e.target.value),t[17]=i,t[18]=y);let b=a.searchPlaceholder,x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=l(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,re),t[19]=x):x=t[19];let S;t[20]!==a.searchPlaceholder||t[21]!==r||t[22]!==y?(S=(0,$.jsx)(`div`,{className:`px-5 pt-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:b,autoComplete:`off`,className:x})]})}),t[20]=a.searchPlaceholder,t[21]=r,t[22]=y,t[23]=S):S=t[23];let C;t[24]!==a.addCustom||t[25]!==a.customDescription||t[26]!==s||t[27]!==u?(C=u?null:(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:l(`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`,w.press),children:[(0,$.jsx)(Pe,{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)(De,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=a.addCustom,t[25]=a.customDescription,t[26]=s,t[27]=u,t[28]=C):C=t[28];let T;t[29]!==f.length||t[30]!==m||t[31]!==a.categories||t[32]!==a.noResults||t[33]!==o?(T=f.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:Yn.map(e=>{let t=m.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,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:l(`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`,w.press),children:[(0,$.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,$.jsx)(Ne,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=a.categories,t[32]=a.noResults,t[33]=o,t[34]=T):T=t[34];let E;t[35]!==C||t[36]!==T?(E=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[C,T]}),t[35]=C,t[36]=T,t[37]=E):E=t[37];let D;return t[38]!==S||t[39]!==E||t[40]!==_?(D=(0,$.jsxs)($.Fragment,{children:[_,S,E]}),t[38]=S,t[39]=E,t[40]=_,t[41]=D):D=t[41],D}function er({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=ot[e],[c,d]=(0,Z.useState)(``),[f,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),b=(0,Z.useRef)(null),S=u(r).providersSettings,C=ue(S),T=(0,Z.useMemo)(()=>x(e,r),[e,r]),E=o?.supportsApiKey!==!1,D=o?.supportsOAuth===!0,[O,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(null),[N,ee]=(0,Z.useState)(`idle`),[F,I]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(``),V=N===`waiting`||N===`waiting_code`;(0,Z.useEffect)(()=>{if(!O||!V)return;let t=window.setInterval(()=>{(async()=>{try{let n=await P(O);if(n.status===`waiting_auth`||n.status===`waiting_code`)ee(n.status===`waiting_code`?`waiting_code`:`waiting`),M(n.message??null),I(n.authUrl??null),R(n.instructions??null);else if(n.status===`completed`){window.clearInterval(t);try{if(e===`xopc-cloud`){let e=await p(m(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`Model catalog refresh failed: ${e.status}`);await Se()}}catch(e){ee(`error`),M(e instanceof Error?e.message:S.revokeFailed);return}ee(`success`),M(n.message??S.saved),window.setTimeout(a,600)}else (n.status===`failed`||n.status===`cancelled`)&&(window.clearInterval(t),ee(`error`),M(n.error??n.message??S.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(t)},[O,V,a,e,S.revokeFailed,S.saved]),(0,Z.useEffect)(()=>()=>{O&&k(O).catch(()=>{})},[O]);let te=async()=>{ee(`waiting`),M(S.oauthStarting),_(null);try{A((await se(e)).sessionId)}catch(e){ee(`error`),M(e instanceof Error?e.message:S.revokeFailed)}},ne=async()=>{if(O){try{await oe(O)}catch{}ee(`idle`),M(null),A(null),I(null),R(null)}},H=async()=>{if(!(!O||!z.trim()))try{await at(O,z.trim()),B(``),M(S.oauthProcessingCode)}catch(e){ee(`error`),M(e instanceof Error?e.message:S.revokeFailed)}},U=async()=>{let t=c.trim();if(!(!t||!E)){h(!0),_(null);try{await _e({[e]:t}),y(!0),window.setTimeout(a,600)}catch(e){_(e instanceof Error?e.message:n.saveError)}finally{h(!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:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":n.back,children:(0,$.jsx)(De,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(Ce,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(Qn,{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,E?(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)($e,{id:`builtin-api-key`,value:c,onChange:d,placeholder:n.apiKeyPlaceholder,labels:C,inputRef:b,onKeyDown:e=>{e.key===`Enter`&&U()}})]}):null,D?(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:S.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:S.oauthHint})]}),(0,$.jsxs)(G,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:V,onClick:()=>void te(),children:[V?(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,S.oauth]})]}),j?(0,$.jsx)(`p`,{className:l(`text-xs`,N===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:j}):null,N===`waiting`||N===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[F?(0,$.jsxs)(`a`,{href:F,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:[S.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>void ne(),children:S.cancelOAuth})]}):null,L?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:L}):null,N===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:z,onChange:e=>B(e.target.value),onKeyDown:e=>e.key===`Enter`&&void H(),placeholder:S.pasteRedirectUrl,className:l(`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`,re)}),(0,$.jsx)(G,{type:`button`,variant:`primary`,onClick:()=>void H(),children:S.submitCode})]}):null]}):null,T.length>0&&E?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.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:[ge(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,g?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(G,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),E?(0,$.jsx)(G,{type:`button`,variant:`primary`,disabled:!c.trim()||f||v,onClick:()=>void U(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function tr(e=`custom`){if(e!==`custom`&&E[e]){let t=E[e].config;return{preset:e,providerId:ne(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 nr(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:E[t.key]?tr(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 rr({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Z.useReducer)(nr,void 0,()=>tr(e)),[c,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=ue(u(r).providersSettings),{preset:h,providerId:g,baseUrl:_,api:v,apiKey:y,modelIds:b,error:x}=o,S=async()=>{let e=g.trim(),r=_.trim();if(!e){s({type:`setError`,value:n.providerIdRequired});return}if(!r){s({type:`setError`,value:n.baseUrlRequired});return}let i=b.map(e=>e.trim()).filter(Boolean);d(!0),s({type:`setError`,value:null});try{let n=t?.providers??{},o=h===`custom`?void 0:E[h]?.config,s={...o??{},baseUrl:r,api:v,apiKey:y.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await Qe({providers:{...n,[e]:s}}),a()}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},T=async()=>{let e=g.trim()||ne(h)||`custom`,t=_.trim();if(!t){s({type:`setError`,value:n.baseUrlRequired});return}p(!0),s({type:`setError`,value:null});try{let r=h===`custom`?void 0:E[h]?.config,i=(await et({providerId:e,baseUrl:t,apiKey:y.trim()||void 0,api:v,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)}},D=g.trim()&&_.trim(),O=(v===`openai-completions`||v===`openai-responses`)&&_.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:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),"aria-label":n.back,children:(0,$.jsx)(De,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(Ce,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)(Qn,{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)(Y,{id:`custom-preset`,value:h,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:W(),children:[(0,$.jsx)(J,{value:`custom`,children:n.presetCustom}),C.map(e=>(0,$.jsx)(J,{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:g,onChange:e=>s({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,re)})]}),(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:_,onChange:e=>s({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,re)})]}),(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)(Y,{id:`custom-api-type`,value:v,onChange:e=>s({type:`setApi`,value:e.target.value}),className:W(),children:rt.map(e=>(0,$.jsx)(J,{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)($e,{id:`custom-api-key`,value:y,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)(G,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!O||f,onClick:()=>void T(),children:[f?(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(nt,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),b.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:l(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,re)}),b.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:l(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,w.press),children:(0,$.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(G,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsx)(G,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(G,{type:`button`,variant:`primary`,disabled:!D||c,onClick:()=>void S(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function ir(){let e=(0,Q.c)(31),t=d(lr),n=!!t,{data:r,isLoading:i}=Ve(n),a;e[0]===n?a=e[1]:(a=n?m(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let{data:c,isLoading:l}=g(a,o,s),u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1},e[5]=u):u=e[5];let{data:f,isLoading:p}=g(n?xe:null,cr,u),h;e[6]===f?h=e[7]:(h=f===void 0?[]:f,e[6]=f,e[7]=h);let _=h,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=g(n?We:null,sr,v),b;bb0:{if(!c||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==c||e[12]!==_?(t=pe(c,j(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=c,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,C;bb1:{if(!y){C=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=S(y.config),e[14]=y.config,e[15]=t),C=t}let w=C,T;if(e[16]!==x||e[17]!==w||e[18]!==c||e[19]!==_){T=[];let t=new Set((c??[]).filter(or).map(ar)),n;e[21]===w?n=e[22]:(n=new Set(w?Object.keys(w.providers):[]),e[21]=w,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?w.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;T.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(w){let t;e[23]===w.providers?t=e[24]:(t=Object.entries(w.providers),e[23]=w.providers,e[24]=t);for(let[e,n]of t)T.some(t=>t.id===e)||T.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=w,e[18]=c,e[19]=_,e[20]=T}else T=e[20];let E=T,D=i||l||p,O;return e[25]!==x||e[26]!==E||e[27]!==w||e[28]!==D||e[29]!==_?(O={cards:E,loading:D,builtinRows:x,customConfig:w,allModels:_},e[25]=x,e[26]=E,e[27]=w,e[28]=D,e[29]=_,e[30]=O):O=e[30],O}function ar(e){return e.id}function or(e){return e.configured}function sr(){return le()}function cr(){return Te()}function lr(e){return e.token}function ur(e){let t=(0,Q.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=ir();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ke,{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(fr)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(dr),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(U,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,$.jsxs)(G,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(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)(G,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,$.jsx)(U,{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)(pr,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function dr(e){return e.configured}function fr(e){return(0,$.jsx)(Ke,{className:`h-32 rounded-2xl`},e)}function pr(e){let t=(0,Q.c)(28),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=l(`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`,w.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 u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Ne,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===c?d=t[11]:(d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,u]}),t[10]=c,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=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]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Me,{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]!==p?(g=(0,$.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==i||t[25]!==g||t[26]!==d?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[d,g]}),t[24]=i,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}function mr(e){let t=(0,Q.c)(156),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c;t[0]===n?c=t[1]:(c=()=>n?{...n}:ke(``),t[0]=n,t[1]=c);let[u,d]=(0,Z.useState)(c),[f,p]=(0,Z.useState)(hr),m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=m):m=t[2];let h=m,g;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==s.modelIdRequired||t[7]!==s.mustBePositive?(g=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=s.modelIdRequired,t[7]=s.mustBePositive,t[8]=g):g=t[8];let _=g,v;t[9]!==u||t[10]!==o||t[11]!==a||t[12]!==_?(v=()=>{if(!_())return;let e=(u.id||``).trim();a({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),o()},t[9]=u,t[10]=o,t[11]=a,t[12]=_,t[13]=v):v=t[13];let y=v,b=u,x;t[14]===b?x=t[15]:(x=Fe(b),t[14]=b,t[15]=x);let S=x,C=r?s.addModelTitle:s.editModelTitle,w;t[16]===C?w=t[17]:(w=(0,$.jsx)(Ce,{className:`text-base font-semibold text-fg`,children:C}),t[16]=C,t[17]=w);let T;t[18]!==s.modelProviderLabel||t[19]!==i?(T=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[18]=s.modelProviderLabel,t[19]=i,t[20]=T):T=t[20];let E;t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(`div`,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=l(D,`p-1.5 hover:bg-surface-base`),t[24]=O):O=t[24];let k;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(ee,{className:`size-4`}),t[25]=k):k=t[25];let A;t[26]===s.close?A=t[27]:(A=(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O,"aria-label":s.close,children:k})}),t[26]=s.close,t[27]=A);let j;t[28]!==E||t[29]!==A?(j=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[E,A]}),t[28]=E,t[29]=A,t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=M):M=t[31];let N;t[32]===s.modelId?N=t[33]:(N=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,M]}),t[32]=s.modelId,t[33]=N);let P;t[34]===f?P=t[35]:(P=l(K(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=P);let F=u.id||``,I;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>h(`id`,e.target.value),t[36]=I):I=t[36];let L=!r,R;t[37]!==P||t[38]!==F||t[39]!==L?(R=(0,$.jsx)(`input`,{className:P,value:F,onChange:I,placeholder:`e.g. llama3.1:8b`,disabled:L}),t[37]=P,t[38]=F,t[39]=L,t[40]=R):R=t[40];let z;t[41]===f?z=t[42]:(z=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=z);let B;t[43]!==N||t[44]!==R||t[45]!==z?(B=(0,$.jsxs)(`div`,{children:[N,R,z]}),t[43]=N,t[44]=R,t[45]=z,t[46]=B):B=t[46];let V;t[47]===s.displayName?V=t[48]:(V=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[47]=s.displayName,t[48]=V);let te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(te=K(),t[49]=te):te=t[49];let ne=u.name||``,re;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>h(`name`,e.target.value),t[50]=re):re=t[50];let H;t[51]===ne?H=t[52]:(H=(0,$.jsx)(`input`,{className:te,value:ne,onChange:re}),t[51]=ne,t[52]=H);let U;t[53]!==V||t[54]!==H?(U=(0,$.jsxs)(`div`,{children:[V,H]}),t[53]=V,t[54]=H,t[55]=U):U=t[55];let ie;t[56]===s.inputTypes?ie=t[57]:(ie=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[56]=s.inputTypes,t[57]=ie);let ae;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ae=W(),t[58]=ae):ae=t[58];let oe;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>h(`input`,ze(e.target.value)),t[59]=oe):oe=t[59];let q;t[60]===s?q=t[61]:(q=de.map(e=>(0,$.jsx)(J,{value:e.value,children:s[e.labelKey]},e.value)),t[60]=s,t[61]=q);let se;t[62]!==S||t[63]!==q?(se=(0,$.jsx)(Y,{className:ae,value:S,onChange:oe,children:q}),t[62]=S,t[63]=q,t[64]=se):se=t[64];let ce;t[65]!==ie||t[66]!==se?(ce=(0,$.jsxs)(`div`,{children:[ie,se]}),t[65]=ie,t[66]=se,t[67]=ce):ce=t[67];let le=u.reasoning||!1,ue;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>h(`reasoning`,e.target.checked),t[68]=ue):ue=t[68];let fe;t[69]===le?fe=t[70]:(fe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[69]=le,t[70]=fe);let pe;t[71]!==s.reasoning||t[72]!==fe?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fe,s.reasoning]}),t[71]=s.reasoning,t[72]=fe,t[73]=pe):pe=t[73];let me;t[74]!==ce||t[75]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,pe]}),t[74]=ce,t[75]=pe,t[76]=me):me=t[76];let he;t[77]===s.contextWindow?he=t[78]:(he=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[77]=s.contextWindow,t[78]=he);let ge;t[79]===f?ge=t[80]:(ge=l(K(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=ge);let _e=u.contextWindow??128e3,ye;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>h(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=ye):ye=t[81];let be;t[82]!==ge||t[83]!==_e?(be=(0,$.jsx)(`input`,{type:`number`,min:1,className:ge,value:_e,onChange:ye}),t[82]=ge,t[83]=_e,t[84]=be):be=t[84];let xe;t[85]===f?xe=t[86]:(xe=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=xe);let Se;t[87]!==he||t[88]!==be||t[89]!==xe?(Se=(0,$.jsxs)(`div`,{children:[he,be,xe]}),t[87]=he,t[88]=be,t[89]=xe,t[90]=Se):Se=t[90];let we;t[91]===s.maxOutputTokens?we=t[92]:(we=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[91]=s.maxOutputTokens,t[92]=we);let Te;t[93]===f?Te=t[94]:(Te=l(K(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=Te);let Ee=u.maxTokens??16384,De;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(De=e=>h(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=De):De=t[95];let Oe;t[96]!==Te||t[97]!==Ee?(Oe=(0,$.jsx)(`input`,{type:`number`,min:1,className:Te,value:Ee,onChange:De}),t[96]=Te,t[97]=Ee,t[98]=Oe):Oe=t[98];let Ae;t[99]===f?Ae=t[100]:(Ae=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Ae);let je;t[101]!==we||t[102]!==Oe||t[103]!==Ae?(je=(0,$.jsxs)(`div`,{children:[we,Oe,Ae]}),t[101]=we,t[102]=Oe,t[103]=Ae,t[104]=je):je=t[104];let Me;t[105]!==Se||t[106]!==je?(Me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Se,je]}),t[105]=Se,t[106]=je,t[107]=Me):Me=t[107];let Ne;t[108]===s.costSection?Ne=t[109]:(Ne=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[108]=s.costSection,t[109]=Ne);let Pe;t[110]===s.costInput?Pe=t[111]:(Pe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[110]=s.costInput,t[111]=Pe);let Ie;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=K(),t[112]=Ie):Ie=t[112];let Le=u.cost?.input??0,Re;t[113]===u.cost?Re=t[114]:(Re=e=>h(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=Re);let Be;t[115]!==Le||t[116]!==Re?(Be=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ie,value:Le,onChange:Re}),t[115]=Le,t[116]=Re,t[117]=Be):Be=t[117];let Ve;t[118]!==Pe||t[119]!==Be?(Ve=(0,$.jsxs)(`div`,{children:[Pe,Be]}),t[118]=Pe,t[119]=Be,t[120]=Ve):Ve=t[120];let He;t[121]===s.costOutput?He=t[122]:(He=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[121]=s.costOutput,t[122]=He);let Ue;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=K(),t[123]=Ue):Ue=t[123];let We=u.cost?.output??0,Ge;t[124]===u.cost?Ge=t[125]:(Ge=e=>h(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=Ge);let X;t[126]!==We||t[127]!==Ge?(X=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ue,value:We,onChange:Ge}),t[126]=We,t[127]=Ge,t[128]=X):X=t[128];let Ke;t[129]!==He||t[130]!==X?(Ke=(0,$.jsxs)(`div`,{children:[He,X]}),t[129]=He,t[130]=X,t[131]=Ke):Ke=t[131];let qe;t[132]!==Ve||t[133]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Ve,Ke]}),t[132]=Ve,t[133]=Ke,t[134]=qe):qe=t[134];let Je;t[135]!==Ne||t[136]!==qe?(Je=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Ne,qe]}),t[135]=Ne,t[136]=qe,t[137]=Je):Je=t[137];let Ye;t[138]!==B||t[139]!==U||t[140]!==me||t[141]!==Me||t[142]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[B,U,me,Me,Je]}),t[138]=B,t[139]=U,t[140]=me,t[141]=Me,t[142]=Je,t[143]=Ye):Ye=t[143];let Xe;t[144]===s.cancel?Xe=t[145]:(Xe=(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(G,{type:`button`,variant:`secondary`,children:s.cancel})}),t[144]=s.cancel,t[145]=Xe);let Ze=r?s.addModelConfirm:s.saveModelConfirm,Qe;t[146]!==y||t[147]!==Ze?(Qe=(0,$.jsx)(G,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:y,children:Ze}),t[146]=y,t[147]=Ze,t[148]=Qe):Qe=t[148];let $e;t[149]!==Xe||t[150]!==Qe?($e=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Xe,Qe]}),t[149]=Xe,t[150]=Qe,t[151]=$e):$e=t[151];let et;return t[152]!==j||t[153]!==Ye||t[154]!==$e?(et=(0,$.jsxs)($.Fragment,{children:[j,Ye,$e]}),t[152]=j,t[153]=Ye,t[154]=$e,t[155]=et):et=t[155],et}function hr(){return new Map}function gr(e){let t=(0,Q.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Ge,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Be)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=l(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,Ue,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=n?(0,$.jsx)(mr,{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]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,$.jsxs)(I,{children:[u,(0,$.jsx)(M,{className:d,onOpenAutoFocus:_r,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,$.jsx)(me,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function _r(e){return e.preventDefault()}function vr(e){let t=(0,Q.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>z(n).then(yr),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)($e,{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 yr(e){return e.apiKey??null}function br(e){let t=(0,Q.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Ge,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Be)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=l(`fixed left-1/2 top-1/2 flex max-h-[85vh] 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`,Ue),t[1]=m):m=t[1];let h;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==i?(h=(0,$.jsxs)(I,{children:[p,(0,$.jsx)(M,{className:m,children:a?(0,$.jsx)(Sr,{providerId:i,customConfig:s,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,$.jsx)(xr,{providerId:i,builtinRows:o,allModels:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=i,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,$.jsx)(me,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function xr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let c=t.find(t=>t.id===e),d=ot[e],f=n.filter(t=>t.provider===e),[p,m]=(0,Z.useState)(c?.apiKey??``),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[b,S]=(0,Z.useState)(null),[C,T]=(0,Z.useState)(!1),E=u(i).providersSettings,D=c?.supportsApiKey!==!1,O=c?.supportsOAuth===!0,A=c?.authMode===`oauth`&&c.authStatus===`connected`,j=c?.configured===!0&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[M,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(`idle`),[te,ne]=(0,Z.useState)(null),[H,U]=(0,Z.useState)(null),[W,ie]=(0,Z.useState)(``),K=z===`waiting`||z===`waiting_code`,ae=(0,Z.useMemo)(()=>x(e,i),[e,i]),q=p!==(c?.apiKey??``),ce=async()=>{let t=p.trim();if(!(!t||!D||N(t))){g(!0),S(null);try{await _e({[e]:t}),v(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){S(e instanceof Error?e.message:r.saveError)}finally{g(!1)}}};(0,Z.useEffect)(()=>{if(!M||!K)return;let e=window.setInterval(()=>{(async()=>{try{let t=await P(M);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),L(t.message??null),ne(t.authUrl??null),U(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),B(`success`),L(t.message??E.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),B(`error`),L(t.error??t.message??E.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[M,K,a,o,E.revokeFailed,E.saved]),(0,Z.useEffect)(()=>()=>{M&&k(M).catch(()=>{})},[M]);let le=async()=>{try{await y(e),o(),a()}catch{}},ue=async()=>{B(`waiting`),L(E.oauthStarting),S(null);try{F((await se(e)).sessionId)}catch(e){B(`error`),L(e instanceof Error?e.message:E.revokeFailed)}},de=async()=>{if(M){try{await oe(M)}catch{}B(`idle`),L(null),F(null),ne(null),U(null)}},fe=async()=>{if(!(!M||!W.trim()))try{await at(M,W.trim()),ie(``),L(E.oauthProcessingCode)}catch(e){B(`error`),L(e instanceof Error?e.message:E.revokeFailed)}},pe=async()=>{try{await V(e),o(),a()}catch(e){S(e instanceof Error?e.message:E.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(Ce,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[d?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.description}):null,c?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:c.baseUrl})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,D?(0,$.jsx)(vr,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{m(e),v(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):c?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),c?.extensionId?(0,$.jsxs)(s,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(R,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,O?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:E.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:A?E.sourceOauth:E.oauthHint})]}),A?(0,$.jsx)(G,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void pe(),children:E.revoke}):(0,$.jsxs)(G,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:K,onClick:()=>void ue(),children:[K?(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(qe,{className:`size-3.5`,"aria-hidden":!0}),E.oauth]})]}),I?(0,$.jsx)(`p`,{className:l(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:I}):null,z===`waiting`||z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[te?(0,$.jsxs)(`a`,{href:te,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),E.openAuthPage]}):null,(0,$.jsx)(G,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:E.cancelOAuth})]}):null,H?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:H}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:W,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void fe(),placeholder:E.pasteRedirectUrl,className:l(`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`,re)}),(0,$.jsx)(G,{type:`button`,variant:`primary`,onClick:()=>void fe(),children:E.submitCode})]}):null]}):null,ae.length>0&&D?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ae.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:[ge(e,r),(0,$.jsx)(R,{className:`size-3`,"aria-hidden":!0})]},e))}):null,f.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,` (`,f.length,`)`]}),(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:f.map(e=>(0,$.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),b?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[j?(0,$.jsxs)(G,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>T(!0),children:[(0,$.jsx)(we,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:D&&q&&!N(p.trim())?(0,$.jsx)(G,{type:`button`,variant:`primary`,disabled:!p.trim()||h||_,onClick:()=>void ce(),children:_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ne,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Ye,{open:C,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void le(),onCancel:()=>T(!1)})]})}function Sr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=u(r).modelsSettings,s=t?.providers[e],[c,d]=(0,Z.useState)(s?.baseUrl??``),[f,p]=(0,Z.useState)(s?.apiKey??``),[m,h]=(0,Z.useState)(s?.models??[]),[g,_]=(0,Z.useState)(s?.modelDiscovery?.enabled===!0),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),j=n=>{if(!t)return null;let r=f.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:N(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},M=async()=>{let e=j({models:m,modelDiscovery:{enabled:g}});if(e){y(!0),x(null);try{await Qe(e),a(),i()}catch(e){x(e instanceof Error?e.message:n.saveError)}finally{y(!1)}}},P=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await Qe({providers:r}),a(),i()}catch{}},F=(e,t)=>{A({model:e,isNew:t}),O(!0)},I=async e=>{if(!k)return;let t=k.isNew?[...m,e]:m.map(t=>t.id===e.id?e:t);h(t);let r=j({models:t});if(r)try{await Qe(r),a()}catch(e){x(e instanceof Error?e.message:n.saveError)}},L=async e=>{let t=m.filter(t=>t.id!==e);h(t),E(null);let r=j({models:t});if(r)try{await Qe(r),a()}catch(e){x(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)(Ce,{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)(ve,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),children:(0,$.jsx)(ee,{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=>d(e.target.value),className:l(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,re)})]}),(0,$.jsx)(vr,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,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:g,onChange:e=>_(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,m.length>0?` (${m.length})`:``]}),(0,$.jsxs)(G,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>F(null,!0),children:[(0,$.jsx)(U,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:m.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.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:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,w.press),onClick:()=>F(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(it,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:l(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,w.press),onClick:()=>E(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(we,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),b?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(G,{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:()=>C(!0),children:[(0,$.jsx)(we,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(G,{type:`button`,variant:`primary`,disabled:v,onClick:()=>void M(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(X,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Ye,{open:S,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void P(),onCancel:()=>C(!1)}),(0,$.jsx)(Ye,{open:T!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,T??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{T&&L(T)},onCancel:()=>E(null)}),(0,$.jsx)(gr,{open:D,onOpenChange:e=>{O(e),e||A(null)},providerId:e,model:k?.model??null,isNew:k?.isNew??!1,onSave:e=>void I(e),m:o})]})}async function Cr(){let e=await p(m(`/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}function wr(){let e=f(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=g(F,Cr,{revalidateOnFocus:!1}),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null);if(r)return(0,$.jsx)(Ke,{className:`h-24 w-full rounded-2xl`});let c=Object.values(t?.sources??{}),l=c.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),u=(t?.references??[]).filter(e=>e.availability===`unavailable`),d=t?.sync.lastSuccessAt??Math.max(0,...c.map(e=>e.lastSuccessAt)),h=o??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),_=async()=>{a(!0),s(null);try{let e=await p(m(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await Se()}catch(t){s(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{a(!1)}};return(0,$.jsx)(`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||u.length>0?(0,$.jsx)(L,{className:`size-4 text-amber-500`,"aria-hidden":!0}):(0,$.jsx)(Ne,{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?`${c.length} 个来源,${l} 个可用模型${d?` · 最近同步 ${new Date(d).toLocaleString()}`:``}`:`${c.length} sources, ${l} available models${d?` · Last synced ${new Date(d).toLocaleString()}`:``}`}),u.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:u.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]}),(0,$.jsxs)(G,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void _(),children:[i?(0,$.jsx)(X,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(T,{className:`size-4`,"aria-hidden":!0}),i?e?`刷新中…`:`Refreshing…`:e?`立即刷新`:`Refresh now`]})]})})}function Tr(e){return q.includes(e)}function Er(){let e=(0,Q.c)(79),t=f(kr),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=n,l=r.capabilitiesSettings,d=a(),[p,m]=i(),{capability:h}=c(),g=Tt(Or),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),x=ir(),S,C;e[2]!==h||e[3]!==p||e[4]!==m?(S=()=>{if(h!==`models`||p.get(`add`)!==`1`)return;v(!0);let e=new URLSearchParams(p);e.delete(`add`),m(e,{replace:!0})},C=[h,p,m],e[2]=h,e[3]=p,e[4]=m,e[5]=S,e[6]=C):(S=e[5],C=e[6]),(0,Z.useEffect)(S,C);let w;e[7]!==l.unsavedChanges||e[8]!==g?(w=e=>g.get(e)?.dirty?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":l.unsavedChanges,title:l.unsavedChanges}):void 0,e[7]=l.unsavedChanges,e[8]=g,e[9]=w):w=e[9];let T=w,E;e[10]!==l.modelsHint||e[11]!==l.tabs.models?(E={id:`models`,icon:ae,label:l.tabs.models,hint:l.modelsHint},e[10]=l.modelsHint,e[11]=l.tabs.models,e[12]=E):E=e[12];let D=l.tabs.image,O=l.imageHint,k;e[13]===T?k=e[14]:(k=T(`image-models`),e[13]=T,e[14]=k);let A;e[15]!==l.imageHint||e[16]!==l.tabs.image||e[17]!==k?(A={id:`image`,icon:ce,label:D,hint:O,suffix:k},e[15]=l.imageHint,e[16]=l.tabs.image,e[17]=k,e[18]=A):A=e[18];let j=l.tabs.voice,M=l.voiceHint,N;e[19]===T?N=e[20]:(N=T(`voice`),e[19]=T,e[20]=N);let P;e[21]!==l.tabs.voice||e[22]!==l.voiceHint||e[23]!==N?(P={id:`voice`,icon:be,label:j,hint:M,suffix:N},e[21]=l.tabs.voice,e[22]=l.voiceHint,e[23]=N,e[24]=P):P=e[24];let ee=l.tabs.search,F=l.searchHint,I;e[25]===T?I=e[26]:(I=T(`search`),e[25]=T,e[26]=I);let L;e[27]!==l.searchHint||e[28]!==l.tabs.search||e[29]!==I?(L={id:`search`,icon:nt,label:ee,hint:F,suffix:I},e[27]=l.searchHint,e[28]=l.tabs.search,e[29]=I,e[30]=L):L=e[30];let R;e[31]!==P||e[32]!==L||e[33]!==E||e[34]!==A?(R=[E,A,P,L],e[31]=P,e[32]=L,e[33]=E,e[34]=A,e[35]=R):R=e[35];let z=R,B;e[36]===d?B=e[37]:(B=e=>d(je(e)),e[36]=d,e[37]=B);let V=B,te=Dr;if(!Tr(h)){let t;return e[38]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(o,{to:je(`models`),replace:!0}),e[38]=t):t=e[38],t}let ne=r.nav.settingsCapabilities,re=l.subtitle,H;e[39]===t?H=e[40]:(H=Xe(t,`configuration`),e[39]=t,e[40]=H);let U;e[41]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(he,{className:`size-4`,"aria-hidden":!0}),e[41]=U):U=e[41];let W;e[42]===l.agentSettingsLink?W=e[43]:(W=(0,$.jsx)(G,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(s,{to:`/agents`,children:[U,l.agentSettingsLink]})}),e[42]=l.agentSettingsLink,e[43]=W);let ie;e[44]!==l.docsLink||e[45]!==l.subtitle||e[46]!==r.nav.settingsCapabilities||e[47]!==H||e[48]!==W?(ie=(0,$.jsx)(st,{title:ne,subtitle:re,docsLink:H,docsLabel:l.docsLink,actions:W}),e[44]=l.docsLink,e[45]=l.subtitle,e[46]=r.nav.settingsCapabilities,e[47]=H,e[48]=W,e[49]=ie):ie=e[49];let K;e[50]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(Et,{}),e[50]=K):K=e[50];let oe;e[51]!==l.tabsAria||e[52]!==h||e[53]!==z||e[54]!==V?(oe=(0,$.jsx)(Ct,{items:z,activeTab:h,onChange:V,ariaLabel:l.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}),e[51]=l.tabsAria,e[52]=h,e[53]=z,e[54]=V,e[55]=oe):oe=e[55];let q;e[56]!==l.connectedProviders||e[57]!==h||e[58]!==z?(q=z.map(e=>(0,$.jsx)(jr,{id:e.id,activeSection:h,hint:e.hint,children:e.id===`models`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wr,{}),(0,$.jsx)(ur,{labels:l.connectedProviders,onAdd:()=>v(!0),onManage:(e,t)=>b({providerId:e,isCustom:t})})]}):(0,$.jsx)(Ar,{section:e.id})},e.id)),e[56]=l.connectedProviders,e[57]=h,e[58]=z,e[59]=q):q=e[59];let se;e[60]!==_||e[61]!==l.addProviderDialog||e[62]!==t||e[63]!==x.builtinRows||e[64]!==x.customConfig?(se=(0,$.jsx)(Zn,{open:_,onOpenChange:v,builtinRows:x.builtinRows,customConfig:x.customConfig,labels:l.addProviderDialog,language:t,onSaved:te}),e[60]=_,e[61]=l.addProviderDialog,e[62]=t,e[63]=x.builtinRows,e[64]=x.customConfig,e[65]=se):se=e[65];let le;e[66]!==l.manageProviderDialog||e[67]!==t||e[68]!==y||e[69]!==x.allModels||e[70]!==x.builtinRows||e[71]!==x.customConfig?(le=y?(0,$.jsx)(br,{open:!0,onOpenChange:e=>{e||b(null)},providerId:y.providerId,isCustom:y.isCustom,builtinRows:x.builtinRows,customConfig:x.customConfig,allModels:x.allModels,labels:l.manageProviderDialog,language:t,onSaved:te}):null,e[66]=l.manageProviderDialog,e[67]=t,e[68]=y,e[69]=x.allModels,e[70]=x.builtinRows,e[71]=x.customConfig,e[72]=le):le=e[72];let ue;return e[73]!==ie||e[74]!==oe||e[75]!==q||e[76]!==se||e[77]!==le?(ue=(0,$.jsxs)(ct,{children:[ie,K,oe,q,se,le]}),e[73]=ie,e[74]=oe,e[75]=q,e[76]=se,e[77]=le,e[78]=ue):ue=e[78],ue}function Dr(){Se()}function Or(e){return e.sections}function kr(e){return e.language}function Ar(e){let t=(0,Q.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)(Kt,{}),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)(Kn,{}),t[2]=e):e=t[2],e}}}function jr({id:e,activeSection:t,hint:n,children:r}){let i=e===t,a=(0,Z.useRef)(i);return i&&(a.current=!0),a.current?(0,$.jsxs)(`div`,{role:`tabpanel`,id:`capability-panel-${e}`,"aria-labelledby":`capability-tab-${e}`,hidden:!i,className:l(`min-w-0 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,i?`flex flex-col gap-3`:void 0),children:[i?(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{Er as CapabilitiesSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,s as t}from"./locale-store-tnRLWdx2.js";var n=[{key:`code-intelligence`,toolIds:[`code_search`,`code_read_symbol`,`code_trace`,`code_impact`,`code_architecture`]},{key:`workspace`,toolIds:[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`exec_command`,`execute_code`]},{key:`messaging`,toolIds:[`send_message`,`send_media`,`text_to_speech`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`,`read_media`,`create_share`]},{key:`web`,toolIds:[`web_search`,`web_fetch`,`web_extract`,`browser_use`]},{key:`misc`,toolIds:[`session_status`,`dreaming`,`tool_manual`,`clarify`,`todo`,`update_plan`,`automation`,`workflow`,`delegate_task`]},{key:`unknown`,toolIds:[`skills_list`,`skill_view`,`skill_manage`]},{key:`extensions`,toolIds:[`extensions`]},{key:`mcp`,toolIds:[`bundle-mcp`]}],r=new Set(n.flatMap(e=>[...e.toolIds].map(e=>String(e))));function i(e){return e.filter(e=>e&&!r.has(e)).sort((e,t)=>e.localeCompare(t))}async function a(){let n=await t(e(`/api/capability-presets`));if(!Array.isArray(n.payload?.presets)||typeof n.payload.defaultPresetId!=`string`||!Array.isArray(n.payload.agents)||!Array.isArray(n.payload.builtinToolIds))throw Error(`Invalid /api/capability-presets response`);return n.payload}async function o(n){let r=await t(e(`/api/capability-presets`),{method:`POST`,body:JSON.stringify(n)}),i=r.payload?.presetId,a=r.payload?.presets;if(!i||!a||typeof a.defaultPresetId!=`string`||!Array.isArray(a.presets)||!Array.isArray(a.agents)||!Array.isArray(a.builtinToolIds))throw Error(`Invalid create capability preset response`);return{presetId:i,presets:a}}async function s(n,r){let i=await t(e(`/api/capability-presets/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(r)});if(!Array.isArray(i.payload?.presets)||typeof i.payload.defaultPresetId!=`string`||!Array.isArray(i.payload.agents)||!Array.isArray(i.payload.builtinToolIds))throw Error(`Invalid update capability preset response`);return i.payload}async function c(n){let r=await t(e(`/api/capability-presets/${encodeURIComponent(n)}`),{method:`DELETE`});if(!Array.isArray(r.payload?.presets)||typeof r.payload.defaultPresetId!=`string`||!Array.isArray(r.payload.agents)||!Array.isArray(r.payload.builtinToolIds))throw Error(`Invalid delete capability preset response`);return r.payload}export{n as a,s as i,c as n,i as o,a as r,o as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
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,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-B1EG4gdu.js";import{l as c,n as l}from"./locale-store-tnRLWdx2.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$l as d,Ac as f,Es as p,Fu as m,Gl as h,Go as g,Gr as _,Is as v,It as y,Jo as b,Ko as x,Ls as S,Nc as C,Ns as w,Nu as T,Ou as E,Sc as D,Uo as O,Wo as k,Yo as A,Ys as j,_l as M,as as N,cs as P,dc as F,ls as I,ms as L,os as ee,ps as R,qo as z,rl as B,yu as te}from"./index-B24B26og.js";import{n as V,r as H}from"./settings-page-layout-CtESNNdx.js";import{n as ne,r as re}from"./settings-loading-skeleton-Q_Vh6HEl.js";import{n as ie,t as ae}from"./settings-form-section-Bb6yYt5f.js";import{a as oe,i as se,n as ce,o as le,r as ue,t as de}from"./capability-presets-api-DdCHSzcA.js";import{a as fe,i as pe,o as U,s as W,t as G}from"./typed-models-lib-5xRRUE9Y.js";var K=n(),q=e(t(),1),J=r(),me=[`deep`,`fast`,`cheap`,`code`,`review`];function he(e){return me.includes(e)}function ge(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:a,labels:o}=e,s=(0,q.useRef)([]),c=(0,q.useRef)(0);for(;s.current.length<t.length;)s.current.push(`preset-model-row-${c.current++}`);s.current.length>t.length&&(s.current.length=t.length);let l=i??(t.some(e=>e.id===`deep`)?`deep`:t[0]?.id)??`deep`,u=t.findIndex(e=>e.id===l),d=u>=0?t[u]:void 0,f=t.map((e,t)=>({row:e,index:t})).filter(({index:e})=>e!==u),p=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},m=e=>{if(u>=0){p(u,{model:e});return}s.current.unshift(`preset-model-row-${c.current++}`),n([{id:l,model:e,fallbacks:[],description:he(l)?o.roleDescriptions[l]:``},...t])},h=e=>{let n=t[e];n&&p(e,{fallbacks:[...n.fallbacks??[],``]})},g=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,p(e,{fallbacks:a})},_=(e,n)=>{let r=t[e];r&&p(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},v=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},b=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:he(r)?o.roleDescriptions[r]:``}])},x=[...me.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],S=(e,t)=>(0,J.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.fallbackModels}),(0,J.jsxs)(w,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>h(t),children:[(0,J.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),o.addFallback]})]}),(e.fallbacks??[]).length>0?(0,J.jsx)(`div`,{className:`grid gap-1.5`,children:(e.fallbacks??[]).map((e,n)=>(0,J.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,J.jsx)(y,{value:e,disabled:r,placeholder:o.fallbackPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>g(t,n,e)}),(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>_(t,n),children:(0,J.jsx)(j,{className:`size-4`,"aria-hidden":!0})})]},`${s.current[t]}-fallback-${n}`))}):(0,J.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.fallbackEmptyHint})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-fg-muted`,children:[o.description,(0,J.jsx)(`input`,{type:`text`,className:W(),value:e.description,disabled:r,placeholder:o.descriptionPlaceholder,onChange:e=>p(t,{description:e.target.value})})]})]});return(0,J.jsxs)(`div`,{className:`grid gap-5`,children:[(0,J.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.defaultTitle}),(0,J.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:o.defaultBadge})]}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.defaultHint})]}),(0,J.jsxs)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 font-mono text-[11px] text-fg-subtle`,children:[o.roleId,`: `,l]})]}),(0,J.jsxs)(`div`,{className:`mt-4 grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.primaryModel}),(0,J.jsx)(y,{value:d?.model??``,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:m})]}),d?(0,J.jsxs)(`details`,{className:`group mt-3`,children:[(0,J.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-md text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,J.jsx)(te,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,J.jsx)(`div`,{className:`mt-3`,children:S(d,u)})]}):null]}),(0,J.jsxs)(`section`,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.otherRolesTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.otherRolesHint})]}),f.length>0?(0,J.jsx)(`div`,{className:`mt-3 grid gap-2`,children:f.map(({row:e,index:t})=>{let n=he(e.id)?e.id:void 0;return(0,J.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 p-3 dark:border-edge`,children:[(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)] md:items-end`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n?o.roleNames[n]:o.customRole}),n?(0,J.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:e.id}):(0,J.jsxs)(`label`,{className:`mt-1 grid gap-1 text-[11px] text-fg-muted`,children:[o.roleId,(0,J.jsx)(`input`,{type:`text`,className:W(),value:e.id,disabled:r,placeholder:o.roleIdPlaceholder,onChange:e=>p(t,{id:e.target.value.toLowerCase()})})]})]}),(0,J.jsxs)(`label`,{className:`grid min-w-0 gap-1.5 text-xs font-medium text-fg-muted`,children:[o.primaryModel,(0,J.jsx)(y,{value:e.model,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>p(t,{model:e})})]})]}),(0,J.jsxs)(`details`,{className:`group mt-3`,children:[(0,J.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,J.jsx)(te,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,J.jsxs)(`div`,{className:`mt-3`,children:[S(e,t),(0,J.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,J.jsxs)(w,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>v(t),children:[(0,J.jsx)(j,{className:`size-4`,"aria-hidden":!0}),o.removeRole]})})]})]})]},s.current[t])})}):(0,J.jsx)(`p`,{className:`mt-3 rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:o.otherRolesEmpty}),(0,J.jsx)(N,{value:``,options:x,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:b})]})]})}function _e(e){let t=(0,K.c)(34),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===c.inheritanceTitle?d=t[3]:(d=(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,J.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,J.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,J.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,J.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(0,J.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,J.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,J.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,J.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,J.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function Y(e){return e.name||e.directoryId}function ve(e){let t=(0,K.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(Y).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,J.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=_);let v;t[8]===h?v=t[9]:(v=(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=v);let y;t[10]!==_||t[11]!==v?(y=(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]===u.modeLabel?b=t[14]:(b=(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=b);let x;t[15]===u.modeInherit?x=t[16]:(x=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=x);let S;t[17]===u.modeAll?S=t[18]:(S=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=S);let C;t[19]===u.modeAllowlist?C=t[20]:(C=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=C);let T;t[21]===u.modeDenylist?T=t[22]:(T=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=T);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==T||t[26]!==D||t[27]!==x||t[28]!==S||t[29]!==C?(O=[x,S,C,T,D],t[25]=T,t[26]=D,t[27]=x,t[28]=S,t[29]=C,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,J.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==b?(j=(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,A]}),t[36]=A,t[37]=b,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==d||t[50]!==r?(M=d?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,J.jsx)(re,{rows:3}):i.length===0?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=Y(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,J.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,J.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,J.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,J.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=d,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==y?(N=(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,j,M]}),t[52]=j,t[53]=M,t[54]=y,t[55]=N):N=t[55],N}var ye=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],be=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],X=[`send_message`,`send_media`,`text_to_speech`,`create_share`],xe=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Se=[...ye,...X],Ce=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],we=[`send_message`,`send_media`];function Te(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function Ee(e){let t=(0,K.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==r?(f=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(De),t[2]=d,t[3]=r,t[4]=f):f=t[4];let p=f,m;if(t[5]!==d||t[6]!==n){m=[];for(let e of oe){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&m.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=le(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),m.push(e)}t[5]=d,t[6]=n,t[7]=m}else m=t[7];let h=m,g;t[12]!==i||t[13]!==r?(g=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=g):g=t[14];let _=g,v;t[15]!==i||t[16]!==r?(v=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=v):v=t[17];let y=v,b;t[18]!==d||t[19]!==i?(b=e=>{i(Te(d,e))},t[18]=d,t[19]=i,t[20]=b):b=t[20];let x=b;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let S;t[23]===l.quickActionsLabel?S=t[24]:(S=(0,J.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=S);let C;t[25]===i?C=t[26]:(C=()=>i({}),t[25]=i,t[26]=C);let T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==C?(T=(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:a,onClick:C,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=C,t[30]=T):T=t[30];let E;t[31]===x?E=t[32]:(E=()=>x([[ye,`deny`]]),t[31]=x,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:a,onClick:E,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=E,t[36]=D):D=t[36];let O;t[37]===x?O=t[38]:(O=()=>x([[be,`deny`]]),t[37]=x,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:a,onClick:O,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=O,t[42]=k):k=t[42];let A;t[43]===x?A=t[44]:(A=()=>x([[X,`deny`]]),t[43]=x,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:a,onClick:A,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=A,t[48]=j):j=t[48];let M;t[49]===x?M=t[50]:(M=()=>x([[xe,`allow`],[Se,`deny`]]),t[49]=x,t[50]=M);let N;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==M?(N=(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:a,onClick:M,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=M,t[54]=N):N=t[54];let F;t[55]===x?F=t[56]:(F=()=>x([[Ce,`allow`],[we,`deny`]]),t[55]=x,t[56]=F);let I;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==F?(I=(0,J.jsx)(w,{type:`button`,variant:`secondary`,className:U,disabled:a,onClick:F,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=F,t[60]=I):I=t[60];let L;t[61]!==k||t[62]!==j||t[63]!==N||t[64]!==I||t[65]!==T||t[66]!==D?(L=(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,N,I]}),t[61]=k,t[62]=j,t[63]=N,t[64]=I,t[65]=T,t[66]=D,t[67]=L):L=t[67];let R;t[68]!==L||t[69]!==S?(R=(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,L]}),t[68]=L,t[69]=S,t[70]=R):R=t[70];let z;t[71]===l.overrideSummaryTitle?z=t[72]:(z=(0,J.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=z);let B;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==p?(B=p.length>0?(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,J.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,J.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=p,t[78]=B):B=t[78];let te;t[79]!==z||t[80]!==B?(te=(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[z,B]}),t[79]=z,t[80]=B,t[81]=te):te=t[81];let V;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==h||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==_||t[98]!==r||t[99]!==y?(V=(0,J.jsx)(`div`,{className:`flex flex-col gap-5`,children:h.map(e=>{let{key:t,ids:n}=e;return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,J.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,J.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,J.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>_(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,J.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,J.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,J.jsxs)(ee,{value:n.scope??``,disabled:a,onChange:t=>y(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,J.jsx)(P,{value:``,children:l.scopeInherit}),(0,J.jsx)(P,{value:`readonly`,children:l.scopeReadonly}),(0,J.jsx)(P,{value:`workspace`,children:l.scopeWorkspace}),(0,J.jsx)(P,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,J.jsx)(ke,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>y(e,e=>Oe(e,`maxCallsPerTurn`,t))}),(0,J.jsx)(ke,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>y(e,e=>Oe(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=h,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=_,t[98]=r,t[99]=y,t[100]=V):V=t[100];let H;return t[101]!==R||t[102]!==te||t[103]!==V?(H=(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[R,te,V]}),t[101]=R,t[102]=te,t[103]=V,t[104]=H):H=t[104],H}function De(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function Oe(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function ke(e){let t=(0,K.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,J.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,J.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Ae=[`blank`,`safe-coder`,`read-only`,`low-cost`],je=[{id:`overview`,icon:d},{id:`models`,icon:M},{id:`tools`,icon:S},{id:`skills`,icon:f},{id:`advanced`,icon:F},{id:`impact`,icon:h}];function Me(e){return pe(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Ne(e){return structuredClone(e?.tools?.builtin??{})}function Z(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Pe(){return{primary:``,fallbacks:``,timeoutMs:``,autoProviderFallback:``}}function Fe(e){return{primary:e?.primary??``,fallbacks:e?.fallbacks?.join(`
|
|
2
|
+
`)??``,timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function Ie(){return{imageModel:Pe(),imageGenerationModel:Pe(),allowFallbacks:``,maxCostTier:``}}function Q(e){return{imageModel:Fe(e?.models?.imageModel),imageGenerationModel:Fe(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function $(e){return e===void 0?``:JSON.stringify(e,null,2)}function Le(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Re(e){return{mcp:$(e?.tools?.mcp),workflows:$(e?.workflows),boundaries:$(e?.boundaries),runtime:$(e?.runtime),locks:$(e?.locks)}}function ze(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Me(e),modelAdvanced:Q(e),toolPolicies:Ne(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Z(e),extendsIds:[...e?.extends??[]],jsonFields:Re(e)}}function Be(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function Ve(e,t){let n=G(e.modelRows),r=Be(e.modelAdvanced.imageModel),i=Be(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function He(e){return e.trim()?JSON.parse(e):void 0}function Ue(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function We(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=He(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Ge(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Ke(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function qe(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:Ve(e,t),tools:{builtin:Ge(e.toolPolicies),mcp:Ue(e.jsonFields.mcp)},skills:Ke(e),extends:[...e.extendsIds].toSorted(),workflows:Ue(e.jsonFields.workflows),boundaries:Ue(e.jsonFields.boundaries),runtime:Ue(e.jsonFields.runtime),locks:Ue(e.jsonFields.locks)}}function Je(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Ge(e.tools?.builtin),mcp:Ue($(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:Ue($(e.workflows)),boundaries:Ue($(e.boundaries)),runtime:Ue($(e.runtime)),locks:Ue($(e.locks))}:null}function Ye(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function Xe(){return{modelAdvanced:Ie(),extendsIds:[],jsonFields:Le()}}function Ze(e,t){return{extends:[...e.extendsIds],models:Ve(e,t)??void 0,tools:We(e)??void 0,skills:Ke(e)??void 0,workflows:He(e.jsonFields.workflows),boundaries:He(e.jsonFields.boundaries),runtime:He(e.jsonFields.runtime),locks:He(e.jsonFields.locks)}}function Qe(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...Xe()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...Xe()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...Xe()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...Xe()}}function $e(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,J.jsx)(w,{asChild:!0,type:`button`,variant:`secondary`,children:(0,J.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,J.jsx)(T,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:y,error:E,isLoading:N,mutate:P}=u(r?`settings-capability-presets`:null,ue,{revalidateOnFocus:!1}),{data:ee=[],isLoading:te}=u(r?`settings-capability-presets-skills-catalog`:null,_,{revalidateOnFocus:!1}),[re,oe]=i(),[le,pe]=(0,q.useState)(``),[U,W]=(0,q.useState)(`overview`),[G,K]=(0,q.useState)(()=>Qe(`blank`,t)),[me,he]=(0,q.useState)(null),[Y,ye]=(0,q.useState)(!1),[be,X]=(0,q.useState)(null),[xe,Se]=(0,q.useState)(!1),[Ce,we]=(0,q.useState)(null),[Te,De]=(0,q.useState)(null),Oe=y?.presets??[],ke=y?.defaultPresetId??`default`,Me=Oe.find(e=>e.id===ke)??null,Ne=Oe.filter(e=>e.id!==ke),Z=(0,q.useMemo)(()=>Oe.find(e=>e.id===le)??Oe[0]??null,[Oe,le]),Pe=!Z||G.id.trim()!==Z.id,Fe=!!(Z&&Z.id===ke),Ie=JSON.stringify(qe(G,Z))!==JSON.stringify(Je(Z)),Q=qe(G,Z),$=Je(Z),Le=[Q.id!==$?.id||Q.name!==$?.name||Q.description!==$?.description?t.tabs.overview:``,JSON.stringify(Q.models)===JSON.stringify($?.models)?``:t.tabs.models,JSON.stringify(Q.tools)===JSON.stringify($?.tools)?``:t.tabs.tools,JSON.stringify(Q.skills)===JSON.stringify($?.skills)?``:t.tabs.skills,JSON.stringify({extends:Q.extends,workflows:Q.workflows,boundaries:Q.boundaries,runtime:Q.runtime,locks:Q.locks})===JSON.stringify({extends:$?.extends,workflows:$?.workflows,boundaries:$?.boundaries,runtime:$?.runtime,locks:$?.locks})?``:t.tabs.advanced].filter(Boolean),Re=be??(E instanceof Error?E.message:null),Be=re.get(`action`)===`new`||!!re.get(`preset`),Ve=re.get(`action`)===`new`&&me===null,Ue=Pe?t.newPreset:Z?.name??t.editorTitle,We=t=>e.agentsSettings.toolsDisableGroups[t],Ge=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,q.useEffect)(()=>{if(!y||Y)return;if(re.get(`action`)===`new`){pe(``),K(Qe(`blank`,t)),W(`overview`);return}let e=re.get(`preset`)?.trim(),n=e?y.presets.find(t=>t.id===e):null;if(n){pe(n.id),K(ze(n)),W(re.get(`tab`)??`overview`);return}Z&&(pe(Z.id),K(e=>e.id===Z.id?e:ze(Z)))},[Y,y,re,Z]);function Ke(e){he(null),pe(e.id),K(ze(e)),oe({preset:e.id},{replace:!0}),W(`overview`)}function Xe(){he(null),pe(``),K(Qe(`blank`,t)),X(null),oe({action:`new`},{replace:!0}),W(`overview`)}function $e(e){he(e),K(Qe(e,t)),X(null),W(`overview`)}function nt(){if(me){let e=Qe(me,t);if(JSON.stringify(qe(G,null))!==JSON.stringify(qe(e,null))&&!window.confirm(t.changeTemplateConfirm))return}he(null),X(null)}function rt(){!Ve&&Ie&&!window.confirm(t.discardConfirm)||(Se(!1),we(null),oe({},{replace:!0}),he(null),X(null),K(ze(Z)),W(`overview`))}async function it(){let e=fe(G.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){X(e),W(`models`);return}for(let e of[G.modelAdvanced.imageModel,G.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks.split(/\r?\n|,/)].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){X(t.invalidModelRef),W(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){X(t.advancedPositiveIntegerError),W(`models`);return}}for(let e of Object.values(G.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){X(t.advancedPositiveIntegerError),W(`tools`);return}for(let e of Object.keys(G.jsonFields))try{He(G.jsonFields[e])}catch{X(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),W(`advanced`);return}ye(!0),X(null);try{let e=Ze(G,Z);if(Pe){let t=await de({id:G.id.trim(),name:G.name.trim(),...G.description.trim()?{description:G.description.trim()}:{},...e});await P(t.presets,{revalidate:!1}),pe(t.presetId),he(null),oe({preset:t.presetId},{replace:!0})}else Z&&await P(await se(Z.id,{name:G.name.trim(),description:G.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){X(e instanceof Error?e.message:t.saveError)}finally{ye(!1)}}async function at(){if(Z){ye(!0),X(null),we(null);try{await P(await ce(Z.id),{revalidate:!1}),Se(!1),pe(``),he(null),K(Qe(`blank`,t)),W(`overview`),oe({},{replace:!0})}catch(e){we(e instanceof Error?e.message:t.deleteError)}finally{ye(!1)}}}return r?(0,J.jsxs)(H,{gap:`gap-5`,className:`pb-24`,children:[(0,J.jsx)(V,{title:t.title,subtitle:t.subtitle,actions:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n,(0,J.jsxs)(w,{type:`button`,onClick:Xe,disabled:Y,children:[(0,J.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Re?(0,J.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Re}):null,N?(0,J.jsx)(ne,{sections:2}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Me?(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:M,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Ke(Me),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Me.name}),(0,J.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,J.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Me.id})]}),(0,J.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Me.description?(0,J.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Me.description}):null,(0,J.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Ye(Me,t)})]})]}):null,(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:M,title:t.listTitle,subtitle:t.listHint}),Ne.length===0?(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:[(0,J.jsx)(`p`,{children:t.empty}),(0,J.jsxs)(w,{type:`button`,variant:`secondary`,onClick:Xe,disabled:Y,children:[(0,J.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]}):(0,J.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Ne.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Ke(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,J.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,J.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,J.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,J.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:Ye(e,t)})]},e.id))})]})]}),(0,J.jsx)(O,{open:Be,onOpenChange:e=>{e||rt()},children:(0,J.jsxs)(b,{children:[(0,J.jsx)(z,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,L)}),(0,J.jsx)(g,{ref:De,className:o(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,R),onOpenAutoFocus:e=>e.preventDefault(),children:(0,J.jsxs)(I,{layer:`modal`,portalContainer:Te,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[!Ve&&Pe&&me?(0,J.jsx)(`button`,{type:`button`,className:o(p,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:nt,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,J.jsx)(m,{className:`size-4`,"aria-hidden":!0})}):null,(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(A,{className:`truncate text-base font-semibold text-fg`,children:Ue}),(0,J.jsx)(x,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ve?t.templatePickerSubtitle:Pe&&me?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[me].title)}`:Pe?t.editorHint:G.id})]})]}),(0,J.jsx)(k,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:o(p,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,J.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),Ve?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-5`,children:(0,J.jsx)(`div`,{className:`mx-auto grid max-w-3xl gap-3 sm:grid-cols-2`,children:Ae.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`group min-h-32 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>$e(e),children:[(0,J.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),e===`blank`?(0,J.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.templateRecommended}):null]}),(0,J.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})}),(0,J.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,J.jsx)(w,{type:`button`,variant:`secondary`,onClick:rt,children:t.cancel})})]}):(0,J.jsxs)(J.Fragment,{children:[Re?(0,J.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Re}):null,(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:je.map(({id:e,icon:n})=>(0,J.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,U===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>W(e),children:[(0,J.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,J.jsxs)(`div`,{className:`w-full`,children:[U===`overview`?(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:d,title:t.overviewTitle,subtitle:t.overviewHint}),(0,J.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,J.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:G.id,disabled:Y||!Pe,onChange:e=>K(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Pe&&Z?(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,J.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String(Z.version))})]}):null,(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,J.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:G.name,disabled:Y,onChange:e=>K(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,J.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:G.description,disabled:Y,onChange:e=>K(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,J.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,J.jsx)(et,{icon:M,label:t.modelsTitle,value:String(G.modelRows.length)}),(0,J.jsx)(et,{icon:S,label:t.toolsTitle,value:String(Object.keys(G.toolPolicies).length)}),(0,J.jsx)(et,{icon:f,label:t.skillsTitle,value:t.skillModeLabels[G.skillMode]})]})]}):null,U===`models`?(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:M,title:t.modelsTitle,subtitle:t.modelsHint}),(0,J.jsx)(ge,{rows:G.modelRows,onChange:e=>K(t=>({...t,modelRows:e})),disabled:Y,defaultRole:Z?.models?.defaultRole,chat:e.chat,labels:{defaultTitle:t.modelDefaultTitle,defaultHint:t.modelDefaultHint,defaultBadge:t.modelDefaultBadge,roleId:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,moreSettings:t.modelMoreSettings,otherRolesTitle:t.modelOtherRolesTitle,otherRolesHint:t.modelOtherRolesHint,otherRolesEmpty:t.modelOtherRolesEmpty,addTaskModel:t.modelAddTaskModel,customRole:t.modelCustomRole,removeRole:t.removeModelRole,roleIdPlaceholder:`custom-role`,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,J.jsx)(tt,{value:G.modelAdvanced,onChange:e=>K(t=>({...t,modelAdvanced:e})),disabled:Y,cp:t})]}):null,U===`tools`?(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:S,title:t.toolsTitle,subtitle:t.toolsHint}),(0,J.jsx)(Ee,{builtinToolIds:y?.builtinToolIds??[],toolPolicies:G.toolPolicies,onChange:e=>K(t=>({...t,toolPolicies:e})),disabled:Y,getToolDescription:Ge,getGroupTitle:We,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,U===`skills`?(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:f,title:t.skillsTitle,subtitle:t.skillsHint}),(0,J.jsx)(ve,{mode:G.skillMode,selected:G.skillPick,catalog:ee,loading:te,disabled:Y,onModeChange:e=>K(t=>({...t,skillMode:e})),onSelectedChange:e=>K(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,U===`advanced`?(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:F,title:t.advancedTitle,subtitle:t.advancedHint}),(0,J.jsx)(_e,{extendsIds:G.extendsIds,onExtendsChange:e=>K(t=>({...t,extendsIds:e})),presetOptions:Oe.filter(e=>e.id!==Z?.id&&e.id!==ke),jsonFields:G.jsonFields,onJsonFieldsChange:e=>K(t=>({...t,jsonFields:e})),disabled:Y,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,U===`impact`?(0,J.jsxs)(ae,{children:[(0,J.jsx)(ie,{icon:h,title:t.usageTitle,subtitle:t.usageHint}),(0,J.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Le.length>0?t.changePreviewSections.replace(`{{sections}}`,Le.join(`、`)):t.changePreviewEmpty})]}),Z?.usage.length?(0,J.jsx)(`div`,{className:`grid gap-2`,children:Z.usage.map(e=>(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,J.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,J.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,J.jsx)(`div`,{className:`font-medium text-fg`,children:Ie?t.unsavedTitle:t.noUnsavedTitle}),(0,J.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ie?(Z?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String(Z?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ie?(0,J.jsx)(w,{type:`button`,variant:`secondary`,disabled:Y,onClick:()=>K(ze(Z)),children:t.discard}):null,Z&&!Fe?(0,J.jsxs)(w,{type:`button`,variant:`secondary`,disabled:Y,onClick:()=>{we(null),Se(!0)},children:[(0,J.jsx)(j,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,J.jsxs)(w,{type:`button`,disabled:Y||!G.id.trim()||!G.name.trim()||!Ie,onClick:()=>void it(),children:[(0,J.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,J.jsx)(O,{open:xe,onOpenChange:e=>{Y||(Se(e),e||we(null))},children:(0,J.jsxs)(b,{children:[(0,J.jsx)(z,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,L)}),(0,J.jsxs)(g,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,R),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,J.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,J.jsx)(A,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,J.jsx)(x,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:Z?t.deleteConfirm.replace(`{{name}}`,Z.name):t.deleteConfirmFallback})]}),Ce?(0,J.jsx)(`div`,{className:`mx-4 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Ce}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,J.jsx)(w,{type:`button`,variant:`secondary`,disabled:Y,onClick:()=>Se(!1),children:t.cancel}),(0,J.jsxs)(w,{type:`button`,disabled:Y||!Z,className:`bg-red-600 text-white shadow-surface hover:bg-red-700 focus-visible:ring-red-600 dark:bg-red-500 dark:hover:bg-red-600`,onClick:()=>void at(),children:[Y?(0,J.jsx)(B,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(j,{className:`size-4`,"aria-hidden":!0}),Y?t.deleting:t.delete]})]})]})]})})]}):(0,J.jsxs)(H,{gap:`gap-3`,children:[(0,J.jsx)(V,{title:t.title,actions:n}),(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function et(e){let t=(0,K.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,J.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,J.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function tt(e){let t=(0,K.c)(102),{value:n,onChange:r,disabled:i,cp:a}=e,o;t[0]!==r||t[1]!==n?(o=(e,t)=>{r({...n,[e]:t})},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]===a.modelSpecializedTitle?c=t[4]:(c=(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelSpecializedTitle}),t[3]=a.modelSpecializedTitle,t[4]=c);let l;t[5]!==a.modelNotSet||t[6]!==a.modelSpecializedSummary||t[7]!==n.imageGenerationModel.primary||t[8]!==n.imageModel.primary?(l=a.modelSpecializedSummary.replace(`{{image}}`,n.imageModel.primary||a.modelNotSet).replace(`{{generation}}`,n.imageGenerationModel.primary||a.modelNotSet),t[5]=a.modelNotSet,t[6]=a.modelSpecializedSummary,t[7]=n.imageGenerationModel.primary,t[8]=n.imageModel.primary,t[9]=l):l=t[9];let u;t[10]===l?u=t[11]:(u=(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:l}),t[10]=l,t[11]=u);let d;t[12]!==c||t[13]!==u?(d=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[c,u]}),t[12]=c,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,J.jsx)(te,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[15]=f):f=t[15];let p;t[16]===d?p=t[17]:(p=(0,J.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[d,f]}),t[16]=d,t[17]=p);let m;t[18]===s?m=t[19]:(m=e=>s(`imageModel`,e),t[18]=s,t[19]=m);let h;t[20]!==a||t[21]!==i||t[22]!==m||t[23]!==n.imageModel?(h=(0,J.jsx)(nt,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:m,disabled:i,cp:a}),t[20]=a,t[21]=i,t[22]=m,t[23]=n.imageModel,t[24]=h):h=t[24];let g;t[25]===s?g=t[26]:(g=e=>s(`imageGenerationModel`,e),t[25]=s,t[26]=g);let _;t[27]!==a||t[28]!==i||t[29]!==g||t[30]!==n.imageGenerationModel?(_=(0,J.jsx)(nt,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:g,disabled:i,cp:a}),t[27]=a,t[28]=i,t[29]=g,t[30]=n.imageGenerationModel,t[31]=_):_=t[31];let v;t[32]!==_||t[33]!==h?(v=(0,J.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge lg:grid-cols-2`,children:[h,_]}),t[32]=_,t[33]=h,t[34]=v):v=t[34];let y;t[35]!==v||t[36]!==p?(y=(0,J.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[p,v]}),t[35]=v,t[36]=p,t[37]=y):y=t[37];let b;t[38]===a.modelAdvancedTitle?b=t[39]:(b=(0,J.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[38]=a.modelAdvancedTitle,t[39]=b);let x;t[40]===a.modelAdvancedHint?x=t[41]:(x=(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[40]=a.modelAdvancedHint,t[41]=x);let S;t[42]!==b||t[43]!==x?(S=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[b,x]}),t[42]=b,t[43]=x,t[44]=S):S=t[44];let C;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,J.jsx)(te,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[45]=C):C=t[45];let w;t[46]===S?w=t[47]:(w=(0,J.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[S,C]}),t[46]=S,t[47]=w);let T;t[48]===a.modelAllowFallbacksLabel?T=t[49]:(T=(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[48]=a.modelAllowFallbacksLabel,t[49]=T);let E;t[50]!==r||t[51]!==n?(E=e=>r({...n,allowFallbacks:e.target.value}),t[50]=r,t[51]=n,t[52]=E):E=t[52];let D;t[53]===a.policyInherit?D=t[54]:(D=(0,J.jsx)(P,{value:``,children:a.policyInherit}),t[53]=a.policyInherit,t[54]=D);let O;t[55]===a.policyEnabled?O=t[56]:(O=(0,J.jsx)(P,{value:`true`,children:a.policyEnabled}),t[55]=a.policyEnabled,t[56]=O);let k;t[57]===a.policyDisabled?k=t[58]:(k=(0,J.jsx)(P,{value:`false`,children:a.policyDisabled}),t[57]=a.policyDisabled,t[58]=k);let A;t[59]!==i||t[60]!==E||t[61]!==D||t[62]!==O||t[63]!==k||t[64]!==n.allowFallbacks?(A=(0,J.jsxs)(ee,{value:n.allowFallbacks,disabled:i,onChange:E,children:[D,O,k]}),t[59]=i,t[60]=E,t[61]=D,t[62]=O,t[63]=k,t[64]=n.allowFallbacks,t[65]=A):A=t[65];let j;t[66]!==T||t[67]!==A?(j=(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[T,A]}),t[66]=T,t[67]=A,t[68]=j):j=t[68];let M;t[69]===a.modelMaxCostTierLabel?M=t[70]:(M=(0,J.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[69]=a.modelMaxCostTierLabel,t[70]=M);let N;t[71]!==r||t[72]!==n?(N=e=>r({...n,maxCostTier:e.target.value}),t[71]=r,t[72]=n,t[73]=N):N=t[73];let F;t[74]===a.policyInherit?F=t[75]:(F=(0,J.jsx)(P,{value:``,children:a.policyInherit}),t[74]=a.policyInherit,t[75]=F);let I;t[76]===a.costTierLow?I=t[77]:(I=(0,J.jsx)(P,{value:`low`,children:a.costTierLow}),t[76]=a.costTierLow,t[77]=I);let L;t[78]===a.costTierMedium?L=t[79]:(L=(0,J.jsx)(P,{value:`medium`,children:a.costTierMedium}),t[78]=a.costTierMedium,t[79]=L);let R;t[80]===a.costTierHigh?R=t[81]:(R=(0,J.jsx)(P,{value:`high`,children:a.costTierHigh}),t[80]=a.costTierHigh,t[81]=R);let z;t[82]!==i||t[83]!==N||t[84]!==F||t[85]!==I||t[86]!==L||t[87]!==R||t[88]!==n.maxCostTier?(z=(0,J.jsxs)(ee,{value:n.maxCostTier,disabled:i,onChange:N,children:[F,I,L,R]}),t[82]=i,t[83]=N,t[84]=F,t[85]=I,t[86]=L,t[87]=R,t[88]=n.maxCostTier,t[89]=z):z=t[89];let B;t[90]!==M||t[91]!==z?(B=(0,J.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[M,z]}),t[90]=M,t[91]=z,t[92]=B):B=t[92];let V;t[93]!==j||t[94]!==B?(V=(0,J.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[j,B]}),t[93]=j,t[94]=B,t[95]=V):V=t[95];let H;t[96]!==w||t[97]!==V?(H=(0,J.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[w,V]}),t[96]=w,t[97]=V,t[98]=H):H=t[98];let ne;return t[99]!==y||t[100]!==H?(ne=(0,J.jsxs)(`div`,{className:`mt-5 grid gap-3 border-t border-edge-subtle pt-5 dark:border-edge`,children:[y,H]}),t[99]=y,t[100]=H,t[101]=ne):ne=t[101],ne}function nt(e){let t=(0,K.c)(69),{title:n,value:r,onChange:i,disabled:a,cp:s}=e,c;t[0]===n?c=t[1]:(c=(0,J.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=c);let l=r.primary||s.modelNotSet,u;t[2]===l?u=t[3]:(u=(0,J.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:l}),t[2]=l,t[3]=u);let d;t[4]!==c||t[5]!==u?(d=(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[c,u]}),t[4]=c,t[5]=u,t[6]=d):d=t[6];let f=s.modelToolPrimaryLabel,p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=o(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`font-mono text-xs`),t[7]=p):p=t[7];let m;t[8]!==i||t[9]!==r?(m=e=>i({...r,primary:e.target.value}),t[8]=i,t[9]=r,t[10]=m):m=t[10];let h;t[11]!==a||t[12]!==m||t[13]!==r.primary?(h=(0,J.jsx)(`input`,{className:p,value:r.primary,disabled:a,placeholder:`provider/model`,onChange:m}),t[11]=a,t[12]=m,t[13]=r.primary,t[14]=h):h=t[14];let g;t[15]!==s.modelToolPrimaryLabel||t[16]!==h?(g=(0,J.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[f,h]}),t[15]=s.modelToolPrimaryLabel,t[16]=h,t[17]=g):g=t[17];let _=s.modelToolFallbacksLabel,v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`min-h-20 resize-y font-mono text-xs`),t[18]=v):v=t[18];let y;t[19]!==i||t[20]!==r?(y=e=>i({...r,fallbacks:e.target.value}),t[19]=i,t[20]=r,t[21]=y):y=t[21];let b;t[22]!==s.modelToolFallbacksPlaceholder||t[23]!==a||t[24]!==y||t[25]!==r.fallbacks?(b=(0,J.jsx)(`textarea`,{className:v,value:r.fallbacks,disabled:a,placeholder:s.modelToolFallbacksPlaceholder,onChange:y}),t[22]=s.modelToolFallbacksPlaceholder,t[23]=a,t[24]=y,t[25]=r.fallbacks,t[26]=b):b=t[26];let x;t[27]!==s.modelToolFallbacksLabel||t[28]!==b?(x=(0,J.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[_,b]}),t[27]=s.modelToolFallbacksLabel,t[28]=b,t[29]=x):x=t[29];let S;t[30]!==i||t[31]!==r?(S=e=>i({...r,timeoutMs:e.target.value}),t[30]=i,t[31]=r,t[32]=S):S=t[32];let C;t[33]!==a||t[34]!==S||t[35]!==r.timeoutMs?(C=(0,J.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:a,onChange:S}),t[33]=a,t[34]=S,t[35]=r.timeoutMs,t[36]=C):C=t[36];let w;t[37]!==s.toolTimeoutLabel||t[38]!==C?(w=(0,J.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.toolTimeoutLabel,C]}),t[37]=s.toolTimeoutLabel,t[38]=C,t[39]=w):w=t[39];let T;t[40]!==i||t[41]!==r?(T=e=>i({...r,autoProviderFallback:e.target.value}),t[40]=i,t[41]=r,t[42]=T):T=t[42];let E;t[43]===s.policyInherit?E=t[44]:(E=(0,J.jsx)(P,{value:``,children:s.policyInherit}),t[43]=s.policyInherit,t[44]=E);let D;t[45]===s.policyEnabled?D=t[46]:(D=(0,J.jsx)(P,{value:`true`,children:s.policyEnabled}),t[45]=s.policyEnabled,t[46]=D);let O;t[47]===s.policyDisabled?O=t[48]:(O=(0,J.jsx)(P,{value:`false`,children:s.policyDisabled}),t[47]=s.policyDisabled,t[48]=O);let k;t[49]!==a||t[50]!==T||t[51]!==E||t[52]!==D||t[53]!==O||t[54]!==r.autoProviderFallback?(k=(0,J.jsxs)(ee,{value:r.autoProviderFallback,disabled:a,onChange:T,children:[E,D,O]}),t[49]=a,t[50]=T,t[51]=E,t[52]=D,t[53]=O,t[54]=r.autoProviderFallback,t[55]=k):k=t[55];let A;t[56]!==s.modelAutoProviderFallbackLabel||t[57]!==k?(A=(0,J.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.modelAutoProviderFallbackLabel,k]}),t[56]=s.modelAutoProviderFallbackLabel,t[57]=k,t[58]=A):A=t[58];let j;t[59]!==w||t[60]!==A?(j=(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[w,A]}),t[59]=w,t[60]=A,t[61]=j):j=t[61];let M;t[62]!==x||t[63]!==j||t[64]!==g?(M=(0,J.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[g,x,j]}),t[62]=x,t[63]=j,t[64]=g,t[65]=M):M=t[65];let N;return t[66]!==M||t[67]!==d?(N=(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[d,M]}),t[66]=M,t[67]=d,t[68]=N):N=t[68],N}export{$e as CapabilityPresetsSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-tnRLWdx2.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await t(e(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await t(e(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}export{i as n,a as r,r as t};
|