@nextclaw/ui 0.20.3 → 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/CHANGELOG.md +45 -0
- package/dist/assets/{api-iMkU_o5P.js → api-m33O1Kb0.js} +6 -6
- package/dist/assets/{appearance-settings-page-CU5k4b-M.js → appearance-settings-page-x4Vjnfmz.js} +1 -1
- package/dist/assets/{book-open-nD8gdMhA.js → book-open-BHiasMCg.js} +1 -1
- package/dist/assets/{channels-list-page-Drlt62kY.js → channels-list-page-DOxJZeXq.js} +2 -2
- package/dist/assets/{config-split-page-BtJZp1E5.js → config-split-page-DBnMEP1o.js} +1 -1
- package/dist/assets/{confirm-dialog-k2-Jq_x3.js → confirm-dialog-f5NKLh5I.js} +2 -2
- package/dist/assets/{createLucideIcon-DxlwKLr-.js → createLucideIcon-CHALGA42.js} +1 -1
- package/dist/assets/desktop-capabilities-page-DixayAe6.js +1 -0
- package/dist/assets/desktop-update-config-ChhfeOHj.js +1 -0
- package/dist/assets/{dist-Cy_e4kNb.js → dist-_UMsWSY0.js} +1 -1
- package/dist/assets/{dist-m08DUswB.js → dist-sD6V4nHX.js} +1 -1
- package/dist/assets/doc-browser-Bq7LJsQY.js +1 -0
- package/dist/assets/doc-browser-BuDgpY2e.js +1 -0
- package/dist/assets/{doc-browser-context-jiy-O4F8.js → doc-browser-context-Capim3og.js} +1 -1
- package/dist/assets/{extensions-CIb17__o.js → extensions-Bdclr3Wr.js} +1 -1
- package/dist/assets/{form-actions-DGf5zUg_.js → form-actions-CH0kWhEt.js} +1 -1
- package/dist/assets/index-BjxnLYE3.js +109 -0
- package/dist/assets/index-CBmwJjwE.css +1 -0
- package/dist/assets/loader-circle-CH_0iPLy.js +1 -0
- package/dist/assets/mcp-marketplace-page-BUsxLVB5.js +10 -0
- package/dist/assets/mcp-marketplace-page-GPRV3fB0.js +1 -0
- package/dist/assets/model-config-page-CIevwqp4.js +1 -0
- package/dist/assets/{navigation-link-DAfwFCj4.js → navigation-link-CAUiM3zS.js} +1 -1
- package/dist/assets/plus-B3obD55V.js +1 -0
- package/dist/assets/privacy-settings-page-CNKfZsYH.js +1 -0
- package/dist/assets/providers-config-page-DAah2NIS.js +1 -0
- package/dist/assets/react-Co6JiC1n.js +8 -0
- package/dist/assets/{refresh-cw-D_Eibznw.js → refresh-cw-BG_LX3SS.js} +1 -1
- package/dist/assets/remote-DuscgfvR.js +1 -0
- package/dist/assets/{rotate-cw-QQjmoWuq.js → rotate-cw-Cz7I_m7O.js} +1 -1
- package/dist/assets/runtime-config-page-Cl1RpmSC.js +1 -0
- package/dist/assets/{save-W2xthJJ2.js → save-BiHnb8ps.js} +1 -1
- package/dist/assets/{search-Vih1R2BD.js → search-C47TyRg0.js} +1 -1
- package/dist/assets/{search-config-page-CtBcL2uc.js → search-config-page-BAIzd6gN.js} +1 -1
- package/dist/assets/{secrets-config-page-Q6XfIj0h.js → secrets-config-page-Ddi-n43R.js} +2 -2
- package/dist/assets/security-config-C8MHnE1r.js +1 -0
- package/dist/assets/{select-lNdozU4o.js → select-BzQKfW1e.js} +2 -2
- package/dist/assets/skeleton-BXFAE9SE.js +1 -0
- package/dist/assets/{tag-chip-gdaU9bE7.js → tag-chip-C3K814HZ.js} +1 -1
- package/dist/assets/x-C1r9IXet.js +1 -0
- package/dist/index.html +29 -21
- package/dist/themes/island/island-atmosphere.webp +0 -0
- package/index.html +8 -0
- package/package.json +8 -8
- package/public/themes/island/island-atmosphere.webp +0 -0
- package/src/app/components/layout/header.tsx +4 -1
- package/src/app/components/layout/page-layout.tsx +4 -1
- package/src/app/components/layout/sidebar.tsx +6 -1
- package/src/app/configs/app-navigation.config.ts +17 -2
- package/src/app/hooks/use-feature-controls.ts +11 -0
- package/src/app/index.tsx +10 -0
- package/src/app/styles/island-theme.css +542 -0
- package/src/features/chat/components/conversation/__tests__/chat-conversation-header.test.tsx +1 -0
- package/src/features/chat/components/conversation/chat-conversation-header.tsx +5 -1
- package/src/features/chat/components/conversation/chat-conversation-panel.tsx +4 -1
- package/src/features/chat/components/layout/__tests__/chat-sidebar-toolbar.test.tsx +10 -0
- package/src/features/chat/components/layout/chat-page-shell.tsx +4 -1
- package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +2 -0
- package/src/features/chat/components/layout/chat-sidebar.tsx +2 -0
- package/src/features/chat/features/session/components/__tests__/chat-sidebar-session-item.test.tsx +12 -0
- package/src/features/chat/features/session/components/chat-sidebar-session-entry.tsx +3 -0
- package/src/features/chat/features/session/components/chat-sidebar-session-item.tsx +14 -1
- package/src/features/chat/features/session/utils/chat-session-deletion.utils.ts +25 -0
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel.test.tsx +1 -0
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +1 -0
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel.tsx +1 -0
- package/src/features/chat/managers/__tests__/chat-thread-deletion.manager.test.ts +125 -0
- package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +0 -37
- package/src/features/chat/managers/chat-thread.manager.ts +17 -28
- package/src/features/desktop-capabilities/components/desktop-authorization-dialog.test.tsx +58 -0
- package/src/features/desktop-capabilities/components/desktop-authorization-dialog.tsx +161 -0
- package/src/features/desktop-capabilities/hooks/use-desktop-capabilities.test.ts +10 -0
- package/src/features/desktop-capabilities/hooks/use-desktop-capabilities.ts +55 -0
- package/src/features/desktop-capabilities/index.ts +1 -0
- package/src/features/desktop-capabilities/managers/desktop-capability.manager.ts +25 -0
- package/src/features/desktop-capabilities/pages/desktop-capabilities-page.test.tsx +44 -0
- package/src/features/desktop-capabilities/pages/desktop-capabilities-page.tsx +171 -0
- package/src/features/desktop-capabilities/stores/desktop-authorization.store.ts +21 -0
- package/src/features/marketplace/components/mcp/__tests__/mcp-connection-dialog.test.tsx +23 -0
- package/src/features/marketplace/components/mcp/mcp-connection-dialog.tsx +35 -0
- package/src/features/marketplace/components/mcp/mcp-marketplace-page.tsx +20 -2
- package/src/features/pwa/managers/__tests__/pwa-shell-theme.manager.test.ts +9 -0
- package/src/features/pwa/managers/pwa-shell-theme.manager.ts +1 -0
- package/src/features/service-apps/components/__tests__/service-apps-panel.test.tsx +35 -1
- package/src/features/service-apps/components/service-action-row.tsx +130 -0
- package/src/features/service-apps/components/service-app-list-item.tsx +11 -66
- package/src/features/service-apps/components/service-apps-panel.tsx +12 -0
- package/src/features/service-apps/hooks/use-service-apps.ts +20 -1
- package/src/features/settings/pages/__tests__/appearance-settings-page.test.tsx +2 -2
- package/src/features/side-dock/components/side-dock.tsx +1 -0
- package/src/index.css +1 -0
- package/src/platforms/desktop/components/__tests__/desktop-app-shell.test.tsx +8 -0
- package/src/platforms/desktop/components/desktop-app-shell.tsx +56 -2
- package/src/platforms/desktop/components/desktop-window-chrome.tsx +1 -0
- package/src/platforms/mobile/components/mobile-settings-shell.tsx +5 -1
- package/src/shared/components/doc-browser/__tests__/doc-browser.test.tsx +3 -0
- package/src/shared/components/doc-browser/doc-browser.tsx +2 -0
- package/src/shared/components/ui/__tests__/confirm-dialog.test.tsx +31 -0
- package/src/shared/components/ui/confirm-dialog.tsx +11 -1
- package/src/shared/components/ui/context-menu/context-menu.tsx +1 -0
- package/src/shared/components/ui/dialog.tsx +2 -0
- package/src/shared/components/ui/overlays/sheet.tsx +2 -0
- package/src/shared/components/ui/popover.tsx +1 -0
- package/src/shared/components/ui/select.tsx +1 -0
- package/src/shared/components/ui/tooltip.tsx +1 -0
- package/src/shared/lib/api/index.ts +1 -0
- package/src/shared/lib/api/utils/mcp-connection.utils.ts +10 -0
- package/src/shared/lib/i18n/locales/en-US/chat.json +2 -0
- package/src/shared/lib/i18n/locales/en-US/core.json +44 -0
- package/src/shared/lib/i18n/locales/en-US/doc-browser.json +1 -0
- package/src/shared/lib/i18n/locales/en-US/marketplace.json +29 -1
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +2 -0
- package/src/shared/lib/i18n/locales/zh-CN/core.json +44 -0
- package/src/shared/lib/i18n/locales/zh-CN/doc-browser.json +1 -0
- package/src/shared/lib/i18n/locales/zh-CN/marketplace.json +29 -1
- package/src/shared/lib/theme/index.test.ts +9 -0
- package/src/shared/lib/theme/index.ts +2 -0
- package/dist/assets/desktop-update-config-BiZmy7FC.js +0 -1
- package/dist/assets/doc-browser-CPsPHh12.js +0 -1
- package/dist/assets/doc-browser-npOvWtgf.js +0 -1
- package/dist/assets/index-C86hxgv5.css +0 -1
- package/dist/assets/index-CYBXR7zN.js +0 -109
- package/dist/assets/loader-circle-BlLuRFVW.js +0 -1
- package/dist/assets/mcp-marketplace-page-B12JNh7Q.js +0 -1
- package/dist/assets/mcp-marketplace-page-kLWW6kzt.js +0 -9
- package/dist/assets/model-config-page-DSeAjVT_.js +0 -1
- package/dist/assets/plus-D4LtWtTk.js +0 -1
- package/dist/assets/privacy-settings-page-tN0Mt15x.js +0 -1
- package/dist/assets/providers-config-page-CgPrXR1u.js +0 -1
- package/dist/assets/react-8iBFECZE.js +0 -8
- package/dist/assets/remote-Derr_AQp.js +0 -1
- package/dist/assets/runtime-config-page-Crq96Jjq.js +0 -1
- package/dist/assets/security-config-CE9rkQvq.js +0 -1
- package/dist/assets/skeleton-B__aTcly.js +0 -1
- package/dist/assets/x-CWdWBu_U.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-DxlwKLr-.js";var t=e(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./mcp-marketplace-page-kLWW6kzt.js";export{e as McpMarketplacePage};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,a as i,d as a,l as o,s,t as c,u as l}from"./react-8iBFECZE.js";import{An as u,Bt as d,G as f,H as p,K as m,Mn as h,On as g,U as ee,W as _,X as v,_n as y,an as te,fn as ne,gn as b,hn as x,jn as S,kn as C,ln as w,q as re,un as T,vn as E}from"./api-iMkU_o5P.js";import{a as D,i as O,n as k,r as A,t as ie}from"./select-lNdozU4o.js";import{a as j,c as ae,i as M,l as oe,n as se,o as ce,r as le,s as N,t as ue}from"./confirm-dialog-k2-Jq_x3.js";import{t as P}from"./createLucideIcon-DxlwKLr-.js";import"./doc-browser-npOvWtgf.js";import{t as de}from"./loader-circle-BlLuRFVW.js";import{t as F}from"./skeleton-B__aTcly.js";import{g as fe,n as I}from"./doc-browser-context-jiy-O4F8.js";import{t as L}from"./tag-chip-gdaU9bE7.js";var pe=class extends h{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:S()})}getOptimisticResult(e){return e.behavior=S(),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`,d=i&&c===`forward`,f=o&&c===`backward`,p=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:C(t,n.data),hasPreviousPage:u(t,n.data),isFetchNextPageError:l,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:p,isRefetchError:s&&!l&&!f,isRefetching:a&&!d&&!p}}};function R(e,t){return E(e,pe,t)}var z=P(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),me=P(`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`}]]),he=P(`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`}]]),B=e(n(),1),V=t(),ge=ne(`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`}}),_e={neutral:`text-gray-900`,success:`text-emerald-800`,warning:`text-amber-900`,danger:`text-rose-700`,info:`text-primary`},ve={neutral:`text-gray-600`,success:`text-emerald-700`,warning:`text-amber-800`,danger:`text-rose-700`,info:`text-primary/90`},H=B.forwardRef(({className:e,tone:t=`neutral`,borderStyle:n=`solid`,title:i,description:a,icon:o,actions:s,children:c,...l},u)=>{let d=t??`neutral`,f=!!i||!!a||!!o||!!s;return(0,V.jsxs)(`div`,{ref:u,className:r(ge({tone:d,borderStyle:n}),e),...l,children:[f?(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[o?(0,V.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:o}):null,(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i?(0,V.jsx)(`p`,{className:r(`text-sm font-medium`,_e[d]),children:i}):null,a?(0,V.jsx)(`p`,{className:r(i?`mt-1`:``,`text-sm leading-6`,ve[d]),children:a}):null]})]})}),s?(0,V.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,c?(0,V.jsx)(`div`,{className:r(f?`mt-3`:``),children:c}):null]})});H.displayName=`NoticeCard`;var ye={open:!1,title:``,description:``,confirmLabel:i(`confirm`),cancelLabel:i(`cancel`),variant:`default`,resolve:null};function U(){let[e,t]=(0,B.useState)(ye),n=(0,B.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??i(`confirm`),cancelLabel:e.cancelLabel??i(`cancel`),variant:e.variant??`default`,resolve:e=>{n(e),t(e=>({...e,open:!1,resolve:null}))}})}),[]),r=(0,B.useCallback)(e=>{t(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:n,ConfirmDialog:(0,B.useCallback)(()=>(0,V.jsx)(ue,{open:e.open,onOpenChange:r,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,r])}}var W=(0,B.createContext)(null);function be({children:e}){let[t,n]=(0,B.useState)(()=>o());(0,B.useEffect)(()=>a(e=>{n(e)}),[]);let r=(0,B.useCallback)(e=>{l(e),n(s())},[]),i=(0,B.useCallback)(()=>{r(t===`en`?`zh`:`en`)},[t,r]),c=(0,B.useMemo)(()=>({language:t,setLanguage:r,toggleLanguage:i}),[t,r,i]);return(0,V.jsx)(W.Provider,{value:c,children:e})}function G(){let e=(0,B.useContext)(W);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:i}}function K(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}}function q({scope:e,isRefreshing:t,searchText:n,searchPlaceholder:r,sort:a,onSearchTextChange:o,onSortChange:s}){return(0,V.jsx)(`div`,{className:`mb-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,V.jsx)(he,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,V.jsx)(`input`,{value:n,onChange:e=>o(e.target.value),placeholder:r,className:`h-9 w-full rounded-xl border border-border/75 bg-card pl-9 pr-9 text-sm transition-colors focus:outline-none focus:ring-0`}),t&&(0,V.jsx)(de,{className:`absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 animate-spin text-primary`,"aria-label":i(`marketplaceRefreshingResults`)})]}),e===`all`&&(0,V.jsxs)(ie,{value:a,onValueChange:e=>s(e),children:[(0,V.jsx)(O,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,V.jsx)(D,{})}),(0,V.jsxs)(k,{children:[(0,V.jsx)(A,{value:`relevance`,children:i(`marketplaceSortRelevance`)}),(0,V.jsx)(A,{value:`updated`,children:i(`marketplaceSortUpdated`)})]})]})]})})}function xe({count:e}){return(0,V.jsx)(V.Fragment,{children:Array.from({length:e},(e,t)=>(0,V.jsx)(`article`,{className:`h-full rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-2.5`,children:[(0,V.jsx)(F,{className:`h-9 w-9 shrink-0 rounded-lg`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,V.jsx)(F,{className:`h-4 w-32 max-w-[70%]`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(F,{className:`h-3 w-12`}),(0,V.jsx)(F,{className:`h-3 w-24`})]}),(0,V.jsx)(F,{className:`h-3 w-full`}),(0,V.jsxs)(`div`,{className:`flex gap-1.5 pt-0.5`,children:[(0,V.jsx)(F,{className:`h-5 w-14 rounded-md`}),(0,V.jsx)(F,{className:`h-5 w-16 rounded-md`}),(0,V.jsx)(F,{className:`h-5 w-12 rounded-md`})]})]})]}),(0,V.jsx)(F,{className:`h-7 w-16 shrink-0 rounded-md`})]})},`marketplace-skeleton-${t}`))})}function Se({hasMore:e,loading:t,sentinelRef:n}){return!e&&!t?null:(0,V.jsxs)(`div`,{className:`py-4`,children:[e&&(0,V.jsx)(`div`,{ref:n,className:`h-1 w-full`,"aria-hidden":`true`}),t&&(0,V.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:i(`loading`)})]})}function Ce(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function J(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function we(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:J(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=J(t),r=e.get(n);if(r)return r}for(let e of n){let n=J(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 Te(e,t){if(!e)return``;for(let n of t)if(J(n).split(`-`)[0]===`zh`&&e.descriptionZh?.trim())return e.descriptionZh.trim();return e.description?.trim()?e.description.trim():e.descriptionZh?.trim()?e.descriptionZh.trim():``}function Ee(){let e=I();(0,B.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;fe(r)&&(n.hasAttribute(`data-doc-external`)||t.ctrlKey||t.metaKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e.open(r)))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)},[e])}var Y=c(e=>({entries:{},setEntry:t=>e(e=>({entries:{...e.entries,[t.id]:t}}))}));function X(e){Y.getState().setEntry(e)}function De(e){let t=e.indexOf(`:`);return t<=0||t>=e.length-1?null:{scope:e.slice(0,t),key:e.slice(t+1)}}function Oe(e){return e===`skill`||e===`skill-preview`}function ke(e){let t=Y(t=>e?t.entries[e]:void 0);return(0,B.useEffect)(()=>{if(!e||Y.getState().entries[e])return;let t=De(e);if(!t||!Oe(t.scope))return;let n=!1,r=t.key,a=i(`marketplaceTypeSkill`);return v(t.key).then(o=>{n||X({id:e,title:r,typeLabel:a,spec:t.key,status:`ready`,summary:i(`marketplaceInstalledLocalSummary`),metadataRaw:o.metadataRaw,contentRaw:o.bodyRaw||o.raw,sourceUrl:o.sourceUrl,sourceLabel:o.source?`Source (${o.source})`:void 0})}).catch(()=>{n||X({id:e,title:r,typeLabel:a,spec:t.key,status:`error`,summary:i(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify({skill:t.key},null,2),contentRaw:i(`marketplaceDetailUnavailableDescription`)})}),()=>{n=!0}},[e]),t}var Ae=`marketplace-detail`,je=`nextclaw://marketplace-detail`;function Me(e,t){return`${e}:${t}`}function Ne(e){return`${je}/${encodeURIComponent(e)}`}function Pe(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 Fe(e){let t=Ne(e.id);return{dedupeKey:`marketplace-detail:${e.id}`,historyPolicy:`managed`,kind:Ae,resourceUri:t,title:e.title,url:t}}function Z(e,t,n){X(t),e.openTarget(Fe(t),{activate:n?.activate,dedupeKey:`marketplace-detail:${t.id}`,title:t.title})}function Ie(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 Q(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,V.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,V.jsx)(`strong`,{children:n.slice(2,-2)},o));else{let e=n.match(/^\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)$/);t.push(e?(0,V.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 Le(e){return/^(#{1,4})\s+/.test(e)||/^([-*])\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)}function Re(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,V.jsxs)(`div`,{className:`relative my-3 overflow-hidden rounded-lg border border-border bg-muted/70`,children:[a?(0,V.jsx)(`span`,{className:`absolute right-3 top-2 font-mono text-[10px] text-muted-foreground`,children:a}):null,(0,V.jsx)(`pre`,{className:`m-0 overflow-x-auto p-3 text-xs leading-6 text-foreground`,children:(0,V.jsx)(`code`,{children:r.join(`
|
|
5
|
-
`)})})]},t),nextIndex:i+1}}function ze(e,t,n){let i=[],a=t,o=n?/^\d+\.\s+/:/^[-*]\s+/;for(;a<e.length&&o.test(e[a]?.trim()??``);)i.push((e[a]??``).trim().replace(o,``)),a+=1;return{node:(0,V.jsx)(n?`ol`:`ul`,{className:r(`my-2 pl-5`,n?`list-decimal`:`list-disc`),children:i.map((e,n)=>(0,V.jsx)(`li`,{className:`my-1`,children:Q(e)},`${t}-${n}`))},t),nextIndex:a}}function Be(e,t,n){let r=`mb-2 mt-5 font-semibold leading-tight text-foreground`;return e===1?(0,V.jsx)(`h1`,{className:r,children:n},t):e===2?(0,V.jsx)(`h2`,{className:r,children:n},t):e===3?(0,V.jsx)(`h3`,{className:r,children:n},t):(0,V.jsx)(`h4`,{className:r,children:n},t)}function Ve(e,t){let n=e[t]?.trim()??``,r=n.match(/^```(\S*)/);if(r)return Re(e,t,r);let i=n.match(/^(#{1,4})\s+(.+)$/);if(i)return{node:Be(Math.min(4,i[1]?.length??2),t,Q(i[2]??``)),nextIndex:t+1};if(/^[-*]\s+/.test(n))return ze(e,t,!1);if(/^\d+\.\s+/.test(n))return ze(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,V.jsx)(`blockquote`,{className:`my-3 rounded-lg border-l-4 border-primary/50 bg-muted/60 px-3 py-2 text-muted-foreground`,children:Q(n.join(` `))},t),nextIndex:r}}let a=[],o=t;for(;o<e.length;){let t=e[o]?.trim()??``;if(!t||Le(t))break;a.push(t),o+=1}return{node:(0,V.jsx)(`p`,{children:Q(a.join(` `))},t),nextIndex:o}}function He(e){let t=Ie(e).replace(/\r\n/g,`
|
|
6
|
-
`).split(`
|
|
7
|
-
`),n=[],r=0;for(;r<t.length;){if(!(t[r]??``).trim()){r+=1;continue}let e=Ve(t,r);n.push(e.node),r=e.nextIndex}return n}function Ue(e){return Array.isArray(e)?e.map(e=>Ue(e)).filter(e=>e.trim().length>0).join(`, `):e&&typeof e==`object`?``:String(e??``)}function We(e){try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?[]:Object.entries(t).map(([e,t])=>({key:e,value:Ue(t)})).filter(e=>e.value.trim().length>0)}catch{return[]}}function Ge(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 Ke(e){let t=We(e);return t.length>0?t:Ge(e)}function qe(){return(0,V.jsxs)(`div`,{className:`space-y-4 p-5`,children:[(0,V.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5`,children:[(0,V.jsx)(F,{className:`h-7 w-1/2`}),(0,V.jsx)(F,{className:`mt-3 h-4 w-3/4`}),(0,V.jsx)(F,{className:`mt-4 h-4 w-full`}),(0,V.jsx)(F,{className:`mt-3 h-4 w-2/3`})]}),(0,V.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(220px,0.42fr)_minmax(0,1fr)]`,children:[(0,V.jsx)(F,{className:`h-56 rounded-xl`}),(0,V.jsx)(F,{className:`h-56 rounded-xl`})]})]})}function Je({raw:e}){let t=Ke(e);return t.length===0?(0,V.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words font-mono text-xs leading-6`,children:e}):(0,V.jsx)(`dl`,{className:`m-0`,children:t.map(e=>(0,V.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,V.jsx)(`dt`,{className:`break-words font-semibold text-primary`,children:e.key}),(0,V.jsx)(`dd`,{className:`m-0 break-words text-card-foreground`,children:e.value})]},e.key))})}function Ye({title:e,children:t}){return(0,V.jsxs)(`article`,{className:`overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:[(0,V.jsx)(`h2`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-sm font-semibold text-card-foreground`,children:e}),(0,V.jsx)(`div`,{className:`p-4 text-sm leading-7 text-card-foreground`,children:t})]})}function Xe(){return(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background p-6 text-center text-muted-foreground`,children:(0,V.jsxs)(`div`,{className:`max-w-sm`,children:[(0,V.jsx)(oe,{className:`mx-auto mb-3 h-7 w-7 text-muted-foreground`}),(0,V.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:i(`marketplaceDetailUnavailableTitle`)}),(0,V.jsx)(`p`,{className:`mt-2 text-sm leading-6`,children:i(`marketplaceDetailUnavailableDescription`)})]})})}function Ze({entry:e}){let t=e.metadataRaw?.trim()||`-`,n=e.contentRaw?.trim()||`-`,r=e.summary?.trim(),a=e.description?.trim(),o=!!a&&a!==r;return(0,V.jsx)(`main`,{className:`h-full overflow-auto bg-background text-foreground custom-scrollbar`,children:(0,V.jsxs)(`div`,{className:`mx-auto max-w-[940px] space-y-4 p-5 pb-9`,children:[(0,V.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,children:[(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.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,V.jsx)(z,{className:`h-4 w-4`})}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`break-words text-2xl font-semibold leading-tight text-foreground`,children:e.title}),(0,V.jsxs)(`p`,{className:`mt-2 break-words text-xs text-muted-foreground`,children:[e.typeLabel,` · `,e.spec,e.author?` · ${e.author}`:``]})]})]}),r?(0,V.jsx)(`p`,{className:`mt-4 text-sm leading-7 text-card-foreground`,children:r}):null,o?(0,V.jsx)(`p`,{className:`mt-3 text-sm leading-7 text-card-foreground`,children:a}):null,e.tags&&e.tags.length>0?(0,V.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:e.tags.map(e=>(0,V.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,V.jsxs)(`p`,{className:`mt-4 break-all text-xs text-muted-foreground`,children:[e.sourceLabel??i(`marketplaceDetailSource`),`: `,` `,(0,V.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-primary hover:underline`,children:e.sourceUrl})]}):null]}),(0,V.jsxs)(`section`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(300px,100%),1fr))] gap-4`,children:[(0,V.jsx)(Ye,{title:i(`marketplaceDetailMetadata`),children:(0,V.jsx)(Je,{raw:t})}),(0,V.jsx)(Ye,{title:i(`marketplaceDetailContent`),children:(0,V.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:He(n)})})]})]})})}function Qe({currentUrl:e}){let t=Pe(e),n=ke(t);return t?!n||n.status===`loading`?(0,V.jsx)(qe,{}):n.status===`error`&&!n.contentRaw?(0,V.jsx)(Xe,{}):(0,V.jsx)(Ze,{entry:n}):(0,V.jsx)(Xe,{})}var $e={[Ae]:{getTitle:e=>e.title,renderContent:({currentUrl:e})=>(0,V.jsx)(Qe,{currentUrl:e}),renderIcon:()=>(0,V.jsx)(z,{className:`h-4 w-4 text-primary`})}},et=160;function tt({disabled:e,onLoadMore:t,thresholdPx:n=et,watchValue:r}){let i=(0,B.useRef)(null),a=(0,B.useRef)(null),o=(0,B.useRef)(t),s=(0,B.useRef)(!1);return(0,B.useEffect)(()=>{o.current=t},[t]),(0,B.useEffect)(()=>{e&&(s.current=!1)},[e]),(0,B.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 $(e){return(e??``).trim().toLowerCase()}function nt(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=$(r);!e||t.has(e)||t.set(e,n)}}return t}function rt(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=$(e);if(!n)continue;let r=t.get(n);if(r)return r}}function it(e,t,n){return we(t?.summaryI18n,t?.summary,e)||Te(n,e)||i(`marketplaceInstalledLocalSummary`)}function at(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}function ot(e){let{item:t,record:n,localeFallbacks:r,onOpen:a,onInstall:o,onToggle:s,onDoctor:c,onRemove:l}=e,u=n,d=t?.name??n?.label??n?.id??`MCP`,f=it(r,t,n),p=at(t,n),m=u?u.enabled===!1?i(`marketplaceDisable`):i(`statusReady`):null;return(0,V.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,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:d}),(0,V.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:p}),(0,V.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:f}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(t?.tags??[]).map(e=>(0,V.jsx)(L,{children:e},e)),m?(0,V.jsx)(L,{tone:`success`,children:m}):null]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!u&&t&&o?(0,V.jsx)(T,{type:`button`,size:`sm`,variant:`primary`,className:`rounded-xl`,onClick:e=>{e.stopPropagation(),o()},children:i(`marketplaceInstall`)}):null,u?(0,V.jsxs)(V.Fragment,{children:[s?(0,V.jsx)(T,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-gray-200 text-gray-700`,onClick:e=>{e.stopPropagation(),s()},children:u.enabled===!1?i(`marketplaceEnable`):i(`marketplaceDisable`)}):null,c?(0,V.jsx)(T,{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:i(`marketplaceMcpDoctor`)}):null,l?(0,V.jsx)(T,{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:i(`marketplaceMcpRemove`)}):null]}):null]})]})})}function st(e){let{item:t,open:n,pending:r,onOpenChange:i,onSubmit:a}=e;return(0,V.jsx)(se,{open:n,onOpenChange:i,children:t?(0,V.jsx)(ct,{item:t,pending:r,onOpenChange:i,onSubmit:a},`${t.slug}:${n?`open`:`closed`}`):null})}function ct(e){let{item:t,pending:n,onOpenChange:r,onSubmit:a}=e,o=t.install,[s,c]=(0,B.useState)(o?.defaultName??``),[l,u]=(0,B.useState)(!0),[f,p]=(0,B.useState)(Object.fromEntries((o?.inputs??[]).map(e=>[e.id,e.defaultValue??``])));return(0,V.jsxs)(le,{children:[(0,V.jsxs)(ce,{children:[(0,V.jsx)(N,{children:i(`marketplaceMcpInstallDialogTitle`)}),(0,V.jsx)(M,{children:t.name})]}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:i(`marketplaceMcpServerName`)}),(0,V.jsx)(w,{value:s,onChange:e=>c(e.target.value),placeholder:o?.defaultName??`mcp-server`})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:i(`marketplaceMcpAllAgents`)}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500`,children:i(`marketplaceMcpAllAgentsDescription`)})]}),(0,V.jsx)(d,{checked:l,onCheckedChange:u})]}),(o?.inputs??[]).map(e=>(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description?(0,V.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,V.jsx)(w,{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,V.jsxs)(j,{children:[(0,V.jsx)(T,{variant:`outline`,onClick:()=>r(!1),disabled:n,children:i(`cancel`)}),(0,V.jsx)(T,{onClick:()=>void a({name:s,allAgents:l,inputs:f}),disabled:n||!s.trim(),children:i(n?`marketplaceInstalling`:`marketplaceInstall`)})]})]})}function lt(e){let{result:t,targetName:n,open:r,pending:a,onOpenChange:o}=e;return(0,V.jsx)(se,{open:r,onOpenChange:o,children:(0,V.jsxs)(le,{children:[(0,V.jsxs)(ce,{children:[(0,V.jsx)(N,{children:i(`marketplaceMcpDoctorTitle`)}),(0,V.jsx)(M,{children:n??`-`})]}),a?(0,V.jsx)(`div`,{className:`text-sm text-gray-500`,children:i(`loading`)}):null,!a&&t?(0,V.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,V.jsxs)(`div`,{children:[i(`marketplaceMcpDoctorAccessible`),`:`,` `,t.accessible?i(`statusReady`):i(`marketplaceOperationFailed`)]}),(0,V.jsxs)(`div`,{children:[i(`marketplaceMcpDoctorTransport`),`:`,` `,t.transport.toUpperCase()]}),(0,V.jsxs)(`div`,{children:[i(`marketplaceMcpDoctorTools`),`: `,t.toolCount]}),t.error?(0,V.jsx)(H,{tone:`danger`,description:t.error,className:`rounded-lg`}):null]}):null]})})}function ut(e){let t=R({queryKey:[`marketplace-mcp-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>f({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,staleTime:15e3}),n=(0,B.useMemo)(()=>K(t.data),[t.data]);return{...t,data:n}}function dt(){return y({queryKey:[`marketplace-mcp-installed`],queryFn:()=>_(),staleTime:1e4})}function ft(){let e=g();return b({mutationFn:m,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),x.success(t.message||i(`marketplaceInstallSuccessMcp`))},onError:e=>{x.error(e.message||i(`marketplaceInstallFailed`))}})}function pt(){let e=g();return b({mutationFn:re,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),x.success(t.message||i(`marketplaceMcpManageSuccess`))},onError:e=>{x.error(e.message||i(`marketplaceOperationFailed`))}})}var mt=12;function ht(){let[e,t]=(0,B.useState)(`catalog`),[n,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(`relevance`),[u,d]=(0,B.useState)(null),[f,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),{language:_}=G(),v=I(),{confirm:y,ConfirmDialog:ne}=U(),x=(0,B.useMemo)(()=>Ce(_),[_]);(0,B.useEffect)(()=>{let e=window.setTimeout(()=>{s(n.trim())},250);return()=>window.clearTimeout(e)},[n]);let S=ut({q:o||void 0,sort:c,pageSize:mt}),C=dt(),{containerRef:w,sentinelRef:re}=tt({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,B.useEffect)(()=>{let e=w.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[w,o,e,c]);let T=ft(),E=pt(),D=b({mutationFn:p,onSuccess:(e,t)=>{m(t),g(e)}}),O=(0,B.useMemo)(()=>nt(C.data?.records??[]),[C.data?.records]),k=(0,B.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]),A=async(e,t)=>{let n=e?.name??t?.label??t?.id??`MCP`,r=Me(e?`mcp`:`mcp-local`,e?.slug??t?.id??t?.spec??n),a=it(x,e,t);if(!e){Z(v,{id:r,title:n,typeLabel:i(`marketplaceTypeMcp`),spec:t?.spec??`-`,status:`ready`,summary:a,metadataRaw:JSON.stringify(t??{},null,2),contentRaw:i(`marketplaceInstalledLocalSummary`),sourceUrl:t?.docsUrl,sourceLabel:i(`marketplaceDetailSource`)});return}Z(v,{id:r,title:n,typeLabel:i(`marketplaceTypeMcp`),spec:e.install.spec,status:`loading`,summary:a,tags:e.tags,author:e.author});try{let t=await ee(e.slug);Z(v,{id:r,title:n,typeLabel:i(`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:i(`marketplaceDetailSource`),tags:e.tags,author:e.author},{activate:!1})}catch(t){Z(v,{id:r,title:n,typeLabel:i(`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})}},ie=async e=>{u&&(await T.mutateAsync({spec:u.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),d(null))},j=async(e,t)=>{let n=t.id||t.spec;n&&(e===`remove`&&!await y({title:`${i(`marketplaceMcpRemoveTitle`)} ${n}?`,description:i(`marketplaceMcpRemoveDescription`),confirmLabel:i(`marketplaceMcpRemove`),variant:`destructive`})||await E.mutateAsync({action:e,id:n,spec:t.spec}))},M=[{id:`catalog`,label:i(`marketplaceMcpTabCatalog`),icon:ae},{id:`installed`,label:i(`marketplaceMcpTabInstalled`),icon:me,count:C.data?.total??0}];return(0,V.jsxs)(te,{title:i(`marketplaceMcpPageTitle`),description:i(`marketplaceMcpPageDescription`),layout:`split`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsx)(`div`,{className:`flex w-fit max-w-full items-center gap-1 rounded-xl bg-muted/60 p-1`,children:M.map(n=>{let i=e===n.id,a=n.icon;return(0,V.jsxs)(`button`,{onClick:()=>t(n.id),className:r(`relative flex min-w-0 items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,i?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:bg-card/60 hover:text-foreground`),children:[(0,V.jsx)(a,{className:`h-4 w-4 shrink-0`}),n.label,n.id===`installed`&&typeof n.count==`number`&&(0,V.jsx)(`span`,{className:r(`flex h-5 min-w-5 items-center justify-center rounded-full px-1.5 text-[11px] font-semibold`,i?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),children:n.count})]},n.id)})}),(0,V.jsx)(`div`,{className:`w-full max-w-xl`,children:(0,V.jsx)(q,{scope:e===`catalog`?`all`:`installed`,searchText:n,isRefreshing:!1,searchPlaceholder:i(`marketplaceMcpSearchPlaceholder`),sort:c,onSearchTextChange:a,onSortChange:l})})]}),(0,V.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`div`,{className:`mb-3 flex items-center justify-between px-1`,children:(0,V.jsxs)(`h3`,{className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[i(e===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`),(0,V.jsx)(`span`,{className:`flex h-6 items-center justify-center rounded-lg bg-muted px-2 text-xs font-medium text-muted-foreground`,children:e===`catalog`?S.data?.total??0:C.data?.total??0})]})}),(0,V.jsxs)(`div`,{ref:w,className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pb-8`,"aria-busy":S.isLoading||S.isFetchingNextPage,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,280px),1fr))] items-stretch gap-4`,children:[e===`catalog`&&S.isLoading&&(0,V.jsx)(xe,{count:mt}),e===`catalog`&&!S.isLoading&&(S.data?.items??[]).map(e=>{let t=rt(e,O);return(0,V.jsx)(ot,{item:e,record:t,localeFallbacks:x,onOpen:()=>void A(e,t),onInstall:()=>d(e),onToggle:t?()=>void j(t.enabled===!1?`enable`:`disable`,t):void 0,onDoctor:t?()=>{m(t.id??null),g(null),D.mutateAsync(t.id??``)}:void 0,onRemove:t?()=>void j(`remove`,t):void 0},e.id)}),e===`installed`&&k.map(e=>(0,V.jsx)(ot,{record:e,localeFallbacks:x,onOpen:()=>void A(void 0,e),onToggle:()=>void j(e.enabled===!1?`enable`:`disable`,e),onDoctor:()=>{m(e.id??null),g(null),D.mutateAsync(e.id??``)},onRemove:()=>void j(`remove`,e)},e.id??e.spec))]}),e===`catalog`&&S.isError&&(0,V.jsx)(H,{tone:`danger`,title:i(`marketplaceMcpSectionCatalog`),description:S.error.message}),e===`installed`&&C.isError&&(0,V.jsx)(H,{tone:`danger`,title:i(`marketplaceMcpSectionInstalled`),description:C.error.message}),e===`catalog`&&!S.isLoading&&!S.isError&&(S.data?.items?.length??0)===0&&(0,V.jsx)(`div`,{className:`mt-4 flex flex-col items-center justify-center rounded-2xl bg-muted/35 py-16`,children:(0,V.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:i(`marketplaceNoMcp`)})}),e===`installed`&&!C.isError&&k.length===0&&(0,V.jsx)(`div`,{className:`mt-4 flex flex-col items-center justify-center rounded-2xl bg-muted/35 py-16`,children:(0,V.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:i(`marketplaceNoInstalledMcp`)})}),e===`catalog`&&!S.isError&&(0,V.jsx)(Se,{hasMore:!!S.hasNextPage,loading:S.isFetchingNextPage,sentinelRef:re})]})]}),(0,V.jsx)(st,{item:u,open:!!u,pending:T.isPending,onOpenChange:e=>!e&&d(null),onSubmit:ie}),(0,V.jsx)(lt,{open:!!f,targetName:f,result:h,pending:D.isPending,onOpenChange:e=>!e&&m(null)}),(0,V.jsx)(ne,{})]})}export{z as _,Z as a,we as c,xe as d,K as f,H as g,U as h,Me as i,q as l,G as m,tt as n,Ee as o,be as p,$e as r,Ce as s,ht as t,Se as u,R as v};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,a as r}from"./react-8iBFECZE.js";import{t as i}from"./navigation-link-DAfwFCj4.js";import{an as a,cn as o,in as s,ln as c,nn as l,rn as u,un as d}from"./api-iMkU_o5P.js";import{t as f}from"./book-open-nD8gdMhA.js";import{t as p}from"./loader-circle-BlLuRFVW.js";import{t as m}from"./skeleton-B__aTcly.js";import{m as h}from"./doc-browser-context-jiy-O4F8.js";import{M as g,T as _,b as v,d as y,l as b,t as x,x as S}from"./index-CYBXR7zN.js";import{t as C}from"./form-actions-DGf5zUg_.js";import{t as w}from"./config-hints-nV5HPOvq.js";var T=e(n(),1),E=t(),D=`provider/model`;function O(e){let{initialModel:t,initialWorkspace:n,isPending:a,modelHelpText:m,modelPlaceholder:g,onSubmit:_,providerCatalog:v,workspacePlaceholder:y}=e,[b,S]=(0,T.useState)(t),[w,D]=(0,T.useState)(n);return(0,E.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_({model:b,workspace:w})},className:`space-y-5`,children:[(0,E.jsx)(s,{children:(0,E.jsxs)(u,{children:[(0,E.jsx)(l,{title:r(`defaultModel`),description:m,layout:`stacked`,children:(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(o,{htmlFor:`model`,className:`sr-only`,children:r(`defaultModel`)}),(0,E.jsx)(x,{id:`model`,value:b,onChange:S,providerCatalog:v,modelPlaceholder:g}),(0,E.jsx)(i,{href:h(`/guide/model-selection`),external:!0,icon:f,size:`xs`,children:r(`channelsGuideTitle`)})]})}),(0,E.jsx)(l,{title:r(`workspace`),layout:`stacked`,children:(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(o,{htmlFor:`workspace`,className:`sr-only`,children:r(`workspace`)}),(0,E.jsx)(c,{id:`workspace`,value:w,onChange:e=>D(e.target.value),placeholder:y,className:`rounded-xl`})]})})]})}),(0,E.jsx)(C,{children:(0,E.jsx)(d,{type:`submit`,disabled:a,size:`sm`,children:a?(0,E.jsx)(p,{className:`h-3.5 w-3.5 animate-spin`}):r(`saveChanges`)})})]})}function k(){let{data:e,isLoading:t}=b(),{data:n}=S(),{data:i}=v(),{data:o}=y(),s=_(),c=o?.uiHints,l=w(`agents.defaults.model`,c),u=w(`agents.defaults.workspace`,c),d=(0,T.useMemo)(()=>g({providersView:n,templatesView:i,config:e,onlyConfigured:!0}),[e,n,i]),f=r(`modelIdentifierHelp`)||l?.help||``,p=(e?.agents?.defaults?.model||``).trim(),h=e?.agents?.defaults?.workspace||``;return t?(0,E.jsx)(a,{title:r(`modelPageTitle`),description:r(`modelPageDescription`),children:(0,E.jsxs)(`div`,{className:`divide-y divide-border/55 overflow-hidden rounded-2xl bg-muted/45`,children:[(0,E.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,E.jsx)(m,{className:`h-5 w-24`}),(0,E.jsx)(m,{className:`h-10 w-full rounded-xl`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,E.jsx)(m,{className:`h-5 w-24`}),(0,E.jsx)(m,{className:`h-10 w-full rounded-xl`})]})]})}):(0,E.jsx)(a,{title:r(`modelPageTitle`),description:r(`modelPageDescription`),children:(0,E.jsx)(O,{initialModel:p,initialWorkspace:h,isPending:s.isPending,modelHelpText:f,modelPlaceholder:l?.placeholder??D,onSubmit:({model:e,workspace:t})=>s.mutate({model:e,workspace:t}),providerCatalog:d,workspacePlaceholder:u?.placeholder??`/path/to/workspace`},`${p}::${h}`)})}export{k as ModelConfigPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-DxlwKLr-.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,a as t}from"./react-8iBFECZE.js";import{Bt as n,an as r,in as i,nn as a,rn as o}from"./api-iMkU_o5P.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-lNdozU4o.js";import{E as f,l as p,v as m}from"./index-CYBXR7zN.js";var h=e();function g(){let e=p(),g=m(),v=f(),y=e.data?.productAnalytics.enabled??!0,b=e.data?.productAnalytics.audience??`external`,x=e=>{v.mutate({data:{enabled:e}})},S=e=>{let t=e;v.mutate({data:{audience:t}})};return(0,h.jsxs)(r,{title:t(`privacyPageTitle`),description:t(`privacyPageDescription`),children:[(0,h.jsx)(i,{title:t(`productAnalyticsSectionTitle`),description:t(`productAnalyticsSectionDescription`),children:(0,h.jsxs)(o,{children:[(0,h.jsx)(a,{title:t(`productAnalyticsEnabledTitle`),description:t(`productAnalyticsEnabledDescription`),control:(0,h.jsx)(n,{"aria-label":t(`productAnalyticsEnabledTitle`),checked:y,disabled:e.isLoading||v.isPending,onCheckedChange:x})}),(0,h.jsx)(a,{title:t(`productAnalyticsAudienceTitle`),description:t(`productAnalyticsAudienceDescription`),control:(0,h.jsxs)(d,{value:b,onValueChange:S,disabled:e.isLoading||v.isPending,children:[(0,h.jsx)(c,{"aria-label":t(`productAnalyticsAudienceTitle`),className:`w-40 sm:w-48`,children:(0,h.jsx)(s,{})}),(0,h.jsxs)(l,{children:[(0,h.jsx)(u,{value:`external`,children:t(`productAnalyticsAudienceExternal`)}),(0,h.jsx)(u,{value:`internal`,children:t(`productAnalyticsAudienceInternal`)}),(0,h.jsx)(u,{value:`qa`,children:t(`productAnalyticsAudienceQa`)})]})]})})]})}),(0,h.jsx)(i,{title:t(`productAnalyticsDataTitle`),children:(0,h.jsxs)(o,{children:[(0,h.jsx)(a,{layout:`stacked`,title:t(`productAnalyticsCollectedTitle`),description:t(`productAnalyticsCollectedDescription`)}),(0,h.jsx)(a,{layout:`stacked`,title:t(`productAnalyticsExcludedTitle`),description:t(`productAnalyticsExcludedDescription`)}),(0,h.jsx)(a,{layout:`stacked`,title:t(`productAnalyticsAnonymousTitle`),description:t(`productAnalyticsAnonymousDescription`)})]})}),(0,h.jsx)(i,{title:t(`productAnalyticsStatusSectionTitle`),children:(0,h.jsxs)(o,{children:[(0,h.jsx)(a,{layout:`stacked`,title:t(`productAnalyticsStatusTitle`),description:_(g.data,g.isLoading)}),g.data?.lastError?(0,h.jsx)(a,{layout:`stacked`,title:t(`productAnalyticsLastErrorTitle`),description:g.data.lastError}):null]})})]})}function _(e,n){if(n)return t(`productAnalyticsStatusLoading`);if(!e?.lastAttemptAt)return t(`productAnalyticsStatusNever`);let r=new Date(e.lastAttemptAt).toLocaleString();if(!e.lastSuccessAt)return`${t(`productAnalyticsLastAttemptLabel`)} ${r} · ${e.pendingReceiptCount} ${t(`productAnalyticsPendingLabel`)}`;let i=new Date(e.lastSuccessAt).toLocaleString();return`${t(`productAnalyticsLastSuccessLabel`)} ${i} · ${e.pendingReceiptCount} ${t(`productAnalyticsPendingLabel`)}`}export{g as PrivacySettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{B as t,H as n,L as r,a as i,s as a}from"./react-8iBFECZE.js";import{Bt as o,On as s,an as c,cn as l,hn as u,ln as d,tn as f,un as p}from"./api-iMkU_o5P.js";import{C as m,a as h,i as g,n as _,r as v,t as y}from"./select-lNdozU4o.js";import{c as b,l as x,t as S}from"./confirm-dialog-k2-Jq_x3.js";import{t as C}from"./createLucideIcon-DxlwKLr-.js";import{t as w}from"./search-Vih1R2BD.js";import{t as T}from"./loader-circle-BlLuRFVW.js";import{t as E}from"./plus-D4LtWtTk.js";import{t as D}from"./refresh-cw-D_Eibznw.js";import{t as O}from"./x-CWdWBu_U.js";import{t as k}from"./host-capabilities-Tk038i04.js";import{C as A,D as j,F as M,G as N,H as P,I as F,K as I,N as L,P as R,S as ee,St as te,W as z,_ as B,_t as V,b as H,bt as U,c as ne,d as W,f as re,g as ie,j as ae,lt as G,m as oe,p as se,pt as K,ut as q,x as ce,xt as le,y as ue}from"./index-CYBXR7zN.js";import{t as de}from"./form-actions-DGf5zUg_.js";import{t as J}from"./config-hints-nV5HPOvq.js";import{a as fe,c as pe,i as me,l as he,n as ge,o as _e,r as ve,s as ye}from"./config-split-page-BtJZp1E5.js";var be=C(`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=C(`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`}]]),Y=e(n(),1),Se={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(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 Ce(e,t){let n=X(e),r=X(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 Z(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 we(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 Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=we(n,t))}return n.trim()}function Te(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Ee(e,t){return Z(t)}function De(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Oe(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=M(i.thinking?.supported);if(a.length>0){let t=F(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 ke(e,t,n){return{...R(e,n),...R(t,n)}}function Ae(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||!Te([...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 je(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Ce(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!Te(e.models,e.currentEditableModels)||!Ae(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Me(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(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),Ce(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),Te(e.models,e.currentEditableModels)||(t.models=De(e.models,e.providerName??``)),Ae(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Oe(e.modelConfig,e.models)),t}function Ne(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Pe(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Pe(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Fe(e){return i(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ie(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 Le(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Re(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function ze(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function Be(e,t,n){return ze(e,t,n).models.slice(e.length)}function Ve(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function He(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):ae.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 Ue(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 We(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 Ge(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:Ie({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:Le({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Ke(e,t){let n=!!e?.supportsWireApi||t,r=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:i(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:Le({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:r.length}),supportsWireApi:n,wireApiSelectOptions:r}}function qe(e){let{providerName:t,providersView:n,templatesView:r,schema:a,language:o}=e,s=t?n?.providers[t]:null,c=r?.providerTemplates.find(e=>e.providerType===s?.providerType),l=s??Se,u=a?.uiHints,d=!!s?.isCustom,f=t?J(`providers.${t}.apiKey`,u):void 0,p=t?J(`providers.${t}.apiBase`,u):void 0,m=t?J(`providers.${t}.extraHeaders`,u):void 0,h=t?J(`providers.${t}.wireApi`,u):void 0,g=c?.displayName||s?.displayName||t||``,_=(l.displayName||``).trim()||g,v=l.enabled!==!1,y=d||c?.supportsModelDiscovery===!0,b=Z([c?.modelPrefix||c?.providerType||``,t||``]),x=c?.defaultApiBase||``,S=l.apiBase||x,C=X(l.extraHeaders||null),w=l.wireApi||c?.defaultWireApi||`auto`,T=Ee(Z((c?.defaultModels??[]).map(e=>Q(e,b))),Z((l.models??[]).map(e=>Q(e,b)))),E=Oe(ke(c?.modelConfig,l.modelConfig,b),T),D=c?.apiBaseHelp?.[o]||c?.apiBaseHelp?.en||p?.help||i(`providerApiBaseHelp`),O=Ge({providerName:t,providerSpec:c,language:o}),k=Ke(c,d);return{apiBaseHelpText:D,apiBaseHint:p,apiKeyHint:f,currentApiBase:S,currentEditableModels:T,currentEnabled:v,currentHeaders:C,currentModelConfig:E,currentWireApi:w,defaultApiBase:x,defaultDisplayName:g,effectiveDisplayName:_,extraHeadersHint:m,...O,providerConfig:s,providerModelAliases:b,resolvedProviderConfig:l,supportsModelDiscovery:y,wireApiHint:h,...k}}function Je(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:r}=e,a=s(),o=ee(),c=B(),l=ie(),[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 r=await c.mutateAsync({provider:t,data:{sessionId:e}});if(r.status===`pending`){g(i(`providerAuthWaitingBrowser`)),y(e,r.nextPollMs??n);return}if(r.status===`authorized`){m(null),v(),g(i(`providerAuthCompleted`)),u.success(i(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}m(null),v(),g(r.message||`Authorization ${r.status}.`),u.error(r.message||`Authorization ${r.status}.`)}catch(e){m(null),v();let t=e instanceof Error?e.message:String(e);g(t),u.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 o.mutateAsync({provider:t,data:r?{methodId:r}:{}});if(!e.sessionId||!e.verificationUri)throw Error(i(`providerAuthStartFailed`));m(e.sessionId),g(`${i(`providerAuthOpenPrompt`)}${e.userCode}${i(`providerAuthOpenPromptSuffix`)}`),await k.openExternalUrl(e.verificationUri),y(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);m(null),v(),g(t),u.error(`${i(`providerAuthStartFailed`)}: ${t}`)}},[v,n?.kind,t,r,y,o]),x=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{f(t),v(),m(null);let e=await l.mutateAsync({provider:t});g(`${i(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),u.success(i(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);g(t),u.error(`${i(`providerAuthImportFailed`)}: ${t}`)}},[v,l,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:l.isPending,startAuth:b,startPending:o.isPending}}function Ye(e){let{providerName:t,apiKey:n,apiKeyRequired:r,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:c,wireApi:l,models:d,providerModelAliases:p}=e,m=A(),h=oe(),g=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[_,v]=(0,Y.useState)(null),y=(0,Y.useCallback)(async()=>{if(t)try{let e=await m.mutateAsync({provider:t,data:Ne({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:c,wireApi:l,models:d,providerModelAliases:p})});if(e.success){u.success(`${i(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let r=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&r.push(`model=${e.model}`),u.error(`${i(`providerTestConnectionFailed`)}: ${e.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);u.error(`${i(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,d,p,t,c,m,l]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(r&&!n.trim()&&!a)return u.error(i(`providerModelsApiKeyRequired`)),null;try{let e=await h.mutateAsync({provider:t,data:Pe({apiKey:n,apiBase:o,extraHeaders:s})});return v({key:g,models:e.models}),u.success(i(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof f&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return u.error(i(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return u.error(`${i(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,r,a,h,g,s,t]),fetchedModels:_?.key===g?_.models:[],isDiscoveringModels:h.isPending,isTestPending:m.isPending,testConnection:y}}var $=t();function Xe({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,"":``})},c=e=>{let n=a.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,$.jsxs)(`div`,{className:r(`space-y-2`,n),children:[a.map(([e,t],n)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(d,{type:`text`,value:e,onChange:e=>o(n,e.target.value,t),placeholder:i(`headerName`),className:`flex-1`}),(0,$.jsx)(d,{type:`text`,value:t,onChange:t=>o(n,e,t.target.value),placeholder:i(`headerValue`),className:`flex-1`}),(0,$.jsx)(p,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>c(n),children:(0,$.jsx)(q,{className:`h-4 w-4 text-red-500`})})]},n)),(0,$.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),i(`add`)]})]})}function Ze(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.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-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:e.label},e.value)})})}function Qe(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:r,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:u,extraHeadersLabel:d,extraHeaders:f,onExtraHeadersChange:p}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.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,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(K,{className:`h-3.5 w-3.5`}),i(`providerAdvancedSettings`)]}),(0,$.jsx)(m,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[r?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)(Ze,{value:o,onChange:e=>s(e),options:u}):(0,$.jsxs)(y,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(g,{className:`rounded-xl`,children:(0,$.jsx)(h,{})}),(0,$.jsx)(_,{children:u.map(e=>(0,$.jsx)(v,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{className:`text-sm font-medium text-foreground`,children:d}),(0,$.jsx)(Xe,{value:f,onChange:p}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerExtraHeadersHelpShort`)})]})]}):null]})}function $e({isSet:e,className:t,value:n,onChange:i,placeholder:a,...o}){let[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!l?(0,$.jsx)(`div`,{onClick:()=>u(!0),className:r(`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,$.jsx)(d,{type:s?`text`:`password`,className:r(`pr-12`,t),value:n,onChange:i,onBlur:()=>{f||u(!1)},placeholder:a,autoFocus:l,...o}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,$.jsx)(p,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>c(!s),children:s?(0,$.jsx)(xe,{className:`h-4 w-4`}):(0,$.jsx)(U,{className:`h-4 w-4`})})})]})}function et(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:r,apiKeyPlaceholder:a,providerAuth:o,providerAuthNote:s,providerAuthMethodOptions:c,providerAuthMethodsCount:u,selectedAuthMethodHint:d,shouldUseAuthMethodPills:f,resolvedAuthMethodId:m,onAuthMethodChange:b,onStartProviderAuth:x,onImportProviderAuthFromCli:S,startPending:C,importPending:w,authSessionId:T,authStatusMessage:E,onApiKeyChange:D}=e,O=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:i(`apiKey`)}),(0,$.jsx)($e,{id:`apiKey`,value:t,isSet:r,onChange:e=>D(e.target.value),placeholder:a,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`leaveBlankToKeepUnchanged`)})]}):null;return o?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[O,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(l,{className:`text-sm font-medium text-foreground`,children:o.displayName||i(`providerAuthSectionTitle`)}),s?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}):null,u>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{className:`text-xs font-medium text-foreground`,children:i(`providerAuthMethodLabel`)}),f?(0,$.jsx)(Ze,{value:m,onChange:b,options:c}):(0,$.jsxs)(y,{value:m,onValueChange:b,children:[(0,$.jsx)(g,{className:`h-8 rounded-lg`,children:(0,$.jsx)(h,{placeholder:i(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(_,{children:c.map(e=>(0,$.jsx)(v,{value:e.value,children:e.label},e.value))})]}),d?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:x,disabled:C||!!T,children:i(C?`providerAuthStarting`:T?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),o.supportsCliImport?(0,$.jsx)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:S,disabled:w,children:i(w?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,T?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i(`providerAuthSessionLabel`),`: `,T.slice(0,8),`…`]}):null]}),E?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E}):null]})]}):O}function tt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=ue({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>Be(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=ze(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function nt(e){let{models:t,modelConfig:n,onModelsChange:r,onRemoveModel:a,onToggleModelThinkingLevel:s,onSetModelThinkingDefault:c,onSetModelVision:u,thinkingLevels:d,formatThinkingLevelLabel:f}=e,[p,m]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(()=>new Set),S=(0,Y.useMemo)(()=>t.filter(e=>b.has(e)),[t,b]),C=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},w=()=>{m(!1),x(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:i(`providerModelsSuggestionsSelected`).replace(`{count}`,String(S.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>x(S.length===t.length?new Set:new Set(t)),children:i(S.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:w,children:i(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:S.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{S.length!==0&&(r(t.filter(e=>!b.has(e))),w())},children:[(0,$.jsx)(q,{className:`h-3 w-3`}),i(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>m(!0),children:[(0,$.jsx)(q,{className:`h-3 w-3`}),i(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(p)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:b.has(e),onChange:()=>C(e),"aria-label":i(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=n[e],r=t?.thinking,m=r?.supported??[],x=r?.default??null,S=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(z,{children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.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-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`providerModelThinkingTitle`),title:i(`providerModelThinkingTitle`),children:(0,$.jsx)(K,{className:`h-3 w-3`})})}),(0,$.jsxs)(N,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:i(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelVisionHint`)})]}),(0,$.jsx)(o,{checked:S,onCheckedChange:t=>u(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:i(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${m.includes(t)?`border-foreground/15 bg-foreground text-background`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-muted hover:text-foreground`}`,children:f(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(l,{className:`text-xs font-medium text-foreground`,children:i(`providerModelThinkingDefault`)}),(0,$.jsxs)(y,{value:x??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:m.length===0,children:[(0,$.jsx)(g,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(h,{})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(v,{value:`__none__`,children:i(`providerModelThinkingDefaultNone`)}),m.map(e=>(0,$.jsx)(v,{value:e,children:f(e)},e))]})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-muted hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":i(`remove`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})]},e)})}),p?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerModelsRemoveSaveHint`)}):null]})}var rt=20,it=50,at=50;function ot(e){let{expanded:t,fetchedTotal:n,models:r,source:a,onExpandedChange:o,onAddModels:s}=e,[c,l]=(0,Y.useState)(``),[u,f]=(0,Y.useState)(()=>new Set),p=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?r.filter(t=>t.toLowerCase().includes(e)):r},[r,c]),m=p.slice(0,at),h=(0,Y.useMemo)(()=>r.filter(e=>u.has(e)),[r,u]),g=e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{e.length!==0&&(s(e),l(``),f(new Set))},v=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&r.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:i(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(n))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":t,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground`,onClick:()=>o(!t),children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i(v).replace(`{count}`,String(r.length))}),(0,$.jsx)(te,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${t?`rotate-90`:``}`})]}),r.length<=it?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-primary/10`,onClick:()=>_(r),children:i(`providerModelsSuggestionsAddAll`)}):null]}),t?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[r.length>rt?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(d,{value:c,onChange:e=>l(e.target.value),placeholder:i(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto overscroll-contain`,children:[m.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-muted/70`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>g(e),"aria-label":i(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),p.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:i(`providerModelsSuggestionsSearchEmpty`)}):null]}),p.length>m.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(m.length)).replace(`{count}`,String(p.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsSelected`).replace(`{count}`,String(h.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:h.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-primary/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>_(h),children:i(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:i(`providerModelsSuggestionsSaveHint`)})]}):null]})}function st({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(x,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),i(`providerModelsSuggestionsFailed`)]})}function ct(e){let{providerName:t,providerModelAliases:n,models:r,modelConfig:a,modelDraft:o,showModelInput:s,onModelDraftChange:c,onShowModelInputChange:u,onAddModel:f,onModelsChange:m,supportsModelDiscovery:h,onDiscoverModels:g,isDiscoveringModels:_,fetchedModels:v,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w}=e,[k,A]=(0,Y.useState)(!1),j=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=tt({providerName:t,models:r,aliases:n,fetchedModels:v,onModelsChange:m}),L=async()=>{await g()&&(A(!0),window.requestAnimationFrame(()=>{let e=j.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=v.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(l,{className:`text-sm font-medium text-foreground`,children:i(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[h?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:_,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${_?`animate-spin`:``}`}),i(_?`providerModelsFetching`:`providerModelsFetch`)]}):null,s?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),i(`providerAddModel`)]})]})]}),s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(d,{value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(u(!1),c(``))},placeholder:i(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(p,{type:`button`,size:`sm`,onClick:f,disabled:o.trim().length===0,children:i(`add`)}),(0,$.jsx)(p,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{u(!1),c(``)},children:(0,$.jsx)(O,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(st,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:h}),h&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}),i(`providerModelsSuggestionsChecking`)]}):h&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:j,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ot,{expanded:k,fetchedTotal:v.length,models:F,source:I,onExpandedChange:A,onAddModels:M})}):null,r.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`providerModelsEmptyShort`)}),s?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:i(`providerAddFirstModel`)})]}):(0,$.jsx)(nt,{models:r,modelConfig:a,onModelsChange:m,onRemoveModel:y,onToggleModelThinkingLevel:b,onSetModelThinkingDefault:x,onSetModelVision:S,thinkingLevels:C,formatThinkingLevelLabel:w})]})}function lt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:r}){if(!r)return(0,$.jsx)(G,{status:`inactive`,label:i(`disabled`),className:n});let a=!e||t;return(0,$.jsx)(G,{status:a?`ready`:`setup`,label:i(a?`statusReady`:`statusSetup`),className:n})}function ut(e){let{context:t,language:n,providerTitle:r,providerDisplayName:a,apiKey:o,apiBase:s,extraHeaders:c,wireApi:u,models:f,modelConfig:m,modelDraft:h,showAdvanced:g,showModelInput:_,resolvedAuthMethodId:v,authSessionId:y,authStatusMessage:b,hasChanges:x,isDeletePending:S,isUpdatePending:C,connectivity:w,startPending:T,importPending:E,onProviderDisplayNameChange:D,onApiKeyChange:O,onApiBaseChange:k,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:F,onModelsChange:I,onRemoveModel:L,onToggleModelThinkingLevel:R,onSetModelThinkingDefault:ee,onSetModelVision:te,onShowAdvancedChange:z,onWireApiChange:B,onExtraHeadersChange:V,onDeleteProvider:H,onSubmit:U,onTestConnection:ne}=e,W=t.providerAuthMethods.find(e=>e.id===v);return(0,$.jsxs)(ge,{children:[(0,$.jsx)(pe,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:r}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:H,disabled:S,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:i(`providerDelete`),children:(0,$.jsx)(q,{className:`h-4 w-4`})}),(0,$.jsx)(lt,{enabled:t.currentEnabled,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired,apiKeySet:t.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:U,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(_e,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:i(`providerDisplayName`)}),(0,$.jsx)(d,{id:`providerDisplayName`,type:`text`,value:a,onChange:e=>D(e.target.value),placeholder:t.defaultDisplayName||i(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(et,{apiKey:o,apiKeyRequired:t.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:t.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:t.apiKeyHint?.placeholder??i(`enterApiKey`),providerAuth:t.providerAuth,providerAuthNote:t.providerAuth?.note?.[n]||t.providerAuth?.note?.en||t.providerAuth?.displayName||``,providerAuthMethodOptions:t.providerAuthMethodOptions,providerAuthMethodsCount:t.providerAuthMethods.length,selectedAuthMethodHint:W?.hint?.[n]||W?.hint?.en||``,shouldUseAuthMethodPills:t.shouldUseAuthMethodPills,resolvedAuthMethodId:v,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,startPending:T,importPending:E,authSessionId:y,authStatusMessage:b,onApiKeyChange:O}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(l,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:i(`apiBase`)}),(0,$.jsx)(d,{id:`apiBase`,type:`text`,value:s,onChange:e=>k(e.target.value),placeholder:t.defaultApiBase||t.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.apiBaseHelpText})]}),(0,$.jsx)(ct,{providerName:t.providerConfig?.providerId??``,providerModelAliases:t.providerModelAliases,models:f,modelConfig:m,modelDraft:h,showModelInput:_,onModelDraftChange:N,onShowModelInputChange:P,onAddModel:F,onModelsChange:I,supportsModelDiscovery:t.supportsModelDiscovery,onDiscoverModels:w.discoverModels,isDiscoveringModels:w.isDiscoveringModels,fetchedModels:w.fetchedModels,onRemoveModel:L,onToggleModelThinkingLevel:R,onSetModelThinkingDefault:ee,onSetModelVision:te,thinkingLevels:ae,formatThinkingLevelLabel:Fe},t.providerConfig?.providerId),(0,$.jsx)(Qe,{showAdvanced:g,onShowAdvancedChange:z,supportsWireApi:t.supportsWireApi,wireApiLabel:i(`wireApi`),wireApi:u,onWireApiChange:B,shouldUseWireApiPills:t.shouldUseWireApiPills,wireApiSelectOptions:t.wireApiSelectOptions,extraHeadersLabel:i(`extraHeaders`),extraHeaders:c,onExtraHeadersChange:V})]}),(0,$.jsx)(ye,{children:(0,$.jsxs)(de,{align:`between`,children:[(0,$.jsxs)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:ne,disabled:w.isTestPending,children:[(0,$.jsx)(be,{className:`mr-1.5 h-3.5 w-3.5`}),w.isTestPending?i(`providerTestingConnection`):i(`providerTestConnection`)]}),(0,$.jsx)(p,{type:`submit`,size:`sm`,disabled:C||!x,children:i(C?`saving`:x?`save`:`unchanged`)})]})})]})]})}function dt({providerName:e,onProviderDeleted:t}){let{data:n}=ce(),{data:r}=H(),{data:o}=W(),s=a(),c=(0,Y.useMemo)(()=>qe({providerName:e,providersView:n,templatesView:r,schema:o,language:s}),[s,e,n,o,r]);if(!e||!c.providerConfig)return(0,$.jsx)(ve,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:i(`providersSelectDescription`)})]})});let l=JSON.stringify({providerConfig:c.providerConfig,currentApiBase:c.currentApiBase,currentEditableModels:c.currentEditableModels,currentModelConfig:c.currentModelConfig,currentWireApi:c.currentWireApi,effectiveDisplayName:c.effectiveDisplayName,preferredAuthMethodId:c.preferredAuthMethodId});return(0,$.jsx)(ft,{providerName:e,onProviderDeleted:t,context:c,language:s},l)}function ft({providerName:e,onProviderDeleted:t,context:n,language:r}){let a=j(),o=se(),{currentApiBase:s,currentEditableModels:c,currentHeaders:l,currentModelConfig:u,currentWireApi:d,defaultApiBase:f,effectiveDisplayName:p,providerAuth:m,providerAuthMethods:h,providerModelAliases:g,resolvedProviderConfig:_,preferredAuthMethodId:v,supportsWireApi:y}=n,[b,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(s),[w,T]=(0,Y.useState)(_.extraHeaders||null),[E,D]=(0,Y.useState)(d),[O,k]=(0,Y.useState)(c),[A,M]=(0,Y.useState)(u),[N,P]=(0,Y.useState)(``),[F,I]=(0,Y.useState)(p),[L,R]=(0,Y.useState)(!1),[ee,te]=(0,Y.useState)(!1),[z,B]=(0,Y.useState)(v),V=Ye({providerName:e,apiKey:b,apiKeyRequired:_.apiKeyRequired!==!1,apiKeySet:_.apiKeySet,apiBase:S,extraHeaders:w,supportsWireApi:y,wireApi:E,models:O,providerModelAliases:g}),H=F.trim()||p||e||i(`providersSelectPlaceholder`),U=(0,Y.useMemo)(()=>{if(!h.length)return``;let e=z.trim();return e&&h.some(t=>t.id===e)?e:v||h[0]?.id||``},[z,v,h]),{authSessionId:ne,authStatusMessage:W,importAuthFromCli:re,importPending:ie,startAuth:ae,startPending:G}=Je({providerName:e,providerAuth:m,resolvedAuthMethodId:U}),oe=(0,Y.useMemo)(()=>je({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:F,effectiveDisplayName:p}),[e,b,S,s,w,l,y,E,d,O,c,A,u,F,p]),K=e=>{k(e),M(t=>Oe(t,e))};return(0,$.jsx)(ut,{context:n,language:r,providerTitle:H,providerDisplayName:F,apiKey:b,apiBase:S,extraHeaders:w,wireApi:E,models:O,modelConfig:A,modelDraft:N,showAdvanced:L,showModelInput:ee,resolvedAuthMethodId:U,authSessionId:ne,authStatusMessage:W,hasChanges:oe,isDeletePending:o.isPending,isUpdatePending:a.isPending,connectivity:V,startPending:G,importPending:ie,onProviderDisplayNameChange:I,onApiKeyChange:x,onApiBaseChange:C,onAuthMethodChange:B,onStartProviderAuth:ae,onImportProviderAuthFromCli:re,onModelDraftChange:P,onShowModelInputChange:te,onAddModel:()=>{let e=Re(O,N,g);K(e.models),P(e.draft)},onModelsChange:K,onRemoveModel:e=>{let t=Ve(O,A,e);k(t.models),M(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{M(n=>He(n,e,t))},onSetModelThinkingDefault:(e,t)=>{M(n=>Ue(n,e,t))},onSetModelVision:(e,t)=>{M(n=>We(n,e,t))},onShowAdvancedChange:R,onWireApiChange:D,onExtraHeadersChange:T,onDeleteProvider:async()=>{if(e&&window.confirm(i(`providerDeleteConfirm`)))try{await o.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&a.mutate({provider:e,data:Me({providerName:e,apiKey:b,apiBase:S,currentApiBase:s,defaultApiBase:f,extraHeaders:w,currentHeaders:l,supportsWireApi:y,wireApi:E,currentWireApi:d,models:O,currentEditableModels:c,modelConfig:A,currentModelConfig:u,providerDisplayName:F,effectiveDisplayName:p})})},onTestConnection:V.testConnection})}function pt(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 mt(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 ht(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 gt(){let{isMobile:e}=ne(),{data:t}=ce(),{data:n}=H(),a=re(),s=se(),l=j(),[u,f]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)([]),[b,x]=(0,Y.useState)(``),C=(0,Y.useMemo)(()=>mt(Object.values(t?.providers??{}),v),[t?.providers,v]),T=(0,Y.useMemo)(()=>n?.providerTemplates??[],[n?.providerTemplates]),D=(0,Y.useMemo)(()=>ht(T),[T]),O=(0,Y.useMemo)(()=>new Map(T.map(e=>[e.providerType,e])),[T]),k=(0,Y.useMemo)(()=>{let e=b.trim().toLowerCase();return C.filter(t=>{if(!e)return!0;let n=t.providerType?O.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[C,b,O]),A=(0,Y.useMemo)(()=>u&&k.some(e=>e.providerId===u)?u:e?null:k[0]?.providerId??null,[k,e,u]);return!t||!n?(0,$.jsx)(c,{title:i(`providersPageTitle`),description:i(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:i(`providersLoading`)})}):(0,$.jsxs)(c,{title:i(`providersPageTitle`),description:i(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(fe,{className:`md:min-h-0`,compactView:u?`detail`:`list`,onMobileBack:()=>f(null),mobileListLabel:i(`providersPageTitle`),children:[(0,$.jsxs)(he,{children:[(0,$.jsx)(pe,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(z,{open:g,onOpenChange:_,children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.jsxs)(p,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),a.isPending?i(`saving`):i(`providerAdd`)]})}),(0,$.jsxs)(N,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:i(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-muted/45`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});x(``),f(e.providerId),y(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(P,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:i(`providerAddCustom`)})]}),D.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-muted/40`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});x(``),f(t.providerId),y(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),_(!1)}catch{}},children:[(0,$.jsx)(P,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.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,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(w,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(d,{value:b,onChange:e=>x(e.target.value),placeholder:i(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(_e,{className:`space-y-2 p-3`,children:[k.map(e=>{let t=e.providerType?O.get(e.providerType):null,n=e.enabled!==!1,a=L(e),s=e.displayName?.trim()||t?.displayName||e.providerId,c=pt(e.apiBase||t?.defaultApiBase||``)||i(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>f(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e.providerId))},role:`button`,tabIndex:0,className:r(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,A===e.providerId?`bg-background/95 text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-background/65 hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(P,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:s}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[c,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(o,{checked:n,disabled:l.isPending,title:i(n?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{l.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(z,{children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),title:i(`more`),children:(0,$.jsx)(le,{className:`h-4 w-4`})})}),(0,$.jsx)(N,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.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:()=>h(e.providerId),children:[(0,$.jsx)(q,{className:`h-4 w-4`}),i(`providerDelete`)]})})]})]}),(0,$.jsx)(G,{status:n?a?`ready`:`setup`:`inactive`,label:i(n?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),k.length===0?(0,$.jsx)(me,{icon:V,title:i(`providersNoMatch`)}):null]})]}),(0,$.jsx)(dt,{providerName:A??void 0,onProviderDeleted:e=>{y(t=>t.filter(t=>t!==e)),e===A&&f(null)}})]}),(0,$.jsx)(S,{open:!!m,onOpenChange:e=>{e||h(null)},title:i(`providerDelete`),description:m??void 0,confirmLabel:i(`delete`),variant:`destructive`,onCancel:()=>h(null),onConfirm:()=>{m&&s.mutateAsync({provider:m}).then(()=>{y(e=>e.filter(e=>e!==m)),m===A&&f(null),h(null)})}})]})}export{gt as ProvidersConfigPage};
|