@nextclaw/ui 0.11.1 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/assets/{ChannelsList-CVPqrxns.js → ChannelsList-CKl1Zg8f.js} +4 -4
  3. package/dist/assets/{ChatPage-BO1VUrAY.js → ChatPage-BJgO27mk.js} +25 -25
  4. package/dist/assets/{DocBrowser-FBwg8iji.js → DocBrowser-DYRBs4-z.js} +1 -1
  5. package/dist/assets/{LogoBadge-BCmJfRT8.js → LogoBadge-33Qlv3Hg.js} +1 -1
  6. package/dist/assets/{MarketplacePage-DWxXUOCx.js → MarketplacePage-B8BZVtjV.js} +2 -2
  7. package/dist/assets/{McpMarketplacePage-Bth9X_hu.js → McpMarketplacePage-BRuE5fJJ.js} +1 -1
  8. package/dist/assets/{ModelConfig-PkSp_ioc.js → ModelConfig-BiFblwO-.js} +1 -1
  9. package/dist/assets/{ProvidersList-DVDge8wa.js → ProvidersList-9goRgHE4.js} +1 -1
  10. package/dist/assets/{RemoteAccessPage-BVkzfEaL.js → RemoteAccessPage-5vCxZPS6.js} +1 -1
  11. package/dist/assets/{RuntimeConfig-ByJs3khh.js → RuntimeConfig-BmDFHBdW.js} +1 -1
  12. package/dist/assets/{SearchConfig-KZUAqYJN.js → SearchConfig-CJx5CKwG.js} +1 -1
  13. package/dist/assets/{SecretsConfig-qwB_Y_Ka.js → SecretsConfig-B91efXoK.js} +2 -2
  14. package/dist/assets/{SessionsConfig-CGCl4UTr.js → SessionsConfig-CbFPVmx3.js} +2 -2
  15. package/dist/assets/index-BtAuUyww.css +1 -0
  16. package/dist/assets/index-COJomMe9.js +8 -0
  17. package/dist/assets/{label-7JEFhkur.js → label-BnSDpjhL.js} +1 -1
  18. package/dist/assets/{ncp-session-adapter-BOqhkrc-.js → ncp-session-adapter-w8ZHprab.js} +1 -1
  19. package/dist/assets/{page-layout-B7q511TE.js → page-layout-B1RIu5-r.js} +1 -1
  20. package/dist/assets/{popover-CywJGmPr.js → popover-ChzbCIfO.js} +1 -1
  21. package/dist/assets/{security-config-zi2UxN5r.js → security-config-eYa6Ovfa.js} +1 -1
  22. package/dist/assets/skeleton-D4Eyop0R.js +1 -0
  23. package/dist/assets/{status-dot-BilwNdTT.js → status-dot-CrCw5tkJ.js} +1 -1
  24. package/dist/assets/{switch-BLp2Pno1.js → switch-C3vVTpfU.js} +1 -1
  25. package/dist/assets/{tabs-custom-CgIdQMGC.js → tabs-custom-Ilrgt6n1.js} +1 -1
  26. package/dist/assets/{useConfirmDialog-BitswAkv.js → useConfirmDialog-BeaFLDO8.js} +1 -1
  27. package/dist/assets/{vendor-D_JxmsLV.js → vendor-waGu-koL.js} +84 -69
  28. package/dist/index.html +3 -3
  29. package/package.json +4 -4
  30. package/src/components/chat/adapters/chat-message.adapter.test.ts +71 -4
  31. package/src/components/chat/adapters/chat-message.adapter.ts +195 -78
  32. package/src/components/chat/containers/chat-message-list.container.tsx +7 -0
  33. package/src/lib/i18n.chat.ts +7 -0
  34. package/dist/assets/index-CrilScMo.css +0 -1
  35. package/dist/assets/index-D41ntvb7.js +0 -8
  36. package/dist/assets/skeleton-qUJZQ03S.js +0 -1
@@ -1 +1 @@
1
- import{r as s,j as t,a3 as oe,ba as ae,bb as ne,X as W,au as ie,$ as le,bc as ce,G as de,ai as ue,bd as me}from"./vendor-D_JxmsLV.js";import{k as we,D as Y,t as i,c as X,ak as xe}from"./index-D41ntvb7.js";function pe(){const{isOpen:T,mode:g,tabs:F,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:$,toggleMode:A,goBack:I,goForward:O,canGoBack:G,canGoForward:_,navigate:y,syncUrl:S,setActiveTab:V,closeTab:H,openNewTab:q}=we(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,h]=s.useState(!1),[d,D]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[n,B]=s.useState({w:480,h:600}),[L,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),P=s.useRef(p),a=(x==null?void 0:x.kind)==="docs";s.useEffect(()=>{if(!a){j("");return}try{const e=new URL(l);j(e.pathname)}catch{j(l)}},[l,N,a]),s.useEffect(()=>{var e;if(a){if(p!==P.current){P.current=p;return}if((e=z.current)!=null&&e.contentWindow)try{const r=new URL(l).pathname;z.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}}},[l,p,a]),s.useEffect(()=>{g==="floating"&&D(e=>({x:Math.max(40,window.innerWidth-n.w-40),y:e.y}))},[g,n.w]),s.useEffect(()=>{const e=r=>{var o;a&&((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&S(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[S,a]);const Q=s.useCallback(e=>{if(e.preventDefault(),!a)return;const r=k.trim();r&&(r.startsWith("/")?y(`${Y}${r}`):r.startsWith("http")?y(r):y(`${Y}/${r}`))},[k,y,a]),Z=s.useCallback(e=>{g==="floating"&&(C(!0),u.current={startX:e.clientX,startY:e.clientY,startPosX:d.x,startPosY:d.y})},[g,d]);s.useEffect(()=>{if(!E)return;const e=o=>{u.current&&D({x:u.current.startPosX+(o.clientX-u.current.startX),y:u.current.startPosY+(o.clientY-u.current.startY)})},r=()=>{C(!1),u.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[E]);const M=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.currentTarget.dataset.axis;m.current={startX:e.clientX,startY:e.clientY,startW:n.w,startH:n.h};const o=w=>{m.current&&B(v=>({w:r==="y"?v.w:Math.max(360,m.current.startW+(w.clientX-m.current.startX)),h:r==="x"?v.h:Math.max(400,m.current.startH+(w.clientY-m.current.startY))}))},f=()=>{h(!1),m.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",f)},[n]),ee=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0),b.current={startX:e.clientX,startW:L};const r=f=>{if(!b.current)return;const w=b.current.startX-f.clientX;K(Math.max(320,Math.min(860,b.current.startW+w)))},o=()=>{h(!1),b.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[L]),te=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.clientX,o=n.w,f=d.x,w=re=>{const se=r-re.clientX,U=Math.max(360,o+se);B(R=>({...R,w:U})),D(R=>({...R,x:f-(U-o)}))},v=()=>{h(!1),window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",v)};window.addEventListener("mousemove",w),window.addEventListener("mouseup",v)},[n.w,d.x]);if(!T)return null;const c=g==="docked";return t.jsxs("div",{className:X("flex flex-col bg-white overflow-hidden relative",c?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:c?{width:L}:{position:"fixed",left:d.x,top:d.y,width:n.w,height:n.h,zIndex:9999},children:[c&&t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:ee}),t.jsxs("div",{className:X("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!c&&"cursor-grab active:cursor-grabbing"),onMouseDown:c?void 0:Z,children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(oe,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:i("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:A,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:c?i("docBrowserFloatMode"):i("docBrowserDockMode"),children:c?t.jsx(ae,{className:"w-3.5 h-3.5"}):t.jsx(ne,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:$,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:i("docBrowserClose"),children:t.jsx(W,{className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2 bg-white border-b border-gray-100 overflow-x-auto custom-scrollbar",children:[F.map(e=>{const r=e.id===N;return t.jsxs("div",{className:X("inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors",r?"bg-blue-50 border-blue-300 text-blue-700":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100"),children:[t.jsx("button",{type:"button",onClick:()=>V(e.id),className:"truncate text-left px-1",title:e.title,children:e.title||i("docBrowserTabUntitled")}),t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),H(e.id)},className:"rounded p-0.5 hover:bg-black/10","aria-label":i("docBrowserCloseTab"),children:t.jsx(W,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(void 0,{kind:"docs",title:"Docs"}),className:"inline-flex items-center justify-center w-7 h-7 rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-100 shrink-0",title:i("docBrowserNewTab"),children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]}),a&&t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:I,disabled:!G,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,disabled:!_,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ce,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:Q,className:"flex-1 relative",children:[t.jsx(de,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:k,onChange:e=>j(e.target.value),placeholder:i("docBrowserSearchPlaceholder"),className:"w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:z,src:l,className:"absolute inset-0 w-full h-full border-0",title:(x==null?void 0:x.title)||"NextClaw Docs",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},`${N}:${p}`),(J||E)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),a&&xe(l)&&t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer","data-doc-external":!0,className:"flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors",children:[i("docBrowserOpenExternal"),t.jsx(ue,{className:"w-3 h-3"})]})}),!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:te}),t.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"x"}),t.jsx("div",{className:"absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"y"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors",onMouseDown:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
1
+ import{r as s,j as t,a3 as oe,bd as ae,be as ne,X as W,ax as ie,$ as le,bf as ce,G as de,ai as ue,bg as me}from"./vendor-waGu-koL.js";import{k as xe,D as Y,t as i,c as X,ak as we}from"./index-COJomMe9.js";function pe(){const{isOpen:T,mode:g,tabs:F,activeTabId:N,currentTab:w,currentUrl:l,navVersion:p,close:$,toggleMode:A,goBack:I,goForward:O,canGoBack:G,canGoForward:_,navigate:y,syncUrl:S,setActiveTab:V,closeTab:H,openNewTab:q}=xe(),[k,j]=s.useState(""),[E,C]=s.useState(!1),[J,h]=s.useState(!1),[d,D]=s.useState(()=>({x:Math.max(40,window.innerWidth-520),y:80})),[n,B]=s.useState({w:480,h:600}),[L,K]=s.useState(420),u=s.useRef(null),m=s.useRef(null),b=s.useRef(null),z=s.useRef(null),P=s.useRef(p),a=(w==null?void 0:w.kind)==="docs";s.useEffect(()=>{if(!a){j("");return}try{const e=new URL(l);j(e.pathname)}catch{j(l)}},[l,N,a]),s.useEffect(()=>{var e;if(a){if(p!==P.current){P.current=p;return}if((e=z.current)!=null&&e.contentWindow)try{const r=new URL(l).pathname;z.current.contentWindow.postMessage({type:"docs-navigate",path:r},"*")}catch{}}},[l,p,a]),s.useEffect(()=>{g==="floating"&&D(e=>({x:Math.max(40,window.innerWidth-n.w-40),y:e.y}))},[g,n.w]),s.useEffect(()=>{const e=r=>{var o;a&&((o=r.data)==null?void 0:o.type)==="docs-route-change"&&typeof r.data.url=="string"&&S(r.data.url)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[S,a]);const Q=s.useCallback(e=>{if(e.preventDefault(),!a)return;const r=k.trim();r&&(r.startsWith("/")?y(`${Y}${r}`):r.startsWith("http")?y(r):y(`${Y}/${r}`))},[k,y,a]),Z=s.useCallback(e=>{g==="floating"&&(C(!0),u.current={startX:e.clientX,startY:e.clientY,startPosX:d.x,startPosY:d.y})},[g,d]);s.useEffect(()=>{if(!E)return;const e=o=>{u.current&&D({x:u.current.startPosX+(o.clientX-u.current.startX),y:u.current.startPosY+(o.clientY-u.current.startY)})},r=()=>{C(!1),u.current=null};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",r),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",r)}},[E]);const M=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.currentTarget.dataset.axis;m.current={startX:e.clientX,startY:e.clientY,startW:n.w,startH:n.h};const o=x=>{m.current&&B(v=>({w:r==="y"?v.w:Math.max(360,m.current.startW+(x.clientX-m.current.startX)),h:r==="x"?v.h:Math.max(400,m.current.startH+(x.clientY-m.current.startY))}))},f=()=>{h(!1),m.current=null,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",o),window.addEventListener("mouseup",f)},[n]),ee=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0),b.current={startX:e.clientX,startW:L};const r=f=>{if(!b.current)return;const x=b.current.startX-f.clientX;K(Math.max(320,Math.min(860,b.current.startW+x)))},o=()=>{h(!1),b.current=null,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[L]),te=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0);const r=e.clientX,o=n.w,f=d.x,x=re=>{const se=r-re.clientX,U=Math.max(360,o+se);B(R=>({...R,w:U})),D(R=>({...R,x:f-(U-o)}))},v=()=>{h(!1),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)};window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},[n.w,d.x]);if(!T)return null;const c=g==="docked";return t.jsxs("div",{className:X("flex flex-col bg-white overflow-hidden relative",c?"h-full border-l border-gray-200 shrink-0":"rounded-2xl shadow-2xl border border-gray-200"),style:c?{width:L}:{position:"fixed",left:d.x,top:d.y,width:n.w,height:n.h,zIndex:9999},children:[c&&t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:ee}),t.jsxs("div",{className:X("flex items-center justify-between px-4 py-2.5 bg-gray-50 border-b border-gray-200 shrink-0 select-none",!c&&"cursor-grab active:cursor-grabbing"),onMouseDown:c?void 0:Z,children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(oe,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 truncate",children:i("docBrowserTitle")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:A,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:c?i("docBrowserFloatMode"):i("docBrowserDockMode"),children:c?t.jsx(ae,{className:"w-3.5 h-3.5"}):t.jsx(ne,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:$,className:"hover:bg-gray-200 rounded-md p-1.5 text-gray-500 hover:text-gray-700 transition-colors",title:i("docBrowserClose"),children:t.jsx(W,{className:"w-3.5 h-3.5"})})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2 bg-white border-b border-gray-100 overflow-x-auto custom-scrollbar",children:[F.map(e=>{const r=e.id===N;return t.jsxs("div",{className:X("inline-flex items-center gap-1 h-7 px-1.5 rounded-lg text-xs border max-w-[220px] shrink-0 transition-colors",r?"bg-blue-50 border-blue-300 text-blue-700":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100"),children:[t.jsx("button",{type:"button",onClick:()=>V(e.id),className:"truncate text-left px-1",title:e.title,children:e.title||i("docBrowserTabUntitled")}),t.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),H(e.id)},className:"rounded p-0.5 hover:bg-black/10","aria-label":i("docBrowserCloseTab"),children:t.jsx(W,{className:"w-3 h-3"})})]},e.id)}),t.jsx("button",{onClick:()=>q(void 0,{kind:"docs",title:"Docs"}),className:"inline-flex items-center justify-center w-7 h-7 rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-100 shrink-0",title:i("docBrowserNewTab"),children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]}),a&&t.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0",children:[t.jsx("button",{onClick:I,disabled:!G,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,disabled:!_,className:"p-1.5 rounded-md hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-600 transition-colors",children:t.jsx(ce,{className:"w-4 h-4"})}),t.jsxs("form",{onSubmit:Q,className:"flex-1 relative",children:[t.jsx(de,{className:"w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx("input",{type:"text",value:k,onChange:e=>j(e.target.value),placeholder:i("docBrowserSearchPlaceholder"),className:"w-full h-8 pl-8 pr-3 rounded-lg bg-gray-50 border border-gray-200 text-xs text-gray-700 focus:outline-none focus:ring-1 focus:ring-primary/30 focus:border-primary/40 transition-colors placeholder:text-gray-400"})]})]}),t.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[t.jsx("iframe",{ref:z,src:l,className:"absolute inset-0 w-full h-full border-0",title:(w==null?void 0:w.title)||"NextClaw Docs",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",allow:"clipboard-read; clipboard-write"},`${N}:${p}`),(J||E)&&t.jsx("div",{className:"absolute inset-0 z-10"})]}),a&&we(l)&&t.jsx("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 border-t border-gray-200 shrink-0",children:t.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer","data-doc-external":!0,className:"flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover font-medium transition-colors",children:[i("docBrowserOpenExternal"),t.jsx(ue,{className:"w-3 h-3"})]})}),!c&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:te}),t.jsx("div",{className:"absolute top-0 right-0 w-1.5 h-full cursor-ew-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"x"}),t.jsx("div",{className:"absolute bottom-0 left-0 h-1.5 w-full cursor-ns-resize z-20 hover:bg-primary/10 transition-colors",onMouseDown:M,"data-axis":"y"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize z-30 flex items-center justify-center text-gray-300 hover:text-gray-500 transition-colors",onMouseDown:M,children:t.jsx(me,{className:"w-3 h-3 rotate-[-45deg]"})})]})]})}export{pe as DocBrowser};
@@ -1 +1 @@
1
- import{r as d,j as e}from"./vendor-D_JxmsLV.js";import{c as t}from"./index-D41ntvb7.js";function x({name:s,src:o,className:a,imgClassName:r,fallback:l}){const[n,i]=d.useState(!1),c=!!o&&!n;return e.jsx("div",{className:t("inline-flex shrink-0 items-center justify-center overflow-hidden",a),children:c?e.jsx("img",{src:o,alt:`${s} logo`,className:t("block h-6 w-6 object-contain",r),onError:()=>i(!0),draggable:!1}):l??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{x as L};
1
+ import{r as d,j as e}from"./vendor-waGu-koL.js";import{c as t}from"./index-COJomMe9.js";function x({name:s,src:o,className:a,imgClassName:r,fallback:l}){const[n,i]=d.useState(!1),c=!!o&&!n;return e.jsx("div",{className:t("inline-flex shrink-0 items-center justify-center overflow-hidden",a),children:c?e.jsx("img",{src:o,alt:`${s} logo`,className:t("block h-6 w-6 object-contain",r),onError:()=>i(!0),draggable:!1}):l??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{x as L};
@@ -1,4 +1,4 @@
1
- import{r as i,j as s,aI as et,aG as tt,aH as nt,aJ as Ie,aM as at,aK as st,aL as A,aN as Ne,aO as Re,aP as rt,aQ as lt,aW as ot,aX as it,b7 as ct,b8 as ut,aY as dt,u as Me,f as Ee,g as Le,e as J,b9 as pt,aA as gt,aB as ft}from"./vendor-D_JxmsLV.js";import{c as De,U as z,t as c,S as mt,e as xt,f as ht,g as yt,h as Ce,m as bt,k as kt}from"./index-D41ntvb7.js";import{T as vt}from"./tabs-custom-CgIdQMGC.js";import{u as wt}from"./useConfirmDialog-BitswAkv.js";import{S as U}from"./skeleton-qUJZQ03S.js";import{b as Tt,p as oe}from"./marketplace-localization-Dk31LJJJ.js";import{P as St,a as Ct}from"./page-layout-B7q511TE.js";var[Y]=lt("Tooltip",[Ne]),X=Ne(),$e="TooltipProvider",Pt=700,ne="tooltip.open",[jt,ie]=Y($e),Oe=e=>{const{__scopeTooltip:t,delayDuration:n=Pt,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:l}=e,g=i.useRef(!0),f=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const k=d.current;return()=>window.clearTimeout(k)},[]),s.jsx(jt,{scope:t,isOpenDelayedRef:g,delayDuration:n,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),g.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>g.current=!0,a)},[a]),isPointerInTransitRef:f,onPointerInTransitChange:i.useCallback(k=>{f.current=k},[]),disableHoverableContent:r,children:l})};Oe.displayName=$e;var K="Tooltip",[It,G]=Y(K),_e=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:l,disableHoverableContent:g,delayDuration:f}=e,d=ie(K,e.__scopeTooltip),k=X(t),[u,b]=i.useState(null),v=et(),h=i.useRef(0),w=g??d.disableHoverableContent,m=f??d.delayDuration,S=i.useRef(!1),[j,P]=tt({prop:a,defaultProp:r??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(ne))):d.onClose(),l==null||l(E)},caller:K}),L=i.useMemo(()=>j?S.current?"delayed-open":"instant-open":"closed",[j]),C=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S.current=!1,P(!0)},[P]),M=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,P(!1)},[P]),$=i.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{S.current=!0,P(!0),h.current=0},m)},[m,P]);return i.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(nt,{...k,children:s.jsx(It,{scope:t,contentId:v,open:j,stateAttribute:L,trigger:u,onTriggerChange:b,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?$():C()},[d.isOpenDelayedRef,$,C]),onTriggerLeave:i.useCallback(()=>{w?M():(window.clearTimeout(h.current),h.current=0)},[M,w]),onOpen:C,onClose:M,disableHoverableContent:w,children:n})})};_e.displayName=K;var ae="TooltipTrigger",Ae=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=G(ae,n),l=ie(ae,n),g=X(n),f=i.useRef(null),d=Ie(t,f,r.onTriggerChange),k=i.useRef(!1),u=i.useRef(!1),b=i.useCallback(()=>k.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",b),[b]),s.jsx(at,{asChild:!0,...g,children:s.jsx(st.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!u.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:A(e.onPointerDown,()=>{r.open&&r.onClose(),k.current=!0,document.addEventListener("pointerup",b,{once:!0})}),onFocus:A(e.onFocus,()=>{k.current||r.onOpen()}),onBlur:A(e.onBlur,r.onClose),onClick:A(e.onClick,r.onClose)})})});Ae.displayName=ae;var ce="TooltipPortal",[Nt,Rt]=Y(ce,{forceMount:void 0}),Ue=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,l=G(ce,t);return s.jsx(Nt,{scope:t,forceMount:n,children:s.jsx(Re,{present:n||l.open,children:s.jsx(rt,{asChild:!0,container:r,children:a})})})};Ue.displayName=ce;var q="TooltipContent",Fe=i.forwardRef((e,t)=>{const n=Rt(q,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...l}=e,g=G(q,e.__scopeTooltip);return s.jsx(Re,{present:a||g.open,children:g.disableHoverableContent?s.jsx(qe,{side:r,...l,ref:t}):s.jsx(Mt,{side:r,...l,ref:t})})}),Mt=i.forwardRef((e,t)=>{const n=G(q,e.__scopeTooltip),a=ie(q,e.__scopeTooltip),r=i.useRef(null),l=Ie(t,r),[g,f]=i.useState(null),{trigger:d,onClose:k}=n,u=r.current,{onPointerInTransitChange:b}=a,v=i.useCallback(()=>{f(null),b(!1)},[b]),h=i.useCallback((w,m)=>{const S=w.currentTarget,j={x:w.clientX,y:w.clientY},P=Ot(j,S.getBoundingClientRect()),L=_t(j,P),C=At(m.getBoundingClientRect()),M=Ft([...L,...C]);f(M),b(!0)},[b]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&u){const w=S=>h(S,u),m=S=>h(S,d);return d.addEventListener("pointerleave",w),u.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",w),u.removeEventListener("pointerleave",m)}}},[d,u,h,v]),i.useEffect(()=>{if(g){const w=m=>{const S=m.target,j={x:m.clientX,y:m.clientY},P=(d==null?void 0:d.contains(S))||(u==null?void 0:u.contains(S)),L=!Ut(j,g);P?v():L&&(v(),k())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[d,u,g,k,v]),s.jsx(qe,{...e,ref:l})}),[Et,Lt]=Y(K,{isInside:!1}),Dt=ut("TooltipContent"),qe=i.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:g,...f}=e,d=G(q,n),k=X(n),{onClose:u}=d;return i.useEffect(()=>(document.addEventListener(ne,u),()=>document.removeEventListener(ne,u)),[u]),i.useEffect(()=>{if(d.trigger){const b=v=>{const h=v.target;h!=null&&h.contains(d.trigger)&&u()};return window.addEventListener("scroll",b,{capture:!0}),()=>window.removeEventListener("scroll",b,{capture:!0})}},[d.trigger,u]),s.jsx(ot,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:b=>b.preventDefault(),onDismiss:u,children:s.jsxs(it,{"data-state":d.stateAttribute,...k,...f,ref:t,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(Dt,{children:a}),s.jsx(Et,{scope:n,isInside:!0,children:s.jsx(ct,{id:d.contentId,role:"tooltip",children:r||a})})]})})});Fe.displayName=q;var ze="TooltipArrow",$t=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=X(n);return Lt(ze,n).isInside?null:s.jsx(dt,{...r,...a,ref:t})});$t.displayName=ze;function Ot(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,a,r,l)){case l:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function _t(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function At(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Ut(e,t){const{x:n,y:a}=e;let r=!1;for(let l=0,g=t.length-1;l<t.length;g=l++){const f=t[l],d=t[g],k=f.x,u=f.y,b=d.x,v=d.y;u>a!=v>a&&n<(b-k)*(a-u)/(v-u)+k&&(r=!r)}return r}function Ft(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),qt(t)}function qt(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const l=t[t.length-1],g=t[t.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const l=n[n.length-1],g=n[n.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var zt=Oe,Ht=_e,Bt=Ae,Kt=Ue,He=Fe;const Gt=zt,ee=Ht,te=Bt,Q=i.forwardRef(({className:e,sideOffset:t=4,...n},a)=>s.jsx(Kt,{children:s.jsx(He,{ref:a,sideOffset:t,className:De("z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Q.displayName=He.displayName;function W(e){return e==="plugin"?"plugins":e==="skill"?"skills":"mcp"}async function Vt(e){var l,g;const t=new URLSearchParams,n=W(e.type);(l=e.q)!=null&&l.trim()&&t.set("q",e.q.trim()),(g=e.tag)!=null&&g.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const a=t.toString(),r=await z.get(a?`/api/marketplace/${n}/items?${a}`:`/api/marketplace/${n}/items`);if(!r.ok)throw new Error(r.error.message);return r.data}async function Qt(e){const t=await z.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Jt(e){const t=await z.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Yt(e){const t=W(e.type),n=await z.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw new Error(n.error.message);return n.data}async function Xt(e){const t=W(e),n=await z.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw new Error(n.error.message);return n.data}async function Wt(e){const t=W(e.type),n=await z.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw new Error(n.error.message);return n.data}function se(e){return Array.from(new Set(e.map(t=>t.spec).filter(Boolean)))}function Zt(e){const t=new Date().toISOString();return e.result.type==="skill"?{type:"skill",spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:"workspace",installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:"marketplace",origin:"marketplace",enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?"disabled":"ready",installedAt:t}}function re(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Be(e,t){return t??{type:e,total:0,specs:[],records:[]}}function en(e){const t=Be(e.result.type,e.view),n=Zt(e),a=t.records.findIndex(l=>re(l,{id:n.id,spec:n.spec})),r=[...t.records];return a>=0?r[a]={...r[a],...n}:r.unshift(n),{...t,type:e.result.type,records:r,specs:se(r),total:r.length}}function tn(e){const t=Be(e.result.type,e.view);if(e.result.action==="uninstall"||e.result.action==="remove"){const a=t.records.filter(r=>!re(r,{id:e.result.id,spec:e.request.spec}));return{...t,records:a,specs:se(a),total:a.length}}const n=t.records.map(a=>re(a,{id:e.result.id,spec:e.request.spec})?e.result.action==="disable"?{...a,enabled:!1,runtimeStatus:"disabled"}:{...a,enabled:!0,runtimeStatus:"ready"}:a);return{...t,records:n,specs:se(n),total:n.length}}function nn(e){return Me({queryKey:["marketplace-items",e],queryFn:()=>Vt(e),placeholderData:(t,n)=>{var l;const a=(l=n==null?void 0:n.queryKey)==null?void 0:l[1];return!a||typeof a!="object"||a===null?void 0:("type"in a?a.type:void 0)===e.type?t:void 0},staleTime:15e3})}function an(e){return Me({queryKey:["marketplace-installed",e],queryFn:()=>Xt(e),staleTime:1e4})}function sn(){const e=Ee();return Le({mutationFn:t=>Yt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>en({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.type==="plugin"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceInstallFailed"))}})}function rn(){const e=Ee();return Le({mutationFn:t=>Wt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>tn({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.action==="enable"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceOperationFailed"))}})}function ln(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(pt,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(mt,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(xt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(ht,{})}),s.jsxs(yt,{children:[s.jsx(Ce,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(Ce,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function on(e){return s.jsx(s.Fragment,{children:Array.from({length:e.count},(t,n)=>s.jsx("article",{className:"rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm",children:s.jsxs("div",{className:"flex items-start gap-3.5 justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 gap-3",children:[s.jsx(U,{className:"h-10 w-10 shrink-0 rounded-xl"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2 pt-0.5",children:[s.jsx(U,{className:"h-4 w-32 max-w-[70%]"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(U,{className:"h-3 w-12"}),s.jsx(U,{className:"h-3 w-24"})]}),s.jsx(U,{className:"h-3 w-full"})]})]}),s.jsx(U,{className:"h-8 w-20 shrink-0 rounded-xl"})]})},`marketplace-skeleton-${n}`))})}function cn(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}const Ke=12,un=Ke;function le(e){return(e??"").trim().toLowerCase()}function F(e,t){const n=le(t);return n.length>0?`${e}:${n}`:""}function dn(e){const t=new Map;for(const n of e){const a=[n.install.spec,n.slug,n.id];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function pn(e){const t=new Map;for(const n of e){const a=[n.spec,n.id,n.label];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function Pe(e,t){const n=[e.install.spec,e.slug,e.id];for(const a of n){const r=F(e.type,a);if(!r)continue;const l=t.get(r);if(l)return l}}function gn(e,t){const n=t.get(F(e.type,e.spec));if(n)return n;const a=t.get(F(e.type,e.id));return a||t.get(F(e.type,e.label))}function fn(e,t,n,a){const r=le(n);if(!r)return!0;const l=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a);return[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,l,...(t==null?void 0:t.tags)??[]].map(f=>le(f)).filter(Boolean).some(f=>f.includes(r))}function mn(e){const t=["bg-amber-600","bg-orange-500","bg-yellow-600","bg-emerald-600","bg-teal-600","bg-cyan-600","bg-stone-600","bg-rose-500","bg-violet-500"];let n=0;for(let a=0;a<e.length;a++)n=e.charCodeAt(a)+((n<<5)-n);return t[Math.abs(n)%t.length]}function xn({name:e,fallback:t}){const n=e||t,a=n.substring(0,2).toUpperCase(),r=mn(n);return s.jsx("div",{className:De("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:a})}function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function B(e){var f,d,k,u;const t=((f=e.metadataRaw)==null?void 0:f.trim())||"-",n=((d=e.contentRaw)==null?void 0:d.trim())||"-",a=(k=e.summary)==null?void 0:k.trim(),r=(u=e.description)==null?void 0:u.trim(),l=!!r&&r!==a,g=`<!doctype html>
1
+ import{r as i,j as s,aL as et,aJ as tt,aK as nt,aM as Ie,aP as at,aN as st,aO as A,aQ as Ne,aR as Re,aS as rt,aT as lt,aZ as ot,a_ as it,ba as ct,bb as ut,a$ as dt,u as Me,f as Ee,g as Le,e as J,bc as pt,aD as gt,aE as ft}from"./vendor-waGu-koL.js";import{c as De,U as z,t as c,S as mt,e as xt,f as ht,g as yt,h as Ce,m as bt,k as kt}from"./index-COJomMe9.js";import{T as vt}from"./tabs-custom-Ilrgt6n1.js";import{u as wt}from"./useConfirmDialog-BeaFLDO8.js";import{S as U}from"./skeleton-D4Eyop0R.js";import{b as Tt,p as oe}from"./marketplace-localization-Dk31LJJJ.js";import{P as St,a as Ct}from"./page-layout-B1RIu5-r.js";var[Y]=lt("Tooltip",[Ne]),X=Ne(),$e="TooltipProvider",Pt=700,ne="tooltip.open",[jt,ie]=Y($e),_e=e=>{const{__scopeTooltip:t,delayDuration:n=Pt,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:l}=e,g=i.useRef(!0),f=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const k=d.current;return()=>window.clearTimeout(k)},[]),s.jsx(jt,{scope:t,isOpenDelayedRef:g,delayDuration:n,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),g.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>g.current=!0,a)},[a]),isPointerInTransitRef:f,onPointerInTransitChange:i.useCallback(k=>{f.current=k},[]),disableHoverableContent:r,children:l})};_e.displayName=$e;var K="Tooltip",[It,G]=Y(K),Oe=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:l,disableHoverableContent:g,delayDuration:f}=e,d=ie(K,e.__scopeTooltip),k=X(t),[u,b]=i.useState(null),v=et(),h=i.useRef(0),w=g??d.disableHoverableContent,m=f??d.delayDuration,S=i.useRef(!1),[j,P]=tt({prop:a,defaultProp:r??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(ne))):d.onClose(),l==null||l(E)},caller:K}),L=i.useMemo(()=>j?S.current?"delayed-open":"instant-open":"closed",[j]),C=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S.current=!1,P(!0)},[P]),M=i.useCallback(()=>{window.clearTimeout(h.current),h.current=0,P(!1)},[P]),$=i.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{S.current=!0,P(!0),h.current=0},m)},[m,P]);return i.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(nt,{...k,children:s.jsx(It,{scope:t,contentId:v,open:j,stateAttribute:L,trigger:u,onTriggerChange:b,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?$():C()},[d.isOpenDelayedRef,$,C]),onTriggerLeave:i.useCallback(()=>{w?M():(window.clearTimeout(h.current),h.current=0)},[M,w]),onOpen:C,onClose:M,disableHoverableContent:w,children:n})})};Oe.displayName=K;var ae="TooltipTrigger",Ae=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=G(ae,n),l=ie(ae,n),g=X(n),f=i.useRef(null),d=Ie(t,f,r.onTriggerChange),k=i.useRef(!1),u=i.useRef(!1),b=i.useCallback(()=>k.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",b),[b]),s.jsx(at,{asChild:!0,...g,children:s.jsx(st.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!u.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:A(e.onPointerDown,()=>{r.open&&r.onClose(),k.current=!0,document.addEventListener("pointerup",b,{once:!0})}),onFocus:A(e.onFocus,()=>{k.current||r.onOpen()}),onBlur:A(e.onBlur,r.onClose),onClick:A(e.onClick,r.onClose)})})});Ae.displayName=ae;var ce="TooltipPortal",[Nt,Rt]=Y(ce,{forceMount:void 0}),Ue=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,l=G(ce,t);return s.jsx(Nt,{scope:t,forceMount:n,children:s.jsx(Re,{present:n||l.open,children:s.jsx(rt,{asChild:!0,container:r,children:a})})})};Ue.displayName=ce;var q="TooltipContent",Fe=i.forwardRef((e,t)=>{const n=Rt(q,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...l}=e,g=G(q,e.__scopeTooltip);return s.jsx(Re,{present:a||g.open,children:g.disableHoverableContent?s.jsx(qe,{side:r,...l,ref:t}):s.jsx(Mt,{side:r,...l,ref:t})})}),Mt=i.forwardRef((e,t)=>{const n=G(q,e.__scopeTooltip),a=ie(q,e.__scopeTooltip),r=i.useRef(null),l=Ie(t,r),[g,f]=i.useState(null),{trigger:d,onClose:k}=n,u=r.current,{onPointerInTransitChange:b}=a,v=i.useCallback(()=>{f(null),b(!1)},[b]),h=i.useCallback((w,m)=>{const S=w.currentTarget,j={x:w.clientX,y:w.clientY},P=_t(j,S.getBoundingClientRect()),L=Ot(j,P),C=At(m.getBoundingClientRect()),M=Ft([...L,...C]);f(M),b(!0)},[b]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&u){const w=S=>h(S,u),m=S=>h(S,d);return d.addEventListener("pointerleave",w),u.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",w),u.removeEventListener("pointerleave",m)}}},[d,u,h,v]),i.useEffect(()=>{if(g){const w=m=>{const S=m.target,j={x:m.clientX,y:m.clientY},P=(d==null?void 0:d.contains(S))||(u==null?void 0:u.contains(S)),L=!Ut(j,g);P?v():L&&(v(),k())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[d,u,g,k,v]),s.jsx(qe,{...e,ref:l})}),[Et,Lt]=Y(K,{isInside:!1}),Dt=ut("TooltipContent"),qe=i.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:g,...f}=e,d=G(q,n),k=X(n),{onClose:u}=d;return i.useEffect(()=>(document.addEventListener(ne,u),()=>document.removeEventListener(ne,u)),[u]),i.useEffect(()=>{if(d.trigger){const b=v=>{const h=v.target;h!=null&&h.contains(d.trigger)&&u()};return window.addEventListener("scroll",b,{capture:!0}),()=>window.removeEventListener("scroll",b,{capture:!0})}},[d.trigger,u]),s.jsx(ot,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:b=>b.preventDefault(),onDismiss:u,children:s.jsxs(it,{"data-state":d.stateAttribute,...k,...f,ref:t,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(Dt,{children:a}),s.jsx(Et,{scope:n,isInside:!0,children:s.jsx(ct,{id:d.contentId,role:"tooltip",children:r||a})})]})})});Fe.displayName=q;var ze="TooltipArrow",$t=i.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=X(n);return Lt(ze,n).isInside?null:s.jsx(dt,{...r,...a,ref:t})});$t.displayName=ze;function _t(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,a,r,l)){case l:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Ot(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function At(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Ut(e,t){const{x:n,y:a}=e;let r=!1;for(let l=0,g=t.length-1;l<t.length;g=l++){const f=t[l],d=t[g],k=f.x,u=f.y,b=d.x,v=d.y;u>a!=v>a&&n<(b-k)*(a-u)/(v-u)+k&&(r=!r)}return r}function Ft(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),qt(t)}function qt(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const l=t[t.length-1],g=t[t.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const l=n[n.length-1],g=n[n.length-2];if((l.x-g.x)*(r.y-g.y)>=(l.y-g.y)*(r.x-g.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var zt=_e,Ht=Oe,Bt=Ae,Kt=Ue,He=Fe;const Gt=zt,ee=Ht,te=Bt,Q=i.forwardRef(({className:e,sideOffset:t=4,...n},a)=>s.jsx(Kt,{children:s.jsx(He,{ref:a,sideOffset:t,className:De("z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Q.displayName=He.displayName;function Z(e){return e==="plugin"?"plugins":e==="skill"?"skills":"mcp"}async function Vt(e){var l,g;const t=new URLSearchParams,n=Z(e.type);(l=e.q)!=null&&l.trim()&&t.set("q",e.q.trim()),(g=e.tag)!=null&&g.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const a=t.toString(),r=await z.get(a?`/api/marketplace/${n}/items?${a}`:`/api/marketplace/${n}/items`);if(!r.ok)throw new Error(r.error.message);return r.data}async function Qt(e){const t=await z.get(`/api/marketplace/skills/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Jt(e){const t=await z.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Yt(e){const t=Z(e.type),n=await z.post(`/api/marketplace/${t}/install`,e);if(!n.ok)throw new Error(n.error.message);return n.data}async function Xt(e){const t=Z(e),n=await z.get(`/api/marketplace/${t}/installed`);if(!n.ok)throw new Error(n.error.message);return n.data}async function Zt(e){const t=Z(e.type),n=await z.post(`/api/marketplace/${t}/manage`,e);if(!n.ok)throw new Error(n.error.message);return n.data}function se(e){return Array.from(new Set(e.map(t=>t.spec).filter(Boolean)))}function Wt(e){const t=new Date().toISOString();return e.result.type==="skill"?{type:"skill",spec:e.result.spec,id:e.request.skill??e.result.spec,label:e.request.skill??e.result.name??e.result.spec,source:"workspace",installPath:e.request.installPath,installedAt:t}:{type:e.result.type,spec:e.result.spec,id:e.result.name??e.result.spec,label:e.result.name??e.result.spec,source:"marketplace",origin:"marketplace",enabled:e.request.enabled??!0,runtimeStatus:e.request.enabled===!1?"disabled":"ready",installedAt:t}}function re(e,t){return!!(t.spec&&e.spec===t.spec||t.id&&e.id===t.id)}function Be(e,t){return t??{type:e,total:0,specs:[],records:[]}}function en(e){const t=Be(e.result.type,e.view),n=Wt(e),a=t.records.findIndex(l=>re(l,{id:n.id,spec:n.spec})),r=[...t.records];return a>=0?r[a]={...r[a],...n}:r.unshift(n),{...t,type:e.result.type,records:r,specs:se(r),total:r.length}}function tn(e){const t=Be(e.result.type,e.view);if(e.result.action==="uninstall"||e.result.action==="remove"){const a=t.records.filter(r=>!re(r,{id:e.result.id,spec:e.request.spec}));return{...t,records:a,specs:se(a),total:a.length}}const n=t.records.map(a=>re(a,{id:e.result.id,spec:e.request.spec})?e.result.action==="disable"?{...a,enabled:!1,runtimeStatus:"disabled"}:{...a,enabled:!0,runtimeStatus:"ready"}:a);return{...t,records:n,specs:se(n),total:n.length}}function nn(e){return Me({queryKey:["marketplace-items",e],queryFn:()=>Vt(e),placeholderData:(t,n)=>{var l;const a=(l=n==null?void 0:n.queryKey)==null?void 0:l[1];return!a||typeof a!="object"||a===null?void 0:("type"in a?a.type:void 0)===e.type?t:void 0},staleTime:15e3})}function an(e){return Me({queryKey:["marketplace-installed",e],queryFn:()=>Xt(e),staleTime:1e4})}function sn(){const e=Ee();return Le({mutationFn:t=>Yt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>en({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.type==="plugin"?c("marketplaceInstallSuccessPlugin"):c("marketplaceInstallSuccessSkill");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceInstallFailed"))}})}function rn(){const e=Ee();return Le({mutationFn:t=>Zt(t),onSuccess:(t,n)=>{e.setQueryData(["marketplace-installed",t.type],r=>tn({view:r,request:n,result:t})),e.invalidateQueries({queryKey:["marketplace-installed",t.type],refetchType:"inactive"}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.action==="enable"?c("marketplaceEnableSuccess"):t.action==="disable"?c("marketplaceDisableSuccess"):c("marketplaceUninstallSuccess");J.success(t.message||a)},onError:t=>{J.error(t.message||c("marketplaceOperationFailed"))}})}function ln(e){return s.jsx("div",{className:"mb-4",children:s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsxs("div",{className:"flex-1 min-w-0 relative",children:[s.jsx(pt,{className:"h-4 w-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),s.jsx("input",{value:e.searchText,onChange:t=>e.onSearchTextChange(t.target.value),placeholder:e.searchPlaceholder,className:"w-full h-9 border border-gray-200/80 rounded-xl pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.scope==="all"&&s.jsxs(mt,{value:e.sort,onValueChange:t=>e.onSortChange(t),children:[s.jsx(xt,{className:"h-9 w-[150px] shrink-0 rounded-lg",children:s.jsx(ht,{})}),s.jsxs(yt,{children:[s.jsx(Ce,{value:"relevance",children:c("marketplaceSortRelevance")}),s.jsx(Ce,{value:"updated",children:c("marketplaceSortUpdated")})]})]})]})})}function on(e){return s.jsx(s.Fragment,{children:Array.from({length:e.count},(t,n)=>s.jsx("article",{className:"rounded-2xl border border-gray-200/40 bg-white px-5 py-4 shadow-sm",children:s.jsxs("div",{className:"flex items-start gap-3.5 justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 gap-3",children:[s.jsx(U,{className:"h-10 w-10 shrink-0 rounded-xl"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2 pt-0.5",children:[s.jsx(U,{className:"h-4 w-32 max-w-[70%]"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(U,{className:"h-3 w-12"}),s.jsx(U,{className:"h-3 w-24"})]}),s.jsx(U,{className:"h-3 w-full"})]})]}),s.jsx(U,{className:"h-8 w-20 shrink-0 rounded-xl"})]})},`marketplace-skeleton-${n}`))})}function cn(e){return s.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onPrev,disabled:e.page<=1||e.busy,children:c("prev")}),s.jsx("div",{className:"text-sm text-gray-600 min-w-20 text-center",children:e.totalPages===0?"0 / 0":`${e.page} / ${e.totalPages}`}),s.jsx("button",{className:"h-8 px-3 rounded-xl border border-gray-200/80 text-sm text-gray-600 disabled:opacity-40",onClick:e.onNext,disabled:e.totalPages===0||e.page>=e.totalPages||e.busy,children:c("next")})]})}const Ke=12,un=Ke;function le(e){return(e??"").trim().toLowerCase()}function F(e,t){const n=le(t);return n.length>0?`${e}:${n}`:""}function dn(e){const t=new Map;for(const n of e){const a=[n.install.spec,n.slug,n.id];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function pn(e){const t=new Map;for(const n of e){const a=[n.spec,n.id,n.label];for(const r of a){const l=F(n.type,r);!l||t.has(l)||t.set(l,n)}}return t}function Pe(e,t){const n=[e.install.spec,e.slug,e.id];for(const a of n){const r=F(e.type,a);if(!r)continue;const l=t.get(r);if(l)return l}}function gn(e,t){const n=t.get(F(e.type,e.spec));if(n)return n;const a=t.get(F(e.type,e.id));return a||t.get(F(e.type,e.label))}function fn(e,t,n,a){const r=le(n);if(!r)return!0;const l=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a);return[e.id,e.spec,e.label,t==null?void 0:t.name,t==null?void 0:t.slug,t==null?void 0:t.summary,l,...(t==null?void 0:t.tags)??[]].map(f=>le(f)).filter(Boolean).some(f=>f.includes(r))}function mn(e){const t=["bg-amber-600","bg-orange-500","bg-yellow-600","bg-emerald-600","bg-teal-600","bg-cyan-600","bg-stone-600","bg-rose-500","bg-violet-500"];let n=0;for(let a=0;a<e.length;a++)n=e.charCodeAt(a)+((n<<5)-n);return t[Math.abs(n)%t.length]}function xn({name:e,fallback:t}){const n=e||t,a=n.substring(0,2).toUpperCase(),r=mn(n);return s.jsx("div",{className:De("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",r),children:a})}function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function B(e){var f,d,k,u;const t=((f=e.metadataRaw)==null?void 0:f.trim())||"-",n=((d=e.contentRaw)==null?void 0:d.trim())||"-",a=(k=e.summary)==null?void 0:k.trim(),r=(u=e.description)==null?void 0:u.trim(),l=!!r&&r!==a,g=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -46,4 +46,4 @@ import{r as i,j as s,aI as et,aG as tt,aH as nt,aJ as Ie,aM as at,aK as st,aL as
46
46
  </section>
47
47
  </main>
48
48
  </body>
49
- </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(g)}`}function je(e){const{item:t,record:n,localeFallbacks:a,installState:r,manageState:l,onOpen:g,onInstall:f,onManage:d}=e,k=(n==null?void 0:n.type)==="plugin"?n:void 0,u=(t==null?void 0:t.name)??(n==null?void 0:n.label)??(n==null?void 0:n.id)??(n==null?void 0:n.spec)??c("marketplaceUnknownItem"),b=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a)||(n?c("marketplaceInstalledLocalSummary"):""),v=(t==null?void 0:t.install.spec)??(n==null?void 0:n.spec)??"",h=(n==null?void 0:n.id)||(n==null?void 0:n.spec),w=h?l.actionsByTarget.get(h):void 0,m=!!w,S=!!k,j=(n==null?void 0:n.type)==="plugin"&&n.origin!=="bundled",P=(n==null?void 0:n.type)==="skill"&&n.source==="workspace",L=!!(j||P),C=n?n.enabled===!1||n.runtimeStatus==="disabled":!1,M=t==null?void 0:t.install.spec,$=typeof M=="string"&&r.installingSpecs.has(M);return s.jsxs("article",{onClick:g,className:"group bg-white border border-gray-200/40 hover:border-blue-300/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-pointer",children:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(xn,{name:u,fallback:v||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(Gt,{delayDuration:400,children:[s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight",children:u})}),s.jsx(Q,{className:"max-w-[300px] text-xs",children:u})]}),s.jsx("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:v&&s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono",children:v})}),s.jsx(Q,{className:"max-w-[300px] text-xs font-mono break-all",children:v})]})}),s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left",children:b})}),b&&s.jsx(Q,{className:"max-w-[400px] text-xs leading-relaxed",children:b})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[t&&!n&&s.jsx("button",{onClick:E=>{E.stopPropagation(),f(t)},disabled:$,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:$?c("marketplaceInstalling"):c("marketplaceInstall")}),k&&S&&s.jsx("button",{disabled:m,onClick:E=>{E.stopPropagation(),d(C?"enable":"disable",k)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:w&&w!=="uninstall"?w==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):C?c("marketplaceEnable"):c("marketplaceDisable")}),n&&L&&s.jsx("button",{disabled:m,onClick:E=>{E.stopPropagation(),d("uninstall",n)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:w==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function hn(e={}){var ke,ve,we,Te,Se;const{forcedType:t}=e,n=gt(),a=ft(),{language:r}=bt(),l=kt(),g=i.useMemo(()=>t==="plugins"||t==="skills"?t:a.type==="plugins"||a.type==="skills"?a.type:null,[t,a.type]);i.useEffect(()=>{t||g||n("/marketplace/plugins",{replace:!0})},[t,g,n]);const f=g==="skills"?"skill":"plugin",d=i.useMemo(()=>Tt(r),[r]),u=f==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[b,v]=i.useState(""),[h,w]=i.useState(""),[m,S]=i.useState("all"),[j,P]=i.useState("relevance"),[L,C]=i.useState(1),[M,$]=i.useState(new Set),[E,ue]=i.useState(new Map);i.useEffect(()=>{const o=setTimeout(()=>{C(1),w(b.trim())},250);return()=>clearTimeout(o)},[b]),i.useEffect(()=>{C(1)},[f]);const N=an(f),R=nn({q:h||void 0,type:f,sort:j,page:L,pageSize:Ke}),Ge=sn(),Ve=rn(),{confirm:Qe,ConfirmDialog:Je}=wt(),V=i.useMemo(()=>{var o;return((o=N.data)==null?void 0:o.records)??[]},[(ke=N.data)==null?void 0:ke.records]),_=i.useMemo(()=>{var o;return((o=R.data)==null?void 0:o.items)??[]},[(ve=R.data)==null?void 0:ve.items]),de=i.useMemo(()=>dn(_),[_]),pe=i.useMemo(()=>pn(V),[V]),H=i.useMemo(()=>{const o=V.filter(p=>p.type===f).map(p=>({key:`${p.type}:${p.spec}:${p.id??""}`,record:p,item:gn(p,de)})).filter(p=>fn(p.record,p.item,h,d));return o.sort((p,y)=>{const T=p.record.installedAt?Date.parse(p.record.installedAt):Number.NaN,x=y.record.installedAt?Date.parse(y.record.installedAt):Number.NaN,D=!Number.isNaN(T),Ze=!Number.isNaN(x);return D&&Ze&&T!==x?x-T:p.record.spec.localeCompare(y.record.spec)}),o},[V,f,de,h,d]),ge=m==="installed"?H.length:((we=R.data)==null?void 0:we.total)??0,Z=m==="installed"?1:((Te=R.data)==null?void 0:Te.totalPages)??0,fe=m==="all"&&R.isLoading&&!R.data,Ye=m==="installed"&&N.isLoading&&!N.data,O=fe||Ye,Xe=i.useMemo(()=>m==="installed"?N.isLoading&&!N.data?c("loading"):`${H.length} ${c(u.installedCountSuffix)}`:R.data?`${_.length} / ${ge}`:c("loading"),[m,N.data,N.isLoading,H.length,R.data,_.length,ge,u.installedCountSuffix]),me={installingSpecs:M},xe={actionsByTarget:E},We=[{id:"all",label:c(u.tabMarketplace)},{id:"installed",label:c(u.tabInstalled),count:((Se=N.data)==null?void 0:Se.total)??0}],he=async o=>{const p=o.install.spec;if(!M.has(p)){$(y=>{const T=new Set(y);return T.add(p),T});try{await Ge.mutateAsync({type:o.type,spec:p,kind:o.install.kind,...o.type==="skill"?{skill:o.slug,installPath:`skills/${o.slug}`}:{}})}catch{}finally{$(y=>{if(!y.has(p))return y;const T=new Set(y);return T.delete(p),T})}}},ye=async(o,p)=>{const y=p.id||p.spec;if(y&&!E.has(y)&&!(o==="uninstall"&&!await Qe({title:`${c("marketplaceUninstallTitle")} ${y}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"}))){ue(T=>{const x=new Map(T);return x.set(y,o),x});try{await Ve.mutateAsync({type:p.type,action:o,id:y,spec:p.spec})}finally{ue(T=>{if(!T.has(y))return T;const x=new Map(T);return x.delete(y),x})}}},be=async(o,p)=>{const y=(o==null?void 0:o.name)??(p==null?void 0:p.label)??(p==null?void 0:p.id)??(p==null?void 0:p.spec)??c("marketplaceUnknownItem");if(!o){const x=B({title:y,typeLabel:(p==null?void 0:p.type)==="plugin"?c("marketplaceTypePlugin"):c("marketplaceTypeSkill"),spec:(p==null?void 0:p.spec)??"-",summary:c("marketplaceInstalledLocalSummary"),metadataRaw:JSON.stringify(p??{},null,2),contentRaw:"-"});l.open(x,{newTab:!0,title:y,kind:"content"});return}const T=oe(o.summaryI18n,o.summary,d);if(o.type==="skill"){try{const x=await Qt(o.slug),D=B({title:y,typeLabel:c("marketplaceTypeSkill"),spec:o.install.spec,summary:T,metadataRaw:x.metadataRaw,contentRaw:x.bodyRaw||x.raw,sourceUrl:x.sourceUrl,sourceLabel:`Source (${x.source})`,tags:o.tags,author:o.author});l.open(D,{newTab:!0,title:y,kind:"content"})}catch(x){const D=B({title:y,typeLabel:c("marketplaceTypeSkill"),spec:o.install.spec,summary:T,metadataRaw:JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),contentRaw:c("marketplaceOperationFailed")});l.open(D,{newTab:!0,title:y,kind:"content"})}return}try{const x=await Jt(o.slug),D=B({title:y,typeLabel:c("marketplaceTypePlugin"),spec:o.install.spec,summary:T,metadataRaw:x.metadataRaw,contentRaw:x.bodyRaw||x.raw||o.summary,sourceUrl:x.sourceUrl,sourceLabel:`Source (${x.source})`,tags:o.tags,author:o.author});l.open(D,{newTab:!0,title:y,kind:"content"})}catch(x){const D=B({title:y,typeLabel:c("marketplaceTypePlugin"),spec:o.install.spec,summary:T,metadataRaw:JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),contentRaw:"-"});l.open(D,{newTab:!0,title:y,kind:"content"})}};return s.jsxs(St,{className:"flex h-full min-h-0 flex-col pb-0",children:[s.jsx(Ct,{title:c(u.pageTitle),description:c(u.pageDescription)}),s.jsx(vt,{tabs:We,activeTab:m,onChange:o=>{S(o),C(1)},className:"mb-4"}),s.jsx(ln,{scope:m,searchText:b,searchPlaceholder:c(u.searchPlaceholder),sort:j,onSearchTextChange:v,onSortChange:o=>{C(1),P(o)}}),s.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:m==="installed"?c(u.sectionInstalled):c(u.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:Xe})]}),m==="all"&&R.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(u.errorLoadData),": ",R.error.message]}),m==="installed"&&N.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(u.errorLoadInstalled),": ",N.error.message]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1","aria-busy":O,children:[s.jsxs("div",{"data-testid":O?"marketplace-list-skeleton":void 0,className:"grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:[O&&s.jsx(on,{count:un}),!O&&m==="all"&&_.map(o=>s.jsx(je,{item:o,record:Pe(o,pe),localeFallbacks:d,installState:me,manageState:xe,onOpen:()=>void be(o,Pe(o,pe)),onInstall:he,onManage:ye},o.id)),!O&&m==="installed"&&H.map(o=>s.jsx(je,{item:o.item,record:o.record,localeFallbacks:d,installState:me,manageState:xe,onOpen:()=>void be(o.item,o.record),onInstall:he,onManage:ye},o.key))]}),m==="all"&&!O&&!R.isError&&_.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(u.emptyData)}),m==="installed"&&!O&&!N.isError&&H.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(u.emptyInstalled)})]})]}),m==="all"&&!fe&&s.jsx("div",{className:"shrink-0",children:s.jsx(cn,{page:L,totalPages:Z,busy:R.isFetching,onPrev:()=>C(o=>Math.max(1,o-1)),onNext:()=>C(o=>Z>0?Math.min(Z,o+1):o+1)})}),s.jsx(Je,{})]})}const Cn=Object.freeze(Object.defineProperty({__proto__:null,MarketplacePage:hn},Symbol.toStringTag,{value:"Module"}));export{He as C,hn as M,zt as P,Ht as R,Gt as T,ee as a,te as b,Q as c,Bt as d,Kt as e,Cn as f,an as u};
49
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(g)}`}function je(e){const{item:t,record:n,localeFallbacks:a,installState:r,manageState:l,onOpen:g,onInstall:f,onManage:d}=e,k=(n==null?void 0:n.type)==="plugin"?n:void 0,u=(t==null?void 0:t.name)??(n==null?void 0:n.label)??(n==null?void 0:n.id)??(n==null?void 0:n.spec)??c("marketplaceUnknownItem"),b=oe(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,a)||(n?c("marketplaceInstalledLocalSummary"):""),v=(t==null?void 0:t.install.spec)??(n==null?void 0:n.spec)??"",h=(n==null?void 0:n.id)||(n==null?void 0:n.spec),w=h?l.actionsByTarget.get(h):void 0,m=!!w,S=!!k,j=(n==null?void 0:n.type)==="plugin"&&n.origin!=="bundled",P=(n==null?void 0:n.type)==="skill"&&n.source==="workspace",L=!!(j||P),C=n?n.enabled===!1||n.runtimeStatus==="disabled":!1,M=t==null?void 0:t.install.spec,$=typeof M=="string"&&r.installingSpecs.has(M);return s.jsxs("article",{onClick:g,className:"group bg-white border border-gray-200/40 hover:border-blue-300/80 rounded-2xl px-5 py-4 hover:shadow-md shadow-sm transition-all flex items-start gap-3.5 justify-between cursor-pointer",children:[s.jsxs("div",{className:"flex gap-3 min-w-0 flex-1 h-full items-start",children:[s.jsx(xn,{name:u,fallback:v||c("marketplaceTypeExtension")}),s.jsx("div",{className:"min-w-0 flex-1 flex flex-col justify-center h-full",children:s.jsxs(Gt,{delayDuration:400,children:[s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("div",{className:"text-[14px] font-semibold text-gray-900 truncate leading-tight",children:u})}),s.jsx(Q,{className:"max-w-[300px] text-xs",children:u})]}),s.jsx("div",{className:"flex items-center gap-1.5 mt-0.5 mb-1.5",children:v&&s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("span",{className:"text-[11px] text-gray-400 truncate max-w-full font-mono",children:v})}),s.jsx(Q,{className:"max-w-[300px] text-xs font-mono break-all",children:v})]})}),s.jsxs(ee,{children:[s.jsx(te,{asChild:!0,children:s.jsx("p",{className:"text-[12px] text-gray-500/90 line-clamp-1 transition-colors leading-relaxed text-left",children:b})}),b&&s.jsx(Q,{className:"max-w-[400px] text-xs leading-relaxed",children:b})]})]})})]}),s.jsxs("div",{className:"shrink-0 flex items-center h-full",children:[t&&!n&&s.jsx("button",{onClick:E=>{E.stopPropagation(),f(t)},disabled:$,className:"inline-flex items-center gap-1.5 h-8 px-4 rounded-xl text-xs font-medium bg-primary text-white hover:bg-primary-600 disabled:opacity-50 transition-colors",children:$?c("marketplaceInstalling"):c("marketplaceInstall")}),k&&S&&s.jsx("button",{disabled:m,onClick:E=>{E.stopPropagation(),d(C?"enable":"disable",k)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-gray-200/80 text-gray-600 bg-white hover:bg-gray-50 hover:border-gray-300 disabled:opacity-50 transition-colors",children:w&&w!=="uninstall"?w==="enable"?c("marketplaceEnabling"):c("marketplaceDisabling"):C?c("marketplaceEnable"):c("marketplaceDisable")}),n&&L&&s.jsx("button",{disabled:m,onClick:E=>{E.stopPropagation(),d("uninstall",n)},className:"inline-flex items-center h-8 px-4 rounded-xl text-xs font-medium border border-rose-100 text-rose-500 bg-white hover:bg-rose-50 hover:border-rose-200 disabled:opacity-50 transition-colors",children:w==="uninstall"?c("marketplaceRemoving"):c("marketplaceUninstall")})]})]})}function hn(e={}){var ke,ve,we,Te,Se;const{forcedType:t}=e,n=gt(),a=ft(),{language:r}=bt(),l=kt(),g=i.useMemo(()=>t==="plugins"||t==="skills"?t:a.type==="plugins"||a.type==="skills"?a.type:null,[t,a.type]);i.useEffect(()=>{t||g||n("/marketplace/plugins",{replace:!0})},[t,g,n]);const f=g==="skills"?"skill":"plugin",d=i.useMemo(()=>Tt(r),[r]),u=f==="plugin"?{pageTitle:"marketplacePluginsPageTitle",pageDescription:"marketplacePluginsPageDescription",tabMarketplace:"marketplaceTabMarketplacePlugins",tabInstalled:"marketplaceTabInstalledPlugins",searchPlaceholder:"marketplaceSearchPlaceholderPlugins",sectionCatalog:"marketplaceSectionPlugins",sectionInstalled:"marketplaceSectionInstalledPlugins",errorLoadData:"marketplaceErrorLoadingPluginsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledPlugins",emptyData:"marketplaceNoPlugins",emptyInstalled:"marketplaceNoInstalledPlugins",installedCountSuffix:"marketplaceInstalledPluginsCountSuffix"}:{pageTitle:"marketplaceSkillsPageTitle",pageDescription:"marketplaceSkillsPageDescription",tabMarketplace:"marketplaceTabMarketplaceSkills",tabInstalled:"marketplaceTabInstalledSkills",searchPlaceholder:"marketplaceSearchPlaceholderSkills",sectionCatalog:"marketplaceSectionSkills",sectionInstalled:"marketplaceSectionInstalledSkills",errorLoadData:"marketplaceErrorLoadingSkillsData",errorLoadInstalled:"marketplaceErrorLoadingInstalledSkills",emptyData:"marketplaceNoSkills",emptyInstalled:"marketplaceNoInstalledSkills",installedCountSuffix:"marketplaceInstalledSkillsCountSuffix"},[b,v]=i.useState(""),[h,w]=i.useState(""),[m,S]=i.useState("all"),[j,P]=i.useState("relevance"),[L,C]=i.useState(1),[M,$]=i.useState(new Set),[E,ue]=i.useState(new Map);i.useEffect(()=>{const o=setTimeout(()=>{C(1),w(b.trim())},250);return()=>clearTimeout(o)},[b]),i.useEffect(()=>{C(1)},[f]);const N=an(f),R=nn({q:h||void 0,type:f,sort:j,page:L,pageSize:Ke}),Ge=sn(),Ve=rn(),{confirm:Qe,ConfirmDialog:Je}=wt(),V=i.useMemo(()=>{var o;return((o=N.data)==null?void 0:o.records)??[]},[(ke=N.data)==null?void 0:ke.records]),O=i.useMemo(()=>{var o;return((o=R.data)==null?void 0:o.items)??[]},[(ve=R.data)==null?void 0:ve.items]),de=i.useMemo(()=>dn(O),[O]),pe=i.useMemo(()=>pn(V),[V]),H=i.useMemo(()=>{const o=V.filter(p=>p.type===f).map(p=>({key:`${p.type}:${p.spec}:${p.id??""}`,record:p,item:gn(p,de)})).filter(p=>fn(p.record,p.item,h,d));return o.sort((p,y)=>{const T=p.record.installedAt?Date.parse(p.record.installedAt):Number.NaN,x=y.record.installedAt?Date.parse(y.record.installedAt):Number.NaN,D=!Number.isNaN(T),We=!Number.isNaN(x);return D&&We&&T!==x?x-T:p.record.spec.localeCompare(y.record.spec)}),o},[V,f,de,h,d]),ge=m==="installed"?H.length:((we=R.data)==null?void 0:we.total)??0,W=m==="installed"?1:((Te=R.data)==null?void 0:Te.totalPages)??0,fe=m==="all"&&R.isLoading&&!R.data,Ye=m==="installed"&&N.isLoading&&!N.data,_=fe||Ye,Xe=i.useMemo(()=>m==="installed"?N.isLoading&&!N.data?c("loading"):`${H.length} ${c(u.installedCountSuffix)}`:R.data?`${O.length} / ${ge}`:c("loading"),[m,N.data,N.isLoading,H.length,R.data,O.length,ge,u.installedCountSuffix]),me={installingSpecs:M},xe={actionsByTarget:E},Ze=[{id:"all",label:c(u.tabMarketplace)},{id:"installed",label:c(u.tabInstalled),count:((Se=N.data)==null?void 0:Se.total)??0}],he=async o=>{const p=o.install.spec;if(!M.has(p)){$(y=>{const T=new Set(y);return T.add(p),T});try{await Ge.mutateAsync({type:o.type,spec:p,kind:o.install.kind,...o.type==="skill"?{skill:o.slug,installPath:`skills/${o.slug}`}:{}})}catch{}finally{$(y=>{if(!y.has(p))return y;const T=new Set(y);return T.delete(p),T})}}},ye=async(o,p)=>{const y=p.id||p.spec;if(y&&!E.has(y)&&!(o==="uninstall"&&!await Qe({title:`${c("marketplaceUninstallTitle")} ${y}?`,description:c("marketplaceUninstallDescription"),confirmLabel:c("marketplaceUninstall"),variant:"destructive"}))){ue(T=>{const x=new Map(T);return x.set(y,o),x});try{await Ve.mutateAsync({type:p.type,action:o,id:y,spec:p.spec})}finally{ue(T=>{if(!T.has(y))return T;const x=new Map(T);return x.delete(y),x})}}},be=async(o,p)=>{const y=(o==null?void 0:o.name)??(p==null?void 0:p.label)??(p==null?void 0:p.id)??(p==null?void 0:p.spec)??c("marketplaceUnknownItem");if(!o){const x=B({title:y,typeLabel:(p==null?void 0:p.type)==="plugin"?c("marketplaceTypePlugin"):c("marketplaceTypeSkill"),spec:(p==null?void 0:p.spec)??"-",summary:c("marketplaceInstalledLocalSummary"),metadataRaw:JSON.stringify(p??{},null,2),contentRaw:"-"});l.open(x,{newTab:!0,title:y,kind:"content"});return}const T=oe(o.summaryI18n,o.summary,d);if(o.type==="skill"){try{const x=await Qt(o.slug),D=B({title:y,typeLabel:c("marketplaceTypeSkill"),spec:o.install.spec,summary:T,metadataRaw:x.metadataRaw,contentRaw:x.bodyRaw||x.raw,sourceUrl:x.sourceUrl,sourceLabel:`Source (${x.source})`,tags:o.tags,author:o.author});l.open(D,{newTab:!0,title:y,kind:"content"})}catch(x){const D=B({title:y,typeLabel:c("marketplaceTypeSkill"),spec:o.install.spec,summary:T,metadataRaw:JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),contentRaw:c("marketplaceOperationFailed")});l.open(D,{newTab:!0,title:y,kind:"content"})}return}try{const x=await Jt(o.slug),D=B({title:y,typeLabel:c("marketplaceTypePlugin"),spec:o.install.spec,summary:T,metadataRaw:x.metadataRaw,contentRaw:x.bodyRaw||x.raw||o.summary,sourceUrl:x.sourceUrl,sourceLabel:`Source (${x.source})`,tags:o.tags,author:o.author});l.open(D,{newTab:!0,title:y,kind:"content"})}catch(x){const D=B({title:y,typeLabel:c("marketplaceTypePlugin"),spec:o.install.spec,summary:T,metadataRaw:JSON.stringify({error:x instanceof Error?x.message:String(x)},null,2),contentRaw:"-"});l.open(D,{newTab:!0,title:y,kind:"content"})}};return s.jsxs(St,{className:"flex h-full min-h-0 flex-col pb-0",children:[s.jsx(Ct,{title:c(u.pageTitle),description:c(u.pageDescription)}),s.jsx(vt,{tabs:Ze,activeTab:m,onChange:o=>{S(o),C(1)},className:"mb-4"}),s.jsx(ln,{scope:m,searchText:b,searchPlaceholder:c(u.searchPlaceholder),sort:j,onSearchTextChange:v,onSortChange:o=>{C(1),P(o)}}),s.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-[14px] font-semibold text-gray-900",children:m==="installed"?c(u.sectionInstalled):c(u.sectionCatalog)}),s.jsx("span",{className:"text-[12px] text-gray-500",children:Xe})]}),m==="all"&&R.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(u.errorLoadData),": ",R.error.message]}),m==="installed"&&N.isError&&s.jsxs("div",{className:"p-4 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm",children:[c(u.errorLoadInstalled),": ",N.error.message]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1","aria-busy":_,children:[s.jsxs("div",{"data-testid":_?"marketplace-list-skeleton":void 0,className:"grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:[_&&s.jsx(on,{count:un}),!_&&m==="all"&&O.map(o=>s.jsx(je,{item:o,record:Pe(o,pe),localeFallbacks:d,installState:me,manageState:xe,onOpen:()=>void be(o,Pe(o,pe)),onInstall:he,onManage:ye},o.id)),!_&&m==="installed"&&H.map(o=>s.jsx(je,{item:o.item,record:o.record,localeFallbacks:d,installState:me,manageState:xe,onOpen:()=>void be(o.item,o.record),onInstall:he,onManage:ye},o.key))]}),m==="all"&&!_&&!R.isError&&O.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(u.emptyData)}),m==="installed"&&!_&&!N.isError&&H.length===0&&s.jsx("div",{className:"text-[13px] text-gray-500 py-8 text-center",children:c(u.emptyInstalled)})]})]}),m==="all"&&!fe&&s.jsx("div",{className:"shrink-0",children:s.jsx(cn,{page:L,totalPages:W,busy:R.isFetching,onPrev:()=>C(o=>Math.max(1,o-1)),onNext:()=>C(o=>W>0?Math.min(W,o+1):o+1)})}),s.jsx(Je,{})]})}const Cn=Object.freeze(Object.defineProperty({__proto__:null,MarketplacePage:hn},Symbol.toStringTag,{value:"Module"}));export{He as C,hn as M,zt as P,Ht as R,Gt as T,ee as a,te as b,Q as c,Bt as d,Kt as e,Cn as f,an as u};
@@ -1,4 +1,4 @@
1
- import{u as ae,f as te,g as R,e as C,r as m,j as a}from"./vendor-D_JxmsLV.js";import{P as he,a as fe}from"./page-layout-B7q511TE.js";import{T as ye}from"./tabs-custom-CgIdQMGC.js";import{U as v,t as n,m as be,k as ke,I as P,S as je,e as ve,f as we,g as Me,h as X,c as Ne,ad as se,ae as ne,af as re,ag as le,ah as ce,ai as Se,B as Y}from"./index-D41ntvb7.js";import{S as Ce}from"./switch-BLp2Pno1.js";import{S}from"./skeleton-qUJZQ03S.js";import{u as Ie}from"./useConfirmDialog-BitswAkv.js";import{b as De,p as Te,a as Pe}from"./marketplace-localization-Dk31LJJJ.js";async function Re(e){var d,o;const t=new URLSearchParams;(d=e.q)!=null&&d.trim()&&t.set("q",e.q.trim()),(o=e.tag)!=null&&o.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const c=t.toString(),i=await v.get(c?`/api/marketplace/mcp/items?${c}`:"/api/marketplace/mcp/items");if(!i.ok)throw new Error(i.error.message);return i.data}async function qe(){const e=await v.get("/api/marketplace/mcp/installed");if(!e.ok)throw new Error(e.error.message);return e.data}async function Ee(e){const t=await v.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Fe(e){const t=await v.post("/api/marketplace/mcp/install",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function $e(e){const t=await v.post("/api/marketplace/mcp/manage",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function Le(e){const t=await v.post("/api/marketplace/mcp/doctor",{name:e});if(!t.ok)throw new Error(t.error.message);return t.data}function ze(e){return ae({queryKey:["marketplace-mcp-items",e],queryFn:()=>Re(e),staleTime:15e3})}function Ae(){return ae({queryKey:["marketplace-mcp-installed"],queryFn:()=>qe(),staleTime:1e4})}function Oe(){const e=te();return R({mutationFn:Fe,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceInstallSuccessMcp"))},onError:t=>{C.error(t.message||n("marketplaceInstallFailed"))}})}function Qe(){const e=te();return R({mutationFn:$e,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceMcpManageSuccess"))},onError:t=>{C.error(t.message||n("marketplaceOperationFailed"))}})}const Ue=12;function oe(e){return(e??"").trim().toLowerCase()}function Ke(e){const t=new Map;for(const c of e){const i=[c.catalogSlug,c.spec,c.id,c.label];for(const d of i){const o=oe(d);!o||t.has(o)||t.set(o,c)}}return t}function Be(e,t){const c=[e.slug,e.install.spec,e.id,e.name];for(const i of c){const d=oe(i);if(!d)continue;const o=t.get(d);if(o)return o}}function T(e,t,c,i,d){const o=k=>k.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),y=`<!doctype html>
1
+ import{u as ae,f as te,g as R,e as C,r as m,j as a}from"./vendor-waGu-koL.js";import{P as he,a as fe}from"./page-layout-B1RIu5-r.js";import{T as ye}from"./tabs-custom-Ilrgt6n1.js";import{U as v,t as n,m as be,k as ke,I as P,S as je,e as ve,f as we,g as Me,h as X,c as Ne,ad as se,ae as ne,af as re,ag as le,ah as ce,ai as Se,B as Y}from"./index-COJomMe9.js";import{S as Ce}from"./switch-C3vVTpfU.js";import{S}from"./skeleton-D4Eyop0R.js";import{u as Ie}from"./useConfirmDialog-BeaFLDO8.js";import{b as De,p as Te,a as Pe}from"./marketplace-localization-Dk31LJJJ.js";async function Re(e){var d,o;const t=new URLSearchParams;(d=e.q)!=null&&d.trim()&&t.set("q",e.q.trim()),(o=e.tag)!=null&&o.trim()&&t.set("tag",e.tag.trim()),e.sort&&t.set("sort",e.sort),typeof e.page=="number"&&Number.isFinite(e.page)&&t.set("page",String(Math.max(1,Math.trunc(e.page)))),typeof e.pageSize=="number"&&Number.isFinite(e.pageSize)&&t.set("pageSize",String(Math.max(1,Math.trunc(e.pageSize))));const c=t.toString(),i=await v.get(c?`/api/marketplace/mcp/items?${c}`:"/api/marketplace/mcp/items");if(!i.ok)throw new Error(i.error.message);return i.data}async function qe(){const e=await v.get("/api/marketplace/mcp/installed");if(!e.ok)throw new Error(e.error.message);return e.data}async function Ee(e){const t=await v.get(`/api/marketplace/mcp/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Fe(e){const t=await v.post("/api/marketplace/mcp/install",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function $e(e){const t=await v.post("/api/marketplace/mcp/manage",{type:"mcp",...e});if(!t.ok)throw new Error(t.error.message);return t.data}async function Le(e){const t=await v.post("/api/marketplace/mcp/doctor",{name:e});if(!t.ok)throw new Error(t.error.message);return t.data}function ze(e){return ae({queryKey:["marketplace-mcp-items",e],queryFn:()=>Re(e),staleTime:15e3})}function Ae(){return ae({queryKey:["marketplace-mcp-installed"],queryFn:()=>qe(),staleTime:1e4})}function Oe(){const e=te();return R({mutationFn:Fe,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceInstallSuccessMcp"))},onError:t=>{C.error(t.message||n("marketplaceInstallFailed"))}})}function Qe(){const e=te();return R({mutationFn:$e,onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-mcp-installed"]}),e.invalidateQueries({queryKey:["marketplace-mcp-items"]}),e.invalidateQueries({queryKey:["marketplace-mcp-doctor"]}),C.success(t.message||n("marketplaceMcpManageSuccess"))},onError:t=>{C.error(t.message||n("marketplaceOperationFailed"))}})}const Ue=12;function oe(e){return(e??"").trim().toLowerCase()}function Ke(e){const t=new Map;for(const c of e){const i=[c.catalogSlug,c.spec,c.id,c.label];for(const d of i){const o=oe(d);!o||t.has(o)||t.set(o,c)}}return t}function Be(e,t){const c=[e.slug,e.install.spec,e.id,e.name];for(const i of c){const d=oe(i);if(!d)continue;const o=t.get(d);if(o)return o}}function T(e,t,c,i,d){const o=k=>k.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),y=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -1 +1 @@
1
- import{r as n,j as e,ac as W,v as z,F as q,a3 as G,ad as K,ae as Y}from"./vendor-D_JxmsLV.js";import{I as A,c as L,u as $,a as J,b as Q,d as X,t as m,C as U,S as Z,e as H,f as ee,g as se,h as te,D as ae,B as re}from"./index-D41ntvb7.js";import{L as R}from"./label-7JEFhkur.js";import{S as u}from"./skeleton-qUJZQ03S.js";import{h as _}from"./config-hints-CApS3K_7.js";import{b as le,f as oe,t as F,c as ne}from"./provider-models-BOeNnjk9.js";import{P as ce,a as ie}from"./page-layout-B7q511TE.js";function de(c){const r=new Set;for(const p of c){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:c,value:r,onChange:p,options:x,disabled:i=!1,placeholder:T,className:k,inputClassName:v,emptyText:j,createText:b,maxItems:N=Number.POSITIVE_INFINITY,onEnter:M}){const[o,l]=n.useState(!1);n.useEffect(()=>{i&&o&&l(!1)},[i,o]);const h=n.useMemo(()=>de(x),[x]),d=r.trim().toLowerCase(),a=n.useMemo(()=>{const s=h.map((f,w)=>({option:f,index:w}));d.length>0&&s.sort((f,w)=>{const S=f.option.toLowerCase(),P=w.option.toLowerCase(),D=S===d?0:S.startsWith(d)?1:S.includes(d)?2:3,I=P===d?0:P.startsWith(d)?1:P.includes(d)?2:3;return D!==I?D-I:f.index-w.index});const g=s.map(f=>f.option);return Number.isFinite(N)?g.slice(0,Math.max(1,N)):g},[h,d,N]),C=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",k),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:c,value:r,disabled:i,onFocus:()=>{i||l(!0)},onChange:s=>{p(s.target.value),!o&&!i&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(M&&(s.preventDefault(),M()),l(!1))},placeholder:T,className:L("pr-10",v)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:i,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",i?"cursor-not-allowed text-gray-300":"text-gray-400 hover:text-gray-600"),"aria-label":"toggle model options",children:e.jsx(W,{className:"h-4 w-4"})}),o&&!i&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!C&&r.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>{p(r.trim()),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:b?b.replace("{value}",r.trim()):r.trim()})]}),a.map(s=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{p(s),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:L("h-4 w-4",s===r.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:s})]},s)),a.length===0&&r.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:j??"No models available"})]})})]})}function Ne(){const{data:c,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),i=X(),[T,k]=n.useState(""),[v,j]=n.useState(""),[b,N]=n.useState(""),M=x==null?void 0:x.uiHints,o=_("agents.defaults.model",M),l=_("agents.defaults.workspace",M),h=n.useMemo(()=>le({meta:p,config:c,onlyConfigured:!0}),[c,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),C=(a==null?void 0:a.name)??"",s=n.useMemo(()=>(a==null?void 0:a.aliases)??[],[a]),g=n.useMemo(()=>(a==null?void 0:a.models)??[],[a]);n.useEffect(()=>{var E,B;if(!((E=c==null?void 0:c.agents)!=null&&E.defaults))return;const t=(c.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];k(y),j(y?F(t,V):""),N(c.agents.defaults.workspace||"")},[c,h,d]);const f=n.useMemo(()=>{const t=new Set;for(const O of g){const y=O.trim();y&&t.add(y)}return[...t]},[g]),w=n.useMemo(()=>{if(!a)return"";const t=F(v,s);return t?ne(a.prefix,t):""},[v,a,s]),S=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",P=t=>{k(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),i.mutate({model:w,workspace:b})};return r?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]})]}):e.jsxs(ce,{children:[e.jsx(ie,{title:m("modelPageTitle"),description:m("modelPageDescription")}),e.jsxs("form",{onSubmit:I,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(q,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(o==null?void 0:o.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(Z,{value:C,onValueChange:P,children:[e.jsx(H,{className:"h-10 w-full rounded-xl",children:e.jsx(ee,{placeholder:m("providersSelectPlaceholder")})}),e.jsx(se,{children:h.map(t=>e.jsx(te,{value:t.name,children:t.displayName},t.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(me,{id:"model",value:v,onChange:D,options:f,disabled:!C,placeholder:(o==null?void 0:o.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:m("modelPickerNoOptions"),createText:m("modelPickerUseCustom")},C)]}),e.jsx("p",{className:"text-xs text-gray-400",children:S}),e.jsx("p",{className:"text-xs text-gray-500",children:m("modelInputCustomHint")}),e.jsxs("a",{href:`${ae}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),m("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(K,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(l==null?void 0:l.label)??"Default Path"}),e.jsx(A,{id:"workspace",value:b,onChange:t=>N(t.target.value),placeholder:(l==null?void 0:l.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(re,{type:"submit",disabled:i.isPending,size:"lg",children:i.isPending?e.jsx(Y,{className:"h-5 w-5 animate-spin"}):m("saveChanges")})})]})]})}export{Ne as ModelConfig};
1
+ import{r as n,j as e,ac as W,v as z,F as q,a3 as G,ad as K,ae as Y}from"./vendor-waGu-koL.js";import{I as A,c as L,u as $,a as J,b as Q,d as X,t as m,C as U,S as Z,e as H,f as ee,g as se,h as te,D as ae,B as re}from"./index-COJomMe9.js";import{L as R}from"./label-BnSDpjhL.js";import{S as u}from"./skeleton-D4Eyop0R.js";import{h as _}from"./config-hints-CApS3K_7.js";import{b as le,f as oe,t as F,c as ne}from"./provider-models-BOeNnjk9.js";import{P as ce,a as ie}from"./page-layout-B1RIu5-r.js";function de(c){const r=new Set;for(const p of c){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:c,value:r,onChange:p,options:x,disabled:i=!1,placeholder:T,className:k,inputClassName:v,emptyText:j,createText:b,maxItems:N=Number.POSITIVE_INFINITY,onEnter:M}){const[o,l]=n.useState(!1);n.useEffect(()=>{i&&o&&l(!1)},[i,o]);const h=n.useMemo(()=>de(x),[x]),d=r.trim().toLowerCase(),a=n.useMemo(()=>{const s=h.map((f,w)=>({option:f,index:w}));d.length>0&&s.sort((f,w)=>{const S=f.option.toLowerCase(),P=w.option.toLowerCase(),D=S===d?0:S.startsWith(d)?1:S.includes(d)?2:3,I=P===d?0:P.startsWith(d)?1:P.includes(d)?2:3;return D!==I?D-I:f.index-w.index});const g=s.map(f=>f.option);return Number.isFinite(N)?g.slice(0,Math.max(1,N)):g},[h,d,N]),C=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",k),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:c,value:r,disabled:i,onFocus:()=>{i||l(!0)},onChange:s=>{p(s.target.value),!o&&!i&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(M&&(s.preventDefault(),M()),l(!1))},placeholder:T,className:L("pr-10",v)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:i,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",i?"cursor-not-allowed text-gray-300":"text-gray-400 hover:text-gray-600"),"aria-label":"toggle model options",children:e.jsx(W,{className:"h-4 w-4"})}),o&&!i&&e.jsx("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg",children:e.jsxs("div",{className:"max-h-60 overflow-y-auto py-1",children:[!C&&r.trim().length>0&&e.jsxs("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>{p(r.trim()),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:"h-4 w-4 text-transparent"}),e.jsx("span",{className:"truncate text-gray-700",children:b?b.replace("{value}",r.trim()):r.trim()})]}),a.map(s=>e.jsxs("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>{p(s),l(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50",children:[e.jsx(z,{className:L("h-4 w-4",s===r.trim()?"text-primary":"text-transparent")}),e.jsx("span",{className:"truncate text-gray-700",children:s})]},s)),a.length===0&&r.trim().length===0&&e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:j??"No models available"})]})})]})}function Ne(){const{data:c,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),i=X(),[T,k]=n.useState(""),[v,j]=n.useState(""),[b,N]=n.useState(""),M=x==null?void 0:x.uiHints,o=_("agents.defaults.model",M),l=_("agents.defaults.workspace",M),h=n.useMemo(()=>le({meta:p,config:c,onlyConfigured:!0}),[c,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),C=(a==null?void 0:a.name)??"",s=n.useMemo(()=>(a==null?void 0:a.aliases)??[],[a]),g=n.useMemo(()=>(a==null?void 0:a.models)??[],[a]);n.useEffect(()=>{var E,B;if(!((E=c==null?void 0:c.agents)!=null&&E.defaults))return;const t=(c.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];k(y),j(y?F(t,V):""),N(c.agents.defaults.workspace||"")},[c,h,d]);const f=n.useMemo(()=>{const t=new Set;for(const O of g){const y=O.trim();y&&t.add(y)}return[...t]},[g]),w=n.useMemo(()=>{if(!a)return"";const t=F(v,s);return t?ne(a.prefix,t):""},[v,a,s]),S=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",P=t=>{k(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),i.mutate({model:w,workspace:b})};return r?e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-8 w-32"}),e.jsx(u,{className:"h-4 w-48"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(u,{className:"h-12 w-12 rounded-xl"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"h-5 w-24"}),e.jsx(u,{className:"h-3 w-32"})]})]}),e.jsx(u,{className:"h-4 w-20 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]}),e.jsxs(U,{className:"rounded-2xl border-gray-200 p-6",children:[e.jsx(u,{className:"h-5 w-24 mb-2"}),e.jsx(u,{className:"h-10 w-full rounded-xl"})]})]}):e.jsxs(ce,{children:[e.jsx(ie,{title:m("modelPageTitle"),description:m("modelPageDescription")}),e.jsxs("form",{onSubmit:I,className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(q,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("defaultModel")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"model",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(o==null?void 0:o.label)??"Model Name"}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"sm:w-[38%] sm:min-w-[170px]",children:e.jsxs(Z,{value:C,onValueChange:P,children:[e.jsx(H,{className:"h-10 w-full rounded-xl",children:e.jsx(ee,{placeholder:m("providersSelectPlaceholder")})}),e.jsx(se,{children:h.map(t=>e.jsx(te,{value:t.name,children:t.displayName},t.name))})]})}),e.jsx("span",{className:"hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex",children:"/"}),e.jsx(me,{id:"model",value:v,onChange:D,options:f,disabled:!C,placeholder:(o==null?void 0:o.placeholder)??"gpt-5.1",className:"sm:flex-1",inputClassName:"h-10 rounded-xl",emptyText:m("modelPickerNoOptions"),createText:m("modelPickerUseCustom")},C)]}),e.jsx("p",{className:"text-xs text-gray-400",children:S}),e.jsx("p",{className:"text-xs text-gray-500",children:m("modelInputCustomHint")}),e.jsxs("a",{href:`${ae}/guide/model-selection`,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:text-primary-hover transition-colors",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),m("channelsGuideTitle")]})]})]}),e.jsxs("div",{className:"p-8 rounded-2xl bg-white border border-gray-200 shadow-card",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary flex items-center justify-center text-white",children:e.jsx(K,{className:"h-5 w-5"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:m("workspace")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"workspace",className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:(l==null?void 0:l.label)??"Default Path"}),e.jsx(A,{id:"workspace",value:b,onChange:t=>N(t.target.value),placeholder:(l==null?void 0:l.placeholder)??"/path/to/workspace",className:"rounded-xl"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(re,{type:"submit",disabled:i.isPending,size:"lg",children:i.isPending?e.jsx(Y,{className:"h-5 w-5 animate-spin"}):m("saveChanges")})})]})]})}export{Ne as ModelConfig};
@@ -1 +1 @@
1
- import{r as p,j as e,aC as St,aD as Tt,aw as et,au as ke,aE as tt,i as kt,X as Xe,f as Lt,e as R,aF as It,G as Dt,K as Et}from"./vendor-D_JxmsLV.js";import{c as ue,I as J,B as O,t as s,S as Le,e as Ie,f as De,g as Ee,h as fe,u as st,a as nt,b as rt,J as _t,K as Bt,M as $t,N as Kt,O as Ft,P as zt,Q as Ot,R as Ht}from"./index-D41ntvb7.js";import{L as z}from"./label-7JEFhkur.js";import{h as le}from"./config-hints-CApS3K_7.js";import{c as Rt,b as Wt,C as qt,a as Ut}from"./config-layout-BHnOoweL.js";import{S as Gt}from"./switch-BLp2Pno1.js";import{a as Qt,b as Vt,c as Xt}from"./popover-CywJGmPr.js";import{S as Se}from"./status-dot-BilwNdTT.js";import{T as Yt}from"./tabs-custom-CgIdQMGC.js";import{L as Jt}from"./LogoBadge-BCmJfRT8.js";import{P as Zt,a as es}from"./page-layout-B7q511TE.js";function ts({isSet:t,className:n,value:r,onChange:i,placeholder:l,...h}){const[d,c]=p.useState(!1),[g,v]=p.useState(!1),w=typeof r=="string"&&r.length>0,P=t&&!w&&!g;return e.jsxs("div",{className:"relative",children:[P?e.jsx("div",{onClick:()=>v(!0),className:ue("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",n),children:"••••••••••••"}):e.jsx(J,{type:d?"text":"password",className:ue("pr-12",n),value:r,onChange:i,onBlur:()=>{w||v(!1)},placeholder:l,autoFocus:g,...h}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||w)&&e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(!d),children:d?e.jsx(St,{className:"h-4 w-4"}):e.jsx(Tt,{className:"h-4 w-4"})})})]})}function ss({value:t,onChange:n,className:r}){const i=t?Object.entries(t):[],l=(c,g,v)=>{const w=[...i];w[c]=[g,v],n(Object.fromEntries(w))},h=()=>{n({...t,"":""})},d=c=>{const g=i.filter((v,w)=>w!==c);n(Object.fromEntries(g))};return e.jsxs("div",{className:ue("space-y-2",r),children:[i.map(([c,g],v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(J,{type:"text",value:c,onChange:w=>l(v,w.target.value,g),placeholder:s("headerName"),className:"flex-1"}),e.jsx(J,{type:"text",value:g,onChange:w=>l(v,c,w.target.value),placeholder:s("headerValue"),className:"flex-1"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(v),children:e.jsx(et,{className:"h-4 w-4 text-red-500"})})]},v)),e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:h,children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),s("add")]})]})}function at(t){const{value:n,onChange:r,options:i}=t;return e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(l=>{const h=l.value===n;return e.jsx("button",{type:"button",onClick:()=>r(l.value),"aria-pressed":h,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${h?"border-primary bg-primary text-white shadow-sm":"border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary"}`,children:l.label},l.value)})})}function ns(t){const{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:l,wireApi:h,onWireApiChange:d,shouldUseWireApiPills:c,wireApiSelectOptions:g,extraHeadersLabel:v,extraHeaders:w,onExtraHeadersChange:P}=t;return e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),s("providerAdvancedSettings")]}),e.jsx(kt,{className:`h-4 w-4 transition-transform ${n?"rotate-180":""}`})]}),n?e.jsxs("div",{className:"mt-4 space-y-5",children:[i?e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:l}),c?e.jsx(at,{value:h,onChange:C=>d(C),options:g}):e.jsxs(Le,{value:h,onValueChange:C=>d(C),children:[e.jsx(Ie,{className:"rounded-xl",children:e.jsx(De,{})}),e.jsx(Ee,{children:g.map(C=>e.jsx(fe,{value:C.value,children:C.label},C.value))})]})]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:v}),e.jsx(ss,{value:w,onChange:P}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerExtraHeadersHelpShort")})]})]}):null]})}function rs(t){const{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:l,selectedAuthMethodHint:h,shouldUseAuthMethodPills:d,resolvedAuthMethodId:c,onAuthMethodChange:g,onStartProviderAuth:v,onImportProviderAuthFromCli:w,startPending:P,importPending:C,authSessionId:b,authStatusMessage:N}=t;return(n==null?void 0:n.kind)!=="device_code"?null:e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:n.displayName||s("providerAuthSectionTitle")}),r?e.jsx("p",{className:"text-xs text-gray-600",children:r}):null,l>1?e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{className:"text-xs font-medium text-gray-700",children:s("providerAuthMethodLabel")}),d?e.jsx(at,{value:c,onChange:g,options:i}):e.jsxs(Le,{value:c,onValueChange:g,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white",children:e.jsx(De,{placeholder:s("providerAuthMethodPlaceholder")})}),e.jsx(Ee,{children:i.map(A=>e.jsx(fe,{value:A.value,children:A.label},A.value))})]}),h?e.jsx("p",{className:"text-xs text-gray-500",children:h}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:v,disabled:P||!!b,children:P?s("providerAuthStarting"):b?s("providerAuthAuthorizing"):s("providerAuthAuthorizeInBrowser")}),n.supportsCliImport?e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:w,disabled:C,children:C?s("providerAuthImporting"):s("providerAuthImportFromCli")}):null,b?e.jsxs("span",{className:"text-xs text-gray-500",children:[s("providerAuthSessionLabel"),": ",b.slice(0,8),"…"]}):null]}),N?e.jsx("p",{className:"text-xs text-gray-600",children:N}):null]})}function as(t){return e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:s("enabled")}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-500",children:t.enabled?s("enabled"):s("disabled")}),e.jsx(Gt,{checked:t.enabled,onCheckedChange:t.onChange})]})]})}const is={enabled:!0,displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},Te=["off","minimal","low","medium","high","adaptive","xhigh"],os=new Set(Te);function ce(t){if(!t)return null;const n=Object.entries(t).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return n.length===0?null:Object.fromEntries(n)}function Ye(t,n){const r=ce(t),i=ce(n);if(r===null&&i===null)return!0;if(!r||!i)return!1;const l=Object.entries(r).sort(([d],[c])=>d.localeCompare(c)),h=Object.entries(i).sort(([d],[c])=>d.localeCompare(c));return l.length!==h.length?!1:l.every(([d,c],g)=>d===h[g][0]&&c===h[g][1])}function Me(t){if(!t||t.length===0)return[];const n=new Set;for(const r of t){const i=r.trim();i&&n.add(i)}return[...n]}function ls(t,n){const r=t.trim();if(!r||!n.trim())return r;const i=`${n.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function de(t,n){let r=t.trim();if(!r)return"";for(const i of n){const l=i.trim();l&&(r=ls(r,l))}return r.trim()}function ge(t,n){return t.length!==n.length?!1:t.every((r,i)=>r===n[i])}function ds(t,n){const r=[...t];for(const i of n)r.includes(i)||r.push(i);return r}function cs(t,n){return n.length===0?t:n.every(i=>!t.includes(i))?ds(t,n):n}function us(t,n){return ge(t,n)?[]:t}function hs(t,n,r){n!==r&&(t.enabled=n)}function _e(t){if(typeof t!="string")return null;const n=t.trim().toLowerCase();return n&&os.has(n)?n:null}function it(t){if(!Array.isArray(t))return[];const n=[];for(const r of t){const i=_e(r);!i||n.includes(i)||n.push(i)}return n}function ms(t,n){if(!t)return{};const r={};for(const[i,l]of Object.entries(t)){const h=de(i,n);if(!h)continue;const d=it(l==null?void 0:l.supported);if(d.length===0)continue;const c=_e(l==null?void 0:l.default);r[h]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return r}function Pe(t,n){const r=new Set(n.map(l=>l.trim()).filter(Boolean)),i={};for(const[l,h]of Object.entries(t)){if(!r.has(l))continue;const d=it(h.supported);if(d.length===0)continue;const c=_e(h.default);i[l]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return i}function Je(t,n){const r=Object.keys(t).sort(),i=Object.keys(n).sort();if(r.length!==i.length)return!1;for(let l=0;l<r.length;l+=1){const h=r[l];if(h!==i[l])return!1;const d=t[h],c=n[h];if(!d||!c)return!1;const g=[...d.supported].sort(),v=[...c.supported].sort();if(!ge(g,v)||(d.default??null)!==(c.default??null))return!1}return!0}function xs(t){return t==="off"?s("chatThinkingLevelOff"):t==="minimal"?s("chatThinkingLevelMinimal"):t==="low"?s("chatThinkingLevelLow"):t==="medium"?s("chatThinkingLevelMedium"):t==="high"?s("chatThinkingLevelHigh"):t==="adaptive"?s("chatThinkingLevelAdaptive"):s("chatThinkingLevelXhigh")}function ps(t){var g,v,w,P,C;const{providerName:n,methods:r,defaultMethodId:i,language:l}=t;if(r.length===0)return"";const h=new Map;for(const b of r){const N=b.id.trim();N&&h.set(N.toLowerCase(),N)}const d=(...b)=>{for(const N of b){const A=h.get(N.toLowerCase());if(A)return A}},c=i==null?void 0:i.trim();if(n==="minimax-portal"){if(l==="zh")return d("cn","china-mainland")??d(c??"")??((g=r[0])==null?void 0:g.id)??"";if(l==="en")return d("global","intl","international")??d(c??"")??((v=r[0])==null?void 0:v.id)??""}if(c){const b=d(c);if(b)return b}return l==="zh"?d("cn")??((w=r[0])==null?void 0:w.id)??"":l==="en"?d("global")??((P=r[0])==null?void 0:P.id)??"":((C=r[0])==null?void 0:C.id)??""}function Ze(t){return t.required&&t.hasDefault&&t.optionCount>1&&t.optionCount<=3}function fs(t){const{models:n,modelThinking:r,modelDraft:i,showModelInput:l,onModelDraftChange:h,onShowModelInputChange:d,onAddModel:c,onRemoveModel:g,onToggleModelThinkingLevel:v,onSetModelThinkingDefault:w,thinkingLevels:P,formatThinkingLevelLabel:C}=t;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{className:"text-sm font-medium text-gray-900",children:s("providerModelsTitle")}),l?null:e.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80",children:[e.jsx(ke,{className:"h-3 w-3"}),s("providerAddModel")]})]}),l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{value:i,onChange:b=>h(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),c()),b.key==="Escape"&&(d(!1),h(""))},placeholder:s("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(O,{type:"button",size:"sm",onClick:c,disabled:i.trim().length===0,children:s("add")}),e.jsx(O,{type:"button",size:"sm",variant:"ghost",onClick:()=>{d(!1),h("")},children:e.jsx(Xe,{className:"h-4 w-4"})})]}):null,n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:s("providerModelsEmptyShort")}),l?null:e.jsx("button",{type:"button",onClick:()=>d(!0),className:"mt-2 text-sm font-medium text-primary hover:text-primary/80",children:s("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(b=>{const N=r[b],A=(N==null?void 0:N.supported)??[],K=(N==null?void 0:N.default)??null;return e.jsxs("div",{className:"group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5",children:[e.jsx("span",{className:"max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]",children:b}),e.jsxs(Qt,{children:[e.jsx(Vt,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":s("providerModelThinkingTitle"),title:s("providerModelThinkingTitle"),children:e.jsx(tt,{className:"h-3 w-3"})})}),e.jsxs(Xt,{className:"w-80 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:s("providerModelThinkingTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(S=>{const y=A.includes(S);return e.jsx("button",{type:"button",onClick:()=>v(b,S),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${y?"border-primary bg-primary text-white":"border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary"}`,children:C(S)},S)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(z,{className:"text-xs font-medium text-gray-700",children:s("providerModelThinkingDefault")}),e.jsxs(Le,{value:K??"__none__",onValueChange:S=>w(b,S==="__none__"?null:S),disabled:A.length===0,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white text-xs",children:e.jsx(De,{})}),e.jsxs(Ee,{children:[e.jsx(fe,{value:"__none__",children:s("providerModelThinkingDefaultNone")}),A.map(S=>e.jsx(fe,{value:S,children:C(S)},S))]})]}),A.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingNoSupported")}):null]})]})]}),e.jsx("button",{type:"button",onClick:()=>g(b),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":s("remove"),children:e.jsx(Xe,{className:"h-3 w-3"})})]},b)})})]})}function gs(t){return t.enabled?e.jsx(Se,{status:t.apiKeySet?"ready":"setup",label:t.apiKeySet?s("statusReady"):s("statusSetup"),className:t.className}):e.jsx(Se,{status:"inactive",label:s("disabled"),className:t.className})}function ys({providerName:t,onProviderDeleted:n}){var Re,We,qe,Ue,Ge,Qe,Ve;const r=Lt(),{data:i}=st(),{data:l}=nt(),{data:h}=rt(),d=_t(),c=Bt(),g=$t(),v=Kt(),w=Ft(),P=zt(),[C,b]=p.useState(""),[N,A]=p.useState(!0),[K,S]=p.useState(""),[y,j]=p.useState(null),[T,k]=p.useState("auto"),[M,G]=p.useState([]),[D,B]=p.useState({}),[ye,Q]=p.useState(""),[W,be]=p.useState(""),[ot,lt]=p.useState(!1),[dt,ct]=p.useState(!1),[ut,q]=p.useState(null),[ht,$]=p.useState(""),[Be,je]=p.useState(""),he=p.useRef(null),o=l==null?void 0:l.providers.find(a=>a.name===t),L=(t?i==null?void 0:i.providers[t]:null)??is,me=h==null?void 0:h.uiHints,Z=!!(o!=null&&o.isCustom),ee=t?le(`providers.${t}.apiKey`,me):void 0,H=t?le(`providers.${t}.apiBase`,me):void 0,ve=t?le(`providers.${t}.extraHeaders`,me):void 0,we=t?le(`providers.${t}.wireApi`,me):void 0,$e=(o==null?void 0:o.displayName)||t||"",te=(L.displayName||"").trim()||$e,se=L.enabled!==!1,mt=W.trim()||te||t||s("providersSelectPlaceholder"),Ke=(o==null?void 0:o.modelPrefix)||t||"",U=p.useMemo(()=>Me([Ke,t||""]),[Ke,t]),Ce=(o==null?void 0:o.defaultApiBase)||"",re=L.apiBase||Ce,Ne=ce(L.extraHeaders||null),ae=L.wireApi||(o==null?void 0:o.defaultWireApi)||"auto",Ae=p.useMemo(()=>Me(((o==null?void 0:o.defaultModels)??[]).map(a=>de(a,U))),[o==null?void 0:o.defaultModels,U]),Fe=p.useMemo(()=>Me((L.models??[]).map(a=>de(a,U))),[L.models,U]),V=p.useMemo(()=>cs(Ae,Fe),[Ae,Fe]),ie=p.useMemo(()=>Pe(ms(L.modelThinking,U),V),[V,U,L.modelThinking]),X=Ot(),xt=((Re=o==null?void 0:o.apiBaseHelp)==null?void 0:Re[X])||((We=o==null?void 0:o.apiBaseHelp)==null?void 0:We.en)||(H==null?void 0:H.help)||s("providerApiBaseHelp"),f=o==null?void 0:o.auth,E=p.useMemo(()=>(f==null?void 0:f.methods)??[],[f==null?void 0:f.methods]),pt=p.useMemo(()=>E.map(a=>{var u,m;return{value:a.id,label:((u=a.label)==null?void 0:u[X])||((m=a.label)==null?void 0:m.en)||a.id}}),[E,X]),xe=p.useMemo(()=>ps({providerName:t,methods:E,defaultMethodId:f==null?void 0:f.defaultMethodId,language:X}),[t,f==null?void 0:f.defaultMethodId,E,X]),oe=p.useMemo(()=>{var u;if(!E.length)return"";const a=Be.trim();return a&&E.some(m=>m.id===a)?a:xe||((u=E[0])==null?void 0:u.id)||""},[Be,xe,E]),ne=p.useMemo(()=>E.find(a=>a.id===oe),[E,oe]),ft=((qe=ne==null?void 0:ne.hint)==null?void 0:qe[X])||((Ue=ne==null?void 0:ne.hint)==null?void 0:Ue.en)||"",gt=Ze({required:(f==null?void 0:f.kind)==="device_code",hasDefault:!!((Ge=f==null?void 0:f.defaultMethodId)!=null&&Ge.trim()),optionCount:E.length}),yt=((Qe=f==null?void 0:f.note)==null?void 0:Qe[X])||((Ve=f==null?void 0:f.note)==null?void 0:Ve.en)||(f==null?void 0:f.displayName)||"",ze=((o==null?void 0:o.wireApiOptions)||["auto","chat","responses"]).map(a=>({value:a,label:a==="chat"?s("wireApiChat"):a==="responses"?s("wireApiResponses"):s("wireApiAuto")})),bt=Ze({required:!!(o!=null&&o.supportsWireApi),hasDefault:typeof(o==null?void 0:o.defaultWireApi)=="string"&&o.defaultWireApi.length>0,optionCount:ze.length}),_=p.useCallback(()=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null)},[]),Oe=p.useCallback((a,u)=>{_(),he.current=window.setTimeout(()=>{(async()=>{if(t)try{const m=await w.mutateAsync({provider:t,data:{sessionId:a}});if(m.status==="pending"){$(s("providerAuthWaitingBrowser")),Oe(a,m.nextPollMs??u);return}if(m.status==="authorized"){q(null),_(),$(s("providerAuthCompleted")),R.success(s("providerAuthCompleted")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]});return}q(null),_(),$(m.message||`Authorization ${m.status}.`),R.error(m.message||`Authorization ${m.status}.`)}catch(m){q(null),_();const x=m instanceof Error?m.message:String(m);$(x),R.error(`Authorization failed: ${x}`)}})()},Math.max(1e3,u))},[_,w,t,r]);p.useEffect(()=>{if(!t){b(""),A(!0),S(""),j(null),k("auto"),G([]),B({}),Q(""),be(""),q(null),$(""),je(""),_();return}b(""),A(se),S(re),j(L.extraHeaders||null),k(ae),G(V),B(ie),Q(""),be(te),q(null),$(""),je(xe),_()},[t,re,se,L.extraHeaders,ae,V,ie,te,xe,_]),p.useEffect(()=>()=>_(),[_]),p.useEffect(()=>{B(a=>Pe(a,M))},[M]);const He=p.useMemo(()=>{if(!t)return!1;const a=C.trim().length>0,u=K.trim()!==re.trim(),m=!Ye(y,Ne),x=o!=null&&o.supportsWireApi?T!==ae:!1,I=!ge(M,V),F=!Je(D,ie),pe=Z?W.trim()!==te:!1;return a||N!==se||u||m||x||I||F||pe},[t,Z,W,te,C,N,se,K,re,y,Ne,o==null?void 0:o.supportsWireApi,T,ae,M,V,D,ie]),jt=()=>{const a=de(ye,U);if(a){if(M.includes(a)){Q("");return}G(u=>[...u,a]),Q("")}},vt=(a,u)=>{B(m=>{const x=m[a],I=(x==null?void 0:x.supported)??[],F=I.includes(u)?I.filter(Y=>Y!==u):Te.filter(Y=>Y===u||I.includes(Y));if(F.length===0){const Y={...m};return delete Y[a],Y}const pe=x!=null&&x.default&&F.includes(x.default)?x.default:void 0;return{...m,[a]:pe?{supported:F,default:pe}:{supported:F}}})},wt=(a,u)=>{B(m=>{const x=m[a];return!x||x.supported.length===0||u&&!x.supported.includes(u)?m:{...m,[a]:u?{supported:x.supported,default:u}:{supported:x.supported}}})},Ct=a=>{if(a.preventDefault(),!t)return;const u={},m=C.trim(),x=K.trim(),I=ce(y),F=W.trim();Z&&F!==te&&(u.displayName=F.length>0?F:null),m.length>0&&(u.apiKey=m),hs(u,N,se),x!==re.trim()&&(u.apiBase=x.length>0&&x!==Ce?x:null),Ye(I,Ne)||(u.extraHeaders=I),o!=null&&o.supportsWireApi&&T!==ae&&(u.wireApi=T),ge(M,V)||(u.models=us(M,Ae)),Je(D,ie)||(u.modelThinking=Pe(D,M)),d.mutate({provider:t,data:u})},Nt=async()=>{if(!t)return;const a=M.find(x=>x.trim().length>0)??"",u=de(a,U),m={apiBase:K.trim(),extraHeaders:ce(y),model:u||null};C.trim().length>0&&(m.apiKey=C.trim()),o!=null&&o.supportsWireApi&&(m.wireApi=T);try{const x=await g.mutateAsync({provider:t,data:m});if(x.success){R.success(`${s("providerTestConnectionSuccess")} (${x.latencyMs}ms)`);return}const I=[`provider=${x.provider}`,`latency=${x.latencyMs}ms`];x.model&&I.push(`model=${x.model}`),R.error(`${s("providerTestConnectionFailed")}: ${x.message} | ${I.join(" | ")}`)}catch(x){const I=x instanceof Error?x.message:String(x);R.error(`${s("providerTestConnectionFailed")}: ${I}`)}},At=async()=>{if(!(!t||!Z||!window.confirm(s("providerDeleteConfirm"))))try{await c.mutateAsync({provider:t}),n==null||n(t)}catch{}},Mt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{$("");const a=await v.mutateAsync({provider:t,data:oe?{methodId:oe}:{}});if(!a.sessionId||!a.verificationUri)throw new Error(s("providerAuthStartFailed"));q(a.sessionId),$(`${s("providerAuthOpenPrompt")}${a.userCode}${s("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Oe(a.sessionId,a.intervalMs)}catch(a){const u=a instanceof Error?a.message:String(a);q(null),_(),$(u),R.error(`${s("providerAuthStartFailed")}: ${u}`)}},Pt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{_(),q(null);const a=await P.mutateAsync({provider:t}),u=a.expiresAt?` (expires: ${a.expiresAt})`:"";$(`${s("providerAuthImportStatusPrefix")}${u}`),R.success(s("providerAuthImportSuccess")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]})}catch(a){const u=a instanceof Error?a.message:String(a);$(u),R.error(`${s("providerAuthImportFailed")}: ${u}`)}};return!t||!o?e.jsx("div",{className:Rt,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:s("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:s("providersSelectDescription")})]})}):e.jsxs("div",{className:Wt,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:mt}),e.jsxs("div",{className:"flex items-center gap-3",children:[Z&&e.jsx("button",{type:"button",onClick:At,disabled:c.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:s("providerDelete"),children:e.jsx(et,{className:"h-4 w-4"})}),e.jsx(gs,{enabled:se,apiKeySet:L.apiKeySet})]})]})}),e.jsxs("form",{onSubmit:Ct,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[e.jsx(as,{enabled:N,onChange:A}),Z&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:s("providerDisplayName")}),e.jsx(J,{id:"providerDisplayName",type:"text",value:W,onChange:a=>be(a.target.value),placeholder:$e||s("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??s("apiKey")}),e.jsx(ts,{id:"apiKey",value:C,isSet:L.apiKeySet,onChange:a=>b(a.target.value),placeholder:(ee==null?void 0:ee.placeholder)??s("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("leaveBlankToKeepUnchanged")})]}),e.jsx(rs,{providerAuth:f,providerAuthNote:yt,providerAuthMethodOptions:pt,providerAuthMethodsCount:E.length,selectedAuthMethodHint:ft,shouldUseAuthMethodPills:gt,resolvedAuthMethodId:oe,onAuthMethodChange:je,onStartProviderAuth:Mt,onImportProviderAuthFromCli:Pt,startPending:v.isPending,importPending:P.isPending,authSessionId:ut,authStatusMessage:ht}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(H==null?void 0:H.label)??s("apiBase")}),e.jsx(J,{id:"apiBase",type:"text",value:K,onChange:a=>S(a.target.value),placeholder:Ce||(H==null?void 0:H.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:xt})]}),e.jsx(fs,{models:M,modelThinking:D,modelDraft:ye,showModelInput:dt,onModelDraftChange:Q,onShowModelInputChange:ct,onAddModel:jt,onRemoveModel:a=>{G(u=>u.filter(m=>m!==a)),B(u=>{const m={...u};return delete m[a],m})},onToggleModelThinkingLevel:vt,onSetModelThinkingDefault:wt,thinkingLevels:Te,formatThinkingLevelLabel:xs}),e.jsx(ns,{showAdvanced:ot,onShowAdvancedChange:lt,supportsWireApi:!!o.supportsWireApi,wireApiLabel:(we==null?void 0:we.label)??s("wireApi"),wireApi:T,onWireApiChange:k,shouldUseWireApiPills:bt,wireApiSelectOptions:ze,extraHeadersLabel:(ve==null?void 0:ve.label)??s("extraHeaders"),extraHeaders:y,onExtraHeadersChange:j})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:Nt,disabled:g.isPending,children:[e.jsx(It,{className:"mr-1.5 h-4 w-4"}),g.isPending?s("providerTestingConnection"):s("providerTestConnection")]}),e.jsx(O,{type:"submit",disabled:d.isPending||!He,children:d.isPending?s("saving"):He?s("save"):s("unchanged")})]})]})]})}function bs(t){if(!t)return null;try{const n=new URL(t),r=n.pathname&&n.pathname!=="/"?n.pathname:"";return`${n.host}${r}`}catch{return t.replace(/^https?:\/\//,"")}}function Es(){const{data:t}=st(),{data:n}=nt(),{data:r}=rt(),i=Ht(),[l,h]=p.useState("installed"),[d,c]=p.useState(),[g,v]=p.useState(""),w=r==null?void 0:r.uiHints,P=(n==null?void 0:n.providers)??[],C=(t==null?void 0:t.providers)??{},b=P.filter(y=>{const j=C[y.name];return(j==null?void 0:j.enabled)!==!1&&(j==null?void 0:j.apiKeySet)}).length,N=[{id:"installed",label:s("providersTabConfigured"),count:b},{id:"all",label:s("providersTabAll"),count:P.length}],A=p.useMemo(()=>{const y=(n==null?void 0:n.providers)??[],j=(t==null?void 0:t.providers)??{},T=g.trim().toLowerCase();return y.filter(k=>{if(l==="installed"){const M=j[k.name];return!!((M==null?void 0:M.enabled)!==!1&&(M!=null&&M.apiKeySet))}return!0}).filter(k=>{var D,B;return T?(((B=(D=j[k.name])==null?void 0:D.displayName)==null?void 0:B.trim())||k.displayName||k.name).toLowerCase().includes(T)||k.name.toLowerCase().includes(T):!0})},[n,t,l,g]);p.useEffect(()=>{if(A.length===0){c(void 0);return}A.some(j=>j.name===d)||c(A[0].name)},[A,d]);const K=d,S=async()=>{try{const y=await i.mutateAsync({data:{}});h("all"),v(""),c(y.name)}catch{}};return!t||!n?e.jsx("div",{className:"p-8",children:s("providersLoading")}):e.jsxs(Zt,{children:[e.jsx(es,{title:s("providersPageTitle"),description:s("providersPageDescription")}),e.jsxs("div",{className:qt,children:[e.jsxs("section",{className:Ut,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Yt,{tabs:N,activeTab:l,onChange:h,className:"mb-0"}),e.jsxs(O,{type:"button",variant:"outline",className:"w-full justify-center",onClick:S,disabled:i.isPending,children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),i.isPending?s("saving"):s("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(J,{value:g,onChange:y=>v(y.target.value),placeholder:s("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[A.map(y=>{var W;const j=t.providers[y.name],T=(j==null?void 0:j.enabled)!==!1,k=!!(T&&(j!=null&&j.apiKeySet)),M=K===y.name,G=((W=j==null?void 0:j.displayName)==null?void 0:W.trim())||y.displayName||y.name,D=le(`providers.${y.name}`,w),B=(j==null?void 0:j.apiBase)||y.defaultApiBase||"",Q=bs(B)||(D==null?void 0:D.help)||s("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(y.name),className:ue("w-full rounded-xl border p-2.5 text-left transition-all",M?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Jt,{name:y.name,src:y.logo?`/logos/${y.logo}`:null,className:ue("h-10 w-10 rounded-lg border",k?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:y.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:G}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:Q})]})]}),e.jsx(Se,{status:T?k?"ready":"setup":"inactive",label:T?k?s("statusReady"):s("statusSetup"):s("disabled"),className:"min-w-[56px] justify-center"})]})},y.name)}),A.length===0&&e.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Et,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:s("providersNoMatch")})]})]})]}),e.jsx(ys,{providerName:K,onProviderDeleted:y=>{y===d&&c(void 0)}})]})]})}export{Es as ProvidersList};
1
+ import{r as p,j as e,aF as St,aG as Tt,az as et,ax as ke,aH as tt,i as kt,X as Xe,f as Lt,e as R,aI as It,G as Dt,K as Et}from"./vendor-waGu-koL.js";import{c as ue,I as J,B as O,t as s,S as Le,e as Ie,f as De,g as Ee,h as fe,u as st,a as nt,b as rt,J as _t,K as Bt,M as $t,N as Kt,O as zt,P as Ft,Q as Ot,R as Ht}from"./index-COJomMe9.js";import{L as F}from"./label-BnSDpjhL.js";import{h as le}from"./config-hints-CApS3K_7.js";import{c as Rt,b as Wt,C as qt,a as Ut}from"./config-layout-BHnOoweL.js";import{S as Gt}from"./switch-C3vVTpfU.js";import{a as Qt,b as Vt,c as Xt}from"./popover-ChzbCIfO.js";import{S as Se}from"./status-dot-CrCw5tkJ.js";import{T as Yt}from"./tabs-custom-Ilrgt6n1.js";import{L as Jt}from"./LogoBadge-33Qlv3Hg.js";import{P as Zt,a as es}from"./page-layout-B1RIu5-r.js";function ts({isSet:t,className:n,value:r,onChange:i,placeholder:l,...h}){const[d,c]=p.useState(!1),[g,v]=p.useState(!1),w=typeof r=="string"&&r.length>0,P=t&&!w&&!g;return e.jsxs("div",{className:"relative",children:[P?e.jsx("div",{onClick:()=>v(!0),className:ue("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",n),children:"••••••••••••"}):e.jsx(J,{type:d?"text":"password",className:ue("pr-12",n),value:r,onChange:i,onBlur:()=>{w||v(!1)},placeholder:l,autoFocus:g,...h}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||w)&&e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(!d),children:d?e.jsx(St,{className:"h-4 w-4"}):e.jsx(Tt,{className:"h-4 w-4"})})})]})}function ss({value:t,onChange:n,className:r}){const i=t?Object.entries(t):[],l=(c,g,v)=>{const w=[...i];w[c]=[g,v],n(Object.fromEntries(w))},h=()=>{n({...t,"":""})},d=c=>{const g=i.filter((v,w)=>w!==c);n(Object.fromEntries(g))};return e.jsxs("div",{className:ue("space-y-2",r),children:[i.map(([c,g],v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(J,{type:"text",value:c,onChange:w=>l(v,w.target.value,g),placeholder:s("headerName"),className:"flex-1"}),e.jsx(J,{type:"text",value:g,onChange:w=>l(v,c,w.target.value),placeholder:s("headerValue"),className:"flex-1"}),e.jsx(O,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(v),children:e.jsx(et,{className:"h-4 w-4 text-red-500"})})]},v)),e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:h,children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),s("add")]})]})}function at(t){const{value:n,onChange:r,options:i}=t;return e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(l=>{const h=l.value===n;return e.jsx("button",{type:"button",onClick:()=>r(l.value),"aria-pressed":h,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${h?"border-primary bg-primary text-white shadow-sm":"border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary"}`,children:l.label},l.value)})})}function ns(t){const{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:l,wireApi:h,onWireApiChange:d,shouldUseWireApiPills:c,wireApiSelectOptions:g,extraHeadersLabel:v,extraHeaders:w,onExtraHeadersChange:P}=t;return e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),s("providerAdvancedSettings")]}),e.jsx(kt,{className:`h-4 w-4 transition-transform ${n?"rotate-180":""}`})]}),n?e.jsxs("div",{className:"mt-4 space-y-5",children:[i?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:l}),c?e.jsx(at,{value:h,onChange:C=>d(C),options:g}):e.jsxs(Le,{value:h,onValueChange:C=>d(C),children:[e.jsx(Ie,{className:"rounded-xl",children:e.jsx(De,{})}),e.jsx(Ee,{children:g.map(C=>e.jsx(fe,{value:C.value,children:C.label},C.value))})]})]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:v}),e.jsx(ss,{value:w,onChange:P}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerExtraHeadersHelpShort")})]})]}):null]})}function rs(t){const{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:l,selectedAuthMethodHint:h,shouldUseAuthMethodPills:d,resolvedAuthMethodId:c,onAuthMethodChange:g,onStartProviderAuth:v,onImportProviderAuthFromCli:w,startPending:P,importPending:C,authSessionId:b,authStatusMessage:N}=t;return(n==null?void 0:n.kind)!=="device_code"?null:e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:n.displayName||s("providerAuthSectionTitle")}),r?e.jsx("p",{className:"text-xs text-gray-600",children:r}):null,l>1?e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{className:"text-xs font-medium text-gray-700",children:s("providerAuthMethodLabel")}),d?e.jsx(at,{value:c,onChange:g,options:i}):e.jsxs(Le,{value:c,onValueChange:g,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white",children:e.jsx(De,{placeholder:s("providerAuthMethodPlaceholder")})}),e.jsx(Ee,{children:i.map(A=>e.jsx(fe,{value:A.value,children:A.label},A.value))})]}),h?e.jsx("p",{className:"text-xs text-gray-500",children:h}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:v,disabled:P||!!b,children:P?s("providerAuthStarting"):b?s("providerAuthAuthorizing"):s("providerAuthAuthorizeInBrowser")}),n.supportsCliImport?e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:w,disabled:C,children:C?s("providerAuthImporting"):s("providerAuthImportFromCli")}):null,b?e.jsxs("span",{className:"text-xs text-gray-500",children:[s("providerAuthSessionLabel"),": ",b.slice(0,8),"…"]}):null]}),N?e.jsx("p",{className:"text-xs text-gray-600",children:N}):null]})}function as(t){return e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:s("enabled")}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-500",children:t.enabled?s("enabled"):s("disabled")}),e.jsx(Gt,{checked:t.enabled,onCheckedChange:t.onChange})]})]})}const is={enabled:!0,displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},Te=["off","minimal","low","medium","high","adaptive","xhigh"],os=new Set(Te);function ce(t){if(!t)return null;const n=Object.entries(t).map(([r,i])=>[r.trim(),i]).filter(([r])=>r.length>0);return n.length===0?null:Object.fromEntries(n)}function Ye(t,n){const r=ce(t),i=ce(n);if(r===null&&i===null)return!0;if(!r||!i)return!1;const l=Object.entries(r).sort(([d],[c])=>d.localeCompare(c)),h=Object.entries(i).sort(([d],[c])=>d.localeCompare(c));return l.length!==h.length?!1:l.every(([d,c],g)=>d===h[g][0]&&c===h[g][1])}function Me(t){if(!t||t.length===0)return[];const n=new Set;for(const r of t){const i=r.trim();i&&n.add(i)}return[...n]}function ls(t,n){const r=t.trim();if(!r||!n.trim())return r;const i=`${n.trim()}/`;return r.startsWith(i)?r.slice(i.length):r}function de(t,n){let r=t.trim();if(!r)return"";for(const i of n){const l=i.trim();l&&(r=ls(r,l))}return r.trim()}function ge(t,n){return t.length!==n.length?!1:t.every((r,i)=>r===n[i])}function ds(t,n){const r=[...t];for(const i of n)r.includes(i)||r.push(i);return r}function cs(t,n){return n.length===0?t:n.every(i=>!t.includes(i))?ds(t,n):n}function us(t,n){return ge(t,n)?[]:t}function hs(t,n,r){n!==r&&(t.enabled=n)}function _e(t){if(typeof t!="string")return null;const n=t.trim().toLowerCase();return n&&os.has(n)?n:null}function it(t){if(!Array.isArray(t))return[];const n=[];for(const r of t){const i=_e(r);!i||n.includes(i)||n.push(i)}return n}function ms(t,n){if(!t)return{};const r={};for(const[i,l]of Object.entries(t)){const h=de(i,n);if(!h)continue;const d=it(l==null?void 0:l.supported);if(d.length===0)continue;const c=_e(l==null?void 0:l.default);r[h]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return r}function Pe(t,n){const r=new Set(n.map(l=>l.trim()).filter(Boolean)),i={};for(const[l,h]of Object.entries(t)){if(!r.has(l))continue;const d=it(h.supported);if(d.length===0)continue;const c=_e(h.default);i[l]=c&&d.includes(c)?{supported:d,default:c}:{supported:d}}return i}function Je(t,n){const r=Object.keys(t).sort(),i=Object.keys(n).sort();if(r.length!==i.length)return!1;for(let l=0;l<r.length;l+=1){const h=r[l];if(h!==i[l])return!1;const d=t[h],c=n[h];if(!d||!c)return!1;const g=[...d.supported].sort(),v=[...c.supported].sort();if(!ge(g,v)||(d.default??null)!==(c.default??null))return!1}return!0}function xs(t){return t==="off"?s("chatThinkingLevelOff"):t==="minimal"?s("chatThinkingLevelMinimal"):t==="low"?s("chatThinkingLevelLow"):t==="medium"?s("chatThinkingLevelMedium"):t==="high"?s("chatThinkingLevelHigh"):t==="adaptive"?s("chatThinkingLevelAdaptive"):s("chatThinkingLevelXhigh")}function ps(t){var g,v,w,P,C;const{providerName:n,methods:r,defaultMethodId:i,language:l}=t;if(r.length===0)return"";const h=new Map;for(const b of r){const N=b.id.trim();N&&h.set(N.toLowerCase(),N)}const d=(...b)=>{for(const N of b){const A=h.get(N.toLowerCase());if(A)return A}},c=i==null?void 0:i.trim();if(n==="minimax-portal"){if(l==="zh")return d("cn","china-mainland")??d(c??"")??((g=r[0])==null?void 0:g.id)??"";if(l==="en")return d("global","intl","international")??d(c??"")??((v=r[0])==null?void 0:v.id)??""}if(c){const b=d(c);if(b)return b}return l==="zh"?d("cn")??((w=r[0])==null?void 0:w.id)??"":l==="en"?d("global")??((P=r[0])==null?void 0:P.id)??"":((C=r[0])==null?void 0:C.id)??""}function Ze(t){return t.required&&t.hasDefault&&t.optionCount>1&&t.optionCount<=3}function fs(t){const{models:n,modelThinking:r,modelDraft:i,showModelInput:l,onModelDraftChange:h,onShowModelInputChange:d,onAddModel:c,onRemoveModel:g,onToggleModelThinkingLevel:v,onSetModelThinkingDefault:w,thinkingLevels:P,formatThinkingLevelLabel:C}=t;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(F,{className:"text-sm font-medium text-gray-900",children:s("providerModelsTitle")}),l?null:e.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80",children:[e.jsx(ke,{className:"h-3 w-3"}),s("providerAddModel")]})]}),l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{value:i,onChange:b=>h(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),c()),b.key==="Escape"&&(d(!1),h(""))},placeholder:s("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(O,{type:"button",size:"sm",onClick:c,disabled:i.trim().length===0,children:s("add")}),e.jsx(O,{type:"button",size:"sm",variant:"ghost",onClick:()=>{d(!1),h("")},children:e.jsx(Xe,{className:"h-4 w-4"})})]}):null,n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-500",children:s("providerModelsEmptyShort")}),l?null:e.jsx("button",{type:"button",onClick:()=>d(!0),className:"mt-2 text-sm font-medium text-primary hover:text-primary/80",children:s("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(b=>{const N=r[b],A=(N==null?void 0:N.supported)??[],K=(N==null?void 0:N.default)??null;return e.jsxs("div",{className:"group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5",children:[e.jsx("span",{className:"max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]",children:b}),e.jsxs(Qt,{children:[e.jsx(Vt,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":s("providerModelThinkingTitle"),title:s("providerModelThinkingTitle"),children:e.jsx(tt,{className:"h-3 w-3"})})}),e.jsxs(Xt,{className:"w-80 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:s("providerModelThinkingTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(S=>{const y=A.includes(S);return e.jsx("button",{type:"button",onClick:()=>v(b,S),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${y?"border-primary bg-primary text-white":"border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary"}`,children:C(S)},S)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{className:"text-xs font-medium text-gray-700",children:s("providerModelThinkingDefault")}),e.jsxs(Le,{value:K??"__none__",onValueChange:S=>w(b,S==="__none__"?null:S),disabled:A.length===0,children:[e.jsx(Ie,{className:"h-8 rounded-lg bg-white text-xs",children:e.jsx(De,{})}),e.jsxs(Ee,{children:[e.jsx(fe,{value:"__none__",children:s("providerModelThinkingDefaultNone")}),A.map(S=>e.jsx(fe,{value:S,children:C(S)},S))]})]}),A.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:s("providerModelThinkingNoSupported")}):null]})]})]}),e.jsx("button",{type:"button",onClick:()=>g(b),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":s("remove"),children:e.jsx(Xe,{className:"h-3 w-3"})})]},b)})})]})}function gs(t){return t.enabled?e.jsx(Se,{status:t.apiKeySet?"ready":"setup",label:t.apiKeySet?s("statusReady"):s("statusSetup"),className:t.className}):e.jsx(Se,{status:"inactive",label:s("disabled"),className:t.className})}function ys({providerName:t,onProviderDeleted:n}){var Re,We,qe,Ue,Ge,Qe,Ve;const r=Lt(),{data:i}=st(),{data:l}=nt(),{data:h}=rt(),d=_t(),c=Bt(),g=$t(),v=Kt(),w=zt(),P=Ft(),[C,b]=p.useState(""),[N,A]=p.useState(!0),[K,S]=p.useState(""),[y,j]=p.useState(null),[T,k]=p.useState("auto"),[M,G]=p.useState([]),[D,B]=p.useState({}),[ye,Q]=p.useState(""),[W,be]=p.useState(""),[ot,lt]=p.useState(!1),[dt,ct]=p.useState(!1),[ut,q]=p.useState(null),[ht,$]=p.useState(""),[Be,je]=p.useState(""),he=p.useRef(null),o=l==null?void 0:l.providers.find(a=>a.name===t),L=(t?i==null?void 0:i.providers[t]:null)??is,me=h==null?void 0:h.uiHints,Z=!!(o!=null&&o.isCustom),ee=t?le(`providers.${t}.apiKey`,me):void 0,H=t?le(`providers.${t}.apiBase`,me):void 0,ve=t?le(`providers.${t}.extraHeaders`,me):void 0,we=t?le(`providers.${t}.wireApi`,me):void 0,$e=(o==null?void 0:o.displayName)||t||"",te=(L.displayName||"").trim()||$e,se=L.enabled!==!1,mt=W.trim()||te||t||s("providersSelectPlaceholder"),Ke=(o==null?void 0:o.modelPrefix)||t||"",U=p.useMemo(()=>Me([Ke,t||""]),[Ke,t]),Ce=(o==null?void 0:o.defaultApiBase)||"",re=L.apiBase||Ce,Ne=ce(L.extraHeaders||null),ae=L.wireApi||(o==null?void 0:o.defaultWireApi)||"auto",Ae=p.useMemo(()=>Me(((o==null?void 0:o.defaultModels)??[]).map(a=>de(a,U))),[o==null?void 0:o.defaultModels,U]),ze=p.useMemo(()=>Me((L.models??[]).map(a=>de(a,U))),[L.models,U]),V=p.useMemo(()=>cs(Ae,ze),[Ae,ze]),ie=p.useMemo(()=>Pe(ms(L.modelThinking,U),V),[V,U,L.modelThinking]),X=Ot(),xt=((Re=o==null?void 0:o.apiBaseHelp)==null?void 0:Re[X])||((We=o==null?void 0:o.apiBaseHelp)==null?void 0:We.en)||(H==null?void 0:H.help)||s("providerApiBaseHelp"),f=o==null?void 0:o.auth,E=p.useMemo(()=>(f==null?void 0:f.methods)??[],[f==null?void 0:f.methods]),pt=p.useMemo(()=>E.map(a=>{var u,m;return{value:a.id,label:((u=a.label)==null?void 0:u[X])||((m=a.label)==null?void 0:m.en)||a.id}}),[E,X]),xe=p.useMemo(()=>ps({providerName:t,methods:E,defaultMethodId:f==null?void 0:f.defaultMethodId,language:X}),[t,f==null?void 0:f.defaultMethodId,E,X]),oe=p.useMemo(()=>{var u;if(!E.length)return"";const a=Be.trim();return a&&E.some(m=>m.id===a)?a:xe||((u=E[0])==null?void 0:u.id)||""},[Be,xe,E]),ne=p.useMemo(()=>E.find(a=>a.id===oe),[E,oe]),ft=((qe=ne==null?void 0:ne.hint)==null?void 0:qe[X])||((Ue=ne==null?void 0:ne.hint)==null?void 0:Ue.en)||"",gt=Ze({required:(f==null?void 0:f.kind)==="device_code",hasDefault:!!((Ge=f==null?void 0:f.defaultMethodId)!=null&&Ge.trim()),optionCount:E.length}),yt=((Qe=f==null?void 0:f.note)==null?void 0:Qe[X])||((Ve=f==null?void 0:f.note)==null?void 0:Ve.en)||(f==null?void 0:f.displayName)||"",Fe=((o==null?void 0:o.wireApiOptions)||["auto","chat","responses"]).map(a=>({value:a,label:a==="chat"?s("wireApiChat"):a==="responses"?s("wireApiResponses"):s("wireApiAuto")})),bt=Ze({required:!!(o!=null&&o.supportsWireApi),hasDefault:typeof(o==null?void 0:o.defaultWireApi)=="string"&&o.defaultWireApi.length>0,optionCount:Fe.length}),_=p.useCallback(()=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null)},[]),Oe=p.useCallback((a,u)=>{_(),he.current=window.setTimeout(()=>{(async()=>{if(t)try{const m=await w.mutateAsync({provider:t,data:{sessionId:a}});if(m.status==="pending"){$(s("providerAuthWaitingBrowser")),Oe(a,m.nextPollMs??u);return}if(m.status==="authorized"){q(null),_(),$(s("providerAuthCompleted")),R.success(s("providerAuthCompleted")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]});return}q(null),_(),$(m.message||`Authorization ${m.status}.`),R.error(m.message||`Authorization ${m.status}.`)}catch(m){q(null),_();const x=m instanceof Error?m.message:String(m);$(x),R.error(`Authorization failed: ${x}`)}})()},Math.max(1e3,u))},[_,w,t,r]);p.useEffect(()=>{if(!t){b(""),A(!0),S(""),j(null),k("auto"),G([]),B({}),Q(""),be(""),q(null),$(""),je(""),_();return}b(""),A(se),S(re),j(L.extraHeaders||null),k(ae),G(V),B(ie),Q(""),be(te),q(null),$(""),je(xe),_()},[t,re,se,L.extraHeaders,ae,V,ie,te,xe,_]),p.useEffect(()=>()=>_(),[_]),p.useEffect(()=>{B(a=>Pe(a,M))},[M]);const He=p.useMemo(()=>{if(!t)return!1;const a=C.trim().length>0,u=K.trim()!==re.trim(),m=!Ye(y,Ne),x=o!=null&&o.supportsWireApi?T!==ae:!1,I=!ge(M,V),z=!Je(D,ie),pe=Z?W.trim()!==te:!1;return a||N!==se||u||m||x||I||z||pe},[t,Z,W,te,C,N,se,K,re,y,Ne,o==null?void 0:o.supportsWireApi,T,ae,M,V,D,ie]),jt=()=>{const a=de(ye,U);if(a){if(M.includes(a)){Q("");return}G(u=>[...u,a]),Q("")}},vt=(a,u)=>{B(m=>{const x=m[a],I=(x==null?void 0:x.supported)??[],z=I.includes(u)?I.filter(Y=>Y!==u):Te.filter(Y=>Y===u||I.includes(Y));if(z.length===0){const Y={...m};return delete Y[a],Y}const pe=x!=null&&x.default&&z.includes(x.default)?x.default:void 0;return{...m,[a]:pe?{supported:z,default:pe}:{supported:z}}})},wt=(a,u)=>{B(m=>{const x=m[a];return!x||x.supported.length===0||u&&!x.supported.includes(u)?m:{...m,[a]:u?{supported:x.supported,default:u}:{supported:x.supported}}})},Ct=a=>{if(a.preventDefault(),!t)return;const u={},m=C.trim(),x=K.trim(),I=ce(y),z=W.trim();Z&&z!==te&&(u.displayName=z.length>0?z:null),m.length>0&&(u.apiKey=m),hs(u,N,se),x!==re.trim()&&(u.apiBase=x.length>0&&x!==Ce?x:null),Ye(I,Ne)||(u.extraHeaders=I),o!=null&&o.supportsWireApi&&T!==ae&&(u.wireApi=T),ge(M,V)||(u.models=us(M,Ae)),Je(D,ie)||(u.modelThinking=Pe(D,M)),d.mutate({provider:t,data:u})},Nt=async()=>{if(!t)return;const a=M.find(x=>x.trim().length>0)??"",u=de(a,U),m={apiBase:K.trim(),extraHeaders:ce(y),model:u||null};C.trim().length>0&&(m.apiKey=C.trim()),o!=null&&o.supportsWireApi&&(m.wireApi=T);try{const x=await g.mutateAsync({provider:t,data:m});if(x.success){R.success(`${s("providerTestConnectionSuccess")} (${x.latencyMs}ms)`);return}const I=[`provider=${x.provider}`,`latency=${x.latencyMs}ms`];x.model&&I.push(`model=${x.model}`),R.error(`${s("providerTestConnectionFailed")}: ${x.message} | ${I.join(" | ")}`)}catch(x){const I=x instanceof Error?x.message:String(x);R.error(`${s("providerTestConnectionFailed")}: ${I}`)}},At=async()=>{if(!(!t||!Z||!window.confirm(s("providerDeleteConfirm"))))try{await c.mutateAsync({provider:t}),n==null||n(t)}catch{}},Mt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{$("");const a=await v.mutateAsync({provider:t,data:oe?{methodId:oe}:{}});if(!a.sessionId||!a.verificationUri)throw new Error(s("providerAuthStartFailed"));q(a.sessionId),$(`${s("providerAuthOpenPrompt")}${a.userCode}${s("providerAuthOpenPromptSuffix")}`),window.open(a.verificationUri,"_blank","noopener,noreferrer"),Oe(a.sessionId,a.intervalMs)}catch(a){const u=a instanceof Error?a.message:String(a);q(null),_(),$(u),R.error(`${s("providerAuthStartFailed")}: ${u}`)}},Pt=async()=>{if(!(!t||(f==null?void 0:f.kind)!=="device_code"))try{_(),q(null);const a=await P.mutateAsync({provider:t}),u=a.expiresAt?` (expires: ${a.expiresAt})`:"";$(`${s("providerAuthImportStatusPrefix")}${u}`),R.success(s("providerAuthImportSuccess")),r.invalidateQueries({queryKey:["config"]}),r.invalidateQueries({queryKey:["config-meta"]})}catch(a){const u=a instanceof Error?a.message:String(a);$(u),R.error(`${s("providerAuthImportFailed")}: ${u}`)}};return!t||!o?e.jsx("div",{className:Rt,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:s("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:s("providersSelectDescription")})]})}):e.jsxs("div",{className:Wt,children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"truncate text-lg font-semibold text-gray-900",children:mt}),e.jsxs("div",{className:"flex items-center gap-3",children:[Z&&e.jsx("button",{type:"button",onClick:At,disabled:c.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:s("providerDelete"),children:e.jsx(et,{className:"h-4 w-4"})}),e.jsx(gs,{enabled:se,apiKeySet:L.apiKeySet})]})]})}),e.jsxs("form",{onSubmit:Ct,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[e.jsx(as,{enabled:N,onChange:A}),Z&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:s("providerDisplayName")}),e.jsx(J,{id:"providerDisplayName",type:"text",value:W,onChange:a=>be(a.target.value),placeholder:$e||s("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(ee==null?void 0:ee.label)??s("apiKey")}),e.jsx(ts,{id:"apiKey",value:C,isSet:L.apiKeySet,onChange:a=>b(a.target.value),placeholder:(ee==null?void 0:ee.placeholder)??s("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:s("leaveBlankToKeepUnchanged")})]}),e.jsx(rs,{providerAuth:f,providerAuthNote:yt,providerAuthMethodOptions:pt,providerAuthMethodsCount:E.length,selectedAuthMethodHint:ft,shouldUseAuthMethodPills:gt,resolvedAuthMethodId:oe,onAuthMethodChange:je,onStartProviderAuth:Mt,onImportProviderAuthFromCli:Pt,startPending:v.isPending,importPending:P.isPending,authSessionId:ut,authStatusMessage:ht}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(H==null?void 0:H.label)??s("apiBase")}),e.jsx(J,{id:"apiBase",type:"text",value:K,onChange:a=>S(a.target.value),placeholder:Ce||(H==null?void 0:H.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:xt})]}),e.jsx(fs,{models:M,modelThinking:D,modelDraft:ye,showModelInput:dt,onModelDraftChange:Q,onShowModelInputChange:ct,onAddModel:jt,onRemoveModel:a=>{G(u=>u.filter(m=>m!==a)),B(u=>{const m={...u};return delete m[a],m})},onToggleModelThinkingLevel:vt,onSetModelThinkingDefault:wt,thinkingLevels:Te,formatThinkingLevelLabel:xs}),e.jsx(ns,{showAdvanced:ot,onShowAdvancedChange:lt,supportsWireApi:!!o.supportsWireApi,wireApiLabel:(we==null?void 0:we.label)??s("wireApi"),wireApi:T,onWireApiChange:k,shouldUseWireApiPills:bt,wireApiSelectOptions:Fe,extraHeadersLabel:(ve==null?void 0:ve.label)??s("extraHeaders"),extraHeaders:y,onExtraHeadersChange:j})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:Nt,disabled:g.isPending,children:[e.jsx(It,{className:"mr-1.5 h-4 w-4"}),g.isPending?s("providerTestingConnection"):s("providerTestConnection")]}),e.jsx(O,{type:"submit",disabled:d.isPending||!He,children:d.isPending?s("saving"):He?s("save"):s("unchanged")})]})]})]})}function bs(t){if(!t)return null;try{const n=new URL(t),r=n.pathname&&n.pathname!=="/"?n.pathname:"";return`${n.host}${r}`}catch{return t.replace(/^https?:\/\//,"")}}function Es(){const{data:t}=st(),{data:n}=nt(),{data:r}=rt(),i=Ht(),[l,h]=p.useState("installed"),[d,c]=p.useState(),[g,v]=p.useState(""),w=r==null?void 0:r.uiHints,P=(n==null?void 0:n.providers)??[],C=(t==null?void 0:t.providers)??{},b=P.filter(y=>{const j=C[y.name];return(j==null?void 0:j.enabled)!==!1&&(j==null?void 0:j.apiKeySet)}).length,N=[{id:"installed",label:s("providersTabConfigured"),count:b},{id:"all",label:s("providersTabAll"),count:P.length}],A=p.useMemo(()=>{const y=(n==null?void 0:n.providers)??[],j=(t==null?void 0:t.providers)??{},T=g.trim().toLowerCase();return y.filter(k=>{if(l==="installed"){const M=j[k.name];return!!((M==null?void 0:M.enabled)!==!1&&(M!=null&&M.apiKeySet))}return!0}).filter(k=>{var D,B;return T?(((B=(D=j[k.name])==null?void 0:D.displayName)==null?void 0:B.trim())||k.displayName||k.name).toLowerCase().includes(T)||k.name.toLowerCase().includes(T):!0})},[n,t,l,g]);p.useEffect(()=>{if(A.length===0){c(void 0);return}A.some(j=>j.name===d)||c(A[0].name)},[A,d]);const K=d,S=async()=>{try{const y=await i.mutateAsync({data:{}});h("all"),v(""),c(y.name)}catch{}};return!t||!n?e.jsx("div",{className:"p-8",children:s("providersLoading")}):e.jsxs(Zt,{children:[e.jsx(es,{title:s("providersPageTitle"),description:s("providersPageDescription")}),e.jsxs("div",{className:qt,children:[e.jsxs("section",{className:Ut,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Yt,{tabs:N,activeTab:l,onChange:h,className:"mb-0"}),e.jsxs(O,{type:"button",variant:"outline",className:"w-full justify-center",onClick:S,disabled:i.isPending,children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),i.isPending?s("saving"):s("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(J,{value:g,onChange:y=>v(y.target.value),placeholder:s("providersFilterPlaceholder"),className:"h-10 rounded-xl pl-9"})]})}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[A.map(y=>{var W;const j=t.providers[y.name],T=(j==null?void 0:j.enabled)!==!1,k=!!(T&&(j!=null&&j.apiKeySet)),M=K===y.name,G=((W=j==null?void 0:j.displayName)==null?void 0:W.trim())||y.displayName||y.name,D=le(`providers.${y.name}`,w),B=(j==null?void 0:j.apiBase)||y.defaultApiBase||"",Q=bs(B)||(D==null?void 0:D.help)||s("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>c(y.name),className:ue("w-full rounded-xl border p-2.5 text-left transition-all",M?"border-primary/30 bg-primary-50/40 shadow-sm":"border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70"),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Jt,{name:y.name,src:y.logo?`/logos/${y.logo}`:null,className:ue("h-10 w-10 rounded-lg border",k?"border-primary/30 bg-white":"border-gray-200/70 bg-white"),imgClassName:"h-5 w-5 object-contain",fallback:e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500",children:y.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:G}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:Q})]})]}),e.jsx(Se,{status:T?k?"ready":"setup":"inactive",label:T?k?s("statusReady"):s("statusSetup"):s("disabled"),className:"min-w-[56px] justify-center"})]})},y.name)}),A.length===0&&e.jsxs("div",{className:"flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center",children:[e.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white",children:e.jsx(Et,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:s("providersNoMatch")})]})]})]}),e.jsx(ys,{providerName:K,onProviderDeleted:y=>{y===d&&c(void 0)}})]})]})}export{Es as ProvidersList};
@@ -1 +1 @@
1
- import{r as y,j as r,b5 as C,S as H,b6 as L}from"./vendor-D_JxmsLV.js";import{P as k,a as z}from"./page-layout-B7q511TE.js";import{t,a9 as T,aa as E,ab as q,ac as P,C as R,Y as j,Z as N,_ as w,y as A,i as I,B as b}from"./index-D41ntvb7.js";import{S as d}from"./status-dot-BilwNdTT.js";const M=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function B(i){var n,e;return((e=(n=i==null?void 0:i.runtime)==null?void 0:n.lastError)==null?void 0:e.trim())||""}function O(i){if(!(i!=null&&i.settings.enabled))return!1;const n=B(i);return M.some(e=>e.test(n))}function V(i){var e,a;return O(i)?{hero:{badgeStatus:"warning",badgeLabel:t("remoteStateReauthorizationRequired"),title:t("remoteStatusReauthorizationTitle"),description:t("remoteStatusReauthorizationDescription")},primaryAction:{kind:"reauthorize",label:t("remoteReauthorizeNow"),showRefreshIcon:!1},issueHint:{title:t("remoteStatusRecoveryTitle"),body:t("remoteStatusReauthorizationHint")},shouldShowIssueHint:!0,requiresReauthorization:!0}:i!=null&&i.account.loggedIn?i.settings.enabled?i.service.running?((e=i.runtime)==null?void 0:e.state)==="connected"?{hero:{badgeStatus:"ready",badgeLabel:t("statusReady"),title:t("remoteStatusReadyTitle"),description:t("remoteStatusReadyDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:((a=i.runtime)==null?void 0:a.state)==="connecting"?{hero:{badgeStatus:"active",badgeLabel:t("connecting"),title:t("remoteStatusConnectingTitle"),description:t("remoteStatusConnectingDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:"warning",badgeLabel:t("remoteStateDisconnected"),title:t("remoteStatusIssueTitle"),description:t("remoteStatusIssueDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:{title:t("remoteStatusRecoveryTitle"),body:t("remoteStatusIssueDetailGeneric")},shouldShowIssueHint:!!(i.settings.enabled&&i.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:"warning",badgeLabel:t("remoteServiceStopped"),title:t("remoteStatusNeedsServiceTitle"),description:t("remoteStatusNeedsServiceDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:{title:t("remoteStatusRecoveryTitle"),body:t("remoteStatusIssueDetailServiceStopped")},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:"inactive",badgeLabel:t("statusInactive"),title:t("remoteStatusNeedsEnable"),description:t("remoteStatusNeedsEnableDescription")},primaryAction:{kind:"enable",label:t("remoteEnableNow"),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:"setup",badgeLabel:t("statusSetup"),title:t("remoteStatusNeedsSignIn"),description:t("remoteStatusNeedsSignInDescription")},primaryAction:{kind:"sign-in-enable",label:t("remoteSignInAndEnable"),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}function s(i){const{label:n,muted:e,value:a}=i,o=a==null||a===""?"-":String(a);return r.jsxs("div",{className:"flex items-start justify-between gap-4 py-2 text-sm",children:[r.jsx("span",{className:"text-gray-500",children:n}),r.jsx("span",{className:e?"text-right text-gray-500":"text-right text-gray-900",children:o})]})}function G(){var h,p,x,S,v;const i=T(),n=E(),e=n.data,a=q(c=>c.actionLabel),o=y.useMemo(()=>V(e),[e]),m=!!a,g=((p=(h=e==null?void 0:e.runtime)==null?void 0:h.deviceName)==null?void 0:p.trim())||((x=e==null?void 0:e.settings.deviceName)==null?void 0:x.trim())||t("remoteDeviceNameAuto"),D=!!(e!=null&&e.account.loggedIn&&P(e)),{hero:l,issueHint:u}=o;return y.useEffect(()=>{i.remoteAccessManager.syncStatus(e)},[i,e]),n.isLoading&&!e?r.jsx("div",{className:"p-8 text-gray-400",children:t("remoteLoading")}):r.jsxs(k,{className:"space-y-6",children:[r.jsx(z,{title:t("remotePageTitle"),description:t("remotePageDescription")}),r.jsxs("div",{className:"grid gap-6 xl:grid-cols-[1.2fr_0.8fr]",children:[r.jsxs(R,{children:[r.jsxs(j,{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(N,{children:l.title}),r.jsx(d,{status:l.badgeStatus,label:l.badgeLabel})]}),r.jsx(w,{children:l.description})]}),r.jsxs(A,{className:"space-y-5",children:[r.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[r.jsx(s,{label:t("remoteSignedInAccount"),value:e==null?void 0:e.account.email}),r.jsx(s,{label:t("remoteDeviceName"),value:g}),r.jsx(s,{label:t("remoteConnectionStatus"),value:l.badgeLabel}),r.jsx(s,{label:t("remoteLastConnectedAt"),value:(S=e==null?void 0:e.runtime)!=null&&S.lastConnectedAt?I(e.runtime.lastConnectedAt):"-",muted:!0})]}),r.jsxs("div",{className:"flex flex-wrap gap-3",children:[o.primaryAction?r.jsxs(b,{onClick:()=>{var c,f;if(((c=o.primaryAction)==null?void 0:c.kind)==="reauthorize"){i.remoteAccessManager.reauthorizeRemoteAccess(e);return}if(((f=o.primaryAction)==null?void 0:f.kind)==="repair"){i.remoteAccessManager.repairRemoteAccess(e);return}i.remoteAccessManager.enableRemoteAccess(e)},disabled:m,children:[o.primaryAction.showRefreshIcon?r.jsx(C,{className:"mr-2 h-4 w-4"}):null,a||o.primaryAction.label]}):null,r.jsxs(b,{variant:"outline",onClick:()=>void i.accountManager.openNextClawWeb(),disabled:m||!D,children:[r.jsx(H,{className:"mr-2 h-4 w-4"}),t("remoteOpenDeviceList")]}),e!=null&&e.settings.enabled?r.jsx(b,{variant:"outline",onClick:()=>void i.remoteAccessManager.disableRemoteAccess(e),disabled:m,children:t("remoteDisable")}):null]}),o.shouldShowIssueHint&&u?r.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3",children:[r.jsx("p",{className:"text-sm font-medium text-amber-900",children:u.title}),r.jsx("p",{className:"mt-1 text-sm leading-6 text-amber-800",children:u.body})]}):null,r.jsx("p",{className:"text-xs text-gray-500",children:t("remoteOpenWebHint")})]})]}),r.jsxs(R,{children:[r.jsxs(j,{children:[r.jsxs(N,{className:"flex items-center gap-2",children:[r.jsx(L,{className:"h-4 w-4 text-primary"}),t("remoteDeviceSectionTitle")]}),r.jsx(w,{children:t("remoteDeviceSectionDescription")})]}),r.jsxs(A,{className:"space-y-5",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(d,{status:e!=null&&e.account.loggedIn?"ready":"inactive",label:e!=null&&e.account.loggedIn?t("remoteAccountConnected"):t("remoteAccountNotConnected")}),r.jsx(d,{status:e!=null&&e.settings.enabled?"active":"inactive",label:e!=null&&e.settings.enabled?t("remoteEnabled"):t("remoteStateDisabled")}),r.jsx(d,{status:e!=null&&e.service.running?"active":"inactive",label:e!=null&&e.service.running?t("remoteServiceRunning"):t("remoteServiceStopped")})]}),r.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[r.jsx(s,{label:t("remoteDeviceName"),value:g}),r.jsx(s,{label:t("remoteConnectionStatus"),value:l.badgeLabel}),r.jsx(s,{label:t("remoteLastConnectedAt"),value:(v=e==null?void 0:e.runtime)!=null&&v.lastConnectedAt?I(e.runtime.lastConnectedAt):"-",muted:!0})]}),r.jsx("div",{className:"rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600",children:e!=null&&e.account.loggedIn?t("remoteOpenWebHint"):t("remoteStatusNeedsSignInDescription")})]})]})]})]})}export{G as RemoteAccessPage};
1
+ import{r as y,j as r,b8 as C,S as H,b9 as L}from"./vendor-waGu-koL.js";import{P as k,a as z}from"./page-layout-B1RIu5-r.js";import{t,a9 as T,aa as E,ab as q,ac as P,C as R,Y as j,Z as N,_ as w,y as A,i as I,B as b}from"./index-COJomMe9.js";import{S as d}from"./status-dot-CrCw5tkJ.js";const M=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function B(i){var n,e;return((e=(n=i==null?void 0:i.runtime)==null?void 0:n.lastError)==null?void 0:e.trim())||""}function O(i){if(!(i!=null&&i.settings.enabled))return!1;const n=B(i);return M.some(e=>e.test(n))}function V(i){var e,a;return O(i)?{hero:{badgeStatus:"warning",badgeLabel:t("remoteStateReauthorizationRequired"),title:t("remoteStatusReauthorizationTitle"),description:t("remoteStatusReauthorizationDescription")},primaryAction:{kind:"reauthorize",label:t("remoteReauthorizeNow"),showRefreshIcon:!1},issueHint:{title:t("remoteStatusRecoveryTitle"),body:t("remoteStatusReauthorizationHint")},shouldShowIssueHint:!0,requiresReauthorization:!0}:i!=null&&i.account.loggedIn?i.settings.enabled?i.service.running?((e=i.runtime)==null?void 0:e.state)==="connected"?{hero:{badgeStatus:"ready",badgeLabel:t("statusReady"),title:t("remoteStatusReadyTitle"),description:t("remoteStatusReadyDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:((a=i.runtime)==null?void 0:a.state)==="connecting"?{hero:{badgeStatus:"active",badgeLabel:t("connecting"),title:t("remoteStatusConnectingTitle"),description:t("remoteStatusConnectingDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:"warning",badgeLabel:t("remoteStateDisconnected"),title:t("remoteStatusIssueTitle"),description:t("remoteStatusIssueDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:{title:t("remoteStatusRecoveryTitle"),body:t("remoteStatusIssueDetailGeneric")},shouldShowIssueHint:!!(i.settings.enabled&&i.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:"warning",badgeLabel:t("remoteServiceStopped"),title:t("remoteStatusNeedsServiceTitle"),description:t("remoteStatusNeedsServiceDescription")},primaryAction:{kind:"repair",label:t("remoteReconnectNow"),showRefreshIcon:!0},issueHint:{title:t("remoteStatusRecoveryTitle"),body:t("remoteStatusIssueDetailServiceStopped")},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:"inactive",badgeLabel:t("statusInactive"),title:t("remoteStatusNeedsEnable"),description:t("remoteStatusNeedsEnableDescription")},primaryAction:{kind:"enable",label:t("remoteEnableNow"),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:"setup",badgeLabel:t("statusSetup"),title:t("remoteStatusNeedsSignIn"),description:t("remoteStatusNeedsSignInDescription")},primaryAction:{kind:"sign-in-enable",label:t("remoteSignInAndEnable"),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}function s(i){const{label:n,muted:e,value:a}=i,o=a==null||a===""?"-":String(a);return r.jsxs("div",{className:"flex items-start justify-between gap-4 py-2 text-sm",children:[r.jsx("span",{className:"text-gray-500",children:n}),r.jsx("span",{className:e?"text-right text-gray-500":"text-right text-gray-900",children:o})]})}function G(){var h,p,x,S,v;const i=T(),n=E(),e=n.data,a=q(c=>c.actionLabel),o=y.useMemo(()=>V(e),[e]),m=!!a,g=((p=(h=e==null?void 0:e.runtime)==null?void 0:h.deviceName)==null?void 0:p.trim())||((x=e==null?void 0:e.settings.deviceName)==null?void 0:x.trim())||t("remoteDeviceNameAuto"),D=!!(e!=null&&e.account.loggedIn&&P(e)),{hero:l,issueHint:u}=o;return y.useEffect(()=>{i.remoteAccessManager.syncStatus(e)},[i,e]),n.isLoading&&!e?r.jsx("div",{className:"p-8 text-gray-400",children:t("remoteLoading")}):r.jsxs(k,{className:"space-y-6",children:[r.jsx(z,{title:t("remotePageTitle"),description:t("remotePageDescription")}),r.jsxs("div",{className:"grid gap-6 xl:grid-cols-[1.2fr_0.8fr]",children:[r.jsxs(R,{children:[r.jsxs(j,{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(N,{children:l.title}),r.jsx(d,{status:l.badgeStatus,label:l.badgeLabel})]}),r.jsx(w,{children:l.description})]}),r.jsxs(A,{className:"space-y-5",children:[r.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[r.jsx(s,{label:t("remoteSignedInAccount"),value:e==null?void 0:e.account.email}),r.jsx(s,{label:t("remoteDeviceName"),value:g}),r.jsx(s,{label:t("remoteConnectionStatus"),value:l.badgeLabel}),r.jsx(s,{label:t("remoteLastConnectedAt"),value:(S=e==null?void 0:e.runtime)!=null&&S.lastConnectedAt?I(e.runtime.lastConnectedAt):"-",muted:!0})]}),r.jsxs("div",{className:"flex flex-wrap gap-3",children:[o.primaryAction?r.jsxs(b,{onClick:()=>{var c,f;if(((c=o.primaryAction)==null?void 0:c.kind)==="reauthorize"){i.remoteAccessManager.reauthorizeRemoteAccess(e);return}if(((f=o.primaryAction)==null?void 0:f.kind)==="repair"){i.remoteAccessManager.repairRemoteAccess(e);return}i.remoteAccessManager.enableRemoteAccess(e)},disabled:m,children:[o.primaryAction.showRefreshIcon?r.jsx(C,{className:"mr-2 h-4 w-4"}):null,a||o.primaryAction.label]}):null,r.jsxs(b,{variant:"outline",onClick:()=>void i.accountManager.openNextClawWeb(),disabled:m||!D,children:[r.jsx(H,{className:"mr-2 h-4 w-4"}),t("remoteOpenDeviceList")]}),e!=null&&e.settings.enabled?r.jsx(b,{variant:"outline",onClick:()=>void i.remoteAccessManager.disableRemoteAccess(e),disabled:m,children:t("remoteDisable")}):null]}),o.shouldShowIssueHint&&u?r.jsxs("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3",children:[r.jsx("p",{className:"text-sm font-medium text-amber-900",children:u.title}),r.jsx("p",{className:"mt-1 text-sm leading-6 text-amber-800",children:u.body})]}):null,r.jsx("p",{className:"text-xs text-gray-500",children:t("remoteOpenWebHint")})]})]}),r.jsxs(R,{children:[r.jsxs(j,{children:[r.jsxs(N,{className:"flex items-center gap-2",children:[r.jsx(L,{className:"h-4 w-4 text-primary"}),t("remoteDeviceSectionTitle")]}),r.jsx(w,{children:t("remoteDeviceSectionDescription")})]}),r.jsxs(A,{className:"space-y-5",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(d,{status:e!=null&&e.account.loggedIn?"ready":"inactive",label:e!=null&&e.account.loggedIn?t("remoteAccountConnected"):t("remoteAccountNotConnected")}),r.jsx(d,{status:e!=null&&e.settings.enabled?"active":"inactive",label:e!=null&&e.settings.enabled?t("remoteEnabled"):t("remoteStateDisabled")}),r.jsx(d,{status:e!=null&&e.service.running?"active":"inactive",label:e!=null&&e.service.running?t("remoteServiceRunning"):t("remoteServiceStopped")})]}),r.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3",children:[r.jsx(s,{label:t("remoteDeviceName"),value:g}),r.jsx(s,{label:t("remoteConnectionStatus"),value:l.badgeLabel}),r.jsx(s,{label:t("remoteLastConnectedAt"),value:(v=e==null?void 0:e.runtime)!=null&&v.lastConnectedAt?I(e.runtime.lastConnectedAt):"-",muted:!0})]}),r.jsx("div",{className:"rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600",children:e!=null&&e.account.loggedIn?t("remoteOpenWebHint"):t("remoteStatusNeedsSignInDescription")})]})]})]})]})}export{G as RemoteAccessPage};
@@ -1 +1 @@
1
- import{r as p,j as e,aw as ee,au as ae,b2 as de,e as se}from"./vendor-D_JxmsLV.js";import{u as me,b as he,X as ue,t,C as R,Y as $,Z as z,_ as D,y as L,I as i,S as te,e as re,f as ne,g as le,h as w,B as S}from"./index-D41ntvb7.js";import{S as pe}from"./switch-BLp2Pno1.js";import{h as x}from"./config-hints-CApS3K_7.js";import{P as xe,a as ge}from"./page-layout-B7q511TE.js";const je=[{value:"main",label:"main"},{value:"per-peer",label:"per-peer"},{value:"per-channel-peer",label:"per-channel-peer"},{value:"per-account-channel-peer",label:"per-account-channel-peer"}];function ve(){return{id:"",default:!1,workspace:"",model:"",engine:"",contextTokens:void 0,maxToolIterations:void 0}}function fe(){return{agentId:"",match:{channel:"",accountId:""}}}function ce(d){const b=d.trim();if(!b)return;const j=Number.parseInt(b,10);return Number.isFinite(j)?j:void 0}function Ce(){const{data:d,isLoading:b}=me(),{data:j}=he(),A=ue(),[_,N]=p.useState([]),[q,E]=p.useState([]),[K,F]=p.useState("per-channel-peer"),[V,U]=p.useState(0),[X,Y]=p.useState(2e5),[Z,G]=p.useState("native");p.useEffect(()=>{var a,r,n;d&&(N((d.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",engine:s.engine??"",contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),E((d.bindings??[]).map(s=>{var c,l,o;return{agentId:s.agentId??"",match:{channel:((c=s.match)==null?void 0:c.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(o=s.match)!=null&&o.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),F(((a=d.session)==null?void 0:a.dmScope)??"per-channel-peer"),U(((n=(r=d.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),Y(d.agents.defaults.contextTokens??2e5),G(d.agents.defaults.engine??"native"))},[d]);const u=j==null?void 0:j.uiHints,h=x("session.dmScope",u),v=x("session.agentToAgent.maxPingPongTurns",u),f=x("agents.defaults.contextTokens",u),I=x("agents.defaults.engine",u),O=x("agents.list.*.contextTokens",u),B=x("agents.list.*.engine",u),y=x("agents.list",u),k=x("bindings",u),oe=p.useMemo(()=>{const a=new Set(["main"]);return _.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[_]),g=(a,r)=>{N(n=>n.map((s,c)=>c===a?{...s,...r}:s))},T=(a,r)=>{E(n=>n.map((s,c)=>c===a?r:s))},ie=()=>{try{const a=_.map((s,c)=>{var m,C,P;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(c)));const o={id:l};return s.default&&(o.default=!0),(m=s.workspace)!=null&&m.trim()&&(o.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(o.model=s.model.trim()),(P=s.engine)!=null&&P.trim()&&(o.engine=s.engine.trim()),typeof s.contextTokens=="number"&&(o.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(o.maxToolIterations=s.maxToolIterations),o}),r=a.map(s=>s.id).filter((s,c,l)=>l.indexOf(s)!==c);if(r.length>0){se.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=q.map((s,c)=>{var J,Q,W,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((J=s.match.accountId)==null?void 0:J.trim())??"",C=(Q=s.match.peer)==null?void 0:Q.kind,P=((H=(W=s.match.peer)==null?void 0:W.id)==null?void 0:H.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(c)));if(!oe.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(c))}: ${l}`);if(!o)throw new Error(t("bindingChannelRequired").replace("{index}",String(c)));const M={agentId:l,match:{channel:o}};if(m&&(M.match.accountId=m),C){if(!P)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(c)));M.match.peer={kind:C,id:P}}return M});A.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,X),engine:Z.trim()||"native"},list:a},bindings:n,session:{dmScope:K,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,V))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);se.error(r)}};return b||!d?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(xe,{className:"space-y-6",children:[e.jsx(ge,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(D,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(f==null?void 0:f.label)??t("defaultContextTokens")}),e.jsx(i,{type:"number",min:1e3,step:1e3,value:X,onChange:a=>Y(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("defaultContextTokensHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(I==null?void 0:I.label)??t("defaultEngine")}),e.jsx(i,{value:Z,onChange:a=>G(a.target.value),placeholder:t("defaultEnginePlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500",children:(I==null?void 0:I.help)??t("defaultEngineHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(h==null?void 0:h.label)??t("dmScope")}),e.jsxs(te,{value:K,onValueChange:a=>F(a),children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsx(le,{children:je.map(a=>e.jsx(w,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(v==null?void 0:v.label)??t("maxPingPongTurns")}),e.jsx(i,{type:"number",min:0,max:5,value:V,onChange:a=>U(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(v==null?void 0:v.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(y==null?void 0:y.label)??t("agentList")}),e.jsx(D,{children:(y==null?void 0:y.help)??t("agentListHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[_.map((a,r)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(i,{value:a.id,onChange:n=>g(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(i,{value:a.workspace??"",onChange:n=>g(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(i,{value:a.model??"",onChange:n=>g(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsx(i,{value:a.engine??"",onChange:n=>g(r,{engine:n.target.value}),placeholder:(B==null?void 0:B.label)??t("engineOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(i,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>g(r,{contextTokens:ce(n.target.value)}),placeholder:(O==null?void 0:O.label)??t("contextTokensPlaceholder")}),e.jsx(i,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>g(r,{maxToolIterations:ce(n.target.value)}),placeholder:t("maxToolsPlaceholder")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(pe,{checked:!!a.default,onCheckedChange:n=>{if(!n){g(r,{default:!1});return}N(s=>s.map((c,l)=>({...c,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>N(n=>n.filter((s,c)=>c!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(S,{type:"button",variant:"outline",onClick:()=>N(a=>[...a,ve()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(D,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[q.map((a,r)=>{var s,c;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(i,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(i,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(i,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(te,{value:n||"__none__",onValueChange:l=>{var m;const o=l==="__none__"?"":l;if(!o){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:o,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsxs(le,{children:[e.jsx(w,{value:"__none__",children:t("peerKindOptional")}),e.jsx(w,{value:"direct",children:"direct"}),e.jsx(w,{value:"group",children:"group"}),e.jsx(w,{value:"channel",children:"channel"})]})]}),e.jsx(i,{value:((c=a.match.peer)==null?void 0:c.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>E(l=>l.filter((o,m)=>m!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(S,{type:"button",variant:"outline",onClick:()=>E(a=>[...a,fe()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(S,{type:"button",onClick:ie,disabled:A.isPending,children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),A.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{Ce as RuntimeConfig};
1
+ import{r as p,j as e,az as ee,ax as ae,b5 as de,e as se}from"./vendor-waGu-koL.js";import{u as me,b as he,X as ue,t,C as R,Y as $,Z as z,_ as D,y as L,I as i,S as te,e as re,f as ne,g as le,h as S,B as w}from"./index-COJomMe9.js";import{S as pe}from"./switch-C3vVTpfU.js";import{h as x}from"./config-hints-CApS3K_7.js";import{P as xe,a as ge}from"./page-layout-B1RIu5-r.js";const je=[{value:"main",label:"main"},{value:"per-peer",label:"per-peer"},{value:"per-channel-peer",label:"per-channel-peer"},{value:"per-account-channel-peer",label:"per-account-channel-peer"}];function ve(){return{id:"",default:!1,workspace:"",model:"",engine:"",contextTokens:void 0,maxToolIterations:void 0}}function fe(){return{agentId:"",match:{channel:"",accountId:""}}}function ce(d){const b=d.trim();if(!b)return;const j=Number.parseInt(b,10);return Number.isFinite(j)?j:void 0}function Ce(){const{data:d,isLoading:b}=me(),{data:j}=he(),A=ue(),[_,N]=p.useState([]),[q,E]=p.useState([]),[K,F]=p.useState("per-channel-peer"),[V,U]=p.useState(0),[X,Y]=p.useState(2e5),[Z,G]=p.useState("native");p.useEffect(()=>{var a,r,n;d&&(N((d.agents.list??[]).map(s=>({id:s.id??"",default:!!s.default,workspace:s.workspace??"",model:s.model??"",engine:s.engine??"",contextTokens:s.contextTokens,maxToolIterations:s.maxToolIterations}))),E((d.bindings??[]).map(s=>{var c,l,o;return{agentId:s.agentId??"",match:{channel:((c=s.match)==null?void 0:c.channel)??"",accountId:((l=s.match)==null?void 0:l.accountId)??"",peer:(o=s.match)!=null&&o.peer?{kind:s.match.peer.kind,id:s.match.peer.id}:void 0}}})),F(((a=d.session)==null?void 0:a.dmScope)??"per-channel-peer"),U(((n=(r=d.session)==null?void 0:r.agentToAgent)==null?void 0:n.maxPingPongTurns)??0),Y(d.agents.defaults.contextTokens??2e5),G(d.agents.defaults.engine??"native"))},[d]);const u=j==null?void 0:j.uiHints,h=x("session.dmScope",u),v=x("session.agentToAgent.maxPingPongTurns",u),f=x("agents.defaults.contextTokens",u),I=x("agents.defaults.engine",u),O=x("agents.list.*.contextTokens",u),B=x("agents.list.*.engine",u),y=x("agents.list",u),k=x("bindings",u),oe=p.useMemo(()=>{const a=new Set(["main"]);return _.forEach(r=>{const n=r.id.trim();n&&a.add(n)}),a},[_]),g=(a,r)=>{N(n=>n.map((s,c)=>c===a?{...s,...r}:s))},T=(a,r)=>{E(n=>n.map((s,c)=>c===a?r:s))},ie=()=>{try{const a=_.map((s,c)=>{var m,C,P;const l=s.id.trim();if(!l)throw new Error(t("agentIdRequiredError").replace("{index}",String(c)));const o={id:l};return s.default&&(o.default=!0),(m=s.workspace)!=null&&m.trim()&&(o.workspace=s.workspace.trim()),(C=s.model)!=null&&C.trim()&&(o.model=s.model.trim()),(P=s.engine)!=null&&P.trim()&&(o.engine=s.engine.trim()),typeof s.contextTokens=="number"&&(o.contextTokens=Math.max(1e3,s.contextTokens)),typeof s.maxToolIterations=="number"&&(o.maxToolIterations=s.maxToolIterations),o}),r=a.map(s=>s.id).filter((s,c,l)=>l.indexOf(s)!==c);if(r.length>0){se.error(`${t("duplicateAgentId")}: ${r[0]}`);return}const n=q.map((s,c)=>{var J,Q,W,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((J=s.match.accountId)==null?void 0:J.trim())??"",C=(Q=s.match.peer)==null?void 0:Q.kind,P=((H=(W=s.match.peer)==null?void 0:W.id)==null?void 0:H.trim())??"";if(!l)throw new Error(t("bindingAgentIdRequired").replace("{index}",String(c)));if(!oe.has(l))throw new Error(`${t("bindingAgentIdNotFound").replace("{index}",String(c))}: ${l}`);if(!o)throw new Error(t("bindingChannelRequired").replace("{index}",String(c)));const M={agentId:l,match:{channel:o}};if(m&&(M.match.accountId=m),C){if(!P)throw new Error(t("bindingPeerIdRequired").replace("{index}",String(c)));M.match.peer={kind:C,id:P}}return M});A.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,X),engine:Z.trim()||"native"},list:a},bindings:n,session:{dmScope:K,agentToAgent:{maxPingPongTurns:Math.min(5,Math.max(0,V))}}}})}catch(a){const r=a instanceof Error?a.message:String(a);se.error(r)}};return b||!d?e.jsx("div",{className:"p-8 text-gray-400",children:t("runtimeLoading")}):e.jsxs(xe,{className:"space-y-6",children:[e.jsx(ge,{title:t("runtimePageTitle"),description:t("runtimePageDescription")}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(h==null?void 0:h.label)??t("dmScope")}),e.jsx(D,{children:(h==null?void 0:h.help)??t("dmScopeHelp")})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(f==null?void 0:f.label)??t("defaultContextTokens")}),e.jsx(i,{type:"number",min:1e3,step:1e3,value:X,onChange:a=>Y(Math.max(1e3,Number.parseInt(a.target.value,10)||1e3))}),e.jsx("p",{className:"text-xs text-gray-500",children:(f==null?void 0:f.help)??t("defaultContextTokensHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(I==null?void 0:I.label)??t("defaultEngine")}),e.jsx(i,{value:Z,onChange:a=>G(a.target.value),placeholder:t("defaultEnginePlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500",children:(I==null?void 0:I.help)??t("defaultEngineHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(h==null?void 0:h.label)??t("dmScope")}),e.jsxs(te,{value:K,onValueChange:a=>F(a),children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsx(le,{children:je.map(a=>e.jsx(S,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-800",children:(v==null?void 0:v.label)??t("maxPingPongTurns")}),e.jsx(i,{type:"number",min:0,max:5,value:V,onChange:a=>U(Math.max(0,Number.parseInt(a.target.value,10)||0))}),e.jsx("p",{className:"text-xs text-gray-500",children:(v==null?void 0:v.help)??t("maxPingPongTurnsHelp")})]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(y==null?void 0:y.label)??t("agentList")}),e.jsx(D,{children:(y==null?void 0:y.help)??t("agentListHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[_.map((a,r)=>e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(i,{value:a.id,onChange:n=>g(r,{id:n.target.value}),placeholder:t("agentIdPlaceholder")}),e.jsx(i,{value:a.workspace??"",onChange:n=>g(r,{workspace:n.target.value}),placeholder:t("workspaceOverridePlaceholder")}),e.jsx(i,{value:a.model??"",onChange:n=>g(r,{model:n.target.value}),placeholder:t("modelOverridePlaceholder")}),e.jsx(i,{value:a.engine??"",onChange:n=>g(r,{engine:n.target.value}),placeholder:(B==null?void 0:B.label)??t("engineOverridePlaceholder")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(i,{type:"number",min:1e3,step:1e3,value:a.contextTokens??"",onChange:n=>g(r,{contextTokens:ce(n.target.value)}),placeholder:(O==null?void 0:O.label)??t("contextTokensPlaceholder")}),e.jsx(i,{type:"number",min:1,value:a.maxToolIterations??"",onChange:n=>g(r,{maxToolIterations:ce(n.target.value)}),placeholder:t("maxToolsPlaceholder")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(pe,{checked:!!a.default,onCheckedChange:n=>{if(!n){g(r,{default:!1});return}N(s=>s.map((c,l)=>({...c,default:l===r})))}}),e.jsx("span",{children:t("defaultAgent")})]}),e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>N(n=>n.filter((s,c)=>c!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})]})]},`${r}-${a.id}`)),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>N(a=>[...a,ve()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addAgent")]})]})]}),e.jsxs(R,{children:[e.jsxs($,{children:[e.jsx(z,{children:(k==null?void 0:k.label)??t("bindings")}),e.jsx(D,{children:(k==null?void 0:k.help)??t("bindingsHelp")})]}),e.jsxs(L,{className:"space-y-3",children:[q.map((a,r)=>{var s,c;const n=((s=a.match.peer)==null?void 0:s.kind)??"";return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(i,{value:a.agentId,onChange:l=>T(r,{...a,agentId:l.target.value}),placeholder:t("targetAgentIdPlaceholder")}),e.jsx(i,{value:a.match.channel,onChange:l=>T(r,{...a,match:{...a.match,channel:l.target.value}}),placeholder:t("channelPlaceholder")}),e.jsx(i,{value:a.match.accountId??"",onChange:l=>T(r,{...a,match:{...a.match,accountId:l.target.value}}),placeholder:t("accountIdOptionalPlaceholder")}),e.jsxs(te,{value:n||"__none__",onValueChange:l=>{var m;const o=l==="__none__"?"":l;if(!o){T(r,{...a,match:{...a.match,peer:void 0}});return}T(r,{...a,match:{...a.match,peer:{kind:o,id:((m=a.match.peer)==null?void 0:m.id)??""}}})},children:[e.jsx(re,{children:e.jsx(ne,{})}),e.jsxs(le,{children:[e.jsx(S,{value:"__none__",children:t("peerKindOptional")}),e.jsx(S,{value:"direct",children:"direct"}),e.jsx(S,{value:"group",children:"group"}),e.jsx(S,{value:"channel",children:"channel"})]})]}),e.jsx(i,{value:((c=a.match.peer)==null?void 0:c.id)??"",onChange:l=>T(r,{...a,match:{...a.match,peer:n?{kind:n,id:l.target.value}:void 0}}),placeholder:t("peerIdPlaceholder")})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>E(l=>l.filter((o,m)=>m!==r)),children:[e.jsx(ee,{className:"h-4 w-4 mr-1"}),t("remove")]})})]},`${r}-${a.agentId}`)}),e.jsxs(w,{type:"button",variant:"outline",onClick:()=>E(a=>[...a,fe()]),children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),t("addBinding")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{type:"button",onClick:ie,disabled:A.isPending,children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),A.isPending?t("saving"):t("saveRuntimeSettings")]})})]})}export{Ce as RuntimeConfig};