nextclaw 0.21.12 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -16
- package/ui-dist/assets/api-DLtsiBKm.js +13 -0
- package/ui-dist/assets/appearance-settings-page-CtkeYXux.js +1 -0
- package/ui-dist/assets/book-open-BQwWBDKb.js +1 -0
- package/ui-dist/assets/channels-list-page-Cv8o9Hxg.js +8 -0
- package/ui-dist/assets/chat-page-BtA7H1Ea.js +1 -0
- package/ui-dist/assets/{config-split-page-CRhlZ_pH.js → config-split-page-EidRBpP2.js} +1 -1
- package/ui-dist/assets/confirm-dialog-iIJFFp2T.js +5 -0
- package/ui-dist/assets/desktop-update-config-C6n_TB1r.js +1 -0
- package/ui-dist/assets/{dist-CikkhOlq.js → dist-CBxWOazz.js} +1 -1
- package/ui-dist/assets/{dist-PVA_xL1D.js → dist-D2eZC3OR.js} +1 -1
- package/ui-dist/assets/doc-browser-B76XOXmW.js +1 -0
- package/ui-dist/assets/doc-browser-DBnj9UMB.js +1 -0
- package/ui-dist/assets/{doc-browser-context-MTw4EvKd.js → doc-browser-context-Sv-044Cl.js} +1 -1
- package/ui-dist/assets/{ellipsis-y6vDtq4M.js → ellipsis-2uzhypw5.js} +1 -1
- package/ui-dist/assets/es2015-DhQo_oS6.js +41 -0
- package/ui-dist/assets/{external-link-DVJIQf_G.js → external-link-CM5dnUI6.js} +1 -1
- package/ui-dist/assets/host-capabilities-9bB_998Z.js +1 -0
- package/ui-dist/assets/i18n-provider-di1waTGX.js +1 -0
- package/ui-dist/assets/index-CBRP-7-a.css +1 -0
- package/ui-dist/assets/index-Z1fYpbNd.js +104 -0
- package/ui-dist/assets/loader-circle-BjmN5DeJ.js +1 -0
- package/ui-dist/assets/mcp-marketplace-page-C_MVQUbT.js +9 -0
- package/ui-dist/assets/mcp-marketplace-page-CoZIiD6G.js +1 -0
- package/ui-dist/assets/model-config-page-Cdr9P6TQ.js +1 -0
- package/ui-dist/assets/plus-3ztRZD_l.js +1 -0
- package/ui-dist/assets/provider-scoped-model-input-g1WkGiJ8.js +1 -0
- package/ui-dist/assets/providers-config-page-CWlO7J4A.js +1 -0
- package/ui-dist/assets/{react-VNqT5Zp7.js → react-DjpzoZXB.js} +1 -1
- package/ui-dist/assets/refresh-cw-DaTv3zxE.js +1 -0
- package/ui-dist/assets/remote-CKWZfVVB.js +1 -0
- package/ui-dist/assets/rotate-cw-CHcaRUDz.js +1 -0
- package/ui-dist/assets/runtime-config-page-CfTqh1nv.js +1 -0
- package/ui-dist/assets/{save-BOJ477H-.js → save-BZof1uie.js} +1 -1
- package/ui-dist/assets/{search-BEti5beA.js → search-MxAarS_g.js} +1 -1
- package/ui-dist/assets/search-config-page-Dm8daYny.js +1 -0
- package/ui-dist/assets/{secrets-config-page--IzrIOid.js → secrets-config-page-D8AbcR05.js} +2 -2
- package/ui-dist/assets/security-config-Ds0LsJmo.js +1 -0
- package/ui-dist/assets/select-D7GcNP0z.js +1 -0
- package/ui-dist/assets/setting-row-CuozlnJd.js +1 -0
- package/ui-dist/assets/side-dock-BcLau5S_.js +3 -0
- package/ui-dist/assets/skeleton-shfmXuYp.js +1 -0
- package/ui-dist/assets/switch-C1BWMU5c.js +1 -0
- package/ui-dist/assets/tag-chip-DCUrQUCP.js +1 -0
- package/ui-dist/assets/tooltip-DfAHHA76.js +1 -0
- package/ui-dist/assets/use-config-DAdbT5QJ.js +1 -0
- package/ui-dist/assets/use-confirm-dialog-eWcJ6V-s.js +1 -0
- package/ui-dist/assets/x-DqL1mYLC.js +1 -0
- package/ui-dist/index.html +53 -17
- package/ui-dist/assets/api-BP_8IaxB.js +0 -13
- package/ui-dist/assets/channels-list-page-DEh5Jjqx.js +0 -8
- package/ui-dist/assets/chat-page-BRB0N5WW.js +0 -105
- package/ui-dist/assets/confirm-dialog-DsivFJ4r.js +0 -5
- package/ui-dist/assets/desktop-update-config-B0w9p2ep.js +0 -1
- package/ui-dist/assets/doc-browser-BoNJ7-tE.js +0 -1
- package/ui-dist/assets/doc-browser-CdJ_d4ik.js +0 -1
- package/ui-dist/assets/index-BiE-K8-q.css +0 -1
- package/ui-dist/assets/index-D9BAE_L_.js +0 -105
- package/ui-dist/assets/mcp-marketplace-page-B1SZNY5m.js +0 -40
- package/ui-dist/assets/mcp-marketplace-page-Cq_Tw42T.js +0 -1
- package/ui-dist/assets/model-config-page-DotaTUHb.js +0 -1
- package/ui-dist/assets/plus-BbZqquJe.js +0 -1
- package/ui-dist/assets/provider-scoped-model-input-DsFRuWJH.js +0 -1
- package/ui-dist/assets/providers-config-page-DW4tQSLN.js +0 -1
- package/ui-dist/assets/remote-B8TiUfwW.js +0 -1
- package/ui-dist/assets/rotate-cw-DjHDTkCv.js +0 -1
- package/ui-dist/assets/runtime-config-page-S6ErRHR8.js +0 -1
- package/ui-dist/assets/search-config-page-DGj5am03.js +0 -1
- package/ui-dist/assets/select-hoj8dK4K.js +0 -41
- package/ui-dist/assets/tag-chip-T8-h-die.js +0 -1
- package/ui-dist/assets/use-config-CjRV2hwL.js +0 -1
- package/ui-dist/assets/x-D9PXs_xP.js +0 -1
- /package/ui-dist/assets/{config-hints-BkYBc7z0.js → config-hints-fGnUjDe9.js} +0 -0
- /package/ui-dist/assets/{middleware-CkFT3R4v.js → middleware-BILWbJE4.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./dist-D2eZC3OR.js";var t=e(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]);export{t};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{h as e,p as t,r as n,t as r,u as i,v as a}from"./react-DjpzoZXB.js";import{$t as o,D as s,E as c,It as l,Lt as u,Nt as d,O as f,Qt as p,Rt as m,T as ee,Xt as h,Yt as g,Zt as _,k as v,w as te,zt as y}from"./api-DLtsiBKm.js";import{c as ne,l as b,t as x}from"./switch-C1BWMU5c.js";import{c as S}from"./dist-D2eZC3OR.js";import{a as C,i as w,n as T,o as E,r as D,s as O}from"./confirm-dialog-iIJFFp2T.js";import{a as k,i as A,n as j,r as M,t as N}from"./select-D7GcNP0z.js";import{a as P,i as F,n as re,o as ie}from"./i18n-provider-di1waTGX.js";import{t as ae}from"./loader-circle-BjmN5DeJ.js";import{n as oe,t as I}from"./skeleton-shfmXuYp.js";import{t as se}from"./use-confirm-dialog-eWcJ6V-s.js";import{n as ce}from"./doc-browser-context-Sv-044Cl.js";import{t as L}from"./tag-chip-DCUrQUCP.js";var le=class extends o{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:p()})}getOptimisticResult(e){return e.behavior=p(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:h(t,n.data),hasPreviousPage:_(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function R(e,t){return y(e,le,t)}var ue=S(`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`}]]),de=S(`PackageSearch`,[[`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`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]);function z(e){if(!e||e.pages.length===0)return;let t=e.pages.flatMap(e=>e.items);return{...e.pages[e.pages.length-1],items:t,pages:e.pages,loadedItems:t.length,loadedPages:e.pages.length}}var B=t();function V({scope:e,isRefreshing:t,searchText:r,searchPlaceholder:i,sort:a,onSearchTextChange:o,onSortChange:s}){return(0,B.jsx)(`div`,{className:`mb-4`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,B.jsx)(de,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,B.jsx)(`input`,{value:r,onChange:e=>o(e.target.value),placeholder:i,className:`h-9 w-full rounded-xl border border-gray-200/80 pl-9 pr-9 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`}),t&&(0,B.jsx)(ae,{className:`absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 animate-spin text-primary`,"aria-label":n(`marketplaceRefreshingResults`)})]}),e===`all`&&(0,B.jsxs)(N,{value:a,onValueChange:e=>s(e),children:[(0,B.jsx)(A,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,B.jsx)(k,{})}),(0,B.jsxs)(j,{children:[(0,B.jsx)(M,{value:`relevance`,children:n(`marketplaceSortRelevance`)}),(0,B.jsx)(M,{value:`updated`,children:n(`marketplaceSortUpdated`)})]})]})]})})}function H({count:e}){return(0,B.jsx)(B.Fragment,{children:Array.from({length:e},(e,t)=>(0,B.jsx)(`article`,{className:`h-full rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-2.5`,children:[(0,B.jsx)(I,{className:`h-9 w-9 shrink-0 rounded-lg`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,B.jsx)(I,{className:`h-4 w-32 max-w-[70%]`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(I,{className:`h-3 w-12`}),(0,B.jsx)(I,{className:`h-3 w-24`})]}),(0,B.jsx)(I,{className:`h-3 w-full`}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 pt-0.5`,children:[(0,B.jsx)(I,{className:`h-5 w-14 rounded-md`}),(0,B.jsx)(I,{className:`h-5 w-16 rounded-md`}),(0,B.jsx)(I,{className:`h-5 w-12 rounded-md`})]})]})]}),(0,B.jsx)(I,{className:`h-7 w-16 shrink-0 rounded-md`})]})},`marketplace-skeleton-${t}`))})}function U({hasMore:e,loading:t,sentinelRef:r}){return!e&&!t?null:(0,B.jsxs)(`div`,{className:`py-4`,children:[e&&(0,B.jsx)(`div`,{ref:r,className:`h-1 w-full`,"aria-hidden":`true`}),t&&(0,B.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:n(`loading`)})]})}function W(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function G(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function K(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:G(e),text:typeof t==`string`?t.trim():``})).filter(e=>e.text.length>0);if(t.length>0){let e=new Map(t.map(e=>[e.locale,e.text]));for(let t of n){let n=G(t),r=e.get(n);if(r)return r}for(let e of n){let n=G(e).split(`-`)[0];if(!n)continue;let r=t.find(e=>e.locale===n||e.locale.startsWith(`${n}-`));if(r)return r.text}return t[0]?.text??``}}return t?.trim()??``}function fe(e,t){if(!e)return``;for(let n of t)if(G(n).split(`-`)[0]===`zh`&&e.descriptionZh?.trim())return e.descriptionZh.trim();return e.description?.trim()?e.description.trim():e.descriptionZh?.trim()?e.descriptionZh.trim():``}var q=r(e=>({entries:{},setEntry:t=>e(e=>({entries:{...e.entries,[t.id]:t}}))}));function pe(e){q.getState().setEntry(e)}var J=`marketplace-detail`,me=`nextclaw://marketplace-detail`;function Y(e,t){return`${e}:${t}`}function he(e){return`${me}/${encodeURIComponent(e)}`}function ge(e){try{let t=new URL(e);if(t.protocol!==`nextclaw:`||t.hostname!==`marketplace-detail`)return null;let n=t.pathname.replace(/^\//,``);return n?decodeURIComponent(n):null}catch{return null}}function _e(e){let t=he(e.id);return{dedupeKey:`marketplace-detail:${e.id}`,historyPolicy:`managed`,kind:J,resourceUri:t,title:e.title,url:t}}function X(e,t,n){pe(t),e.openTarget(_e(t),{activate:n?.activate,dedupeKey:`marketplace-detail:${t.id}`,title:t.title})}function ve(e){let t=e.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
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
|
+
`).trim():e}function Z(e){let t=[],n=/(`[^`]+`|\*\*[^*]+\*\*|\[[^\]]+\]\(https?:\/\/[^)\s]+\))/g,r=0,i=0;for(let a of e.matchAll(n)){if(a.index===void 0)continue;a.index>r&&t.push(e.slice(r,a.index));let n=a[0],o=`${i}-${a.index}`;if(n.startsWith("`"))t.push((0,B.jsx)(`code`,{className:`rounded border border-border bg-muted px-1 py-0.5 font-mono text-[0.88em] text-foreground`,children:n.slice(1,-1)},o));else if(n.startsWith(`**`))t.push((0,B.jsx)(`strong`,{children:n.slice(2,-2)},o));else{let e=n.match(/^\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)$/);t.push(e?(0,B.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,children:e[1]},o):n)}r=a.index+n.length,i+=1}return r<e.length&&t.push(e.slice(r)),t}function ye(e){return/^(#{1,4})\s+/.test(e)||/^([-*])\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)}function be(e,t,n){let r=[],i=t+1;for(;i<e.length&&!e[i]?.trim().startsWith("```");)r.push(e[i]??``),i+=1;let a=n[1]??``;return{node:(0,B.jsxs)(`div`,{className:`relative my-3 overflow-hidden rounded-lg border border-border bg-muted/70`,children:[a?(0,B.jsx)(`span`,{className:`absolute right-3 top-2 font-mono text-[10px] text-muted-foreground`,children:a}):null,(0,B.jsx)(`pre`,{className:`m-0 overflow-x-auto p-3 text-xs leading-6 text-foreground`,children:(0,B.jsx)(`code`,{children:r.join(`
|
|
5
|
+
`)})})]},t),nextIndex:i+1}}function xe(e,t,n){let r=[],a=t,o=n?/^\d+\.\s+/:/^[-*]\s+/;for(;a<e.length&&o.test(e[a]?.trim()??``);)r.push((e[a]??``).trim().replace(o,``)),a+=1;return{node:(0,B.jsx)(n?`ol`:`ul`,{className:i(`my-2 pl-5`,n?`list-decimal`:`list-disc`),children:r.map((e,n)=>(0,B.jsx)(`li`,{className:`my-1`,children:Z(e)},`${t}-${n}`))},t),nextIndex:a}}function Se(e,t,n){let r=`mb-2 mt-5 font-semibold leading-tight text-foreground`;return e===1?(0,B.jsx)(`h1`,{className:r,children:n},t):e===2?(0,B.jsx)(`h2`,{className:r,children:n},t):e===3?(0,B.jsx)(`h3`,{className:r,children:n},t):(0,B.jsx)(`h4`,{className:r,children:n},t)}function Ce(e,t){let n=e[t]?.trim()??``,r=n.match(/^```(\S*)/);if(r)return be(e,t,r);let i=n.match(/^(#{1,4})\s+(.+)$/);if(i)return{node:Se(Math.min(4,i[1]?.length??2),t,Z(i[2]??``)),nextIndex:t+1};if(/^[-*]\s+/.test(n))return xe(e,t,!1);if(/^\d+\.\s+/.test(n))return xe(e,t,!0);if(/^>\s?/.test(n)){let n=[],r=t;for(;r<e.length&&/^>\s?/.test(e[r]?.trim()??``);)n.push((e[r]??``).trim().replace(/^>\s?/,``)),r+=1;return{node:(0,B.jsx)(`blockquote`,{className:`my-3 rounded-lg border-l-4 border-primary/50 bg-muted/60 px-3 py-2 text-muted-foreground`,children:Z(n.join(` `))},t),nextIndex:r}}let a=[],o=t;for(;o<e.length;){let t=e[o]?.trim()??``;if(!t||ye(t))break;a.push(t),o+=1}return{node:(0,B.jsx)(`p`,{children:Z(a.join(` `))},t),nextIndex:o}}function we(e){let t=ve(e).replace(/\r\n/g,`
|
|
6
|
+
`).split(`
|
|
7
|
+
`),n=[],r=0;for(;r<t.length;){if(!(t[r]??``).trim()){r+=1;continue}let e=Ce(t,r);n.push(e.node),r=e.nextIndex}return n}function Te(e){return Array.isArray(e)?e.map(e=>Te(e)).filter(e=>e.trim().length>0).join(`, `):e&&typeof e==`object`?``:String(e??``)}function Ee(e){try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?[]:Object.entries(t).map(([e,t])=>({key:e,value:Te(t)})).filter(e=>e.value.trim().length>0)}catch{return[]}}function De(e){return e.replace(/\r\n/g,`
|
|
8
|
+
`).split(`
|
|
9
|
+
`).map(e=>e.match(/^([A-Za-z0-9_.-]+):\s*(.+)$/)).filter(e=>!!e).map(e=>({key:e[1]??``,value:e[2]?.replace(/^["']|["']$/g,``)??``})).filter(e=>e.key&&e.value.trim().length>0)}function Oe(e){let t=Ee(e);return t.length>0?t:De(e)}function ke(){return(0,B.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5`,children:[(0,B.jsx)(I,{className:`h-7 w-1/2`}),(0,B.jsx)(I,{className:`mt-3 h-4 w-3/4`}),(0,B.jsx)(I,{className:`mt-4 h-4 w-full`}),(0,B.jsx)(I,{className:`mt-3 h-4 w-2/3`})]}),(0,B.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(220px,0.42fr)_minmax(0,1fr)]`,children:[(0,B.jsx)(I,{className:`h-56 rounded-xl`}),(0,B.jsx)(I,{className:`h-56 rounded-xl`})]})]})}function Ae({raw:e}){let t=Oe(e);return t.length===0?(0,B.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words font-mono text-xs leading-6`,children:e}):(0,B.jsx)(`dl`,{className:`m-0`,children:t.map(e=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[minmax(104px,0.34fr)_minmax(0,1fr)] gap-3 border-b border-border/70 py-2 last:border-b-0`,children:[(0,B.jsx)(`dt`,{className:`break-words font-semibold text-primary`,children:e.key}),(0,B.jsx)(`dd`,{className:`m-0 break-words text-card-foreground`,children:e.value})]},e.key))})}function je({title:e,children:t}){return(0,B.jsxs)(`article`,{className:`overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:[(0,B.jsx)(`h2`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-sm font-semibold text-card-foreground`,children:e}),(0,B.jsx)(`div`,{className:`p-4 text-sm leading-7 text-card-foreground`,children:t})]})}function Me(){return(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background p-6 text-center text-muted-foreground`,children:(0,B.jsxs)(`div`,{className:`max-w-sm`,children:[(0,B.jsx)(ie,{className:`mx-auto mb-3 h-7 w-7 text-muted-foreground`}),(0,B.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:n(`marketplaceDetailUnavailableTitle`)}),(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-6`,children:n(`marketplaceDetailUnavailableDescription`)})]})})}function Ne({entry:e}){let t=e.metadataRaw?.trim()||`-`,r=e.contentRaw?.trim()||`-`,i=e.summary?.trim(),a=e.description?.trim(),o=!!a&&a!==i;return(0,B.jsx)(`main`,{className:`h-full overflow-auto bg-background text-foreground custom-scrollbar`,children:(0,B.jsxs)(`div`,{className:`mx-auto max-w-[940px] space-y-4 p-5 pb-9`,children:[(0,B.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{className:`mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-muted text-primary`,children:(0,B.jsx)(P,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h1`,{className:`break-words text-2xl font-semibold leading-tight text-foreground`,children:e.title}),(0,B.jsxs)(`p`,{className:`mt-2 break-words text-xs text-muted-foreground`,children:[e.typeLabel,` · `,e.spec,e.author?` · ${e.author}`:``]})]})]}),i?(0,B.jsx)(`p`,{className:`mt-4 text-sm leading-7 text-card-foreground`,children:i}):null,o?(0,B.jsx)(`p`,{className:`mt-3 text-sm leading-7 text-card-foreground`,children:a}):null,e.tags&&e.tags.length>0?(0,B.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:e.tags.map(e=>(0,B.jsx)(`span`,{className:`rounded-full border border-border bg-muted px-3 py-1 text-xs text-muted-foreground`,children:e},e))}):null,e.sourceUrl?(0,B.jsxs)(`p`,{className:`mt-4 break-all text-xs text-muted-foreground`,children:[e.sourceLabel??n(`marketplaceDetailSource`),`: `,` `,(0,B.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-primary hover:underline`,children:e.sourceUrl})]}):null]}),(0,B.jsxs)(`section`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(300px,100%),1fr))] gap-4`,children:[(0,B.jsx)(je,{title:n(`marketplaceDetailMetadata`),children:(0,B.jsx)(Ae,{raw:t})}),(0,B.jsx)(je,{title:n(`marketplaceDetailContent`),children:(0,B.jsx)(`div`,{className:`marketplace-detail-markdown space-y-3 text-sm leading-7 text-card-foreground [&_a]:font-medium [&_a]:text-primary [&_a:hover]:underline`,children:we(r)})})]})]})})}function Pe({currentUrl:e}){let t=ge(e),n=q(e=>t?e.entries[t]:void 0);return!t||!n?(0,B.jsx)(Me,{}):n.status===`loading`?(0,B.jsx)(ke,{}):(0,B.jsx)(Ne,{entry:n})}var Fe={[J]:{getTitle:e=>e.title,renderContent:({currentUrl:e})=>(0,B.jsx)(Pe,{currentUrl:e}),renderIcon:()=>(0,B.jsx)(P,{className:`h-4 w-4 text-primary`})}},Q=a(e(),1),Ie=160;function Le({disabled:e,onLoadMore:t,thresholdPx:n=Ie,watchValue:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(t),s=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{o.current=t},[t]),(0,Q.useEffect)(()=>{e&&(s.current=!1)},[e]),(0,Q.useEffect)(()=>{let t=i.current,r=a.current;if(e||!t||!r)return;let c=()=>{s.current||e||(s.current=!0,Promise.resolve(o.current()).finally(()=>{s.current=!1}))},l=()=>{r.getBoundingClientRect().top-t.getBoundingClientRect().bottom<=n&&c()};if(typeof IntersectionObserver==`function`){let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:t,rootMargin:`0px 0px ${n}px 0px`});return e.observe(r),l(),()=>{e.disconnect()}}return t.addEventListener(`scroll`,l,{passive:!0}),l(),()=>{t.removeEventListener(`scroll`,l)}},[e,n,r]),{containerRef:i,sentinelRef:a}}function Re(e){return(e??``).trim().toLowerCase()}function ze(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=Re(r);!e||t.has(e)||t.set(e,n)}}return t}function Be(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=Re(e);if(!n)continue;let r=t.get(n);if(r)return r}}function Ve(e,t,r){return K(t?.summaryI18n,t?.summary,e)||fe(r,e)||n(`marketplaceInstalledLocalSummary`)}function He(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}function Ue(e){let{item:t,record:r,localeFallbacks:i,onOpen:a,onInstall:o,onToggle:s,onDoctor:c,onRemove:l}=e,u=r,d=t?.name??r?.label??r?.id??`MCP`,f=Ve(i,t,r),p=He(t,r),m=u?u.enabled===!1?n(`marketplaceDisable`):n(`statusReady`):null;return(0,B.jsx)(`article`,{onClick:a,className:`cursor-pointer rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm transition hover:border-blue-300 hover:shadow-md`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:d}),(0,B.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:p}),(0,B.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:f}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(t?.tags??[]).map(e=>(0,B.jsx)(L,{children:e},e)),m?(0,B.jsx)(L,{tone:`success`,children:m}):null]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!u&&t&&o?(0,B.jsx)(b,{type:`button`,size:`sm`,variant:`primary`,className:`rounded-xl`,onClick:e=>{e.stopPropagation(),o()},children:n(`marketplaceInstall`)}):null,u?(0,B.jsxs)(B.Fragment,{children:[s?(0,B.jsx)(b,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-gray-200 text-gray-700`,onClick:e=>{e.stopPropagation(),s()},children:u.enabled===!1?n(`marketplaceEnable`):n(`marketplaceDisable`)}):null,c?(0,B.jsx)(b,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-blue-200 text-blue-700 hover:border-blue-300 hover:bg-blue-50 hover:text-blue-700`,onClick:e=>{e.stopPropagation(),c()},children:n(`marketplaceMcpDoctor`)}):null,l?(0,B.jsx)(b,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-rose-200 text-rose-600 hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600`,onClick:e=>{e.stopPropagation(),l()},children:n(`marketplaceMcpRemove`)}):null]}):null]})]})})}function We(e){let{item:t,open:n,pending:r,onOpenChange:i,onSubmit:a}=e;return(0,B.jsx)(T,{open:n,onOpenChange:i,children:t?(0,B.jsx)(Ge,{item:t,pending:r,onOpenChange:i,onSubmit:a},`${t.slug}:${n?`open`:`closed`}`):null})}function Ge(e){let{item:t,pending:r,onOpenChange:i,onSubmit:a}=e,o=t.install,[s,c]=(0,Q.useState)(o?.defaultName??``),[l,u]=(0,Q.useState)(!0),[f,p]=(0,Q.useState)(Object.fromEntries((o?.inputs??[]).map(e=>[e.id,e.defaultValue??``])));return(0,B.jsxs)(D,{children:[(0,B.jsxs)(E,{children:[(0,B.jsx)(O,{children:n(`marketplaceMcpInstallDialogTitle`)}),(0,B.jsx)(w,{children:t.name})]}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:n(`marketplaceMcpServerName`)}),(0,B.jsx)(d,{value:s,onChange:e=>c(e.target.value),placeholder:o?.defaultName??`mcp-server`})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:n(`marketplaceMcpAllAgents`)}),(0,B.jsx)(`div`,{className:`text-xs text-gray-500`,children:n(`marketplaceMcpAllAgentsDescription`)})]}),(0,B.jsx)(x,{checked:l,onCheckedChange:u})]}),(o?.inputs??[]).map(e=>(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description?(0,B.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,B.jsx)(d,{type:e.secret?`password`:`text`,value:f[e.id]??``,onChange:t=>p(n=>({...n,[e.id]:t.target.value})),placeholder:e.defaultValue??``})]},e.id))]}),(0,B.jsxs)(C,{children:[(0,B.jsx)(b,{variant:`outline`,onClick:()=>i(!1),disabled:r,children:n(`cancel`)}),(0,B.jsx)(b,{onClick:()=>void a({name:s,allAgents:l,inputs:f}),disabled:r||!s.trim(),children:n(r?`marketplaceInstalling`:`marketplaceInstall`)})]})]})}function Ke(e){let{result:t,targetName:r,open:i,pending:a,onOpenChange:o}=e;return(0,B.jsx)(T,{open:i,onOpenChange:o,children:(0,B.jsxs)(D,{children:[(0,B.jsxs)(E,{children:[(0,B.jsx)(O,{children:n(`marketplaceMcpDoctorTitle`)}),(0,B.jsx)(w,{children:r??`-`})]}),a?(0,B.jsx)(`div`,{className:`text-sm text-gray-500`,children:n(`loading`)}):null,!a&&t?(0,B.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,B.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorAccessible`),`:`,` `,t.accessible?n(`statusReady`):n(`marketplaceOperationFailed`)]}),(0,B.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTransport`),`:`,` `,t.transport.toUpperCase()]}),(0,B.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTools`),`: `,t.toolCount]}),t.error?(0,B.jsx)(F,{tone:`danger`,description:t.error,className:`rounded-lg`}):null]}):null]})})}function qe(e){let t=R({queryKey:[`marketplace-mcp-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>s({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,staleTime:15e3}),n=(0,Q.useMemo)(()=>z(t.data),[t.data]);return{...t,data:n}}function Je(){return m({queryKey:[`marketplace-mcp-installed`],queryFn:()=>c(),staleTime:1e4})}function Ye(){let e=g();return u({mutationFn:f,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),l.success(t.message||n(`marketplaceInstallSuccessMcp`))},onError:e=>{l.error(e.message||n(`marketplaceInstallFailed`))}})}function Xe(){let e=g();return u({mutationFn:v,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),l.success(t.message||n(`marketplaceMcpManageSuccess`))},onError:e=>{l.error(e.message||n(`marketplaceOperationFailed`))}})}var $=12;function Ze(){let[e,t]=(0,Q.useState)(`catalog`),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(`relevance`),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),{language:_}=re(),v=ce(),{confirm:y,ConfirmDialog:b}=se(),x=(0,Q.useMemo)(()=>W(_),[_]);(0,Q.useEffect)(()=>{let e=window.setTimeout(()=>{s(r.trim())},250);return()=>window.clearTimeout(e)},[r]);let S=qe({q:o||void 0,sort:c,pageSize:$}),C=Je(),{containerRef:w,sentinelRef:T}=Le({disabled:e!==`catalog`||S.isError||!S.hasNextPage||S.isFetchingNextPage,onLoadMore:()=>S.fetchNextPage(),watchValue:`${e}:${o}:${c}:${S.data?.loadedItems??0}:${S.data?.loadedPages??0}`});(0,Q.useEffect)(()=>{let e=w.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[w,o,e,c]);let E=Ye(),D=Xe(),O=u({mutationFn:te,onSuccess:(e,t)=>{m(t),g(e)}}),k=(0,Q.useMemo)(()=>ze(C.data?.records??[]),[C.data?.records]),A=(0,Q.useMemo)(()=>(C.data?.records??[]).filter(e=>{let t=[e.id??``,e.label??``,e.catalogSlug??``,e.description??``,e.descriptionZh??``].join(` `).toLowerCase();return o?t.includes(o.toLowerCase()):!0}),[C.data?.records,o]),j=async(e,t)=>{let r=e?.name??t?.label??t?.id??`MCP`,i=Y(e?`mcp`:`mcp-local`,e?.slug??t?.id??t?.spec??r),a=Ve(x,e,t);if(!e){X(v,{id:i,title:r,typeLabel:n(`marketplaceTypeMcp`),spec:t?.spec??`-`,status:`ready`,summary:a,metadataRaw:JSON.stringify(t??{},null,2),contentRaw:n(`marketplaceInstalledLocalSummary`),sourceUrl:t?.docsUrl,sourceLabel:n(`marketplaceDetailSource`)});return}X(v,{id:i,title:r,typeLabel:n(`marketplaceTypeMcp`),spec:e.install.spec,status:`loading`,summary:a,tags:e.tags,author:e.author});try{let t=await ee(e.slug);X(v,{id:i,title:r,typeLabel:n(`marketplaceTypeMcp`),spec:e.install.spec,status:`ready`,summary:a,metadataRaw:t.metadataRaw||JSON.stringify(e,null,2),contentRaw:t.bodyRaw||t.raw,sourceUrl:t.sourceUrl,sourceLabel:n(`marketplaceDetailSource`),tags:e.tags,author:e.author},{activate:!1})}catch(t){X(v,{id:i,title:r,typeLabel:n(`marketplaceTypeMcp`),spec:e.install.spec,status:`error`,summary:a,metadataRaw:JSON.stringify({error:t instanceof Error?t.message:String(t)},null,2),contentRaw:a},{activate:!1})}},M=async e=>{d&&(await E.mutateAsync({spec:d.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),f(null))},N=async(e,t)=>{let r=t.id||t.spec;r&&(e===`remove`&&!await y({title:`${n(`marketplaceMcpRemoveTitle`)} ${r}?`,description:n(`marketplaceMcpRemoveDescription`),confirmLabel:n(`marketplaceMcpRemove`),variant:`destructive`})||await D.mutateAsync({action:e,id:r,spec:t.spec}))},P=[{id:`catalog`,label:n(`marketplaceMcpTabCatalog`),icon:oe},{id:`installed`,label:n(`marketplaceMcpTabInstalled`),icon:ue,count:C.data?.total??0}];return(0,B.jsxs)(ne,{className:`flex h-full min-h-0 flex-col pb-0 px-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-6 w-full max-w-[1400px] h-full min-h-0 mx-auto`,children:[(0,B.jsxs)(`div`,{className:`relative overflow-hidden rounded-[32px] bg-gradient-to-br from-[#0F172A] via-[#1E1B4B] to-[#312E81] px-10 py-14 text-white shadow-xl isolate`,children:[(0,B.jsx)(`div`,{className:`absolute top-0 right-0 -m-32 opacity-30 pointer-events-none mix-blend-screen scale-150 transform-gpu`,children:(0,B.jsx)(`div`,{className:`w-[500px] h-[500px] rounded-full bg-gradient-to-tl from-fuchsia-500/40 via-purple-500/30 to-indigo-500/20 blur-[80px]`})}),(0,B.jsx)(`div`,{className:`absolute bottom-0 left-0 -m-32 opacity-20 pointer-events-none mix-blend-screen transform-gpu`,children:(0,B.jsx)(`div`,{className:`w-[400px] h-[400px] rounded-full bg-gradient-to-tr from-blue-500/40 to-cyan-500/20 blur-[80px]`})}),(0,B.jsxs)(`div`,{className:`relative z-10 flex flex-col gap-3`,children:[(0,B.jsx)(`h1`,{className:`text-[38px] font-extrabold tracking-[-0.02em] leading-tight drop-shadow-sm text-transparent bg-clip-text bg-gradient-to-r from-white via-white to-white/70`,children:n(`marketplaceMcpPageTitle`)}),(0,B.jsx)(`p`,{className:`text-[17px] font-medium text-purple-100/70 max-w-2xl leading-relaxed tracking-wide`,children:n(`marketplaceMcpPageDescription`)})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4 mt-2`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-gray-100/60 backdrop-blur-sm rounded-2xl w-fit border border-gray-200/50 shadow-inner`,children:P.map(n=>{let r=e===n.id,a=n.icon;return(0,B.jsxs)(`button`,{onClick:()=>t(n.id),className:i(`relative flex items-center gap-2 px-5 py-2.5 rounded-xl font-semibold text-[14px] transition-all duration-300`,r?`text-gray-900 bg-white shadow-[0_2px_10px_rgb(0,0,0,0.06)]`:`text-gray-500 hover:text-gray-700 hover:bg-gray-200/40`),children:[(0,B.jsx)(a,{className:i(`w-4 h-4`,r?`text-primary`:`text-gray-400`)}),n.label,n.id===`installed`&&typeof n.count==`number`&&(0,B.jsx)(`span`,{className:i(`ml-1 flex items-center justify-center h-5 px-1.5 min-w-5 rounded-full text-[11px] font-bold transition-colors`,r?`bg-primary/10 text-primary`:`bg-gray-200 text-gray-500`),children:n.count})]},n.id)})}),(0,B.jsx)(`div`,{className:`flex-1 w-full md:max-w-md`,children:(0,B.jsx)(V,{scope:e===`catalog`?`all`:`installed`,searchText:r,isRefreshing:!1,searchPlaceholder:n(`marketplaceMcpSearchPlaceholder`),sort:c,onSearchTextChange:a,onSortChange:l})})]}),(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col mt-2`,children:[(0,B.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-1`,children:(0,B.jsxs)(`h3`,{className:`text-[18px] font-bold tracking-tight text-gray-900 flex items-center gap-2`,children:[n(e===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`),(0,B.jsx)(`span`,{className:`flex items-center justify-center h-6 px-2 rounded-lg bg-gray-100 text-[12px] font-semibold text-gray-500`,children:e===`catalog`?S.data?.total??0:C.data?.total??0})]})}),(0,B.jsxs)(`div`,{ref:w,className:`min-h-0 flex-1 overflow-y-auto pr-3 pb-8 -mx-1 px-1 custom-scrollbar`,"aria-busy":S.isLoading||S.isFetchingNextPage,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-[22px] md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 items-stretch`,children:[e===`catalog`&&S.isLoading&&(0,B.jsx)(H,{count:$}),e===`catalog`&&!S.isLoading&&(S.data?.items??[]).map(e=>{let t=Be(e,k);return(0,B.jsx)(Ue,{item:e,record:t,localeFallbacks:x,onOpen:()=>void j(e,t),onInstall:()=>f(e),onToggle:t?()=>void N(t.enabled===!1?`enable`:`disable`,t):void 0,onDoctor:t?()=>{m(t.id??null),g(null),O.mutateAsync(t.id??``)}:void 0,onRemove:t?()=>void N(`remove`,t):void 0},e.id)}),e===`installed`&&A.map(e=>(0,B.jsx)(Ue,{record:e,localeFallbacks:x,onOpen:()=>void j(void 0,e),onToggle:()=>void N(e.enabled===!1?`enable`:`disable`,e),onDoctor:()=>{m(e.id??null),g(null),O.mutateAsync(e.id??``)},onRemove:()=>void N(`remove`,e)},e.id??e.spec))]}),e===`catalog`&&S.isError&&(0,B.jsx)(F,{tone:`danger`,title:n(`marketplaceMcpSectionCatalog`),description:S.error.message}),e===`installed`&&C.isError&&(0,B.jsx)(F,{tone:`danger`,title:n(`marketplaceMcpSectionInstalled`),description:C.error.message}),e===`catalog`&&!S.isLoading&&!S.isError&&(S.data?.items?.length??0)===0&&(0,B.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,B.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoMcp`)})}),e===`installed`&&!C.isError&&A.length===0&&(0,B.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,B.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoInstalledMcp`)})}),e===`catalog`&&!S.isError&&(0,B.jsx)(U,{hasMore:!!S.hasNextPage,loading:S.isFetchingNextPage,sentinelRef:T})]})]})]}),(0,B.jsx)(We,{item:d,open:!!d,pending:E.isPending,onOpenChange:e=>!e&&f(null),onSubmit:M}),(0,B.jsx)(Ke,{open:!!p,targetName:p,result:h,pending:O.isPending,onOpenChange:e=>!e&&m(null)}),(0,B.jsx)(b,{})]})}export{X as a,V as c,z as d,R as f,Y as i,U as l,Le as n,W as o,Fe as r,K as s,Ze as t,H as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./mcp-marketplace-page-C_MVQUbT.js";export{e as McpMarketplacePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,p as t,r as n,v as r}from"./react-DjpzoZXB.js";import{Mt as i,Nt as a}from"./api-DLtsiBKm.js";import{c as o,l as s,n as c,s as l}from"./switch-C1BWMU5c.js";import{t as u}from"./book-open-BQwWBDKb.js";import{t as d}from"./provider-scoped-model-input-g1WkGiJ8.js";import{t as f}from"./loader-circle-BjmN5DeJ.js";import{n as p,t as m}from"./skeleton-shfmXuYp.js";import{s as h}from"./doc-browser-context-Sv-044Cl.js";import{m as g,mt as _}from"./index-Z1fYpbNd.js";import{l as v,m as y,r as b,t as x,u as S}from"./use-config-DAdbT5QJ.js";import{t as C}from"./config-hints-fGnUjDe9.js";var w=r(e(),1),T=t(),E=`provider/model`;function D(e){let{initialModel:t,initialWorkspace:r,isPending:o,modelHelpText:c,modelLabel:l,modelPlaceholder:m,onSubmit:g,providerCatalog:v,workspaceLabel:y,workspacePlaceholder:b}=e,[x,S]=(0,w.useState)(t),[C,E]=(0,w.useState)(r);return(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g({model:x,workspace:C})},className:`space-y-8`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(p,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:n(`defaultModel`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(i,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:l}),(0,T.jsx)(d,{id:`model`,value:x,onChange:S,providerCatalog:v,modelPlaceholder:m}),(0,T.jsx)(`p`,{className:`text-xs text-gray-400`,children:c}),(0,T.jsxs)(`a`,{href:`${h}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,T.jsx)(u,{className:`h-3.5 w-3.5`}),n(`channelsGuideTitle`)]})]})]}),(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(_,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:n(`workspace`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(i,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:y}),(0,T.jsx)(a,{id:`workspace`,value:C,onChange:e=>E(e.target.value),placeholder:b,className:`rounded-xl`})]})]})]}),(0,T.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,T.jsx)(s,{type:`submit`,disabled:o,size:`lg`,children:o?(0,T.jsx)(f,{className:`h-5 w-5 animate-spin`}):n(`saveChanges`)})})]})}function O(){let{data:e,isLoading:t}=x(),{data:r}=S(),{data:i}=v(),{data:a}=b(),s=y(),u=a?.uiHints,d=C(`agents.defaults.model`,u),f=C(`agents.defaults.workspace`,u),p=(0,w.useMemo)(()=>g({providersView:r,templatesView:i,config:e,onlyConfigured:!0}),[e,r,i]),h=n(`modelIdentifierHelp`)||d?.help||``,_=(e?.agents?.defaults?.model||``).trim(),O=e?.agents?.defaults?.workspace||``;return t?(0,T.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(m,{className:`h-8 w-32`}),(0,T.jsx)(m,{className:`h-4 w-48`})]}),(0,T.jsxs)(c,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsxs)(`div`,{className:`mb-6 flex items-center gap-4`,children:[(0,T.jsx)(m,{className:`h-12 w-12 rounded-xl`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(m,{className:`h-5 w-24`}),(0,T.jsx)(m,{className:`h-3 w-32`})]})]}),(0,T.jsx)(m,{className:`mb-2 h-4 w-20`}),(0,T.jsx)(m,{className:`h-10 w-full rounded-xl`})]}),(0,T.jsxs)(c,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsx)(m,{className:`mb-2 h-5 w-24`}),(0,T.jsx)(m,{className:`h-10 w-full rounded-xl`})]})]}):(0,T.jsxs)(o,{children:[(0,T.jsx)(l,{title:n(`modelPageTitle`),description:n(`modelPageDescription`)}),(0,T.jsx)(D,{initialModel:_,initialWorkspace:O,isPending:s.isPending,modelHelpText:h,modelLabel:d?.label??`Model Name`,modelPlaceholder:d?.placeholder??E,onSubmit:({model:e,workspace:t})=>s.mutate({model:e,workspace:t}),providerCatalog:p,workspaceLabel:f?.label??`Default Path`,workspacePlaceholder:f?.placeholder??`/path/to/workspace`},`${_}::${O}`)]})}export{O as ModelConfigPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e}from"./dist-D2eZC3OR.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,p as t,r as n,u as r,v as i}from"./react-DjpzoZXB.js";import{Nt as a}from"./api-DLtsiBKm.js";import{c as o}from"./dist-D2eZC3OR.js";import{a as s,i as c,n as l,r as u,t as d,w as f}from"./select-D7GcNP0z.js";import{B as p,H as m,V as h,W as g,b as _,g as v,h as y}from"./index-Z1fYpbNd.js";var b=o(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),x=i(e(),1),S=t(),C=g(`15rem`);function w(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function T({id:e,value:t,onChange:n,options:i,disabled:o=!1,placeholder:s,className:c,inputClassName:l,emptyText:u,createText:d,toggleLabel:g,maxItems:_=1/0,onEnter:v}){let[y,T]=(0,x.useState)(!1);(0,x.useEffect)(()=>{o&&y&&T(!1)},[o,y]);let E=(0,x.useMemo)(()=>w(i),[i]),D=t.trim().toLowerCase(),O=(0,x.useMemo)(()=>{let e=E.map((e,t)=>({option:e,index:t}));D.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===D?0:n.startsWith(D)?1:n.includes(D)?2:3,a=r===D?0:r.startsWith(D)?1:r.includes(D)?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},[E,D,_]),k=t.trim().length>0&&E.some(e=>e===t.trim()),A=()=>T(!1);return(0,S.jsxs)(p,{open:y&&!o,onOpenChange:e=>T(!o&&e),children:[(0,S.jsx)(h,{asChild:!0,children:(0,S.jsxs)(`div`,{className:r(`relative`,c),children:[(0,S.jsx)(a,{id:e,value:t,disabled:o,onFocus:()=>{o||T(!0)},onChange:e=>{n(e.target.value),!y&&!o&&T(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),A())},placeholder:s,className:r(`pr-10`,l)}),(0,S.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e=>!e),disabled:o,className:r(`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":g,children:(0,S.jsx)(b,{className:`h-4 w-4`})})]})}),(0,S.jsx)(m,{align:`start`,className:`flex w-[var(--radix-popover-trigger-width)] min-w-[12rem] flex-col overflow-hidden rounded-xl border border-gray-200 p-0 shadow-lg`,onOpenAutoFocus:e=>e.preventDefault(),style:{maxHeight:C},children:(0,S.jsxs)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto py-1`,children:[!k&&t.trim().length>0&&(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:`h-4 w-4 text-transparent`}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:d.replace(`{value}`,t.trim())})]}),O.map(e=>(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:r(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),O.length===0&&t.trim().length===0&&(0,S.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u})]})})]})}var E=`provider/model`;function D(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function O({id:e,value:t,onChange:r,providerCatalog:i,disabled:o=!1,providerPlaceholder:f,modelPlaceholder:p,className:m}){let[h,g]=(0,x.useState)(``),[b,C]=(0,x.useState)(``),w=i.length>0,O=p??E,k=(0,x.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),A=k.get(h),j=(0,x.useMemo)(()=>A?.aliases??[],[A]),M=(0,x.useMemo)(()=>D(A?.models??[]),[A]);return(0,x.useEffect)(()=>{let e=t.trim();if(!w){g(``),C(e);return}if(!e){C(``),g(e=>k.has(e)?e:``);return}let n=v(e,i)??``,r=k.get(n)?.aliases??[];g(n),C(n?_(e,r):e)},[w,i,k,t]),w?(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,S.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,S.jsxs)(d,{value:h,onValueChange:e=>{let t=D(k.get(e)?.models??[])[0]??``;if(g(e),C(t),!t){r(``);return}r(y(k.get(e)?.prefix??e,t))},disabled:o,children:[(0,S.jsx)(c,{className:`h-10 w-full rounded-xl`,children:(0,S.jsx)(s,{placeholder:f??n(`providersSelectPlaceholder`)})}),(0,S.jsx)(l,{children:i.map(e=>(0,S.jsx)(u,{value:e.name,children:e.displayName},e.name))})]})}),(0,S.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,S.jsx)(T,{id:e,value:b,onChange:e=>{if(!A){let t=e.trim();C(t),r(t);return}let t=_(e,j);C(t),r(t?y(A.prefix,t):``)},options:M,disabled:o||!h,placeholder:O,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:n(`modelPickerNoOptions`),createText:n(`modelPickerUseCustom`),toggleLabel:n(`modelPickerToggleOptions`)},h)]}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]}):(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,S.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:n(`providersEmptyTitle`)}),(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:n(`providersEmptyDescription`)})]}),(0,S.jsx)(a,{id:e,value:t,disabled:o,onChange:e=>r(e.target.value),placeholder:O,className:`mt-3 h-10 rounded-xl`}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]})}export{O as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,h as t,p as n,r,u as i,v as a}from"./react-DjpzoZXB.js";import{It as o,Mt as s,Nt as c,Yt as l}from"./api-DLtsiBKm.js";import{c as u,l as d,s as f,t as p}from"./switch-C1BWMU5c.js";import{c as m}from"./dist-D2eZC3OR.js";import{t as h}from"./confirm-dialog-iIJFFp2T.js";import{t as g}from"./search-MxAarS_g.js";import{C as _,a as v,i as y,n as b,r as x,t as S}from"./select-D7GcNP0z.js";import{t as C}from"./ellipsis-2uzhypw5.js";import{t as w}from"./plus-3ztRZD_l.js";import{t as T}from"./x-DqL1mYLC.js";import{t as E}from"./host-capabilities-9bB_998Z.js";import{B as D,H as O,I as k,U as A,_ as j,dt as M,f as N,ht as P,nt as F,p as I,rt as L,v as R,y as z}from"./index-Z1fYpbNd.js";import{a as ee,c as B,d as V,f as te,h as ne,i as re,l as ie,r as ae,s as H,u as oe}from"./use-config-DAdbT5QJ.js";import{t as U}from"./config-hints-fGnUjDe9.js";import{a as W,c as G,i as K,n as se,o as q,r as ce,s as J}from"./config-split-page-EidRBpP2.js";var le=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`}]]),ue=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`}]]),de=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`}]]),Y=a(t(),1),X=n();function fe({isSet:e,className:t,value:n,onChange:r,placeholder:a,...o}){let[s,l]=(0,Y.useState)(!1),[u,f]=(0,Y.useState)(!1),p=typeof n==`string`&&n.length>0;return(0,X.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!u?(0,X.jsx)(`div`,{onClick:()=>f(!0),className:i(`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,X.jsx)(c,{type:s?`text`:`password`,className:i(`pr-12`,t),value:n,onChange:r,onBlur:()=>{p||f(!1)},placeholder:a,autoFocus:u,...o}),(0,X.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,X.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!s),children:s?(0,X.jsx)(ue,{className:`h-4 w-4`}):(0,X.jsx)(P,{className:`h-4 w-4`})})})]})}function pe({value:e,onChange:t,className:n}){let a=e?Object.entries(e):[],o=(e,n,r)=>{let i=[...a];i[e]=[n,r],t(Object.fromEntries(i))},s=()=>{t({...e,"":``})},l=e=>{let n=a.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,X.jsxs)(`div`,{className:i(`space-y-2`,n),children:[a.map(([e,t],n)=>(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(c,{type:`text`,value:e,onChange:e=>o(n,e.target.value,t),placeholder:r(`headerName`),className:`flex-1`}),(0,X.jsx)(c,{type:`text`,value:t,onChange:t=>o(n,e,t.target.value),placeholder:r(`headerValue`),className:`flex-1`}),(0,X.jsx)(d,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(n),children:(0,X.jsx)(L,{className:`h-4 w-4 text-red-500`})})]},n)),(0,X.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,X.jsx)(w,{className:`h-4 w-4 mr-2`}),r(`add`)]})]})}function me(e){let{value:t,onChange:n,options:r}=e;return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,X.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-primary-foreground shadow-sm`:`border-border bg-card text-muted-foreground hover:border-primary/40 hover:bg-accent/70 hover:text-accent-foreground`}`,children:e.label},e.value)})})}function he(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:c,shouldUseWireApiPills:l,wireApiSelectOptions:u,extraHeadersLabel:d,extraHeaders:f,onExtraHeadersChange:p}=e;return(0,X.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(de,{className:`h-3.5 w-3.5`}),r(`providerAdvancedSettings`)]}),(0,X.jsx)(_,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,X.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(s,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),l?(0,X.jsx)(me,{value:o,onChange:e=>c(e),options:u}):(0,X.jsxs)(S,{value:o,onValueChange:e=>c(e),children:[(0,X.jsx)(y,{className:`rounded-xl`,children:(0,X.jsx)(v,{})}),(0,X.jsx)(b,{children:u.map(e=>(0,X.jsx)(x,{value:e.value,children:e.label},e.value))})]})]}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(s,{className:`text-sm font-medium text-foreground`,children:d}),(0,X.jsx)(pe,{value:f,onChange:p}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerExtraHeadersHelpShort`)})]})]}):null]})}function ge(e){let{providerAuth:t,providerAuthNote:n,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:u,onStartProviderAuth:f,onImportProviderAuthFromCli:p,startPending:m,importPending:h,authSessionId:g,authStatusMessage:_}=e;return t?.kind===`device_code`?(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,X.jsx)(s,{className:`text-sm font-medium text-foreground`,children:t.displayName||r(`providerAuthSectionTitle`)}),n?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}):null,a>1?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(s,{className:`text-xs font-medium text-foreground`,children:r(`providerAuthMethodLabel`)}),c?(0,X.jsx)(me,{value:l,onChange:u,options:i}):(0,X.jsxs)(S,{value:l,onValueChange:u,children:[(0,X.jsx)(y,{className:`h-8 rounded-lg`,children:(0,X.jsx)(v,{placeholder:r(`providerAuthMethodPlaceholder`)})}),(0,X.jsx)(b,{children:i.map(e=>(0,X.jsx)(x,{value:e.value,children:e.label},e.value))})]}),o?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o}):null]}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:f,disabled:m||!!g,children:r(m?`providerAuthStarting`:g?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,X.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:p,disabled:h,children:r(h?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,g?(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[r(`providerAuthSessionLabel`),`: `,g.slice(0,8),`…`]}):null]}),_?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:_}):null]}):null}var _e={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function Z(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 ve(e,t){let n=Z(e),r=Z(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 Q(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 ye(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 $(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=ye(n,t))}return n.trim()}function be(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function xe(e,t){return Q(t)}function Se(e,t){return Q(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Ce(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={},a=R(i.thinking?.supported);if(a.length>0){let t=z(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function we(e,t,n){return{...j(e,n),...j(t,n)}}function Te(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||!be([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Ee(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!ve(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!be(e.models,e.currentEditableModels)||!Te(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function De(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=Z(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),ve(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),be(e.models,e.currentEditableModels)||(t.models=Se(e.models,e.providerName??``)),Te(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Ce(e.modelConfig,e.models)),t}function Oe(e){let t=$(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={apiBase:e.apiBase.trim(),extraHeaders:Z(e.extraHeaders),model:t||null};return e.apiKey.trim().length>0&&(n.apiKey=e.apiKey.trim()),e.supportsWireApi&&(n.wireApi=e.wireApi),n}function ke(e){return r(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ae(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 je(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Me(e,t,n){let r=$(t,n);return r?r.includes(`/`)?{models:e,draft:t,errorKey:`providerModelInvalidProviderPrefix`}:e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function Ne(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function Pe(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):I.filter(e=>e===n||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Fe(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function Ie(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function Le(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Ae({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:je({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Re(e,t){let n=!!e?.supportsWireApi||t,i=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:r(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:je({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:i.length}),supportsWireApi:n,wireApiSelectOptions:i}}function ze(e){let{providerName:t,providersView:n,templatesView:i,schema:a,language:o}=e,s=t?n?.providers[t]:null,c=i?.providerTemplates.find(e=>e.providerType===s?.providerType),l=s??_e,u=a?.uiHints,d=!!s?.isCustom,f=t?U(`providers.${t}.apiKey`,u):void 0,p=t?U(`providers.${t}.apiBase`,u):void 0,m=t?U(`providers.${t}.extraHeaders`,u):void 0,h=t?U(`providers.${t}.wireApi`,u):void 0,g=c?.displayName||s?.displayName||t||``,_=(l.displayName||``).trim()||g,v=l.enabled!==!1,y=Q([c?.modelPrefix||c?.providerType||``,t||``]),b=c?.defaultApiBase||``,x=l.apiBase||b,S=Z(l.extraHeaders||null),C=l.wireApi||c?.defaultWireApi||`auto`,w=xe(Q((c?.defaultModels??[]).map(e=>$(e,y))),Q((l.models??[]).map(e=>$(e,y)))),T=Ce(we(c?.modelConfig,l.modelConfig,y),w),E=c?.apiBaseHelp?.[o]||c?.apiBaseHelp?.en||p?.help||r(`providerApiBaseHelp`),D=Le({providerName:t,providerSpec:c,language:o}),O=Re(c,d);return{apiBaseHelpText:E,apiBaseHint:p,apiKeyHint:f,currentApiBase:x,currentEditableModels:w,currentEnabled:v,currentHeaders:S,currentModelConfig:T,currentWireApi:C,defaultApiBase:b,defaultDisplayName:g,effectiveDisplayName:_,extraHeadersHint:m,...D,providerConfig:s,providerModelAliases:y,resolvedProviderConfig:l,wireApiHint:h,...O}}function Be(e){let{models:t,modelConfig:n,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:l,onAddModel:u,onRemoveModel:f,onToggleModelThinkingLevel:m,onSetModelThinkingDefault:h,onSetModelVision:g,thinkingLevels:_,formatThinkingLevelLabel:C}=e;return(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(s,{className:`text-sm font-medium text-foreground`,children:r(`providerModelsTitle`)}),a?null:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,X.jsx)(w,{className:`h-3 w-3`}),r(`providerAddModel`)]})]}),a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(c,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u()),e.key===`Escape`&&(l(!1),o(``))},placeholder:r(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,X.jsx)(d,{type:`button`,size:`sm`,onClick:u,disabled:i.trim().length===0,children:r(`add`)}),(0,X.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{l(!1),o(``)},children:(0,X.jsx)(T,{className:`h-4 w-4`})})]}):null,t.length===0?(0,X.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-muted/60 px-4 py-6 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`providerModelsEmptyShort`)}),a?null:(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:r(`providerAddFirstModel`)})]}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=n[e],i=t?.thinking,a=i?.supported??[],o=i?.default??null,c=t?.vision===!0;return(0,X.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-card px-3 py-1.5`,children:[(0,X.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,X.jsxs)(D,{children:[(0,X.jsx)(A,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-accent hover:text-accent-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`providerModelThinkingTitle`),title:r(`providerModelThinkingTitle`),children:(0,X.jsx)(de,{className:`h-3 w-3`})})}),(0,X.jsxs)(O,{className:`w-80 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/60 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelVisionTitle`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelVisionHint`)})]}),(0,X.jsx)(p,{checked:c,onCheckedChange:t=>g(e,t)})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelThinkingTitle`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingHint`)})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_.map(t=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${a.includes(t)?`border-primary bg-primary text-white`:`border-border bg-card text-muted-foreground hover:border-primary/40 hover:bg-accent/70 hover:text-accent-foreground`}`,children:C(t)},t))}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(s,{className:`text-xs font-medium text-foreground`,children:r(`providerModelThinkingDefault`)}),(0,X.jsxs)(S,{value:o??`__none__`,onValueChange:t=>h(e,t===`__none__`?null:t),disabled:a.length===0,children:[(0,X.jsx)(y,{className:`h-8 rounded-lg text-xs`,children:(0,X.jsx)(v,{})}),(0,X.jsxs)(b,{children:[(0,X.jsx)(x,{value:`__none__`,children:r(`providerModelThinkingDefaultNone`)}),a.map(e=>(0,X.jsx)(x,{value:e,children:C(e)},e))]})]}),a.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-accent hover:text-accent-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`remove`),children:(0,X.jsx)(T,{className:`h-3 w-3`})})]},e)})})]})}function Ve({apiKeySet:e,className:t,enabled:n}){return n?(0,X.jsx)(F,{status:e?`ready`:`setup`,label:r(e?`statusReady`:`statusSetup`),className:t}):(0,X.jsx)(F,{status:`inactive`,label:r(`disabled`),className:t})}function He(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:i}=e,a=l(),s=V(),c=B(),u=H(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),_=(0,Y.useRef)(null),v=(0,Y.useCallback)(()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},[]),y=(0,Y.useCallback)((e,n)=>{v(),_.current=window.setTimeout(()=>{(async()=>{if(t)try{let i=await c.mutateAsync({provider:t,data:{sessionId:e}});if(i.status===`pending`){g(r(`providerAuthWaitingBrowser`)),y(e,i.nextPollMs??n);return}if(i.status===`authorized`){m(null),v(),g(r(`providerAuthCompleted`)),o.success(r(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}m(null),v(),g(i.message||`Authorization ${i.status}.`),o.error(i.message||`Authorization ${i.status}.`)}catch(e){m(null),v();let t=e instanceof Error?e.message:String(e);g(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[v,c,t,a]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{f(t),g(``);let e=await s.mutateAsync({provider:t,data:i?{methodId:i}:{}});if(!e.sessionId||!e.verificationUri)throw Error(r(`providerAuthStartFailed`));m(e.sessionId),g(`${r(`providerAuthOpenPrompt`)}${e.userCode}${r(`providerAuthOpenPromptSuffix`)}`),await E.openExternalUrl(e.verificationUri),y(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);m(null),v(),g(t),o.error(`${r(`providerAuthStartFailed`)}: ${t}`)}},[v,n?.kind,t,i,y,s]),x=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{f(t),v(),m(null);let e=await u.mutateAsync({provider:t});g(`${r(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),o.success(r(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);g(t),o.error(`${r(`providerAuthImportFailed`)}: ${t}`)}},[v,u,n?.kind,t,a]);return(0,Y.useEffect)(()=>{v()},[v,t]),(0,Y.useEffect)(()=>()=>v(),[v]),{authSessionId:d===t?p:null,authStatusMessage:d===t?h:``,importAuthFromCli:x,importPending:u.isPending,startAuth:b,startPending:s.isPending}}function Ue({providerName:t,onProviderDeleted:n}){let{data:i}=oe(),{data:a}=ie(),{data:s}=ae(),c=ne(),l=ee(),u=te(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(`auto`),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)({}),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(``),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(``),N=e(),P=(0,Y.useMemo)(()=>ze({providerName:t,providersView:i,templatesView:a,schema:s,language:N}),[N,t,i,s,a]),{currentApiBase:F,currentEditableModels:I,currentHeaders:L,currentModelConfig:R,currentWireApi:z,defaultApiBase:B,effectiveDisplayName:V,providerAuth:re,providerAuthMethods:H,providerConfig:U,providerModelAliases:W,resolvedProviderConfig:G,preferredAuthMethodId:K,supportsWireApi:q}=P,ce=T.trim()||V||t||r(`providersSelectPlaceholder`),J=(0,Y.useMemo)(()=>{if(!H.length)return``;let e=j.trim();return e&&H.some(t=>t.id===e)?e:K||H[0]?.id||``},[j,K,H]),{authSessionId:le,authStatusMessage:ue,importAuthFromCli:de,importPending:fe,startAuth:pe,startPending:me}=He({providerName:t,providerAuth:re,resolvedAuthMethodId:J});(0,Y.useEffect)(()=>{if(!t){f(``),m(``),g(null),v(`auto`),b([]),S({}),w(``),E(``),M(``);return}f(``),m(F),g(G.extraHeaders||null),v(z),b(I),S(R),w(``),E(V),M(K)},[t,F,G.extraHeaders,z,I,R,V,K]),(0,Y.useEffect)(()=>S(e=>Ce(e,y)),[y]);let he=(0,Y.useMemo)(()=>Ee({providerName:t,apiKey:d,apiBase:p,currentApiBase:F,extraHeaders:h,currentHeaders:L,supportsWireApi:q,wireApi:_,currentWireApi:z,models:y,currentEditableModels:I,modelConfig:x,currentModelConfig:R,providerDisplayName:T,effectiveDisplayName:V}),[t,d,p,F,h,L,q,_,z,y,I,x,R,T,V]);return!t||!U?(0,X.jsx)(se,{children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(`providersSelectTitle`)}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:r(`providersSelectDescription`)})]})}):(0,X.jsx)(We,{context:P,language:N,providerTitle:ce,providerDisplayName:T,apiKey:d,apiBase:p,extraHeaders:h,wireApi:_,models:y,modelConfig:x,modelDraft:C,showAdvanced:D,showModelInput:k,resolvedAuthMethodId:J,authSessionId:le,authStatusMessage:ue,hasChanges:he,isDeletePending:l.isPending,isUpdatePending:c.isPending,isTestPending:u.isPending,startPending:me,importPending:fe,onProviderDisplayNameChange:E,onApiKeyChange:f,onApiBaseChange:m,onAuthMethodChange:M,onStartProviderAuth:pe,onImportProviderAuthFromCli:de,onModelDraftChange:w,onShowModelInputChange:A,onAddModel:()=>{let e=Me(y,C,W);if(e.errorKey){o.error(r(`providerModelInvalidProviderPrefix`));return}b(e.models),w(e.draft)},onRemoveModel:e=>{let t=Ne(y,x,e);b(t.models),S(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{S(n=>Pe(n,e,t))},onSetModelThinkingDefault:(e,t)=>{S(n=>Fe(n,e,t))},onSetModelVision:(e,t)=>{S(n=>Ie(n,e,t))},onShowAdvancedChange:O,onWireApiChange:v,onExtraHeadersChange:g,onDeleteProvider:async()=>{if(t&&window.confirm(r(`providerDeleteConfirm`)))try{await l.mutateAsync({provider:t}),n?.(t)}catch{}},onSubmit:e=>{e.preventDefault(),t&&c.mutate({provider:t,data:De({providerName:t,apiKey:d,apiBase:p,currentApiBase:F,defaultApiBase:B,extraHeaders:h,currentHeaders:L,supportsWireApi:q,wireApi:_,currentWireApi:z,models:y,currentEditableModels:I,modelConfig:x,currentModelConfig:R,providerDisplayName:T,effectiveDisplayName:V})})},onTestConnection:async()=>{if(t)try{let e=await u.mutateAsync({provider:t,data:Oe({apiKey:d,apiBase:p,extraHeaders:h,supportsWireApi:q,wireApi:_,models:y,providerModelAliases:W})});if(e.success){o.success(`${r(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let n=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&n.push(`model=${e.model}`),o.error(`${r(`providerTestConnectionFailed`)}: ${e.message} | ${n.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);o.error(`${r(`providerTestConnectionFailed`)}: ${t}`)}}})}function We(e){let{context:t,language:n,providerTitle:i,providerDisplayName:a,apiKey:o,apiBase:l,extraHeaders:u,wireApi:f,models:p,modelConfig:m,modelDraft:h,showAdvanced:g,showModelInput:_,resolvedAuthMethodId:v,authSessionId:y,authStatusMessage:b,hasChanges:x,isDeletePending:S,isUpdatePending:C,isTestPending:w,startPending:T,importPending:E,onProviderDisplayNameChange:D,onApiKeyChange:O,onApiBaseChange:k,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:F,onRemoveModel:R,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:ee,onSetModelVision:B,onShowAdvancedChange:V,onWireApiChange:te,onExtraHeadersChange:ne,onDeleteProvider:re,onSubmit:ie,onTestConnection:ae}=e,H=t.providerAuthMethods.find(e=>e.id===v);return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{className:`px-6 py-4`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:i}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:re,disabled:S,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:r(`providerDelete`),children:(0,X.jsx)(L,{className:`h-4 w-4`})}),(0,X.jsx)(Ve,{enabled:t.currentEnabled,apiKeySet:t.resolvedProviderConfig.apiKeySet})]})]})}),(0,X.jsxs)(`form`,{onSubmit:ie,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(q,{className:`space-y-5 px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(s,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:r(`providerDisplayName`)}),(0,X.jsx)(c,{id:`providerDisplayName`,type:`text`,value:a,onChange:e=>D(e.target.value),placeholder:t.defaultDisplayName||r(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerDisplayNameHelpShort`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(s,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:t.apiKeyHint?.label??r(`apiKey`)}),(0,X.jsx)(fe,{id:`apiKey`,value:o,isSet:t.resolvedProviderConfig.apiKeySet,onChange:e=>O(e.target.value),placeholder:t.apiKeyHint?.placeholder??r(`enterApiKey`),className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`leaveBlankToKeepUnchanged`)})]}),(0,X.jsx)(ge,{providerAuth:t.providerAuth,providerAuthNote:t.providerAuth?.note?.[n]||t.providerAuth?.note?.en||t.providerAuth?.displayName||``,providerAuthMethodOptions:t.providerAuthMethodOptions,providerAuthMethodsCount:t.providerAuthMethods.length,selectedAuthMethodHint:H?.hint?.[n]||H?.hint?.en||``,shouldUseAuthMethodPills:t.shouldUseAuthMethodPills,resolvedAuthMethodId:v,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,startPending:T,importPending:E,authSessionId:y,authStatusMessage:b}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(s,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:t.apiBaseHint?.label??r(`apiBase`)}),(0,X.jsx)(c,{id:`apiBase`,type:`text`,value:l,onChange:e=>k(e.target.value),placeholder:t.defaultApiBase||t.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.apiBaseHelpText})]}),(0,X.jsx)(Be,{models:p,modelConfig:m,modelDraft:h,showModelInput:_,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:F,onRemoveModel:R,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:ee,onSetModelVision:B,thinkingLevels:I,formatThinkingLevelLabel:ke}),(0,X.jsx)(he,{showAdvanced:g,onShowAdvancedChange:V,supportsWireApi:t.supportsWireApi,wireApiLabel:t.wireApiHint?.label??r(`wireApi`),wireApi:f,onWireApiChange:te,shouldUseWireApiPills:t.shouldUseWireApiPills,wireApiSelectOptions:t.wireApiSelectOptions,extraHeadersLabel:t.extraHeadersHint?.label??r(`extraHeaders`),extraHeaders:u,onExtraHeadersChange:ne})]}),(0,X.jsxs)(J,{className:`flex items-center justify-between px-6 py-4`,children:[(0,X.jsxs)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:ae,disabled:w,children:[(0,X.jsx)(le,{className:`mr-1.5 h-4 w-4`}),r(w?`providerTestingConnection`:`providerTestConnection`)]}),(0,X.jsx)(d,{type:`submit`,disabled:C||!x,children:r(C?`saving`:x?`save`:`unchanged`)})]})]})]})}function Ge(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 Ke(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function qe(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function Je(){let{isMobile:e}=N(),{data:t}=oe(),{data:n}=ie(),a=re(),o=ee(),s=ne(),[l,m]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)([]),[T,E]=(0,Y.useState)(``),j=(0,Y.useMemo)(()=>Ke(Object.values(t?.providers??{}),x),[t?.providers,x]),P=(0,Y.useMemo)(()=>n?.providerTemplates??[],[n?.providerTemplates]),I=(0,Y.useMemo)(()=>qe(P),[P]),R=(0,Y.useMemo)(()=>new Map(P.map(e=>[e.providerType,e])),[P]),z=(0,Y.useMemo)(()=>{let e=T.trim().toLowerCase();return j.filter(t=>{if(!e)return!0;let n=t.providerType?R.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[j,T,R]),B=(0,Y.useMemo)(()=>l&&z.some(e=>e.providerId===l)?l:e?null:z[0]?.providerId??null,[z,e,l]);return!t||!n?(0,X.jsx)(`div`,{className:`p-8`,children:r(`providersLoading`)}):(0,X.jsxs)(u,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,X.jsx)(f,{title:r(`providersPageTitle`),description:r(`providersPageDescription`)}),(0,X.jsxs)(K,{className:`xl:min-h-0`,mobileView:e?B?`detail`:`list`:void 0,onMobileBack:()=>m(null),mobileListLabel:r(`providersPageTitle`),children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,X.jsxs)(D,{open:y,onOpenChange:b,children:[(0,X.jsx)(A,{asChild:!0,children:(0,X.jsxs)(d,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,X.jsx)(w,{className:`mr-2 h-4 w-4`}),a.isPending?r(`saving`):r(`providerAdd`)]})}),(0,X.jsxs)(O,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,X.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:r(`providerTemplatePickerTitle`)}),(0,X.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border bg-card px-3 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/70`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});E(``),m(e.providerId),S(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),b(!1)}catch{}},children:[(0,X.jsx)(k,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border bg-background`}),(0,X.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:r(`providerAddCustom`)})]}),I.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border bg-card px-3 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/70`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});E(``),m(t.providerId),S(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),b(!1)}catch{}},children:[(0,X.jsx)(k,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,X.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,X.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(g,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,X.jsx)(c,{value:T,onChange:e=>E(e.target.value),placeholder:r(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,X.jsxs)(q,{className:`space-y-2 p-3`,children:[z.map(e=>{let t=e.providerType?R.get(e.providerType):null,n=e.enabled!==!1,a=!!(n&&e.apiKeySet),o=e.displayName?.trim()||t?.displayName||e.providerId,c=Ge(e.apiBase||t?.defaultApiBase||``)||r(`providersDefaultDescription`);return(0,X.jsx)(`div`,{onClick:()=>m(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m(e.providerId))},role:`button`,tabIndex:0,className:i(`w-full rounded-xl border p-2.5 text-left transition-all`,B===e.providerId?`border-primary/35 bg-primary-50/45 text-foreground shadow-sm`:`border-border bg-card text-muted-foreground hover:border-primary/35 hover:bg-accent/70 hover:text-accent-foreground`),children:(0,X.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,X.jsx)(k,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:i(`h-10 w-10 rounded-lg border`,a?`border-primary/35 bg-background`:`border-border bg-background`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,X.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:o}),(0,X.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,X.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[c,` · `,e.models?.length??0]})]})]}),(0,X.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5`,children:[(0,X.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,X.jsx)(p,{checked:n,disabled:s.isPending,title:r(n?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{s.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,X.jsxs)(D,{children:[(0,X.jsx)(A,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-accent hover:text-accent-foreground`,onClick:e=>e.stopPropagation(),title:r(`more`),children:(0,X.jsx)(C,{className:`h-4 w-4`})})}),(0,X.jsx)(O,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-sm text-red-600 hover:bg-red-50`,onClick:()=>v(e.providerId),children:[(0,X.jsx)(L,{className:`h-4 w-4`}),r(`providerDelete`)]})})]})]}),(0,X.jsx)(F,{status:n?a?`ready`:`setup`:`inactive`,label:r(n?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),z.length===0?(0,X.jsx)(ce,{icon:M,title:r(`providersNoMatch`)}):null]})]}),(0,X.jsx)(Ue,{providerName:B??void 0,onProviderDeleted:e=>{S(t=>t.filter(t=>t!==e)),e===B&&m(null)}})]}),(0,X.jsx)(h,{open:!!_,onOpenChange:e=>{e||v(null)},title:r(`providerDelete`),description:_??void 0,confirmLabel:r(`delete`),variant:`destructive`,onCancel:()=>v(null),onConfirm:()=>{_&&o.mutateAsync({provider:_}).then(()=>{S(e=>e.filter(e=>e!==_)),_===B&&m(null),v(null)})}})]})}export{Je as ProvidersConfigPage};
|