@nextclaw/ui 0.9.0 → 0.9.2

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 (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/assets/{ChannelsList-C7F_As4r.js → ChannelsList-DKD6Llid.js} +1 -1
  3. package/dist/assets/ChatPage-BK9X4Tin.js +38 -0
  4. package/dist/assets/{DocBrowser-Dsd8Dlq8.js → DocBrowser-CVwUDJMO.js} +1 -1
  5. package/dist/assets/{LogoBadge-2ChEc_oz.js → LogoBadge-CYQ_b7jk.js} +1 -1
  6. package/dist/assets/{MarketplacePage-BXck6-X3.js → MarketplacePage-B_2z3ii_.js} +1 -1
  7. package/dist/assets/{ModelConfig-CgHRSD0b.js → ModelConfig-CsX-_fyy.js} +1 -1
  8. package/dist/assets/{ProvidersList-PPfZucvS.js → ProvidersList-CZstsyv7.js} +1 -1
  9. package/dist/assets/{RuntimeConfig-ClLEKNTN.js → RuntimeConfig-CX2TGEG1.js} +1 -1
  10. package/dist/assets/{SearchConfig-CuXVCbrf.js → SearchConfig-C-WBTcWi.js} +1 -1
  11. package/dist/assets/{SecretsConfig-udJz6Ake.js → SecretsConfig-9kbR0ZCB.js} +1 -1
  12. package/dist/assets/{SessionsConfig-C1XnFfiC.js → SessionsConfig-Bohn3P1q.js} +1 -1
  13. package/dist/assets/{chat-message-BETwXLD4.js → chat-message-AWIcksDK.js} +1 -1
  14. package/dist/assets/{index-CsvP4CER.js → index-BEgClaDH.js} +3 -3
  15. package/dist/assets/index-C8GsgIUn.css +1 -0
  16. package/dist/assets/{index-COJdlL0e.js → index-CPDASUXh.js} +1 -1
  17. package/dist/assets/{label-BGL-ztxh.js → label-DD61y-4v.js} +1 -1
  18. package/dist/assets/{page-layout-aw88k7tG.js → page-layout-CfnoVycc.js} +1 -1
  19. package/dist/assets/{popover-DyEvzhmV.js → popover-DsugZ6rp.js} +1 -1
  20. package/dist/assets/{security-config-BuPAQn82.js → security-config-DIrf2Z0O.js} +1 -1
  21. package/dist/assets/skeleton-DJ-Wen2o.js +1 -0
  22. package/dist/assets/{switch-BK8jIzto.js → switch-NX5OmUXQ.js} +1 -1
  23. package/dist/assets/{tabs-custom-Da3cEOji.js → tabs-custom-9ihB5Jem.js} +1 -1
  24. package/dist/assets/{useConfirmDialog-z0CE92iS.js → useConfirmDialog-BuQnVTeR.js} +1 -1
  25. package/dist/assets/{vendor-CkJHmX1g.js → vendor-DKBNiC31.js} +1 -1
  26. package/dist/index.html +3 -3
  27. package/package.json +6 -6
  28. package/src/api/types.ts +63 -3
  29. package/src/components/chat/chat-composer-state.ts +53 -0
  30. package/src/components/chat/chat-page-data.ts +1 -15
  31. package/src/components/chat/chat-page-runtime.test.ts +26 -0
  32. package/src/components/chat/chat-page-runtime.ts +21 -4
  33. package/src/components/chat/chat-stream/types.ts +3 -0
  34. package/src/components/chat/containers/chat-input-bar.container.tsx +12 -41
  35. package/src/components/chat/legacy/LegacyChatPage.tsx +1 -15
  36. package/src/components/chat/managers/chat-input.manager.ts +43 -13
  37. package/src/components/chat/ncp/NcpChatPage.tsx +11 -18
  38. package/src/components/chat/ncp/ncp-chat-input.manager.ts +42 -12
  39. package/src/components/chat/ncp/ncp-chat-page-data.ts +1 -15
  40. package/src/components/chat/presenter/chat-presenter-context.tsx +2 -0
  41. package/src/components/chat/stores/chat-input.store.ts +4 -0
  42. package/dist/assets/ChatPage-Oo7-OUsx.js +0 -37
  43. package/dist/assets/index-D-bXl7qL.css +0 -1
  44. package/dist/assets/skeleton-drzO_tdU.js +0 -1
@@ -1 +1 @@
1
- import{r as s,j as t,F as oe,b0 as ae,b1 as ne,aw as W,a3 as ie,y as le,b2 as ce,s as de,a7 as ue,b3 as me}from"./vendor-CkJHmX1g.js";import{n as we,D as Y,t as i,c as X,ah as xe}from"./index-CsvP4CER.js";function pe(){const{isOpen:F,mode:g,tabs:T,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:A,toggleMode:I,goBack:$,goForward:O,canGoBack:_,canGoForward:G,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(!F)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:I,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:A,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:[T.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:$,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(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,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(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,F as oe,b0 as ae,b1 as ne,aw as W,ai as ie,y as le,b2 as ce,s as de,a5 as ue,b3 as me}from"./vendor-DKBNiC31.js";import{n as we,D as Y,t as i,c as X,ah as xe}from"./index-BEgClaDH.js";function pe(){const{isOpen:F,mode:g,tabs:T,activeTabId:N,currentTab:x,currentUrl:l,navVersion:p,close:A,toggleMode:I,goBack:$,goForward:O,canGoBack:_,canGoForward:G,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(!F)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:I,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:A,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:[T.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:$,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(le,{className:"w-4 h-4"})}),t.jsx("button",{onClick:O,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(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 +1 @@
1
- import{j as e,r as d}from"./vendor-CkJHmX1g.js";import{c as a}from"./index-CsvP4CER.js";const c={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function b({status:s,label:r,className:n}){const t=c[s];return e.jsxs("div",{className:a("inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5",t.bg,n),children:[e.jsx("span",{className:a("h-1.5 w-1.5 rounded-full",t.dot)}),e.jsx("span",{className:a("text-[11px] font-medium",t.text),children:r})]})}function p({name:s,src:r,className:n,imgClassName:t,fallback:o}){const[l,g]=d.useState(!1),i=!!r&&!l;return e.jsx("div",{className:a("inline-flex shrink-0 items-center justify-center overflow-hidden",n),children:i?e.jsx("img",{src:r,alt:`${s} logo`,className:a("block h-6 w-6 object-contain",t),onError:()=>g(!0),draggable:!1}):o??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{p as L,b as S};
1
+ import{j as e,r as d}from"./vendor-DKBNiC31.js";import{c as a}from"./index-BEgClaDH.js";const c={active:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},ready:{dot:"bg-emerald-500",text:"text-emerald-600",bg:"bg-emerald-50"},inactive:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},setup:{dot:"bg-gray-300",text:"text-gray-400",bg:"bg-gray-100/80"},warning:{dot:"bg-amber-400",text:"text-amber-600",bg:"bg-amber-50"}};function b({status:s,label:r,className:n}){const t=c[s];return e.jsxs("div",{className:a("inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5",t.bg,n),children:[e.jsx("span",{className:a("h-1.5 w-1.5 rounded-full",t.dot)}),e.jsx("span",{className:a("text-[11px] font-medium",t.text),children:r})]})}function p({name:s,src:r,className:n,imgClassName:t,fallback:o}){const[l,g]=d.useState(!1),i=!!r&&!l;return e.jsx("div",{className:a("inline-flex shrink-0 items-center justify-center overflow-hidden",n),children:i?e.jsx("img",{src:r,alt:`${s} logo`,className:a("block h-6 w-6 object-contain",t),onError:()=>g(!0),draggable:!1}):o??e.jsx("span",{className:"text-lg font-bold uppercase",children:s.slice(0,1)})})}export{p as L,b as S};
@@ -1,4 +1,4 @@
1
- import{u as Re,b as Me,d as Le,e as Y,r as i,j as n,aB as et,az as tt,aA as at,aC as De,aF as nt,aD as st,aE as A,aG as $e,aH as ot,aI as rt,aO as lt,aP as it,aX as ct,aY as dt,aQ as ut,as as pt,at as mt,aZ as gt}from"./vendor-CkJHmX1g.js";import{af as q,t as u,c as re,p as ft,n as xt,S as ht,e as yt,f as bt,g as kt,h as Ne}from"./index-CsvP4CER.js";import{S as F}from"./skeleton-drzO_tdU.js";import{T as vt}from"./tabs-custom-Da3cEOji.js";import{P as _e}from"./index-COJdlL0e.js";import{u as wt}from"./useConfirmDialog-z0CE92iS.js";import{P as Tt,a as St}from"./page-layout-aw88k7tG.js";function J(e){return e==="plugin"?"plugins":"skills"}async function Ct(e){var r,c;const t=new URLSearchParams,a=J(e.type);(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),(c=e.tag)!=null&&c.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 s=t.toString(),o=await q.get(s?`/api/marketplace/${a}/items?${s}`:`/api/marketplace/${a}/items`);if(!o.ok)throw new Error(o.error.message);return o.data}async function Pt(e){const t=await q.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 q.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Nt(e){const t=J(e.type),a=await q.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function It(e){const t=J(e),a=await q.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function Et(e){const t=J(e.type),a=await q.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Rt(e){return Re({queryKey:["marketplace-items",e],queryFn:()=>Ct(e),placeholderData:(t,a)=>{var r;const s=(r=a==null?void 0:a.queryKey)==null?void 0:r[1];return!s||typeof s!="object"||s===null?void 0:("type"in s?s.type:void 0)===e.type?t:void 0},staleTime:15e3})}function Mt(e){return Re({queryKey:["marketplace-installed",e],queryFn:()=>It(e),staleTime:1e4})}function Lt(){const e=Me();return Le({mutationFn:t=>Nt(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.type==="plugin"?u("marketplaceInstallSuccessPlugin"):u("marketplaceInstallSuccessSkill");Y.success(t.message||a)},onError:t=>{Y.error(t.message||u("marketplaceInstallFailed"))}})}function Dt(){const e=Me();return Le({mutationFn:t=>Et(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.action==="enable"?u("marketplaceEnableSuccess"):t.action==="disable"?u("marketplaceDisableSuccess"):u("marketplaceUninstallSuccess");Y.success(t.message||a)},onError:t=>{Y.error(t.message||u("marketplaceOperationFailed"))}})}var[X]=rt("Tooltip",[$e]),W=$e(),Oe="TooltipProvider",$t=700,ne="tooltip.open",[_t,le]=X(Oe),Ae=e=>{const{__scopeTooltip:t,delayDuration:a=$t,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:r}=e,c=i.useRef(!0),g=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),n.jsx(_t,{scope:t,isOpenDelayedRef:c,delayDuration:a,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:g,onPointerInTransitChange:i.useCallback(h=>{g.current=h},[]),disableHoverableContent:o,children:r})};Ae.displayName=Oe;var B="Tooltip",[Ot,G]=X(B),Fe=e=>{const{__scopeTooltip:t,children:a,open:s,defaultOpen:o,onOpenChange:r,disableHoverableContent:c,delayDuration:g}=e,d=le(B,e.__scopeTooltip),h=W(t),[p,y]=i.useState(null),v=et(),x=i.useRef(0),T=c??d.disableHoverableContent,f=g??d.delayDuration,C=i.useRef(!1),[I,N]=tt({prop:s,defaultProp:o??!1,onChange:S=>{S?(d.onOpen(),document.dispatchEvent(new CustomEvent(ne))):d.onClose(),r==null||r(S)},caller:B}),M=i.useMemo(()=>I?C.current?"delayed-open":"instant-open":"closed",[I]),P=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,C.current=!1,N(!0)},[N]),R=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,N(!1)},[N]),D=i.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{C.current=!0,N(!0),x.current=0},f)},[f,N]);return i.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),n.jsx(at,{...h,children:n.jsx(Ot,{scope:t,contentId:v,open:I,stateAttribute:M,trigger:p,onTriggerChange:y,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?D():P()},[d.isOpenDelayedRef,D,P]),onTriggerLeave:i.useCallback(()=>{T?R():(window.clearTimeout(x.current),x.current=0)},[R,T]),onOpen:P,onClose:R,disableHoverableContent:T,children:a})})};Fe.displayName=B;var se="TooltipTrigger",Ue=i.forwardRef((e,t)=>{const{__scopeTooltip:a,...s}=e,o=G(se,a),r=le(se,a),c=W(a),g=i.useRef(null),d=De(t,g,o.onTriggerChange),h=i.useRef(!1),p=i.useRef(!1),y=i.useCallback(()=>h.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),n.jsx(nt,{asChild:!0,...c,children:n.jsx(st.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!r.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:A(e.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:A(e.onFocus,()=>{h.current||o.onOpen()}),onBlur:A(e.onBlur,o.onClose),onClick:A(e.onClick,o.onClose)})})});Ue.displayName=se;var ie="TooltipPortal",[At,Ft]=X(ie,{forceMount:void 0}),ze=e=>{const{__scopeTooltip:t,forceMount:a,children:s,container:o}=e,r=G(ie,t);return n.jsx(At,{scope:t,forceMount:a,children:n.jsx(_e,{present:a||r.open,children:n.jsx(ot,{asChild:!0,container:o,children:s})})})};ze.displayName=ie;var z="TooltipContent",qe=i.forwardRef((e,t)=>{const a=Ft(z,e.__scopeTooltip),{forceMount:s=a.forceMount,side:o="top",...r}=e,c=G(z,e.__scopeTooltip);return n.jsx(_e,{present:s||c.open,children:c.disableHoverableContent?n.jsx(He,{side:o,...r,ref:t}):n.jsx(Ut,{side:o,...r,ref:t})})}),Ut=i.forwardRef((e,t)=>{const a=G(z,e.__scopeTooltip),s=le(z,e.__scopeTooltip),o=i.useRef(null),r=De(t,o),[c,g]=i.useState(null),{trigger:d,onClose:h}=a,p=o.current,{onPointerInTransitChange:y}=s,v=i.useCallback(()=>{g(null),y(!1)},[y]),x=i.useCallback((T,f)=>{const C=T.currentTarget,I={x:T.clientX,y:T.clientY},N=Bt(I,C.getBoundingClientRect()),M=Gt(I,N),P=Qt(f.getBoundingClientRect()),R=Yt([...M,...P]);g(R),y(!0)},[y]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&p){const T=C=>x(C,p),f=C=>x(C,d);return d.addEventListener("pointerleave",T),p.addEventListener("pointerleave",f),()=>{d.removeEventListener("pointerleave",T),p.removeEventListener("pointerleave",f)}}},[d,p,x,v]),i.useEffect(()=>{if(c){const T=f=>{const C=f.target,I={x:f.clientX,y:f.clientY},N=(d==null?void 0:d.contains(C))||(p==null?void 0:p.contains(C)),M=!Vt(I,c);N?v():M&&(v(),h())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[d,p,c,h,v]),n.jsx(He,{...e,ref:r})}),[zt,qt]=X(B,{isInside:!1}),Ht=dt("TooltipContent"),He=i.forwardRef((e,t)=>{const{__scopeTooltip:a,children:s,"aria-label":o,onEscapeKeyDown:r,onPointerDownOutside:c,...g}=e,d=G(z,a),h=W(a),{onClose:p}=d;return i.useEffect(()=>(document.addEventListener(ne,p),()=>document.removeEventListener(ne,p)),[p]),i.useEffect(()=>{if(d.trigger){const y=v=>{const x=v.target;x!=null&&x.contains(d.trigger)&&p()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,p]),n.jsx(lt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:c,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:n.jsxs(it,{"data-state":d.stateAttribute,...h,...g,ref:t,style:{...g.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:[n.jsx(Ht,{children:s}),n.jsx(zt,{scope:a,isInside:!0,children:n.jsx(ct,{id:d.contentId,role:"tooltip",children:o||s})})]})})});qe.displayName=z;var Ke="TooltipArrow",Kt=i.forwardRef((e,t)=>{const{__scopeTooltip:a,...s}=e,o=W(a);return qt(Ke,a).isInside?null:n.jsx(ut,{...o,...s,ref:t})});Kt.displayName=Ke;function Bt(e,t){const a=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),r=Math.abs(t.left-e.x);switch(Math.min(a,s,o,r)){case r:return"left";case o:return"right";case a:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function Gt(e,t,a=5){const s=[];switch(t){case"top":s.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":s.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":s.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":s.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return s}function Qt(e){const{top:t,right:a,bottom:s,left:o}=e;return[{x:o,y:t},{x:a,y:t},{x:a,y:s},{x:o,y:s}]}function Vt(e,t){const{x:a,y:s}=e;let o=!1;for(let r=0,c=t.length-1;r<t.length;c=r++){const g=t[r],d=t[c],h=g.x,p=g.y,y=d.x,v=d.y;p>s!=v>s&&a<(y-h)*(s-p)/(v-p)+h&&(o=!o)}return o}function Yt(e){const t=e.slice();return t.sort((a,s)=>a.x<s.x?-1:a.x>s.x?1:a.y<s.y?-1:a.y>s.y?1:0),Jt(t)}function Jt(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const r=t[t.length-1],c=t[t.length-2];if((r.x-c.x)*(o.y-c.y)>=(r.y-c.y)*(o.x-c.x))t.pop();else break}t.push(o)}t.pop();const a=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;a.length>=2;){const r=a[a.length-1],c=a[a.length-2];if((r.x-c.x)*(o.y-c.y)>=(r.y-c.y)*(o.x-c.x))a.pop();else break}a.push(o)}return a.pop(),t.length===1&&a.length===1&&t[0].x===a[0].x&&t[0].y===a[0].y?t:t.concat(a)}var Xt=Ae,Wt=Fe,Zt=Ue,ea=ze,Be=qe;const ta=Xt,ee=Wt,te=Zt,V=i.forwardRef(({className:e,sideOffset:t=4,...a},s)=>n.jsx(ea,{children:n.jsx(Be,{ref:s,sideOffset:t,className:re("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),...a})}));V.displayName=Be.displayName;const Ge=12,aa=Ge;function oe(e){return(e??"").trim().toLowerCase()}function U(e,t){const a=oe(t);return a.length>0?`${e}:${a}`:""}function na(e){const t=new Map;for(const a of e){const s=[a.install.spec,a.slug,a.id];for(const o of s){const r=U(a.type,o);!r||t.has(r)||t.set(r,a)}}return t}function sa(e){const t=new Map;for(const a of e){const s=[a.spec,a.id,a.label];for(const o of s){const r=U(a.type,o);!r||t.has(r)||t.set(r,a)}}return t}function Ie(e,t){const a=[e.install.spec,e.slug,e.id];for(const s of a){const o=U(e.type,s);if(!o)continue;const r=t.get(o);if(r)return r}}function oa(e,t){const a=t.get(U(e.type,e.spec));if(a)return a;const s=t.get(U(e.type,e.id));return s||t.get(U(e.type,e.label))}function ra(e){const t=e.trim().toLowerCase().replace(/_/g,"-"),a=t.split("-")[0],s=[t,a,"en"];return Array.from(new Set(s.filter(Boolean)))}function ae(e){return e.trim().toLowerCase().replace(/_/g,"-")}function ce(e,t,a){var s;if(e){const o=Object.entries(e).map(([r,c])=>({locale:ae(r),text:typeof c=="string"?c.trim():""})).filter(r=>r.text.length>0);if(o.length>0){const r=new Map(o.map(c=>[c.locale,c.text]));for(const c of a){const g=ae(c),d=r.get(g);if(d)return d}for(const c of a){const g=ae(c).split("-")[0];if(!g)continue;const d=o.find(h=>h.locale===g||h.locale.startsWith(`${g}-`));if(d)return d.text}return((s=o[0])==null?void 0:s.text)??""}}return(t==null?void 0:t.trim())??""}function la(e,t,a,s){const o=oe(a);if(!o)return!0;const r=ce(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,s);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,r,...(t==null?void 0:t.tags)??[]].map(g=>oe(g)).filter(Boolean).some(g=>g.includes(o))}function ia(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 a=0;for(let s=0;s<e.length;s++)a=e.charCodeAt(s)+((a<<5)-a);return t[Math.abs(a)%t.length]}function ca({name:e,fallback:t}){const a=e||t,s=a.substring(0,2).toUpperCase(),o=ia(a);return n.jsx("div",{className:re("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",o),children:s})}function E(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function K(e){var g,d,h,p;const t=((g=e.metadataRaw)==null?void 0:g.trim())||"-",a=((d=e.contentRaw)==null?void 0:d.trim())||"-",s=(h=e.summary)==null?void 0:h.trim(),o=(p=e.description)==null?void 0:p.trim(),r=!!o&&o!==s,c=`<!doctype html>
1
+ import{u as Re,b as Me,d as Le,e as Y,r as i,j as n,aB as et,az as tt,aA as at,aC as De,aF as nt,aD as st,aE as A,aG as $e,aH as ot,aI as rt,aO as lt,aP as it,aX as ct,aY as dt,aQ as ut,as as pt,at as mt,aZ as gt}from"./vendor-DKBNiC31.js";import{af as q,t as u,c as re,p as ft,n as xt,S as ht,e as yt,f as bt,g as kt,h as Ne}from"./index-BEgClaDH.js";import{S as F}from"./skeleton-DJ-Wen2o.js";import{T as vt}from"./tabs-custom-9ihB5Jem.js";import{P as _e}from"./index-CPDASUXh.js";import{u as wt}from"./useConfirmDialog-BuQnVTeR.js";import{P as Tt,a as St}from"./page-layout-CfnoVycc.js";function J(e){return e==="plugin"?"plugins":"skills"}async function Ct(e){var r,c;const t=new URLSearchParams,a=J(e.type);(r=e.q)!=null&&r.trim()&&t.set("q",e.q.trim()),(c=e.tag)!=null&&c.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 s=t.toString(),o=await q.get(s?`/api/marketplace/${a}/items?${s}`:`/api/marketplace/${a}/items`);if(!o.ok)throw new Error(o.error.message);return o.data}async function Pt(e){const t=await q.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 q.get(`/api/marketplace/plugins/items/${encodeURIComponent(e)}/content`);if(!t.ok)throw new Error(t.error.message);return t.data}async function Nt(e){const t=J(e.type),a=await q.post(`/api/marketplace/${t}/install`,e);if(!a.ok)throw new Error(a.error.message);return a.data}async function It(e){const t=J(e),a=await q.get(`/api/marketplace/${t}/installed`);if(!a.ok)throw new Error(a.error.message);return a.data}async function Et(e){const t=J(e.type),a=await q.post(`/api/marketplace/${t}/manage`,e);if(!a.ok)throw new Error(a.error.message);return a.data}function Rt(e){return Re({queryKey:["marketplace-items",e],queryFn:()=>Ct(e),placeholderData:(t,a)=>{var r;const s=(r=a==null?void 0:a.queryKey)==null?void 0:r[1];return!s||typeof s!="object"||s===null?void 0:("type"in s?s.type:void 0)===e.type?t:void 0},staleTime:15e3})}function Mt(e){return Re({queryKey:["marketplace-installed",e],queryFn:()=>It(e),staleTime:1e4})}function Lt(){const e=Me();return Le({mutationFn:t=>Nt(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.type==="plugin"?u("marketplaceInstallSuccessPlugin"):u("marketplaceInstallSuccessSkill");Y.success(t.message||a)},onError:t=>{Y.error(t.message||u("marketplaceInstallFailed"))}})}function Dt(){const e=Me();return Le({mutationFn:t=>Et(t),onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-installed",t.type]}),e.invalidateQueries({queryKey:["marketplace-items"]}),t.type==="plugin"&&e.invalidateQueries({queryKey:["ncp-session-types"]});const a=t.action==="enable"?u("marketplaceEnableSuccess"):t.action==="disable"?u("marketplaceDisableSuccess"):u("marketplaceUninstallSuccess");Y.success(t.message||a)},onError:t=>{Y.error(t.message||u("marketplaceOperationFailed"))}})}var[X]=rt("Tooltip",[$e]),W=$e(),Oe="TooltipProvider",$t=700,ne="tooltip.open",[_t,le]=X(Oe),Ae=e=>{const{__scopeTooltip:t,delayDuration:a=$t,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:r}=e,c=i.useRef(!0),g=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),n.jsx(_t,{scope:t,isOpenDelayedRef:c,delayDuration:a,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:g,onPointerInTransitChange:i.useCallback(h=>{g.current=h},[]),disableHoverableContent:o,children:r})};Ae.displayName=Oe;var B="Tooltip",[Ot,G]=X(B),Fe=e=>{const{__scopeTooltip:t,children:a,open:s,defaultOpen:o,onOpenChange:r,disableHoverableContent:c,delayDuration:g}=e,d=le(B,e.__scopeTooltip),h=W(t),[p,y]=i.useState(null),v=et(),x=i.useRef(0),T=c??d.disableHoverableContent,f=g??d.delayDuration,C=i.useRef(!1),[I,N]=tt({prop:s,defaultProp:o??!1,onChange:S=>{S?(d.onOpen(),document.dispatchEvent(new CustomEvent(ne))):d.onClose(),r==null||r(S)},caller:B}),M=i.useMemo(()=>I?C.current?"delayed-open":"instant-open":"closed",[I]),P=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,C.current=!1,N(!0)},[N]),R=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,N(!1)},[N]),D=i.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{C.current=!0,N(!0),x.current=0},f)},[f,N]);return i.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),n.jsx(at,{...h,children:n.jsx(Ot,{scope:t,contentId:v,open:I,stateAttribute:M,trigger:p,onTriggerChange:y,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?D():P()},[d.isOpenDelayedRef,D,P]),onTriggerLeave:i.useCallback(()=>{T?R():(window.clearTimeout(x.current),x.current=0)},[R,T]),onOpen:P,onClose:R,disableHoverableContent:T,children:a})})};Fe.displayName=B;var se="TooltipTrigger",Ue=i.forwardRef((e,t)=>{const{__scopeTooltip:a,...s}=e,o=G(se,a),r=le(se,a),c=W(a),g=i.useRef(null),d=De(t,g,o.onTriggerChange),h=i.useRef(!1),p=i.useRef(!1),y=i.useCallback(()=>h.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),n.jsx(nt,{asChild:!0,...c,children:n.jsx(st.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:d,onPointerMove:A(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!r.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:A(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:A(e.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:A(e.onFocus,()=>{h.current||o.onOpen()}),onBlur:A(e.onBlur,o.onClose),onClick:A(e.onClick,o.onClose)})})});Ue.displayName=se;var ie="TooltipPortal",[At,Ft]=X(ie,{forceMount:void 0}),ze=e=>{const{__scopeTooltip:t,forceMount:a,children:s,container:o}=e,r=G(ie,t);return n.jsx(At,{scope:t,forceMount:a,children:n.jsx(_e,{present:a||r.open,children:n.jsx(ot,{asChild:!0,container:o,children:s})})})};ze.displayName=ie;var z="TooltipContent",qe=i.forwardRef((e,t)=>{const a=Ft(z,e.__scopeTooltip),{forceMount:s=a.forceMount,side:o="top",...r}=e,c=G(z,e.__scopeTooltip);return n.jsx(_e,{present:s||c.open,children:c.disableHoverableContent?n.jsx(He,{side:o,...r,ref:t}):n.jsx(Ut,{side:o,...r,ref:t})})}),Ut=i.forwardRef((e,t)=>{const a=G(z,e.__scopeTooltip),s=le(z,e.__scopeTooltip),o=i.useRef(null),r=De(t,o),[c,g]=i.useState(null),{trigger:d,onClose:h}=a,p=o.current,{onPointerInTransitChange:y}=s,v=i.useCallback(()=>{g(null),y(!1)},[y]),x=i.useCallback((T,f)=>{const C=T.currentTarget,I={x:T.clientX,y:T.clientY},N=Bt(I,C.getBoundingClientRect()),M=Gt(I,N),P=Qt(f.getBoundingClientRect()),R=Yt([...M,...P]);g(R),y(!0)},[y]);return i.useEffect(()=>()=>v(),[v]),i.useEffect(()=>{if(d&&p){const T=C=>x(C,p),f=C=>x(C,d);return d.addEventListener("pointerleave",T),p.addEventListener("pointerleave",f),()=>{d.removeEventListener("pointerleave",T),p.removeEventListener("pointerleave",f)}}},[d,p,x,v]),i.useEffect(()=>{if(c){const T=f=>{const C=f.target,I={x:f.clientX,y:f.clientY},N=(d==null?void 0:d.contains(C))||(p==null?void 0:p.contains(C)),M=!Vt(I,c);N?v():M&&(v(),h())};return document.addEventListener("pointermove",T),()=>document.removeEventListener("pointermove",T)}},[d,p,c,h,v]),n.jsx(He,{...e,ref:r})}),[zt,qt]=X(B,{isInside:!1}),Ht=dt("TooltipContent"),He=i.forwardRef((e,t)=>{const{__scopeTooltip:a,children:s,"aria-label":o,onEscapeKeyDown:r,onPointerDownOutside:c,...g}=e,d=G(z,a),h=W(a),{onClose:p}=d;return i.useEffect(()=>(document.addEventListener(ne,p),()=>document.removeEventListener(ne,p)),[p]),i.useEffect(()=>{if(d.trigger){const y=v=>{const x=v.target;x!=null&&x.contains(d.trigger)&&p()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,p]),n.jsx(lt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:c,onFocusOutside:y=>y.preventDefault(),onDismiss:p,children:n.jsxs(it,{"data-state":d.stateAttribute,...h,...g,ref:t,style:{...g.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:[n.jsx(Ht,{children:s}),n.jsx(zt,{scope:a,isInside:!0,children:n.jsx(ct,{id:d.contentId,role:"tooltip",children:o||s})})]})})});qe.displayName=z;var Ke="TooltipArrow",Kt=i.forwardRef((e,t)=>{const{__scopeTooltip:a,...s}=e,o=W(a);return qt(Ke,a).isInside?null:n.jsx(ut,{...o,...s,ref:t})});Kt.displayName=Ke;function Bt(e,t){const a=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),r=Math.abs(t.left-e.x);switch(Math.min(a,s,o,r)){case r:return"left";case o:return"right";case a:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function Gt(e,t,a=5){const s=[];switch(t){case"top":s.push({x:e.x-a,y:e.y+a},{x:e.x+a,y:e.y+a});break;case"bottom":s.push({x:e.x-a,y:e.y-a},{x:e.x+a,y:e.y-a});break;case"left":s.push({x:e.x+a,y:e.y-a},{x:e.x+a,y:e.y+a});break;case"right":s.push({x:e.x-a,y:e.y-a},{x:e.x-a,y:e.y+a});break}return s}function Qt(e){const{top:t,right:a,bottom:s,left:o}=e;return[{x:o,y:t},{x:a,y:t},{x:a,y:s},{x:o,y:s}]}function Vt(e,t){const{x:a,y:s}=e;let o=!1;for(let r=0,c=t.length-1;r<t.length;c=r++){const g=t[r],d=t[c],h=g.x,p=g.y,y=d.x,v=d.y;p>s!=v>s&&a<(y-h)*(s-p)/(v-p)+h&&(o=!o)}return o}function Yt(e){const t=e.slice();return t.sort((a,s)=>a.x<s.x?-1:a.x>s.x?1:a.y<s.y?-1:a.y>s.y?1:0),Jt(t)}function Jt(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const r=t[t.length-1],c=t[t.length-2];if((r.x-c.x)*(o.y-c.y)>=(r.y-c.y)*(o.x-c.x))t.pop();else break}t.push(o)}t.pop();const a=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;a.length>=2;){const r=a[a.length-1],c=a[a.length-2];if((r.x-c.x)*(o.y-c.y)>=(r.y-c.y)*(o.x-c.x))a.pop();else break}a.push(o)}return a.pop(),t.length===1&&a.length===1&&t[0].x===a[0].x&&t[0].y===a[0].y?t:t.concat(a)}var Xt=Ae,Wt=Fe,Zt=Ue,ea=ze,Be=qe;const ta=Xt,ee=Wt,te=Zt,V=i.forwardRef(({className:e,sideOffset:t=4,...a},s)=>n.jsx(ea,{children:n.jsx(Be,{ref:s,sideOffset:t,className:re("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),...a})}));V.displayName=Be.displayName;const Ge=12,aa=Ge;function oe(e){return(e??"").trim().toLowerCase()}function U(e,t){const a=oe(t);return a.length>0?`${e}:${a}`:""}function na(e){const t=new Map;for(const a of e){const s=[a.install.spec,a.slug,a.id];for(const o of s){const r=U(a.type,o);!r||t.has(r)||t.set(r,a)}}return t}function sa(e){const t=new Map;for(const a of e){const s=[a.spec,a.id,a.label];for(const o of s){const r=U(a.type,o);!r||t.has(r)||t.set(r,a)}}return t}function Ie(e,t){const a=[e.install.spec,e.slug,e.id];for(const s of a){const o=U(e.type,s);if(!o)continue;const r=t.get(o);if(r)return r}}function oa(e,t){const a=t.get(U(e.type,e.spec));if(a)return a;const s=t.get(U(e.type,e.id));return s||t.get(U(e.type,e.label))}function ra(e){const t=e.trim().toLowerCase().replace(/_/g,"-"),a=t.split("-")[0],s=[t,a,"en"];return Array.from(new Set(s.filter(Boolean)))}function ae(e){return e.trim().toLowerCase().replace(/_/g,"-")}function ce(e,t,a){var s;if(e){const o=Object.entries(e).map(([r,c])=>({locale:ae(r),text:typeof c=="string"?c.trim():""})).filter(r=>r.text.length>0);if(o.length>0){const r=new Map(o.map(c=>[c.locale,c.text]));for(const c of a){const g=ae(c),d=r.get(g);if(d)return d}for(const c of a){const g=ae(c).split("-")[0];if(!g)continue;const d=o.find(h=>h.locale===g||h.locale.startsWith(`${g}-`));if(d)return d.text}return((s=o[0])==null?void 0:s.text)??""}}return(t==null?void 0:t.trim())??""}function la(e,t,a,s){const o=oe(a);if(!o)return!0;const r=ce(t==null?void 0:t.summaryI18n,t==null?void 0:t.summary,s);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,r,...(t==null?void 0:t.tags)??[]].map(g=>oe(g)).filter(Boolean).some(g=>g.includes(o))}function ia(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 a=0;for(let s=0;s<e.length;s++)a=e.charCodeAt(s)+((a<<5)-a);return t[Math.abs(a)%t.length]}function ca({name:e,fallback:t}){const a=e||t,s=a.substring(0,2).toUpperCase(),o=ia(a);return n.jsx("div",{className:re("flex items-center justify-center w-10 h-10 rounded-xl text-white font-semibold text-sm shrink-0",o),children:s})}function E(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function K(e){var g,d,h,p;const t=((g=e.metadataRaw)==null?void 0:g.trim())||"-",a=((d=e.contentRaw)==null?void 0:d.trim())||"-",s=(h=e.summary)==null?void 0:h.trim(),o=(p=e.description)==null?void 0:p.trim(),r=!!o&&o!==s,c=`<!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -1 +1 @@
1
- import{r as n,j as e,a0 as W,l as z,q,F as G,a1 as K,a2 as Y}from"./vendor-CkJHmX1g.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-CsvP4CER.js";import{L as R}from"./label-BGL-ztxh.js";import{S as u}from"./skeleton-drzO_tdU.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-D3B_xWXx.js";import{P as ie,a as ce}from"./page-layout-aw88k7tG.js";function de(i){const r=new Set;for(const p of i){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:i,value:r,onChange:p,options:x,disabled:c=!1,placeholder:T,className:P,inputClassName:b,emptyText:j,createText:k,maxItems:N=Number.POSITIVE_INFINITY,onEnter:v}){const[o,l]=n.useState(!1);n.useEffect(()=>{c&&o&&l(!1)},[c,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 C=f.option.toLowerCase(),S=w.option.toLowerCase(),D=C===d?0:C.startsWith(d)?1:C.includes(d)?2:3,I=S===d?0:S.startsWith(d)?1:S.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]),M=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",P),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:i,value:r,disabled:c,onFocus:()=>{c||l(!0)},onChange:s=>{p(s.target.value),!o&&!c&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(v&&(s.preventDefault(),v()),l(!1))},placeholder:T,className:L("pr-10",b)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:c,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",c?"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&&!c&&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:[!M&&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:k?k.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:i,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),c=X(),[T,P]=n.useState(""),[b,j]=n.useState(""),[k,N]=n.useState(""),v=x==null?void 0:x.uiHints,o=_("agents.defaults.model",v),l=_("agents.defaults.workspace",v),h=n.useMemo(()=>le({meta:p,config:i,onlyConfigured:!0}),[i,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),M=(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=i==null?void 0:i.agents)!=null&&E.defaults))return;const t=(i.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];P(y),j(y?F(t,V):""),N(i.agents.defaults.workspace||"")},[i,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(b,s);return t?ne(a.prefix,t):""},[b,a,s]),C=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",S=t=>{P(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),c.mutate({model:w})};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(ie,{children:[e.jsx(ce,{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:M,onValueChange:S,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:b,onChange:D,options:f,disabled:!M,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")},M)]}),e.jsx("p",{className:"text-xs text-gray-400",children:C}),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:k,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:c.isPending,size:"lg",children:c.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,a0 as W,l as z,q,F as G,a1 as K,a2 as Y}from"./vendor-DKBNiC31.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-BEgClaDH.js";import{L as R}from"./label-DD61y-4v.js";import{S as u}from"./skeleton-DJ-Wen2o.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-D3B_xWXx.js";import{P as ie,a as ce}from"./page-layout-CfnoVycc.js";function de(i){const r=new Set;for(const p of i){const x=p.trim();x.length>0&&r.add(x)}return[...r]}function me({id:i,value:r,onChange:p,options:x,disabled:c=!1,placeholder:T,className:P,inputClassName:b,emptyText:j,createText:k,maxItems:N=Number.POSITIVE_INFINITY,onEnter:v}){const[o,l]=n.useState(!1);n.useEffect(()=>{c&&o&&l(!1)},[c,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 C=f.option.toLowerCase(),S=w.option.toLowerCase(),D=C===d?0:C.startsWith(d)?1:C.includes(d)?2:3,I=S===d?0:S.startsWith(d)?1:S.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]),M=r.trim().length>0&&h.some(s=>s===r.trim());return e.jsxs("div",{className:L("relative",P),onBlur:()=>{setTimeout(()=>l(!1),120)},children:[e.jsx(A,{id:i,value:r,disabled:c,onFocus:()=>{c||l(!0)},onChange:s=>{p(s.target.value),!o&&!c&&l(!0)},onKeyDown:s=>{s.key==="Enter"&&(v&&(s.preventDefault(),v()),l(!1))},placeholder:T,className:L("pr-10",b)}),e.jsx("button",{type:"button",onMouseDown:s=>s.preventDefault(),onClick:()=>l(s=>!s),disabled:c,className:L("absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center",c?"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&&!c&&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:[!M&&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:k?k.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:i,isLoading:r}=$(),{data:p}=J(),{data:x}=Q(),c=X(),[T,P]=n.useState(""),[b,j]=n.useState(""),[k,N]=n.useState(""),v=x==null?void 0:x.uiHints,o=_("agents.defaults.model",v),l=_("agents.defaults.workspace",v),h=n.useMemo(()=>le({meta:p,config:i,onlyConfigured:!0}),[i,p]),d=n.useMemo(()=>new Map(h.map(t=>[t.name,t])),[h]),a=d.get(T),M=(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=i==null?void 0:i.agents)!=null&&E.defaults))return;const t=(i.agents.defaults.model||"").trim(),y=oe(t,h)??"",V=((B=d.get(y))==null?void 0:B.aliases)??[];P(y),j(y?F(t,V):""),N(i.agents.defaults.workspace||"")},[i,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(b,s);return t?ne(a.prefix,t):""},[b,a,s]),C=m("modelIdentifierHelp")||(o==null?void 0:o.help)||"",S=t=>{P(t),j("")},D=t=>{if(!a){j("");return}j(F(t,s))},I=t=>{t.preventDefault(),c.mutate({model:w})};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(ie,{children:[e.jsx(ce,{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:M,onValueChange:S,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:b,onChange:D,options:f,disabled:!M,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")},M)]}),e.jsx("p",{className:"text-xs text-gray-400",children:C}),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:k,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:c.isPending,size:"lg",children:c.isPending?e.jsx(Y,{className:"h-5 w-5 animate-spin"}):m("saveChanges")})})]})]})}export{Ne as ModelConfig};
@@ -1 +1 @@
1
- import{r as x,j as e,au as Mt,av as Tt,ao as ot,a3 as _e,b as kt,e as F,aw as tt,ax as st,C as St,ay as Lt,s as It,K as Dt}from"./vendor-CkJHmX1g.js";import{c as de,I as X,B as K,t as n,u as ct,a as dt,b as ut,U as Et,V as _t,W as $t,X as Bt,Y as Kt,Z as zt,_ as Ft,S as Te,e as ke,f as Se,g as Le,h as ye,$ as Ot}from"./index-CsvP4CER.js";import{L as O}from"./label-BGL-ztxh.js";import{P as Ht,a as Rt,b as Wt}from"./popover-DyEvzhmV.js";import{S as mt,L as qt}from"./LogoBadge-2ChEc_oz.js";import{h as le}from"./config-hints-CApS3K_7.js";import{c as Ut,b as Gt,C as Vt,a as Qt}from"./config-layout-BHnOoweL.js";import{T as Xt}from"./tabs-custom-Da3cEOji.js";import{P as Yt,a as Zt}from"./page-layout-aw88k7tG.js";import"./index-COJdlL0e.js";function Jt({isSet:t,className:r,value:a,onChange:l,placeholder:c,...g}){const[d,u]=x.useState(!1),[j,b]=x.useState(!1),w=typeof a=="string"&&a.length>0,I=t&&!w&&!j;return e.jsxs("div",{className:"relative",children:[I?e.jsx("div",{onClick:()=>b(!0),className:de("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",r),children:"••••••••••••"}):e.jsx(X,{type:d?"text":"password",className:de("pr-12",r),value:a,onChange:l,onBlur:()=>{w||b(!1)},placeholder:c,autoFocus:j,...g}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||w)&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(!d),children:d?e.jsx(Mt,{className:"h-4 w-4"}):e.jsx(Tt,{className:"h-4 w-4"})})})]})}function es({value:t,onChange:r,className:a}){const l=t?Object.entries(t):[],c=(u,j,b)=>{const w=[...l];w[u]=[j,b],r(Object.fromEntries(w))},g=()=>{r({...t,"":""})},d=u=>{const j=l.filter((b,w)=>w!==u);r(Object.fromEntries(j))};return e.jsxs("div",{className:de("space-y-2",a),children:[l.map(([u,j],b)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(X,{type:"text",value:u,onChange:w=>c(b,w.target.value,j),placeholder:n("headerName"),className:"flex-1"}),e.jsx(X,{type:"text",value:j,onChange:w=>c(b,u,w.target.value),placeholder:n("headerValue"),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(b),children:e.jsx(ot,{className:"h-4 w-4 text-red-500"})})]},b)),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(_e,{className:"h-4 w-4 mr-2"}),n("add")]})]})}const ts={displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},Ee=["off","minimal","low","medium","high","adaptive","xhigh"],ss=new Set(Ee);function ce(t){if(!t)return null;const r=Object.entries(t).map(([a,l])=>[a.trim(),l]).filter(([a])=>a.length>0);return r.length===0?null:Object.fromEntries(r)}function nt(t,r){const a=ce(t),l=ce(r);if(a===null&&l===null)return!0;if(!a||!l)return!1;const c=Object.entries(a).sort(([d],[u])=>d.localeCompare(u)),g=Object.entries(l).sort(([d],[u])=>d.localeCompare(u));return c.length!==g.length?!1:c.every(([d,u],j)=>d===g[j][0]&&u===g[j][1])}function Ie(t){if(!t||t.length===0)return[];const r=new Set;for(const a of t){const l=a.trim();l&&r.add(l)}return[...r]}function ns(t,r){const a=t.trim();if(!a||!r.trim())return a;const l=`${r.trim()}/`;return a.startsWith(l)?a.slice(l.length):a}function oe(t,r){let a=t.trim();if(!a)return"";for(const l of r){const c=l.trim();c&&(a=ns(a,c))}return a.trim()}function je(t,r){return t.length!==r.length?!1:t.every((a,l)=>a===r[l])}function rs(t,r){const a=[...t];for(const l of r)a.includes(l)||a.push(l);return a}function as(t,r){return r.length===0?t:r.every(l=>!t.includes(l))?rs(t,r):r}function is(t,r){return je(t,r)?[]:t}function $e(t){if(typeof t!="string")return null;const r=t.trim().toLowerCase();return r&&ss.has(r)?r:null}function ht(t){if(!Array.isArray(t))return[];const r=[];for(const a of t){const l=$e(a);!l||r.includes(l)||r.push(l)}return r}function ls(t,r){if(!t)return{};const a={};for(const[l,c]of Object.entries(t)){const g=oe(l,r);if(!g)continue;const d=ht(c==null?void 0:c.supported);if(d.length===0)continue;const u=$e(c==null?void 0:c.default);a[g]=u&&d.includes(u)?{supported:d,default:u}:{supported:d}}return a}function De(t,r){const a=new Set(r.map(c=>c.trim()).filter(Boolean)),l={};for(const[c,g]of Object.entries(t)){if(!a.has(c))continue;const d=ht(g.supported);if(d.length===0)continue;const u=$e(g.default);l[c]=u&&d.includes(u)?{supported:d,default:u}:{supported:d}}return l}function rt(t,r){const a=Object.keys(t).sort(),l=Object.keys(r).sort();if(a.length!==l.length)return!1;for(let c=0;c<a.length;c+=1){const g=a[c];if(g!==l[c])return!1;const d=t[g],u=r[g];if(!d||!u)return!1;const j=[...d.supported].sort(),b=[...u.supported].sort();if(!je(j,b)||(d.default??null)!==(u.default??null))return!1}return!0}function at(t){return t==="off"?n("chatThinkingLevelOff"):t==="minimal"?n("chatThinkingLevelMinimal"):t==="low"?n("chatThinkingLevelLow"):t==="medium"?n("chatThinkingLevelMedium"):t==="high"?n("chatThinkingLevelHigh"):t==="adaptive"?n("chatThinkingLevelAdaptive"):n("chatThinkingLevelXhigh")}function os(t){var j,b,w,I,D;const{providerName:r,methods:a,defaultMethodId:l,language:c}=t;if(a.length===0)return"";const g=new Map;for(const k of a){const A=k.id.trim();A&&g.set(A.toLowerCase(),A)}const d=(...k)=>{for(const A of k){const P=g.get(A.toLowerCase());if(P)return P}},u=l==null?void 0:l.trim();if(r==="minimax-portal"){if(c==="zh")return d("cn","china-mainland")??d(u??"")??((j=a[0])==null?void 0:j.id)??"";if(c==="en")return d("global","intl","international")??d(u??"")??((b=a[0])==null?void 0:b.id)??""}if(u){const k=d(u);if(k)return k}return c==="zh"?d("cn")??((w=a[0])==null?void 0:w.id)??"":c==="en"?d("global")??((I=a[0])==null?void 0:I.id)??"":((D=a[0])==null?void 0:D.id)??""}function it(t){return t.required&&t.hasDefault&&t.optionCount>1&&t.optionCount<=3}function lt(t){const{value:r,onChange:a,options:l}=t;return e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(c=>{const g=c.value===r;return e.jsx("button",{type:"button",onClick:()=>a(c.value),"aria-pressed":g,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${g?"border-primary bg-primary text-white shadow-sm":"border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary"}`,children:c.label},c.value)})})}function cs({providerName:t,onProviderDeleted:r}){var Ve,Qe,Xe,Ye,Ze,Je,et;const a=kt(),{data:l}=ct(),{data:c}=dt(),{data:g}=ut(),d=Et(),u=_t(),j=$t(),b=Bt(),w=Kt(),I=zt(),[D,k]=x.useState(""),[A,P]=x.useState(""),[H,ne]=x.useState(null),[f,v]=x.useState("auto"),[N,M]=x.useState([]),[E,_]=x.useState({}),[R,$]=x.useState(""),[U,Y]=x.useState(""),[be,pt]=x.useState(!1),[ve,ue]=x.useState(!1),[me,W]=x.useState(null),[Be,B]=x.useState(""),[Ke,he]=x.useState(""),pe=x.useRef(null),i=c==null?void 0:c.providers.find(s=>s.name===t),T=(t?l==null?void 0:l.providers[t]:null)??ts,xe=g==null?void 0:g.uiHints,Z=!!(i!=null&&i.isCustom),J=t?le(`providers.${t}.apiKey`,xe):void 0,z=t?le(`providers.${t}.apiBase`,xe):void 0,we=t?le(`providers.${t}.extraHeaders`,xe):void 0,Ne=t?le(`providers.${t}.wireApi`,xe):void 0,ze=(i==null?void 0:i.displayName)||t||"",ee=(T.displayName||"").trim()||ze,xt=U.trim()||ee||t||n("providersSelectPlaceholder"),Fe=(i==null?void 0:i.modelPrefix)||t||"",q=x.useMemo(()=>Ie([Fe,t||""]),[Fe,t]),Ce=(i==null?void 0:i.defaultApiBase)||"",re=T.apiBase||Ce,Ae=ce(T.extraHeaders||null),ae=T.wireApi||(i==null?void 0:i.defaultWireApi)||"auto",Pe=x.useMemo(()=>Ie(((i==null?void 0:i.defaultModels)??[]).map(s=>oe(s,q))),[i==null?void 0:i.defaultModels,q]),Oe=x.useMemo(()=>Ie((T.models??[]).map(s=>oe(s,q))),[T.models,q]),G=x.useMemo(()=>as(Pe,Oe),[Pe,Oe]),ie=x.useMemo(()=>De(ls(T.modelThinking,q),G),[G,q,T.modelThinking]),V=Ft(),ft=((Ve=i==null?void 0:i.apiBaseHelp)==null?void 0:Ve[V])||((Qe=i==null?void 0:i.apiBaseHelp)==null?void 0:Qe.en)||(z==null?void 0:z.help)||n("providerApiBaseHelp"),p=i==null?void 0:i.auth,S=x.useMemo(()=>(p==null?void 0:p.methods)??[],[p==null?void 0:p.methods]),He=x.useMemo(()=>S.map(s=>{var o,h;return{value:s.id,label:((o=s.label)==null?void 0:o[V])||((h=s.label)==null?void 0:h.en)||s.id}}),[S,V]),fe=x.useMemo(()=>os({providerName:t,methods:S,defaultMethodId:p==null?void 0:p.defaultMethodId,language:V}),[t,p==null?void 0:p.defaultMethodId,S,V]),te=x.useMemo(()=>{var o;if(!S.length)return"";const s=Ke.trim();return s&&S.some(h=>h.id===s)?s:fe||((o=S[0])==null?void 0:o.id)||""},[Ke,fe,S]),se=x.useMemo(()=>S.find(s=>s.id===te),[S,te]),Re=((Xe=se==null?void 0:se.hint)==null?void 0:Xe[V])||((Ye=se==null?void 0:se.hint)==null?void 0:Ye.en)||"",gt=it({required:(p==null?void 0:p.kind)==="device_code",hasDefault:!!((Ze=p==null?void 0:p.defaultMethodId)!=null&&Ze.trim()),optionCount:S.length}),We=((Je=p==null?void 0:p.note)==null?void 0:Je[V])||((et=p==null?void 0:p.note)==null?void 0:et.en)||(p==null?void 0:p.displayName)||"",Me=((i==null?void 0:i.wireApiOptions)||["auto","chat","responses"]).map(s=>({value:s,label:s==="chat"?n("wireApiChat"):s==="responses"?n("wireApiResponses"):n("wireApiAuto")})),yt=it({required:!!(i!=null&&i.supportsWireApi),hasDefault:typeof(i==null?void 0:i.defaultWireApi)=="string"&&i.defaultWireApi.length>0,optionCount:Me.length}),L=x.useCallback(()=>{pe.current!==null&&(window.clearTimeout(pe.current),pe.current=null)},[]),qe=x.useCallback((s,o)=>{L(),pe.current=window.setTimeout(()=>{(async()=>{if(t)try{const h=await w.mutateAsync({provider:t,data:{sessionId:s}});if(h.status==="pending"){B(n("providerAuthWaitingBrowser")),qe(s,h.nextPollMs??o);return}if(h.status==="authorized"){W(null),L(),B(n("providerAuthCompleted")),F.success(n("providerAuthCompleted")),a.invalidateQueries({queryKey:["config"]}),a.invalidateQueries({queryKey:["config-meta"]});return}W(null),L(),B(h.message||`Authorization ${h.status}.`),F.error(h.message||`Authorization ${h.status}.`)}catch(h){W(null),L();const m=h instanceof Error?h.message:String(h);B(m),F.error(`Authorization failed: ${m}`)}})()},Math.max(1e3,o))},[L,w,t,a]);x.useEffect(()=>{if(!t){k(""),P(""),ne(null),v("auto"),M([]),_({}),$(""),Y(""),W(null),B(""),he(""),L();return}k(""),P(re),ne(T.extraHeaders||null),v(ae),M(G),_(ie),$(""),Y(ee),W(null),B(""),he(fe),L()},[t,re,T.extraHeaders,ae,G,ie,ee,fe,L]),x.useEffect(()=>()=>L(),[L]),x.useEffect(()=>{_(s=>De(s,N))},[N]);const Ue=x.useMemo(()=>{if(!t)return!1;const s=D.trim().length>0,o=A.trim()!==re.trim(),h=!nt(H,Ae),m=i!=null&&i.supportsWireApi?f!==ae:!1,y=!je(N,G),C=!rt(E,ie),ge=Z?U.trim()!==ee:!1;return s||o||h||m||y||C||ge},[t,Z,U,ee,D,A,re,H,Ae,i==null?void 0:i.supportsWireApi,f,ae,N,G,E,ie]),Ge=()=>{const s=oe(R,q);if(s){if(N.includes(s)){$("");return}M(o=>[...o,s]),$("")}},jt=(s,o)=>{_(h=>{const m=h[s],y=(m==null?void 0:m.supported)??[],C=y.includes(o)?y.filter(Q=>Q!==o):Ee.filter(Q=>Q===o||y.includes(Q));if(C.length===0){const Q={...h};return delete Q[s],Q}const ge=m!=null&&m.default&&C.includes(m.default)?m.default:void 0;return{...h,[s]:ge?{supported:C,default:ge}:{supported:C}}})},bt=(s,o)=>{_(h=>{const m=h[s];return!m||m.supported.length===0||o&&!m.supported.includes(o)?h:{...h,[s]:o?{supported:m.supported,default:o}:{supported:m.supported}}})},vt=s=>{if(s.preventDefault(),!t)return;const o={},h=D.trim(),m=A.trim(),y=ce(H),C=U.trim();Z&&C!==ee&&(o.displayName=C.length>0?C:null),h.length>0&&(o.apiKey=h),m!==re.trim()&&(o.apiBase=m.length>0&&m!==Ce?m:null),nt(y,Ae)||(o.extraHeaders=y),i!=null&&i.supportsWireApi&&f!==ae&&(o.wireApi=f),je(N,G)||(o.models=is(N,Pe)),rt(E,ie)||(o.modelThinking=De(E,N)),d.mutate({provider:t,data:o})},wt=async()=>{if(!t)return;const s=N.find(m=>m.trim().length>0)??"",o=oe(s,q),h={apiBase:A.trim(),extraHeaders:ce(H),model:o||null};D.trim().length>0&&(h.apiKey=D.trim()),i!=null&&i.supportsWireApi&&(h.wireApi=f);try{const m=await j.mutateAsync({provider:t,data:h});if(m.success){F.success(`${n("providerTestConnectionSuccess")} (${m.latencyMs}ms)`);return}const y=[`provider=${m.provider}`,`latency=${m.latencyMs}ms`];m.model&&y.push(`model=${m.model}`),F.error(`${n("providerTestConnectionFailed")}: ${m.message} | ${y.join(" | ")}`)}catch(m){const y=m instanceof Error?m.message:String(m);F.error(`${n("providerTestConnectionFailed")}: ${y}`)}},Nt=async()=>{if(!(!t||!Z||!window.confirm(n("providerDeleteConfirm"))))try{await u.mutateAsync({provider:t}),r==null||r(t)}catch{}},Ct=async()=>{if(!(!t||(p==null?void 0:p.kind)!=="device_code"))try{B("");const s=await b.mutateAsync({provider:t,data:te?{methodId:te}:{}});if(!s.sessionId||!s.verificationUri)throw new Error(n("providerAuthStartFailed"));W(s.sessionId),B(`${n("providerAuthOpenPrompt")}${s.userCode}${n("providerAuthOpenPromptSuffix")}`),window.open(s.verificationUri,"_blank","noopener,noreferrer"),qe(s.sessionId,s.intervalMs)}catch(s){const o=s instanceof Error?s.message:String(s);W(null),L(),B(o),F.error(`${n("providerAuthStartFailed")}: ${o}`)}},At=async()=>{if(!(!t||(p==null?void 0:p.kind)!=="device_code"))try{L(),W(null);const s=await I.mutateAsync({provider:t}),o=s.expiresAt?` (expires: ${s.expiresAt})`:"";B(`${n("providerAuthImportStatusPrefix")}${o}`),F.success(n("providerAuthImportSuccess")),a.invalidateQueries({queryKey:["config"]}),a.invalidateQueries({queryKey:["config-meta"]})}catch(s){const o=s instanceof Error?s.message:String(s);B(o),F.error(`${n("providerAuthImportFailed")}: ${o}`)}};if(!t||!i)return e.jsx("div",{className:Ut,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:n("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:n("providersSelectDescription")})]})});const Pt=T.apiKeySet?n("statusReady"):n("statusSetup");return e.jsxs("div",{className:Gt,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:xt}),e.jsxs("div",{className:"flex items-center gap-3",children:[Z&&e.jsx("button",{type:"button",onClick:Nt,disabled:u.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:n("providerDelete"),children:e.jsx(ot,{className:"h-4 w-4"})}),e.jsx(mt,{status:T.apiKeySet?"ready":"setup",label:Pt})]})]})}),e.jsxs("form",{onSubmit:vt,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:[Z&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:n("providerDisplayName")}),e.jsx(X,{id:"providerDisplayName",type:"text",value:U,onChange:s=>Y(s.target.value),placeholder:ze||n("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(J==null?void 0:J.label)??n("apiKey")}),e.jsx(Jt,{id:"apiKey",value:D,isSet:T.apiKeySet,onChange:s=>k(s.target.value),placeholder:(J==null?void 0:J.placeholder)??n("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:n("leaveBlankToKeepUnchanged")})]}),(p==null?void 0:p.kind)==="device_code"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:p.displayName||n("providerAuthSectionTitle")}),We?e.jsx("p",{className:"text-xs text-gray-600",children:We}):null,S.length>1?e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-xs font-medium text-gray-700",children:n("providerAuthMethodLabel")}),gt?e.jsx(lt,{value:te,onChange:he,options:He}):e.jsxs(Te,{value:te,onValueChange:he,children:[e.jsx(ke,{className:"h-8 rounded-lg bg-white",children:e.jsx(Se,{placeholder:n("providerAuthMethodPlaceholder")})}),e.jsx(Le,{children:He.map(s=>e.jsx(ye,{value:s.value,children:s.label},s.value))})]}),Re?e.jsx("p",{className:"text-xs text-gray-500",children:Re}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:Ct,disabled:b.isPending||!!me,children:b.isPending?n("providerAuthStarting"):me?n("providerAuthAuthorizing"):n("providerAuthAuthorizeInBrowser")}),p.supportsCliImport?e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:At,disabled:I.isPending,children:I.isPending?n("providerAuthImporting"):n("providerAuthImportFromCli")}):null,me?e.jsxs("span",{className:"text-xs text-gray-500",children:[n("providerAuthSessionLabel"),": ",me.slice(0,8),"…"]}):null]}),Be?e.jsx("p",{className:"text-xs text-gray-600",children:Be}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(z==null?void 0:z.label)??n("apiBase")}),e.jsx(X,{id:"apiBase",type:"text",value:A,onChange:s=>P(s.target.value),placeholder:Ce||(z==null?void 0:z.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:ft})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:n("providerModelsTitle")}),!ve&&e.jsxs("button",{type:"button",onClick:()=>ue(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(_e,{className:"h-3 w-3"}),n("providerAddModel")]})]}),ve&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:R,onChange:s=>$(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Ge()),s.key==="Escape"&&(ue(!1),$(""))},placeholder:n("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(K,{type:"button",size:"sm",onClick:Ge,disabled:R.trim().length===0,children:n("add")}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{ue(!1),$("")},children:e.jsx(tt,{className:"h-4 w-4"})})]}),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:n("providerModelsEmptyShort")}),!ve&&e.jsx("button",{type:"button",onClick:()=>ue(!0),className:"mt-2 text-sm text-primary hover:text-primary/80 font-medium",children:n("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(s=>{const o=E[s],h=(o==null?void 0:o.supported)??[],m=(o==null?void 0:o.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:s}),e.jsxs(Ht,{children:[e.jsx(Rt,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":n("providerModelThinkingTitle"),title:n("providerModelThinkingTitle"),children:e.jsx(st,{className:"h-3 w-3"})})}),e.jsxs(Wt,{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:n("providerModelThinkingTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerModelThinkingHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ee.map(y=>{const C=h.includes(y);return e.jsx("button",{type:"button",onClick:()=>jt(s,y),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${C?"border-primary bg-primary text-white":"border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary"}`,children:at(y)},y)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(O,{className:"text-xs font-medium text-gray-700",children:n("providerModelThinkingDefault")}),e.jsxs(Te,{value:m??"__none__",onValueChange:y=>bt(s,y==="__none__"?null:y),disabled:h.length===0,children:[e.jsx(ke,{className:"h-8 rounded-lg bg-white text-xs",children:e.jsx(Se,{})}),e.jsxs(Le,{children:[e.jsx(ye,{value:"__none__",children:n("providerModelThinkingDefaultNone")}),h.map(y=>e.jsx(ye,{value:y,children:at(y)},y))]})]}),h.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:n("providerModelThinkingNoSupported")}):null]})]})]}),e.jsx("button",{type:"button",onClick:()=>{M(y=>y.filter(C=>C!==s)),_(y=>{const C={...y};return delete C[s],C})},className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":n("remove"),children:e.jsx(tt,{className:"h-3 w-3"})})]},s)})})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>pt(!be),className:"flex w-full items-center justify-between text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),n("providerAdvancedSettings")]}),e.jsx(St,{className:`h-4 w-4 transition-transform ${be?"rotate-180":""}`})]}),be&&e.jsxs("div",{className:"mt-4 space-y-5",children:[i.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(Ne==null?void 0:Ne.label)??n("wireApi")}),yt?e.jsx(lt,{value:f,onChange:s=>v(s),options:Me}):e.jsxs(Te,{value:f,onValueChange:s=>v(s),children:[e.jsx(ke,{className:"rounded-xl",children:e.jsx(Se,{})}),e.jsx(Le,{children:Me.map(s=>e.jsx(ye,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:(we==null?void 0:we.label)??n("extraHeaders")}),e.jsx(es,{value:H,onChange:ne}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerExtraHeadersHelpShort")})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:wt,disabled:j.isPending,children:[e.jsx(Lt,{className:"mr-1.5 h-4 w-4"}),j.isPending?n("providerTestingConnection"):n("providerTestConnection")]}),e.jsx(K,{type:"submit",disabled:d.isPending||!Ue,children:d.isPending?n("saving"):Ue?n("save"):n("unchanged")})]})]})]})}function ds(t){if(!t)return null;try{const r=new URL(t),a=r.pathname&&r.pathname!=="/"?r.pathname:"";return`${r.host}${a}`}catch{return t.replace(/^https?:\/\//,"")}}function Cs(){const{data:t}=ct(),{data:r}=dt(),{data:a}=ut(),l=Ot(),[c,g]=x.useState("installed"),[d,u]=x.useState(),[j,b]=x.useState(""),w=a==null?void 0:a.uiHints,I=(r==null?void 0:r.providers)??[],D=(t==null?void 0:t.providers)??{},k=I.filter(f=>{var v;return(v=D[f.name])==null?void 0:v.apiKeySet}).length,A=[{id:"installed",label:n("providersTabConfigured"),count:k},{id:"all",label:n("providersTabAll"),count:I.length}],P=x.useMemo(()=>{const f=(r==null?void 0:r.providers)??[],v=(t==null?void 0:t.providers)??{},N=j.trim().toLowerCase();return f.filter(M=>{var E;return c==="installed"?!!((E=v[M.name])!=null&&E.apiKeySet):!0}).filter(M=>{var R,$;return N?((($=(R=v[M.name])==null?void 0:R.displayName)==null?void 0:$.trim())||M.displayName||M.name).toLowerCase().includes(N)||M.name.toLowerCase().includes(N):!0})},[r,t,c,j]);x.useEffect(()=>{if(P.length===0){u(void 0);return}P.some(v=>v.name===d)||u(P[0].name)},[P,d]);const H=d,ne=async()=>{try{const f=await l.mutateAsync({data:{}});g("all"),b(""),u(f.name)}catch{}};return!t||!r?e.jsx("div",{className:"p-8",children:n("providersLoading")}):e.jsxs(Yt,{children:[e.jsx(Zt,{title:n("providersPageTitle"),description:n("providersPageDescription")}),e.jsxs("div",{className:Vt,children:[e.jsxs("section",{className:Qt,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Xt,{tabs:A,activeTab:c,onChange:g,className:"mb-0"}),e.jsxs(K,{type:"button",variant:"outline",className:"w-full justify-center",onClick:ne,disabled:l.isPending,children:[e.jsx(_e,{className:"mr-2 h-4 w-4"}),l.isPending?n("saving"):n("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(It,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(X,{value:j,onChange:f=>b(f.target.value),placeholder:n("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:[P.map(f=>{var Y;const v=t.providers[f.name],N=!!(v!=null&&v.apiKeySet),M=H===f.name,E=((Y=v==null?void 0:v.displayName)==null?void 0:Y.trim())||f.displayName||f.name,_=le(`providers.${f.name}`,w),R=(v==null?void 0:v.apiBase)||f.defaultApiBase||"",U=ds(R)||(_==null?void 0:_.help)||n("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>u(f.name),className:de("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(qt,{name:f.name,src:f.logo?`/logos/${f.logo}`:null,className:de("h-10 w-10 rounded-lg border",N?"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:f.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:E}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:U})]})]}),e.jsx(mt,{status:N?"ready":"setup",label:N?n("statusReady"):n("statusSetup"),className:"min-w-[56px] justify-center"})]})},f.name)}),P.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(Dt,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:n("providersNoMatch")})]})]})]}),e.jsx(cs,{providerName:H,onProviderDeleted:f=>{f===d&&u(void 0)}})]})]})}export{Cs as ProvidersList};
1
+ import{r as x,j as e,au as Mt,av as Tt,ao as ot,ai as _e,b as kt,e as F,aw as tt,ax as st,C as St,ay as Lt,s as It,K as Dt}from"./vendor-DKBNiC31.js";import{c as de,I as X,B as K,t as n,u as ct,a as dt,b as ut,U as Et,V as _t,W as $t,X as Bt,Y as Kt,Z as zt,_ as Ft,S as Te,e as ke,f as Se,g as Le,h as ye,$ as Ot}from"./index-BEgClaDH.js";import{L as O}from"./label-DD61y-4v.js";import{a as Ht,b as Rt,c as Wt}from"./popover-DsugZ6rp.js";import{S as mt,L as qt}from"./LogoBadge-CYQ_b7jk.js";import{h as le}from"./config-hints-CApS3K_7.js";import{c as Ut,b as Gt,C as Vt,a as Qt}from"./config-layout-BHnOoweL.js";import{T as Xt}from"./tabs-custom-9ihB5Jem.js";import{P as Yt,a as Zt}from"./page-layout-CfnoVycc.js";import"./index-CPDASUXh.js";function Jt({isSet:t,className:r,value:a,onChange:l,placeholder:c,...g}){const[d,u]=x.useState(!1),[j,b]=x.useState(!1),w=typeof a=="string"&&a.length>0,I=t&&!w&&!j;return e.jsxs("div",{className:"relative",children:[I?e.jsx("div",{onClick:()=>b(!0),className:de("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",r),children:"••••••••••••"}):e.jsx(X,{type:d?"text":"password",className:de("pr-12",r),value:a,onChange:l,onBlur:()=>{w||b(!1)},placeholder:c,autoFocus:j,...g}),e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:(t||w)&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(!d),children:d?e.jsx(Mt,{className:"h-4 w-4"}):e.jsx(Tt,{className:"h-4 w-4"})})})]})}function es({value:t,onChange:r,className:a}){const l=t?Object.entries(t):[],c=(u,j,b)=>{const w=[...l];w[u]=[j,b],r(Object.fromEntries(w))},g=()=>{r({...t,"":""})},d=u=>{const j=l.filter((b,w)=>w!==u);r(Object.fromEntries(j))};return e.jsxs("div",{className:de("space-y-2",a),children:[l.map(([u,j],b)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(X,{type:"text",value:u,onChange:w=>c(b,w.target.value,j),placeholder:n("headerName"),className:"flex-1"}),e.jsx(X,{type:"text",value:j,onChange:w=>c(b,u,w.target.value),placeholder:n("headerValue"),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(b),children:e.jsx(ot,{className:"h-4 w-4 text-red-500"})})]},b)),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(_e,{className:"h-4 w-4 mr-2"}),n("add")]})]})}const ts={displayName:"",apiKeySet:!1,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},Ee=["off","minimal","low","medium","high","adaptive","xhigh"],ss=new Set(Ee);function ce(t){if(!t)return null;const r=Object.entries(t).map(([a,l])=>[a.trim(),l]).filter(([a])=>a.length>0);return r.length===0?null:Object.fromEntries(r)}function nt(t,r){const a=ce(t),l=ce(r);if(a===null&&l===null)return!0;if(!a||!l)return!1;const c=Object.entries(a).sort(([d],[u])=>d.localeCompare(u)),g=Object.entries(l).sort(([d],[u])=>d.localeCompare(u));return c.length!==g.length?!1:c.every(([d,u],j)=>d===g[j][0]&&u===g[j][1])}function Ie(t){if(!t||t.length===0)return[];const r=new Set;for(const a of t){const l=a.trim();l&&r.add(l)}return[...r]}function ns(t,r){const a=t.trim();if(!a||!r.trim())return a;const l=`${r.trim()}/`;return a.startsWith(l)?a.slice(l.length):a}function oe(t,r){let a=t.trim();if(!a)return"";for(const l of r){const c=l.trim();c&&(a=ns(a,c))}return a.trim()}function je(t,r){return t.length!==r.length?!1:t.every((a,l)=>a===r[l])}function rs(t,r){const a=[...t];for(const l of r)a.includes(l)||a.push(l);return a}function as(t,r){return r.length===0?t:r.every(l=>!t.includes(l))?rs(t,r):r}function is(t,r){return je(t,r)?[]:t}function $e(t){if(typeof t!="string")return null;const r=t.trim().toLowerCase();return r&&ss.has(r)?r:null}function ht(t){if(!Array.isArray(t))return[];const r=[];for(const a of t){const l=$e(a);!l||r.includes(l)||r.push(l)}return r}function ls(t,r){if(!t)return{};const a={};for(const[l,c]of Object.entries(t)){const g=oe(l,r);if(!g)continue;const d=ht(c==null?void 0:c.supported);if(d.length===0)continue;const u=$e(c==null?void 0:c.default);a[g]=u&&d.includes(u)?{supported:d,default:u}:{supported:d}}return a}function De(t,r){const a=new Set(r.map(c=>c.trim()).filter(Boolean)),l={};for(const[c,g]of Object.entries(t)){if(!a.has(c))continue;const d=ht(g.supported);if(d.length===0)continue;const u=$e(g.default);l[c]=u&&d.includes(u)?{supported:d,default:u}:{supported:d}}return l}function rt(t,r){const a=Object.keys(t).sort(),l=Object.keys(r).sort();if(a.length!==l.length)return!1;for(let c=0;c<a.length;c+=1){const g=a[c];if(g!==l[c])return!1;const d=t[g],u=r[g];if(!d||!u)return!1;const j=[...d.supported].sort(),b=[...u.supported].sort();if(!je(j,b)||(d.default??null)!==(u.default??null))return!1}return!0}function at(t){return t==="off"?n("chatThinkingLevelOff"):t==="minimal"?n("chatThinkingLevelMinimal"):t==="low"?n("chatThinkingLevelLow"):t==="medium"?n("chatThinkingLevelMedium"):t==="high"?n("chatThinkingLevelHigh"):t==="adaptive"?n("chatThinkingLevelAdaptive"):n("chatThinkingLevelXhigh")}function os(t){var j,b,w,I,D;const{providerName:r,methods:a,defaultMethodId:l,language:c}=t;if(a.length===0)return"";const g=new Map;for(const k of a){const A=k.id.trim();A&&g.set(A.toLowerCase(),A)}const d=(...k)=>{for(const A of k){const P=g.get(A.toLowerCase());if(P)return P}},u=l==null?void 0:l.trim();if(r==="minimax-portal"){if(c==="zh")return d("cn","china-mainland")??d(u??"")??((j=a[0])==null?void 0:j.id)??"";if(c==="en")return d("global","intl","international")??d(u??"")??((b=a[0])==null?void 0:b.id)??""}if(u){const k=d(u);if(k)return k}return c==="zh"?d("cn")??((w=a[0])==null?void 0:w.id)??"":c==="en"?d("global")??((I=a[0])==null?void 0:I.id)??"":((D=a[0])==null?void 0:D.id)??""}function it(t){return t.required&&t.hasDefault&&t.optionCount>1&&t.optionCount<=3}function lt(t){const{value:r,onChange:a,options:l}=t;return e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(c=>{const g=c.value===r;return e.jsx("button",{type:"button",onClick:()=>a(c.value),"aria-pressed":g,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${g?"border-primary bg-primary text-white shadow-sm":"border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary"}`,children:c.label},c.value)})})}function cs({providerName:t,onProviderDeleted:r}){var Ve,Qe,Xe,Ye,Ze,Je,et;const a=kt(),{data:l}=ct(),{data:c}=dt(),{data:g}=ut(),d=Et(),u=_t(),j=$t(),b=Bt(),w=Kt(),I=zt(),[D,k]=x.useState(""),[A,P]=x.useState(""),[H,ne]=x.useState(null),[f,v]=x.useState("auto"),[N,M]=x.useState([]),[E,_]=x.useState({}),[R,$]=x.useState(""),[U,Y]=x.useState(""),[be,pt]=x.useState(!1),[ve,ue]=x.useState(!1),[me,W]=x.useState(null),[Be,B]=x.useState(""),[Ke,he]=x.useState(""),pe=x.useRef(null),i=c==null?void 0:c.providers.find(s=>s.name===t),T=(t?l==null?void 0:l.providers[t]:null)??ts,xe=g==null?void 0:g.uiHints,Z=!!(i!=null&&i.isCustom),J=t?le(`providers.${t}.apiKey`,xe):void 0,z=t?le(`providers.${t}.apiBase`,xe):void 0,we=t?le(`providers.${t}.extraHeaders`,xe):void 0,Ne=t?le(`providers.${t}.wireApi`,xe):void 0,ze=(i==null?void 0:i.displayName)||t||"",ee=(T.displayName||"").trim()||ze,xt=U.trim()||ee||t||n("providersSelectPlaceholder"),Fe=(i==null?void 0:i.modelPrefix)||t||"",q=x.useMemo(()=>Ie([Fe,t||""]),[Fe,t]),Ce=(i==null?void 0:i.defaultApiBase)||"",re=T.apiBase||Ce,Ae=ce(T.extraHeaders||null),ae=T.wireApi||(i==null?void 0:i.defaultWireApi)||"auto",Pe=x.useMemo(()=>Ie(((i==null?void 0:i.defaultModels)??[]).map(s=>oe(s,q))),[i==null?void 0:i.defaultModels,q]),Oe=x.useMemo(()=>Ie((T.models??[]).map(s=>oe(s,q))),[T.models,q]),G=x.useMemo(()=>as(Pe,Oe),[Pe,Oe]),ie=x.useMemo(()=>De(ls(T.modelThinking,q),G),[G,q,T.modelThinking]),V=Ft(),ft=((Ve=i==null?void 0:i.apiBaseHelp)==null?void 0:Ve[V])||((Qe=i==null?void 0:i.apiBaseHelp)==null?void 0:Qe.en)||(z==null?void 0:z.help)||n("providerApiBaseHelp"),p=i==null?void 0:i.auth,S=x.useMemo(()=>(p==null?void 0:p.methods)??[],[p==null?void 0:p.methods]),He=x.useMemo(()=>S.map(s=>{var o,h;return{value:s.id,label:((o=s.label)==null?void 0:o[V])||((h=s.label)==null?void 0:h.en)||s.id}}),[S,V]),fe=x.useMemo(()=>os({providerName:t,methods:S,defaultMethodId:p==null?void 0:p.defaultMethodId,language:V}),[t,p==null?void 0:p.defaultMethodId,S,V]),te=x.useMemo(()=>{var o;if(!S.length)return"";const s=Ke.trim();return s&&S.some(h=>h.id===s)?s:fe||((o=S[0])==null?void 0:o.id)||""},[Ke,fe,S]),se=x.useMemo(()=>S.find(s=>s.id===te),[S,te]),Re=((Xe=se==null?void 0:se.hint)==null?void 0:Xe[V])||((Ye=se==null?void 0:se.hint)==null?void 0:Ye.en)||"",gt=it({required:(p==null?void 0:p.kind)==="device_code",hasDefault:!!((Ze=p==null?void 0:p.defaultMethodId)!=null&&Ze.trim()),optionCount:S.length}),We=((Je=p==null?void 0:p.note)==null?void 0:Je[V])||((et=p==null?void 0:p.note)==null?void 0:et.en)||(p==null?void 0:p.displayName)||"",Me=((i==null?void 0:i.wireApiOptions)||["auto","chat","responses"]).map(s=>({value:s,label:s==="chat"?n("wireApiChat"):s==="responses"?n("wireApiResponses"):n("wireApiAuto")})),yt=it({required:!!(i!=null&&i.supportsWireApi),hasDefault:typeof(i==null?void 0:i.defaultWireApi)=="string"&&i.defaultWireApi.length>0,optionCount:Me.length}),L=x.useCallback(()=>{pe.current!==null&&(window.clearTimeout(pe.current),pe.current=null)},[]),qe=x.useCallback((s,o)=>{L(),pe.current=window.setTimeout(()=>{(async()=>{if(t)try{const h=await w.mutateAsync({provider:t,data:{sessionId:s}});if(h.status==="pending"){B(n("providerAuthWaitingBrowser")),qe(s,h.nextPollMs??o);return}if(h.status==="authorized"){W(null),L(),B(n("providerAuthCompleted")),F.success(n("providerAuthCompleted")),a.invalidateQueries({queryKey:["config"]}),a.invalidateQueries({queryKey:["config-meta"]});return}W(null),L(),B(h.message||`Authorization ${h.status}.`),F.error(h.message||`Authorization ${h.status}.`)}catch(h){W(null),L();const m=h instanceof Error?h.message:String(h);B(m),F.error(`Authorization failed: ${m}`)}})()},Math.max(1e3,o))},[L,w,t,a]);x.useEffect(()=>{if(!t){k(""),P(""),ne(null),v("auto"),M([]),_({}),$(""),Y(""),W(null),B(""),he(""),L();return}k(""),P(re),ne(T.extraHeaders||null),v(ae),M(G),_(ie),$(""),Y(ee),W(null),B(""),he(fe),L()},[t,re,T.extraHeaders,ae,G,ie,ee,fe,L]),x.useEffect(()=>()=>L(),[L]),x.useEffect(()=>{_(s=>De(s,N))},[N]);const Ue=x.useMemo(()=>{if(!t)return!1;const s=D.trim().length>0,o=A.trim()!==re.trim(),h=!nt(H,Ae),m=i!=null&&i.supportsWireApi?f!==ae:!1,y=!je(N,G),C=!rt(E,ie),ge=Z?U.trim()!==ee:!1;return s||o||h||m||y||C||ge},[t,Z,U,ee,D,A,re,H,Ae,i==null?void 0:i.supportsWireApi,f,ae,N,G,E,ie]),Ge=()=>{const s=oe(R,q);if(s){if(N.includes(s)){$("");return}M(o=>[...o,s]),$("")}},jt=(s,o)=>{_(h=>{const m=h[s],y=(m==null?void 0:m.supported)??[],C=y.includes(o)?y.filter(Q=>Q!==o):Ee.filter(Q=>Q===o||y.includes(Q));if(C.length===0){const Q={...h};return delete Q[s],Q}const ge=m!=null&&m.default&&C.includes(m.default)?m.default:void 0;return{...h,[s]:ge?{supported:C,default:ge}:{supported:C}}})},bt=(s,o)=>{_(h=>{const m=h[s];return!m||m.supported.length===0||o&&!m.supported.includes(o)?h:{...h,[s]:o?{supported:m.supported,default:o}:{supported:m.supported}}})},vt=s=>{if(s.preventDefault(),!t)return;const o={},h=D.trim(),m=A.trim(),y=ce(H),C=U.trim();Z&&C!==ee&&(o.displayName=C.length>0?C:null),h.length>0&&(o.apiKey=h),m!==re.trim()&&(o.apiBase=m.length>0&&m!==Ce?m:null),nt(y,Ae)||(o.extraHeaders=y),i!=null&&i.supportsWireApi&&f!==ae&&(o.wireApi=f),je(N,G)||(o.models=is(N,Pe)),rt(E,ie)||(o.modelThinking=De(E,N)),d.mutate({provider:t,data:o})},wt=async()=>{if(!t)return;const s=N.find(m=>m.trim().length>0)??"",o=oe(s,q),h={apiBase:A.trim(),extraHeaders:ce(H),model:o||null};D.trim().length>0&&(h.apiKey=D.trim()),i!=null&&i.supportsWireApi&&(h.wireApi=f);try{const m=await j.mutateAsync({provider:t,data:h});if(m.success){F.success(`${n("providerTestConnectionSuccess")} (${m.latencyMs}ms)`);return}const y=[`provider=${m.provider}`,`latency=${m.latencyMs}ms`];m.model&&y.push(`model=${m.model}`),F.error(`${n("providerTestConnectionFailed")}: ${m.message} | ${y.join(" | ")}`)}catch(m){const y=m instanceof Error?m.message:String(m);F.error(`${n("providerTestConnectionFailed")}: ${y}`)}},Nt=async()=>{if(!(!t||!Z||!window.confirm(n("providerDeleteConfirm"))))try{await u.mutateAsync({provider:t}),r==null||r(t)}catch{}},Ct=async()=>{if(!(!t||(p==null?void 0:p.kind)!=="device_code"))try{B("");const s=await b.mutateAsync({provider:t,data:te?{methodId:te}:{}});if(!s.sessionId||!s.verificationUri)throw new Error(n("providerAuthStartFailed"));W(s.sessionId),B(`${n("providerAuthOpenPrompt")}${s.userCode}${n("providerAuthOpenPromptSuffix")}`),window.open(s.verificationUri,"_blank","noopener,noreferrer"),qe(s.sessionId,s.intervalMs)}catch(s){const o=s instanceof Error?s.message:String(s);W(null),L(),B(o),F.error(`${n("providerAuthStartFailed")}: ${o}`)}},At=async()=>{if(!(!t||(p==null?void 0:p.kind)!=="device_code"))try{L(),W(null);const s=await I.mutateAsync({provider:t}),o=s.expiresAt?` (expires: ${s.expiresAt})`:"";B(`${n("providerAuthImportStatusPrefix")}${o}`),F.success(n("providerAuthImportSuccess")),a.invalidateQueries({queryKey:["config"]}),a.invalidateQueries({queryKey:["config-meta"]})}catch(s){const o=s instanceof Error?s.message:String(s);B(o),F.error(`${n("providerAuthImportFailed")}: ${o}`)}};if(!t||!i)return e.jsx("div",{className:Ut,children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:n("providersSelectTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:n("providersSelectDescription")})]})});const Pt=T.apiKeySet?n("statusReady"):n("statusSetup");return e.jsxs("div",{className:Gt,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:xt}),e.jsxs("div",{className:"flex items-center gap-3",children:[Z&&e.jsx("button",{type:"button",onClick:Nt,disabled:u.isPending,className:"text-gray-400 hover:text-red-500 transition-colors",title:n("providerDelete"),children:e.jsx(ot,{className:"h-4 w-4"})}),e.jsx(mt,{status:T.apiKeySet?"ready":"setup",label:Pt})]})]})}),e.jsxs("form",{onSubmit:vt,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:[Z&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"providerDisplayName",className:"text-sm font-medium text-gray-900",children:n("providerDisplayName")}),e.jsx(X,{id:"providerDisplayName",type:"text",value:U,onChange:s=>Y(s.target.value),placeholder:ze||n("providerDisplayNamePlaceholder"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerDisplayNameHelpShort")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiKey",className:"text-sm font-medium text-gray-900",children:(J==null?void 0:J.label)??n("apiKey")}),e.jsx(Jt,{id:"apiKey",value:D,isSet:T.apiKeySet,onChange:s=>k(s.target.value),placeholder:(J==null?void 0:J.placeholder)??n("enterApiKey"),className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:n("leaveBlankToKeepUnchanged")})]}),(p==null?void 0:p.kind)==="device_code"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:p.displayName||n("providerAuthSectionTitle")}),We?e.jsx("p",{className:"text-xs text-gray-600",children:We}):null,S.length>1?e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-xs font-medium text-gray-700",children:n("providerAuthMethodLabel")}),gt?e.jsx(lt,{value:te,onChange:he,options:He}):e.jsxs(Te,{value:te,onValueChange:he,children:[e.jsx(ke,{className:"h-8 rounded-lg bg-white",children:e.jsx(Se,{placeholder:n("providerAuthMethodPlaceholder")})}),e.jsx(Le,{children:He.map(s=>e.jsx(ye,{value:s.value,children:s.label},s.value))})]}),Re?e.jsx("p",{className:"text-xs text-gray-500",children:Re}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:Ct,disabled:b.isPending||!!me,children:b.isPending?n("providerAuthStarting"):me?n("providerAuthAuthorizing"):n("providerAuthAuthorizeInBrowser")}),p.supportsCliImport?e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:At,disabled:I.isPending,children:I.isPending?n("providerAuthImporting"):n("providerAuthImportFromCli")}):null,me?e.jsxs("span",{className:"text-xs text-gray-500",children:[n("providerAuthSessionLabel"),": ",me.slice(0,8),"…"]}):null]}),Be?e.jsx("p",{className:"text-xs text-gray-600",children:Be}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"apiBase",className:"text-sm font-medium text-gray-900",children:(z==null?void 0:z.label)??n("apiBase")}),e.jsx(X,{id:"apiBase",type:"text",value:A,onChange:s=>P(s.target.value),placeholder:Ce||(z==null?void 0:z.placeholder)||"https://api.example.com",className:"rounded-xl"}),e.jsx("p",{className:"text-xs text-gray-500",children:ft})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:n("providerModelsTitle")}),!ve&&e.jsxs("button",{type:"button",onClick:()=>ue(!0),className:"text-xs text-primary hover:text-primary/80 font-medium flex items-center gap-1",children:[e.jsx(_e,{className:"h-3 w-3"}),n("providerAddModel")]})]}),ve&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{value:R,onChange:s=>$(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Ge()),s.key==="Escape"&&(ue(!1),$(""))},placeholder:n("providerModelInputPlaceholder"),className:"flex-1 rounded-xl",autoFocus:!0}),e.jsx(K,{type:"button",size:"sm",onClick:Ge,disabled:R.trim().length===0,children:n("add")}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{ue(!1),$("")},children:e.jsx(tt,{className:"h-4 w-4"})})]}),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:n("providerModelsEmptyShort")}),!ve&&e.jsx("button",{type:"button",onClick:()=>ue(!0),className:"mt-2 text-sm text-primary hover:text-primary/80 font-medium",children:n("providerAddFirstModel")})]}):e.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(s=>{const o=E[s],h=(o==null?void 0:o.supported)??[],m=(o==null?void 0:o.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:s}),e.jsxs(Ht,{children:[e.jsx(Rt,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":n("providerModelThinkingTitle"),title:n("providerModelThinkingTitle"),children:e.jsx(st,{className:"h-3 w-3"})})}),e.jsxs(Wt,{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:n("providerModelThinkingTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerModelThinkingHint")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ee.map(y=>{const C=h.includes(y);return e.jsx("button",{type:"button",onClick:()=>jt(s,y),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${C?"border-primary bg-primary text-white":"border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary"}`,children:at(y)},y)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(O,{className:"text-xs font-medium text-gray-700",children:n("providerModelThinkingDefault")}),e.jsxs(Te,{value:m??"__none__",onValueChange:y=>bt(s,y==="__none__"?null:y),disabled:h.length===0,children:[e.jsx(ke,{className:"h-8 rounded-lg bg-white text-xs",children:e.jsx(Se,{})}),e.jsxs(Le,{children:[e.jsx(ye,{value:"__none__",children:n("providerModelThinkingDefaultNone")}),h.map(y=>e.jsx(ye,{value:y,children:at(y)},y))]})]}),h.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:n("providerModelThinkingNoSupported")}):null]})]})]}),e.jsx("button",{type:"button",onClick:()=>{M(y=>y.filter(C=>C!==s)),_(y=>{const C={...y};return delete C[s],C})},className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 transition-opacity hover:bg-gray-100 hover:text-gray-600 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100","aria-label":n("remove"),children:e.jsx(tt,{className:"h-3 w-3"})})]},s)})})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>pt(!be),className:"flex w-full items-center justify-between text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),n("providerAdvancedSettings")]}),e.jsx(St,{className:`h-4 w-4 transition-transform ${be?"rotate-180":""}`})]}),be&&e.jsxs("div",{className:"mt-4 space-y-5",children:[i.supportsWireApi&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"wireApi",className:"text-sm font-medium text-gray-900",children:(Ne==null?void 0:Ne.label)??n("wireApi")}),yt?e.jsx(lt,{value:f,onChange:s=>v(s),options:Me}):e.jsxs(Te,{value:f,onValueChange:s=>v(s),children:[e.jsx(ke,{className:"rounded-xl",children:e.jsx(Se,{})}),e.jsx(Le,{children:Me.map(s=>e.jsx(ye,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-sm font-medium text-gray-900",children:(we==null?void 0:we.label)??n("extraHeaders")}),e.jsx(es,{value:H,onChange:ne}),e.jsx("p",{className:"text-xs text-gray-500",children:n("providerExtraHeadersHelpShort")})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:wt,disabled:j.isPending,children:[e.jsx(Lt,{className:"mr-1.5 h-4 w-4"}),j.isPending?n("providerTestingConnection"):n("providerTestConnection")]}),e.jsx(K,{type:"submit",disabled:d.isPending||!Ue,children:d.isPending?n("saving"):Ue?n("save"):n("unchanged")})]})]})]})}function ds(t){if(!t)return null;try{const r=new URL(t),a=r.pathname&&r.pathname!=="/"?r.pathname:"";return`${r.host}${a}`}catch{return t.replace(/^https?:\/\//,"")}}function Cs(){const{data:t}=ct(),{data:r}=dt(),{data:a}=ut(),l=Ot(),[c,g]=x.useState("installed"),[d,u]=x.useState(),[j,b]=x.useState(""),w=a==null?void 0:a.uiHints,I=(r==null?void 0:r.providers)??[],D=(t==null?void 0:t.providers)??{},k=I.filter(f=>{var v;return(v=D[f.name])==null?void 0:v.apiKeySet}).length,A=[{id:"installed",label:n("providersTabConfigured"),count:k},{id:"all",label:n("providersTabAll"),count:I.length}],P=x.useMemo(()=>{const f=(r==null?void 0:r.providers)??[],v=(t==null?void 0:t.providers)??{},N=j.trim().toLowerCase();return f.filter(M=>{var E;return c==="installed"?!!((E=v[M.name])!=null&&E.apiKeySet):!0}).filter(M=>{var R,$;return N?((($=(R=v[M.name])==null?void 0:R.displayName)==null?void 0:$.trim())||M.displayName||M.name).toLowerCase().includes(N)||M.name.toLowerCase().includes(N):!0})},[r,t,c,j]);x.useEffect(()=>{if(P.length===0){u(void 0);return}P.some(v=>v.name===d)||u(P[0].name)},[P,d]);const H=d,ne=async()=>{try{const f=await l.mutateAsync({data:{}});g("all"),b(""),u(f.name)}catch{}};return!t||!r?e.jsx("div",{className:"p-8",children:n("providersLoading")}):e.jsxs(Yt,{children:[e.jsx(Zt,{title:n("providersPageTitle"),description:n("providersPageDescription")}),e.jsxs("div",{className:Vt,children:[e.jsxs("section",{className:Qt,children:[e.jsxs("div",{className:"border-b border-gray-100 px-4 pt-4 pb-3 space-y-3",children:[e.jsx(Xt,{tabs:A,activeTab:c,onChange:g,className:"mb-0"}),e.jsxs(K,{type:"button",variant:"outline",className:"w-full justify-center",onClick:ne,disabled:l.isPending,children:[e.jsx(_e,{className:"mr-2 h-4 w-4"}),l.isPending?n("saving"):n("providerAddCustom")]})]}),e.jsx("div",{className:"border-b border-gray-100 px-4 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(It,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx(X,{value:j,onChange:f=>b(f.target.value),placeholder:n("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:[P.map(f=>{var Y;const v=t.providers[f.name],N=!!(v!=null&&v.apiKeySet),M=H===f.name,E=((Y=v==null?void 0:v.displayName)==null?void 0:Y.trim())||f.displayName||f.name,_=le(`providers.${f.name}`,w),R=(v==null?void 0:v.apiBase)||f.defaultApiBase||"",U=ds(R)||(_==null?void 0:_.help)||n("providersDefaultDescription");return e.jsx("button",{type:"button",onClick:()=>u(f.name),className:de("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(qt,{name:f.name,src:f.logo?`/logos/${f.logo}`:null,className:de("h-10 w-10 rounded-lg border",N?"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:f.name[0]})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:E}),e.jsx("p",{className:"line-clamp-1 text-[11px] text-gray-500",children:U})]})]}),e.jsx(mt,{status:N?"ready":"setup",label:N?n("statusReady"):n("statusSetup"),className:"min-w-[56px] justify-center"})]})},f.name)}),P.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(Dt,{className:"h-5 w-5 text-gray-300"})}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:n("providersNoMatch")})]})]})]}),e.jsx(cs,{providerName:H,onProviderDeleted:f=>{f===d&&u(void 0)}})]})]})}export{Cs as ProvidersList};
@@ -1 +1 @@
1
- import{r as p,j as e,ao as ee,a3 as ae,aU as de,e as se}from"./vendor-CkJHmX1g.js";import{u as me,b as he,a2 as ue,t,C as R,a3 as $,a4 as z,a5 as D,z 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-CsvP4CER.js";import{S as pe}from"./switch-BK8jIzto.js";import{h as x}from"./config-hints-CApS3K_7.js";import{P as xe,a as ge}from"./page-layout-aw88k7tG.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),[G,J]=p.useState(2e5),[Q,W]=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),J(d.agents.defaults.contextTokens??2e5),W(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 X,Y,Z,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((X=s.match.accountId)==null?void 0:X.trim())??"",C=(Y=s.match.peer)==null?void 0:Y.kind,P=((H=(Z=s.match.peer)==null?void 0:Z.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,G),engine:Q.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:G,onChange:a=>J(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:Q,onChange:a=>W(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};
1
+ import{r as p,j as e,ao as ee,ai as ae,aU as de,e as se}from"./vendor-DKBNiC31.js";import{u as me,b as he,a2 as ue,t,C as R,a3 as $,a4 as z,a5 as D,z 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-BEgClaDH.js";import{S as pe}from"./switch-NX5OmUXQ.js";import{h as x}from"./config-hints-CApS3K_7.js";import{P as xe,a as ge}from"./page-layout-CfnoVycc.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),[G,J]=p.useState(2e5),[Q,W]=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),J(d.agents.defaults.contextTokens??2e5),W(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 X,Y,Z,H;const l=s.agentId.trim(),o=s.match.channel.trim(),m=((X=s.match.accountId)==null?void 0:X.trim())??"",C=(Y=s.match.peer)==null?void 0:Y.kind,P=((H=(Z=s.match.peer)==null?void 0:Z.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,G),engine:Q.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:G,onChange:a=>J(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:Q,onChange:a=>W(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};
@@ -1 +1 @@
1
- import{r as l,j as e,s as X,a7 as Z,K as $}from"./vendor-CkJHmX1g.js";import{P as ee,a as se}from"./page-layout-aw88k7tG.js";import{u as ae,a as re,R as le,t as a,c as k,B as j,S as b,e as y,f as g,g as N,h as m,I as h}from"./index-CsvP4CER.js";import{L as c}from"./label-BGL-ztxh.js";import{C as te,a as ce,b as ne}from"./config-layout-BHnOoweL.js";const ie=[{value:"noLimit",label:"searchFreshnessNoLimit"},{value:"oneDay",label:"searchFreshnessOneDay"},{value:"oneWeek",label:"searchFreshnessOneWeek"},{value:"oneMonth",label:"searchFreshnessOneMonth"},{value:"oneYear",label:"searchFreshnessOneYear"}];function ue(){var O;const{data:u}=ae(),{data:n}=re(),x=le(),i=(n==null?void 0:n.search)??[],r=u==null?void 0:u.search,[t,f]=l.useState("bocha"),[S,P]=l.useState("bocha"),[d,C]=l.useState(["bocha"]),[w,B]=l.useState("10"),[A,T]=l.useState(""),[D,K]=l.useState("https://api.bocha.cn/v1/web-search"),[L,U]=l.useState(!0),[E,R]=l.useState("noLimit"),[F,V]=l.useState(""),[I,_]=l.useState("https://api.search.brave.com/res/v1/web/search");l.useEffect(()=>{r&&(f(r.provider),P(r.provider),C(r.enabledProviders),B(String(r.defaults.maxResults)),K(r.providers.bocha.baseUrl),U(!!r.providers.bocha.summary),R(r.providers.bocha.freshness??"noLimit"),_(r.providers.brave.baseUrl))},[r]);const v=l.useMemo(()=>i.find(s=>s.name===t),[i,t]),G=r==null?void 0:r.providers[t],p=d.includes(t),H=(r==null?void 0:r.providers.bocha.docsUrl)??((O=n==null?void 0:n.search.find(s=>s.name==="bocha"))==null?void 0:O.docsUrl)??"https://open.bocha.cn",W=p?a("searchProviderDeactivate"):a("searchProviderActivate"),M=(s=d,o=S)=>({provider:o,enabledProviders:s,defaults:{maxResults:Number(w)||10},providers:{bocha:{apiKey:A||void 0,baseUrl:D,summary:L,freshness:E},brave:{apiKey:F||void 0,baseUrl:I}}}),Y=()=>{const s=p?d.filter(o=>o!==t):[...d,t];C(s),x.mutate({data:M(s)})},q=s=>{P(s)},z=s=>{s.preventDefault(),x.mutate({data:M()})};return!r||i.length===0?e.jsx("div",{className:"p-8",children:a("loading")}):e.jsxs(ee,{children:[e.jsx(se,{title:a("searchPageTitle"),description:a("searchPageDescription")}),e.jsxs("div",{className:te,children:[e.jsxs("section",{className:ce,children:[e.jsx("div",{className:"border-b border-gray-100 px-4 py-4",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-gray-500",children:a("searchChannels")})}),e.jsx("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:i.map(s=>{const o=r.providers[s.name],J=d.includes(s.name),Q=t===s.name;return e.jsx("button",{type:"button",onClick:()=>f(s.name),className:k("w-full rounded-xl border p-3 text-left transition-all",Q?"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:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:s.displayName}),e.jsx("p",{className:"line-clamp-2 text-[11px] text-gray-500",children:s.name==="bocha"?a("searchProviderBochaDescription"):a("searchProviderBraveDescription")})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600",children:o.apiKeySet?a("searchStatusConfigured"):a("searchStatusNeedsSetup")}),J?e.jsx("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700",children:a("searchProviderActivated")}):null]})]})},s.name)})})]}),e.jsx("form",{onSubmit:z,className:k(ne,"p-6"),children:!v||!G?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-gray-500",children:a("searchNoProviderSelected")}):e.jsxs("div",{className:"space-y-6 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white",children:e.jsx(X,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:v.displayName}),e.jsx("p",{className:"text-sm text-gray-500",children:v.description})]})]}),e.jsx(j,{type:"button",variant:p?"secondary":"outline",className:"rounded-xl",onClick:Y,children:W})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchActiveProvider")}),e.jsxs(b,{value:S,onValueChange:q,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:i.map(s=>e.jsx(m,{value:s.name,children:s.displayName},s.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchDefaultMaxResults")}),e.jsx(h,{value:w,onChange:s=>B(s.target.value),inputMode:"numeric",className:"rounded-xl"})]})]}),t==="bocha"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:A,onChange:s=>T(s.target.value),placeholder:r.providers.bocha.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:D,onChange:s=>K(s.target.value),className:"rounded-xl"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderSummary")}),e.jsxs(b,{value:L?"true":"false",onValueChange:s=>U(s==="true"),children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsxs(N,{children:[e.jsx(m,{value:"true",children:a("enabled")}),e.jsx(m,{value:"false",children:a("disabled")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderFreshness")}),e.jsxs(b,{value:E,onValueChange:R,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:ie.map(s=>e.jsx(m,{value:s.value,children:a(s.label)},s.value))})]})]})]}),e.jsx("div",{className:"space-y-2",children:e.jsx("a",{href:H,target:"_blank",rel:"noreferrer",children:e.jsxs(j,{type:"button",variant:"outline",className:"rounded-xl",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),a("searchProviderOpenDocs")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:F,onChange:s=>V(s.target.value),placeholder:r.providers.brave.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:I,onChange:s=>_(s.target.value),className:"rounded-xl"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(j,{type:"submit",disabled:x.isPending,children:[e.jsx($,{className:"mr-2 h-4 w-4"}),x.isPending?a("saving"):a("saveChanges")]})})]})})]})]})}export{ue as SearchConfig};
1
+ import{r as l,j as e,s as X,a5 as Z,K as $}from"./vendor-DKBNiC31.js";import{P as ee,a as se}from"./page-layout-CfnoVycc.js";import{u as ae,a as re,R as le,t as a,c as k,B as j,S as b,e as y,f as g,g as N,h as m,I as h}from"./index-BEgClaDH.js";import{L as c}from"./label-DD61y-4v.js";import{C as te,a as ce,b as ne}from"./config-layout-BHnOoweL.js";const ie=[{value:"noLimit",label:"searchFreshnessNoLimit"},{value:"oneDay",label:"searchFreshnessOneDay"},{value:"oneWeek",label:"searchFreshnessOneWeek"},{value:"oneMonth",label:"searchFreshnessOneMonth"},{value:"oneYear",label:"searchFreshnessOneYear"}];function ue(){var O;const{data:u}=ae(),{data:n}=re(),x=le(),i=(n==null?void 0:n.search)??[],r=u==null?void 0:u.search,[t,f]=l.useState("bocha"),[S,P]=l.useState("bocha"),[d,C]=l.useState(["bocha"]),[w,B]=l.useState("10"),[A,T]=l.useState(""),[D,K]=l.useState("https://api.bocha.cn/v1/web-search"),[L,U]=l.useState(!0),[E,R]=l.useState("noLimit"),[F,V]=l.useState(""),[I,_]=l.useState("https://api.search.brave.com/res/v1/web/search");l.useEffect(()=>{r&&(f(r.provider),P(r.provider),C(r.enabledProviders),B(String(r.defaults.maxResults)),K(r.providers.bocha.baseUrl),U(!!r.providers.bocha.summary),R(r.providers.bocha.freshness??"noLimit"),_(r.providers.brave.baseUrl))},[r]);const v=l.useMemo(()=>i.find(s=>s.name===t),[i,t]),G=r==null?void 0:r.providers[t],p=d.includes(t),H=(r==null?void 0:r.providers.bocha.docsUrl)??((O=n==null?void 0:n.search.find(s=>s.name==="bocha"))==null?void 0:O.docsUrl)??"https://open.bocha.cn",W=p?a("searchProviderDeactivate"):a("searchProviderActivate"),M=(s=d,o=S)=>({provider:o,enabledProviders:s,defaults:{maxResults:Number(w)||10},providers:{bocha:{apiKey:A||void 0,baseUrl:D,summary:L,freshness:E},brave:{apiKey:F||void 0,baseUrl:I}}}),Y=()=>{const s=p?d.filter(o=>o!==t):[...d,t];C(s),x.mutate({data:M(s)})},q=s=>{P(s)},z=s=>{s.preventDefault(),x.mutate({data:M()})};return!r||i.length===0?e.jsx("div",{className:"p-8",children:a("loading")}):e.jsxs(ee,{children:[e.jsx(se,{title:a("searchPageTitle"),description:a("searchPageDescription")}),e.jsxs("div",{className:te,children:[e.jsxs("section",{className:ce,children:[e.jsx("div",{className:"border-b border-gray-100 px-4 py-4",children:e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-gray-500",children:a("searchChannels")})}),e.jsx("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:i.map(s=>{const o=r.providers[s.name],J=d.includes(s.name),Q=t===s.name;return e.jsx("button",{type:"button",onClick:()=>f(s.name),className:k("w-full rounded-xl border p-3 text-left transition-all",Q?"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:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-gray-900",children:s.displayName}),e.jsx("p",{className:"line-clamp-2 text-[11px] text-gray-500",children:s.name==="bocha"?a("searchProviderBochaDescription"):a("searchProviderBraveDescription")})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600",children:o.apiKeySet?a("searchStatusConfigured"):a("searchStatusNeedsSetup")}),J?e.jsx("span",{className:"rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700",children:a("searchProviderActivated")}):null]})]})},s.name)})})]}),e.jsx("form",{onSubmit:z,className:k(ne,"p-6"),children:!v||!G?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-gray-500",children:a("searchNoProviderSelected")}):e.jsxs("div",{className:"space-y-6 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white",children:e.jsx(X,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:v.displayName}),e.jsx("p",{className:"text-sm text-gray-500",children:v.description})]})]}),e.jsx(j,{type:"button",variant:p?"secondary":"outline",className:"rounded-xl",onClick:Y,children:W})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchActiveProvider")}),e.jsxs(b,{value:S,onValueChange:q,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:i.map(s=>e.jsx(m,{value:s.name,children:s.displayName},s.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchDefaultMaxResults")}),e.jsx(h,{value:w,onChange:s=>B(s.target.value),inputMode:"numeric",className:"rounded-xl"})]})]}),t==="bocha"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:A,onChange:s=>T(s.target.value),placeholder:r.providers.bocha.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:D,onChange:s=>K(s.target.value),className:"rounded-xl"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderSummary")}),e.jsxs(b,{value:L?"true":"false",onValueChange:s=>U(s==="true"),children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsxs(N,{children:[e.jsx(m,{value:"true",children:a("enabled")}),e.jsx(m,{value:"false",children:a("disabled")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderFreshness")}),e.jsxs(b,{value:E,onValueChange:R,children:[e.jsx(y,{className:"rounded-xl",children:e.jsx(g,{})}),e.jsx(N,{children:ie.map(s=>e.jsx(m,{value:s.value,children:a(s.label)},s.value))})]})]})]}),e.jsx("div",{className:"space-y-2",children:e.jsx("a",{href:H,target:"_blank",rel:"noreferrer",children:e.jsxs(j,{type:"button",variant:"outline",className:"rounded-xl",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),a("searchProviderOpenDocs")]})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("apiKey")}),e.jsx(h,{type:"password",value:F,onChange:s=>V(s.target.value),placeholder:r.providers.brave.apiKeyMasked||a("enterApiKey"),className:"rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:a("searchProviderBaseUrl")}),e.jsx(h,{value:I,onChange:s=>_(s.target.value),className:"rounded-xl"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(j,{type:"submit",disabled:x.isPending,children:[e.jsx($,{className:"mr-2 h-4 w-4"}),x.isPending?a("saving"):a("saveChanges")]})})]})})]})]})}export{ue as SearchConfig};
@@ -1,3 +1,3 @@
1
- import{r as u,j as e,ao as H,a3 as L,aU as G,e as J}from"./vendor-CkJHmX1g.js";import{u as K,ae as Q,t as a,C as R,a3 as T,a4 as M,a5 as O,z as A,S as x,e as m,f as p,g as j,h as o,I as h,B as _}from"./index-CsvP4CER.js";import{L as k}from"./label-BGL-ztxh.js";import{S as W}from"./switch-BK8jIzto.js";import{P as X,a as Y}from"./page-layout-aw88k7tG.js";const U=["env","file","exec"];function P(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function Z(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...P(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...P(n),source:"file",path:l.path}:{...P(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
1
+ import{r as u,j as e,ao as H,ai as L,aU as G,e as J}from"./vendor-DKBNiC31.js";import{u as K,ae as Q,t as a,C as R,a3 as T,a4 as M,a5 as O,z as A,S as x,e as m,f as p,g as j,h as o,I as h,B as _}from"./index-BEgClaDH.js";import{L as k}from"./label-DD61y-4v.js";import{S as W}from"./switch-NX5OmUXQ.js";import{P as X,a as Y}from"./page-layout-CfnoVycc.js";const U=["env","file","exec"];function P(n=""){return{alias:n,source:"env",prefix:"",path:"",command:"",argsText:"",cwd:"",timeoutMs:5e3}}function Z(){return{path:"",source:"env",provider:"",id:""}}function ee(n,l){return l.source==="env"?{...P(n),source:"env",prefix:l.prefix??""}:l.source==="file"?{...P(n),source:"file",path:l.path}:{...P(n),source:"exec",command:l.command,argsText:(l.args??[]).join(`
2
2
  `),cwd:l.cwd??"",timeoutMs:l.timeoutMs??5e3}}function se(n){return n.source==="env"?{source:"env",...n.prefix.trim()?{prefix:n.prefix.trim()}:{}}:n.source==="file"?{source:"file",path:n.path.trim(),format:"json"}:{source:"exec",command:n.command.trim(),args:n.argsText.split(`
3
3
  `).map(l=>l.trim()).filter(Boolean),...n.cwd.trim()?{cwd:n.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(n.timeoutMs||5e3))}}function ie(){const{data:n,isLoading:l}=K(),b=Q(),[D,y]=u.useState(!0),[I,E]=u.useState(""),[V,S]=u.useState(""),[F,$]=u.useState(""),[C,f]=u.useState([]),[q,v]=u.useState([]);u.useEffect(()=>{const s=n==null?void 0:n.secrets;if(!s){y(!0),E(""),S(""),$(""),f([]),v([]);return}y(!!s.enabled),E(s.defaults.env??""),S(s.defaults.file??""),$(s.defaults.exec??"");const t=Object.entries(s.providers).map(([c,i])=>ee(c,i)),r=Object.entries(s.refs).map(([c,i])=>({path:c,source:i.source,provider:i.provider??"",id:i.id}));f(t),v(r)},[n==null?void 0:n.secrets]);const w=u.useMemo(()=>{const s=C.map(t=>t.alias.trim()).filter(Boolean);return Array.from(new Set(s))},[C]),d=(s,t)=>{f(r=>r.map((c,i)=>i===s?{...c,...t}:c))},N=(s,t)=>{v(r=>r.map((c,i)=>i===s?{...c,...t}:c))},z=()=>{try{const s={};for(const[r,c]of C.entries()){const i=c.alias.trim();if(!i)throw new Error(`${a("providerAlias")} #${r+1} ${a("isRequired")}`);if(s[i])throw new Error(`${a("providerAlias")}: ${i} (${a("duplicate")})`);if(c.source==="file"&&!c.path.trim())throw new Error(`${a("secretFilePath")} #${r+1} ${a("isRequired")}`);if(c.source==="exec"&&!c.command.trim())throw new Error(`${a("secretExecCommand")} #${r+1} ${a("isRequired")}`);s[i]=se(c)}const t={};for(const[r,c]of q.entries()){const i=c.path.trim(),B=c.id.trim();if(!i)throw new Error(`${a("secretConfigPath")} #${r+1} ${a("isRequired")}`);if(!B)throw new Error(`${a("secretId")} #${r+1} ${a("isRequired")}`);const g=c.provider.trim();if(g&&!s[g])throw new Error(`${a("secretProviderAlias")}: ${g} ${a("notFound")}`);t[i]={source:c.source,...g?{provider:g}:{},id:B}}b.mutate({data:{enabled:D,defaults:{env:I.trim()||null,file:V.trim()||null,exec:F.trim()||null},providers:s,refs:t}})}catch(s){const t=s instanceof Error?s.message:String(s);J.error(t)}};return l?e.jsx("div",{className:"p-8 text-gray-400",children:a("loading")}):e.jsxs(X,{className:"space-y-6",children:[e.jsx(Y,{title:a("secretsPageTitle"),description:a("secretsPageDescription")}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secrets")}),e.jsx(O,{children:a("secretsEnabledHelp")})]}),e.jsxs(A,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-200 p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-800",children:a("enabled")}),e.jsx("p",{className:"text-xs text-gray-500",children:a("secretsEnabledHelp")})]}),e.jsx(W,{checked:D,onCheckedChange:y})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultEnvProvider")}),e.jsxs(x,{value:I||"__none__",onValueChange:s=>E(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultFileProvider")}),e.jsxs(x,{value:V||"__none__",onValueChange:s=>S(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:a("defaultExecProvider")}),e.jsxs(x,{value:F||"__none__",onValueChange:s=>$(s==="__none__"?"":s),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("noneOption")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretProvidersTitle")}),e.jsx(O,{children:a("secretProvidersDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[C.map((s,t)=>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-3 gap-3",children:[e.jsx(h,{value:s.alias,onChange:r=>d(t,{alias:r.target.value}),placeholder:a("providerAlias")}),e.jsxs(x,{value:s.source,onValueChange:r=>d(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(r=>r.filter((c,i)=>i!==t)),children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),a("removeProvider")]})]}),s.source==="env"&&e.jsx(h,{value:s.prefix,onChange:r=>d(t,{prefix:r.target.value}),placeholder:a("envPrefix")}),s.source==="file"&&e.jsx(h,{value:s.path,onChange:r=>d(t,{path:r.target.value}),placeholder:a("secretFilePath")}),s.source==="exec"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{value:s.command,onChange:r=>d(t,{command:r.target.value}),placeholder:a("secretExecCommand")}),e.jsx("textarea",{className:"min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono",value:s.argsText,onChange:r=>d(t,{argsText:r.target.value}),placeholder:a("secretExecArgs")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(h,{value:s.cwd,onChange:r=>d(t,{cwd:r.target.value}),placeholder:a("secretExecCwd")}),e.jsx(h,{type:"number",min:1,value:s.timeoutMs,onChange:r=>d(t,{timeoutMs:Number.parseInt(r.target.value,10)||5e3}),placeholder:a("secretExecTimeoutMs")})]})]})]},`provider-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>f(s=>[...s,P()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretProvider")]})]})]}),e.jsxs(R,{children:[e.jsxs(T,{children:[e.jsx(M,{children:a("secretRefsTitle")}),e.jsx(O,{children:a("secretRefsDescription")})]}),e.jsxs(A,{className:"space-y-3",children:[q.map((s,t)=>e.jsx("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(h,{value:s.path,onChange:r=>N(t,{path:r.target.value}),placeholder:a("secretConfigPath")}),e.jsx(h,{value:s.id,onChange:r=>N(t,{id:r.target.value}),placeholder:a("secretId")}),e.jsxs(x,{value:s.source,onValueChange:r=>N(t,{source:r}),children:[e.jsx(m,{children:e.jsx(p,{})}),e.jsx(j,{children:U.map(r=>e.jsx(o,{value:r,children:r},r))})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2",children:[e.jsxs(x,{value:s.provider||"__none__",onValueChange:r=>N(t,{provider:r==="__none__"?"":r}),children:[e.jsx(m,{children:e.jsx(p,{placeholder:a("secretProviderAlias")})}),e.jsxs(j,{children:[e.jsx(o,{value:"__none__",children:a("noneOption")}),w.map(r=>e.jsx(o,{value:r,children:r},r))]})]}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(r=>r.filter((c,i)=>i!==t)),children:e.jsx(H,{className:"h-4 w-4"})})]})]})},`ref-${t}`)),e.jsxs(_,{type:"button",variant:"outline",onClick:()=>v(s=>[...s,Z()]),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),a("addSecretRef")]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(_,{type:"button",onClick:z,disabled:b.isPending,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),b.isPending?a("saving"):a("save")]})})]})}export{ie as SecretsConfig};
@@ -1,2 +1,2 @@
1
- import{r,j as e,ap as I,s as J,aV as T,aS as X,z as Z,M as Q,aW as ee,aa as se,ac as te}from"./vendor-CkJHmX1g.js";import{u as ae}from"./useConfirmDialog-z0CE92iS.js";import{j as re,i as ne,l as le,ab as ie,ac as oe,t,B as f,c as i,S as de,e as ce,f as xe,g as me,h as U,I as k,ad as ue,s as he}from"./index-CsvP4CER.js";import{b as ge,a as fe,S as ye,e as be}from"./chat-message-BETwXLD4.js";import{P as pe,a as je}from"./page-layout-aw88k7tG.js";import"./index-COJdlL0e.js";const y="__unknown_channel__";function ve(a){return he(a)}function j(a){const l=a.indexOf(":");return l<=0?y:a.slice(0,l).trim()||y}function C(a){return a===y?t("sessionsUnknownChannel"):a}function Ne({session:a,channel:l,runStatus:d,isSelected:x,onSelect:n}){const b=C(l),m=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:n,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",x?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:i("font-semibold truncate pr-2 flex-1 text-sm",x?"text-brand-800":"text-gray-900"),children:m}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",x?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:b})]}),e.jsxs("div",{className:i("flex items-center text-xs justify-between mt-2 font-medium",x?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:d?e.jsx(ye,{status:d}):null}),e.jsx(ee,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ue(a.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:a.messageCount})]})]})]})}function we({message:a}){const l=a.role.toLowerCase()==="user",d=be(a.content).trim();return e.jsx("div",{className:i("flex w-full mb-6",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",l?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:l?e.jsx(se,{className:"w-4 h-4 text-primary-100"}):e.jsx(te,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 space-y-1 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4 mb-2",children:[e.jsx("span",{className:i("font-semibold text-xs",l?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",l?"text-primary-200":"text-gray-400"),children:ve(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:d||"-"})]})]})})}function _e(){var B,E,K,R;const[a,l]=r.useState(""),[d]=r.useState(100),[x]=r.useState(0),[n,b]=r.useState(null),[m,q]=r.useState("all"),[M,v]=r.useState(""),[L,N]=r.useState(""),[w,S]=r.useState(!1),F=r.useMemo(()=>({q:a.trim()||void 0,limit:d,activeMinutes:x}),[a,d,x]),g=re(F),D=ne({states:["queued","running"],limit:200}),u=le(n,200),p=ie(),_=oe(),{confirm:z,ConfirmDialog:V}=ae(),c=r.useMemo(()=>{var s;return((s=g.data)==null?void 0:s.sessions)??[]},[(B=g.data)==null?void 0:B.sessions]),P=r.useMemo(()=>{var s;return ge(((s=D.data)==null?void 0:s.runs)??[])},[(E=D.data)==null?void 0:E.runs]),O=r.useMemo(()=>fe(P),[P]),o=r.useMemo(()=>c.find(s=>s.key===n),[c,n]),W=r.useMemo(()=>{const s=new Set;for(const h of c)s.add(j(h.key));return Array.from(s).sort((h,A)=>h===y?1:A===y?-1:h.localeCompare(A))},[c]),H=r.useMemo(()=>m==="all"?c:c.filter(s=>j(s.key)===m),[c,m]);r.useEffect(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),S(!1)},[o]);const $=()=>{n&&(p.mutate({key:n,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),S(!1))},Y=async()=>{if(!n)return;await z({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&p.mutate({key:n,data:{clearHistory:!0}})},G=async()=>{if(!n)return;await z({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.mutate({key:n},{onSuccess:()=>b(null)})};return e.jsxs(pe,{fullHeight:!0,children:[e.jsx(je,{title:t("sessionsPageTitle"),description:t("sessionsPageDescription")}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 relative",children:[e.jsxs("div",{className:"w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:[c.length," ",t("sessionsListTitle")]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>g.refetch(),children:e.jsx(I,{className:i("h-3.5 w-3.5",g.isFetching&&"animate-spin")})})]}),e.jsxs(de,{value:m,onValueChange:q,children:[e.jsx(ce,{className:"w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700",children:e.jsx(xe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(me,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(U,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),W.map(s=>e.jsx(U,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(J,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(k,{value:a,onChange:s=>l(s.target.value),placeholder:t("sessionsSearchPlaceholder"),className:"pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative",children:g.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):H.length===0?e.jsxs("div",{className:"text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4",children:[e.jsx(T,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):H.map(s=>e.jsx(Ne,{session:s,channel:j(s.key),runStatus:O.get(s.key),isSelected:n===s.key,onSelect:()=>b(s.key)},s.key))})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200",children:[(p.isPending||_.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),n&&o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0",children:e.jsx(X,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:o.label||o.key.split(":").pop()||o.key}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:C(j(o.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:n,children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>S(!w),className:i("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(f,{variant:"outline",size:"sm",onClick:Y,className:"h-8.5 rounded-lg shadow-none hover:bg-gray-50 hover:text-gray-900 border-gray-200 text-xs font-semibold text-gray-500",children:t("sessionsClearHistory")}),e.jsx(f,{variant:"outline",size:"sm",onClick:G,className:"h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500",children:t("delete")})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in",children:[e.jsx(k,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(k,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(f,{size:"sm",onClick:$,className:"h-8 px-4 shrink-0 shadow-none",disabled:p.isPending,children:t("sessionsSaveMeta")})]})]}),e.jsxs("div",{className:`flex-1 overflow-y-auto p-6 relative
1
+ import{r,j as e,ap as I,s as J,aV as T,aS as X,z as Z,M as Q,aW as ee,a8 as se,aa as te}from"./vendor-DKBNiC31.js";import{u as ae}from"./useConfirmDialog-BuQnVTeR.js";import{j as re,i as ne,l as le,ab as ie,ac as oe,t,B as f,c as i,S as de,e as ce,f as xe,g as me,h as U,I as k,ad as ue,s as he}from"./index-BEgClaDH.js";import{b as ge,a as fe,S as ye,e as be}from"./chat-message-AWIcksDK.js";import{P as pe,a as je}from"./page-layout-CfnoVycc.js";import"./index-CPDASUXh.js";const y="__unknown_channel__";function ve(a){return he(a)}function j(a){const l=a.indexOf(":");return l<=0?y:a.slice(0,l).trim()||y}function C(a){return a===y?t("sessionsUnknownChannel"):a}function Ne({session:a,channel:l,runStatus:d,isSelected:x,onSelect:n}){const b=C(l),m=a.label||a.key.split(":").pop()||a.key;return e.jsxs("button",{onClick:n,className:i("w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group",x?"bg-brand-50 border border-brand-100/50":"bg-transparent border border-transparent hover:bg-gray-50/80"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-1.5",children:[e.jsx("div",{className:i("font-semibold truncate pr-2 flex-1 text-sm",x?"text-brand-800":"text-gray-900"),children:m}),e.jsx("div",{className:i("text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize",x?"bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]":"bg-gray-100 text-gray-500"),children:b})]}),e.jsxs("div",{className:i("flex items-center text-xs justify-between mt-2 font-medium",x?"text-brand-600/80":"text-gray-400"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:d?e.jsx(ye,{status:d}):null}),e.jsx(ee,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{className:"truncate max-w-[100px]",children:ue(a.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"w-3.5 h-3.5 opacity-70"}),e.jsx("span",{children:a.messageCount})]})]})]})}function we({message:a}){const l=a.role.toLowerCase()==="user",d=be(a.content).trim();return e.jsx("div",{className:i("flex w-full mb-6",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:i("max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm",l?"bg-primary text-white rounded-tr-sm":"bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50"),children:[e.jsx("div",{className:"shrink-0 pt-0.5",children:l?e.jsx(se,{className:"w-4 h-4 text-primary-100"}):e.jsx(te,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 space-y-1 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4 mb-2",children:[e.jsx("span",{className:i("font-semibold text-xs",l?"text-primary-50":"text-gray-900 capitalize"),children:a.role}),e.jsx("span",{className:i("text-[10px]",l?"text-primary-200":"text-gray-400"),children:ve(a.timestamp)})]}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[15px]",children:d||"-"})]})]})})}function _e(){var B,E,K,R;const[a,l]=r.useState(""),[d]=r.useState(100),[x]=r.useState(0),[n,b]=r.useState(null),[m,q]=r.useState("all"),[M,v]=r.useState(""),[L,N]=r.useState(""),[w,S]=r.useState(!1),F=r.useMemo(()=>({q:a.trim()||void 0,limit:d,activeMinutes:x}),[a,d,x]),g=re(F),D=ne({states:["queued","running"],limit:200}),u=le(n,200),p=ie(),_=oe(),{confirm:z,ConfirmDialog:V}=ae(),c=r.useMemo(()=>{var s;return((s=g.data)==null?void 0:s.sessions)??[]},[(B=g.data)==null?void 0:B.sessions]),P=r.useMemo(()=>{var s;return ge(((s=D.data)==null?void 0:s.runs)??[])},[(E=D.data)==null?void 0:E.runs]),O=r.useMemo(()=>fe(P),[P]),o=r.useMemo(()=>c.find(s=>s.key===n),[c,n]),W=r.useMemo(()=>{const s=new Set;for(const h of c)s.add(j(h.key));return Array.from(s).sort((h,A)=>h===y?1:A===y?-1:h.localeCompare(A))},[c]),H=r.useMemo(()=>m==="all"?c:c.filter(s=>j(s.key)===m),[c,m]);r.useEffect(()=>{o?(v(o.label||""),N(o.preferredModel||"")):(v(""),N("")),S(!1)},[o]);const $=()=>{n&&(p.mutate({key:n,data:{label:M.trim()||null,preferredModel:L.trim()||null}}),S(!1))},Y=async()=>{if(!n)return;await z({title:t("sessionsClearHistory")+"?",variant:"destructive",confirmLabel:t("sessionsClearHistory")})&&p.mutate({key:n,data:{clearHistory:!0}})},G=async()=>{if(!n)return;await z({title:t("sessionsDeleteConfirm")+"?",variant:"destructive",confirmLabel:t("sessionsDeleteConfirm")})&&_.mutate({key:n},{onSuccess:()=>b(null)})};return e.jsxs(pe,{fullHeight:!0,children:[e.jsx(je,{title:t("sessionsPageTitle"),description:t("sessionsPageDescription")}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 relative",children:[e.jsxs("div",{className:"w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase tracking-wider",children:[c.length," ",t("sessionsListTitle")]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100",onClick:()=>g.refetch(),children:e.jsx(I,{className:i("h-3.5 w-3.5",g.isFetching&&"animate-spin")})})]}),e.jsxs(de,{value:m,onValueChange:q,children:[e.jsx(ce,{className:"w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700",children:e.jsx(xe,{placeholder:t("sessionsAllChannels")})}),e.jsxs(me,{className:"rounded-xl shadow-lg border-gray-100 max-w-[280px]",children:[e.jsx(U,{value:"all",className:"rounded-lg text-xs",children:t("sessionsAllChannels")}),W.map(s=>e.jsx(U,{value:s,className:"rounded-lg text-xs truncate pr-6",children:C(s)},s))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(J,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),e.jsx(k,{value:a,onChange:s=>l(s.target.value),placeholder:t("sessionsSearchPlaceholder"),className:"pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative",children:g.isLoading?e.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:t("sessionsLoading")}):H.length===0?e.jsxs("div",{className:"text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4",children:[e.jsx(T,{className:"w-8 h-8 mx-auto mb-2 text-gray-300"}),t("sessionsEmpty")]}):H.map(s=>e.jsx(Ne,{session:s,channel:j(s.key),runStatus:O.get(s.key),isSelected:n===s.key,onSelect:()=>b(s.key)},s.key))})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200",children:[(p.isPending||_.isPending)&&e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20",children:e.jsx("div",{className:"h-full bg-primary animate-pulse w-1/3 rounded-r-full"})}),n&&o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0",children:e.jsx(X,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 tracking-tight",children:o.label||o.key.split(":").pop()||o.key}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest",children:C(j(o.key))})]}),e.jsx("div",{className:"text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70",title:n,children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>S(!w),className:i("h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold",w?"bg-gray-100 text-gray-900":"hover:bg-gray-50 hover:text-gray-900"),children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-1.5"}),t("sessionsMetadata")]}),e.jsx(f,{variant:"outline",size:"sm",onClick:Y,className:"h-8.5 rounded-lg shadow-none hover:bg-gray-50 hover:text-gray-900 border-gray-200 text-xs font-semibold text-gray-500",children:t("sessionsClearHistory")}),e.jsx(f,{variant:"outline",size:"sm",onClick:G,className:"h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500",children:t("delete")})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in",children:[e.jsx(k,{placeholder:t("sessionsLabelPlaceholder"),value:M,onChange:s=>v(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(k,{placeholder:t("sessionsModelPlaceholder"),value:L,onChange:s=>N(s.target.value),className:"h-8 text-sm bg-white"}),e.jsx(f,{size:"sm",onClick:$,className:"h-8 px-4 shrink-0 shadow-none",disabled:p.isPending,children:t("sessionsSaveMeta")})]})]}),e.jsxs("div",{className:`flex-1 overflow-y-auto p-6 relative
2
2
  [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[u.isLoading&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 animate-pulse",children:[e.jsx(I,{className:"w-6 h-6 text-primary animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:t("sessionsHistoryLoading")})]})}),u.error&&e.jsx("div",{className:"text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm",children:u.error.message}),!u.isLoading&&((K=u.data)==null?void 0:K.messages.length)===0&&e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[e.jsx(Q,{className:"w-12 h-12 mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm",children:t("sessionsEmpty")})]}),e.jsx("div",{className:"max-w-3xl mx-auto",children:(((R=u.data)==null?void 0:R.messages)??[]).map((s,h)=>e.jsx(we,{message:s},`${s.timestamp}-${h}`))})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3",children:e.jsx(T,{className:"h-8 w-8 text-gray-300 -rotate-3"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:t("sessionsNoSelectionTitle")}),e.jsx("p",{className:"text-sm text-center max-w-sm leading-relaxed",children:t("sessionsNoSelectionDescription")})]})]})]}),e.jsx(V,{})]})}export{_e as SessionsConfig};
@@ -1,3 +1,3 @@
1
- import{j as u,a2 as m}from"./vendor-CkJHmX1g.js";import{t as p,c as g}from"./index-CsvP4CER.js";const l={queued:1,running:2};function o(t){return t==="queued"||t==="running"?t:null}function y(t){const n=Date.parse(t??"");return Number.isFinite(n)?n:0}function d(t,n){const e=o(t.state),r=o(n.state);if(!e||!r)return!1;const s=l[e],i=l[r];return i!==s?i>s:y(n.requestedAt)>=y(t.requestedAt)}function R(t){var e;const n=new Map;for(const r of t){const s=(e=r.sessionKey)==null?void 0:e.trim();if(!s||!o(r.state))continue;const i=n.get(s);(!i||d(i,r))&&n.set(s,r)}return n}function A(t){const n=new Map;for(const[e,r]of t.entries()){const s=o(r.state);s&&n.set(e,s)}return n}function j({status:t,className:n}){const e=t==="running"?p("sessionsRunStatusRunning"):p("sessionsRunStatusQueued");return u.jsxs("span",{className:g("inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400",n),title:e,"aria-label":e,children:[u.jsx(m,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:"sr-only",children:e})]})}const h=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function c(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,n=2400){return t.length<=n?t:`${t.slice(0,n)}
1
+ import{j as u,a2 as m}from"./vendor-DKBNiC31.js";import{t as p,c as g}from"./index-BEgClaDH.js";const l={queued:1,running:2};function o(t){return t==="queued"||t==="running"?t:null}function y(t){const n=Date.parse(t??"");return Number.isFinite(n)?n:0}function d(t,n){const e=o(t.state),r=o(n.state);if(!e||!r)return!1;const s=l[e],i=l[r];return i!==s?i>s:y(n.requestedAt)>=y(t.requestedAt)}function R(t){var e;const n=new Map;for(const r of t){const s=(e=r.sessionKey)==null?void 0:e.trim();if(!s||!o(r.state))continue;const i=n.get(s);(!i||d(i,r))&&n.set(s,r)}return n}function A(t){const n=new Map;for(const[e,r]of t.entries()){const s=o(r.state);s&&n.set(e,s)}return n}function j({status:t,className:n}){const e=t==="running"?p("sessionsRunStatusRunning"):p("sessionsRunStatusQueued");return u.jsxs("span",{className:g("inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400",n),title:e,"aria-label":e,children:[u.jsx(m,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:"sr-only",children:e})]})}const h=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function c(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,n=2400){return t.length<=n?t:`${t.slice(0,n)}
2
2
  …`}function a(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t==null)return"";try{return f(JSON.stringify(t,null,2))}catch{return String(t)}}function S(t){if(c(t))return t;if(typeof t!="string")return null;const n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return null;try{const e=JSON.parse(n);return c(e)?e:null}catch{return null}}function T(t){const n=S(t);if(!n){const r=a(t).trim();return r?f(r,120):void 0}const e=[];for(const r of h){const s=n[r];if(typeof s=="string"&&s.trim()?e.push(`${r}: ${s.trim()}`):(typeof s=="number"||typeof s=="boolean")&&e.push(`${r}: ${String(s)}`),e.length>=2)break}return e.length>0?e.join(" · "):f(a(n),140)}function N(t){if(typeof t=="string")return t;if(Array.isArray(t)){const n=[];for(const e of t){if(typeof e=="string"){n.push(e);continue}if(c(e)){if(typeof e.text=="string"){n.push(e.text);continue}typeof e.content=="string"&&n.push(e.content)}}if(n.length>0)return n.join(`
3
3
  `)}return a(t)}export{j as S,A as a,R as b,a as c,N as e,T as s};