@nextclaw/ui 0.12.27 → 0.12.29

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/dist/assets/api-CKKNxbsy.js +15 -0
  3. package/dist/assets/{app-manager-provider-oYdeYPSv.js → app-manager-provider-BM1hziPv.js} +1 -1
  4. package/dist/assets/{channels-list-page-DkPvpAqc.js → channels-list-page-CQGbbPJz.js} +2 -2
  5. package/dist/assets/{chat-page-b7Zf32fF.js → chat-page-A5_heqOE.js} +1 -1
  6. package/dist/assets/{desktop-DVUbOWbR.js → desktop-CmIbyIrg.js} +1 -1
  7. package/dist/assets/{desktop-update-config-CP8dFYXK.js → desktop-update-config-jWt63bXG.js} +1 -1
  8. package/dist/assets/{dialog-BKo0RItd.js → dialog-DWZeMf9V.js} +1 -1
  9. package/dist/assets/{dist-CFiwgaLs.js → dist-DN-YM_0Y.js} +1 -1
  10. package/dist/assets/{es2015-BhznEEyJ.js → es2015-ZJ-nWL4L.js} +1 -1
  11. package/dist/assets/{index-DqJ3CYwi.js → index-zYi4W031.js} +3 -3
  12. package/dist/assets/{marketplace-page-BVqFjnEB.js → marketplace-page-BO74RmDP.js} +1 -1
  13. package/dist/assets/marketplace-page-DmeV1ihQ.js +1 -0
  14. package/dist/assets/mcp-marketplace-page-Bk3uY3No.js +1 -0
  15. package/dist/assets/{mcp-marketplace-page-BOYJO0kp.js → mcp-marketplace-page-CoTYEIEI.js} +1 -1
  16. package/dist/assets/{model-config-Bg2yycmn.js → model-config-Bzk1sqTS.js} +1 -1
  17. package/dist/assets/{notice-card-Dr6xCwva.js → notice-card-BM2_YNoc.js} +1 -1
  18. package/dist/assets/{popover-BDFNiLlg.js → popover-2H9DS7Cv.js} +1 -1
  19. package/dist/assets/{provider-scoped-model-input-BMTp4BEH.js → provider-scoped-model-input-DsZJ44ZV.js} +1 -1
  20. package/dist/assets/{providers-list-DC1q3fvC.js → providers-list-CjkQwdQf.js} +1 -1
  21. package/dist/assets/remote-Dm6hKGew.js +1 -0
  22. package/dist/assets/{runtime-config-page-q-nC0C5i.js → runtime-config-page-DXNa4Xa-.js} +1 -1
  23. package/dist/assets/{search-config-CcKHif8O.js → search-config-D5laxxn9.js} +1 -1
  24. package/dist/assets/{secrets-config-DSg6O92a.js → secrets-config-CNsbCI2d.js} +1 -1
  25. package/dist/assets/{select-BUTwE_lC.js → select-C2c10F3e.js} +1 -1
  26. package/dist/assets/{setting-row-BavcnXw1.js → setting-row-CB_ZFbIZ.js} +1 -1
  27. package/dist/assets/{tag-chip-Dm2Lqnpu.js → tag-chip-CrQfVN3A.js} +1 -1
  28. package/dist/assets/{use-config-Cyv5IuSt.js → use-config-jAYudJxy.js} +1 -1
  29. package/dist/assets/{use-infinite-scroll-loader-DF2e6nQ2.js → use-infinite-scroll-loader-C_j5u-rR.js} +1 -1
  30. package/dist/index.html +11 -11
  31. package/package.json +9 -9
  32. package/src/features/channels/utils/channel-form-fields.utils.ts +0 -9
  33. package/src/features/marketplace/components/marketplace-page.test.tsx +29 -29
  34. package/src/features/marketplace/utils/marketplace-installed-cache.utils.test.ts +11 -11
  35. package/src/shared/lib/logos/index.ts +0 -1
  36. package/dist/assets/api-DGD9_Bg4.js +0 -15
  37. package/dist/assets/marketplace-page-DkQ2hTs1.js +0 -1
  38. package/dist/assets/mcp-marketplace-page-DSML7NN0.js +0 -1
  39. package/dist/assets/remote-Dr3jcfWP.js +0 -1
  40. package/dist/logos/mochat.svg +0 -6
  41. package/public/logos/mochat.svg +0 -6
@@ -1,4 +1,4 @@
1
- import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{A as a,At as o,D as s,E as c,Gt as l,Ht as u,Jt as d,Kt as f,Lt as p,M as m,O as h,Rt as g,Ut as _,Vt as v,Wt as y,Xt as b,an as x,en as S,in as ee,j as te,k as ne,nn as C,qt as w,rn as T,tn as E,zt as D}from"./api-DGD9_Bg4.js";import{l as re,t as ie,u as ae}from"./cpu-DPPwMzoC.js";import{a as oe,c as se,i as O,l as ce,n as le,o as ue,s as k,t as de}from"./use-infinite-scroll-loader-DF2e6nQ2.js";import{t as A}from"./createLucideIcon-DzY6wN61.js";import{n as j}from"./search-CRtQwr-h.js";import{t as M}from"./download-CMM8po31.js";import{t as N}from"./sparkles-BmgOD4nY.js";import{i as fe}from"./doc-browser-context-FukQHvyo.js";import{n as pe}from"./doc-browser-CAhfnm0D.js";import{X as P,_ as F,g as I,h as me,u as L,v as R,y as z}from"./index-DqJ3CYwi.js";import{t as he}from"./tabs-custom-D48zdZoc.js";function ge(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function B(e,t,n){let r=e.slice(0);return r[t]=n,r}var V=class extends x{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,E.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ee(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ge(e,n).forEach(e=>{e.destroy()}),ge(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=T(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new S(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=B(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&E.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},H=e(t(),1);function _e({queries:e,...t},n){let r=b(n),i=d(),a=w(),o=H.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{v(e),y(e,a,r.getQueryCache().get(e.queryHash))}),f(a);let[s]=H.useState(()=>new V(r,o,t)),[c,p,m]=s.getOptimisticResult(o,t.combine),h=!i&&t.subscribed!==!1;H.useSyncExternalStore(H.useCallback(e=>h?s.subscribe(E.batchCalls(e)):C,[s,h]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),H.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let g=c.some((e,t)=>_(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&_(n,e)?u(n,new S(r,n),a):[]}):[];if(g.length>0)throw Promise.all(g);let x=c.find((e,t)=>{let n=o[t];return n&&l({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(x?.error)throw x.error;return p(m())}var U=A(`BriefcaseBusiness`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),ve=A(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ye=A(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),be=A(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),xe=A(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Se=A(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Ce=A(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),we=A(`PowerOff`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Te=A(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Ee=A(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]);function W(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function De(e){let t=new Date().toISOString();return e.result.type===`skill`?{type:`skill`,spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:`workspace`,installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:`marketplace`,origin:`marketplace`,enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?`disabled`:`ready`,installedAt:t}}function G(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Oe(e,t){return t??{type:e,total:0,specs:[],records:[]}}function ke(e){let t=Oe(e.result.type,e.view),n=De(e),r=t.records.findIndex(e=>G(e,{id:n.id,spec:n.spec})),i=[...t.records];return r>=0?i[r]={...i[r],...n}:i.unshift(n),{...t,type:e.result.type,records:i,specs:W(i),total:i.length}}function Ae(e){let t=Oe(e.result.type,e.view);if(e.result.action===`uninstall`||e.result.action===`remove`){let n=t.records.filter(t=>!G(t,{id:e.result.id,spec:e.request.spec}));return{...t,records:n,specs:W(n),total:n.length}}let n=t.records.map(t=>G(t,{id:e.result.id,spec:e.request.spec})?e.result.action===`disable`?{...t,enabled:!1,runtimeStatus:`disabled`}:{...t,enabled:!0,runtimeStatus:`ready`}:t);return{...t,records:n,specs:W(n),total:n.length}}function je(e){let t=ce({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>s({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type&&Me(r,e)?t:void 0},staleTime:15e3}),n=(0,H.useMemo)(()=>se(t.data),[t.data]);return{...t,data:n}}function Me(e,t){return e.q===t.q&&e.tag===t.tag&&e.scene===t.scene&&e.sort===t.sort&&e.pageSize===t.pageSize}function Ne(e=!0){return D({queryKey:[`marketplace-skill-scenes`],queryFn:a,enabled:e,staleTime:6e4})}function Pe(e,t=!0){let n=_e({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>s({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,H.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{let i=typeof e.count==`number`?e.count:n[r]?.data?.total;typeof i==`number`&&t.set(e.scene,i)}),t},[n,e])}function Fe(e){return D({queryKey:[`marketplace-installed`,e],queryFn:()=>c(e),staleTime:1e4})}function Ie(){let e=b();return g({mutationFn:e=>te(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>ke({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),t.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=t.type===`plugin`?r(`marketplaceInstallSuccessPlugin`):r(`marketplaceInstallSuccessSkill`);p.success(t.message||i)},onError:e=>{p.error(e.message||r(`marketplaceInstallFailed`))}})}function Le(){let e=b();return g({mutationFn:e=>m(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>Ae({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),t.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=t.action===`enable`?r(`marketplaceEnableSuccess`):t.action===`disable`?r(`marketplaceDisableSuccess`):r(`marketplaceUninstallSuccess`);p.success(t.message||i)},onError:e=>{p.error(e.message||r(`marketplaceOperationFailed`))}})}function K(e){return(e??``).trim().toLowerCase()}function q(e,t){let n=K(t);return n.length>0?`${e}:${n}`:``}function Re(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=q(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function ze(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=q(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function J(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=q(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function Be(e,t){return t.get(q(e.type,e.spec))||t.get(q(e.type,e.id))||t.get(q(e.type,e.label))}function Ve(e,t,n,r){let i=K(n);if(!i)return!0;let a=O(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>K(e)).filter(Boolean).some(e=>e.includes(i))}function Y(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function He(e){let t=e.replace(/\r\n/g,`
1
+ import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{A as a,At as o,D as s,E as c,Gt as l,Ht as u,Jt as d,Kt as f,Lt as p,M as m,O as h,Rt as g,Ut as _,Vt as v,Wt as y,Xt as b,an as x,en as S,in as ee,j as te,k as ne,nn as C,qt as w,rn as T,tn as E,zt as D}from"./api-CKKNxbsy.js";import{l as re,t as ie,u as ae}from"./cpu-DPPwMzoC.js";import{a as oe,c as se,i as O,l as ce,n as le,o as ue,s as k,t as de}from"./use-infinite-scroll-loader-C_j5u-rR.js";import{t as A}from"./createLucideIcon-DzY6wN61.js";import{n as j}from"./search-CRtQwr-h.js";import{t as M}from"./download-CMM8po31.js";import{t as N}from"./sparkles-BmgOD4nY.js";import{i as fe}from"./doc-browser-context-FukQHvyo.js";import{n as pe}from"./doc-browser-CAhfnm0D.js";import{X as P,_ as F,g as I,h as me,u as L,v as R,y as z}from"./index-zYi4W031.js";import{t as he}from"./tabs-custom-D48zdZoc.js";function ge(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function B(e,t,n){let r=e.slice(0);return r[t]=n,r}var V=class extends x{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,E.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ee(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ge(e,n).forEach(e=>{e.destroy()}),ge(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=T(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new S(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=B(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&E.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},H=e(t(),1);function _e({queries:e,...t},n){let r=b(n),i=d(),a=w(),o=H.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{v(e),y(e,a,r.getQueryCache().get(e.queryHash))}),f(a);let[s]=H.useState(()=>new V(r,o,t)),[c,p,m]=s.getOptimisticResult(o,t.combine),h=!i&&t.subscribed!==!1;H.useSyncExternalStore(H.useCallback(e=>h?s.subscribe(E.batchCalls(e)):C,[s,h]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),H.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let g=c.some((e,t)=>_(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&_(n,e)?u(n,new S(r,n),a):[]}):[];if(g.length>0)throw Promise.all(g);let x=c.find((e,t)=>{let n=o[t];return n&&l({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(x?.error)throw x.error;return p(m())}var U=A(`BriefcaseBusiness`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),ve=A(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ye=A(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),be=A(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),xe=A(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Se=A(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),Ce=A(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),we=A(`PowerOff`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Te=A(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Ee=A(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]);function W(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function De(e){let t=new Date().toISOString();return e.result.type===`skill`?{type:`skill`,spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:`workspace`,installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:`marketplace`,origin:`marketplace`,enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?`disabled`:`ready`,installedAt:t}}function G(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Oe(e,t){return t??{type:e,total:0,specs:[],records:[]}}function ke(e){let t=Oe(e.result.type,e.view),n=De(e),r=t.records.findIndex(e=>G(e,{id:n.id,spec:n.spec})),i=[...t.records];return r>=0?i[r]={...i[r],...n}:i.unshift(n),{...t,type:e.result.type,records:i,specs:W(i),total:i.length}}function Ae(e){let t=Oe(e.result.type,e.view);if(e.result.action===`uninstall`||e.result.action===`remove`){let n=t.records.filter(t=>!G(t,{id:e.result.id,spec:e.request.spec}));return{...t,records:n,specs:W(n),total:n.length}}let n=t.records.map(t=>G(t,{id:e.result.id,spec:e.request.spec})?e.result.action===`disable`?{...t,enabled:!1,runtimeStatus:`disabled`}:{...t,enabled:!0,runtimeStatus:`ready`}:t);return{...t,records:n,specs:W(n),total:n.length}}function je(e){let t=ce({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>s({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type&&Me(r,e)?t:void 0},staleTime:15e3}),n=(0,H.useMemo)(()=>se(t.data),[t.data]);return{...t,data:n}}function Me(e,t){return e.q===t.q&&e.tag===t.tag&&e.scene===t.scene&&e.sort===t.sort&&e.pageSize===t.pageSize}function Ne(e=!0){return D({queryKey:[`marketplace-skill-scenes`],queryFn:a,enabled:e,staleTime:6e4})}function Pe(e,t=!0){let n=_e({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>s({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,H.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{let i=typeof e.count==`number`?e.count:n[r]?.data?.total;typeof i==`number`&&t.set(e.scene,i)}),t},[n,e])}function Fe(e){return D({queryKey:[`marketplace-installed`,e],queryFn:()=>c(e),staleTime:1e4})}function Ie(){let e=b();return g({mutationFn:e=>te(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>ke({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),t.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=t.type===`plugin`?r(`marketplaceInstallSuccessPlugin`):r(`marketplaceInstallSuccessSkill`);p.success(t.message||i)},onError:e=>{p.error(e.message||r(`marketplaceInstallFailed`))}})}function Le(){let e=b();return g({mutationFn:e=>m(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>Ae({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),t.type===`plugin`&&e.invalidateQueries({queryKey:[`ncp-session-types`]});let i=t.action===`enable`?r(`marketplaceEnableSuccess`):t.action===`disable`?r(`marketplaceDisableSuccess`):r(`marketplaceUninstallSuccess`);p.success(t.message||i)},onError:e=>{p.error(e.message||r(`marketplaceOperationFailed`))}})}function K(e){return(e??``).trim().toLowerCase()}function q(e,t){let n=K(t);return n.length>0?`${e}:${n}`:``}function Re(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=q(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function ze(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=q(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function J(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=q(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function Be(e,t){return t.get(q(e.type,e.spec))||t.get(q(e.type,e.id))||t.get(q(e.type,e.label))}function Ve(e,t,n,r){let i=K(n);if(!i)return!0;let a=O(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>K(e)).filter(Boolean).some(e=>e.includes(i))}function Y(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function He(e){let t=e.replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `);if(t[0]?.trim()!==`---`)return e;let n=t.findIndex((e,t)=>t>0&&e.trim()===`---`);return n>0?t.slice(n+1).join(`
4
4
  `).trim():e}function X(e){return Y(e).replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,`<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>`)}function Ue(e){return/^(#{1,4})\s+/.test(e)||/^([-*])\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)}function We(e,t,n){let r=[],i=t+1;for(;i<e.length&&!e[i]?.trim().startsWith("```");)r.push(e[i]??``),i+=1;return{html:`<div class="code-block">${n[1]?`<span class="code-language">${Y(n[1])}</span>`:``}<pre><code>${Y(r.join(`
@@ -0,0 +1 @@
1
+ import{t as e}from"./marketplace-page-BO74RmDP.js";export{e as MarketplacePage};
@@ -0,0 +1 @@
1
+ import{t as e}from"./mcp-marketplace-page-CoTYEIEI.js";export{e as McpMarketplacePage};
@@ -1,4 +1,4 @@
1
- import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{At as a,C as o,Lt as s,Mt as c,Nt as l,Rt as u,S as d,T as f,Xt as p,b as m,ft as h,w as g,x as _,zt as v}from"./api-DGD9_Bg4.js";import{a as y,c as b,i as x,l as S,n as ee,o as C,r as w,s as T,t as te}from"./use-infinite-scroll-loader-DF2e6nQ2.js";import{a as E,i as D,n as O,o as k,r as A,t as j}from"./dialog-BKo0RItd.js";import{t as M}from"./createLucideIcon-DzY6wN61.js";import{t as N}from"./sparkles-BmgOD4nY.js";import{t as P}from"./notice-card-Dr6xCwva.js";import{i as F}from"./doc-browser-context-FukQHvyo.js";import{n as I}from"./doc-browser-CAhfnm0D.js";import{h as L}from"./index-DqJ3CYwi.js";import{t as R}from"./tag-chip-Dm2Lqnpu.js";var ne=M(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]);function z(e){return(e??``).trim().toLowerCase()}function re(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=z(r);!e||t.has(e)||t.set(e,n)}}return t}function B(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=z(e);if(!n)continue;let r=t.get(n);if(r)return r}}function V(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function H(e,t,n,r,i){let a=`<!doctype html>
1
+ import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{At as a,C as o,Lt as s,Mt as c,Nt as l,Rt as u,S as d,T as f,Xt as p,b as m,ft as h,w as g,x as _,zt as v}from"./api-CKKNxbsy.js";import{a as y,c as b,i as x,l as S,n as ee,o as C,r as w,s as T,t as te}from"./use-infinite-scroll-loader-C_j5u-rR.js";import{a as E,i as D,n as O,o as k,r as A,t as j}from"./dialog-DWZeMf9V.js";import{t as M}from"./createLucideIcon-DzY6wN61.js";import{t as N}from"./sparkles-BmgOD4nY.js";import{t as P}from"./notice-card-BM2_YNoc.js";import{i as F}from"./doc-browser-context-FukQHvyo.js";import{n as I}from"./doc-browser-CAhfnm0D.js";import{h as L}from"./index-zYi4W031.js";import{t as R}from"./tag-chip-CrQfVN3A.js";var ne=M(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]);function z(e){return(e??``).trim().toLowerCase()}function re(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=z(r);!e||t.has(e)||t.set(e,n)}}return t}function B(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=z(e);if(!n)continue;let r=t.get(n);if(r)return r}}function V(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function H(e,t,n,r,i){let a=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Mt as a,Nt as o,jt as s,kt as c,wt as l}from"./api-DGD9_Bg4.js";import{t as u}from"./book-open-BcnAiKde.js";import{n as d,t as f}from"./provider-scoped-model-input-BMTp4BEH.js";import{t as p}from"./sparkles-BmgOD4nY.js";import{t as m}from"./doc-browser-context-FukQHvyo.js";import{i as h,n as g,r as _,y as v}from"./use-config-Cyv5IuSt.js";import{Q as y,tt as b,u as x}from"./index-DqJ3CYwi.js";import{t as S}from"./config-hints-BNfpOL4J.js";var C=e(t(),1),w=n(),T=`provider/model`;function E(e){let{initialModel:t,initialWorkspace:n,isPending:i,modelHelpText:c,modelLabel:l,modelPlaceholder:d,onSubmit:h,providerCatalog:g,workspaceLabel:_,workspacePlaceholder:v}=e,[x,S]=(0,C.useState)(t),[T,E]=(0,C.useState)(n);return(0,w.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h({model:x,workspace:T})},className:`space-y-8`,children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-2`,children:[(0,w.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,w.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,w.jsx)(p,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:r(`defaultModel`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:l}),(0,w.jsx)(f,{id:`model`,value:x,onChange:S,providerCatalog:g,modelPlaceholder:d}),(0,w.jsx)(`p`,{className:`text-xs text-gray-400`,children:c}),(0,w.jsxs)(`a`,{href:`${m}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,w.jsx)(u,{className:`h-3.5 w-3.5`}),r(`channelsGuideTitle`)]})]})]}),(0,w.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,w.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,w.jsx)(b,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:r(`workspace`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:_}),(0,w.jsx)(a,{id:`workspace`,value:T,onChange:e=>E(e.target.value),placeholder:v,className:`rounded-xl`})]})]})]}),(0,w.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,w.jsx)(o,{type:`submit`,disabled:i,size:`lg`,children:i?(0,w.jsx)(y,{className:`h-5 w-5 animate-spin`}):r(`saveChanges`)})})]})}function D(){let{data:e,isLoading:t}=g(),{data:n}=_(),{data:a}=h(),o=v(),s=a?.uiHints,u=S(`agents.defaults.model`,s),f=S(`agents.defaults.workspace`,s),p=(0,C.useMemo)(()=>d({meta:n,config:e,onlyConfigured:!0}),[e,n]),m=r(`modelIdentifierHelp`)||u?.help||``,y=(e?.agents?.defaults?.model||``).trim(),b=e?.agents?.defaults?.workspace||``;return t?(0,w.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-8 w-32`}),(0,w.jsx)(x,{className:`h-4 w-48`})]}),(0,w.jsxs)(l,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsxs)(`div`,{className:`mb-6 flex items-center gap-4`,children:[(0,w.jsx)(x,{className:`h-12 w-12 rounded-xl`}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-5 w-24`}),(0,w.jsx)(x,{className:`h-3 w-32`})]})]}),(0,w.jsx)(x,{className:`mb-2 h-4 w-20`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]}),(0,w.jsxs)(l,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsx)(x,{className:`mb-2 h-5 w-24`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]})]}):(0,w.jsxs)(i,{children:[(0,w.jsx)(c,{title:r(`modelPageTitle`),description:r(`modelPageDescription`)}),(0,w.jsx)(E,{initialModel:y,initialWorkspace:b,isPending:o.isPending,modelHelpText:m,modelLabel:u?.label??`Model Name`,modelPlaceholder:u?.placeholder??T,onSubmit:({model:e,workspace:t})=>o.mutate({model:e,workspace:t}),providerCatalog:p,workspaceLabel:f?.label??`Default Path`,workspacePlaceholder:f?.placeholder??`/path/to/workspace`},`${y}::${b}`)]})}export{D as ModelConfig};
1
+ import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Mt as a,Nt as o,jt as s,kt as c,wt as l}from"./api-CKKNxbsy.js";import{t as u}from"./book-open-BcnAiKde.js";import{n as d,t as f}from"./provider-scoped-model-input-DsZJ44ZV.js";import{t as p}from"./sparkles-BmgOD4nY.js";import{t as m}from"./doc-browser-context-FukQHvyo.js";import{i as h,n as g,r as _,y as v}from"./use-config-jAYudJxy.js";import{Q as y,tt as b,u as x}from"./index-zYi4W031.js";import{t as S}from"./config-hints-BNfpOL4J.js";var C=e(t(),1),w=n(),T=`provider/model`;function E(e){let{initialModel:t,initialWorkspace:n,isPending:i,modelHelpText:c,modelLabel:l,modelPlaceholder:d,onSubmit:h,providerCatalog:g,workspaceLabel:_,workspacePlaceholder:v}=e,[x,S]=(0,C.useState)(t),[T,E]=(0,C.useState)(n);return(0,w.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h({model:x,workspace:T})},className:`space-y-8`,children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-2`,children:[(0,w.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,w.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,w.jsx)(p,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:r(`defaultModel`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:l}),(0,w.jsx)(f,{id:`model`,value:x,onChange:S,providerCatalog:g,modelPlaceholder:d}),(0,w.jsx)(`p`,{className:`text-xs text-gray-400`,children:c}),(0,w.jsxs)(`a`,{href:`${m}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,w.jsx)(u,{className:`h-3.5 w-3.5`}),r(`channelsGuideTitle`)]})]})]}),(0,w.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,w.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,w.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,w.jsx)(b,{className:`h-5 w-5`})}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:r(`workspace`)})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:_}),(0,w.jsx)(a,{id:`workspace`,value:T,onChange:e=>E(e.target.value),placeholder:v,className:`rounded-xl`})]})]})]}),(0,w.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,w.jsx)(o,{type:`submit`,disabled:i,size:`lg`,children:i?(0,w.jsx)(y,{className:`h-5 w-5 animate-spin`}):r(`saveChanges`)})})]})}function D(){let{data:e,isLoading:t}=g(),{data:n}=_(),{data:a}=h(),o=v(),s=a?.uiHints,u=S(`agents.defaults.model`,s),f=S(`agents.defaults.workspace`,s),p=(0,C.useMemo)(()=>d({meta:n,config:e,onlyConfigured:!0}),[e,n]),m=r(`modelIdentifierHelp`)||u?.help||``,y=(e?.agents?.defaults?.model||``).trim(),b=e?.agents?.defaults?.workspace||``;return t?(0,w.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-8 w-32`}),(0,w.jsx)(x,{className:`h-4 w-48`})]}),(0,w.jsxs)(l,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsxs)(`div`,{className:`mb-6 flex items-center gap-4`,children:[(0,w.jsx)(x,{className:`h-12 w-12 rounded-xl`}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(x,{className:`h-5 w-24`}),(0,w.jsx)(x,{className:`h-3 w-32`})]})]}),(0,w.jsx)(x,{className:`mb-2 h-4 w-20`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]}),(0,w.jsxs)(l,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,w.jsx)(x,{className:`mb-2 h-5 w-24`}),(0,w.jsx)(x,{className:`h-10 w-full rounded-xl`})]})]}):(0,w.jsxs)(i,{children:[(0,w.jsx)(c,{title:r(`modelPageTitle`),description:r(`modelPageDescription`)}),(0,w.jsx)(E,{initialModel:y,initialWorkspace:b,isPending:o.isPending,modelHelpText:m,modelLabel:u?.label??`Model Name`,modelPlaceholder:u?.placeholder??T,onSubmit:({model:e,workspace:t})=>o.mutate({model:e,workspace:t}),providerCatalog:p,workspaceLabel:f?.label??`Default Path`,workspacePlaceholder:f?.placeholder??`/path/to/workspace`},`${y}::${b}`)]})}export{D as ModelConfig};
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,u as r}from"./i18n-D1144VAA.js";import{Pt as i}from"./api-DGD9_Bg4.js";var a=e(t(),1),o=n(),s=i(`rounded-2xl border px-4 py-3`,{variants:{tone:{neutral:`border-gray-200 bg-gray-50 text-gray-900`,success:`border-emerald-200 bg-emerald-50 text-emerald-900`,warning:`border-amber-200 bg-amber-50 text-amber-900`,danger:`border-rose-200 bg-rose-50 text-rose-700`,info:`border-primary/20 bg-primary/10 text-primary`},borderStyle:{solid:``,dashed:`border-dashed`}},defaultVariants:{tone:`neutral`,borderStyle:`solid`}}),c={neutral:`text-gray-900`,success:`text-emerald-800`,warning:`text-amber-900`,danger:`text-rose-700`,info:`text-primary`},l={neutral:`text-gray-600`,success:`text-emerald-700`,warning:`text-amber-800`,danger:`text-rose-700`,info:`text-primary/90`},u=a.forwardRef(({className:e,tone:t=`neutral`,borderStyle:n=`solid`,title:i,description:a,icon:u,actions:d,children:f,...p},m)=>{let h=t??`neutral`,g=!!i||!!a||!!u||!!d;return(0,o.jsxs)(`div`,{ref:m,className:r(s({tone:h,borderStyle:n}),e),...p,children:[g?(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-2`,children:[u?(0,o.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:u}):null,(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i?(0,o.jsx)(`p`,{className:r(`text-sm font-medium`,c[h]),children:i}):null,a?(0,o.jsx)(`p`,{className:r(i?`mt-1`:``,`text-sm leading-6`,l[h]),children:a}):null]})]})}),d?(0,o.jsx)(`div`,{className:`shrink-0`,children:d}):null]}):null,f?(0,o.jsx)(`div`,{className:r(g?`mt-3`:``),children:f}):null]})});u.displayName=`NoticeCard`;export{u as t};
1
+ import{_ as e,m as t,p as n,u as r}from"./i18n-D1144VAA.js";import{Pt as i}from"./api-CKKNxbsy.js";var a=e(t(),1),o=n(),s=i(`rounded-2xl border px-4 py-3`,{variants:{tone:{neutral:`border-gray-200 bg-gray-50 text-gray-900`,success:`border-emerald-200 bg-emerald-50 text-emerald-900`,warning:`border-amber-200 bg-amber-50 text-amber-900`,danger:`border-rose-200 bg-rose-50 text-rose-700`,info:`border-primary/20 bg-primary/10 text-primary`},borderStyle:{solid:``,dashed:`border-dashed`}},defaultVariants:{tone:`neutral`,borderStyle:`solid`}}),c={neutral:`text-gray-900`,success:`text-emerald-800`,warning:`text-amber-900`,danger:`text-rose-700`,info:`text-primary`},l={neutral:`text-gray-600`,success:`text-emerald-700`,warning:`text-amber-800`,danger:`text-rose-700`,info:`text-primary/90`},u=a.forwardRef(({className:e,tone:t=`neutral`,borderStyle:n=`solid`,title:i,description:a,icon:u,actions:d,children:f,...p},m)=>{let h=t??`neutral`,g=!!i||!!a||!!u||!!d;return(0,o.jsxs)(`div`,{ref:m,className:r(s({tone:h,borderStyle:n}),e),...p,children:[g?(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-2`,children:[u?(0,o.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:u}):null,(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i?(0,o.jsx)(`p`,{className:r(`text-sm font-medium`,c[h]),children:i}):null,a?(0,o.jsx)(`p`,{className:r(i?`mt-1`:``,`text-sm leading-6`,l[h]),children:a}):null]})]})}),d?(0,o.jsx)(`div`,{className:`shrink-0`,children:d}):null]}):null,f?(0,o.jsx)(`div`,{className:r(g?`mt-3`:``),children:f}):null]})});u.displayName=`NoticeCard`;export{u as t};
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,u as r}from"./i18n-D1144VAA.js";import{_ as i,a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,n as p,o as m,r as ee,t as h}from"./es2015-BhznEEyJ.js";import{t as g}from"./dist-CFiwgaLs.js";import{C as _,E as v,S as y,T as b,w as x}from"./select-BUTwE_lC.js";var S=e(t(),1),C=n(),w=`Popover`,[T,te]=u(w,[v]),E=v(),[D,O]=T(w),k=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,l=E(t),u=S.useRef(null),[d,f]=S.useState(!1),[p,m]=s({prop:r,defaultProp:i??!1,onChange:a,caller:w});return(0,C.jsx)(b,{...l,children:(0,C.jsx)(D,{scope:t,contentId:c(),triggerRef:u,open:p,onOpenChange:m,onOpenToggle:S.useCallback(()=>m(e=>!e),[m]),hasCustomAnchor:d,onCustomAnchorAdd:S.useCallback(()=>f(!0),[]),onCustomAnchorRemove:S.useCallback(()=>f(!1),[]),modal:o,children:n})})};k.displayName=w;var A=`PopoverAnchor`,j=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=O(A,n),a=E(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return S.useEffect(()=>(o(),()=>s()),[o,s]),(0,C.jsx)(y,{...a,...r,ref:t})});j.displayName=A;var M=`PopoverTrigger`,N=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,a=O(M,n),s=E(n),c=l(t,a.triggerRef),u=(0,C.jsx)(o.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.contentId,"data-state":q(a.open),...r,ref:c,onClick:i(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:(0,C.jsx)(y,{asChild:!0,...s,children:u})});N.displayName=M;var P=`PopoverPortal`,[F,I]=T(P,{forceMount:void 0}),L=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=O(P,t);return(0,C.jsx)(F,{scope:t,forceMount:n,children:(0,C.jsx)(g,{present:n||a.open,children:(0,C.jsx)(d,{asChild:!0,container:i,children:r})})})};L.displayName=P;var R=`PopoverContent`,z=S.forwardRef((e,t)=>{let n=I(R,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=O(R,e.__scopePopover);return(0,C.jsx)(g,{present:r||a.open,children:a.modal?(0,C.jsx)(B,{...i,ref:t}):(0,C.jsx)(V,{...i,ref:t})})});z.displayName=R;var ne=f(`PopoverContent.RemoveScroll`),B=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(null),a=l(t,r),o=S.useRef(!1);return S.useEffect(()=>{let e=r.current;if(e)return h(e)},[]),(0,C.jsx)(p,{as:ne,allowPinchZoom:!0,children:(0,C.jsx)(H,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:i(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:i(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;o.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:i(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),V=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(!1),i=S.useRef(!1);return(0,C.jsx)(H,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),H=S.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,...f}=e,p=O(R,n),h=E(n);return ee(),(0,C.jsx)(a,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,C.jsx)(m,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:(0,C.jsx)(x,{"data-state":q(p.open),role:`dialog`,id:p.contentId,...h,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),U=`PopoverClose`,W=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,a=O(U,n);return(0,C.jsx)(o.button,{type:`button`,...r,ref:t,onClick:i(e.onClick,()=>a.onOpenChange(!1))})});W.displayName=U;var G=`PopoverArrow`,K=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=E(n);return(0,C.jsx)(_,{...i,...r,ref:t})});K.displayName=G;function q(e){return e?`open`:`closed`}var J=k,Y=j,X=N,Z=L,Q=z,re=J,ie=X,$=S.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...i},a)=>(0,C.jsx)(Z,{children:(0,C.jsx)(Q,{ref:a,sideOffset:t,align:n,className:r(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})}));$.displayName=Q.displayName;export{Q as a,X as c,Y as i,$ as n,Z as o,ie as r,J as s,re as t};
1
+ import{_ as e,m as t,p as n,u as r}from"./i18n-D1144VAA.js";import{_ as i,a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,n as p,o as m,r as ee,t as h}from"./es2015-ZJ-nWL4L.js";import{t as g}from"./dist-DN-YM_0Y.js";import{C as _,E as v,S as y,T as b,w as x}from"./select-C2c10F3e.js";var S=e(t(),1),C=n(),w=`Popover`,[T,te]=u(w,[v]),E=v(),[D,O]=T(w),k=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,l=E(t),u=S.useRef(null),[d,f]=S.useState(!1),[p,m]=s({prop:r,defaultProp:i??!1,onChange:a,caller:w});return(0,C.jsx)(b,{...l,children:(0,C.jsx)(D,{scope:t,contentId:c(),triggerRef:u,open:p,onOpenChange:m,onOpenToggle:S.useCallback(()=>m(e=>!e),[m]),hasCustomAnchor:d,onCustomAnchorAdd:S.useCallback(()=>f(!0),[]),onCustomAnchorRemove:S.useCallback(()=>f(!1),[]),modal:o,children:n})})};k.displayName=w;var A=`PopoverAnchor`,j=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=O(A,n),a=E(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return S.useEffect(()=>(o(),()=>s()),[o,s]),(0,C.jsx)(y,{...a,...r,ref:t})});j.displayName=A;var M=`PopoverTrigger`,N=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,a=O(M,n),s=E(n),c=l(t,a.triggerRef),u=(0,C.jsx)(o.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.contentId,"data-state":q(a.open),...r,ref:c,onClick:i(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:(0,C.jsx)(y,{asChild:!0,...s,children:u})});N.displayName=M;var P=`PopoverPortal`,[F,I]=T(P,{forceMount:void 0}),L=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=O(P,t);return(0,C.jsx)(F,{scope:t,forceMount:n,children:(0,C.jsx)(g,{present:n||a.open,children:(0,C.jsx)(d,{asChild:!0,container:i,children:r})})})};L.displayName=P;var R=`PopoverContent`,z=S.forwardRef((e,t)=>{let n=I(R,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=O(R,e.__scopePopover);return(0,C.jsx)(g,{present:r||a.open,children:a.modal?(0,C.jsx)(B,{...i,ref:t}):(0,C.jsx)(V,{...i,ref:t})})});z.displayName=R;var ne=f(`PopoverContent.RemoveScroll`),B=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(null),a=l(t,r),o=S.useRef(!1);return S.useEffect(()=>{let e=r.current;if(e)return h(e)},[]),(0,C.jsx)(p,{as:ne,allowPinchZoom:!0,children:(0,C.jsx)(H,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:i(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:i(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;o.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:i(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),V=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(!1),i=S.useRef(!1);return(0,C.jsx)(H,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),H=S.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,...f}=e,p=O(R,n),h=E(n);return ee(),(0,C.jsx)(a,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,C.jsx)(m,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:(0,C.jsx)(x,{"data-state":q(p.open),role:`dialog`,id:p.contentId,...h,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),U=`PopoverClose`,W=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,a=O(U,n);return(0,C.jsx)(o.button,{type:`button`,...r,ref:t,onClick:i(e.onClick,()=>a.onOpenChange(!1))})});W.displayName=U;var G=`PopoverArrow`,K=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=E(n);return(0,C.jsx)(_,{...i,...r,ref:t})});K.displayName=G;function q(e){return e?`open`:`closed`}var J=k,Y=j,X=N,Z=L,Q=z,re=J,ie=X,$=S.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...i},a)=>(0,C.jsx)(Z,{children:(0,C.jsx)(Q,{ref:a,sideOffset:t,align:n,className:r(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})}));$.displayName=Q.displayName;export{Q as a,X as c,Y as i,$ as n,Z as o,ie as r,J as s,re as t};
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{Mt as a}from"./api-DGD9_Bg4.js";import{t as o}from"./createLucideIcon-DzY6wN61.js";import{a as s,i as c,k as l,n as u,r as d,t as f}from"./select-BUTwE_lC.js";var p=o(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),m=e(t(),1),h=n();function g(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function _({id:e,value:t,onChange:n,options:r,disabled:o=!1,placeholder:s,className:c,inputClassName:u,emptyText:d,createText:f,maxItems:_=1/0,onEnter:v}){let[y,b]=(0,m.useState)(!1);(0,m.useEffect)(()=>{o&&y&&b(!1)},[o,y]);let x=(0,m.useMemo)(()=>g(r),[r]),S=t.trim().toLowerCase(),C=(0,m.useMemo)(()=>{let e=x.map((e,t)=>({option:e,index:t}));S.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===S?0:n.startsWith(S)?1:n.includes(S)?2:3,a=r===S?0:r.startsWith(S)?1:r.includes(S)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(_)?t.slice(0,Math.max(1,_)):t},[x,S,_]),w=t.trim().length>0&&x.some(e=>e===t.trim());return(0,h.jsxs)(`div`,{className:i(`relative`,c),onBlur:()=>{setTimeout(()=>b(!1),120)},children:[(0,h.jsx)(a,{id:e,value:t,disabled:o,onFocus:()=>{o||b(!0)},onChange:e=>{n(e.target.value),!y&&!o&&b(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),b(!1))},placeholder:s,className:i(`pr-10`,u)}),(0,h.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(e=>!e),disabled:o,className:i(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,o?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":`toggle model options`,children:(0,h.jsx)(p,{className:`h-4 w-4`})}),y&&!o&&(0,h.jsx)(`div`,{className:`absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg`,children:(0,h.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[!w&&t.trim().length>0&&(0,h.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,h.jsx)(l,{className:`h-4 w-4 text-transparent`}),(0,h.jsx)(`span`,{className:`truncate text-gray-700`,children:f?f.replace(`{value}`,t.trim()):t.trim()})]}),C.map(e=>(0,h.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,h.jsx)(l,{className:i(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,h.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),C.length===0&&t.trim().length===0&&(0,h.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:d??`No models available`})]})})]})}var v=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function y(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function b(e,t){let n=e.trim(),r=t.trim();if(!n||!r)return n;let i=`${r}/`;return n.startsWith(i)?n.slice(i.length):n}function x(e,t){let n=e.trim();if(!n)return``;for(let e of t)n=b(n,e);return n.trim()}function S(e,t){let n=t.trim(),r=e.trim();return n?r?`${r}/${n}`:n:``}function C(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&v.has(t)?t:null}function w(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=C(n);!e||t.includes(e)||t.push(e)}return t}function T(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=x(r,t);if(!e)continue;let a=w(i?.supported);if(a.length===0)continue;let o=C(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function E(e,t,n){let r=x(t,n);return r?e[r]??null:null}function D(e,t){let n=e.trim();if(!n)return null;let r=null;for(let e of t)for(let t of e.aliases){let i=t.trim();i&&(n===i||n.startsWith(`${i}/`))&&(!r||i.length>r.score)&&(r={name:e.name,score:i.length})}if(r)return r.name;for(let e of t){let t=x(n,e.aliases);if(t&&y(e.models??[]).some(e=>e===t))return e.name}return null}function O(e){return e?e.enabled!==!1&&e.apiKeySet===!0:!1}function k(e){let{meta:t,config:n,onlyConfigured:r=!1}=e,i=(t?.providers??[]).map(e=>{let t=n?.providers?.[e.name],r=(e.modelPrefix||e.name||``).trim(),i=y([e.modelPrefix||``,e.name||``]),a=y((t?.models??[]).map(e=>x(e,i))),o=T(t?.modelThinking,i),s=t?.displayName?.trim(),c=O(t);return{name:e.name,displayName:s||e.displayName||e.name,prefix:r,aliases:i,models:a,modelThinking:o,configured:c}});return r?i.filter(e=>e.configured&&e.models.length>0):i}var A=`provider/model`;function j(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function M({id:e,value:t,onChange:n,providerCatalog:i,disabled:o=!1,providerPlaceholder:l,modelPlaceholder:p,className:g}){let[v,y]=(0,m.useState)(``),[b,C]=(0,m.useState)(``),w=i.length>0,T=p??A,E=(0,m.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),O=E.get(v),k=(0,m.useMemo)(()=>O?.aliases??[],[O]),M=(0,m.useMemo)(()=>j(O?.models??[]),[O]);return(0,m.useEffect)(()=>{let e=t.trim();if(!w){y(``),C(e);return}if(!e){C(``),y(e=>E.has(e)?e:``);return}let n=D(e,i)??``,r=E.get(n)?.aliases??[];y(n),C(n?x(e,r):e)},[w,i,E,t]),w?(0,h.jsxs)(`div`,{className:g,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,h.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,h.jsxs)(f,{value:v,onValueChange:e=>{let t=j(E.get(e)?.models??[])[0]??``;if(y(e),C(t),!t){n(``);return}n(S(E.get(e)?.prefix??e,t))},disabled:o,children:[(0,h.jsx)(c,{className:`h-10 w-full rounded-xl`,children:(0,h.jsx)(s,{placeholder:l??r(`providersSelectPlaceholder`)})}),(0,h.jsx)(u,{children:i.map(e=>(0,h.jsx)(d,{value:e.name,children:e.displayName},e.name))})]})}),(0,h.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,h.jsx)(_,{id:e,value:b,onChange:e=>{if(!O){let t=e.trim();C(t),n(t);return}let t=x(e,k);C(t),n(t?S(O.prefix,t):``)},options:M,disabled:o||!v,placeholder:T,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:r(`modelPickerNoOptions`),createText:r(`modelPickerUseCustom`)},v)]}),(0,h.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:r(`modelInputCustomHint`)})]}):(0,h.jsxs)(`div`,{className:g,children:[(0,h.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,h.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:r(`providersEmptyTitle`)}),(0,h.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:r(`providersEmptyDescription`)})]}),(0,h.jsx)(a,{id:e,value:t,disabled:o,onChange:e=>n(e.target.value),placeholder:T,className:`mt-3 h-10 rounded-xl`}),(0,h.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:r(`modelInputCustomHint`)})]})}export{E as i,k as n,S as r,M as t};
1
+ import{_ as e,m as t,p as n,r,u as i}from"./i18n-D1144VAA.js";import{Mt as a}from"./api-CKKNxbsy.js";import{t as o}from"./createLucideIcon-DzY6wN61.js";import{a as s,i as c,k as l,n as u,r as d,t as f}from"./select-C2c10F3e.js";var p=o(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),m=e(t(),1),h=n();function g(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function _({id:e,value:t,onChange:n,options:r,disabled:o=!1,placeholder:s,className:c,inputClassName:u,emptyText:d,createText:f,maxItems:_=1/0,onEnter:v}){let[y,b]=(0,m.useState)(!1);(0,m.useEffect)(()=>{o&&y&&b(!1)},[o,y]);let x=(0,m.useMemo)(()=>g(r),[r]),S=t.trim().toLowerCase(),C=(0,m.useMemo)(()=>{let e=x.map((e,t)=>({option:e,index:t}));S.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===S?0:n.startsWith(S)?1:n.includes(S)?2:3,a=r===S?0:r.startsWith(S)?1:r.includes(S)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(_)?t.slice(0,Math.max(1,_)):t},[x,S,_]),w=t.trim().length>0&&x.some(e=>e===t.trim());return(0,h.jsxs)(`div`,{className:i(`relative`,c),onBlur:()=>{setTimeout(()=>b(!1),120)},children:[(0,h.jsx)(a,{id:e,value:t,disabled:o,onFocus:()=>{o||b(!0)},onChange:e=>{n(e.target.value),!y&&!o&&b(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),b(!1))},placeholder:s,className:i(`pr-10`,u)}),(0,h.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(e=>!e),disabled:o,className:i(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,o?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":`toggle model options`,children:(0,h.jsx)(p,{className:`h-4 w-4`})}),y&&!o&&(0,h.jsx)(`div`,{className:`absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg`,children:(0,h.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[!w&&t.trim().length>0&&(0,h.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,h.jsx)(l,{className:`h-4 w-4 text-transparent`}),(0,h.jsx)(`span`,{className:`truncate text-gray-700`,children:f?f.replace(`{value}`,t.trim()):t.trim()})]}),C.map(e=>(0,h.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),b(!1)},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,h.jsx)(l,{className:i(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,h.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),C.length===0&&t.trim().length===0&&(0,h.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:d??`No models available`})]})})]})}var v=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]);function y(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function b(e,t){let n=e.trim(),r=t.trim();if(!n||!r)return n;let i=`${r}/`;return n.startsWith(i)?n.slice(i.length):n}function x(e,t){let n=e.trim();if(!n)return``;for(let e of t)n=b(n,e);return n.trim()}function S(e,t){let n=t.trim(),r=e.trim();return n?r?`${r}/${n}`:n:``}function C(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&v.has(t)?t:null}function w(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=C(n);!e||t.includes(e)||t.push(e)}return t}function T(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=x(r,t);if(!e)continue;let a=w(i?.supported);if(a.length===0)continue;let o=C(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function E(e,t,n){let r=x(t,n);return r?e[r]??null:null}function D(e,t){let n=e.trim();if(!n)return null;let r=null;for(let e of t)for(let t of e.aliases){let i=t.trim();i&&(n===i||n.startsWith(`${i}/`))&&(!r||i.length>r.score)&&(r={name:e.name,score:i.length})}if(r)return r.name;for(let e of t){let t=x(n,e.aliases);if(t&&y(e.models??[]).some(e=>e===t))return e.name}return null}function O(e){return e?e.enabled!==!1&&e.apiKeySet===!0:!1}function k(e){let{meta:t,config:n,onlyConfigured:r=!1}=e,i=(t?.providers??[]).map(e=>{let t=n?.providers?.[e.name],r=(e.modelPrefix||e.name||``).trim(),i=y([e.modelPrefix||``,e.name||``]),a=y((t?.models??[]).map(e=>x(e,i))),o=T(t?.modelThinking,i),s=t?.displayName?.trim(),c=O(t);return{name:e.name,displayName:s||e.displayName||e.name,prefix:r,aliases:i,models:a,modelThinking:o,configured:c}});return r?i.filter(e=>e.configured&&e.models.length>0):i}var A=`provider/model`;function j(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function M({id:e,value:t,onChange:n,providerCatalog:i,disabled:o=!1,providerPlaceholder:l,modelPlaceholder:p,className:g}){let[v,y]=(0,m.useState)(``),[b,C]=(0,m.useState)(``),w=i.length>0,T=p??A,E=(0,m.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),O=E.get(v),k=(0,m.useMemo)(()=>O?.aliases??[],[O]),M=(0,m.useMemo)(()=>j(O?.models??[]),[O]);return(0,m.useEffect)(()=>{let e=t.trim();if(!w){y(``),C(e);return}if(!e){C(``),y(e=>E.has(e)?e:``);return}let n=D(e,i)??``,r=E.get(n)?.aliases??[];y(n),C(n?x(e,r):e)},[w,i,E,t]),w?(0,h.jsxs)(`div`,{className:g,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,h.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,h.jsxs)(f,{value:v,onValueChange:e=>{let t=j(E.get(e)?.models??[])[0]??``;if(y(e),C(t),!t){n(``);return}n(S(E.get(e)?.prefix??e,t))},disabled:o,children:[(0,h.jsx)(c,{className:`h-10 w-full rounded-xl`,children:(0,h.jsx)(s,{placeholder:l??r(`providersSelectPlaceholder`)})}),(0,h.jsx)(u,{children:i.map(e=>(0,h.jsx)(d,{value:e.name,children:e.displayName},e.name))})]})}),(0,h.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,h.jsx)(_,{id:e,value:b,onChange:e=>{if(!O){let t=e.trim();C(t),n(t);return}let t=x(e,k);C(t),n(t?S(O.prefix,t):``)},options:M,disabled:o||!v,placeholder:T,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:r(`modelPickerNoOptions`),createText:r(`modelPickerUseCustom`)},v)]}),(0,h.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:r(`modelInputCustomHint`)})]}):(0,h.jsxs)(`div`,{className:g,children:[(0,h.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,h.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:r(`providersEmptyTitle`)}),(0,h.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:r(`providersEmptyDescription`)})]}),(0,h.jsx)(a,{id:e,value:t,disabled:o,onChange:e=>n(e.target.value),placeholder:T,className:`mt-3 h-10 rounded-xl`}),(0,h.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:r(`modelInputCustomHint`)})]})}export{E as i,k as n,S as r,M as t};
@@ -1 +1 @@
1
- import{_ as e,a as t,m as n,p as r,r as i,u as a}from"./i18n-D1144VAA.js";import{At as o,Lt as s,Mt as c,Nt as l,Xt as u,ft as d,jt as f,kt as p}from"./api-DGD9_Bg4.js";import{t as m}from"./createLucideIcon-DzY6wN61.js";import{t as h}from"./search-CRtQwr-h.js";import{O as g,a as _,i as v,n as y,r as b,t as x}from"./select-BUTwE_lC.js";import{t as S}from"./key-round-DUq47t0P.js";import{t as C}from"./plus-B-YHtTNC.js";import{t as w}from"./x-BeyYA_h6.js";import{t as T}from"./status-dot-l3kPFdq_.js";import{a as ee,b as te,c as ne,g as re,h as ie,i as ae,n as oe,p as se,r as ce,u as le}from"./use-config-Cyv5IuSt.js";import{n as E,r as ue,t as D}from"./popover-BDFNiLlg.js";import{X as de,Y as O,q as k}from"./index-DqJ3CYwi.js";import{t as A}from"./tabs-custom-D48zdZoc.js";import{t as fe}from"./config-hints-BNfpOL4J.js";import{a as pe,c as me,i as he,n as ge,o as _e,r as j,s as ve,t as M}from"./config-split-page-CcrEUtwu.js";import{t as ye}from"./setting-row-BavcnXw1.js";var be=m(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),xe=m(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Se=m(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ce=m(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),N=e(n(),1),P=r();function we({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[s,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1),p=typeof n==`string`&&n.length>0;return(0,P.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,P.jsx)(`div`,{onClick:()=>f(!0),className:a(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,P.jsx)(c,{type:s?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{p||f(!1)},placeholder:i,autoFocus:d,...o}),(0,P.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,P.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!s),children:s?(0,P.jsx)(xe,{className:`h-4 w-4`}):(0,P.jsx)(Se,{className:`h-4 w-4`})})})]})}function Te({value:e,onChange:t,className:n}){let r=e?Object.entries(e):[],o=(e,n,i)=>{let a=[...r];a[e]=[n,i],t(Object.fromEntries(a))},s=()=>{t({...e,"":``})},u=e=>{let n=r.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,P.jsxs)(`div`,{className:a(`space-y-2`,n),children:[r.map(([e,t],n)=>(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(c,{type:`text`,value:e,onChange:e=>o(n,e.target.value,t),placeholder:i(`headerName`),className:`flex-1`}),(0,P.jsx)(c,{type:`text`,value:t,onChange:t=>o(n,e,t.target.value),placeholder:i(`headerValue`),className:`flex-1`}),(0,P.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>u(n),children:(0,P.jsx)(de,{className:`h-4 w-4 text-red-500`})})]},n)),(0,P.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,P.jsx)(C,{className:`h-4 w-4 mr-2`}),i(`add`)]})]})}function Ee(e){let{value:t,onChange:n,options:r}=e;return(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,P.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function De(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:r,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:p}=e;return(0,P.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(Ce,{className:`h-3.5 w-3.5`}),i(`providerAdvancedSettings`)]}),(0,P.jsx)(g,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,P.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[r?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,P.jsx)(Ee,{value:o,onChange:e=>s(e),options:l}):(0,P.jsxs)(x,{value:o,onValueChange:e=>s(e),children:[(0,P.jsx)(v,{className:`rounded-xl`,children:(0,P.jsx)(_,{})}),(0,P.jsx)(y,{children:l.map(e=>(0,P.jsx)(b,{value:e.value,children:e.label},e.value))})]})]}):null,(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{className:`text-sm font-medium text-gray-900`,children:u}),(0,P.jsx)(Te,{value:d,onChange:p}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerExtraHeadersHelpShort`)})]})]}):null]})}function Oe(e){let{providerAuth:t,providerAuthNote:n,providerAuthMethodOptions:r,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:s,resolvedAuthMethodId:c,onAuthMethodChange:u,onStartProviderAuth:d,onImportProviderAuthFromCli:p,startPending:m,importPending:h,authSessionId:g,authStatusMessage:S}=e;return t?.kind===`device_code`?(0,P.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,P.jsx)(f,{className:`text-sm font-medium text-gray-900`,children:t.displayName||i(`providerAuthSectionTitle`)}),n?(0,P.jsx)(`p`,{className:`text-xs text-gray-600`,children:n}):null,a>1?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{className:`text-xs font-medium text-gray-700`,children:i(`providerAuthMethodLabel`)}),s?(0,P.jsx)(Ee,{value:c,onChange:u,options:r}):(0,P.jsxs)(x,{value:c,onValueChange:u,children:[(0,P.jsx)(v,{className:`h-8 rounded-lg bg-white`,children:(0,P.jsx)(_,{placeholder:i(`providerAuthMethodPlaceholder`)})}),(0,P.jsx)(y,{children:r.map(e=>(0,P.jsx)(b,{value:e.value,children:e.label},e.value))})]}),o?(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:d,disabled:m||!!g,children:i(m?`providerAuthStarting`:g?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,P.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:h,children:i(h?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,g?(0,P.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[i(`providerAuthSessionLabel`),`: `,g.slice(0,8),`…`]}):null]}),S?(0,P.jsx)(`p`,{className:`text-xs text-gray-600`,children:S}):null]}):null}function ke(e){let{enabled:t,onChange:n}=e;return(0,P.jsx)(ye,{tone:`muted`,title:i(`enabled`),control:(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`span`,{className:`text-xs text-gray-500`,children:i(t?`enabled`:`disabled`)}),(0,P.jsx)(d,{checked:t,onCheckedChange:n})]})})}var Ae={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},je=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],F=new Set(je);function I(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function Me(e,t){let n=I(e),r=I(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Ne(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Pe(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function L(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Pe(n,t))}return n.trim()}function Fe(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ie(e,t){return t}function Le(e,t){return e}function Re(e,t,n){t!==n&&(e.enabled=t)}function R(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&F.has(t)?t:null}function ze(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=R(n);!e||t.includes(e)||t.push(e)}return t}function Be(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=L(r,t);if(!e)continue;let a=ze(i?.supported);if(a.length===0)continue;let o=R(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Ve(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=ze(i.supported);if(e.length===0)continue;let a=R(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function He(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Fe([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function Ue(e){return i(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function We(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Ge(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function Ke(e){let{models:t,modelThinking:n,modelDraft:r,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:s,onAddModel:u,onRemoveModel:d,onToggleModelThinkingLevel:p,onSetModelThinkingDefault:m,thinkingLevels:h,formatThinkingLevelLabel:g}=e;return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(f,{className:`text-sm font-medium text-gray-900`,children:i(`providerModelsTitle`)}),a?null:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,P.jsx)(C,{className:`h-3 w-3`}),i(`providerAddModel`)]})]}),a?(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(c,{value:r,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u()),e.key===`Escape`&&(s(!1),o(``))},placeholder:i(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,P.jsx)(l,{type:`button`,size:`sm`,onClick:u,disabled:r.trim().length===0,children:i(`add`)}),(0,P.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{s(!1),o(``)},children:(0,P.jsx)(w,{className:`h-4 w-4`})})]}):null,t.length===0?(0,P.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,P.jsx)(`p`,{className:`text-sm text-gray-500`,children:i(`providerModelsEmptyShort`)}),a?null:(0,P.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:i(`providerAddFirstModel`)})]}):(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=n[e],r=t?.supported??[],a=t?.default??null;return(0,P.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,P.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,P.jsxs)(D,{children:[(0,P.jsx)(ue,{asChild:!0,children:(0,P.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`providerModelThinkingTitle`),title:i(`providerModelThinkingTitle`),children:(0,P.jsx)(Ce,{className:`h-3 w-3`})})}),(0,P.jsxs)(E,{className:`w-80 space-y-3`,children:[(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:i(`providerModelThinkingTitle`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerModelThinkingHint`)})]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:h.map(t=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>p(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${r.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:g(t)},t))}),(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsx)(f,{className:`text-xs font-medium text-gray-700`,children:i(`providerModelThinkingDefault`)}),(0,P.jsxs)(x,{value:a??`__none__`,onValueChange:t=>m(e,t===`__none__`?null:t),disabled:r.length===0,children:[(0,P.jsx)(v,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,P.jsx)(_,{})}),(0,P.jsxs)(y,{children:[(0,P.jsx)(b,{value:`__none__`,children:i(`providerModelThinkingDefaultNone`)}),r.map(e=>(0,P.jsx)(b,{value:e,children:g(e)},e))]})]}),r.length===0?(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`remove`),children:(0,P.jsx)(w,{className:`h-3 w-3`})})]},e)})})]})}function qe(e){return e.enabled?(0,P.jsx)(T,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?i(`statusReady`):i(`statusSetup`),className:e.className}):(0,P.jsx)(T,{status:`inactive`,label:i(`disabled`),className:e.className})}function Je({providerName:e,onProviderDeleted:n}){let r=u(),{data:a}=oe(),{data:o}=ce(),{data:d}=ae(),p=te(),m=ne(),h=re(),g=ie(),_=se(),v=le(),[y,b]=(0,N.useState)(``),[x,S]=(0,N.useState)(!0),[C,w]=(0,N.useState)(``),[T,ee]=(0,N.useState)(null),[E,ue]=(0,N.useState)(`auto`),[D,O]=(0,N.useState)([]),[k,A]=(0,N.useState)({}),[he,j]=(0,N.useState)(``),[M,ye]=(0,N.useState)(``),[xe,Se]=(0,N.useState)(!1),[Ce,Te]=(0,N.useState)(!1),[Ee,F]=(0,N.useState)(null),[Pe,R]=(0,N.useState)(``),[ze,Je]=(0,N.useState)(``),z=(0,N.useRef)(null),B=o?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ae,Ye=d?.uiHints,H=!!B?.isCustom,Xe=e?fe(`providers.${e}.apiKey`,Ye):void 0,Ze=e?fe(`providers.${e}.apiBase`,Ye):void 0,Qe=e?fe(`providers.${e}.extraHeaders`,Ye):void 0,$e=e?fe(`providers.${e}.wireApi`,Ye):void 0,et=B?.displayName||e||``,U=(V.displayName||``).trim()||et,W=V.enabled!==!1,tt=M.trim()||U||e||i(`providersSelectPlaceholder`),G=(0,N.useMemo)(()=>Ne([B?.modelPrefix||e||``,e||``]),[e,B?.modelPrefix]),nt=B?.defaultApiBase||``,rt=V.apiBase||nt,it=I(V.extraHeaders||null),at=V.wireApi||B?.defaultWireApi||`auto`,ot=(0,N.useMemo)(()=>Ne((B?.defaultModels??[]).map(e=>L(e,G))),[B?.defaultModels,G]),st=(0,N.useMemo)(()=>Ne((V.models??[]).map(e=>L(e,G))),[V.models,G]),K=(0,N.useMemo)(()=>Ie(ot,st),[ot,st]),q=(0,N.useMemo)(()=>Ve(Be(V.modelThinking,G),K),[K,G,V.modelThinking]),J=t(),ct=B?.apiBaseHelp?.[J]||B?.apiBaseHelp?.en||Ze?.help||i(`providerApiBaseHelp`),Y=B?.auth,X=Y?.methods??[],Z=!!B?.supportsWireApi||H,lt=(0,N.useMemo)(()=>X.map(e=>({value:e.id,label:e.label?.[J]||e.label?.en||e.id})),[X,J]),ut=(0,N.useMemo)(()=>We({providerName:e,methods:X,defaultMethodId:Y?.defaultMethodId,language:J}),[e,Y?.defaultMethodId,X,J]),Q=(0,N.useMemo)(()=>{if(!X.length)return``;let e=ze.trim();return e&&X.some(t=>t.id===e)?e:ut||X[0]?.id||``},[ze,ut,X]),dt=(0,N.useMemo)(()=>X.find(e=>e.id===Q),[X,Q]),ft=Ge({required:Y?.kind===`device_code`,hasDefault:!!Y?.defaultMethodId?.trim(),optionCount:X.length}),pt=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:i(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),mt=Ge({required:Z,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:pt.length}),$=(0,N.useCallback)(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),ht=(0,N.useCallback)((t,n)=>{$(),z.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await _.mutateAsync({provider:e,data:{sessionId:t}});if(a.status===`pending`){R(i(`providerAuthWaitingBrowser`)),ht(t,a.nextPollMs??n);return}if(a.status===`authorized`){F(null),$(),R(i(`providerAuthCompleted`)),s.success(i(`providerAuthCompleted`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`config-meta`]});return}F(null),$(),R(a.message||`Authorization ${a.status}.`),s.error(a.message||`Authorization ${a.status}.`)}catch(e){F(null),$();let t=e instanceof Error?e.message:String(e);R(t),s.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[$,_,e,r]);(0,N.useEffect)(()=>{if(!e){b(``),S(!0),w(``),ee(null),ue(`auto`),O([]),A({}),j(``),ye(``),F(null),R(``),Je(``),$();return}b(``),S(W),w(rt),ee(V.extraHeaders||null),ue(at),O(K),A(q),j(``),ye(U),F(null),R(``),Je(ut),$()},[e,rt,W,V.extraHeaders,at,K,q,U,ut,$]),(0,N.useEffect)(()=>()=>$(),[$]),(0,N.useEffect)(()=>A(e=>Ve(e,D)),[D]);let gt=(0,N.useMemo)(()=>e?y.trim().length>0||x!==W||C.trim()!==rt.trim()||!Me(T,it)||Z&&E!==at||!Fe(D,K)||!He(k,q)||H&&M.trim()!==U:!1,[e,y,x,W,C,rt,T,it,Z,E,at,D,K,k,q,H,M,U]);return!e||!B?(0,P.jsx)(ge,{children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:i(`providersSelectTitle`)}),(0,P.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:i(`providersSelectDescription`)})]})}):(0,P.jsxs)(pe,{children:[(0,P.jsx)(me,{className:`px-6 py-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:tt}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(i(`providerDeleteConfirm`)))try{await m.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:m.isPending,className:`text-gray-400 transition-colors hover:text-red-500`,title:i(`providerDelete`),children:(0,P.jsx)(de,{className:`h-4 w-4`})}),(0,P.jsx)(qe,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,P.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=y.trim(),i=C.trim(),a=I(T),o=M.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Re(n,x,W),i!==rt.trim()&&(n.apiBase=i.length>0&&i!==nt?i:null),Me(a,it)||(n.extraHeaders=a),Z&&E!==at&&(n.wireApi=E),Fe(D,K)||(n.models=Le(D,ot)),He(k,q)||(n.modelThinking=Ve(k,D)),p.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,P.jsxs)(_e,{className:`space-y-5 px-6 py-5`,children:[(0,P.jsx)(ke,{enabled:x,onChange:S}),H&&(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:i(`providerDisplayName`)}),(0,P.jsx)(c,{id:`providerDisplayName`,type:`text`,value:M,onChange:e=>ye(e.target.value),placeholder:et||i(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerDisplayNameHelpShort`)})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:Xe?.label??i(`apiKey`)}),(0,P.jsx)(we,{id:`apiKey`,value:y,isSet:V.apiKeySet,onChange:e=>b(e.target.value),placeholder:Xe?.placeholder??i(`enterApiKey`),className:`rounded-xl`}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`leaveBlankToKeepUnchanged`)})]}),(0,P.jsx)(Oe,{providerAuth:Y,providerAuthNote:Y?.note?.[J]||Y?.note?.en||Y?.displayName||``,providerAuthMethodOptions:lt,providerAuthMethodsCount:X.length,selectedAuthMethodHint:dt?.hint?.[J]||dt?.hint?.en||``,shouldUseAuthMethodPills:ft,resolvedAuthMethodId:Q,onAuthMethodChange:Je,onStartProviderAuth:async()=>{if(!(!e||Y?.kind!==`device_code`))try{R(``);let t=await g.mutateAsync({provider:e,data:Q?{methodId:Q}:{}});if(!t.sessionId||!t.verificationUri)throw Error(i(`providerAuthStartFailed`));F(t.sessionId),R(`${i(`providerAuthOpenPrompt`)}${t.userCode}${i(`providerAuthOpenPromptSuffix`)}`),window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),ht(t.sessionId,t.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);F(null),$(),R(t),s.error(`${i(`providerAuthStartFailed`)}: ${t}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||Y?.kind!==`device_code`))try{$(),F(null);let t=await v.mutateAsync({provider:e});R(`${i(`providerAuthImportStatusPrefix`)}${t.expiresAt?` (expires: ${t.expiresAt})`:``}`),s.success(i(`providerAuthImportSuccess`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let t=e instanceof Error?e.message:String(e);R(t),s.error(`${i(`providerAuthImportFailed`)}: ${t}`)}},startPending:g.isPending,importPending:v.isPending,authSessionId:Ee,authStatusMessage:Pe}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Ze?.label??i(`apiBase`)}),(0,P.jsx)(c,{id:`apiBase`,type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:nt||Ze?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:ct})]}),(0,P.jsx)(Ke,{models:D,modelThinking:k,modelDraft:he,showModelInput:Ce,onModelDraftChange:j,onShowModelInputChange:Te,onAddModel:()=>{let e=L(he,G);if(e){if(D.includes(e)){j(``);return}O(t=>[...t,e]),j(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),A(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{A(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):je.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{A(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:je,formatThinkingLevelLabel:Ue}),(0,P.jsx)(De,{showAdvanced:xe,onShowAdvancedChange:Se,supportsWireApi:Z,wireApiLabel:$e?.label??i(`wireApi`),wireApi:E,onWireApiChange:ue,shouldUseWireApiPills:mt,wireApiSelectOptions:pt,extraHeadersLabel:Qe?.label??i(`extraHeaders`),extraHeaders:T,onExtraHeadersChange:ee})]}),(0,P.jsxs)(ve,{className:`flex items-center justify-between px-6 py-4`,children:[(0,P.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let t=L(D.find(e=>e.trim().length>0)??``,G),n={apiBase:C.trim(),extraHeaders:I(T),model:t||null};y.trim().length>0&&(n.apiKey=y.trim()),Z&&(n.wireApi=E);try{let t=await h.mutateAsync({provider:e,data:n});if(t.success){s.success(`${i(`providerTestConnectionSuccess`)} (${t.latencyMs}ms)`);return}let r=[`provider=${t.provider}`,`latency=${t.latencyMs}ms`];t.model&&r.push(`model=${t.model}`),s.error(`${i(`providerTestConnectionFailed`)}: ${t.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);s.error(`${i(`providerTestConnectionFailed`)}: ${t}`)}},disabled:h.isPending,children:[(0,P.jsx)(be,{className:`mr-1.5 h-4 w-4`}),h.isPending?i(`providerTestingConnection`):i(`providerTestConnection`)]}),(0,P.jsx)(l,{type:`submit`,disabled:p.isPending||!gt,children:p.isPending?i(`saving`):i(gt?`save`:`unchanged`)})]})]})]})}function z(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function B(e){return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let n=e.provider.name===`nextclaw`?1:0,r=t.provider.name===`nextclaw`?1:0;return n===r?e.index-t.index:n-r}).map(({provider:e})=>e)}function V(){let{isMobile:e}=O(),{data:t}=oe(),{data:n}=ce(),{data:r}=ae(),s=ee(),[u,d]=(0,N.useState)(`installed`),[f,m]=(0,N.useState)(null),[g,_]=(0,N.useState)(``),v=(0,N.useMemo)(()=>B(n?.providers??[]),[n?.providers]),y=t?.providers??{},b=(0,N.useMemo)(()=>{let e=g.trim().toLowerCase();return v.filter(e=>u!==`installed`||!!(y[e.name]?.enabled!==!1&&y[e.name]?.apiKeySet)).filter(t=>e?(y[t.name]?.displayName?.trim()||t.displayName||t.name).toLowerCase().includes(e)||t.name.toLowerCase().includes(e):!0)},[u,v,y,g]),x=(0,N.useMemo)(()=>f&&b.some(e=>e.name===f)?f:e?null:b[0]?.name??null,[b,e,f]);return!t||!n?(0,P.jsx)(`div`,{className:`p-8`,children:i(`providersLoading`)}):(0,P.jsxs)(o,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,P.jsx)(p,{title:i(`providersPageTitle`),description:i(`providersPageDescription`)}),(0,P.jsxs)(he,{className:`xl:min-h-0`,mobileView:e?x?`detail`:`list`:void 0,onMobileBack:()=>m(null),mobileListLabel:i(`providersPageTitle`),children:[(0,P.jsxs)(pe,{children:[(0,P.jsxs)(me,{className:`space-y-3 px-4 pb-3 pt-4`,children:[(0,P.jsx)(A,{tabs:[{id:`installed`,label:i(`providersTabConfigured`),count:v.filter(e=>y[e.name]?.enabled!==!1&&y[e.name]?.apiKeySet).length},{id:`all`,label:i(`providersTabAll`),count:v.length}],activeTab:u,onChange:d,className:`mb-0`}),(0,P.jsxs)(l,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await s.mutateAsync({data:{}});d(`all`),_(``),m(e.name)}catch{}},disabled:s.isPending,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),s.isPending?i(`saving`):i(`providerAddCustom`)]})]}),(0,P.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(h,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,P.jsx)(c,{value:g,onChange:e=>_(e.target.value),placeholder:i(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,P.jsxs)(_e,{className:`space-y-2 p-3`,children:[b.map(e=>{let t=y[e.name],n=t?.enabled!==!1,o=!!(n&&t?.apiKeySet),s=t?.displayName?.trim()||e.displayName||e.name,c=z(t?.apiBase||e.defaultApiBase||``)||fe(`providers.${e.name}`,r?.uiHints)?.help||i(`providersDefaultDescription`);return(0,P.jsx)(M,{onClick:()=>m(e.name),active:x===e.name,children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,P.jsx)(k,{name:e.name,src:e.logo?`/logos/${e.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,P.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:e.name[0]})}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:s}),(0,P.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:c})]})]}),(0,P.jsx)(T,{status:n?o?`ready`:`setup`:`inactive`,label:i(n?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},e.name)}),b.length===0?(0,P.jsx)(j,{icon:S,title:i(`providersNoMatch`)}):null]})]}),(0,P.jsx)(Je,{providerName:x??void 0,onProviderDeleted:e=>{e===x&&m(null)}})]})]})}export{V as ProvidersList};
1
+ import{_ as e,a as t,m as n,p as r,r as i,u as a}from"./i18n-D1144VAA.js";import{At as o,Lt as s,Mt as c,Nt as l,Xt as u,ft as d,jt as f,kt as p}from"./api-CKKNxbsy.js";import{t as m}from"./createLucideIcon-DzY6wN61.js";import{t as h}from"./search-CRtQwr-h.js";import{O as g,a as _,i as v,n as y,r as b,t as x}from"./select-C2c10F3e.js";import{t as S}from"./key-round-DUq47t0P.js";import{t as C}from"./plus-B-YHtTNC.js";import{t as w}from"./x-BeyYA_h6.js";import{t as T}from"./status-dot-l3kPFdq_.js";import{a as ee,b as te,c as ne,g as re,h as ie,i as ae,n as oe,p as se,r as ce,u as le}from"./use-config-jAYudJxy.js";import{n as E,r as ue,t as D}from"./popover-2H9DS7Cv.js";import{X as de,Y as O,q as k}from"./index-zYi4W031.js";import{t as A}from"./tabs-custom-D48zdZoc.js";import{t as fe}from"./config-hints-BNfpOL4J.js";import{a as pe,c as me,i as he,n as ge,o as _e,r as j,s as ve,t as M}from"./config-split-page-CcrEUtwu.js";import{t as ye}from"./setting-row-CB_ZFbIZ.js";var be=m(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),xe=m(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Se=m(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ce=m(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),N=e(n(),1),P=r();function we({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[s,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1),p=typeof n==`string`&&n.length>0;return(0,P.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,P.jsx)(`div`,{onClick:()=>f(!0),className:a(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,P.jsx)(c,{type:s?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{p||f(!1)},placeholder:i,autoFocus:d,...o}),(0,P.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,P.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!s),children:s?(0,P.jsx)(xe,{className:`h-4 w-4`}):(0,P.jsx)(Se,{className:`h-4 w-4`})})})]})}function Te({value:e,onChange:t,className:n}){let r=e?Object.entries(e):[],o=(e,n,i)=>{let a=[...r];a[e]=[n,i],t(Object.fromEntries(a))},s=()=>{t({...e,"":``})},u=e=>{let n=r.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,P.jsxs)(`div`,{className:a(`space-y-2`,n),children:[r.map(([e,t],n)=>(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(c,{type:`text`,value:e,onChange:e=>o(n,e.target.value,t),placeholder:i(`headerName`),className:`flex-1`}),(0,P.jsx)(c,{type:`text`,value:t,onChange:t=>o(n,e,t.target.value),placeholder:i(`headerValue`),className:`flex-1`}),(0,P.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>u(n),children:(0,P.jsx)(de,{className:`h-4 w-4 text-red-500`})})]},n)),(0,P.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,P.jsx)(C,{className:`h-4 w-4 mr-2`}),i(`add`)]})]})}function Ee(e){let{value:t,onChange:n,options:r}=e;return(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,P.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function De(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:r,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:p}=e;return(0,P.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(Ce,{className:`h-3.5 w-3.5`}),i(`providerAdvancedSettings`)]}),(0,P.jsx)(g,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,P.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[r?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,P.jsx)(Ee,{value:o,onChange:e=>s(e),options:l}):(0,P.jsxs)(x,{value:o,onValueChange:e=>s(e),children:[(0,P.jsx)(v,{className:`rounded-xl`,children:(0,P.jsx)(_,{})}),(0,P.jsx)(y,{children:l.map(e=>(0,P.jsx)(b,{value:e.value,children:e.label},e.value))})]})]}):null,(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{className:`text-sm font-medium text-gray-900`,children:u}),(0,P.jsx)(Te,{value:d,onChange:p}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerExtraHeadersHelpShort`)})]})]}):null]})}function Oe(e){let{providerAuth:t,providerAuthNote:n,providerAuthMethodOptions:r,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:s,resolvedAuthMethodId:c,onAuthMethodChange:u,onStartProviderAuth:d,onImportProviderAuthFromCli:p,startPending:m,importPending:h,authSessionId:g,authStatusMessage:S}=e;return t?.kind===`device_code`?(0,P.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,P.jsx)(f,{className:`text-sm font-medium text-gray-900`,children:t.displayName||i(`providerAuthSectionTitle`)}),n?(0,P.jsx)(`p`,{className:`text-xs text-gray-600`,children:n}):null,a>1?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{className:`text-xs font-medium text-gray-700`,children:i(`providerAuthMethodLabel`)}),s?(0,P.jsx)(Ee,{value:c,onChange:u,options:r}):(0,P.jsxs)(x,{value:c,onValueChange:u,children:[(0,P.jsx)(v,{className:`h-8 rounded-lg bg-white`,children:(0,P.jsx)(_,{placeholder:i(`providerAuthMethodPlaceholder`)})}),(0,P.jsx)(y,{children:r.map(e=>(0,P.jsx)(b,{value:e.value,children:e.label},e.value))})]}),o?(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:d,disabled:m||!!g,children:i(m?`providerAuthStarting`:g?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,P.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:h,children:i(h?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,g?(0,P.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[i(`providerAuthSessionLabel`),`: `,g.slice(0,8),`…`]}):null]}),S?(0,P.jsx)(`p`,{className:`text-xs text-gray-600`,children:S}):null]}):null}function ke(e){let{enabled:t,onChange:n}=e;return(0,P.jsx)(ye,{tone:`muted`,title:i(`enabled`),control:(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`span`,{className:`text-xs text-gray-500`,children:i(t?`enabled`:`disabled`)}),(0,P.jsx)(d,{checked:t,onCheckedChange:n})]})})}var Ae={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},je=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],F=new Set(je);function I(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function Me(e,t){let n=I(e),r=I(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Ne(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Pe(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function L(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Pe(n,t))}return n.trim()}function Fe(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ie(e,t){return t}function Le(e,t){return e}function Re(e,t,n){t!==n&&(e.enabled=t)}function R(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&F.has(t)?t:null}function ze(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=R(n);!e||t.includes(e)||t.push(e)}return t}function Be(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=L(r,t);if(!e)continue;let a=ze(i?.supported);if(a.length===0)continue;let o=R(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Ve(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=ze(i.supported);if(e.length===0)continue;let a=R(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function He(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Fe([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function Ue(e){return i(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function We(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Ge(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function Ke(e){let{models:t,modelThinking:n,modelDraft:r,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:s,onAddModel:u,onRemoveModel:d,onToggleModelThinkingLevel:p,onSetModelThinkingDefault:m,thinkingLevels:h,formatThinkingLevelLabel:g}=e;return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(f,{className:`text-sm font-medium text-gray-900`,children:i(`providerModelsTitle`)}),a?null:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,P.jsx)(C,{className:`h-3 w-3`}),i(`providerAddModel`)]})]}),a?(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(c,{value:r,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u()),e.key===`Escape`&&(s(!1),o(``))},placeholder:i(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,P.jsx)(l,{type:`button`,size:`sm`,onClick:u,disabled:r.trim().length===0,children:i(`add`)}),(0,P.jsx)(l,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{s(!1),o(``)},children:(0,P.jsx)(w,{className:`h-4 w-4`})})]}):null,t.length===0?(0,P.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,P.jsx)(`p`,{className:`text-sm text-gray-500`,children:i(`providerModelsEmptyShort`)}),a?null:(0,P.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:i(`providerAddFirstModel`)})]}):(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=n[e],r=t?.supported??[],a=t?.default??null;return(0,P.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,P.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,P.jsxs)(D,{children:[(0,P.jsx)(ue,{asChild:!0,children:(0,P.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`providerModelThinkingTitle`),title:i(`providerModelThinkingTitle`),children:(0,P.jsx)(Ce,{className:`h-3 w-3`})})}),(0,P.jsxs)(E,{className:`w-80 space-y-3`,children:[(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:i(`providerModelThinkingTitle`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerModelThinkingHint`)})]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:h.map(t=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>p(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${r.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:g(t)},t))}),(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsx)(f,{className:`text-xs font-medium text-gray-700`,children:i(`providerModelThinkingDefault`)}),(0,P.jsxs)(x,{value:a??`__none__`,onValueChange:t=>m(e,t===`__none__`?null:t),disabled:r.length===0,children:[(0,P.jsx)(v,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,P.jsx)(_,{})}),(0,P.jsxs)(y,{children:[(0,P.jsx)(b,{value:`__none__`,children:i(`providerModelThinkingDefaultNone`)}),r.map(e=>(0,P.jsx)(b,{value:e,children:g(e)},e))]})]}),r.length===0?(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`remove`),children:(0,P.jsx)(w,{className:`h-3 w-3`})})]},e)})})]})}function qe(e){return e.enabled?(0,P.jsx)(T,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?i(`statusReady`):i(`statusSetup`),className:e.className}):(0,P.jsx)(T,{status:`inactive`,label:i(`disabled`),className:e.className})}function Je({providerName:e,onProviderDeleted:n}){let r=u(),{data:a}=oe(),{data:o}=ce(),{data:d}=ae(),p=te(),m=ne(),h=re(),g=ie(),_=se(),v=le(),[y,b]=(0,N.useState)(``),[x,S]=(0,N.useState)(!0),[C,w]=(0,N.useState)(``),[T,ee]=(0,N.useState)(null),[E,ue]=(0,N.useState)(`auto`),[D,O]=(0,N.useState)([]),[k,A]=(0,N.useState)({}),[he,j]=(0,N.useState)(``),[M,ye]=(0,N.useState)(``),[xe,Se]=(0,N.useState)(!1),[Ce,Te]=(0,N.useState)(!1),[Ee,F]=(0,N.useState)(null),[Pe,R]=(0,N.useState)(``),[ze,Je]=(0,N.useState)(``),z=(0,N.useRef)(null),B=o?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ae,Ye=d?.uiHints,H=!!B?.isCustom,Xe=e?fe(`providers.${e}.apiKey`,Ye):void 0,Ze=e?fe(`providers.${e}.apiBase`,Ye):void 0,Qe=e?fe(`providers.${e}.extraHeaders`,Ye):void 0,$e=e?fe(`providers.${e}.wireApi`,Ye):void 0,et=B?.displayName||e||``,U=(V.displayName||``).trim()||et,W=V.enabled!==!1,tt=M.trim()||U||e||i(`providersSelectPlaceholder`),G=(0,N.useMemo)(()=>Ne([B?.modelPrefix||e||``,e||``]),[e,B?.modelPrefix]),nt=B?.defaultApiBase||``,rt=V.apiBase||nt,it=I(V.extraHeaders||null),at=V.wireApi||B?.defaultWireApi||`auto`,ot=(0,N.useMemo)(()=>Ne((B?.defaultModels??[]).map(e=>L(e,G))),[B?.defaultModels,G]),st=(0,N.useMemo)(()=>Ne((V.models??[]).map(e=>L(e,G))),[V.models,G]),K=(0,N.useMemo)(()=>Ie(ot,st),[ot,st]),q=(0,N.useMemo)(()=>Ve(Be(V.modelThinking,G),K),[K,G,V.modelThinking]),J=t(),ct=B?.apiBaseHelp?.[J]||B?.apiBaseHelp?.en||Ze?.help||i(`providerApiBaseHelp`),Y=B?.auth,X=Y?.methods??[],Z=!!B?.supportsWireApi||H,lt=(0,N.useMemo)(()=>X.map(e=>({value:e.id,label:e.label?.[J]||e.label?.en||e.id})),[X,J]),ut=(0,N.useMemo)(()=>We({providerName:e,methods:X,defaultMethodId:Y?.defaultMethodId,language:J}),[e,Y?.defaultMethodId,X,J]),Q=(0,N.useMemo)(()=>{if(!X.length)return``;let e=ze.trim();return e&&X.some(t=>t.id===e)?e:ut||X[0]?.id||``},[ze,ut,X]),dt=(0,N.useMemo)(()=>X.find(e=>e.id===Q),[X,Q]),ft=Ge({required:Y?.kind===`device_code`,hasDefault:!!Y?.defaultMethodId?.trim(),optionCount:X.length}),pt=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:i(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),mt=Ge({required:Z,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:pt.length}),$=(0,N.useCallback)(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),ht=(0,N.useCallback)((t,n)=>{$(),z.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await _.mutateAsync({provider:e,data:{sessionId:t}});if(a.status===`pending`){R(i(`providerAuthWaitingBrowser`)),ht(t,a.nextPollMs??n);return}if(a.status===`authorized`){F(null),$(),R(i(`providerAuthCompleted`)),s.success(i(`providerAuthCompleted`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`config-meta`]});return}F(null),$(),R(a.message||`Authorization ${a.status}.`),s.error(a.message||`Authorization ${a.status}.`)}catch(e){F(null),$();let t=e instanceof Error?e.message:String(e);R(t),s.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[$,_,e,r]);(0,N.useEffect)(()=>{if(!e){b(``),S(!0),w(``),ee(null),ue(`auto`),O([]),A({}),j(``),ye(``),F(null),R(``),Je(``),$();return}b(``),S(W),w(rt),ee(V.extraHeaders||null),ue(at),O(K),A(q),j(``),ye(U),F(null),R(``),Je(ut),$()},[e,rt,W,V.extraHeaders,at,K,q,U,ut,$]),(0,N.useEffect)(()=>()=>$(),[$]),(0,N.useEffect)(()=>A(e=>Ve(e,D)),[D]);let gt=(0,N.useMemo)(()=>e?y.trim().length>0||x!==W||C.trim()!==rt.trim()||!Me(T,it)||Z&&E!==at||!Fe(D,K)||!He(k,q)||H&&M.trim()!==U:!1,[e,y,x,W,C,rt,T,it,Z,E,at,D,K,k,q,H,M,U]);return!e||!B?(0,P.jsx)(ge,{children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:i(`providersSelectTitle`)}),(0,P.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:i(`providersSelectDescription`)})]})}):(0,P.jsxs)(pe,{children:[(0,P.jsx)(me,{className:`px-6 py-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:tt}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(i(`providerDeleteConfirm`)))try{await m.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:m.isPending,className:`text-gray-400 transition-colors hover:text-red-500`,title:i(`providerDelete`),children:(0,P.jsx)(de,{className:`h-4 w-4`})}),(0,P.jsx)(qe,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,P.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=y.trim(),i=C.trim(),a=I(T),o=M.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Re(n,x,W),i!==rt.trim()&&(n.apiBase=i.length>0&&i!==nt?i:null),Me(a,it)||(n.extraHeaders=a),Z&&E!==at&&(n.wireApi=E),Fe(D,K)||(n.models=Le(D,ot)),He(k,q)||(n.modelThinking=Ve(k,D)),p.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,P.jsxs)(_e,{className:`space-y-5 px-6 py-5`,children:[(0,P.jsx)(ke,{enabled:x,onChange:S}),H&&(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:i(`providerDisplayName`)}),(0,P.jsx)(c,{id:`providerDisplayName`,type:`text`,value:M,onChange:e=>ye(e.target.value),placeholder:et||i(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`providerDisplayNameHelpShort`)})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:Xe?.label??i(`apiKey`)}),(0,P.jsx)(we,{id:`apiKey`,value:y,isSet:V.apiKeySet,onChange:e=>b(e.target.value),placeholder:Xe?.placeholder??i(`enterApiKey`),className:`rounded-xl`}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:i(`leaveBlankToKeepUnchanged`)})]}),(0,P.jsx)(Oe,{providerAuth:Y,providerAuthNote:Y?.note?.[J]||Y?.note?.en||Y?.displayName||``,providerAuthMethodOptions:lt,providerAuthMethodsCount:X.length,selectedAuthMethodHint:dt?.hint?.[J]||dt?.hint?.en||``,shouldUseAuthMethodPills:ft,resolvedAuthMethodId:Q,onAuthMethodChange:Je,onStartProviderAuth:async()=>{if(!(!e||Y?.kind!==`device_code`))try{R(``);let t=await g.mutateAsync({provider:e,data:Q?{methodId:Q}:{}});if(!t.sessionId||!t.verificationUri)throw Error(i(`providerAuthStartFailed`));F(t.sessionId),R(`${i(`providerAuthOpenPrompt`)}${t.userCode}${i(`providerAuthOpenPromptSuffix`)}`),window.open(t.verificationUri,`_blank`,`noopener,noreferrer`),ht(t.sessionId,t.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);F(null),$(),R(t),s.error(`${i(`providerAuthStartFailed`)}: ${t}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||Y?.kind!==`device_code`))try{$(),F(null);let t=await v.mutateAsync({provider:e});R(`${i(`providerAuthImportStatusPrefix`)}${t.expiresAt?` (expires: ${t.expiresAt})`:``}`),s.success(i(`providerAuthImportSuccess`)),r.invalidateQueries({queryKey:[`config`]}),r.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let t=e instanceof Error?e.message:String(e);R(t),s.error(`${i(`providerAuthImportFailed`)}: ${t}`)}},startPending:g.isPending,importPending:v.isPending,authSessionId:Ee,authStatusMessage:Pe}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(f,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Ze?.label??i(`apiBase`)}),(0,P.jsx)(c,{id:`apiBase`,type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:nt||Ze?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:ct})]}),(0,P.jsx)(Ke,{models:D,modelThinking:k,modelDraft:he,showModelInput:Ce,onModelDraftChange:j,onShowModelInputChange:Te,onAddModel:()=>{let e=L(he,G);if(e){if(D.includes(e)){j(``);return}O(t=>[...t,e]),j(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),A(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{A(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):je.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{A(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:je,formatThinkingLevelLabel:Ue}),(0,P.jsx)(De,{showAdvanced:xe,onShowAdvancedChange:Se,supportsWireApi:Z,wireApiLabel:$e?.label??i(`wireApi`),wireApi:E,onWireApiChange:ue,shouldUseWireApiPills:mt,wireApiSelectOptions:pt,extraHeadersLabel:Qe?.label??i(`extraHeaders`),extraHeaders:T,onExtraHeadersChange:ee})]}),(0,P.jsxs)(ve,{className:`flex items-center justify-between px-6 py-4`,children:[(0,P.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let t=L(D.find(e=>e.trim().length>0)??``,G),n={apiBase:C.trim(),extraHeaders:I(T),model:t||null};y.trim().length>0&&(n.apiKey=y.trim()),Z&&(n.wireApi=E);try{let t=await h.mutateAsync({provider:e,data:n});if(t.success){s.success(`${i(`providerTestConnectionSuccess`)} (${t.latencyMs}ms)`);return}let r=[`provider=${t.provider}`,`latency=${t.latencyMs}ms`];t.model&&r.push(`model=${t.model}`),s.error(`${i(`providerTestConnectionFailed`)}: ${t.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);s.error(`${i(`providerTestConnectionFailed`)}: ${t}`)}},disabled:h.isPending,children:[(0,P.jsx)(be,{className:`mr-1.5 h-4 w-4`}),h.isPending?i(`providerTestingConnection`):i(`providerTestConnection`)]}),(0,P.jsx)(l,{type:`submit`,disabled:p.isPending||!gt,children:p.isPending?i(`saving`):i(gt?`save`:`unchanged`)})]})]})]})}function z(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function B(e){return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let n=e.provider.name===`nextclaw`?1:0,r=t.provider.name===`nextclaw`?1:0;return n===r?e.index-t.index:n-r}).map(({provider:e})=>e)}function V(){let{isMobile:e}=O(),{data:t}=oe(),{data:n}=ce(),{data:r}=ae(),s=ee(),[u,d]=(0,N.useState)(`installed`),[f,m]=(0,N.useState)(null),[g,_]=(0,N.useState)(``),v=(0,N.useMemo)(()=>B(n?.providers??[]),[n?.providers]),y=t?.providers??{},b=(0,N.useMemo)(()=>{let e=g.trim().toLowerCase();return v.filter(e=>u!==`installed`||!!(y[e.name]?.enabled!==!1&&y[e.name]?.apiKeySet)).filter(t=>e?(y[t.name]?.displayName?.trim()||t.displayName||t.name).toLowerCase().includes(e)||t.name.toLowerCase().includes(e):!0)},[u,v,y,g]),x=(0,N.useMemo)(()=>f&&b.some(e=>e.name===f)?f:e?null:b[0]?.name??null,[b,e,f]);return!t||!n?(0,P.jsx)(`div`,{className:`p-8`,children:i(`providersLoading`)}):(0,P.jsxs)(o,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,P.jsx)(p,{title:i(`providersPageTitle`),description:i(`providersPageDescription`)}),(0,P.jsxs)(he,{className:`xl:min-h-0`,mobileView:e?x?`detail`:`list`:void 0,onMobileBack:()=>m(null),mobileListLabel:i(`providersPageTitle`),children:[(0,P.jsxs)(pe,{children:[(0,P.jsxs)(me,{className:`space-y-3 px-4 pb-3 pt-4`,children:[(0,P.jsx)(A,{tabs:[{id:`installed`,label:i(`providersTabConfigured`),count:v.filter(e=>y[e.name]?.enabled!==!1&&y[e.name]?.apiKeySet).length},{id:`all`,label:i(`providersTabAll`),count:v.length}],activeTab:u,onChange:d,className:`mb-0`}),(0,P.jsxs)(l,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await s.mutateAsync({data:{}});d(`all`),_(``),m(e.name)}catch{}},disabled:s.isPending,children:[(0,P.jsx)(C,{className:`mr-2 h-4 w-4`}),s.isPending?i(`saving`):i(`providerAddCustom`)]})]}),(0,P.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(h,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,P.jsx)(c,{value:g,onChange:e=>_(e.target.value),placeholder:i(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,P.jsxs)(_e,{className:`space-y-2 p-3`,children:[b.map(e=>{let t=y[e.name],n=t?.enabled!==!1,o=!!(n&&t?.apiKeySet),s=t?.displayName?.trim()||e.displayName||e.name,c=z(t?.apiBase||e.defaultApiBase||``)||fe(`providers.${e.name}`,r?.uiHints)?.help||i(`providersDefaultDescription`);return(0,P.jsx)(M,{onClick:()=>m(e.name),active:x===e.name,children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,P.jsx)(k,{name:e.name,src:e.logo?`/logos/${e.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,P.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:e.name[0]})}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:s}),(0,P.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:c})]})]}),(0,P.jsx)(T,{status:n?o?`ready`:`setup`:`inactive`,label:i(n?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},e.name)}),b.length===0?(0,P.jsx)(j,{icon:S,title:i(`providersNoMatch`)}):null]})]}),(0,P.jsx)(Je,{providerName:x??void 0,onProviderDeleted:e=>{e===x&&m(null)}})]})]})}export{V as ProvidersList};
@@ -0,0 +1 @@
1
+ import{m as e}from"./app-manager-provider-BM1hziPv.js";export{e as RemoteAccessPage};
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Dt as a,Et as o,Lt as s,Mt as c,Nt as l,Ot as u,Tt as d,_t as f,ft as p,ht as m,kt as h,wt as g,xt as _,yt as v}from"./api-DGD9_Bg4.js";import{t as y}from"./createLucideIcon-DzY6wN61.js";import{b,l as x,x as S}from"./desktop-DVUbOWbR.js";import{a as C,i as w,n as T,r as E,t as D}from"./select-BUTwE_lC.js";import{t as ee}from"./play-AqrNslHI.js";import{t as O}from"./plus-B-YHtTNC.js";import{t as te}from"./rotate-cw-BN9yjccP.js";import{t as ne}from"./save-CO_4qf6b.js";import{t as k}from"./notice-card-Dr6xCwva.js";import{n as A,x as j}from"./use-config-Cyv5IuSt.js";import{Q as M,X as N}from"./index-DqJ3CYwi.js";import{t as P}from"./setting-row-BavcnXw1.js";var re=y(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),F=e(t(),1),I=n(),L={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},R={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},z={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function B(e){return r(L[e]??`runtimeControlUnavailable`)}function V(e){return r(R[e]??`runtimeControlServiceUnknown`)}function H(e){return r(z[e.environment])}function U(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function W(e){return e?[{action:`start-service`,capability:e.canStartService,label:r(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:r(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:r(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:r(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function G(e){let{busy:t,icon:n}=e;return t?(0,I.jsx)(M,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,I.jsx)(ee,{className:`mr-2 h-4 w-4`}):n===`square`?(0,I.jsx)(re,{className:`mr-2 h-4 w-4`}):(0,I.jsx)(te,{className:`mr-2 h-4 w-4`})}function K(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:c,visibleLifecycle:f,visibleMessage:p,visibleServiceState:h}=m(),y=W(n??void 0),b=async e=>{let t=U(n,e);if(!t?.available){s.error(_(t?.reasonIfUnavailable)??r(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(r(`runtimeControlStopServiceConfirm`))))try{let t=await v.runRuntimeControlAction(e);s.success(_(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);s.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}},x=async()=>{if(!n?.canRestartApp.available){s.error(_(n?.canRestartApp.reasonIfUnavailable)??r(`runtimeRestartAppUnavailable`));return}if(window.confirm(r(`runtimeControlRestartAppConfirm`)))try{let e=await v.runRuntimeControlAction(`restart-app`);s.success(_(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);s.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`runtimeControlTitle`)}),(0,I.jsx)(o,{children:r(`runtimeControlDescription`)})]}),(0,I.jsxs)(d,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-gray-200 bg-gray-50 p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:V(h)}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:n?H(n):r(`runtimeControlLoading`)})]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600`,children:p}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:B(f)}),n?.managementHint?(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:_(n.managementHint)}):null,i&&!e?(0,I.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),c?(0,I.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-amber-200 bg-amber-50 p-4`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:r(`runtimeControlPendingRestartTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-amber-800`,children:r(`runtimeControlPendingRestartDescription`)}),c.changedPaths.length>0?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:r(`runtimeControlPendingRestartPaths`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.changedPaths.map(e=>(0,I.jsx)(`span`,{className:`rounded-full border border-amber-200 bg-white px-2.5 py-1 text-xs text-amber-800`,children:e},e))})]}):null]}):null,(0,I.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:y.map(n=>(0,I.jsxs)(l,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){x();return}b(n.action)},disabled:!n.capability.available||e,children:[(0,I.jsx)(G,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),y.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:_(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})}function q(e){let{description:t,title:n}=e;return(0,I.jsx)(k,{tone:`neutral`,title:n,description:t})}function J(e){let{children:t}=e;return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`runtimePresenceTitle`)}),(0,I.jsx)(o,{children:r(`runtimePresenceDescription`)})]}),(0,I.jsx)(d,{children:t})]})}function Y(){let e=f().runtimeControlView?.environment,t=S(e=>e.supported),n=S(e=>e.initialized),i=S(e=>e.busyAction),a=S(e=>e.snapshot);return(0,F.useEffect)(()=>{if(e===`desktop-embedded`){b.start();return}b.markUnsupported()},[e]),e===`desktop-embedded`?(0,I.jsx)(J,{children:(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(k,{tone:`neutral`,title:r(`runtimePresenceBehaviorLabel`),description:a?.closeToBackground?r(`runtimePresenceBehaviorBackground`):r(`runtimePresenceBehaviorQuit`),className:`rounded-xl`}),!n||t&&!a?(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:r(`runtimePresenceLoading`)}):null,a?(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(P,{title:r(`runtimePresenceCloseToBackground`),description:r(`runtimePresenceCloseToBackgroundHelp`),control:(0,I.jsx)(p,{id:`runtime-presence-close-background`,"aria-label":r(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{b.updatePreferences({closeToBackground:e})}})}),(0,I.jsx)(P,{title:r(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?r(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??r(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,I.jsx)(p,{id:`runtime-presence-launch-login`,"aria-label":r(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{b.updatePreferences({launchAtLogin:e})}})})]}):null]})}):e===`managed-local-service`?(0,I.jsx)(J,{children:(0,I.jsx)(q,{title:r(`runtimePresenceManagedLocalTitle`),description:r(`runtimePresenceManagedLocalDescription`)})}):e===`self-hosted-web`?(0,I.jsx)(J,{children:(0,I.jsx)(q,{title:r(`runtimePresenceSelfHostedTitle`),description:r(`runtimePresenceSelfHostedDescription`)})}):e===`shared-web`?(0,I.jsx)(J,{children:(0,I.jsx)(q,{title:r(`runtimePresenceSharedTitle`),description:r(`runtimePresenceSharedDescription`)})}):(0,I.jsx)(J,{children:(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:r(`runtimePresenceLoading`)})})}function X(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`)}),(0,I.jsx)(K,{}),(0,I.jsx)(Y,{}),(0,I.jsx)(x,{})]})}var Z={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function ie(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function ae(){return{agentId:``,match:{channel:``,accountId:``}}}function oe(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Z,configText:JSON.stringify(Z,null,2)}}function se(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function Q(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function $(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ce(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(se),bindings:(e.bindings??[]).map(Q),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function le(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function ue(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(r(`agentIdRequiredError`).replace(`{index}`,String(t)));return le(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${r(`duplicateAgentId`)}: ${n[0]}`);let i=e.bindings.map((t,n)=>{let i=t.agentId.trim(),a=t.match.channel.trim(),o=t.match.accountId?.trim()??``,s=t.match.peer?.kind,c=t.match.peer?.id?.trim()??``;if(!i)throw Error(r(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(i))throw Error(`${r(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${i}`);if(!a)throw Error(r(`bindingChannelRequired`).replace(`{index}`,String(n)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(r(`bindingPeerIdRequired`).replace(`{index}`,String(n)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,n)=>{let i=t.id.trim(),a=t.type.trim();if(!i)throw Error(r(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!a)throw Error(r(`runtimeEntryTypeRequired`).replace(`{id}`,i));if(e[i])throw Error(`${r(`runtimeEntryDuplicate`)}: ${i}`);let o=t.configText.trim()?JSON.parse(t.configText):{};if(o&&(typeof o!=`object`||Array.isArray(o)))throw Error(r(`runtimeEntryConfigObjectRequired`).replace(`{id}`,i));return e[i]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:a,config:o??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function de(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`agentList`)}),(0,I.jsx)(o,{children:r(`agentListHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-3`,children:[e.agents.map((t,n)=>(0,I.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,I.jsx)(c,{value:t.id,onChange:t=>e.onUpdateAgent(n,{id:t.target.value}),placeholder:r(`agentIdPlaceholder`)}),(0,I.jsx)(c,{value:t.workspace??``,onChange:t=>e.onUpdateAgent(n,{workspace:t.target.value}),placeholder:r(`workspaceOverridePlaceholder`)}),(0,I.jsx)(c,{value:t.model??``,onChange:t=>e.onUpdateAgent(n,{model:t.target.value}),placeholder:r(`modelOverridePlaceholder`)}),(0,I.jsx)(c,{value:t.runtime??t.engine??``,onChange:t=>e.onUpdateAgent(n,{runtime:t.target.value}),placeholder:r(`engineOverridePlaceholder`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,I.jsx)(c,{type:`number`,min:1e3,step:1e3,value:t.contextTokens??``,onChange:t=>e.onUpdateAgent(n,{contextTokens:$(t.target.value)}),placeholder:r(`contextTokensPlaceholder`)}),(0,I.jsx)(c,{type:`number`,min:1,value:t.maxToolIterations??``,onChange:t=>e.onUpdateAgent(n,{maxToolIterations:$(t.target.value)}),placeholder:r(`maxToolsPlaceholder`)})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,I.jsx)(p,{checked:!!t.default,onCheckedChange:t=>e.onSetDefaultAgent(n,t)}),(0,I.jsx)(`span`,{children:r(`defaultAgent`)})]}),(0,I.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e.onRemoveAgent(n),children:[(0,I.jsx)(N,{className:`h-4 w-4 mr-1`}),r(`remove`)]})]})]},`${n}-${t.id}`)),(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:e.onAddAgent,children:[(0,I.jsx)(O,{className:`h-4 w-4 mr-2`}),r(`addAgent`)]})]})]})}function fe(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`bindings`)}),(0,I.jsx)(o,{children:r(`bindingsHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-3`,children:[e.bindings.map((t,n)=>{let i=t.match.peer?.kind??``;return(0,I.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,I.jsx)(c,{value:t.agentId,onChange:r=>e.onUpdateBinding(n,{...t,agentId:r.target.value}),placeholder:r(`targetAgentIdPlaceholder`)}),(0,I.jsx)(c,{value:t.match.channel,onChange:r=>e.onUpdateBinding(n,{...t,match:{...t.match,channel:r.target.value}}),placeholder:r(`channelPlaceholder`)}),(0,I.jsx)(c,{value:t.match.accountId??``,onChange:r=>e.onUpdateBinding(n,{...t,match:{...t.match,accountId:r.target.value}}),placeholder:r(`accountIdOptionalPlaceholder`)}),(0,I.jsxs)(D,{value:i||`__none__`,onValueChange:r=>{let i=r===`__none__`?``:r;e.onUpdateBinding(n,i?{...t,match:{...t.match,peer:{kind:i,id:t.match.peer?.id??``}}}:{...t,match:{...t.match,peer:void 0}})},children:[(0,I.jsx)(w,{children:(0,I.jsx)(C,{})}),(0,I.jsxs)(T,{children:[(0,I.jsx)(E,{value:`__none__`,children:r(`peerKindOptional`)}),(0,I.jsx)(E,{value:`direct`,children:r(`peerKindDirect`)}),(0,I.jsx)(E,{value:`group`,children:r(`peerKindGroup`)}),(0,I.jsx)(E,{value:`channel`,children:r(`peerKindChannel`)})]})]}),(0,I.jsx)(c,{value:t.match.peer?.id??``,onChange:r=>e.onUpdateBinding(n,{...t,match:{...t.match,peer:i?{kind:i,id:r.target.value}:void 0}}),placeholder:r(`peerIdPlaceholder`)})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e.onRemoveBinding(n),children:[(0,I.jsx)(N,{className:`h-4 w-4 mr-1`}),r(`remove`)]})})]},`${n}-${t.agentId}`)}),(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:e.onAddBinding,children:[(0,I.jsx)(O,{className:`h-4 w-4 mr-2`}),r(`addBinding`)]})]})]})}function pe(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`runtimeEntries`)}),(0,I.jsx)(o,{children:r(`runtimeEntriesHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-3`,children:[e.entries.map((t,n)=>(0,I.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,I.jsx)(c,{value:t.id,onChange:t=>e.onUpdateEntry(n,{id:t.target.value}),placeholder:r(`runtimeEntryIdPlaceholder`)}),(0,I.jsx)(c,{value:t.label??``,onChange:t=>e.onUpdateEntry(n,{label:t.target.value}),placeholder:r(`runtimeEntryLabelPlaceholder`)}),(0,I.jsx)(c,{value:t.type,onChange:t=>e.onUpdateEntry(n,{type:t.target.value}),placeholder:r(`runtimeEntryTypePlaceholder`)}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-200 px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`text-sm text-gray-700`,children:r(`enabled`)}),(0,I.jsx)(p,{checked:t.enabled!==!1,onCheckedChange:t=>e.onUpdateEntry(n,{enabled:t})})]})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`runtimeEntryConfigJson`)}),(0,I.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-gray-200 px-3 py-2 text-sm font-mono`,value:t.configText,onChange:t=>e.onUpdateEntry(n,{configText:t.target.value}),spellCheck:!1})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:()=>e.onRemoveEntry(n),children:[(0,I.jsx)(N,{className:`mr-2 h-4 w-4`}),r(`delete`)]})})]},`${n}-${t.id||`runtime-entry`}`)),(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:e.onAddEntry,children:[(0,I.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addRuntimeEntry`)]})]})]})}var me=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function he(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`dmScope`)}),(0,I.jsx)(o,{children:r(`dmScopeHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-md border border-gray-200 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:r(`runtimeCompanionEnabled`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`runtimeCompanionEnabledHelp`)})]}),(0,I.jsx)(p,{checked:e.companionEnabled,onCheckedChange:e.onCompanionEnabledChange})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`defaultContextTokens`)}),(0,I.jsx)(c,{type:`number`,min:1e3,step:1e3,value:e.defaultContextTokens,onChange:t=>e.onDefaultContextTokensChange(Math.max(1e3,Number.parseInt(t.target.value,10)||1e3))}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`defaultContextTokensHelp`)})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`defaultEngine`)}),(0,I.jsx)(c,{value:e.defaultEngine,onChange:t=>e.onDefaultEngineChange(t.target.value),placeholder:r(`defaultEnginePlaceholder`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`defaultEngineHelp`)})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`dmScope`)}),(0,I.jsxs)(D,{value:e.dmScope,onValueChange:t=>e.onDmScopeChange(t),children:[(0,I.jsx)(w,{children:(0,I.jsx)(C,{})}),(0,I.jsx)(T,{children:me.map(e=>(0,I.jsx)(E,{value:e.value,children:r(e.labelKey)},e.value))})]})]})]})]})}function ge(e){let t=(0,F.useMemo)(()=>ce(e.config),[e.config]),[n,a]=(0,F.useState)(t.agents),[o,c]=(0,F.useState)(t.bindings),[u,d]=(0,F.useState)(t.runtimeEntries),[f,p]=(0,F.useState)(t.dmScope),[m,h]=(0,F.useState)(t.companionEnabled),[g,_]=(0,F.useState)(t.defaultContextTokens),[v,y]=(0,F.useState)(t.defaultEngine),b=(0,F.useMemo)(()=>{let e=new Set([`main`]);return n.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[n]);return(0,I.jsxs)(i,{className:`space-y-6`,children:[(0,I.jsx)(X,{}),(0,I.jsx)(he,{companionEnabled:m,dmScope:f,defaultContextTokens:g,defaultEngine:v,onCompanionEnabledChange:h,onDmScopeChange:p,onDefaultContextTokensChange:_,onDefaultEngineChange:y}),(0,I.jsx)(pe,{entries:u,onUpdateEntry:(e,t)=>d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>d(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>d(e=>[...e,oe()])}),(0,I.jsx)(de,{agents:n,onUpdateAgent:(e,t)=>{a(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>a(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>a(e=>[...e,ie()]),onSetDefaultAgent:(e,t)=>a(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,I.jsx)(fe,{bindings:o,onUpdateBinding:(e,t)=>{c(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>c(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>c(e=>[...e,ae()])}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(l,{type:`button`,onClick:()=>{try{let t=ue({companionEnabled:m,agents:n,bindings:o,runtimeEntries:u,dmScope:f,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});e.updateRuntime.mutate({data:t})}catch(e){s.error(e instanceof Error?e.message:String(e))}},disabled:e.updateRuntime.isPending,children:[(0,I.jsx)(ne,{className:`h-4 w-4 mr-2`}),e.updateRuntime.isPending?r(`saving`):r(`saveRuntimeSettings`)]})})]})}function _e(){let{data:e,isLoading:t}=A(),n=j();return t||!e?(0,I.jsx)(`div`,{className:`p-8 text-gray-400`,children:r(`runtimeLoading`)}):(0,I.jsx)(ge,{config:e,updateRuntime:n})}export{_e as RuntimeConfig};
1
+ import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Dt as a,Et as o,Lt as s,Mt as c,Nt as l,Ot as u,Tt as d,_t as f,ft as p,ht as m,kt as h,wt as g,xt as _,yt as v}from"./api-CKKNxbsy.js";import{t as y}from"./createLucideIcon-DzY6wN61.js";import{b,l as x,x as S}from"./desktop-CmIbyIrg.js";import{a as C,i as w,n as T,r as E,t as D}from"./select-C2c10F3e.js";import{t as ee}from"./play-AqrNslHI.js";import{t as O}from"./plus-B-YHtTNC.js";import{t as te}from"./rotate-cw-BN9yjccP.js";import{t as ne}from"./save-CO_4qf6b.js";import{t as k}from"./notice-card-BM2_YNoc.js";import{n as A,x as j}from"./use-config-jAYudJxy.js";import{Q as M,X as N}from"./index-zYi4W031.js";import{t as P}from"./setting-row-CB_ZFbIZ.js";var re=y(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),F=e(t(),1),I=n(),L={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},R={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},z={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function B(e){return r(L[e]??`runtimeControlUnavailable`)}function V(e){return r(R[e]??`runtimeControlServiceUnknown`)}function H(e){return r(z[e.environment])}function U(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function W(e){return e?[{action:`start-service`,capability:e.canStartService,label:r(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:r(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:r(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:r(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function G(e){let{busy:t,icon:n}=e;return t?(0,I.jsx)(M,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,I.jsx)(ee,{className:`mr-2 h-4 w-4`}):n===`square`?(0,I.jsx)(re,{className:`mr-2 h-4 w-4`}):(0,I.jsx)(te,{className:`mr-2 h-4 w-4`})}function K(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:c,visibleLifecycle:f,visibleMessage:p,visibleServiceState:h}=m(),y=W(n??void 0),b=async e=>{let t=U(n,e);if(!t?.available){s.error(_(t?.reasonIfUnavailable)??r(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(r(`runtimeControlStopServiceConfirm`))))try{let t=await v.runRuntimeControlAction(e);s.success(_(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);s.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}},x=async()=>{if(!n?.canRestartApp.available){s.error(_(n?.canRestartApp.reasonIfUnavailable)??r(`runtimeRestartAppUnavailable`));return}if(window.confirm(r(`runtimeControlRestartAppConfirm`)))try{let e=await v.runRuntimeControlAction(`restart-app`);s.success(_(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);s.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`runtimeControlTitle`)}),(0,I.jsx)(o,{children:r(`runtimeControlDescription`)})]}),(0,I.jsxs)(d,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-gray-200 bg-gray-50 p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:V(h)}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:n?H(n):r(`runtimeControlLoading`)})]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600`,children:p}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:B(f)}),n?.managementHint?(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:_(n.managementHint)}):null,i&&!e?(0,I.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),c?(0,I.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-amber-200 bg-amber-50 p-4`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:r(`runtimeControlPendingRestartTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-amber-800`,children:r(`runtimeControlPendingRestartDescription`)}),c.changedPaths.length>0?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:r(`runtimeControlPendingRestartPaths`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.changedPaths.map(e=>(0,I.jsx)(`span`,{className:`rounded-full border border-amber-200 bg-white px-2.5 py-1 text-xs text-amber-800`,children:e},e))})]}):null]}):null,(0,I.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:y.map(n=>(0,I.jsxs)(l,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){x();return}b(n.action)},disabled:!n.capability.available||e,children:[(0,I.jsx)(G,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),y.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:_(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})}function q(e){let{description:t,title:n}=e;return(0,I.jsx)(k,{tone:`neutral`,title:n,description:t})}function J(e){let{children:t}=e;return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`runtimePresenceTitle`)}),(0,I.jsx)(o,{children:r(`runtimePresenceDescription`)})]}),(0,I.jsx)(d,{children:t})]})}function Y(){let e=f().runtimeControlView?.environment,t=S(e=>e.supported),n=S(e=>e.initialized),i=S(e=>e.busyAction),a=S(e=>e.snapshot);return(0,F.useEffect)(()=>{if(e===`desktop-embedded`){b.start();return}b.markUnsupported()},[e]),e===`desktop-embedded`?(0,I.jsx)(J,{children:(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(k,{tone:`neutral`,title:r(`runtimePresenceBehaviorLabel`),description:a?.closeToBackground?r(`runtimePresenceBehaviorBackground`):r(`runtimePresenceBehaviorQuit`),className:`rounded-xl`}),!n||t&&!a?(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:r(`runtimePresenceLoading`)}):null,a?(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(P,{title:r(`runtimePresenceCloseToBackground`),description:r(`runtimePresenceCloseToBackgroundHelp`),control:(0,I.jsx)(p,{id:`runtime-presence-close-background`,"aria-label":r(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{b.updatePreferences({closeToBackground:e})}})}),(0,I.jsx)(P,{title:r(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?r(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??r(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,I.jsx)(p,{id:`runtime-presence-launch-login`,"aria-label":r(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{b.updatePreferences({launchAtLogin:e})}})})]}):null]})}):e===`managed-local-service`?(0,I.jsx)(J,{children:(0,I.jsx)(q,{title:r(`runtimePresenceManagedLocalTitle`),description:r(`runtimePresenceManagedLocalDescription`)})}):e===`self-hosted-web`?(0,I.jsx)(J,{children:(0,I.jsx)(q,{title:r(`runtimePresenceSelfHostedTitle`),description:r(`runtimePresenceSelfHostedDescription`)})}):e===`shared-web`?(0,I.jsx)(J,{children:(0,I.jsx)(q,{title:r(`runtimePresenceSharedTitle`),description:r(`runtimePresenceSharedDescription`)})}):(0,I.jsx)(J,{children:(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:r(`runtimePresenceLoading`)})})}function X(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`)}),(0,I.jsx)(K,{}),(0,I.jsx)(Y,{}),(0,I.jsx)(x,{})]})}var Z={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function ie(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function ae(){return{agentId:``,match:{channel:``,accountId:``}}}function oe(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Z,configText:JSON.stringify(Z,null,2)}}function se(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function Q(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function $(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ce(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(se),bindings:(e.bindings??[]).map(Q),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function le(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function ue(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(r(`agentIdRequiredError`).replace(`{index}`,String(t)));return le(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${r(`duplicateAgentId`)}: ${n[0]}`);let i=e.bindings.map((t,n)=>{let i=t.agentId.trim(),a=t.match.channel.trim(),o=t.match.accountId?.trim()??``,s=t.match.peer?.kind,c=t.match.peer?.id?.trim()??``;if(!i)throw Error(r(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(i))throw Error(`${r(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${i}`);if(!a)throw Error(r(`bindingChannelRequired`).replace(`{index}`,String(n)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(r(`bindingPeerIdRequired`).replace(`{index}`,String(n)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,n)=>{let i=t.id.trim(),a=t.type.trim();if(!i)throw Error(r(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!a)throw Error(r(`runtimeEntryTypeRequired`).replace(`{id}`,i));if(e[i])throw Error(`${r(`runtimeEntryDuplicate`)}: ${i}`);let o=t.configText.trim()?JSON.parse(t.configText):{};if(o&&(typeof o!=`object`||Array.isArray(o)))throw Error(r(`runtimeEntryConfigObjectRequired`).replace(`{id}`,i));return e[i]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:a,config:o??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function de(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`agentList`)}),(0,I.jsx)(o,{children:r(`agentListHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-3`,children:[e.agents.map((t,n)=>(0,I.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,I.jsx)(c,{value:t.id,onChange:t=>e.onUpdateAgent(n,{id:t.target.value}),placeholder:r(`agentIdPlaceholder`)}),(0,I.jsx)(c,{value:t.workspace??``,onChange:t=>e.onUpdateAgent(n,{workspace:t.target.value}),placeholder:r(`workspaceOverridePlaceholder`)}),(0,I.jsx)(c,{value:t.model??``,onChange:t=>e.onUpdateAgent(n,{model:t.target.value}),placeholder:r(`modelOverridePlaceholder`)}),(0,I.jsx)(c,{value:t.runtime??t.engine??``,onChange:t=>e.onUpdateAgent(n,{runtime:t.target.value}),placeholder:r(`engineOverridePlaceholder`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,I.jsx)(c,{type:`number`,min:1e3,step:1e3,value:t.contextTokens??``,onChange:t=>e.onUpdateAgent(n,{contextTokens:$(t.target.value)}),placeholder:r(`contextTokensPlaceholder`)}),(0,I.jsx)(c,{type:`number`,min:1,value:t.maxToolIterations??``,onChange:t=>e.onUpdateAgent(n,{maxToolIterations:$(t.target.value)}),placeholder:r(`maxToolsPlaceholder`)})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,I.jsx)(p,{checked:!!t.default,onCheckedChange:t=>e.onSetDefaultAgent(n,t)}),(0,I.jsx)(`span`,{children:r(`defaultAgent`)})]}),(0,I.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e.onRemoveAgent(n),children:[(0,I.jsx)(N,{className:`h-4 w-4 mr-1`}),r(`remove`)]})]})]},`${n}-${t.id}`)),(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:e.onAddAgent,children:[(0,I.jsx)(O,{className:`h-4 w-4 mr-2`}),r(`addAgent`)]})]})]})}function fe(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`bindings`)}),(0,I.jsx)(o,{children:r(`bindingsHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-3`,children:[e.bindings.map((t,n)=>{let i=t.match.peer?.kind??``;return(0,I.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,I.jsx)(c,{value:t.agentId,onChange:r=>e.onUpdateBinding(n,{...t,agentId:r.target.value}),placeholder:r(`targetAgentIdPlaceholder`)}),(0,I.jsx)(c,{value:t.match.channel,onChange:r=>e.onUpdateBinding(n,{...t,match:{...t.match,channel:r.target.value}}),placeholder:r(`channelPlaceholder`)}),(0,I.jsx)(c,{value:t.match.accountId??``,onChange:r=>e.onUpdateBinding(n,{...t,match:{...t.match,accountId:r.target.value}}),placeholder:r(`accountIdOptionalPlaceholder`)}),(0,I.jsxs)(D,{value:i||`__none__`,onValueChange:r=>{let i=r===`__none__`?``:r;e.onUpdateBinding(n,i?{...t,match:{...t.match,peer:{kind:i,id:t.match.peer?.id??``}}}:{...t,match:{...t.match,peer:void 0}})},children:[(0,I.jsx)(w,{children:(0,I.jsx)(C,{})}),(0,I.jsxs)(T,{children:[(0,I.jsx)(E,{value:`__none__`,children:r(`peerKindOptional`)}),(0,I.jsx)(E,{value:`direct`,children:r(`peerKindDirect`)}),(0,I.jsx)(E,{value:`group`,children:r(`peerKindGroup`)}),(0,I.jsx)(E,{value:`channel`,children:r(`peerKindChannel`)})]})]}),(0,I.jsx)(c,{value:t.match.peer?.id??``,onChange:r=>e.onUpdateBinding(n,{...t,match:{...t.match,peer:i?{kind:i,id:r.target.value}:void 0}}),placeholder:r(`peerIdPlaceholder`)})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e.onRemoveBinding(n),children:[(0,I.jsx)(N,{className:`h-4 w-4 mr-1`}),r(`remove`)]})})]},`${n}-${t.agentId}`)}),(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:e.onAddBinding,children:[(0,I.jsx)(O,{className:`h-4 w-4 mr-2`}),r(`addBinding`)]})]})]})}function pe(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`runtimeEntries`)}),(0,I.jsx)(o,{children:r(`runtimeEntriesHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-3`,children:[e.entries.map((t,n)=>(0,I.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,I.jsx)(c,{value:t.id,onChange:t=>e.onUpdateEntry(n,{id:t.target.value}),placeholder:r(`runtimeEntryIdPlaceholder`)}),(0,I.jsx)(c,{value:t.label??``,onChange:t=>e.onUpdateEntry(n,{label:t.target.value}),placeholder:r(`runtimeEntryLabelPlaceholder`)}),(0,I.jsx)(c,{value:t.type,onChange:t=>e.onUpdateEntry(n,{type:t.target.value}),placeholder:r(`runtimeEntryTypePlaceholder`)}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-200 px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`text-sm text-gray-700`,children:r(`enabled`)}),(0,I.jsx)(p,{checked:t.enabled!==!1,onCheckedChange:t=>e.onUpdateEntry(n,{enabled:t})})]})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`runtimeEntryConfigJson`)}),(0,I.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-gray-200 px-3 py-2 text-sm font-mono`,value:t.configText,onChange:t=>e.onUpdateEntry(n,{configText:t.target.value}),spellCheck:!1})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:()=>e.onRemoveEntry(n),children:[(0,I.jsx)(N,{className:`mr-2 h-4 w-4`}),r(`delete`)]})})]},`${n}-${t.id||`runtime-entry`}`)),(0,I.jsxs)(l,{type:`button`,variant:`outline`,onClick:e.onAddEntry,children:[(0,I.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addRuntimeEntry`)]})]})]})}var me=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function he(e){return(0,I.jsxs)(g,{children:[(0,I.jsxs)(a,{children:[(0,I.jsx)(u,{children:r(`dmScope`)}),(0,I.jsx)(o,{children:r(`dmScopeHelp`)})]}),(0,I.jsxs)(d,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-md border border-gray-200 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:r(`runtimeCompanionEnabled`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`runtimeCompanionEnabledHelp`)})]}),(0,I.jsx)(p,{checked:e.companionEnabled,onCheckedChange:e.onCompanionEnabledChange})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`defaultContextTokens`)}),(0,I.jsx)(c,{type:`number`,min:1e3,step:1e3,value:e.defaultContextTokens,onChange:t=>e.onDefaultContextTokensChange(Math.max(1e3,Number.parseInt(t.target.value,10)||1e3))}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`defaultContextTokensHelp`)})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`defaultEngine`)}),(0,I.jsx)(c,{value:e.defaultEngine,onChange:t=>e.onDefaultEngineChange(t.target.value),placeholder:r(`defaultEnginePlaceholder`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`defaultEngineHelp`)})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:r(`dmScope`)}),(0,I.jsxs)(D,{value:e.dmScope,onValueChange:t=>e.onDmScopeChange(t),children:[(0,I.jsx)(w,{children:(0,I.jsx)(C,{})}),(0,I.jsx)(T,{children:me.map(e=>(0,I.jsx)(E,{value:e.value,children:r(e.labelKey)},e.value))})]})]})]})]})}function ge(e){let t=(0,F.useMemo)(()=>ce(e.config),[e.config]),[n,a]=(0,F.useState)(t.agents),[o,c]=(0,F.useState)(t.bindings),[u,d]=(0,F.useState)(t.runtimeEntries),[f,p]=(0,F.useState)(t.dmScope),[m,h]=(0,F.useState)(t.companionEnabled),[g,_]=(0,F.useState)(t.defaultContextTokens),[v,y]=(0,F.useState)(t.defaultEngine),b=(0,F.useMemo)(()=>{let e=new Set([`main`]);return n.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[n]);return(0,I.jsxs)(i,{className:`space-y-6`,children:[(0,I.jsx)(X,{}),(0,I.jsx)(he,{companionEnabled:m,dmScope:f,defaultContextTokens:g,defaultEngine:v,onCompanionEnabledChange:h,onDmScopeChange:p,onDefaultContextTokensChange:_,onDefaultEngineChange:y}),(0,I.jsx)(pe,{entries:u,onUpdateEntry:(e,t)=>d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>d(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>d(e=>[...e,oe()])}),(0,I.jsx)(de,{agents:n,onUpdateAgent:(e,t)=>{a(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>a(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>a(e=>[...e,ie()]),onSetDefaultAgent:(e,t)=>a(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,I.jsx)(fe,{bindings:o,onUpdateBinding:(e,t)=>{c(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>c(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>c(e=>[...e,ae()])}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsxs)(l,{type:`button`,onClick:()=>{try{let t=ue({companionEnabled:m,agents:n,bindings:o,runtimeEntries:u,dmScope:f,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});e.updateRuntime.mutate({data:t})}catch(e){s.error(e instanceof Error?e.message:String(e))}},disabled:e.updateRuntime.isPending,children:[(0,I.jsx)(ne,{className:`h-4 w-4 mr-2`}),e.updateRuntime.isPending?r(`saving`):r(`saveRuntimeSettings`)]})})]})}function _e(){let{data:e,isLoading:t}=A(),n=j();return t||!e?(0,I.jsx)(`div`,{className:`p-8 text-gray-400`,children:r(`runtimeLoading`)}):(0,I.jsx)(ge,{config:e,updateRuntime:n})}export{_e as RuntimeConfig};
@@ -1 +1 @@
1
- import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Mt as a,Nt as o,jt as s,kt as c}from"./api-DGD9_Bg4.js";import{t as l}from"./search-CRtQwr-h.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-BUTwE_lC.js";import{t as h}from"./external-link-CpEvG65F.js";import{t as g}from"./key-round-DUq47t0P.js";import{S as _,n as v,r as y}from"./use-config-Cyv5IuSt.js";import{Y as b}from"./index-DqJ3CYwi.js";import{a as x,c as S,i as C,n as w,o as T,s as E,t as D}from"./config-split-page-CcrEUtwu.js";var O=e(t(),1),k=n(),A=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],j=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],M=[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],N={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function P(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl}}}}function F(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl}}}}function I(e){let{label:t,value:n,onChange:r,placeholder:i,type:o=`text`,inputMode:c}=e;return(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(s,{children:t}),(0,k.jsx)(a,{type:o,value:n,onChange:e=>r(e.target.value),placeholder:i,inputMode:c,className:`rounded-xl`})]})}function L(e){let{label:t,value:n,options:i,onChange:a}=e;return(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(s,{children:t}),(0,k.jsxs)(m,{value:n,onValueChange:a,children:[(0,k.jsx)(d,{className:`rounded-xl`,children:(0,k.jsx)(u,{})}),(0,k.jsx)(f,{children:i.map(e=>(0,k.jsx)(p,{value:e.value,children:r(e.label)},e.value))})]})]})}function R({docsUrl:e}){return e?(0,k.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:(0,k.jsxs)(o,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,k.jsx)(h,{className:`mr-2 h-4 w-4`}),r(`searchProviderOpenDocs`)]})}):null}function z(e){let{draft:t,provider:n,search:i,selectedDocsUrl:a,updateProviderDraft:o}=e;if(n===`bocha`){let{bocha:e}=t.providers;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(I,{label:r(`apiKey`),value:e.apiKey,onChange:e=>o(`bocha`,{apiKey:e}),placeholder:i.providers.bocha.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,k.jsx)(I,{label:r(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`bocha`,{baseUrl:e})}),(0,k.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,k.jsx)(L,{label:r(`searchProviderSummary`),value:e.summary?`true`:`false`,options:M,onChange:e=>o(`bocha`,{summary:e===`true`})}),(0,k.jsx)(L,{label:r(`searchProviderFreshness`),value:e.freshness,options:A,onChange:e=>o(`bocha`,{freshness:e})})]}),(0,k.jsx)(R,{docsUrl:a??`https://open.bocha.cn`})]})}if(n===`tavily`){let{tavily:e}=t.providers;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(I,{label:r(`apiKey`),value:e.apiKey,onChange:e=>o(`tavily`,{apiKey:e}),placeholder:i.providers.tavily.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,k.jsx)(I,{label:r(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`tavily`,{baseUrl:e})}),(0,k.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,k.jsx)(L,{label:r(`searchProviderSearchDepth`),value:e.searchDepth,options:j,onChange:e=>o(`tavily`,{searchDepth:e})}),(0,k.jsx)(L,{label:r(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:M,onChange:e=>o(`tavily`,{includeAnswer:e===`true`})})]}),(0,k.jsx)(R,{docsUrl:a})]})}let{brave:s}=t.providers;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(I,{label:r(`apiKey`),value:s.apiKey,onChange:e=>o(`brave`,{apiKey:e}),placeholder:i.providers.brave.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,k.jsx)(I,{label:r(`searchProviderBaseUrl`),value:s.baseUrl,onChange:e=>o(`brave`,{baseUrl:e})})]})}function B(e){let{draft:t,providers:n,search:i,selectedProvider:a,onSelect:o}=e;return(0,k.jsxs)(x,{children:[(0,k.jsx)(S,{className:`px-4 py-4`,children:(0,k.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:r(`searchChannels`)})}),(0,k.jsx)(T,{className:`space-y-2 p-3`,children:n.map(e=>{let n=i.providers[e.name],s=t.enabledProviders.includes(e.name);return(0,k.jsx)(D,{onClick:()=>o(e.name),active:a===e.name,className:`p-3`,children:(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,k.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:r(N[e.name])})]}),(0,k.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,k.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?r(`searchStatusConfigured`):r(`searchStatusNeedsSetup`)}),s?(0,k.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:r(`searchProviderActivated`)}):null]})]})},e.name)})})]})}function V(e){let{initialDraft:t,providers:n,search:i,onSubmit:a,isPending:s}=e,{isMobile:c}=b(),[u,d]=(0,O.useState)(c?null:i.provider),[f,p]=(0,O.useState)(t),m=u&&n.some(e=>e.name===u)?u:c?null:i.provider,h=n.find(e=>e.name===m)??null,_=m?i.providers[m]:null,v=m?f.enabledProviders.includes(m):!1,y=_?.docsUrl??h?.docsUrl;return(0,k.jsxs)(C,{className:`xl:min-h-0`,mobileView:c?m?`detail`:`list`:void 0,onMobileBack:()=>d(null),mobileListLabel:r(`searchPageTitle`),children:[(0,k.jsx)(B,{draft:f,providers:n,search:i,selectedProvider:m??i.provider,onSelect:d}),h?(0,k.jsx)(x,{children:(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(f)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsx)(S,{className:`px-6 py-5`,children:(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,k.jsx)(l,{className:`h-5 w-5`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:h.displayName}),(0,k.jsx)(`p`,{className:`text-sm text-gray-500`,children:h.description})]})]}),(0,k.jsx)(o,{type:`button`,variant:v?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=v?f.enabledProviders.filter(e=>e!==m):m?[...f.enabledProviders,m]:f.enabledProviders,t={...f,enabledProviders:e};p(t),a(t)},children:r(v?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,k.jsxs)(T,{className:`space-y-6 px-6 py-5`,children:[(0,k.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,k.jsx)(L,{label:r(`searchActiveProvider`),value:f.activeProvider,options:n.map(e=>({value:e.name,label:e.displayName})),onChange:e=>p({...f,activeProvider:e})}),(0,k.jsx)(I,{label:r(`searchDefaultMaxResults`),value:f.maxResults,onChange:e=>p({...f,maxResults:e}),inputMode:`numeric`})]}),(0,k.jsx)(z,{draft:f,provider:m,search:i,selectedDocsUrl:y,updateProviderDraft:(e,t)=>{p(n=>({...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}}))}})]}),(0,k.jsx)(E,{className:`flex justify-end px-6 py-4`,children:(0,k.jsxs)(o,{type:`submit`,disabled:s,children:[(0,k.jsx)(g,{className:`mr-2 h-4 w-4`}),r(s?`saving`:`saveChanges`)]})})]})}):(0,k.jsx)(w,{children:(0,k.jsx)(`p`,{className:`text-sm text-gray-500`,children:r(`searchNoProviderSelected`)})})]})}function H(){let{data:e}=v(),{data:t}=y(),n=_(),a=t?.search??[],o=e?.search;return!o||a.length===0?(0,k.jsx)(`div`,{className:`p-8`,children:r(`loading`)}):(0,k.jsxs)(i,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,k.jsx)(c,{title:r(`searchPageTitle`),description:r(`searchPageDescription`)}),(0,k.jsx)(V,{initialDraft:P(o),providers:a,search:o,onSubmit:e=>n.mutate({data:F(e)}),isPending:n.isPending},JSON.stringify(o))]})}export{H as SearchConfig};
1
+ import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Mt as a,Nt as o,jt as s,kt as c}from"./api-CKKNxbsy.js";import{t as l}from"./search-CRtQwr-h.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-C2c10F3e.js";import{t as h}from"./external-link-CpEvG65F.js";import{t as g}from"./key-round-DUq47t0P.js";import{S as _,n as v,r as y}from"./use-config-jAYudJxy.js";import{Y as b}from"./index-zYi4W031.js";import{a as x,c as S,i as C,n as w,o as T,s as E,t as D}from"./config-split-page-CcrEUtwu.js";var O=e(t(),1),k=n(),A=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],j=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],M=[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],N={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function P(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl}}}}function F(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl}}}}function I(e){let{label:t,value:n,onChange:r,placeholder:i,type:o=`text`,inputMode:c}=e;return(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(s,{children:t}),(0,k.jsx)(a,{type:o,value:n,onChange:e=>r(e.target.value),placeholder:i,inputMode:c,className:`rounded-xl`})]})}function L(e){let{label:t,value:n,options:i,onChange:a}=e;return(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(s,{children:t}),(0,k.jsxs)(m,{value:n,onValueChange:a,children:[(0,k.jsx)(d,{className:`rounded-xl`,children:(0,k.jsx)(u,{})}),(0,k.jsx)(f,{children:i.map(e=>(0,k.jsx)(p,{value:e.value,children:r(e.label)},e.value))})]})]})}function R({docsUrl:e}){return e?(0,k.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:(0,k.jsxs)(o,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,k.jsx)(h,{className:`mr-2 h-4 w-4`}),r(`searchProviderOpenDocs`)]})}):null}function z(e){let{draft:t,provider:n,search:i,selectedDocsUrl:a,updateProviderDraft:o}=e;if(n===`bocha`){let{bocha:e}=t.providers;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(I,{label:r(`apiKey`),value:e.apiKey,onChange:e=>o(`bocha`,{apiKey:e}),placeholder:i.providers.bocha.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,k.jsx)(I,{label:r(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`bocha`,{baseUrl:e})}),(0,k.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,k.jsx)(L,{label:r(`searchProviderSummary`),value:e.summary?`true`:`false`,options:M,onChange:e=>o(`bocha`,{summary:e===`true`})}),(0,k.jsx)(L,{label:r(`searchProviderFreshness`),value:e.freshness,options:A,onChange:e=>o(`bocha`,{freshness:e})})]}),(0,k.jsx)(R,{docsUrl:a??`https://open.bocha.cn`})]})}if(n===`tavily`){let{tavily:e}=t.providers;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(I,{label:r(`apiKey`),value:e.apiKey,onChange:e=>o(`tavily`,{apiKey:e}),placeholder:i.providers.tavily.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,k.jsx)(I,{label:r(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>o(`tavily`,{baseUrl:e})}),(0,k.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,k.jsx)(L,{label:r(`searchProviderSearchDepth`),value:e.searchDepth,options:j,onChange:e=>o(`tavily`,{searchDepth:e})}),(0,k.jsx)(L,{label:r(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:M,onChange:e=>o(`tavily`,{includeAnswer:e===`true`})})]}),(0,k.jsx)(R,{docsUrl:a})]})}let{brave:s}=t.providers;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(I,{label:r(`apiKey`),value:s.apiKey,onChange:e=>o(`brave`,{apiKey:e}),placeholder:i.providers.brave.apiKeyMasked||r(`enterApiKey`),type:`password`}),(0,k.jsx)(I,{label:r(`searchProviderBaseUrl`),value:s.baseUrl,onChange:e=>o(`brave`,{baseUrl:e})})]})}function B(e){let{draft:t,providers:n,search:i,selectedProvider:a,onSelect:o}=e;return(0,k.jsxs)(x,{children:[(0,k.jsx)(S,{className:`px-4 py-4`,children:(0,k.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:r(`searchChannels`)})}),(0,k.jsx)(T,{className:`space-y-2 p-3`,children:n.map(e=>{let n=i.providers[e.name],s=t.enabledProviders.includes(e.name);return(0,k.jsx)(D,{onClick:()=>o(e.name),active:a===e.name,className:`p-3`,children:(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,k.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:r(N[e.name])})]}),(0,k.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,k.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?r(`searchStatusConfigured`):r(`searchStatusNeedsSetup`)}),s?(0,k.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:r(`searchProviderActivated`)}):null]})]})},e.name)})})]})}function V(e){let{initialDraft:t,providers:n,search:i,onSubmit:a,isPending:s}=e,{isMobile:c}=b(),[u,d]=(0,O.useState)(c?null:i.provider),[f,p]=(0,O.useState)(t),m=u&&n.some(e=>e.name===u)?u:c?null:i.provider,h=n.find(e=>e.name===m)??null,_=m?i.providers[m]:null,v=m?f.enabledProviders.includes(m):!1,y=_?.docsUrl??h?.docsUrl;return(0,k.jsxs)(C,{className:`xl:min-h-0`,mobileView:c?m?`detail`:`list`:void 0,onMobileBack:()=>d(null),mobileListLabel:r(`searchPageTitle`),children:[(0,k.jsx)(B,{draft:f,providers:n,search:i,selectedProvider:m??i.provider,onSelect:d}),h?(0,k.jsx)(x,{children:(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(f)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsx)(S,{className:`px-6 py-5`,children:(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,k.jsx)(l,{className:`h-5 w-5`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:h.displayName}),(0,k.jsx)(`p`,{className:`text-sm text-gray-500`,children:h.description})]})]}),(0,k.jsx)(o,{type:`button`,variant:v?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=v?f.enabledProviders.filter(e=>e!==m):m?[...f.enabledProviders,m]:f.enabledProviders,t={...f,enabledProviders:e};p(t),a(t)},children:r(v?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,k.jsxs)(T,{className:`space-y-6 px-6 py-5`,children:[(0,k.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,k.jsx)(L,{label:r(`searchActiveProvider`),value:f.activeProvider,options:n.map(e=>({value:e.name,label:e.displayName})),onChange:e=>p({...f,activeProvider:e})}),(0,k.jsx)(I,{label:r(`searchDefaultMaxResults`),value:f.maxResults,onChange:e=>p({...f,maxResults:e}),inputMode:`numeric`})]}),(0,k.jsx)(z,{draft:f,provider:m,search:i,selectedDocsUrl:y,updateProviderDraft:(e,t)=>{p(n=>({...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}}))}})]}),(0,k.jsx)(E,{className:`flex justify-end px-6 py-4`,children:(0,k.jsxs)(o,{type:`submit`,disabled:s,children:[(0,k.jsx)(g,{className:`mr-2 h-4 w-4`}),r(s?`saving`:`saveChanges`)]})})]})}):(0,k.jsx)(w,{children:(0,k.jsx)(`p`,{className:`text-sm text-gray-500`,children:r(`searchNoProviderSelected`)})})]})}function H(){let{data:e}=v(),{data:t}=y(),n=_(),a=t?.search??[],o=e?.search;return!o||a.length===0?(0,k.jsx)(`div`,{className:`p-8`,children:r(`loading`)}):(0,k.jsxs)(i,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,k.jsx)(c,{title:r(`searchPageTitle`),description:r(`searchPageDescription`)}),(0,k.jsx)(V,{initialDraft:P(o),providers:a,search:o,onSubmit:e=>n.mutate({data:F(e)}),isPending:n.isPending},JSON.stringify(o))]})}export{H as SearchConfig};
@@ -1,3 +1,3 @@
1
- import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Dt as a,Et as o,Lt as s,Mt as c,Nt as l,Ot as u,Tt as d,ft as f,jt as p,kt as m,wt as h}from"./api-DGD9_Bg4.js";import{a as g,i as _,n as v,r as y,t as b}from"./select-BUTwE_lC.js";import{t as x}from"./plus-B-YHtTNC.js";import{t as S}from"./save-CO_4qf6b.js";import{C,n as w}from"./use-config-Cyv5IuSt.js";import{X as T}from"./index-DqJ3CYwi.js";var E=e(t(),1),D=n(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
1
+ import{_ as e,m as t,p as n,r}from"./i18n-D1144VAA.js";import{At as i,Dt as a,Et as o,Lt as s,Mt as c,Nt as l,Ot as u,Tt as d,ft as f,jt as p,kt as m,wt as h}from"./api-CKKNxbsy.js";import{a as g,i as _,n as v,r as y,t as b}from"./select-C2c10F3e.js";import{t as x}from"./plus-B-YHtTNC.js";import{t as S}from"./save-CO_4qf6b.js";import{C,n as w}from"./use-config-jAYudJxy.js";import{X as T}from"./index-zYi4W031.js";var E=e(t(),1),D=n(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
2
2
  `),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function M(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
3
3
  `).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function N(e){return e?{enabled:!!e.enabled,defaultEnv:e.defaults.env??``,defaultFile:e.defaults.file??``,defaultExec:e.defaults.exec??``,providers:Object.entries(e.providers).map(([e,t])=>j(e,t)),refs:Object.entries(e.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}:{enabled:!0,defaultEnv:``,defaultFile:``,defaultExec:``,providers:[],refs:[]}}function P(e){return{enabled:e.enabled,defaults:{env:e.defaultEnv||null,file:e.defaultFile||null,exec:e.defaultExec||null},providers:Object.fromEntries(e.providers.map(e=>[e.alias.trim(),M(e)]).filter(([e])=>e)),refs:Object.fromEntries(e.refs.map(e=>[e.path.trim(),{source:e.source,...e.provider.trim()?{provider:e.provider.trim()}:{},id:e.id.trim()}]).filter(([e,t])=>e&&t.id))}}function F(e){let{defaultEnv:t,defaultFile:n,defaultExec:i,providerAliases:s,onChange:c}=e;return(0,D.jsxs)(h,{children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(u,{children:r(`secrets`)}),(0,D.jsx)(o,{children:r(`secretsEnabledHelp`)})]}),(0,D.jsx)(d,{className:`space-y-4`,children:[{label:r(`defaultEnvProvider`),value:t,key:`defaultEnv`},{label:r(`defaultFileProvider`),value:n,key:`defaultFile`},{label:r(`defaultExecProvider`),value:i,key:`defaultExec`}].map(e=>(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(p,{children:e.label}),(0,D.jsxs)(b,{value:e.value||`__none__`,onValueChange:t=>c(e.key,t===`__none__`?``:t),children:[(0,D.jsx)(_,{children:(0,D.jsx)(g,{placeholder:r(`noneOption`)})}),(0,D.jsxs)(v,{children:[(0,D.jsx)(y,{value:`__none__`,children:r(`noneOption`)}),s.map(e=>(0,D.jsx)(y,{value:e,children:e},e))]})]})]},e.key))})]})}function I(e){let{providers:t,onUpdate:n,onRemove:i,onAdd:s}=e;return(0,D.jsxs)(h,{children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(u,{children:r(`secretProvidersTitle`)}),(0,D.jsx)(o,{children:r(`secretProvidersDescription`)})]}),(0,D.jsxs)(d,{className:`space-y-3`,children:[t.map((e,t)=>(0,D.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-3`,children:[(0,D.jsx)(c,{value:e.alias,onChange:e=>n(t,{alias:e.target.value}),placeholder:r(`providerAlias`)}),(0,D.jsxs)(b,{value:e.source,onValueChange:e=>n(t,{source:e}),children:[(0,D.jsx)(_,{children:(0,D.jsx)(g,{})}),(0,D.jsx)(v,{children:O.map(e=>(0,D.jsx)(y,{value:e,children:e},e))})]}),(0,D.jsxs)(l,{type:`button`,variant:`outline`,onClick:()=>i(t),children:[(0,D.jsx)(T,{className:`mr-2 h-4 w-4`}),r(`removeProvider`)]})]}),e.source===`env`?(0,D.jsx)(c,{value:e.prefix,onChange:e=>n(t,{prefix:e.target.value}),placeholder:r(`envPrefix`)}):null,e.source===`file`?(0,D.jsx)(c,{value:e.path,onChange:e=>n(t,{path:e.target.value}),placeholder:r(`secretFilePath`)}):null,e.source===`exec`?(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(c,{value:e.command,onChange:e=>n(t,{command:e.target.value}),placeholder:r(`secretExecCommand`)}),(0,D.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`,value:e.argsText,onChange:e=>n(t,{argsText:e.target.value}),placeholder:r(`secretExecArgs`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-2`,children:[(0,D.jsx)(c,{value:e.cwd,onChange:e=>n(t,{cwd:e.target.value}),placeholder:r(`secretExecCwd`)}),(0,D.jsx)(c,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>n(t,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:r(`secretExecTimeoutMs`)})]})]}):null]},`provider-${t}`)),(0,D.jsxs)(l,{type:`button`,variant:`outline`,onClick:s,children:[(0,D.jsx)(x,{className:`mr-2 h-4 w-4`}),r(`addSecretProvider`)]})]})]})}function L(e){let{refs:t,providerAliases:n,onUpdate:i,onRemove:s,onAdd:f}=e;return(0,D.jsxs)(h,{children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(u,{children:r(`secretRefsTitle`)}),(0,D.jsx)(o,{children:r(`secretRefsDescription`)})]}),(0,D.jsxs)(d,{className:`space-y-3`,children:[t.map((e,t)=>(0,D.jsx)(`div`,{className:`space-y-3 rounded-xl border border-gray-200 p-3`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,D.jsx)(c,{value:e.path,onChange:e=>i(t,{path:e.target.value}),placeholder:r(`secretConfigPath`)}),(0,D.jsx)(c,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:r(`secretId`)}),(0,D.jsxs)(b,{value:e.source,onValueChange:e=>i(t,{source:e}),children:[(0,D.jsx)(_,{children:(0,D.jsx)(g,{})}),(0,D.jsx)(v,{children:O.map(e=>(0,D.jsx)(y,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,D.jsxs)(b,{value:e.provider||`__none__`,onValueChange:e=>i(t,{provider:e===`__none__`?``:e}),children:[(0,D.jsx)(_,{children:(0,D.jsx)(g,{placeholder:r(`secretProviderAlias`)})}),(0,D.jsxs)(v,{children:[(0,D.jsx)(y,{value:`__none__`,children:r(`noneOption`)}),n.map(e=>(0,D.jsx)(y,{value:e,children:e},e))]})]}),(0,D.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>s(t),children:(0,D.jsx)(T,{className:`h-4 w-4`})})]})]})},`ref-${t}`)),(0,D.jsxs)(l,{type:`button`,variant:`outline`,onClick:f,children:[(0,D.jsx)(x,{className:`mr-2 h-4 w-4`}),r(`addSecretRef`)]})]})]})}function R(e){let{initialState:t,isPending:n,onSubmit:c}=e,[p,g]=(0,E.useState)(t),_=(0,E.useMemo)(()=>{let e=p.providers.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[p.providers]);return(0,D.jsxs)(i,{className:`space-y-6`,children:[(0,D.jsx)(m,{title:r(`secretsPageTitle`),description:r(`secretsPageDescription`)}),(0,D.jsxs)(h,{children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(u,{children:r(`secrets`)}),(0,D.jsx)(o,{children:r(`secretsEnabledHelp`)})]}),(0,D.jsxs)(d,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-gray-800`,children:r(`enabled`)}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:r(`secretsEnabledHelp`)})]}),(0,D.jsx)(f,{checked:p.enabled,onCheckedChange:e=>g(t=>({...t,enabled:e}))})]}),(0,D.jsx)(F,{defaultEnv:p.defaultEnv,defaultFile:p.defaultFile,defaultExec:p.defaultExec,providerAliases:_,onChange:(e,t)=>g(n=>({...n,[e]:t}))})]})]}),(0,D.jsx)(I,{providers:p.providers,onUpdate:(e,t)=>{g(n=>({...n,providers:n.providers.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>g(t=>({...t,providers:t.providers.filter((t,n)=>n!==e)})),onAdd:()=>g(e=>({...e,providers:[...e.providers,k()]}))}),(0,D.jsx)(L,{refs:p.refs,providerAliases:_,onUpdate:(e,t)=>{g(n=>({...n,refs:n.refs.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>g(t=>({...t,refs:t.refs.filter((t,n)=>n!==e)})),onAdd:()=>g(e=>({...e,refs:[...e.refs,A()]}))}),(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(l,{type:`button`,onClick:()=>{try{let e={};for(let[t,n]of p.providers.entries()){let i=n.alias.trim();if(!i)throw Error(`${r(`providerAlias`)} #${t+1} ${r(`isRequired`)}`);if(e[i])throw Error(`${r(`providerAlias`)}: ${i} (${r(`duplicate`)})`);if(n.source===`file`&&!n.path.trim())throw Error(`${r(`secretFilePath`)} #${t+1} ${r(`isRequired`)}`);if(n.source===`exec`&&!n.command.trim())throw Error(`${r(`secretExecCommand`)} #${t+1} ${r(`isRequired`)}`);e[i]=M(n)}let t={};for(let[n,i]of p.refs.entries()){let a=i.path.trim(),o=i.id.trim();if(!a)throw Error(`${r(`secretConfigPath`)} #${n+1} ${r(`isRequired`)}`);if(!o)throw Error(`${r(`secretId`)} #${n+1} ${r(`isRequired`)}`);let s=i.provider.trim();if(s&&!e[s])throw Error(`${r(`secretProviderAlias`)}: ${s} ${r(`notFound`)}`);t[a]={source:i.source,...s?{provider:s}:{},id:o}}c({enabled:p.enabled,defaultEnv:p.defaultEnv.trim(),defaultFile:p.defaultFile.trim(),defaultExec:p.defaultExec.trim(),providers:Object.entries(e).map(([e,t])=>j(e,t)),refs:Object.entries(t).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))})}catch(e){s.error(e instanceof Error?e.message:String(e))}},disabled:n,children:[(0,D.jsx)(S,{className:`mr-2 h-4 w-4`}),r(n?`saving`:`save`)]})})]})}function z(){let{data:e,isLoading:t}=w(),n=C();return t?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:r(`loading`)}):(0,D.jsx)(R,{initialState:N(e?.secrets),isPending:n.isPending,onSubmit:e=>n.mutate({data:P(e)})},JSON.stringify(e?.secrets??null))}export{z as SecretsConfig};