@axiom-lattice/gateway 4.2.1 → 4.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{a2a-standard-VEQBXBMM.mjs → a2a-standard-ALXWP7V6.mjs} +2 -2
  2. package/dist/chunk-EMYRCJOI.mjs +99 -0
  3. package/dist/chunk-EMYRCJOI.mjs.map +1 -0
  4. package/dist/{chunk-J4BK77PA.mjs → chunk-YKTXW6F6.mjs} +11 -1
  5. package/dist/chunk-YKTXW6F6.mjs.map +1 -0
  6. package/dist/embed/{embed-page-AgentDetailSideApp-KGYKTMZR.js → embed-page-AgentDetailSideApp-3LBCEKFU.js} +1 -1
  7. package/dist/embed/{embed-page-AgentGovernanceWorkbench-F42AJH77.js → embed-page-AgentGovernanceWorkbench-K3JUQNBW.js} +1 -1
  8. package/dist/embed/{embed-page-MessageGraph-ACHQORG7.js → embed-page-MessageGraph-3X4ROEN6.js} +1 -1
  9. package/dist/embed/{embed-page-ReactChart-FGUHXBED.js → embed-page-ReactChart-F6VYCIYY.js} +1 -1
  10. package/dist/embed/{embed-page-SkillFlow-SFZ5HLMK.js → embed-page-SkillFlow-3CF7R3CW.js} +1 -1
  11. package/dist/embed/{embed-page-TasksSideApp-4GY5YBTN.js → embed-page-TasksSideApp-3WRDBZU3.js} +1 -1
  12. package/dist/embed/{embed-page-TeamWorkspace-YWE6ZTLB.js → embed-page-TeamWorkspace-6JSMZYUF.js} +1 -1
  13. package/dist/embed/{embed-page-TopologyRuntimeView-MKFPCHT3.js → embed-page-TopologyRuntimeView-YDFENLHH.js} +1 -1
  14. package/dist/embed/{embed-page-WorkflowAutomationView-WT6VH5HD.js → embed-page-WorkflowAutomationView-MP5B7Q2Q.js} +1 -1
  15. package/dist/embed/{embed-page-chunk-67U2KZFL.js → embed-page-chunk-B2E2XOH2.js} +10 -10
  16. package/dist/embed/{embed-page-chunk-FU2KMTSK.js → embed-page-chunk-FFO7CAYL.js} +1 -1
  17. package/dist/embed/{embed-page-chunk-MGZK7ELC.js → embed-page-chunk-GDTBDOUE.js} +354 -187
  18. package/dist/embed/{embed-page-chunk-3WXEO6CG.js → embed-page-chunk-IRP6JSSX.js} +1 -1
  19. package/dist/embed/{embed-page-chunk-3PY2YGBU.js → embed-page-chunk-PAJ5NG2Z.js} +1 -1
  20. package/dist/embed/{embed-page-chunk-HS5VQFWH.js → embed-page-chunk-QEYWJHEK.js} +1 -1
  21. package/dist/embed/{embed-page-chunk-N46WJ2FS.js → embed-page-chunk-RVXX5HKF.js} +1 -1
  22. package/dist/embed/{embed-page-chunk-FDID7LZP.js → embed-page-chunk-UOL6CUAL.js} +1 -1
  23. package/dist/embed/{embed-page-chunk-74BPRLSV.js → embed-page-chunk-URNZX66S.js} +5 -5
  24. package/dist/embed/{embed-page-chunk-42S7N5Y5.js → embed-page-chunk-YMJGPA3F.js} +163 -145
  25. package/dist/embed/embed-page.js +1 -1
  26. package/dist/index.d.mts +10 -0
  27. package/dist/index.d.ts +10 -0
  28. package/dist/index.js +1748 -873
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.mjs +1238 -432
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/{resources-SRQRKW5G.mjs → resources-JFKAPS45.mjs} +16 -10
  33. package/dist/resources-JFKAPS45.mjs.map +1 -0
  34. package/package.json +9 -7
  35. package/dist/chunk-J4BK77PA.mjs.map +0 -1
  36. package/dist/chunk-LHQY46YB.mjs +0 -47
  37. package/dist/chunk-LHQY46YB.mjs.map +0 -1
  38. package/dist/resources-SRQRKW5G.mjs.map +0 -1
  39. /package/dist/{a2a-standard-VEQBXBMM.mjs.map → a2a-standard-ALXWP7V6.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";import{a as Dr}from"./embed-page-chunk-FU2KMTSK.js";import{$ as Jt,$a as Bt,Ea as Pr,F as zo,Fa as Mt,G as mr,Ga as Ir,Ha as w,Ia as Ar,J as ur,Ja as Ie,K as gr,L as at,La as eo,M as jo,Ma as tt,Na as $o,Oa as st,Pa as Se,Qa as to,R as fr,Ra as Er,Sa as oo,T as St,U as yr,V as hr,W as vr,a as qn,b as Vn,c as et,d as Yt,da as br,f as lr,fa as Zt,ga as xr,ib as Nr,j as Et,ka as wr,l as cr,la as Ve,mb as Mr,na as Lo,o as dr,oa as Cr,ob as Br,p as Xt,pa as Sr,qb as Oo,r as Nt,ua as _o,va as kr,w as pr,ya as Rr,za as Tr}from"./embed-page-chunk-42S7N5Y5.js";import{f as Wn,i as We,k as Hn,m as Gn,o as Qn,p as Ce,q as me}from"./embed-page-chunk-74BPRLSV.js";import{a as s}from"./embed-page-chunk-MB65DZAX.js";import{$ as Kt,$b as er,Ac as rr,Ca as $n,Eb as qt,Fa as wt,Gc as ir,Ia as ve,Ic as ar,Ja as $e,Kc as Gt,La as P,Lc as Qt,Ma as On,Nc as sr,Tb as Zn,V as At,Va as Bo,W as z,Y as No,Z as xe,_ as Ee,aa as ze,bc as tr,fc as or,ia as _e,la as _n,mb as Ct,mc as Vt,na as Mo,oa as ce,ob as Yn,pa as qe,qb as Xn,rc as ft,sb as Do,ta as H,tb as Jn,va as ne,wa as Te,xa as q,ya as pe,yb as Fo,yc as nr}from"./embed-page-chunk-O4QK5LWZ.js";import{a as C}from"./embed-page-chunk-4BKXE5ON.js";import{e as n}from"./embed-page-chunk-6Y3UYJ6Z.js";var Fr=n(s()),la=w(({token:e,css:t})=>({button:t`
1
+ import{a as it,b as Gt,c as Hn,d as qn}from"./embed-page-chunk-B2E2XOH2.js";import{a as zr}from"./embed-page-chunk-FFO7CAYL.js";import{$ as to,$a as Dt,Ea as Ir,F as jo,Fa as Bt,G as ur,Ga as Ar,Ha as C,Ia as Er,J as gr,Ja as Ie,K as fr,L as at,La as no,M as Lo,Ma as tt,Na as Wo,Oa as st,Pa as Se,Qa as ro,R as yr,Ra as Nr,Sa as io,T as kt,U as hr,V as br,W as vr,a as Gn,b as Do,c as et,d as Zt,da as xr,f as cr,fa as oo,ga as wr,ib as Mr,j as Nt,ka as Cr,l as dr,la as Ve,mb as Br,na as _o,o as pr,oa as Sr,ob as Dr,p as eo,pa as kr,qb as Uo,r as Mt,ua as Oo,va as Rr,w as mr,ya as Tr,za as Pr}from"./embed-page-chunk-YMJGPA3F.js";import{f as Kn,i as Oe,k as Vn,m as Qn,o as Yn,p as Ce,q as me}from"./embed-page-chunk-URNZX66S.js";import{a}from"./embed-page-chunk-MB65DZAX.js";import{$ as Vt,$b as tr,Ac as ir,Ca as Wn,Eb as Qt,Fa as Ct,Gc as ar,Ia as be,Ic as sr,Ja as _e,Kc as Xt,La as P,Lc as Jt,Ma as Un,Nc as lr,Tb as er,V as Et,Va as zo,W as F,Y as Mo,Z as xe,_ as Ee,aa as Fe,bc as or,fc as nr,ia as Le,la as On,mb as St,mc as Yt,na as Bo,oa as ce,ob as Xn,pa as qe,qb as Jn,rc as yt,sb as Fo,ta as H,tb as Zn,va as ne,wa as Te,xa as q,ya as pe,yb as $o,yc as rr}from"./embed-page-chunk-O4QK5LWZ.js";import{a as w}from"./embed-page-chunk-4BKXE5ON.js";import{e as n}from"./embed-page-chunk-6Y3UYJ6Z.js";var Fr=n(a()),ma=C(({token:e,css:t})=>({button:t`
2
2
  display: inline-flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -19,7 +19,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
19
19
  background: ${e.colorBgTextHover};
20
20
  border-color: ${e.colorBorderSecondary};
21
21
  }
22
- `})),kt=({ariaLabel:e,icon:t,onClick:o,pressed:r=!1})=>{let{styles:a}=la();return(0,Fr.jsx)(z,{type:"text",size:"small",className:a.button,icon:t,onClick:o,"aria-label":e,"aria-pressed":r})};var Wo=n(s()),Uo=()=>{let{toolsVisible:e,toggleTools:t}=Se();return(0,Wo.jsx)(kt,{ariaLabel:"Toggle file directory",icon:(0,Wo.jsx)(at,{size:16}),onClick:t,pressed:e})};var he=n(C());var Ue=n(C());var no=n(C());function Ko(e){let[t,o]=(0,no.useState)(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return(0,no.useEffect)(()=>{let r=window.matchMedia(e),a=i=>{o(i.matches)};return r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t}var ke=n(s()),yt=({main:e,detail:t,tools:o,logo:r,menu:a,header:i,mainStyle:d})=>{let{styles:c}=to(),{detailVisible:p,detailSize:g,detailSelectedCard:b,toolsVisible:x,toolSelectedCard:h,contentAppSelectedCard:u,menuCollapsed:m,setMenuCollapsed:v,closeDetail:O,closeTools:_}=Se(),E=Ko("(max-width: 768px)"),Y=p||(m??E),ee=p&&!E,de=Y?"collapsed":"expanded",V=p||x,S=x&&(g||"large")==="large"?"middle":g||"large";return(0,ke.jsxs)("div",{className:`fina_chat ${c.layout}`,children:[a&&(0,ke.jsxs)("div",{className:`${c.menu} ${de} ${ee?c.menuSnap:""}`,children:[r,a]}),(0,ke.jsxs)("div",{className:c.contentArea,children:[(i||E&&a)&&(0,ke.jsxs)("div",{className:c.header,children:[E&&a?(0,ke.jsx)("button",{className:c.mobileMenuToggle,onClick:()=>v(!Y),"aria-label":"Toggle menu",children:(0,ke.jsx)(xr,{size:18})}):null,i]}),(0,ke.jsxs)("div",{className:c.columns,style:{gap:V?void 0:0},children:[(0,ke.jsx)("div",{className:`${c.mainContent} ${V?"open":""}`,children:(0,ke.jsx)("div",{className:`${c.chat} ${u?"full_content_width":""}`,style:d,children:e})}),(0,ke.jsxs)("div",{className:`${c.detailPanel} ${p?`open ${S}`:""}`,children:[p&&E&&(0,ke.jsx)("button",{className:c.mobilePanelClose,onClick:O,"aria-label":"Close detail panel",children:(0,ke.jsx)(Mt,{size:20})}),p&&b&&t?(0,ke.jsx)("div",{className:c.detailContent,children:t}):null]}),(0,ke.jsxs)("div",{className:`${c.toolPanel} ${x?"open":""}`,children:[x&&E&&(0,ke.jsx)("button",{className:c.mobilePanelClose,onClick:_,"aria-label":"Close tool panel",children:(0,ke.jsx)(Mt,{size:20})}),x&&o?(0,ke.jsx)("div",{className:c.detailContent,children:o}):null]})]})]})]})};var Pe=n(C());var N=n(s()),zr={wrapper:{background:"transparent",borderRadius:"0 24px 24px 0"},content:{background:"rgba(255, 255, 255, 0.72)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)"},header:{background:"transparent",borderBottom:"1px solid rgba(0, 0, 0, 0.06)"},body:{padding:0}},ca=w(({token:e,css:t})=>({sidebar:t`
22
+ `})),Rt=({ariaLabel:e,icon:t,onClick:o,pressed:r=!1})=>{let{styles:s}=ma();return(0,Fr.jsx)(F,{type:"text",size:"small",className:s.button,icon:t,onClick:o,"aria-label":e,"aria-pressed":r})};var Ko=n(a()),Ho=()=>{let{toolsVisible:e,toggleTools:t}=Se();return(0,Ko.jsx)(Rt,{ariaLabel:"Toggle file directory",icon:(0,Ko.jsx)(at,{size:16}),onClick:t,pressed:e})};var he=n(w());var Ue=n(w());var ao=n(w());function lt(e){let[t,o]=(0,ao.useState)(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return(0,ao.useEffect)(()=>{let r=window.matchMedia(e),s=i=>{o(i.matches)};return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}var ke=n(a()),ht=({main:e,detail:t,tools:o,logo:r,menu:s,header:i,mainStyle:d})=>{let{styles:c}=ro(),{detailVisible:p,detailSize:g,detailSelectedCard:v,toolsVisible:x,toolSelectedCard:h,contentAppSelectedCard:u,menuCollapsed:m,setMenuCollapsed:b,closeDetail:O,closeTools:L}=Se(),N=lt("(max-width: 768px)"),X=lt("(max-width: 1100px)"),ee=p||(m??N),de=p&&!N,Q=ee?"collapsed":"expanded",S=p||x,B=x&&(g||"large")==="large"?"middle":g||"large";return(0,ke.jsxs)("div",{className:`fina_chat ${c.layout}`,children:[s&&(0,ke.jsxs)("div",{className:`${c.menu} ${Q} ${de?c.menuSnap:""}`,children:[r,s]}),(0,ke.jsxs)("div",{className:c.contentArea,children:[(i||N&&s)&&(0,ke.jsxs)("div",{className:c.header,children:[N&&s?(0,ke.jsx)("button",{className:c.mobileMenuToggle,onClick:()=>b(!ee),"aria-label":"Toggle menu",children:(0,ke.jsx)(wr,{size:18})}):null,i]}),(0,ke.jsxs)("div",{className:c.columns,style:{gap:S?void 0:0},children:[(0,ke.jsx)("div",{className:`${c.mainContent} ${S?"open":""}`,children:(0,ke.jsx)("div",{className:`${c.chat} ${u?"full_content_width":""}`,style:d,children:e})}),(0,ke.jsxs)("div",{className:`${c.detailPanel} ${p?`open ${B}`:""}`,children:[p&&N&&(0,ke.jsx)("button",{className:c.mobilePanelClose,onClick:O,"aria-label":"Close detail panel",children:(0,ke.jsx)(Bt,{size:20})}),p&&v&&t?(0,ke.jsx)("div",{className:c.detailContent,children:t}):null]}),(0,ke.jsxs)("div",{className:`${c.toolPanel} ${x?"open":""}`,children:[x&&X&&(0,ke.jsx)("button",{className:c.mobilePanelClose,onClick:L,"aria-label":"Close tool panel",children:(0,ke.jsx)(Bt,{size:20})}),x&&o?(0,ke.jsx)("div",{className:c.detailContent,children:o}):null]})]})]})]})};var Pe=n(w());var E=n(a()),$r={wrapper:{background:"transparent",borderRadius:"0 24px 24px 0"},content:{background:"rgba(255, 255, 255, 0.72)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)"},header:{background:"transparent",borderBottom:"1px solid rgba(0, 0, 0, 0.06)"},body:{padding:0}},ua=C(({token:e,css:t})=>({sidebar:t`
23
23
  display: flex;
24
24
  flex-direction: column;
25
25
  height: 100%;
@@ -63,7 +63,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
63
63
  width: 22px;
64
64
  height: 22px;
65
65
  }
66
- `})),da=e=>{let t=new Map;return e.forEach(o=>{let r=o.group||null;t.has(r)||t.set(r,[]),t.get(r).push(o)}),Array.from(t.entries()).map(([o,r])=>({group:o,items:r.sort((a,i)=>(a.order??0)-(i.order??0))})).sort((o,r)=>{if(o.group===null)return-1;if(r.group===null)return 1;let a=o.items[0]?.order??0,i=r.items[0]?.order??0;return a-i})},ro=({items:e,onItemClick:t,logo:o,logoIcon:r,logoText:a="Menu",showBranding:i=!0,showToggle:d=!0,showNewAnalysis:c=!1,onNewAnalysis:p,defaultExpanded:g=!0,forceIconMode:b=!1,collapsed:x,onCollapsedChange:h,className:u,style:m,footer:v,getContextMenuItems:O})=>{let{styles:_}=ca(),{styles:E}=to(),Y=x!==void 0,[ee,de]=(0,Pe.useState)(!g),V=Y?x:ee;(0,Pe.useEffect)(()=>{Y||h?.(V)},[]);let[S,F]=(0,Pe.useState)({}),[J,Z]=(0,Pe.useState)(()=>{let k=new Set;return e.forEach(oe=>{oe.type==="drawer"&&oe.inline&&oe.inlineDefaultExpanded&&k.add(oe.id)}),k}),A=V||b,B=!!A,j=(0,Pe.useMemo)(()=>da(e),[e]),se=(0,Pe.useCallback)(k=>{t?.(k),k.type==="drawer"&&((k.inline??!1)&&!A?Z(D=>{let U=new Set(D);return U.has(k.id)?U.delete(k.id):U.add(k.id),U}):F(D=>({...D,[k.id]:!0})))},[t,A]),$=(0,Pe.useCallback)(k=>{F(oe=>({...oe,[k]:!1}))},[]),R=(0,Pe.useMemo)(()=>e.filter(k=>k.type==="drawer"&&S[k.id]).map(k=>k.id),[e,S]);(0,Pe.useEffect)(()=>{if(R.length===0)return;let k=oe=>{let D=oe.target;!D||typeof D.closest!="function"||R.forEach(U=>{D.closest(`.menu-drawer-${U}`)||$(U)})};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[R,$]);let I=(0,Pe.useCallback)(()=>{if(!b){let k=!V;Y?h?.(k):de(k)}},[b,V,Y,h]);return(0,N.jsxs)(N.Fragment,{children:[A?(0,N.jsxs)("div",{className:`${_.sidebar} ${E.iconMode} ${u||""}`,style:m,children:[i?(0,N.jsx)("div",{className:E.iconModeLogo,children:o||r||(0,N.jsx)(zo,{size:28,color:"#1677ff"})}):null,(0,N.jsx)("div",{className:E.iconModeContainer,children:j.map(({group:k,items:oe},D)=>(0,N.jsxs)(Pe.default.Fragment,{children:[D>0&&(0,N.jsx)("div",{className:E.iconModeDivider}),(0,N.jsx)("div",{className:E.iconModeGroup,children:oe.map(U=>{let Oe=O?.(U),Ke=U.badge!==void 0&&U.badge!==!1&&U.badge!==0,Ze=(0,N.jsxs)("button",{className:E.iconModeButton,onClick:()=>se(U),title:U.name,"aria-label":U.name,style:{position:"relative"},children:[(0,N.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:U.icon}),Ke&&(0,N.jsx)("span",{style:{position:"absolute",top:2,right:2,minWidth:typeof U.badge=="number"?16:8,height:typeof U.badge=="number"?16:8,borderRadius:typeof U.badge=="number"?8:4,background:"#ef4444",color:"#fff",fontSize:10,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof U.badge=="number"?"0 3px":0},children:typeof U.badge=="number"?U.badge>99?"99+":U.badge:null})]},U.id);return Oe?(0,N.jsx)(qe,{menu:{items:Oe},trigger:["contextMenu"],children:Ze},U.id):Ze})})]},k||`group-${D}`))}),d&&(0,N.jsx)("button",{className:E.iconModeButton,onClick:I,title:"Expand sidebar","aria-label":"Expand sidebar",style:{marginTop:"auto"},children:(0,N.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:(0,N.jsx)(Nt,{size:22})})}),v&&(0,N.jsx)("div",{style:{marginTop:"auto",paddingTop:8},children:typeof v=="function"?v({isIconMode:A}):v})]}):(0,N.jsxs)("div",{className:`${_.sidebar} ${E.expandedMenu} ${u||""}`,style:m,children:[i?(0,N.jsxs)("div",{className:`${E.expandedMenuLogo} ${B?"collapsed":""}`,children:[(0,N.jsx)("div",{className:"logo-icon",children:o||r||(0,N.jsx)(zo,{size:28,color:"#1677ff"})}),(0,N.jsx)("span",{className:"logo-text",children:a}),d&&!b&&(0,N.jsx)("button",{className:E.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",children:(0,N.jsx)(Zt,{size:18})})]}):d&&!b?(0,N.jsx)("button",{className:E.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",style:{alignSelf:"flex-end",marginBottom:8},children:(0,N.jsx)(Zt,{size:18})}):null,c&&(0,N.jsxs)("button",{className:`${E.newAnalysisBtn} ${B?"collapsed":""}`,onClick:p,children:[(0,N.jsx)(Cr,{size:18}),(0,N.jsx)("span",{className:"btn-text",children:"New Thread"})]}),(0,N.jsx)("div",{className:E.buttonContainerExpanded,children:j.map(({group:k,items:oe})=>(0,N.jsxs)("div",{className:E.menuGroup,children:[k&&(0,N.jsx)("div",{className:`${E.menuGroupTitle} ${B?"collapsed":""}`,children:k}),oe.map(D=>{let U=D.inline??!1,Oe=J.has(D.id),Ke=O?.(D),Ze=D.badge!==void 0&&D.badge!==!1&&D.badge!==0,gt=(0,N.jsxs)("button",{className:`${E.menuItemExpanded} ${B?"collapsed":""} ${Oe?E.menuItemExpandedActive:""}`,onClick:()=>se(D),title:B?D.name:void 0,"aria-label":D.name,"aria-expanded":Oe,children:[(0,N.jsx)("span",{className:"menu-icon",children:D.icon}),(0,N.jsx)("span",{className:"menu-label",children:D.name}),Ze&&(0,N.jsx)("span",{style:{marginLeft:"auto",minWidth:typeof D.badge=="number"?18:8,height:typeof D.badge=="number"?18:8,borderRadius:typeof D.badge=="number"?9:4,background:"#ef4444",color:"#fff",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof D.badge=="number"?"0 4px":0},children:typeof D.badge=="number"?D.badge>99?"99+":D.badge:null}),U&&!B&&(0,N.jsx)("span",{className:E.inlineDrawerIndicator,children:Oe?(0,N.jsx)(Xt,{size:16}):(0,N.jsx)(Nt,{size:16})})]}),nt=Ke?(0,N.jsx)(qe,{menu:{items:Ke},trigger:["contextMenu"],children:gt},D.id):(0,N.jsx)(Pe.default.Fragment,{children:gt},D.id);return(0,N.jsxs)(Pe.default.Fragment,{children:[nt,U&&Oe&&!B&&(0,N.jsx)("div",{className:E.inlineDrawerContainer,children:D.content})]},D.id)})]},k||"ungrouped"))}),v&&(0,N.jsx)("div",{style:{marginTop:"auto",paddingTop:16,borderTop:"1px solid rgba(0, 0, 0, 0.06)"},children:typeof v=="function"?v({isIconMode:A}):v})]}),e.filter(k=>k.type==="drawer").map(k=>(0,N.jsx)(Mo,{rootClassName:`menu-drawer-${k.id}`,title:(0,N.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,N.jsx)("span",{style:{fontSize:16,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:k.title||k.name}),(0,N.jsx)("button",{onClick:()=>$(k.id),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:8,border:"1px solid rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.5)",cursor:"pointer"},children:(0,N.jsx)(Zt,{size:24})})]}),open:S[k.id]||!1,onClose:()=>$(k.id),placement:"left",width:k.width||600,styles:{...zr,header:{padding:"16px 20px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},content:{...zr.content,borderRadius:"0 24px 24px 0",overflow:"hidden"}},closable:!1,mask:!1,destroyOnClose:!0,children:k.content},k.id))]})};var jr=n(C());var Lr=n(s()),{TextArea:vl}=H;var _r=n(s());var Rt=n(C());var Ho=class{apps=new Map;defaultId=void 0;register(t){if(!t.id)throw new Error("App must have an id");this.apps.set(t.id,t),this.defaultId===void 0&&(this.defaultId=t.id)}get(t){return this.apps.get(t)}list(){return Array.from(this.apps.values())}getDefaultId(){return this.defaultId}setDefault(t){if(!this.apps.has(t))throw new Error(`Cannot set default to unregistered app: ${t}`);this.defaultId=t}getCurrentId(){return this.currentId}setCurrent(t){if(!this.apps.has(t))throw new Error(`Cannot set current to unregistered app: ${t}`);this.currentId=t}resetCurrent(){this.currentId=void 0}currentId=void 0},pa=new Ho;var ma=n(s()),kl=(0,Rt.createContext)(null);var Or=n(s()),Il=w(({token:e})=>({container:{display:"flex",flexDirection:"column",gap:e.padding,padding:e.padding},header:{fontSize:e.fontSizeHeading5,fontWeight:600,color:e.colorText,paddingBottom:e.paddingSM,borderBottom:`1px solid ${e.colorBorderSecondary}`},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:e.padding},card:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.paddingXS,padding:e.paddingLG,borderRadius:e.borderRadiusLG,border:`1px solid ${e.colorBorder}`,cursor:"pointer",transition:"all 0.2s",background:e.colorBgContainer,"&:hover":{borderColor:e.colorPrimary,background:e.colorPrimaryBg}},activeCard:{borderColor:e.colorPrimary,background:e.colorPrimaryBg},icon:{fontSize:28,lineHeight:1},name:{fontSize:e.fontSize,fontWeight:500,color:e.colorText,textAlign:"center"},activeName:{color:e.colorPrimary}}));var li=n(C());var lt=n(C());var ua=n(s());var Bl=300*1e3,Dl=(0,lt.createContext)(null);var rn=n(C());var qo=n(C());var ga=n(C());var fa=n(s());var Ur=n(s()),Hl=w(({token:e,css:t})=>({container:t`
66
+ `})),ga=e=>{let t=new Map;return e.forEach(o=>{let r=o.group||null;t.has(r)||t.set(r,[]),t.get(r).push(o)}),Array.from(t.entries()).map(([o,r])=>({group:o,items:r.sort((s,i)=>(s.order??0)-(i.order??0))})).sort((o,r)=>{if(o.group===null)return-1;if(r.group===null)return 1;let s=o.items[0]?.order??0,i=r.items[0]?.order??0;return s-i})},so=({items:e,onItemClick:t,logo:o,logoIcon:r,logoText:s="Menu",showBranding:i=!0,showToggle:d=!0,showNewAnalysis:c=!1,onNewAnalysis:p,defaultExpanded:g=!0,forceIconMode:v=!1,collapsed:x,onCollapsedChange:h,className:u,style:m,footer:b,getContextMenuItems:O})=>{let{styles:L}=ua(),{styles:N}=ro(),X=x!==void 0,[ee,de]=(0,Pe.useState)(!g),Q=X?x:ee;(0,Pe.useEffect)(()=>{X||h?.(Q)},[]);let[S,B]=(0,Pe.useState)({}),[J,Z]=(0,Pe.useState)(()=>{let k=new Set;return e.forEach(oe=>{oe.type==="drawer"&&oe.inline&&oe.inlineDefaultExpanded&&k.add(oe.id)}),k}),A=Q||v,D=!!A,$=(0,Pe.useMemo)(()=>ga(e),[e]),se=(0,Pe.useCallback)(k=>{t?.(k),k.type==="drawer"&&((k.inline??!1)&&!A?Z(z=>{let U=new Set(z);return U.has(k.id)?U.delete(k.id):U.add(k.id),U}):B(z=>({...z,[k.id]:!0})))},[t,A]),_=(0,Pe.useCallback)(k=>{B(oe=>({...oe,[k]:!1}))},[]),R=(0,Pe.useMemo)(()=>e.filter(k=>k.type==="drawer"&&S[k.id]).map(k=>k.id),[e,S]);(0,Pe.useEffect)(()=>{if(R.length===0)return;let k=oe=>{let z=oe.target;!z||typeof z.closest!="function"||R.forEach(U=>{z.closest(`.menu-drawer-${U}`)||_(U)})};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[R,_]);let I=(0,Pe.useCallback)(()=>{if(!v){let k=!Q;X?h?.(k):de(k)}},[v,Q,X,h]);return(0,E.jsxs)(E.Fragment,{children:[A?(0,E.jsxs)("div",{className:`${L.sidebar} ${N.iconMode} ${u||""}`,style:m,children:[i?(0,E.jsx)("div",{className:N.iconModeLogo,children:o||r||(0,E.jsx)(jo,{size:28,color:"#1677ff"})}):null,(0,E.jsx)("div",{className:N.iconModeContainer,children:$.map(({group:k,items:oe},z)=>(0,E.jsxs)(Pe.default.Fragment,{children:[z>0&&(0,E.jsx)("div",{className:N.iconModeDivider}),(0,E.jsx)("div",{className:N.iconModeGroup,children:oe.map(U=>{let We=O?.(U),Ke=U.badge!==void 0&&U.badge!==!1&&U.badge!==0,Ze=(0,E.jsxs)("button",{className:N.iconModeButton,onClick:()=>se(U),title:U.name,"aria-label":U.name,style:{position:"relative"},children:[(0,E.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:U.icon}),Ke&&(0,E.jsx)("span",{style:{position:"absolute",top:2,right:2,minWidth:typeof U.badge=="number"?16:8,height:typeof U.badge=="number"?16:8,borderRadius:typeof U.badge=="number"?8:4,background:"#ef4444",color:"#fff",fontSize:10,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof U.badge=="number"?"0 3px":0},children:typeof U.badge=="number"?U.badge>99?"99+":U.badge:null})]},U.id);return We?(0,E.jsx)(qe,{menu:{items:We},trigger:["contextMenu"],children:Ze},U.id):Ze})})]},k||`group-${z}`))}),d&&(0,E.jsx)("button",{className:N.iconModeButton,onClick:I,title:"Expand sidebar","aria-label":"Expand sidebar",style:{marginTop:"auto"},children:(0,E.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:(0,E.jsx)(Mt,{size:22})})}),b&&(0,E.jsx)("div",{style:{marginTop:"auto",paddingTop:8},children:typeof b=="function"?b({isIconMode:A}):b})]}):(0,E.jsxs)("div",{className:`${L.sidebar} ${N.expandedMenu} ${u||""}`,style:m,children:[i?(0,E.jsxs)("div",{className:`${N.expandedMenuLogo} ${D?"collapsed":""}`,children:[(0,E.jsx)("div",{className:"logo-icon",children:o||r||(0,E.jsx)(jo,{size:28,color:"#1677ff"})}),(0,E.jsx)("span",{className:"logo-text",children:s}),d&&!v&&(0,E.jsx)("button",{className:N.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",children:(0,E.jsx)(oo,{size:18})})]}):d&&!v?(0,E.jsx)("button",{className:N.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",style:{alignSelf:"flex-end",marginBottom:8},children:(0,E.jsx)(oo,{size:18})}):null,c&&(0,E.jsxs)("button",{className:`${N.newAnalysisBtn} ${D?"collapsed":""}`,onClick:p,children:[(0,E.jsx)(Sr,{size:18}),(0,E.jsx)("span",{className:"btn-text",children:"New Thread"})]}),(0,E.jsx)("div",{className:N.buttonContainerExpanded,children:$.map(({group:k,items:oe})=>(0,E.jsxs)("div",{className:N.menuGroup,children:[k&&(0,E.jsx)("div",{className:`${N.menuGroupTitle} ${D?"collapsed":""}`,children:k}),oe.map(z=>{let U=z.inline??!1,We=J.has(z.id),Ke=O?.(z),Ze=z.badge!==void 0&&z.badge!==!1&&z.badge!==0,ft=(0,E.jsxs)("button",{className:`${N.menuItemExpanded} ${D?"collapsed":""} ${We?N.menuItemExpandedActive:""}`,onClick:()=>se(z),title:D?z.name:void 0,"aria-label":z.name,"aria-expanded":We,children:[(0,E.jsx)("span",{className:"menu-icon",children:z.icon}),(0,E.jsx)("span",{className:"menu-label",children:z.name}),Ze&&(0,E.jsx)("span",{style:{marginLeft:"auto",minWidth:typeof z.badge=="number"?18:8,height:typeof z.badge=="number"?18:8,borderRadius:typeof z.badge=="number"?9:4,background:"#ef4444",color:"#fff",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof z.badge=="number"?"0 4px":0},children:typeof z.badge=="number"?z.badge>99?"99+":z.badge:null}),U&&!D&&(0,E.jsx)("span",{className:N.inlineDrawerIndicator,children:We?(0,E.jsx)(eo,{size:16}):(0,E.jsx)(Mt,{size:16})})]}),nt=Ke?(0,E.jsx)(qe,{menu:{items:Ke},trigger:["contextMenu"],children:ft},z.id):(0,E.jsx)(Pe.default.Fragment,{children:ft},z.id);return(0,E.jsxs)(Pe.default.Fragment,{children:[nt,U&&We&&!D&&(0,E.jsx)("div",{className:N.inlineDrawerContainer,children:z.content})]},z.id)})]},k||"ungrouped"))}),b&&(0,E.jsx)("div",{style:{marginTop:"auto",paddingTop:16,borderTop:"1px solid rgba(0, 0, 0, 0.06)"},children:typeof b=="function"?b({isIconMode:A}):b})]}),e.filter(k=>k.type==="drawer").map(k=>(0,E.jsx)(Bo,{rootClassName:`menu-drawer-${k.id}`,title:(0,E.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,E.jsx)("span",{style:{fontSize:16,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:k.title||k.name}),(0,E.jsx)("button",{onClick:()=>_(k.id),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:8,border:"1px solid rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.5)",cursor:"pointer"},children:(0,E.jsx)(oo,{size:24})})]}),open:S[k.id]||!1,onClose:()=>_(k.id),placement:"left",width:k.width||600,styles:{...$r,header:{padding:"16px 20px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},content:{...$r.content,borderRadius:"0 24px 24px 0",overflow:"hidden"}},closable:!1,mask:!1,destroyOnClose:!0,children:k.content},k.id))]})};var jr=n(w());var Lr=n(a()),{TextArea:Pl}=H;var _r=n(w());var Or=n(a());var Wr=n(a());var Tt=n(w());var qo=class{apps=new Map;defaultId=void 0;register(t){if(!t.id)throw new Error("App must have an id");this.apps.set(t.id,t),this.defaultId===void 0&&(this.defaultId=t.id)}get(t){return this.apps.get(t)}list(){return Array.from(this.apps.values())}getDefaultId(){return this.defaultId}setDefault(t){if(!this.apps.has(t))throw new Error(`Cannot set default to unregistered app: ${t}`);this.defaultId=t}getCurrentId(){return this.currentId}setCurrent(t){if(!this.apps.has(t))throw new Error(`Cannot set current to unregistered app: ${t}`);this.currentId=t}resetCurrent(){this.currentId=void 0}currentId=void 0},ya=new qo;var ha=n(a()),jl=(0,Tt.createContext)(null);var Kr=n(a()),Wl=C(({token:e})=>({container:{display:"flex",flexDirection:"column",gap:e.padding,padding:e.padding},header:{fontSize:e.fontSizeHeading5,fontWeight:600,color:e.colorText,paddingBottom:e.paddingSM,borderBottom:`1px solid ${e.colorBorderSecondary}`},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:e.padding},card:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.paddingXS,padding:e.paddingLG,borderRadius:e.borderRadiusLG,border:`1px solid ${e.colorBorder}`,cursor:"pointer",transition:"all 0.2s",background:e.colorBgContainer,"&:hover":{borderColor:e.colorPrimary,background:e.colorPrimaryBg}},activeCard:{borderColor:e.colorPrimary,background:e.colorPrimaryBg},icon:{fontSize:28,lineHeight:1},name:{fontSize:e.fontSize,fontWeight:500,color:e.colorText,textAlign:"center"},activeName:{color:e.colorPrimary}}));var ci=n(w());var Ca=n(w());var Vo=n(a());var Hr=n(a());var ct=n(w());var ka=n(a());var ac=300*1e3,sc=(0,ct.createContext)(null);var Ra=n(a());var ln=n(w());var Qo=n(w());var Ta=n(w());var Pa=n(a());var Vr=n(a()),xc=C(({token:e,css:t})=>({container:t`
67
67
  display: flex;
68
68
  flex-direction: column;
69
69
  height: 100%;
@@ -166,7 +166,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
166
166
  gap: 2px;
167
167
  `,emptyContainer:t`
168
168
  padding: 24px 16px;
169
- `}));var Aa=n(C());var ct=n(C());var ha=n(s());var mc=(0,ct.createContext)(null);var Lt=n(C());var Ae=n(C());var M=n(s()),va=w(({token:e,css:t})=>({container:t`
169
+ `}));var Oa=n(w());var dt=n(w());var Ia=n(a());var _c=(0,dt.createContext)(null);var Ot=n(w());var Ae=n(w());var M=n(a()),Aa=C(({token:e,css:t})=>({container:t`
170
170
  display: flex;
171
171
  flex-direction: column;
172
172
  height: 100%;
@@ -411,7 +411,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
411
411
  transform: translateY(0);
412
412
  }
413
413
  }
414
- `})),ba=({component_key:e,data:t})=>t?.component?(0,M.jsx)(M.Fragment,{children:t.component}):(0,M.jsxs)("div",{children:[(0,M.jsx)("p",{children:"Component view not found"}),(0,M.jsx)("pre",{children:JSON.stringify({component_key:e,data:t},null,2)})]}),io=e=>(0,M.jsx)(Bo,{style:{fontSize:12,opacity:.6}}),ao=({region:e="side",compact:t=!0,showCloseButton:o=!0})=>{let{styles:r}=va(),{sideAppSelectedCard:a,contentAppSelectedCard:i,closeSideApp:d,closeContentApp:c,openSideApp:p,openContentApp:g}=Se(),b=e==="side"?a:i,x=e==="side"?d:c,h=e==="side"?p:g,[u,m]=(0,Ae.useState)(JSON.stringify(b)),[v,O]=(0,Ae.useState)(null),[_,E]=(0,Ae.useState)([]),[Y,ee]=(0,Ae.useState)(!1),[de,V]=(0,Ae.useState)(!1),[S,F]=(0,Ae.useState)(!1),J=(0,Ae.useRef)(null),Z=(0,Ae.useCallback)(()=>{J.current&&(clearTimeout(J.current),J.current=null),V(!1),F(!1),ee(!0)},[]),A=(0,Ae.useCallback)(()=>{J.current=setTimeout(()=>{V(!0)},150)},[]),ae=(0,Ae.useCallback)(()=>{de&&(ee(!1),V(!1))},[de]),B=(T,le,k,oe)=>{let D=[..._,{label:le,children:k,key:T,componentKey:oe}];E(D),m(T)},j=T=>{let le=u,k=_.findIndex(D=>D.key===T),oe=_.filter(D=>D.key!==T);if(oe.length===0){x();return}le===T&&(k>0?le=_[k-1].key:le=oe[0].key),E(oe),m(le)},se=T=>{m(T)};(0,Ae.useEffect)(()=>{if(!b)return;let T=JSON.stringify(b);if(_.find(k=>k.key===T)){m(T),setTimeout(()=>{document.querySelector(`[data-tab-key="${T}"]`)?.scrollIntoView({behavior:"smooth",inline:"center"})},100);return}let le=Oo(b?.component_key)?.side_app_view||ba;B(T,b?.message||b?.data?.message||"Unnamed",(0,M.jsx)(le,{component_key:b?.component_key||"",data:b?.data,context:b?.context}),b?.component_key),J.current&&clearTimeout(J.current),ee(!0),V(!1),F(!0),J.current=setTimeout(()=>{V(!0)},1500)},[b]);let $=_.find(T=>T.key===u),R=_.map(T=>({key:T.key,label:(0,M.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[io(T.componentKey),(0,M.jsx)("span",{style:{flex:1},children:T.label}),(0,M.jsx)(Ct,{style:{fontSize:10,opacity:.5},onClick:le=>{le.stopPropagation(),j(T.key)}})]}),onClick:()=>se(T.key)})),I=(0,Ae.useMemo)(()=>({openApp:h}),[h]);return(0,M.jsxs)("div",{className:r.container,children:[t&&_.length>0&&(0,M.jsx)("div",{className:r.compactWrapper,onMouseEnter:Z,onMouseLeave:A,children:Y?(0,M.jsxs)("div",{className:`${r.floatingHeader} ${S?r.floatingHeaderPeek:""} ${de?r.floatingHeaderLeaving:""}`,onAnimationEnd:ae,children:[(0,M.jsx)("div",{className:r.floatingTabsStrip,children:_.map(T=>(0,M.jsx)(ze,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>se(T.key),onMouseEnter:()=>O(T.key),onMouseLeave:()=>O(null),children:[io(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${v===T.key||T.key===u?"always-visible":""}`,onClick:le=>{le.stopPropagation(),j(T.key)},children:(0,M.jsx)(Ct,{style:{fontSize:10}})})]})},T.key))}),_.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(ft,{})})}),o&&(0,M.jsx)(ze,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(Ct,{})})})]}):$&&(0,M.jsxs)("div",{className:r.compactPill,children:[io($.componentKey),(0,M.jsx)("span",{className:r.compactPillLabel,children:$.label})]})}),!t&&(0,M.jsxs)("div",{className:r.header,children:[(0,M.jsx)("div",{className:r.tabsStrip,children:_.map(T=>(0,M.jsx)(ze,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>se(T.key),onMouseEnter:()=>O(T.key),onMouseLeave:()=>O(null),children:[io(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${v===T.key||T.key===u?"always-visible":""}`,onClick:le=>{le.stopPropagation(),j(T.key)},children:(0,M.jsx)(Ct,{style:{fontSize:10}})})]})},T.key))}),(0,M.jsxs)("div",{className:r.actions,children:[_.length>0&&(0,M.jsx)("div",{className:r.tabCounter,children:_.length}),_.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(ft,{})})}),o&&(0,M.jsx)(ze,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(Ct,{})})})]})]}),(0,M.jsx)("div",{className:r.content,style:t&&_.length>0?{paddingTop:10}:void 0,children:(0,M.jsx)(oo.Provider,{value:I,children:$?(0,M.jsx)("div",{className:r.contentWrapper,children:$.children},$.key):(0,M.jsxs)("div",{className:r.emptyState,children:[(0,M.jsx)(Bo,{className:"icon"}),(0,M.jsx)("span",{children:"Select an app to start"})]})})})]})};var Ft=n(C());var Vo=n(C());var Go=n(s());var Pc=w(({token:e,css:t})=>({content:t`
414
+ `})),Ea=({component_key:e,data:t})=>t?.component?(0,M.jsx)(M.Fragment,{children:t.component}):(0,M.jsxs)("div",{children:[(0,M.jsx)("p",{children:"Component view not found"}),(0,M.jsx)("pre",{children:JSON.stringify({component_key:e,data:t},null,2)})]}),lo=e=>(0,M.jsx)(zo,{style:{fontSize:12,opacity:.6}}),co=({region:e="side",compact:t=!0,showCloseButton:o=!0})=>{let{styles:r}=Aa(),{sideAppSelectedCard:s,contentAppSelectedCard:i,closeSideApp:d,closeContentApp:c,openSideApp:p,openContentApp:g}=Se(),v=e==="side"?s:i,x=e==="side"?d:c,h=e==="side"?p:g,[u,m]=(0,Ae.useState)(JSON.stringify(v)),[b,O]=(0,Ae.useState)(null),[L,N]=(0,Ae.useState)([]),[X,ee]=(0,Ae.useState)(!1),[de,Q]=(0,Ae.useState)(!1),[S,B]=(0,Ae.useState)(!1),J=(0,Ae.useRef)(null),Z=(0,Ae.useCallback)(()=>{J.current&&(clearTimeout(J.current),J.current=null),Q(!1),B(!1),ee(!0)},[]),A=(0,Ae.useCallback)(()=>{J.current=setTimeout(()=>{Q(!0)},150)},[]),ae=(0,Ae.useCallback)(()=>{de&&(ee(!1),Q(!1))},[de]),D=(T,le,k,oe)=>{let z=[...L,{label:le,children:k,key:T,componentKey:oe}];N(z),m(T)},$=T=>{let le=u,k=L.findIndex(z=>z.key===T),oe=L.filter(z=>z.key!==T);if(oe.length===0){x();return}le===T&&(k>0?le=L[k-1].key:le=oe[0].key),N(oe),m(le)},se=T=>{m(T)};(0,Ae.useEffect)(()=>{if(!v)return;let T=JSON.stringify(v);if(L.find(k=>k.key===T)){m(T),setTimeout(()=>{document.querySelector(`[data-tab-key="${T}"]`)?.scrollIntoView({behavior:"smooth",inline:"center"})},100);return}let le=Uo(v?.component_key)?.side_app_view||Ea;D(T,v?.message||v?.data?.message||"Unnamed",(0,M.jsx)(le,{component_key:v?.component_key||"",data:v?.data,context:v?.context}),v?.component_key),J.current&&clearTimeout(J.current),ee(!0),Q(!1),B(!0),J.current=setTimeout(()=>{Q(!0)},1500)},[v]);let _=L.find(T=>T.key===u),R=L.map(T=>({key:T.key,label:(0,M.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[lo(T.componentKey),(0,M.jsx)("span",{style:{flex:1},children:T.label}),(0,M.jsx)(St,{style:{fontSize:10,opacity:.5},onClick:le=>{le.stopPropagation(),$(T.key)}})]}),onClick:()=>se(T.key)})),I=(0,Ae.useMemo)(()=>({openApp:h}),[h]);return(0,M.jsxs)("div",{className:r.container,children:[t&&L.length>0&&(0,M.jsx)("div",{className:r.compactWrapper,onMouseEnter:Z,onMouseLeave:A,children:X?(0,M.jsxs)("div",{className:`${r.floatingHeader} ${S?r.floatingHeaderPeek:""} ${de?r.floatingHeaderLeaving:""}`,onAnimationEnd:ae,children:[(0,M.jsx)("div",{className:r.floatingTabsStrip,children:L.map(T=>(0,M.jsx)(Fe,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>se(T.key),onMouseEnter:()=>O(T.key),onMouseLeave:()=>O(null),children:[lo(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${b===T.key||T.key===u?"always-visible":""}`,onClick:le=>{le.stopPropagation(),$(T.key)},children:(0,M.jsx)(St,{style:{fontSize:10}})})]})},T.key))}),L.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(yt,{})})}),o&&(0,M.jsx)(Fe,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(St,{})})})]}):_&&(0,M.jsxs)("div",{className:r.compactPill,children:[lo(_.componentKey),(0,M.jsx)("span",{className:r.compactPillLabel,children:_.label})]})}),!t&&(0,M.jsxs)("div",{className:r.header,children:[(0,M.jsx)("div",{className:r.tabsStrip,children:L.map(T=>(0,M.jsx)(Fe,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>se(T.key),onMouseEnter:()=>O(T.key),onMouseLeave:()=>O(null),children:[lo(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${b===T.key||T.key===u?"always-visible":""}`,onClick:le=>{le.stopPropagation(),$(T.key)},children:(0,M.jsx)(St,{style:{fontSize:10}})})]})},T.key))}),(0,M.jsxs)("div",{className:r.actions,children:[L.length>0&&(0,M.jsx)("div",{className:r.tabCounter,children:L.length}),L.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(yt,{})})}),o&&(0,M.jsx)(Fe,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(St,{})})})]})]}),(0,M.jsx)("div",{className:r.content,style:t&&L.length>0?{paddingTop:10}:void 0,children:(0,M.jsx)(io.Provider,{value:I,children:_?(0,M.jsx)("div",{className:r.contentWrapper,children:_.children},_.key):(0,M.jsxs)("div",{className:r.emptyState,children:[(0,M.jsx)(zo,{className:"icon"}),(0,M.jsx)("span",{children:"Select an app to start"})]})})})]})};var Ft=n(w());var Yo=n(w());var Xo=n(a());var td=C(({token:e,css:t})=>({content:t`
415
415
  display: flex;
416
416
  flex-direction: column;
417
417
  gap: 4px;
@@ -462,6 +462,11 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
462
462
  background: ${e.colorWarningBg};
463
463
  color: ${e.colorWarningText};
464
464
  font-size: 12px;
465
+ `,sentRow:t`
466
+ display: flex;
467
+ justify-content: flex-end;
468
+ margin-top: 2px;
469
+ color: ${e.colorTextTertiary};
465
470
  `,actions:t`
466
471
  display: flex;
467
472
  align-items: center;
@@ -474,26 +479,61 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
474
479
  font-size: 13px;
475
480
  color: ${e.colorTextSecondary};
476
481
  padding: 4px 0;
477
-
478
- time {
479
- flex-shrink: 0;
480
- font-size: 12px;
481
- color: ${e.colorTextTertiary};
482
- }
483
- `}));var Hr=n(s()),Nc=w(({token:e,css:t})=>({root:t`
482
+ `}));var Gr=n(a());var sd=C(({token:e,css:t})=>({row:t`
484
483
  display: flex;
485
484
  align-items: center;
486
485
  gap: 8px;
487
- font-size: 13px;
488
- color: ${e.colorTextSecondary};
489
- padding: 4px 0;
486
+ width: 100%;
487
+ max-width: 440px;
488
+ min-width: 0;
489
+ padding: 3px 6px;
490
+ margin: 1px 0;
491
+ border: none;
492
+ border-radius: 8px;
493
+ background: transparent;
494
+ text-align: left;
495
+ color: inherit;
496
+ transition: background 0.15s ease;
490
497
 
491
- time {
492
- flex-shrink: 0;
493
- font-size: 12px;
494
- color: ${e.colorTextTertiary};
498
+ &:not(:disabled) {
499
+ cursor: pointer;
500
+ }
501
+
502
+ &:hover:not(:disabled) {
503
+ background: ${e.colorFillQuaternary};
504
+
505
+ .lattice-task-open-hint {
506
+ opacity: 1;
507
+ }
495
508
  }
496
- `}));var qr=n(s());var Wc=w(({token:e,css:t})=>({root:t`
509
+ `,dot:t`
510
+ width: 8px;
511
+ height: 8px;
512
+ border-radius: 50%;
513
+ flex-shrink: 0;
514
+ `,label:t`
515
+ flex-shrink: 0;
516
+ font-size: 12px;
517
+ font-weight: 400;
518
+ color: ${e.colorTextSecondary};
519
+ `,title:t`
520
+ min-width: 0;
521
+ font-size: 13px;
522
+ font-weight: 600;
523
+ color: ${e.colorText};
524
+ white-space: nowrap;
525
+ overflow: hidden;
526
+ text-overflow: ellipsis;
527
+ `,spacer:t`
528
+ flex: 1;
529
+ min-width: 4px;
530
+ `,openHint:t`
531
+ flex-shrink: 0;
532
+ display: inline-flex;
533
+ color: ${e.colorTextTertiary};
534
+ opacity: 0;
535
+ transition: opacity 0.15s ease;
536
+ `}));var Qr=n(a());var wd=5*6e4,Cd=C(({token:e,css:t})=>({root:t`
497
537
  flex: 1;
498
538
  min-height: 0;
499
539
  overflow-y: auto;
@@ -519,11 +559,18 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
519
559
  transform: translateX(-50%);
520
560
  `,list:t`
521
561
  padding: 0 12px;
522
- `}));var zt=n(C());var Vr=n(s()),md=w(({token:e,css:t})=>({root:t`
562
+ `,divider:t`
563
+ display: flex;
564
+ justify-content: center;
565
+ margin: 8px 0 4px;
566
+ `,dividerText:t`
567
+ font-size: 12px;
568
+ color: ${e.colorTextTertiary};
569
+ `}));var $t=n(w());var Yr=n(a());var qd=C(({token:e,css:t})=>({root:t`
523
570
  flex-shrink: 0;
524
571
  border-top: 1px solid ${e.colorBorderSecondary};
525
572
  background: ${e.colorBgContainer};
526
- padding: 8px 12px;
573
+ padding: 8px 12px max(8px, env(safe-area-inset-bottom));
527
574
  `,reply:t`
528
575
  display: flex;
529
576
  align-items: center;
@@ -540,41 +587,33 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
540
587
  margin-top: 8px;
541
588
  font-size: 13px;
542
589
  color: ${e.colorErrorText};
543
- `}));var Gr=n(s());var yd=w(({token:e,css:t})=>({root:t`
590
+ `}));var Ma=n(w());var Xr=n(a());var Yd=C(({token:e,css:t})=>({root:t`
544
591
  display: flex;
545
592
  align-items: center;
546
- justify-content: space-between;
547
593
  gap: 12px;
548
594
  width: 100%;
549
595
  min-width: 0;
550
- `,trailing:t`
596
+ `,leading:t`
551
597
  display: flex;
552
598
  align-items: center;
553
- gap: 6px;
554
599
  flex-shrink: 0;
555
- `,connection:t`
556
- display: inline-flex;
600
+ `,title:t`
601
+ margin: 0;
602
+ min-width: 0;
603
+ flex: 1 1 auto;
604
+ font-size: 15px;
605
+ font-weight: 600;
606
+ color: ${e.colorText};
607
+ white-space: nowrap;
608
+ overflow: hidden;
609
+ text-overflow: ellipsis;
610
+ `,trailing:t`
611
+ display: flex;
557
612
  align-items: center;
558
613
  gap: 6px;
559
- font-size: 13px;
560
- color: ${e.colorTextSecondary};
561
- white-space: nowrap;
562
- `,dot:t`
563
- width: 8px;
564
- height: 8px;
565
- border-radius: 9999px;
566
- background: ${e.colorTextSecondary};
567
- `,dotLive:t`
568
- background: ${e.colorSuccess};
569
- `,dotBusy:t`
570
- background: ${e.colorWarning};
571
- `,dotDown:t`
572
- background: ${e.colorError};
573
- `,counts:t`
574
- font-size: 13px;
575
- color: ${e.colorTextSecondary};
576
- white-space: nowrap;
577
- `}));var Qo=n(C());var Yo=n(s());var Cd=w(({token:e,css:t})=>({root:t`
614
+ flex-shrink: 0;
615
+ margin-left: auto;
616
+ `}));var jt=n(w());var Zo=n(a());var ap=C(({token:e,css:t})=>({root:t`
578
617
  display: flex;
579
618
  flex-direction: column;
580
619
  height: 100%;
@@ -587,8 +626,6 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
587
626
  justify-content: space-between;
588
627
  gap: 12px;
589
628
  padding-bottom: ${e.padding}px;
590
- border-bottom: 1px solid ${e.colorBorderSecondary};
591
- margin-bottom: ${e.padding}px;
592
629
  `,titleSection:t`
593
630
  display: flex;
594
631
  align-items: center;
@@ -598,22 +635,25 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
598
635
  font-size: 16px;
599
636
  font-weight: 600;
600
637
  color: ${e.colorText};
601
- `,count:t`
602
- font-size: 13px;
603
- color: ${e.colorTextSecondary};
604
- `,actions:t`
605
- display: flex;
606
- align-items: center;
607
- gap: 8px;
638
+ `,search:t`
639
+ padding-bottom: ${e.padding}px;
640
+ margin-bottom: ${e.padding}px;
641
+ border-bottom: 1px solid ${e.colorBorderSecondary};
608
642
  `,section:t`
609
643
  margin-bottom: ${e.paddingLG}px;
610
644
  `,sectionTitle:t`
611
- font-size: 13px;
645
+ display: flex;
646
+ align-items: center;
647
+ gap: 6px;
648
+ font-size: 12px;
612
649
  font-weight: 600;
613
650
  color: ${e.colorTextSecondary};
614
651
  text-transform: uppercase;
615
652
  letter-spacing: 0.5px;
616
- margin: 0 0 12px 0;
653
+ margin: 0 0 8px 0;
654
+ `,sectionCount:t`
655
+ font-weight: 500;
656
+ color: ${e.colorTextTertiary};
617
657
  `,list:t`
618
658
  list-style: none;
619
659
  padding: 0;
@@ -621,13 +661,13 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
621
661
  `,row:t`
622
662
  display: flex;
623
663
  align-items: center;
624
- gap: 12px;
625
- padding: 10px 12px;
664
+ gap: 10px;
665
+ padding: 6px 8px;
626
666
  border-radius: ${e.borderRadius}px;
627
667
  transition: background-color 150ms;
628
668
 
629
669
  &:hover {
630
- background-color: ${e.colorBgElevated};
670
+ background-color: ${e.colorBgTextHover};
631
671
  }
632
672
  `,identity:t`
633
673
  display: flex;
@@ -644,21 +684,101 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
644
684
  `,meta:t`
645
685
  font-size: 12px;
646
686
  color: ${e.colorTextSecondary};
647
- `,controls:t`
648
- display: flex;
687
+ white-space: nowrap;
688
+ overflow: hidden;
689
+ text-overflow: ellipsis;
690
+ `,avatarWrap:t`
691
+ position: relative;
692
+ display: inline-flex;
693
+ flex-shrink: 0;
694
+ `,presenceDot:t`
695
+ position: absolute;
696
+ right: -1px;
697
+ bottom: -1px;
698
+ width: 10px;
699
+ height: 10px;
700
+ border-radius: 50%;
701
+ border: 2px solid ${e.colorBgContainer};
702
+ box-sizing: content-box;
703
+ `,botBadge:t`
704
+ position: absolute;
705
+ left: -4px;
706
+ top: -4px;
707
+ display: inline-flex;
649
708
  align-items: center;
650
- gap: 4px;
709
+ justify-content: center;
710
+ width: 14px;
711
+ height: 14px;
712
+ border-radius: 50%;
713
+ color: #fff;
714
+ border: 1.5px solid ${e.colorBgContainer};
715
+ `,action:t`
651
716
  flex-shrink: 0;
717
+ color: ${e.colorTextTertiary};
718
+
719
+ &:hover {
720
+ color: ${e.colorText};
721
+ }
652
722
  `,empty:t`
653
723
  color: ${e.colorTextSecondary};
654
724
  font-size: 13px;
655
725
  font-style: italic;
656
- padding: 12px 0;
726
+ padding: 8px 0;
657
727
  `,historical:t`
658
728
  opacity: 0.7;
659
729
  `,error:t`
660
730
  margin-bottom: 12px;
661
- `}));var lo=n(C());var Qr=n(s());var nn=n(C());var re=n(C());var Xo=e=>{if(!e)return"";let t=e.split("/").filter(Boolean);return t[t.length-1]??""},Yr=(e,t)=>{if(t==="name")return null;let o=t==="created"?e.created_at:e.modified_at;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function jt(e,t="name",o="asc"){return[...e].sort((r,a)=>{if(!!r.is_dir!=!!a.is_dir)return r.is_dir?-1:1;if(t==="name"){let c=Xo(r.path),p=Xo(a.path);return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=Yr(r,t),d=Yr(a,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}function Xr(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>{let a=(r.path||"").toLowerCase(),i=Xo(r.path).toLowerCase();return a.includes(o)||i.includes(o)}):e}function Jr(e){let t=[];return e.forEach(o=>{let r=(o.path||"").split("/").filter(Boolean);if(r.length===0)return;let a=t;r.forEach((i,d)=>{let c=d===r.length-1,p="/"+r.slice(0,d+1).join("/"),g=a.find(b=>b.path===p);g||(g=c?{...o,path:p,name:i}:{path:p,name:i,is_dir:!0,children:[]},a.push(g)),c||(a=g.children??(g.children=[]))})}),t}function Jo(e,t="name",o="asc"){return jt(e,t,o).map(r=>r.children?{...r,children:Jo(r.children,t,o)}:r)}var y=n(s()),wa=w(({token:e,css:t})=>({container:t`
731
+ `}));var Lt=n(w());var Jr=n(a()),yp=C(({token:e,css:t})=>({root:t`
732
+ display: flex;
733
+ flex-direction: column;
734
+ height: 100%;
735
+ overflow-y: auto;
736
+ padding: 8px;
737
+ `,empty:t`
738
+ margin: auto;
739
+ color: ${e.colorTextSecondary};
740
+ font-size: 14px;
741
+ `,list:t`
742
+ list-style: none;
743
+ margin: 0;
744
+ padding: 0;
745
+ display: flex;
746
+ flex-direction: column;
747
+ gap: 8px;
748
+ `,item:t`
749
+ display: flex;
750
+ `,open:t`
751
+ width: 100%;
752
+ display: flex;
753
+ flex-direction: column;
754
+ gap: 6px;
755
+ text-align: left;
756
+ padding: 10px 12px;
757
+ border: 1px solid ${e.colorBorderSecondary};
758
+ border-radius: ${e.borderRadiusLG}px;
759
+ background: ${e.colorBgContainer};
760
+ cursor: pointer;
761
+ transition: all 0.15s ease;
762
+
763
+ &:hover {
764
+ background: ${e.colorFillQuaternary};
765
+ border-color: ${e.colorBorder};
766
+ }
767
+ `,title:t`
768
+ font-size: 14px;
769
+ font-weight: 500;
770
+ color: ${e.colorText};
771
+ overflow: hidden;
772
+ text-overflow: ellipsis;
773
+ white-space: nowrap;
774
+ `,meta:t`
775
+ display: flex;
776
+ align-items: center;
777
+ flex-wrap: wrap;
778
+ gap: 8px;
779
+ font-size: 12px;
780
+ color: ${e.colorTextSecondary};
781
+ `}));var sn=n(w());var re=n(w());var en=e=>{if(!e)return"";let t=e.split("/").filter(Boolean);return t[t.length-1]??""},Zr=(e,t)=>{if(t==="name")return null;let o=t==="created"?e.created_at:e.modified_at;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function _t(e,t="name",o="asc"){return[...e].sort((r,s)=>{if(!!r.is_dir!=!!s.is_dir)return r.is_dir?-1:1;if(t==="name"){let c=en(r.path),p=en(s.path);return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=Zr(r,t),d=Zr(s,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}function ei(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>{let s=(r.path||"").toLowerCase(),i=en(r.path).toLowerCase();return s.includes(o)||i.includes(o)}):e}function ti(e){let t=[];return e.forEach(o=>{let r=(o.path||"").split("/").filter(Boolean);if(r.length===0)return;let s=t;r.forEach((i,d)=>{let c=d===r.length-1,p="/"+r.slice(0,d+1).join("/"),g=s.find(v=>v.path===p);g||(g=c?{...o,path:p,name:i}:{path:p,name:i,is_dir:!0,children:[]},s.push(g)),c||(s=g.children??(g.children=[]))})}),t}function tn(e,t="name",o="asc"){return _t(e,t,o).map(r=>r.children?{...r,children:tn(r.children,t,o)}:r)}var y=n(a()),Da=C(({token:e,css:t})=>({container:t`
662
782
  height: 100%;
663
783
  overflow-y: auto;
664
784
  overflow-x: hidden;
@@ -847,7 +967,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
847
967
  width: 14px;
848
968
  height: 14px;
849
969
  }
850
- `})),Zr=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()},Ca=e=>{if(!e)return"";let t=e.split(/[/\\]/);return t[t.length-1]},Zo=e=>Ca(e.name||e.path),Sa=e=>(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{style:{fontWeight:600},children:Zo(e)}),e.created_at?(0,y.jsxs)("div",{children:["Created: ",Zr(e.created_at)]}):null,e.modified_at?(0,y.jsxs)("div",{children:["Modified: ",Zr(e.modified_at)]}):null]}),ka={display:"flex",flexDirection:"column",gap:12},en=({workspaceId:e,projectId:t,resourceFolders:o,folderEntries:r,folderLoading:a,directoryChildren:i,directoryLoading:d,directoryExpanded:c,uploadingFolder:p,onRefreshFolder:g,onUploadFolder:b,onToggleDirectory:x,onAssetClick:h})=>{let{styles:u}=wa(),{message:m}=No.useApp(),{currentAssistant:v}=et(),{getFileDownloadUrl:O,downloadFolder:_,getDirectFileUrl:E,listPathByFolder:Y}=Ie(),{openSideApp:ee}=Se(),{currentTenant:de}=We(),V=de?.id||"",[S,F]=(0,re.useState)(null),[J,Z]=(0,re.useState)(null),{check:A,pin:ae,unpin:B,enableCustomMenu:j,get:se}=co(),$=tn(),[R,I]=(0,re.useState)($);(0,re.useEffect)(()=>{I($)},[$]);let[T,le]=(0,re.useState)({}),[k,oe]=(0,re.useState)(null),[D,U]=(0,re.useState)(""),[Oe,Ke]=(0,re.useState)(""),[Ze,gt]=(0,re.useState)(!1),[nt,W]=(0,re.useState)(""),[fe,rt]=(0,re.useState)("name"),[Qe,na]=(0,re.useState)("asc"),[Ot,Po]=(0,re.useState)(null),[ra,Io]=(0,re.useState)(!1);(0,re.useEffect)(()=>{k&&on(se).then(f=>{I(Array.from(new Set([...$,...f])).sort())})},[k]),(0,re.useEffect)(()=>{let f=nt.trim();if(!f){Po(null),Io(!1);return}let X=!1;return Io(!0),Mr(Y,o.map(K=>K.name),v?.id).then(K=>{X||Po(Xr(K,f))}).catch(()=>{X||Po([])}).finally(()=>{X||Io(!1)}),()=>{X=!0}},[nt,Y,o,v?.id]);let Ao=(0,re.useMemo)(()=>Ot?Jo(Jr(Ot),fe,Qe):null,[Ot,fe,Qe]),Wt=(0,re.useCallback)((f,X)=>{if(!X||!j)return;le(L=>L[f]?L:{...L,[f]:{isPinned:!1,pinnedId:null,loading:!0}});let K={contentType:"file",contentConfig:{resourcePath:f,tenantId:V,workspaceId:e||"",projectId:t||"",assistantId:v?.id||"",fileName:f.split("/").pop()||f},isMatch:L=>L.resourcePath===f};A(K).then(L=>{le(He=>({...He,[f]:{...L,loading:!1}}))}).catch(()=>{le(L=>({...L,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))})},[j,A,v?.id]),ia=async()=>{if(!k||!D.trim()){m.warning("Please enter a menu name");return}gt(!0);try{let f=k.split("/").pop()||k;await ae({contentType:"file",name:D.trim(),group:Oe.trim()||void 0,contentConfig:{resourcePath:k,tenantId:V,workspaceId:e||"",projectId:t||"",assistantId:v?.id||"",fileName:f},isMatch:X=>X.resourcePath===k}),m.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),oe(null),U(""),Ke(""),le(X=>{let K={...X};return delete K[k],K})}catch(f){m.error(f.message||"Failed to pin")}finally{gt(!1)}},Ut=(0,re.useCallback)(async(f,X)=>{le(K=>({...K,[f]:{...K[f],loading:!0}}));try{await B(X),m.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),le(K=>({...K,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))}catch(K){m.error(K.message||"Failed to unpin"),le(L=>({...L,[f]:{...L[f],loading:!1}}))}},[B,m]),jn=(0,re.useCallback)(async f=>{Z(f);try{let X=await _(f,v?.id),K=URL.createObjectURL(X),L=document.createElement("a");L.href=K;let He=f.replace(/\/$/,"").split("/").pop()||"folder";L.download=`${He}.zip`,L.click(),window.setTimeout(()=>URL.revokeObjectURL(K),0)}catch(X){m.error(X instanceof Error?X.message:"Failed to download folder")}finally{Z(null)}},[_,v?.id,m]),Eo=re.default.useCallback((f,X)=>{let K=Zo(f);if(f.is_dir){let L=c[f.path]||!1,He=i[f.path]||[],aa=d[f.path]||!1;return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map((Ye,sa)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${sa}`)),(0,y.jsx)("button",{type:"button",className:u.treeToggle,"aria-label":`${L?"collapse":"expand"} ${K}`,onClick:()=>void x(f.path),children:(0,y.jsx)(Nt,{size:14,style:{transform:L?"rotate(90deg)":void 0}})}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,"aria-label":`toggle ${K}`,onClick:()=>void x(f.path),title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(at,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:Ye=>Wt(f.path,Ye),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let Ye=T[f.path];Ye?.pinnedId&&Ut(f.path,Ye.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(qt,{}),label:"Preview",onClick:()=>{let Ye=E(f.path);Ye&&ee({component_key:"attachments",data:{file_id:f.path,url:Ye},message:K})}},{key:"share",icon:(0,y.jsx)(Vt,{}),label:"Share",onClick:()=>F(f.path)},{key:"download-folder",icon:(0,y.jsx)(Fo,{}),label:"Download",disabled:J===f.path,onClick:()=>{jn(f.path)}}]},children:(0,y.jsx)(z,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]}),L?aa?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):He.length>0?jt(He,fe,Qe).map(Ye=>Eo(Ye,X+1)):(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null]},f.path)}return(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map((L,He)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${He}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsx)(ze,{title:Sa(f),placement:"rightTop",children:(0,y.jsxs)("button",{type:"button",className:u.assetItem,onClick:()=>h(f),"aria-label":`open ${K}`,children:[(0,y.jsx)("div",{className:u.assetIcon,children:Nr(K)}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]})}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:L=>Wt(f.path,L),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let L=T[f.path];L?.pinnedId&&Ut(f.path,L.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(""),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(qt,{}),label:"Preview",onClick:()=>h(f)},{key:"download",icon:(0,y.jsx)(Fo,{}),label:"Download",onClick:()=>{let L=O(f.path,v?.id);window.open(L,"_blank")}},{key:"share",icon:(0,y.jsx)(Vt,{}),label:"Share",onClick:()=>F(f.path)}]},children:(0,y.jsx)(z,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]},f.path)},[i,c,d,h,x,u,O,_,v?.id,j,T,Wt,Ut,J,jn,fe,Qe]),Ln=(f,X)=>{if(!f.is_dir)return Eo(f,X);let K=Zo(f);return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map((L,He)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${He}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(at,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:L=>Wt(f.path,L),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let L=T[f.path];L?.pinnedId&&Ut(f.path,L.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(qt,{}),label:"Preview",onClick:()=>{let L=E(f.path);L&&ee({component_key:"attachments",data:{file_id:f.path,url:L},message:K})}},{key:"share",icon:(0,y.jsx)(Vt,{}),label:"Share",onClick:()=>F(f.path)}]},children:(0,y.jsx)(z,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]}),f.children&&f.children.length>0?jt(f.children,fe,Qe).map(L=>Ln(L,X+1)):null]},f.path)};return t?(0,y.jsxs)("div",{className:u.container,children:[(0,y.jsxs)("h3",{className:u.header,children:[(0,y.jsx)(at,{size:16}),(0,y.jsx)("span",{children:"Files"})]}),(0,y.jsxs)("div",{className:u.toolbar,children:[(0,y.jsx)(H,{size:"small",placeholder:"Search files\u2026",allowClear:!0,value:nt,onChange:f=>W(f.target.value)}),(0,y.jsxs)("div",{className:u.toolbarRow,children:[(0,y.jsx)(Ee,{size:"small",style:{flex:1,minWidth:0},value:fe,onChange:f=>rt(f),options:[{value:"name",label:"Name"},{value:"created",label:"Created"},{value:"modified",label:"Modified"}]}),(0,y.jsx)(z,{size:"small",icon:Qe==="asc"?(0,y.jsx)(Gt,{}):(0,y.jsx)(Qt,{}),onClick:()=>na(f=>f==="asc"?"desc":"asc"),title:Qe==="asc"?"Ascending":"Descending"})]})]}),Ot!==null?(0,y.jsx)("div",{className:u.assetList,children:ra?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):Ao&&Ao.length>0?Ao.map(f=>Ln(f,0)):(0,y.jsxs)("div",{className:u.emptyState,children:['No files match "',nt.trim(),'"']})}):o.map(f=>{let X=r[f.name]||[],K=a[f.name]||!1,L=X.length;return(0,y.jsxs)("div",{className:u.section,children:[(0,y.jsxs)("div",{className:u.sectionHeader,children:[(0,y.jsx)("span",{className:u.sectionTitle,onClick:()=>void g(f),title:"Click to refresh",children:f.displayName||f.name}),(0,y.jsx)("span",{className:u.badge,children:L})]}),K?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):(0,y.jsxs)("div",{className:u.assetList,children:[jt(X,fe,Qe).map(He=>Eo(He,0)),X.length===0?(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null,f.allowUpload?(0,y.jsx)("button",{type:"button",className:u.uploadBtn,onClick:()=>void b(f.name),disabled:!e||!t||p===f.name,children:p===f.name?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ne,{size:"small"}),(0,y.jsx)("span",{children:"Uploading..."})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Tr,{size:14}),(0,y.jsx)("span",{children:"Upload"})]})}):null]})]},f.name)}),S&&(0,y.jsx)(Er,{open:!!S,filePath:S,assistantId:v?.id,fileName:S.split("/").pop(),onClose:()=>F(null)}),(0,y.jsx)(pe,{title:"Pin to Menu",open:!!k,onOk:ia,onCancel:()=>oe(null),confirmLoading:Ze,okText:"Pin",children:(0,y.jsxs)("div",{style:ka,children:[(0,y.jsx)(H,{placeholder:"Menu name (required)",value:D,onChange:f=>U(f.target.value)}),(0,y.jsx)(Kt,{placeholder:"Group (optional, select or type new)",value:Oe,options:R.map(f=>({value:f})),onChange:f=>Ke(f),filterOption:(f,X)=>X?.value?.toUpperCase().includes(f.toUpperCase())??!1})]})})]}):(0,y.jsx)("div",{className:u.emptyState,children:"Please select a project to browse files"})};var ei=n(s());var ep=w(({token:e,css:t})=>({root:t`
970
+ `})),oi=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()},za=e=>{if(!e)return"";let t=e.split(/[/\\]/);return t[t.length-1]},on=e=>za(e.name||e.path),Fa=e=>(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{style:{fontWeight:600},children:on(e)}),e.created_at?(0,y.jsxs)("div",{children:["Created: ",oi(e.created_at)]}):null,e.modified_at?(0,y.jsxs)("div",{children:["Modified: ",oi(e.modified_at)]}):null]}),$a={display:"flex",flexDirection:"column",gap:12},nn=({workspaceId:e,projectId:t,resourceFolders:o,folderEntries:r,folderLoading:s,directoryChildren:i,directoryLoading:d,directoryExpanded:c,uploadingFolder:p,onRefreshFolder:g,onUploadFolder:v,onToggleDirectory:x,onAssetClick:h})=>{let{styles:u}=Da(),{message:m}=Mo.useApp(),{currentAssistant:b}=et(),{getFileDownloadUrl:O,downloadFolder:L,getDirectFileUrl:N,listPathByFolder:X}=Ie(),{openSideApp:ee}=Se(),{currentTenant:de}=Oe(),Q=de?.id||"",[S,B]=(0,re.useState)(null),[J,Z]=(0,re.useState)(null),{check:A,pin:ae,unpin:D,enableCustomMenu:$,get:se}=po(),_=rn(),[R,I]=(0,re.useState)(_);(0,re.useEffect)(()=>{I(_)},[_]);let[T,le]=(0,re.useState)({}),[k,oe]=(0,re.useState)(null),[z,U]=(0,re.useState)(""),[We,Ke]=(0,re.useState)(""),[Ze,ft]=(0,re.useState)(!1),[nt,W]=(0,re.useState)(""),[fe,rt]=(0,re.useState)("name"),[Qe,sa]=(0,re.useState)("asc"),[Kt,Io]=(0,re.useState)(null),[la,Ao]=(0,re.useState)(!1);(0,re.useEffect)(()=>{k&&an(se).then(f=>{I(Array.from(new Set([..._,...f])).sort())})},[k]),(0,re.useEffect)(()=>{let f=nt.trim();if(!f){Io(null),Ao(!1);return}let Y=!1;return Ao(!0),Br(X,o.map(K=>K.name),b?.id).then(K=>{Y||Io(ei(K,f))}).catch(()=>{Y||Io([])}).finally(()=>{Y||Ao(!1)}),()=>{Y=!0}},[nt,X,o,b?.id]);let Eo=(0,re.useMemo)(()=>Kt?tn(ti(Kt),fe,Qe):null,[Kt,fe,Qe]),Ht=(0,re.useCallback)((f,Y)=>{if(!Y||!$)return;le(j=>j[f]?j:{...j,[f]:{isPinned:!1,pinnedId:null,loading:!0}});let K={contentType:"file",contentConfig:{resourcePath:f,tenantId:Q,workspaceId:e||"",projectId:t||"",assistantId:b?.id||"",fileName:f.split("/").pop()||f},isMatch:j=>j.resourcePath===f};A(K).then(j=>{le(He=>({...He,[f]:{...j,loading:!1}}))}).catch(()=>{le(j=>({...j,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))})},[$,A,b?.id]),ca=async()=>{if(!k||!z.trim()){m.warning("Please enter a menu name");return}ft(!0);try{let f=k.split("/").pop()||k;await ae({contentType:"file",name:z.trim(),group:We.trim()||void 0,contentConfig:{resourcePath:k,tenantId:Q,workspaceId:e||"",projectId:t||"",assistantId:b?.id||"",fileName:f},isMatch:Y=>Y.resourcePath===k}),m.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),oe(null),U(""),Ke(""),le(Y=>{let K={...Y};return delete K[k],K})}catch(f){m.error(f.message||"Failed to pin")}finally{ft(!1)}},qt=(0,re.useCallback)(async(f,Y)=>{le(K=>({...K,[f]:{...K[f],loading:!0}}));try{await D(Y),m.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),le(K=>({...K,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))}catch(K){m.error(K.message||"Failed to unpin"),le(j=>({...j,[f]:{...j[f],loading:!1}}))}},[D,m]),Ln=(0,re.useCallback)(async f=>{Z(f);try{let Y=await L(f,b?.id),K=URL.createObjectURL(Y),j=document.createElement("a");j.href=K;let He=f.replace(/\/$/,"").split("/").pop()||"folder";j.download=`${He}.zip`,j.click(),window.setTimeout(()=>URL.revokeObjectURL(K),0)}catch(Y){m.error(Y instanceof Error?Y.message:"Failed to download folder")}finally{Z(null)}},[L,b?.id,m]),No=re.default.useCallback((f,Y)=>{let K=on(f);if(f.is_dir){let j=c[f.path]||!1,He=i[f.path]||[],da=d[f.path]||!1;return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:Y}).map((Ye,pa)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${pa}`)),(0,y.jsx)("button",{type:"button",className:u.treeToggle,"aria-label":`${j?"collapse":"expand"} ${K}`,onClick:()=>void x(f.path),children:(0,y.jsx)(Mt,{size:14,style:{transform:j?"rotate(90deg)":void 0}})}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,"aria-label":`toggle ${K}`,onClick:()=>void x(f.path),title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(at,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:Ye=>Ht(f.path,Ye),menu:{items:[...$?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let Ye=T[f.path];Ye?.pinnedId&&qt(f.path,Ye.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(Qt,{}),label:"Preview",onClick:()=>{let Ye=N(f.path);Ye&&ee({component_key:"attachments",data:{file_id:f.path,url:Ye},message:K})}},{key:"share",icon:(0,y.jsx)(Yt,{}),label:"Share",onClick:()=>B(f.path)},{key:"download-folder",icon:(0,y.jsx)($o,{}),label:"Download",disabled:J===f.path,onClick:()=>{Ln(f.path)}}]},children:(0,y.jsx)(F,{type:"text",size:"small",icon:(0,y.jsx)(yt,{})})})]}),j?da?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):He.length>0?_t(He,fe,Qe).map(Ye=>No(Ye,Y+1)):(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null]},f.path)}return(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:Y}).map((j,He)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${He}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsx)(Fe,{title:Fa(f),placement:"rightTop",children:(0,y.jsxs)("button",{type:"button",className:u.assetItem,onClick:()=>h(f),"aria-label":`open ${K}`,children:[(0,y.jsx)("div",{className:u.assetIcon,children:Mr(K)}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]})}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:j=>Ht(f.path,j),menu:{items:[...$?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let j=T[f.path];j?.pinnedId&&qt(f.path,j.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(""),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(Qt,{}),label:"Preview",onClick:()=>h(f)},{key:"download",icon:(0,y.jsx)($o,{}),label:"Download",onClick:()=>{let j=O(f.path,b?.id);window.open(j,"_blank")}},{key:"share",icon:(0,y.jsx)(Yt,{}),label:"Share",onClick:()=>B(f.path)}]},children:(0,y.jsx)(F,{type:"text",size:"small",icon:(0,y.jsx)(yt,{})})})]},f.path)},[i,c,d,h,x,u,O,L,b?.id,$,T,Ht,qt,J,Ln,fe,Qe]),_n=(f,Y)=>{if(!f.is_dir)return No(f,Y);let K=on(f);return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:Y}).map((j,He)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${He}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(at,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:j=>Ht(f.path,j),menu:{items:[...$?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let j=T[f.path];j?.pinnedId&&qt(f.path,j.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(Qt,{}),label:"Preview",onClick:()=>{let j=N(f.path);j&&ee({component_key:"attachments",data:{file_id:f.path,url:j},message:K})}},{key:"share",icon:(0,y.jsx)(Yt,{}),label:"Share",onClick:()=>B(f.path)}]},children:(0,y.jsx)(F,{type:"text",size:"small",icon:(0,y.jsx)(yt,{})})})]}),f.children&&f.children.length>0?_t(f.children,fe,Qe).map(j=>_n(j,Y+1)):null]},f.path)};return t?(0,y.jsxs)("div",{className:u.container,children:[(0,y.jsxs)("h3",{className:u.header,children:[(0,y.jsx)(at,{size:16}),(0,y.jsx)("span",{children:"Files"})]}),(0,y.jsxs)("div",{className:u.toolbar,children:[(0,y.jsx)(H,{size:"small",placeholder:"Search files\u2026",allowClear:!0,value:nt,onChange:f=>W(f.target.value)}),(0,y.jsxs)("div",{className:u.toolbarRow,children:[(0,y.jsx)(Ee,{size:"small",style:{flex:1,minWidth:0},value:fe,onChange:f=>rt(f),options:[{value:"name",label:"Name"},{value:"created",label:"Created"},{value:"modified",label:"Modified"}]}),(0,y.jsx)(F,{size:"small",icon:Qe==="asc"?(0,y.jsx)(Xt,{}):(0,y.jsx)(Jt,{}),onClick:()=>sa(f=>f==="asc"?"desc":"asc"),title:Qe==="asc"?"Ascending":"Descending"})]})]}),Kt!==null?(0,y.jsx)("div",{className:u.assetList,children:la?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):Eo&&Eo.length>0?Eo.map(f=>_n(f,0)):(0,y.jsxs)("div",{className:u.emptyState,children:['No files match "',nt.trim(),'"']})}):o.map(f=>{let Y=r[f.name]||[],K=s[f.name]||!1,j=Y.length;return(0,y.jsxs)("div",{className:u.section,children:[(0,y.jsxs)("div",{className:u.sectionHeader,children:[(0,y.jsx)("span",{className:u.sectionTitle,onClick:()=>void g(f),title:"Click to refresh",children:f.displayName||f.name}),(0,y.jsx)("span",{className:u.badge,children:j})]}),K?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):(0,y.jsxs)("div",{className:u.assetList,children:[_t(Y,fe,Qe).map(He=>No(He,0)),Y.length===0?(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null,f.allowUpload?(0,y.jsx)("button",{type:"button",className:u.uploadBtn,onClick:()=>void v(f.name),disabled:!e||!t||p===f.name,children:p===f.name?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ne,{size:"small"}),(0,y.jsx)("span",{children:"Uploading..."})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pr,{size:14}),(0,y.jsx)("span",{children:"Upload"})]})}):null]})]},f.name)}),S&&(0,y.jsx)(Nr,{open:!!S,filePath:S,assistantId:b?.id,fileName:S.split("/").pop(),onClose:()=>B(null)}),(0,y.jsx)(pe,{title:"Pin to Menu",open:!!k,onOk:ca,onCancel:()=>oe(null),confirmLoading:Ze,okText:"Pin",children:(0,y.jsxs)("div",{style:$a,children:[(0,y.jsx)(H,{placeholder:"Menu name (required)",value:z,onChange:f=>U(f.target.value)}),(0,y.jsx)(Vt,{placeholder:"Group (optional, select or type new)",value:We,options:R.map(f=>({value:f})),onChange:f=>Ke(f),filterOption:(f,Y)=>Y?.value?.toUpperCase().includes(f.toUpperCase())??!1})]})})]}):(0,y.jsx)("div",{className:u.emptyState,children:"Please select a project to browse files"})};var ni=n(a());var _p=C(({token:e,css:t})=>({root:t`
851
971
  display: flex;
852
972
  flex-direction: column;
853
973
  height: 100%;
@@ -872,88 +992,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
872
992
  flex: 1;
873
993
  min-height: 0;
874
994
  overflow: hidden;
875
- `}));var Ra=n(C());var ti=n(s());var ap=w(({token:e,css:t})=>({root:t`
876
- display: flex;
877
- flex-direction: column;
878
- height: 100%;
879
- overflow-y: auto;
880
- padding: 12px;
881
- background: transparent;
882
- `,header:t`
883
- display: flex;
884
- align-items: center;
885
- gap: 8px;
886
- margin-bottom: 12px;
887
- padding: 0 4px;
888
- font-size: 15px;
889
- line-height: 1.4;
890
- font-weight: 600;
891
- color: ${e.colorText};
892
- letter-spacing: -0.01em;
893
- padding-bottom: 8px;
894
- border-bottom: 1px solid ${e.colorBorderSecondary};
895
-
896
- svg {
897
- width: 16px;
898
- height: 16px;
899
- color: ${e.colorTextSecondary};
900
- }
901
- `,list:t`
902
- display: flex;
903
- flex-direction: column;
904
- gap: 2px;
905
- `,item:t`
906
- display: flex;
907
- flex-direction: column;
908
- gap: 6px;
909
- padding: 10px 8px;
910
- border-radius: 6px;
911
- transition: background 0.15s ease;
912
- background: transparent;
913
-
914
- &:hover {
915
- background: ${e.colorBgTextHover};
916
- }
917
- `,itemRow:t`
918
- display: flex;
919
- align-items: center;
920
- gap: 8px;
921
- flex-wrap: wrap;
922
- `,kindTag:t`
923
- flex-shrink: 0;
924
- font-size: 11px;
925
- font-weight: 500;
926
- border-radius: 4px;
927
- padding: 2px 6px;
928
- `,text:t`
929
- flex: 1;
930
- min-width: 0;
931
- font-size: 13px;
932
- color: ${e.colorText};
933
- line-height: 1.4;
934
- word-break: break-word;
935
- `,time:t`
936
- flex-shrink: 0;
937
- font-size: 11px;
938
- color: ${e.colorTextTertiary};
939
- white-space: nowrap;
940
- `,empty:t`
941
- display: flex;
942
- flex-direction: column;
943
- align-items: center;
944
- justify-content: center;
945
- padding: 24px;
946
- text-align: center;
947
- color: ${e.colorTextSecondary};
948
- font-size: 13px;
949
- gap: 8px;
950
-
951
- svg {
952
- width: 32px;
953
- height: 32px;
954
- opacity: 0.5;
955
- }
956
- `}));var oi=n(s());var Ep=w(({token:e,css:t})=>({root:t`
995
+ `}));var ri=n(a());var pm=C(({token:e,css:t})=>({root:t`
957
996
  display: flex;
958
997
  flex-direction: column;
959
998
  height: 100%;
@@ -972,34 +1011,82 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
972
1011
  white-space: nowrap;
973
1012
  border: 0;
974
1013
  `,loading:t`
1014
+ flex: 1;
1015
+ display: flex;
1016
+ flex-direction: column;
1017
+ align-items: center;
1018
+ justify-content: center;
1019
+ gap: 14px;
975
1020
  padding: 24px;
976
- overflow-y: auto;
1021
+ `,loadingDots:t`
1022
+ display: inline-flex;
1023
+ align-items: center;
1024
+ gap: 6px;
1025
+
1026
+ span {
1027
+ width: 8px;
1028
+ height: 8px;
1029
+ border-radius: 50%;
1030
+ background: ${e.colorPrimary};
1031
+ animation: room-loading-pulse 1.2s ease-in-out infinite;
1032
+
1033
+ &:nth-child(2) {
1034
+ animation-delay: 0.15s;
1035
+ }
1036
+
1037
+ &:nth-child(3) {
1038
+ animation-delay: 0.3s;
1039
+ }
1040
+ }
1041
+
1042
+ @keyframes room-loading-pulse {
1043
+ 0%,
1044
+ 80%,
1045
+ 100% {
1046
+ opacity: 0.25;
1047
+ transform: translateY(0);
1048
+ }
1049
+
1050
+ 40% {
1051
+ opacity: 1;
1052
+ transform: translateY(-4px);
1053
+ }
1054
+ }
1055
+ `,loadingText:t`
1056
+ font-size: 13px;
1057
+ color: ${e.colorTextSecondary};
977
1058
  `,main:t`
978
1059
  display: flex;
979
1060
  flex-direction: column;
980
1061
  flex: 1;
981
1062
  min-height: 0;
982
1063
  min-width: 0;
983
- `}));var Ea=n(s()),Lp=w(({css:e})=>({wrapper:e`
984
- height: 100%;
985
- width: 100%;
986
- overflow: hidden;
987
- `}));var ni=n(s()),Vp=w(({token:e,css:t})=>({menuList:t`
988
- height: 100%;
989
- overflow-y: auto;
990
- `,header:t`
1064
+ `,thinking:t`
991
1065
  display: flex;
992
1066
  align-items: center;
993
1067
  gap: 8px;
994
- padding: 0 4px;
995
- `,headerTitle:t`
996
- margin: 0;
997
- font-size: 15px;
998
- font-weight: 600;
1068
+ padding: 2px 12px 6px;
1069
+ font-size: 12px;
1070
+ color: ${e.colorTextSecondary};
1071
+ `,backButton:t`
1072
+ width: 40px;
1073
+ height: 40px;
1074
+ display: flex;
1075
+ align-items: center;
1076
+ justify-content: center;
1077
+ border: none;
1078
+ background: transparent;
999
1079
  color: ${e.colorText};
1000
- white-space: nowrap;
1080
+ cursor: pointer;
1081
+ padding: 0;
1082
+ margin-left: -8px;
1083
+ `}));var Wa=n(a()),vm=C(({css:e})=>({wrapper:e`
1084
+ height: 100%;
1085
+ width: 100%;
1001
1086
  overflow: hidden;
1002
- text-overflow: ellipsis;
1087
+ `}));var ii=n(a()),Am=C(({token:e,css:t})=>({menuList:t`
1088
+ height: 100%;
1089
+ overflow-y: auto;
1003
1090
  `,empty:t`
1004
1091
  display: flex;
1005
1092
  flex-direction: column;
@@ -1009,7 +1096,16 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1009
1096
  color: ${e.colorTextSecondary};
1010
1097
  font-size: 14px;
1011
1098
  gap: 8px;
1012
- `}));var ai=n(C());var an=n(C());var ri=n(s()),em=w(({token:e,css:t})=>({container:t`
1099
+ `,mobileRoot:t`
1100
+ display: flex;
1101
+ flex-direction: column;
1102
+ height: 100%;
1103
+ overflow: hidden;
1104
+ `,mobileBody:t`
1105
+ flex: 1;
1106
+ min-height: 0;
1107
+ overflow: hidden;
1108
+ `}));var li=n(w());var cn=n(w());var ai=n(a()),Fm=C(({token:e,css:t})=>({container:t`
1013
1109
  display: flex;
1014
1110
  flex-direction: column;
1015
1111
  height: 100%;
@@ -1096,7 +1192,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1096
1192
  color: ${e.colorPrimary};
1097
1193
  `,emptyContainer:t`
1098
1194
  padding: 24px 16px;
1099
- `}));var ii=n(s()),nm=w(({token:e,css:t})=>({container:t`
1195
+ `}));var si=n(a()),Lm=C(({token:e,css:t})=>({container:t`
1100
1196
  display: flex;
1101
1197
  flex-direction: column;
1102
1198
  height: 100%;
@@ -1189,7 +1285,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1189
1285
  display: flex;
1190
1286
  flex-direction: column;
1191
1287
  gap: 12px;
1192
- `}));var si=n(s()),um=w(({token:e,css:t})=>({menuList:t`
1288
+ `}));var dn=n(a()),Ym=C(({token:e,css:t})=>({menuList:t`
1193
1289
  height: 100%;
1194
1290
  overflow-y: auto;
1195
1291
  `,header:t`
@@ -1214,7 +1310,45 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1214
1310
  color: ${e.colorTextSecondary};
1215
1311
  font-size: 14px;
1216
1312
  gap: 8px;
1217
- `}));var ci=n(s()),Cm=w(({token:e,css:t})=>({iconNav:t`
1313
+ `,mobileRoot:t`
1314
+ display: flex;
1315
+ flex-direction: column;
1316
+ height: 100%;
1317
+ overflow: hidden;
1318
+ `,mobileHeader:t`
1319
+ display: flex;
1320
+ align-items: center;
1321
+ gap: 4px;
1322
+ flex-shrink: 0;
1323
+ min-height: 48px;
1324
+ padding: 0 8px;
1325
+ border-bottom: 1px solid ${e.colorBorderSecondary};
1326
+ `,backButton:t`
1327
+ width: 44px;
1328
+ height: 44px;
1329
+ display: flex;
1330
+ align-items: center;
1331
+ justify-content: center;
1332
+ border: none;
1333
+ background: transparent;
1334
+ color: ${e.colorText};
1335
+ cursor: pointer;
1336
+ `,mobileBody:t`
1337
+ flex: 1;
1338
+ min-height: 0;
1339
+ overflow: hidden;
1340
+ `}));var di=n(a()),pu=C(({token:e,css:t})=>({outer:t`
1341
+ display: flex;
1342
+ flex-direction: column;
1343
+ height: 100%;
1344
+ width: 100%;
1345
+ min-height: 0;
1346
+ overflow: hidden;
1347
+ `,inner:t`
1348
+ flex: 1;
1349
+ min-height: 0;
1350
+ overflow: hidden;
1351
+ `,iconNav:t`
1218
1352
  display: flex;
1219
1353
  flex-direction: column;
1220
1354
  align-items: center;
@@ -1257,7 +1391,40 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1257
1391
  height: 100%;
1258
1392
  width: 100%;
1259
1393
  overflow: hidden;
1260
- `}));var _a=n(s());var _t=n(C());var po=18,Fm={agent:_t.default.createElement(Et,{size:po}),html:_t.default.createElement(fr,{size:po}),custom:_t.default.createElement(Sr,{size:po}),file:_t.default.createElement(ur,{size:po})};var Ja=n(C());var $a=n(C());var di=n(s());var Xa=n(C());var mo=n(C());var dt=n(C());function pi(e){let{get:t}=me(),[o,r]=(0,dt.useState)(null),[a,i]=(0,dt.useState)(!0),[d,c]=(0,dt.useState)(!1);(0,dt.useEffect)(()=>{let b=!0,x=e||"/api/middleware-types";return i(!0),c(!1),r(null),t(x).then(h=>{if(!b)return;if(!Array.isArray(h)||h.length===0){c(!0);return}let u=h.map(m=>({type:m.type,name:m.name,description:m.description,icon:m.icon,tools:Array.isArray(m.tools)?m.tools.map(v=>({id:v.name,name:v.name,description:v.description})):[],schema:m.configSchema,defaultConfig:m.defaultConfig||{},category:m.category,capabilityBundleEligible:m.capabilityBundleEligible===!0,connectionSchema:m.connectionSchema?{fields:m.connectionSchema.fields,hasTest:m.connectionSchema.hasTest,hasDiscover:m.connectionSchema.hasDiscover,resourceLabel:m.connectionSchema.resourceLabel}:void 0}));r(u)}).catch(()=>{b&&c(!0)}).finally(()=>{b&&i(!1)}),()=>{b=!1}},[e,t]);let p=new Set(["topology"]);return{middlewareTypes:(0,dt.useMemo)(()=>(o||Gn).filter(b=>!p.has(b.type)),[o]),isLoading:a,isFallback:d}}var mi=w(({token:e,css:t})=>({nav:t`
1394
+ `,mobileRoot:t`
1395
+ display: flex;
1396
+ flex-direction: column;
1397
+ height: 100%;
1398
+ width: 100%;
1399
+ overflow: hidden;
1400
+ `,mobilePage:t`
1401
+ flex: 1;
1402
+ min-height: 0;
1403
+ overflow: hidden;
1404
+ `,tabBar:t`
1405
+ display: flex;
1406
+ flex-shrink: 0;
1407
+ border-top: 1px solid ${e.colorBorderSecondary};
1408
+ background: ${e.colorBgContainer};
1409
+ padding-bottom: env(safe-area-inset-bottom);
1410
+ `,tabButton:t`
1411
+ flex: 1;
1412
+ min-height: 48px;
1413
+ display: flex;
1414
+ flex-direction: column;
1415
+ align-items: center;
1416
+ justify-content: center;
1417
+ gap: 2px;
1418
+ border: none;
1419
+ background: transparent;
1420
+ cursor: pointer;
1421
+ color: ${e.colorTextSecondary};
1422
+ font-size: 11px;
1423
+
1424
+ &.active {
1425
+ color: ${e.colorPrimary};
1426
+ }
1427
+ `}));var Za=n(a());var Wt=n(w());var mo=18,ku={agent:Wt.default.createElement(Nt,{size:mo}),html:Wt.default.createElement(yr,{size:mo}),custom:Wt.default.createElement(kr,{size:mo}),file:Wt.default.createElement(gr,{size:mo})};var ms=n(w());var es=n(w());var pi=n(a());var ps=n(w());var uo=n(w());var pt=n(w());function mi(e){let{get:t}=me(),[o,r]=(0,pt.useState)(null),[s,i]=(0,pt.useState)(!0),[d,c]=(0,pt.useState)(!1);(0,pt.useEffect)(()=>{let v=!0,x=e||"/api/middleware-types";return i(!0),c(!1),r(null),t(x).then(h=>{if(!v)return;if(!Array.isArray(h)||h.length===0){c(!0);return}let u=h.map(m=>({type:m.type,name:m.name,description:m.description,icon:m.icon,tools:Array.isArray(m.tools)?m.tools.map(b=>({id:b.name,name:b.name,description:b.description})):[],schema:m.configSchema,defaultConfig:m.defaultConfig||{},category:m.category,capabilityBundleEligible:m.capabilityBundleEligible===!0,connectionSchema:m.connectionSchema?{fields:m.connectionSchema.fields,hasTest:m.connectionSchema.hasTest,hasDiscover:m.connectionSchema.hasDiscover,resourceLabel:m.connectionSchema.resourceLabel}:void 0}));r(u)}).catch(()=>{v&&c(!0)}).finally(()=>{v&&i(!1)}),()=>{v=!1}},[e,t]);let p=new Set(["topology"]);return{middlewareTypes:(0,pt.useMemo)(()=>(o||Qn).filter(v=>!p.has(v.type)),[o]),isLoading:s,isFallback:d}}var ui=C(({token:e,css:t})=>({nav:t`
1261
1428
  width: clamp(180px, 20vw, 240px);
1262
1429
  flex-shrink: 0;
1263
1430
  border-right: 1px solid ${e.colorBorderSecondary};
@@ -1371,7 +1538,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1371
1538
  height: 6px;
1372
1539
  border-radius: 9999px;
1373
1540
  flex-shrink: 0;
1374
- `}));var ui=n(s()),{Text:Vm}=P;var ue=n(C());var pt=n(C());var je=n(s()),{Text:gi}=P,fi=({connectionType:e,value:t=[],onChange:o})=>{let{token:r}=$e.useToken(),{get:a}=me(),[i,d]=(0,pt.useState)([]),[c,p]=(0,pt.useState)(!0),g=(0,pt.useRef)(e),b=(0,pt.useRef)(o);b.current=o,(0,pt.useEffect)(()=>{let h=!0;return g.current!==e&&(g.current=e,b.current([])),d([]),p(!0),a(`/api/connections?type=${encodeURIComponent(e)}`).then(u=>{h&&(Array.isArray(u)?d(u):u?.data?.records&&d(u.data.records))}).catch(()=>{h&&d([])}).finally(()=>{h&&p(!1)}),()=>{h=!1}},[e,a]);let x=new Set(t);return c?(0,je.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,je.jsx)(ne,{size:"small"})}):i.length===0?(0,je.jsx)(xe,{description:`No "${e}" connections`,image:xe.PRESENTED_IMAGE_SIMPLE}):(0,je.jsxs)("div",{children:[(0,je.jsxs)(ce,{style:{marginBottom:8},children:[(0,je.jsx)(z,{size:"small",onClick:()=>o(i.map(h=>h.key)),children:"Select All"}),(0,je.jsx)(z,{size:"small",onClick:()=>o([]),children:"Deselect All"})]}),(0,je.jsx)(Te,{size:"small",style:{maxHeight:"30vh",overflowY:"auto"},children:i.map(h=>(0,je.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:r.borderRadius,backgroundColor:x.has(h.key)?r.colorPrimaryBg:"transparent",border:`1px solid ${x.has(h.key)?r.colorPrimary:"transparent"}`,marginBottom:4},onClick:()=>{x.has(h.key)?o(t.filter(u=>u!==h.key)):o([...t,h.key])},children:(0,je.jsx)(Te.Item.Meta,{avatar:(0,je.jsx)(_e,{checked:x.has(h.key)}),title:(0,je.jsx)(gi,{style:{fontSize:12},children:h.name}),description:h.description?(0,je.jsx)(gi,{type:"secondary",style:{fontSize:10},children:h.description}):void 0})},h.key))})]})};var l=n(s()),{Text:we}=P,sn=w(({token:e,css:t})=>({pageHeader:t`
1541
+ `}));var gi=n(a()),{Text:Fu}=P;var ue=n(w());var mt=n(w());var $e=n(a()),{Text:fi}=P,yi=({connectionType:e,value:t=[],onChange:o})=>{let{token:r}=_e.useToken(),{get:s}=me(),[i,d]=(0,mt.useState)([]),[c,p]=(0,mt.useState)(!0),g=(0,mt.useRef)(e),v=(0,mt.useRef)(o);v.current=o,(0,mt.useEffect)(()=>{let h=!0;return g.current!==e&&(g.current=e,v.current([])),d([]),p(!0),s(`/api/connections?type=${encodeURIComponent(e)}`).then(u=>{h&&(Array.isArray(u)?d(u):u?.data?.records&&d(u.data.records))}).catch(()=>{h&&d([])}).finally(()=>{h&&p(!1)}),()=>{h=!1}},[e,s]);let x=new Set(t);return c?(0,$e.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,$e.jsx)(ne,{size:"small"})}):i.length===0?(0,$e.jsx)(xe,{description:`No "${e}" connections`,image:xe.PRESENTED_IMAGE_SIMPLE}):(0,$e.jsxs)("div",{children:[(0,$e.jsxs)(ce,{style:{marginBottom:8},children:[(0,$e.jsx)(F,{size:"small",onClick:()=>o(i.map(h=>h.key)),children:"Select All"}),(0,$e.jsx)(F,{size:"small",onClick:()=>o([]),children:"Deselect All"})]}),(0,$e.jsx)(Te,{size:"small",style:{maxHeight:"30vh",overflowY:"auto"},children:i.map(h=>(0,$e.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:r.borderRadius,backgroundColor:x.has(h.key)?r.colorPrimaryBg:"transparent",border:`1px solid ${x.has(h.key)?r.colorPrimary:"transparent"}`,marginBottom:4},onClick:()=>{x.has(h.key)?o(t.filter(u=>u!==h.key)):o([...t,h.key])},children:(0,$e.jsx)(Te.Item.Meta,{avatar:(0,$e.jsx)(Le,{checked:x.has(h.key)}),title:(0,$e.jsx)(fi,{style:{fontSize:12},children:h.name}),description:h.description?(0,$e.jsx)(fi,{type:"secondary",style:{fontSize:10},children:h.description}):void 0})},h.key))})]})};var l=n(a()),{Text:we}=P,pn=C(({token:e,css:t})=>({pageHeader:t`
1375
1542
  display: flex;
1376
1543
  align-items: center;
1377
1544
  gap: 16px;
@@ -1440,7 +1607,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1440
1607
  grid-template-columns: repeat(2, minmax(0, 1fr));
1441
1608
  gap: 12px 16px;
1442
1609
  padding: 8px 0;
1443
- `})),uo=({title:e,selectedCount:t,totalCount:o,searchPlaceholder:r,searchText:a,onSearchChange:i,onSelectAll:d,onClearAll:c,children:p,styles:g})=>{let b=o>0&&t===o;return(0,l.jsxs)("div",{className:g.dataSection,children:[(0,l.jsxs)("div",{className:g.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:[e,(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t," / ",o," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:b?c:d,children:b?"Clear":"Select All"})})]}),(0,l.jsx)("div",{style:{marginBottom:10},children:(0,l.jsx)(H,{size:"small",allowClear:!0,prefix:(0,l.jsx)(ir,{style:{fontSize:12}}),placeholder:r,value:a,onChange:x=>i(x.target.value),style:{width:"100%"}})}),(0,l.jsx)("div",{className:g.dataList,children:p})]})},Oa=({text:e,className:t})=>(0,l.jsx)(ze,{title:e,placement:"topLeft",children:(0,l.jsx)("div",{className:t,children:e})}),Wa=({tools:e,selectedToolNames:t,allToolNames:o,onChange:r,styles:a})=>{let i=e.length>0&&t.length===o.length,d=c=>{if(t.includes(c)){let p=t.filter(g=>g!==c);r(p.length===0?void 0:p)}else{let p=[...t,c];r(p.length===o.length&&o.every(g=>p.includes(g))?void 0:p)}};return(0,l.jsxs)("div",{className:a.dataSection,children:[(0,l.jsxs)("div",{className:a.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Tools",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t.length," / ",o.length," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:()=>r(i?[]:void 0),children:i?"Clear":"Select All"})})]}),(0,l.jsx)("div",{className:a.toolsGrid,children:e.map(c=>{let p=t.includes(c.name);return(0,l.jsx)(Bt,{item:c,dense:!0,className:p?a.selectedCard:void 0,onClick:()=>d(c.name),renderIcon:()=>(0,l.jsx)("span",{style:{fontSize:14,fontWeight:600},children:c.name.charAt(0).toUpperCase()}),renderPrimary:()=>c.name,renderDetails:()=>(0,l.jsx)(Oa,{text:c.description,className:a.toolDesc}),renderHeaderActions:()=>(0,l.jsx)(_e,{checked:p,onClick:g=>g.stopPropagation(),onChange:()=>d(c.name)})},c.id)})})]})},Ua=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/skills");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch skills:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>m.name.toLowerCase().includes(p.toLowerCase())||m.description.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(uo,{title:"Skill Library",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search skills\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.id)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No skills available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.id);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.id):[...h,m.id]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description})})},m.id)}})})},Ka=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/database-configs");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch database configs:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(uo,{title:"Databases",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search databases\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No databases available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.key);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.key):[...h,m.key]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},Ha=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/metrics-configs");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch metrics configs:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(uo,{title:"Metrics Servers",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search servers\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No servers available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.key);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.key):[...h,m.key]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},qa=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{x.current||(x.current=!0,c(!0),b("/api/collections").then(m=>{m.success&&i(m.data.records)}).catch(()=>{}).finally(()=>c(!1)))},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.label||m.name).toLowerCase().includes(p.toLowerCase())||m.name.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(uo,{title:"Collections",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search collections\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.name)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No collections available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.name);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.name):[...h,m.name]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.label||m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.name})})},m.name)}})})},Va=({value:e,onChange:t,token:o,styles:r})=>{let a=Array.isArray(e)?e:[],[i,d]=(0,ue.useState)({from:"",to:"",purpose:""}),c=()=>{!i.from.trim()||!i.to.trim()||!i.purpose.trim()||(t([...a,{...i}]),d({from:"",to:"",purpose:""}))};return(0,l.jsxs)("div",{className:r.dataSection,children:[(0,l.jsx)("div",{className:r.dataSectionHeader,children:(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Dependencies",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[a.length," edges"]})]})}),(0,l.jsx)("div",{className:r.dataList,children:a.length===0?(0,l.jsx)(xe,{description:"No dependencies defined yet",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):a.map((p,g)=>(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",marginBottom:4,borderRadius:o.borderRadius,backgroundColor:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`},children:[(0,l.jsx)(ve,{color:"blue",style:{margin:0,fontSize:11},children:p.from}),(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},children:"\u2192"}),(0,l.jsx)(ve,{color:"green",style:{margin:0,fontSize:11},children:p.to}),(0,l.jsx)(we,{style:{fontSize:12,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.purpose}),(0,l.jsx)(z,{type:"text",size:"small",danger:!0,icon:(0,l.jsx)(Jn,{}),onClick:()=>t(a.filter((b,x)=>x!==g))})]},g))}),(0,l.jsxs)("div",{style:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:12,marginTop:12},children:[(0,l.jsx)(we,{strong:!0,style:{fontSize:13,display:"block",marginBottom:8},children:"Add Dependency"}),(0,l.jsxs)(ce,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,l.jsx)(H,{size:"small",placeholder:"Source Agent ID",value:i.from,onChange:p=>d({...i,from:p.target.value})}),(0,l.jsx)(H,{size:"small",placeholder:"Target Agent ID",value:i.to,onChange:p=>d({...i,to:p.target.value})}),(0,l.jsx)(H,{size:"small",placeholder:"Purpose (e.g. classify invoice fields)",value:i.purpose,onChange:p=>d({...i,purpose:p.target.value}),onPressEnter:c}),(0,l.jsx)(z,{type:"dashed",size:"small",icon:(0,l.jsx)(nr,{}),onClick:c,disabled:!i.from.trim()||!i.to.trim()||!i.purpose.trim(),block:!0,children:"Add Edge"})]})]})]})},yi=(e,t,o,r,a)=>{let i=t.title||e,d=t.description?(0,l.jsx)(ze,{title:t.description,children:(0,l.jsx)(rr,{style:{color:a.colorTextSecondary,cursor:"pointer"}})}):null;if(t.widget==="switch"||!t.widget&&t.type==="boolean")return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(wt,{size:"small",checked:o,onChange:r})]},e),gridItem:null};if(t.widget==="segmented"){let g=t.enum?.map(b=>({value:b,label:{global:"Global",agent:"Agent",project:"Project"}[b]||b}))||[];return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(_n,{size:"small",value:o,onChange:r,options:g})]},e),gridItem:null}}let c=(0,l.jsxs)("span",{children:[i,d&&(0,l.jsxs)(l.Fragment,{children:["\xA0",d]})]}),p;if(t.type==="number"||t.type==="integer")p=(0,l.jsx)(H,{size:"small",type:"number",value:o,onChange:g=>r(parseFloat(g.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}});else if(t.widget==="select"||t.enum&&!t.widget){let g=t.enumLabels,b=g?Object.entries(g).map(([x,h])=>({value:x,label:h})):t.enum?.map(x=>({value:x,label:x}))||[];p=(0,l.jsx)(Ee,{size:"small",value:o,onChange:r,options:b,style:{width:"100%"}})}else t.widget==="textarea"?p=(0,l.jsx)(H.TextArea,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}}):p=(0,l.jsx)(H,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default});return{row:null,gridItem:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,l.jsx)(we,{style:{fontSize:12,color:a.colorTextSecondary},children:c}),p]},e)}},hi=({type:e})=>{let{token:t}=$e.useToken();switch(e){case"browser":return(0,l.jsx)(tr,{style:{color:t.colorPrimary}});case"sql":return(0,l.jsx)(Do,{style:{color:t.colorWarning}});case"skill":return(0,l.jsx)(sr,{style:{color:t.colorSuccess}});case"filesystem":return(0,l.jsx)(er,{style:{color:t.colorInfo}});case"code_eval":return(0,l.jsx)(Yn,{style:{color:t.colorError}});case"metrics":return(0,l.jsx)(Yt,{size:20,style:{color:t.colorWarning}});case"topology":return(0,l.jsx)(ar,{style:{color:t.colorPrimary}});case"document-parser":return(0,l.jsx)(Zn,{style:{color:t.colorSuccess}});case"collection":return(0,l.jsx)(Do,{style:{color:t.colorInfo}});default:return(0,l.jsx)(or,{style:{color:t.colorWarning}})}},Ga=({middleware:e,middlewareType:t,onToggle:o,onConfigChange:r,onAllowedToolsChange:a,enabledAriaLabel:i,sectionTitles:d,headerActions:c,token:p,styles:g,renderListSubSection:b})=>{let x=t?.schema?.properties??{},h=Object.keys(x),u=h.filter(S=>{let F=x[S];return F.widget==="skillSelect"||F.widget==="databaseSelect"||F.widget==="metricsSelect"||F.widget==="collectionSelect"||F.widget==="connectionSelect"||F.widget==="topologyEdgeBuilder"}),m=h.filter(S=>{let F=x[S];return u.includes(S)?!1:F.widget==="switch"||F.widget==="segmented"}),v=h.filter(S=>!(u.includes(S)||m.includes(S)||S==="vmIsolation")),O=u.filter(S=>{let F=x[S];return S==="skills"&&e.config.readAll===!0||S==="serverKeys"&&e.config.connectAll===!0||S==="collectionKeys"&&e.config.connectAll===!0||S==="connections"&&e.config.connectAll===!0?!1:!!F.widget}),_=()=>(0,l.jsxs)(l.Fragment,{children:[m.map(S=>{let F=x[S],{row:J}=yi(S,F,e.config[S]??F.default,Z=>r({[S]:Z}),p);return(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:J},S)}),v.length>0&&(0,l.jsx)("div",{className:g.configGrid,children:v.map(S=>{let F=x[S],{gridItem:J}=yi(S,F,e.config[S]??F.default,Z=>r({[S]:Z}),p);return J})})]}),E=t?.tools,Y=E?.map(S=>S.name)??[],ee=e.allowedTools??Y,de=E&&E.length>0,V=m.length>0||v.length>0;return(0,l.jsxs)("div",{style:{maxWidth:960},children:[(0,l.jsxs)("div",{className:g.pageHeader,children:[(0,l.jsx)("div",{className:g.pageIcon,children:(0,l.jsx)(hi,{type:e.type})}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("h2",{className:g.pageName,children:e.name}),(0,l.jsx)("p",{className:g.pageDesc,children:e.description})]}),(0,l.jsxs)(ce,{size:10,children:[c,(0,l.jsx)(ve,{color:e.enabled?"success":"default",style:{margin:0,fontSize:11},children:e.enabled?"Enabled":"Disabled"}),(0,l.jsx)(wt,{"aria-label":i,checked:e.enabled,onChange:S=>{if(o(),S){let F=t;F?.defaultConfig&&!e.config&&r(F.defaultConfig)}}})]})]}),V&&(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:g.blockTitle,children:d?.config??"Config"}),(0,l.jsx)("div",{style:{marginTop:12},children:_()})]}),O.length>0&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.resources??"Resources Permission"}),O.map(S=>{let F=x[S],J=e.config[S]??F.default??[];return b(S,F,J,Z=>r({[S]:Z}),e.type)})]}),de&&E&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.tools??"Tools Permission"}),(0,l.jsx)(Wa,{tools:E,selectedToolNames:ee,allToolNames:Y,onChange:a,styles:g})]})]})},Qa=e=>{let{token:t}=$e.useToken(),{styles:o}=sn();return(0,l.jsx)(Ga,{...e,token:t,styles:o,renderListSubSection:(a,i,d,c,p)=>{switch(i.widget){case"skillSelect":return(0,l.jsx)(Ua,{value:d,onChange:c,token:t,styles:o},a);case"databaseSelect":return(0,l.jsx)(Ka,{value:d,onChange:c,token:t,styles:o},a);case"metricsSelect":return(0,l.jsx)(Ha,{value:d,onChange:c,token:t,styles:o},a);case"collectionSelect":return(0,l.jsx)(qa,{value:d,onChange:c,token:t,styles:o},a);case"connectionSelect":return(0,l.jsxs)("div",{className:o.dataSection,children:[(0,l.jsx)("div",{className:o.dataSectionHeader,children:(0,l.jsx)(we,{strong:!0,style:{fontSize:13},children:i.title||"Connections"})}),(0,l.jsx)(fi,{connectionType:i.connectionType??(a==="connections"?p:""),value:d||[],onChange:c})]},a);case"topologyEdgeBuilder":return(0,l.jsx)(Va,{value:d,onChange:c,token:t,styles:o},a);default:return null}}})};var vi=n(s()),{Text:fu}=P,yu=w(({css:e,token:t})=>({toolRow:e`
1610
+ `})),go=({title:e,selectedCount:t,totalCount:o,searchPlaceholder:r,searchText:s,onSearchChange:i,onSelectAll:d,onClearAll:c,children:p,styles:g})=>{let v=o>0&&t===o;return(0,l.jsxs)("div",{className:g.dataSection,children:[(0,l.jsxs)("div",{className:g.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:[e,(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t," / ",o," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(F,{type:"link",size:"small",onClick:v?c:d,children:v?"Clear":"Select All"})})]}),(0,l.jsx)("div",{style:{marginBottom:10},children:(0,l.jsx)(H,{size:"small",allowClear:!0,prefix:(0,l.jsx)(ar,{style:{fontSize:12}}),placeholder:r,value:s,onChange:x=>i(x.target.value),style:{width:"100%"}})}),(0,l.jsx)("div",{className:g.dataList,children:p})]})},ts=({text:e,className:t})=>(0,l.jsx)(Fe,{title:e,placement:"topLeft",children:(0,l.jsx)("div",{className:t,children:e})}),os=({tools:e,selectedToolNames:t,allToolNames:o,onChange:r,styles:s})=>{let i=e.length>0&&t.length===o.length,d=c=>{if(t.includes(c)){let p=t.filter(g=>g!==c);r(p.length===0?void 0:p)}else{let p=[...t,c];r(p.length===o.length&&o.every(g=>p.includes(g))?void 0:p)}};return(0,l.jsxs)("div",{className:s.dataSection,children:[(0,l.jsxs)("div",{className:s.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Tools",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t.length," / ",o.length," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(F,{type:"link",size:"small",onClick:()=>r(i?[]:void 0),children:i?"Clear":"Select All"})})]}),(0,l.jsx)("div",{className:s.toolsGrid,children:e.map(c=>{let p=t.includes(c.name);return(0,l.jsx)(Dt,{item:c,dense:!0,className:p?s.selectedCard:void 0,onClick:()=>d(c.name),renderIcon:()=>(0,l.jsx)("span",{style:{fontSize:14,fontWeight:600},children:c.name.charAt(0).toUpperCase()}),renderPrimary:()=>c.name,renderDetails:()=>(0,l.jsx)(ts,{text:c.description,className:s.toolDesc}),renderHeaderActions:()=>(0,l.jsx)(Le,{checked:p,onClick:g=>g.stopPropagation(),onChange:()=>d(c.name)})},c.id)})})]})},ns=({value:e,onChange:t,token:o,styles:r})=>{let[s,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:v}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let b=await v("/api/skills");b.success&&b.data&&Array.isArray(b.data.records)&&i(b.data.records)}catch(b){console.error("Failed to fetch skills:",b)}finally{c(!1)}})()},[v]);let h=Array.isArray(e)?e:[],u=s.filter(m=>m.name.toLowerCase().includes(p.toLowerCase())||m.description.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Skill Library",selectedCount:h.length,totalCount:s.length,searchPlaceholder:"Search skills\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(s.map(m=>m.id)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No skills available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let b=h.includes(m.id);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:b?o.colorSuccessBg:"transparent",border:`1px solid ${b?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(b?h.filter(O=>O!==m.id):[...h,m.id]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:b}),title:(0,l.jsx)(we,{strong:b,style:{fontSize:13},children:m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description})})},m.id)}})})},rs=({value:e,onChange:t,token:o,styles:r})=>{let[s,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:v}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let b=await v("/api/database-configs");b.success&&b.data&&Array.isArray(b.data.records)&&i(b.data.records)}catch(b){console.error("Failed to fetch database configs:",b)}finally{c(!1)}})()},[v]);let h=Array.isArray(e)?e:[],u=s.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Databases",selectedCount:h.length,totalCount:s.length,searchPlaceholder:"Search databases\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(s.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No databases available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let b=h.includes(m.key);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:b?o.colorSuccessBg:"transparent",border:`1px solid ${b?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(b?h.filter(O=>O!==m.key):[...h,m.key]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:b}),title:(0,l.jsx)(we,{strong:b,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},is=({value:e,onChange:t,token:o,styles:r})=>{let[s,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:v}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let b=await v("/api/metrics-configs");b.success&&b.data&&Array.isArray(b.data.records)&&i(b.data.records)}catch(b){console.error("Failed to fetch metrics configs:",b)}finally{c(!1)}})()},[v]);let h=Array.isArray(e)?e:[],u=s.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Metrics Servers",selectedCount:h.length,totalCount:s.length,searchPlaceholder:"Search servers\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(s.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No servers available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let b=h.includes(m.key);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:b?o.colorSuccessBg:"transparent",border:`1px solid ${b?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(b?h.filter(O=>O!==m.key):[...h,m.key]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:b}),title:(0,l.jsx)(we,{strong:b,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},as=({value:e,onChange:t,token:o,styles:r})=>{let[s,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:v}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{x.current||(x.current=!0,c(!0),v("/api/collections").then(m=>{m.success&&i(m.data.records)}).catch(()=>{}).finally(()=>c(!1)))},[v]);let h=Array.isArray(e)?e:[],u=s.filter(m=>(m.label||m.name).toLowerCase().includes(p.toLowerCase())||m.name.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Collections",selectedCount:h.length,totalCount:s.length,searchPlaceholder:"Search collections\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(s.map(m=>m.name)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No collections available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let b=h.includes(m.name);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:b?o.colorSuccessBg:"transparent",border:`1px solid ${b?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(b?h.filter(O=>O!==m.name):[...h,m.name]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:b}),title:(0,l.jsx)(we,{strong:b,style:{fontSize:13},children:m.label||m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.name})})},m.name)}})})},ss=({value:e,onChange:t,token:o,styles:r})=>{let s=Array.isArray(e)?e:[],[i,d]=(0,ue.useState)({from:"",to:"",purpose:""}),c=()=>{!i.from.trim()||!i.to.trim()||!i.purpose.trim()||(t([...s,{...i}]),d({from:"",to:"",purpose:""}))};return(0,l.jsxs)("div",{className:r.dataSection,children:[(0,l.jsx)("div",{className:r.dataSectionHeader,children:(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Dependencies",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[s.length," edges"]})]})}),(0,l.jsx)("div",{className:r.dataList,children:s.length===0?(0,l.jsx)(xe,{description:"No dependencies defined yet",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):s.map((p,g)=>(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",marginBottom:4,borderRadius:o.borderRadius,backgroundColor:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`},children:[(0,l.jsx)(be,{color:"blue",style:{margin:0,fontSize:11},children:p.from}),(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},children:"\u2192"}),(0,l.jsx)(be,{color:"green",style:{margin:0,fontSize:11},children:p.to}),(0,l.jsx)(we,{style:{fontSize:12,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.purpose}),(0,l.jsx)(F,{type:"text",size:"small",danger:!0,icon:(0,l.jsx)(Zn,{}),onClick:()=>t(s.filter((v,x)=>x!==g))})]},g))}),(0,l.jsxs)("div",{style:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:12,marginTop:12},children:[(0,l.jsx)(we,{strong:!0,style:{fontSize:13,display:"block",marginBottom:8},children:"Add Dependency"}),(0,l.jsxs)(ce,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,l.jsx)(H,{size:"small",placeholder:"Source Agent ID",value:i.from,onChange:p=>d({...i,from:p.target.value})}),(0,l.jsx)(H,{size:"small",placeholder:"Target Agent ID",value:i.to,onChange:p=>d({...i,to:p.target.value})}),(0,l.jsx)(H,{size:"small",placeholder:"Purpose (e.g. classify invoice fields)",value:i.purpose,onChange:p=>d({...i,purpose:p.target.value}),onPressEnter:c}),(0,l.jsx)(F,{type:"dashed",size:"small",icon:(0,l.jsx)(rr,{}),onClick:c,disabled:!i.from.trim()||!i.to.trim()||!i.purpose.trim(),block:!0,children:"Add Edge"})]})]})]})},hi=(e,t,o,r,s)=>{let i=t.title||e,d=t.description?(0,l.jsx)(Fe,{title:t.description,children:(0,l.jsx)(ir,{style:{color:s.colorTextSecondary,cursor:"pointer"}})}):null;if(t.widget==="switch"||!t.widget&&t.type==="boolean")return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(Ct,{size:"small",checked:o,onChange:r})]},e),gridItem:null};if(t.widget==="segmented"){let g=t.enum?.map(v=>({value:v,label:{global:"Global",agent:"Agent",project:"Project"}[v]||v}))||[];return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(On,{size:"small",value:o,onChange:r,options:g})]},e),gridItem:null}}let c=(0,l.jsxs)("span",{children:[i,d&&(0,l.jsxs)(l.Fragment,{children:["\xA0",d]})]}),p;if(t.type==="number"||t.type==="integer")p=(0,l.jsx)(H,{size:"small",type:"number",value:o,onChange:g=>r(parseFloat(g.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}});else if(t.widget==="select"||t.enum&&!t.widget){let g=t.enumLabels,v=g?Object.entries(g).map(([x,h])=>({value:x,label:h})):t.enum?.map(x=>({value:x,label:x}))||[];p=(0,l.jsx)(Ee,{size:"small",value:o,onChange:r,options:v,style:{width:"100%"}})}else t.widget==="textarea"?p=(0,l.jsx)(H.TextArea,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}}):p=(0,l.jsx)(H,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default});return{row:null,gridItem:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,l.jsx)(we,{style:{fontSize:12,color:s.colorTextSecondary},children:c}),p]},e)}},bi=({type:e})=>{let{token:t}=_e.useToken();switch(e){case"browser":return(0,l.jsx)(or,{style:{color:t.colorPrimary}});case"sql":return(0,l.jsx)(Fo,{style:{color:t.colorWarning}});case"skill":return(0,l.jsx)(lr,{style:{color:t.colorSuccess}});case"filesystem":return(0,l.jsx)(tr,{style:{color:t.colorInfo}});case"code_eval":return(0,l.jsx)(Xn,{style:{color:t.colorError}});case"metrics":return(0,l.jsx)(Zt,{size:20,style:{color:t.colorWarning}});case"topology":return(0,l.jsx)(sr,{style:{color:t.colorPrimary}});case"document-parser":return(0,l.jsx)(er,{style:{color:t.colorSuccess}});case"collection":return(0,l.jsx)(Fo,{style:{color:t.colorInfo}});default:return(0,l.jsx)(nr,{style:{color:t.colorWarning}})}},ls=({middleware:e,middlewareType:t,onToggle:o,onConfigChange:r,onAllowedToolsChange:s,enabledAriaLabel:i,sectionTitles:d,headerActions:c,token:p,styles:g,renderListSubSection:v})=>{let x=t?.schema?.properties??{},h=Object.keys(x),u=h.filter(S=>{let B=x[S];return B.widget==="skillSelect"||B.widget==="databaseSelect"||B.widget==="metricsSelect"||B.widget==="collectionSelect"||B.widget==="connectionSelect"||B.widget==="topologyEdgeBuilder"}),m=h.filter(S=>{let B=x[S];return u.includes(S)?!1:B.widget==="switch"||B.widget==="segmented"}),b=h.filter(S=>!(u.includes(S)||m.includes(S)||S==="vmIsolation")),O=u.filter(S=>{let B=x[S];return S==="skills"&&e.config.readAll===!0||S==="serverKeys"&&e.config.connectAll===!0||S==="collectionKeys"&&e.config.connectAll===!0||S==="connections"&&e.config.connectAll===!0?!1:!!B.widget}),L=()=>(0,l.jsxs)(l.Fragment,{children:[m.map(S=>{let B=x[S],{row:J}=hi(S,B,e.config[S]??B.default,Z=>r({[S]:Z}),p);return(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:J},S)}),b.length>0&&(0,l.jsx)("div",{className:g.configGrid,children:b.map(S=>{let B=x[S],{gridItem:J}=hi(S,B,e.config[S]??B.default,Z=>r({[S]:Z}),p);return J})})]}),N=t?.tools,X=N?.map(S=>S.name)??[],ee=e.allowedTools??X,de=N&&N.length>0,Q=m.length>0||b.length>0;return(0,l.jsxs)("div",{style:{maxWidth:960},children:[(0,l.jsxs)("div",{className:g.pageHeader,children:[(0,l.jsx)("div",{className:g.pageIcon,children:(0,l.jsx)(bi,{type:e.type})}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("h2",{className:g.pageName,children:e.name}),(0,l.jsx)("p",{className:g.pageDesc,children:e.description})]}),(0,l.jsxs)(ce,{size:10,children:[c,(0,l.jsx)(be,{color:e.enabled?"success":"default",style:{margin:0,fontSize:11},children:e.enabled?"Enabled":"Disabled"}),(0,l.jsx)(Ct,{"aria-label":i,checked:e.enabled,onChange:S=>{if(o(),S){let B=t;B?.defaultConfig&&!e.config&&r(B.defaultConfig)}}})]})]}),Q&&(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:g.blockTitle,children:d?.config??"Config"}),(0,l.jsx)("div",{style:{marginTop:12},children:L()})]}),O.length>0&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.resources??"Resources Permission"}),O.map(S=>{let B=x[S],J=e.config[S]??B.default??[];return v(S,B,J,Z=>r({[S]:Z}),e.type)})]}),de&&N&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.tools??"Tools Permission"}),(0,l.jsx)(os,{tools:N,selectedToolNames:ee,allToolNames:X,onChange:s,styles:g})]})]})},cs=e=>{let{token:t}=_e.useToken(),{styles:o}=pn();return(0,l.jsx)(ls,{...e,token:t,styles:o,renderListSubSection:(s,i,d,c,p)=>{switch(i.widget){case"skillSelect":return(0,l.jsx)(ns,{value:d,onChange:c,token:t,styles:o},s);case"databaseSelect":return(0,l.jsx)(rs,{value:d,onChange:c,token:t,styles:o},s);case"metricsSelect":return(0,l.jsx)(is,{value:d,onChange:c,token:t,styles:o},s);case"collectionSelect":return(0,l.jsx)(as,{value:d,onChange:c,token:t,styles:o},s);case"connectionSelect":return(0,l.jsxs)("div",{className:o.dataSection,children:[(0,l.jsx)("div",{className:o.dataSectionHeader,children:(0,l.jsx)(we,{strong:!0,style:{fontSize:13},children:i.title||"Connections"})}),(0,l.jsx)(yi,{connectionType:i.connectionType??(s==="connections"?p:""),value:d||[],onChange:c})]},s);case"topologyEdgeBuilder":return(0,l.jsx)(ss,{value:d,onChange:c,token:t,styles:o},s);default:return null}}})};var vi=n(a()),{Text:rg}=P,ig=C(({css:e,token:t})=>({toolRow:e`
1444
1611
  width: 100%;
1445
1612
  background: ${t.colorFillQuaternary};
1446
1613
  border-color: ${t.colorBorderSecondary};
@@ -1451,7 +1618,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1451
1618
  `,toolName:e`
1452
1619
  font-weight: 600;
1453
1620
  font-size: 13px;
1454
- `}));var bi=n(s()),{Text:xu}=P,wu=w(({css:e,token:t})=>({diagram:e`
1621
+ `}));var xi=n(a()),{Text:cg}=P,dg=C(({css:e,token:t})=>({diagram:e`
1455
1622
  display: flex;
1456
1623
  flex-direction: column;
1457
1624
  gap: 0;
@@ -1486,7 +1653,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1486
1653
  font-size: 12px;
1487
1654
  line-height: 1.5;
1488
1655
  color: ${t.colorTextSecondary};
1489
- `}));var xi=n(s()),{Text:zu,Title:ju}=P,Lu=w(({css:e,token:t})=>({layout:e`
1656
+ `}));var wi=n(a()),{Text:Rg,Title:Tg}=P,Pg=C(({css:e,token:t})=>({layout:e`
1490
1657
  display: flex;
1491
1658
  height: 100%;
1492
1659
  gap: 20px;
@@ -1519,7 +1686,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1519
1686
  font-size: 13px;
1520
1687
  font-weight: 600;
1521
1688
  padding: 2px 8px;
1522
- `}));var ln=n(s());var Za=n(s());var wi=n(C());var cn=n(s()),{Text:ag}=P,{TextArea:sg}=H,{useToken:lg}=$e;var Ci=n(C());var pn=n(s()),{Text:fg}=P,{TextArea:yg}=H,hg=w(({token:e,css:t})=>({container:t`
1689
+ `}));var mn=n(a());var Ci=n(a());var Si=n(w());var un=n(a()),{Text:Yg}=P,{TextArea:Xg}=H,{useToken:Jg}=_e;var ki=n(w());var fn=n(a()),{Text:af}=P,{TextArea:sf}=H,lf=C(({token:e,css:t})=>({container:t`
1523
1690
  height: 100%;
1524
1691
  display: flex;
1525
1692
  flex-direction: column;
@@ -1568,14 +1735,14 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1568
1735
  font-size: 13px;
1569
1736
  color: ${e.colorTextSecondary};
1570
1737
  margin-top: 8px;
1571
- `}));var fo=n(C());var Si=n(C());var mn=n(s()),{Text:kg}=P,Rg=w(({css:e})=>({formField:e`
1738
+ `}));var yo=n(w());var Ri=n(w());var yn=n(a()),{Text:ff}=P,yf=C(({css:e})=>({formField:e`
1572
1739
  margin-bottom: 16px;
1573
1740
  `,fieldLabel:e`
1574
1741
  display: block;
1575
1742
  margin-bottom: 6px;
1576
1743
  font-weight: 500;
1577
1744
  font-size: 13px;
1578
- `}));var ts=n(s()),{Text:Dg}=P;var Ri=n(C());var os=n(C());var ki=n(s());var un=n(s()),{Text:Hg}=P,{TextArea:qg}=H,{useToken:Vg}=$e,{Panel:Gg}=At;var bt=n(C());var gn=n(s()),of=(0,bt.lazy)(()=>import("./embed-page-SkillFlow-SFZ5HLMK.js")),{Text:nf}=P,{TextArea:rf}=H;var Ti=n(C());var yn=n(C());var hn=n(s()),{Text:uf,Paragraph:gf}=P,ff=w(({token:e,css:t})=>({root:t`
1745
+ `}));var gs=n(a()),{Text:Rf}=P;var Pi=n(w());var fs=n(w());var Ti=n(a());var hn=n(a()),{Text:Ff}=P,{TextArea:$f}=H,{useToken:jf}=_e,{Panel:Lf}=Et;var xt=n(w());var bn=n(a()),Vf=(0,xt.lazy)(()=>import("./embed-page-SkillFlow-3CF7R3CW.js")),{Text:Gf}=P,{TextArea:Qf}=H;var Ii=n(w());var xn=n(w());var wn=n(a()),{Text:ny,Paragraph:ry}=P,iy=C(({token:e,css:t})=>({root:t`
1579
1746
  height: 100%;
1580
1747
  display: flex;
1581
1748
  flex-direction: column;
@@ -1649,7 +1816,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1649
1816
  background: ${e.colorPrimaryBg} !important;
1650
1817
  transition: background 0.25s;
1651
1818
  }
1652
- `}));var bn=n(s()),{Text:kf}=P,Rf=w(({token:e,css:t})=>({container:t`
1819
+ `}));var Sn=n(a()),{Text:gy}=P,fy=C(({token:e,css:t})=>({container:t`
1653
1820
  padding: ${e.paddingLG}px;
1654
1821
  height: 100%;
1655
1822
  overflow-y: auto;
@@ -1663,7 +1830,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1663
1830
  gap: ${e.marginSM}px;
1664
1831
  margin-bottom: ${e.marginSM}px;
1665
1832
  align-items: center;
1666
- `}));var xn=n(C());var Pi=n(s());var Ii=n(C());var Ai=n(s()),{Text:Ff,Title:zf}=P;var ho=n(C());var yo=n(C());var Ei=n(C());var Ni=n(s()),{Text:Hf}=P;var Mi=n(s()),{Text:ey}=P;var wn=n(C());var Cn=n(s()),{Text:dy,Paragraph:py}=P;var Sn=n(s()),{Text:Cy}=P;var kn=n(C());var Bi=n(s()),{Text:Py}=P;var Rn=n(C());var vo=n(C());var Di=n(C());var Fi=n(s()),{Text:Ly}=P;var Tn=n(s()),{Text:Gy}=P;var xo=n(C());var bo=n(C());var Tt=n(s()),rs=(0,bo.lazy)(()=>import("./embed-page-TasksSideApp-4GY5YBTN.js").then(e=>({default:e.TasksSideApp}))),Pn=()=>{let{openSideApp:e,sideAppVisible:t,sideAppSelectedCard:o}=Se(),r=t&&o?.component_key==="tasks_side_app_pin";return(0,Tt.jsx)(kt,{ariaLabel:"Open tasks",icon:(0,Tt.jsx)(Jt,{size:16}),onClick:()=>{r||e({component_key:"tasks_side_app_pin",message:"Tasks",data:{component:(0,Tt.jsx)(bo.Suspense,{fallback:(0,Tt.jsx)(ne,{style:{display:"block",margin:"auto"}}),children:(0,Tt.jsx)(rs,{showProjectFilter:!1})})}})}})};var $t=n(C());var In=n(s()),{Text:lh}=P;var ch=w(({css:e,token:t})=>({body:e`
1833
+ `}));var kn=n(w());var Ai=n(a());var Ei=n(w());var Ni=n(a()),{Text:Ry,Title:Ty}=P;var bo=n(w());var ho=n(w());var Mi=n(w());var Bi=n(a()),{Text:zy}=P;var Di=n(a()),{Text:Ky}=P;var Rn=n(w());var Tn=n(a()),{Text:eh,Paragraph:th}=P;var Pn=n(a()),{Text:mh}=P;var In=n(w());var zi=n(a()),{Text:hh}=P;var An=n(w());var vo=n(w());var Fi=n(w());var $i=n(a()),{Text:Ih}=P;var En=n(a()),{Text:jh}=P;var wo=n(w());var xo=n(w());var Pt=n(a()),hs=(0,xo.lazy)(()=>import("./embed-page-TasksSideApp-3WRDBZU3.js").then(e=>({default:e.TasksSideApp}))),Nn=()=>{let{openSideApp:e,sideAppVisible:t,sideAppSelectedCard:o}=Se(),r=t&&o?.component_key==="tasks_side_app_pin";return(0,Pt.jsx)(Rt,{ariaLabel:"Open tasks",icon:(0,Pt.jsx)(to,{size:16}),onClick:()=>{r||e({component_key:"tasks_side_app_pin",message:"Tasks",data:{component:(0,Pt.jsx)(xo.Suspense,{fallback:(0,Pt.jsx)(ne,{style:{display:"block",margin:"auto"}}),children:(0,Pt.jsx)(hs,{showProjectFilter:!1})})}})}})};var Ut=n(w());var Mn=n(a()),{Text:Jh}=P;var Zh=C(({css:e,token:t})=>({body:e`
1667
1834
  display: flex;
1668
1835
  height: 460px;
1669
1836
  `,leftPanel:e`
@@ -1822,7 +1989,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1822
1989
  padding: 12px 24px;
1823
1990
  border-top: 1px solid ${t.colorBorderSecondary};
1824
1991
  flex-shrink: 0;
1825
- `}));var An=n(s()),{Title:Th,Text:Ph,Paragraph:Ih}=P,Ah=w(({css:e,token:t})=>({container:e` display: flex; flex-direction: column; height: 100%; padding: 24px; overflow-y: auto; `,setupWrap:e` max-width: 520px; margin: 30px auto 0; `,card:e` border-radius: ${t.borderRadiusLG}px; `,statusCard:e` max-width: 560px; margin: 40px auto 0; border-radius: ${t.borderRadiusLG}px; `,loadingWrap:e` display: flex; align-items: center; justify-content: center; height: 100%; `,avatar:e`
1992
+ `}));var Bn=n(a()),{Title:yb,Text:hb,Paragraph:bb}=P,vb=C(({css:e,token:t})=>({container:e` display: flex; flex-direction: column; height: 100%; padding: 24px; overflow-y: auto; `,setupWrap:e` max-width: 520px; margin: 30px auto 0; `,card:e` border-radius: ${t.borderRadiusLG}px; `,statusCard:e` max-width: 560px; margin: 40px auto 0; border-radius: ${t.borderRadiusLG}px; `,loadingWrap:e` display: flex; align-items: center; justify-content: center; height: 100%; `,avatar:e`
1826
1993
  width: 56px; height: 56px; border-radius: ${t.borderRadiusLG}px;
1827
1994
  background: linear-gradient(135deg, ${t.colorPrimary}, ${t.colorPrimaryActive});
1828
1995
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 12px;
@@ -1837,7 +2004,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1837
2004
  `,chatRoot:e` display: flex; flex-direction: column; height: 100%; min-height: 0; `,chatBar:e`
1838
2005
  display: flex; align-items: center; justify-content: space-between;
1839
2006
  padding: 8px 16px; border-bottom: 1px solid ${t.colorBorderSecondary}; flex-shrink: 0;
1840
- `,chatFill:e` flex: 1; min-height: 0; `}));var $i=n(C());var Nn=n(C());var be=n(C());function Li(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>(r.label||"").toLowerCase().includes(o)):e}var ji=(e,t)=>{let o=t==="created"?e.createdAt:e.updatedAt;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function _i(e,t="updated",o="desc"){return[...e].sort((r,a)=>{if(t==="name"){let c=r.label||"",p=a.label||"";return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=ji(r,t),d=ji(a,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}var G=n(s()),is=w(({token:e,css:t})=>({container:t`
2007
+ `,chatFill:e` flex: 1; min-height: 0; `}));var Ki=n(w());var Wi=n(w());var ve=n(w());function _i(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>(r.label||"").toLowerCase().includes(o)):e}var Li=(e,t)=>{let o=t==="created"?e.createdAt:e.updatedAt;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function Oi(e,t="updated",o="desc"){return[...e].sort((r,s)=>{if(t==="name"){let c=r.label||"",p=s.label||"";return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=Li(r,t),d=Li(s,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}var V=n(a()),bs=C(({token:e,css:t})=>({container:t`
1841
2008
  padding: 4px;
1842
2009
  font-size: 13px;
1843
2010
  background: transparent;
@@ -1964,7 +2131,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1964
2131
  text-align: center;
1965
2132
  color: ${e.colorTextSecondary};
1966
2133
  font-size: 12px;
1967
- `})),En=()=>{let{styles:e}=is(),{threads:t,threadId:o,selectThread:r,deleteThread:a,updateThread:i,isLoading:d}=tt(),[c,p]=(0,be.useState)(null),[g,b]=(0,be.useState)(!1),[x,h]=(0,be.useState)(null),[u,m]=(0,be.useState)(""),[v,O]=(0,be.useState)(!1),[_,E]=(0,be.useState)(""),[Y,ee]=(0,be.useState)("updated"),[de,V]=(0,be.useState)("desc"),S=(0,be.useRef)(!1),F=(0,be.useRef)(!1),J=(0,be.useCallback)((R,I)=>{R.stopPropagation(),p(I)},[]),Z=(0,be.useCallback)(async()=>{if(c){b(!0);try{await a(c),q.success("Conversation deleted"),p(null)}catch{q.error("Failed to delete conversation")}finally{b(!1)}}},[c,a]),A=(0,be.useCallback)((R,I)=>{R.stopPropagation(),h(I.id),m(I.label)},[]),ae=(0,be.useCallback)(async R=>{if(F.current)return;let I=u.trim();if(!I||I===R.label){h(null);return}F.current=!0,O(!0);try{await i({...R,label:I}),q.success("Conversation renamed")}catch{q.error("Failed to rename conversation")}finally{F.current=!1,O(!1),h(null)}},[u,i]),B=(0,be.useCallback)(()=>{S.current=!0,h(null)},[]),j=(0,be.useCallback)(R=>{R.key==="Enter"?(R.preventDefault(),R.currentTarget.blur()):R.key==="Escape"&&(R.preventDefault(),B())},[B]),se=(0,be.useCallback)(R=>{if(S.current){S.current=!1;return}ae(R)},[ae]),$=be.default.useMemo(()=>_i(Li(t,_),Y,de),[t,_,Y,de]);return(0,G.jsxs)("div",{className:e.container,children:[(0,G.jsxs)("div",{className:e.toolbar,children:[(0,G.jsx)(H,{size:"small",placeholder:"Search conversations\u2026",allowClear:!0,value:_,onChange:R=>E(R.target.value)}),(0,G.jsxs)("div",{className:e.toolbarRow,children:[(0,G.jsx)(Ee,{size:"small",style:{flex:1,minWidth:0},value:Y,onChange:R=>ee(R),options:[{value:"name",label:"Name"},{value:"updated",label:"Updated"},{value:"created",label:"Created"}]}),(0,G.jsx)(z,{size:"small",icon:de==="asc"?(0,G.jsx)(Gt,{}):(0,G.jsx)(Qt,{}),onClick:()=>V(R=>R==="asc"?"desc":"asc"),title:de==="asc"?"Ascending":"Descending"})]})]}),d?(0,G.jsx)("div",{className:e.loading,children:"Loading conversations..."}):$.length===0?(0,G.jsx)("div",{className:e.emptyState,children:_.trim()?`No conversations match "${_.trim()}"`:"No conversations yet"}):(0,G.jsx)("div",{className:e.threadList,children:$.map(R=>(0,G.jsxs)("div",{className:`${e.threadItem} ${R.id===o?"active":""}`,onClick:()=>r(R.id),title:R.label,children:[(0,G.jsx)("div",{className:e.threadIcon,children:(0,G.jsx)(br,{size:14})}),x===R.id?(0,G.jsx)("input",{className:e.renameInput,"aria-label":"Conversation name",value:u,autoFocus:!0,disabled:v,onClick:I=>I.stopPropagation(),onFocus:I=>I.target.select(),onChange:I=>m(I.target.value),onKeyDown:I=>j(I),onBlur:()=>se(R)}):(0,G.jsx)("div",{className:R.id===o?e.threadNameActive:e.threadName,children:R.label}),x===R.id?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Save name",disabled:v,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),ae(R)},children:(0,G.jsx)(dr,{size:12})}),(0,G.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Cancel rename",disabled:v,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),B()},children:(0,G.jsx)(Mt,{size:12})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("button",{className:e.actionBtn,onClick:I=>A(I,R),title:"Rename conversation",children:(0,G.jsx)(wr,{size:12})}),(0,G.jsx)("button",{className:e.actionBtn,onClick:I=>J(I,R.id),title:"Delete conversation",children:(0,G.jsx)(Rr,{size:12})})]})]},R.id))}),(0,G.jsx)(pe,{title:"Delete Conversation",open:c!==null,onCancel:()=>p(null),onOk:Z,okText:"Delete",okButtonProps:{danger:!0,loading:g},cancelText:"Cancel",children:(0,G.jsx)("p",{children:"Are you sure you want to delete this conversation? This action cannot be undone."})})]})};var Mn=n(s());var Oi=n(s());var Wi=n(C());var Ui=n(s()),{Text:vv}=P;var fs=n(C());var Bn=n(C());var Ki=n(s()),{Text:kv}=P;var gs=n(C());var us=n(C());var Dn=n(s());var Fn=n(s()),{Dragger:Bv}=On,{Text:Dv,Title:Fv}=P;var Hi=n(s()),{Title:Uv,Text:Kv}=P;var ye=n(s()),qi=[{id:"personal_assistant",type:"route",name:"Personal Assistant",icon:(0,ye.jsx)(Et,{size:20}),order:-10},{id:"workspace_projects",type:"route",name:"Projects",icon:(0,ye.jsx)(at,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:(0,ye.jsx)(Yt,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:(0,ye.jsx)(mr,{size:20}),order:20,group:"DataSource"},{id:"connections",builtin:"connections",type:"route",name:"Plugins",icon:(0,ye.jsx)(Lo,{size:20}),order:21},{id:"topology-runtimes",type:"route",name:"Runtime",icon:(0,ye.jsx)(St,{size:20}),order:26,group:"Process"},{id:"topology-inbox",type:"route",name:"Inbox",icon:(0,ye.jsx)(yr,{size:20}),order:27,group:"Process"},{id:"workflows",type:"route",name:"Automations",icon:(0,ye.jsx)(_o,{size:20}),order:25,group:"Process"},{id:"shares",type:"route",name:"Shares",icon:(0,ye.jsx)(_o,{size:20}),order:55,group:"Settings"},{id:"workspace_migration",type:"route",name:"Migration",icon:(0,ye.jsx)(lr,{size:20}),order:56,group:"Settings"},{id:"eval",type:"route",name:"Eval",icon:(0,ye.jsx)(gr,{size:20}),order:28,group:"Process"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:(0,ye.jsx)(Et,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:(0,ye.jsx)(Ir,{size:20}),order:35,group:"Settings"},{id:"collections",type:"route",name:"Collections",icon:(0,ye.jsx)(vr,{size:20}),order:29,group:"Knowledge"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:(0,ye.jsx)(Lo,{size:20}),order:40,group:"Settings"},{id:"a2a-keys",type:"route",name:"API Keys",icon:(0,ye.jsx)(hr,{size:20}),order:45,group:"Settings"},{id:"open-audit",type:"route",name:"Audit Log",icon:(0,ye.jsx)(St,{size:20}),order:47,group:"Settings"},{id:"capability-bundles",type:"route",name:"Runtime Profiles",icon:(0,ye.jsx)(kr,{size:20}),order:46,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:(0,ye.jsx)(Pr,{size:20}),order:50,group:"Settings"},{id:"tasks",type:"route",name:"Tasks",icon:(0,ye.jsx)(Jt,{size:20}),order:100}];var lx=(0,Ue.lazy)(()=>import("./embed-page-AgentGovernanceWorkbench-F42AJH77.js").then(e=>({default:e.AgentGovernanceWorkbench}))),cx=(0,Ue.lazy)(()=>import("./embed-page-TopologyRuntimeView-MKFPCHT3.js").then(e=>({default:e.TopologyRuntimeView}))),dx=(0,Ue.lazy)(()=>import("./embed-page-WorkflowAutomationView-WT6VH5HD.js").then(e=>({default:e.WorkflowAutomationView}))),px=(0,Ue.lazy)(()=>import("./embed-page-TasksSideApp-4GY5YBTN.js").then(e=>({default:e.TasksSideApp}))),mx=(0,Ue.lazy)(()=>import("./embed-page-AgentDetailSideApp-KGYKTMZR.js").then(e=>({default:e.AgentDetailSideApp})));var Ne=n(s());function ys(e){let{contentType:t,assistantId:o,contentConfig:r,workspaceId:a,projectId:i}=e;return t==="agent"?{agentId:o,workspaceId:a||void 0,projectId:i||void 0}:{...r,workspaceId:a||void 0,projectId:i||void 0}}async function hs(e,t,o){let{contentType:r,assistantId:a,contentConfig:i,isMatch:d}=t;if(!(r==="agent"?!!a:!!i)||!o)return{isPinned:!1,pinnedId:null};let p=await e("/api/menu-items?menuTarget=workspace");if(p.success&&p.data?.records){let g=d??(x=>r==="agent"&&x.agentId===a),b=p.data.records.find(x=>x.contentType===r&&g(x.contentConfig));if(b)return{isPinned:!0,pinnedId:b.id}}return{isPinned:!1,pinnedId:null}}async function vs(e,t){let{contentType:o,name:r,group:a}=t,i=ys(t),d={menuTarget:"workspace",contentType:o,contentConfig:i,group:a?.trim()||void 0,name:r.trim(),sortOrder:0},c=await e("/api/menu-items",d);if(!c.success)throw new Error(c.message||"Failed to pin");return{id:c.data.id}}async function bs(e,t){let o=await e(`/api/menu-items/${t}`);if(!o.success)throw new Error(o.message||"Failed to unpin")}function co(){let e=he.default.useContext(Ar),{config:t}=Ce(),{post:o,get:r,del:a}=me(),i=t.enableCustomMenu??!1,d=(0,he.useCallback)(async g=>hs(r,g,i),[r,i]),c=(0,he.useCallback)(async g=>vs(o,{...g,workspaceId:e?.workspaceId,projectId:e?.projectId}),[o,e]),p=(0,he.useCallback)(async g=>bs(a,g),[a]);return{check:d,pin:c,unpin:p,enableCustomMenu:i,get:r}}function Vi(e){let t=new Set;for(let o of e)o.group?.trim()&&t.add(o.group.trim());return Array.from(t).sort()}function tn(){let{config:e}=Ce(),t=he.default.useMemo(()=>Vi(qi),[]),o=he.default.useMemo(()=>Vi(e.workspaceMenuItems??[]),[e.workspaceMenuItems]);return he.default.useMemo(()=>Array.from(new Set([...t,...o])).sort(),[t,o])}async function on(e){let t=await e("/api/menu-items?menuTarget=workspace");if(t.success&&t.data?.records){let o=new Set;for(let r of t.data.records)r.group?.trim()&&o.add(r.group.trim());return Array.from(o).sort()}return[]}var xs={display:"flex",flexDirection:"column",gap:12},vn=({assistantId:e,contentType:t="agent",contentConfig:o,isMatch:r,size:a="small",label:i,block:d})=>{let{check:c,pin:p,unpin:g,enableCustomMenu:b,get:x}=co(),[h,u]=(0,he.useState)(!1),[m,v]=(0,he.useState)(""),[O,_]=(0,he.useState)(""),[E,Y]=(0,he.useState)(!1),[ee,de]=(0,he.useState)(!1),[V,S]=(0,he.useState)(null),[F,J]=(0,he.useState)(!0),Z=tn(),[A,ae]=(0,he.useState)(Z);(0,he.useEffect)(()=>{ae(Z)},[Z]),(0,he.useEffect)(()=>{h&&on(x).then(I=>{ae(Array.from(new Set([...Z,...I])).sort())})},[h]);let B=t==="agent"?!!e:!!o,j=(0,he.useCallback)(async()=>{if(!B||!b){J(!1);return}J(!0);try{let I=await c({contentType:t,assistantId:e,contentConfig:o,isMatch:r});de(I.isPinned),S(I.pinnedId)}catch{}finally{J(!1)}},[B,b,c,t,e,o,r]);if((0,he.useEffect)(()=>{j()},[j]),!B||!b)return null;let se=async()=>{if(!O.trim()){q.warning("Please enter a menu name");return}Y(!0);try{await p({contentType:t,assistantId:e,contentConfig:o,isMatch:r,name:O.trim(),group:m.trim()||void 0}),q.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),u(!1),v(""),_(""),j()}catch(I){q.error(I.message||"Failed to pin to menu")}finally{Y(!1)}},$=async()=>{if(V){Y(!0);try{await g(V),q.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),de(!1),S(null)}catch(I){q.error(I.message||"Failed to unpin from menu")}finally{Y(!1)}}},R=()=>{ee?$():u(!0)};return(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(ze,{title:ee?"Unpin from Menu":"Pin to Menu",children:i?(0,Ne.jsx)(z,{type:"text",size:a,block:d,icon:ee?(0,Ne.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Ne.jsx)(Ve,{size:14}),onClick:R,loading:F||E&&ee,children:i}):(0,Ne.jsx)(z,{type:"text",size:a,block:d,icon:ee?(0,Ne.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Ne.jsx)(Ve,{size:14}),onClick:R,loading:F||E&&ee})}),(0,Ne.jsx)(pe,{title:"Pin to Menu",open:h,onOk:se,onCancel:()=>u(!1),confirmLoading:E,okText:"Pin",children:(0,Ne.jsxs)("div",{style:xs,children:[(0,Ne.jsx)(H,{placeholder:"Menu name (required)",value:O,onChange:I=>_(I.target.value)}),(0,Ne.jsx)(Kt,{placeholder:"Group (optional, select or type new)",value:m,options:A.map(I=>({value:I})),onChange:I=>v(I),filterOption:(I,T)=>T?.value?.toUpperCase().includes(I.toUpperCase())??!1})]})})]})};var ie=n(C());var Q=n(s()),zn=50,ws=w(({token:e,css:t})=>({container:t`
2134
+ `})),Dn=()=>{let{styles:e}=bs(),{threads:t,threadId:o,selectThread:r,deleteThread:s,updateThread:i,isLoading:d}=tt(),[c,p]=(0,ve.useState)(null),[g,v]=(0,ve.useState)(!1),[x,h]=(0,ve.useState)(null),[u,m]=(0,ve.useState)(""),[b,O]=(0,ve.useState)(!1),[L,N]=(0,ve.useState)(""),[X,ee]=(0,ve.useState)("updated"),[de,Q]=(0,ve.useState)("desc"),S=(0,ve.useRef)(!1),B=(0,ve.useRef)(!1),J=(0,ve.useCallback)((R,I)=>{R.stopPropagation(),p(I)},[]),Z=(0,ve.useCallback)(async()=>{if(c){v(!0);try{await s(c),q.success("Conversation deleted"),p(null)}catch{q.error("Failed to delete conversation")}finally{v(!1)}}},[c,s]),A=(0,ve.useCallback)((R,I)=>{R.stopPropagation(),h(I.id),m(I.label)},[]),ae=(0,ve.useCallback)(async R=>{if(B.current)return;let I=u.trim();if(!I||I===R.label){h(null);return}B.current=!0,O(!0);try{await i({...R,label:I}),q.success("Conversation renamed")}catch{q.error("Failed to rename conversation")}finally{B.current=!1,O(!1),h(null)}},[u,i]),D=(0,ve.useCallback)(()=>{S.current=!0,h(null)},[]),$=(0,ve.useCallback)(R=>{R.key==="Enter"?(R.preventDefault(),R.currentTarget.blur()):R.key==="Escape"&&(R.preventDefault(),D())},[D]),se=(0,ve.useCallback)(R=>{if(S.current){S.current=!1;return}ae(R)},[ae]),_=ve.default.useMemo(()=>Oi(_i(t,L),X,de),[t,L,X,de]);return(0,V.jsxs)("div",{className:e.container,children:[(0,V.jsxs)("div",{className:e.toolbar,children:[(0,V.jsx)(H,{size:"small",placeholder:"Search conversations\u2026",allowClear:!0,value:L,onChange:R=>N(R.target.value)}),(0,V.jsxs)("div",{className:e.toolbarRow,children:[(0,V.jsx)(Ee,{size:"small",style:{flex:1,minWidth:0},value:X,onChange:R=>ee(R),options:[{value:"name",label:"Name"},{value:"updated",label:"Updated"},{value:"created",label:"Created"}]}),(0,V.jsx)(F,{size:"small",icon:de==="asc"?(0,V.jsx)(Xt,{}):(0,V.jsx)(Jt,{}),onClick:()=>Q(R=>R==="asc"?"desc":"asc"),title:de==="asc"?"Ascending":"Descending"})]})]}),d?(0,V.jsx)("div",{className:e.loading,children:"Loading conversations..."}):_.length===0?(0,V.jsx)("div",{className:e.emptyState,children:L.trim()?`No conversations match "${L.trim()}"`:"No conversations yet"}):(0,V.jsx)("div",{className:e.threadList,children:_.map(R=>(0,V.jsxs)("div",{className:`${e.threadItem} ${R.id===o?"active":""}`,onClick:()=>r(R.id),title:R.label,children:[(0,V.jsx)("div",{className:e.threadIcon,children:(0,V.jsx)(xr,{size:14})}),x===R.id?(0,V.jsx)("input",{className:e.renameInput,"aria-label":"Conversation name",value:u,autoFocus:!0,disabled:b,onClick:I=>I.stopPropagation(),onFocus:I=>I.target.select(),onChange:I=>m(I.target.value),onKeyDown:I=>$(I),onBlur:()=>se(R)}):(0,V.jsx)("div",{className:R.id===o?e.threadNameActive:e.threadName,children:R.label}),x===R.id?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Save name",disabled:b,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),ae(R)},children:(0,V.jsx)(pr,{size:12})}),(0,V.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Cancel rename",disabled:b,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),D()},children:(0,V.jsx)(Bt,{size:12})})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("button",{className:e.actionBtn,onClick:I=>A(I,R),title:"Rename conversation",children:(0,V.jsx)(Cr,{size:12})}),(0,V.jsx)("button",{className:e.actionBtn,onClick:I=>J(I,R.id),title:"Delete conversation",children:(0,V.jsx)(Tr,{size:12})})]})]},R.id))}),(0,V.jsx)(pe,{title:"Delete Conversation",open:c!==null,onCancel:()=>p(null),onOk:Z,okText:"Delete",okButtonProps:{danger:!0,loading:g},cancelText:"Cancel",children:(0,V.jsx)("p",{children:"Are you sure you want to delete this conversation? This action cannot be undone."})})]})};var Ui=n(a());var Hi=n(a());var qi=n(w());var Vi=n(a()),{Text:nv}=P;var ks=n(w());var zn=n(w());var Gi=n(a()),{Text:cv}=P;var Ss=n(w());var Cs=n(w());var Fn=n(a());var $n=n(a()),{Dragger:bv}=Un,{Text:vv,Title:xv}=P;var Qi=n(a()),{Title:Iv,Text:Av}=P;var ye=n(a()),Yi=[{id:"personal_assistant",type:"route",name:"Personal Assistant",icon:(0,ye.jsx)(Nt,{size:20}),order:-10},{id:"workspace_projects",type:"route",name:"Projects",icon:(0,ye.jsx)(at,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:(0,ye.jsx)(Zt,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:(0,ye.jsx)(ur,{size:20}),order:20,group:"DataSource"},{id:"connections",builtin:"connections",type:"route",name:"Plugins",icon:(0,ye.jsx)(_o,{size:20}),order:21},{id:"topology-runtimes",type:"route",name:"Runtime",icon:(0,ye.jsx)(kt,{size:20}),order:26,group:"Process"},{id:"topology-inbox",type:"route",name:"Inbox",icon:(0,ye.jsx)(hr,{size:20}),order:27,group:"Process"},{id:"workflows",type:"route",name:"Automations",icon:(0,ye.jsx)(Oo,{size:20}),order:25,group:"Process"},{id:"shares",type:"route",name:"Shares",icon:(0,ye.jsx)(Oo,{size:20}),order:55,group:"Settings"},{id:"workspace_migration",type:"route",name:"Migration",icon:(0,ye.jsx)(cr,{size:20}),order:56,group:"Settings"},{id:"eval",type:"route",name:"Eval",icon:(0,ye.jsx)(fr,{size:20}),order:28,group:"Process"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:(0,ye.jsx)(Nt,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:(0,ye.jsx)(Ar,{size:20}),order:35,group:"Settings"},{id:"collections",type:"route",name:"Collections",icon:(0,ye.jsx)(vr,{size:20}),order:29,group:"Knowledge"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:(0,ye.jsx)(_o,{size:20}),order:40,group:"Settings"},{id:"a2a-keys",type:"route",name:"API Keys",icon:(0,ye.jsx)(br,{size:20}),order:45,group:"Settings"},{id:"open-audit",type:"route",name:"Audit Log",icon:(0,ye.jsx)(kt,{size:20}),order:47,group:"Settings"},{id:"capability-bundles",type:"route",name:"Runtime Profiles",icon:(0,ye.jsx)(Rr,{size:20}),order:46,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:(0,ye.jsx)(Ir,{size:20}),order:50,group:"Settings"},{id:"tasks",type:"route",name:"Tasks",icon:(0,ye.jsx)(to,{size:20}),order:100}];var Vx=(0,Ue.lazy)(()=>import("./embed-page-AgentGovernanceWorkbench-K3JUQNBW.js").then(e=>({default:e.AgentGovernanceWorkbench}))),Gx=(0,Ue.lazy)(()=>import("./embed-page-TopologyRuntimeView-YDFENLHH.js").then(e=>({default:e.TopologyRuntimeView}))),Qx=(0,Ue.lazy)(()=>import("./embed-page-WorkflowAutomationView-MP5B7Q2Q.js").then(e=>({default:e.WorkflowAutomationView}))),Yx=(0,Ue.lazy)(()=>import("./embed-page-TasksSideApp-3WRDBZU3.js").then(e=>({default:e.TasksSideApp}))),Xx=(0,Ue.lazy)(()=>import("./embed-page-AgentDetailSideApp-3LBCEKFU.js").then(e=>({default:e.AgentDetailSideApp})));var Ne=n(a());function Rs(e){let{contentType:t,assistantId:o,contentConfig:r,workspaceId:s,projectId:i}=e;return t==="agent"?{agentId:o,workspaceId:s||void 0,projectId:i||void 0}:{...r,workspaceId:s||void 0,projectId:i||void 0}}async function Ts(e,t,o){let{contentType:r,assistantId:s,contentConfig:i,isMatch:d}=t;if(!(r==="agent"?!!s:!!i)||!o)return{isPinned:!1,pinnedId:null};let p=await e("/api/menu-items?menuTarget=workspace");if(p.success&&p.data?.records){let g=d??(x=>r==="agent"&&x.agentId===s),v=p.data.records.find(x=>x.contentType===r&&g(x.contentConfig));if(v)return{isPinned:!0,pinnedId:v.id}}return{isPinned:!1,pinnedId:null}}async function Ps(e,t){let{contentType:o,name:r,group:s}=t,i=Rs(t),d={menuTarget:"workspace",contentType:o,contentConfig:i,group:s?.trim()||void 0,name:r.trim(),sortOrder:0},c=await e("/api/menu-items",d);if(!c.success)throw new Error(c.message||"Failed to pin");return{id:c.data.id}}async function Is(e,t){let o=await e(`/api/menu-items/${t}`);if(!o.success)throw new Error(o.message||"Failed to unpin")}function po(){let e=he.default.useContext(Er),{config:t}=Ce(),{post:o,get:r,del:s}=me(),i=t.enableCustomMenu??!1,d=(0,he.useCallback)(async g=>Ts(r,g,i),[r,i]),c=(0,he.useCallback)(async g=>Ps(o,{...g,workspaceId:e?.workspaceId,projectId:e?.projectId}),[o,e]),p=(0,he.useCallback)(async g=>Is(s,g),[s]);return{check:d,pin:c,unpin:p,enableCustomMenu:i,get:r}}function Xi(e){let t=new Set;for(let o of e)o.group?.trim()&&t.add(o.group.trim());return Array.from(t).sort()}function rn(){let{config:e}=Ce(),t=he.default.useMemo(()=>Xi(Yi),[]),o=he.default.useMemo(()=>Xi(e.workspaceMenuItems??[]),[e.workspaceMenuItems]);return he.default.useMemo(()=>Array.from(new Set([...t,...o])).sort(),[t,o])}async function an(e){let t=await e("/api/menu-items?menuTarget=workspace");if(t.success&&t.data?.records){let o=new Set;for(let r of t.data.records)r.group?.trim()&&o.add(r.group.trim());return Array.from(o).sort()}return[]}var As={display:"flex",flexDirection:"column",gap:12},Cn=({assistantId:e,contentType:t="agent",contentConfig:o,isMatch:r,size:s="small",label:i,block:d})=>{let{check:c,pin:p,unpin:g,enableCustomMenu:v,get:x}=po(),[h,u]=(0,he.useState)(!1),[m,b]=(0,he.useState)(""),[O,L]=(0,he.useState)(""),[N,X]=(0,he.useState)(!1),[ee,de]=(0,he.useState)(!1),[Q,S]=(0,he.useState)(null),[B,J]=(0,he.useState)(!0),Z=rn(),[A,ae]=(0,he.useState)(Z);(0,he.useEffect)(()=>{ae(Z)},[Z]),(0,he.useEffect)(()=>{h&&an(x).then(I=>{ae(Array.from(new Set([...Z,...I])).sort())})},[h]);let D=t==="agent"?!!e:!!o,$=(0,he.useCallback)(async()=>{if(!D||!v){J(!1);return}J(!0);try{let I=await c({contentType:t,assistantId:e,contentConfig:o,isMatch:r});de(I.isPinned),S(I.pinnedId)}catch{}finally{J(!1)}},[D,v,c,t,e,o,r]);if((0,he.useEffect)(()=>{$()},[$]),!D||!v)return null;let se=async()=>{if(!O.trim()){q.warning("Please enter a menu name");return}X(!0);try{await p({contentType:t,assistantId:e,contentConfig:o,isMatch:r,name:O.trim(),group:m.trim()||void 0}),q.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),u(!1),b(""),L(""),$()}catch(I){q.error(I.message||"Failed to pin to menu")}finally{X(!1)}},_=async()=>{if(Q){X(!0);try{await g(Q),q.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),de(!1),S(null)}catch(I){q.error(I.message||"Failed to unpin from menu")}finally{X(!1)}}},R=()=>{ee?_():u(!0)};return(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Fe,{title:ee?"Unpin from Menu":"Pin to Menu",children:i?(0,Ne.jsx)(F,{type:"text",size:s,block:d,icon:ee?(0,Ne.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Ne.jsx)(Ve,{size:14}),onClick:R,loading:B||N&&ee,children:i}):(0,Ne.jsx)(F,{type:"text",size:s,block:d,icon:ee?(0,Ne.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Ne.jsx)(Ve,{size:14}),onClick:R,loading:B||N&&ee})}),(0,Ne.jsx)(pe,{title:"Pin to Menu",open:h,onOk:se,onCancel:()=>u(!1),confirmLoading:N,okText:"Pin",children:(0,Ne.jsxs)("div",{style:As,children:[(0,Ne.jsx)(H,{placeholder:"Menu name (required)",value:O,onChange:I=>L(I.target.value)}),(0,Ne.jsx)(Vt,{placeholder:"Group (optional, select or type new)",value:m,options:A.map(I=>({value:I})),onChange:I=>b(I),filterOption:(I,T)=>T?.value?.toUpperCase().includes(I.toUpperCase())??!1})]})})]})};var ie=n(w());var G=n(a()),jn=50,Es=C(({token:e,css:t})=>({container:t`
1968
2135
  position: relative;
1969
2136
  `,projectTrigger:t`
1970
2137
  display: flex;
@@ -2163,11 +2330,11 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
2163
2330
  display: flex;
2164
2331
  justify-content: flex-end;
2165
2332
  gap: 8px;
2166
- `})),wo=({disableDropdown:e=!0,showWorkspace:t=!0,value:o,onChange:r,kind:a})=>{let{styles:i}=ws(),{workspaceId:d,workspaces:c,projectId:p,projects:g,trainingProjects:b=[],personalProjects:x=[],setWorkspace:h,setProject:u,createProject:m}=Ie(),[v,O]=(0,ie.useState)(!1),_=(0,ie.useRef)(null),E=(0,ie.useRef)(null),[Y,ee]=(0,ie.useState)(!1),[de,V]=(0,ie.useState)(!1),[S,F]=(0,ie.useState)(""),[J,Z]=(0,ie.useState)(null),[A,ae]=(0,ie.useState)(!1),B=(0,ie.useRef)(null),j=o!==void 0,se=j?o:p,$=(0,ie.useMemo)(()=>{if(a==="business")return g;if(a==="training")return b;if(a==="personal")return x;let W=new Map;for(let fe of[...g,...b,...x])W.has(fe.id)||W.set(fe.id,fe);return Array.from(W.values())},[a,g,b,x]);(0,ie.useEffect)(()=>{let W=fe=>{E.current&&!E.current.contains(fe.target)&&(ee(!1),O(!1))};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[]);let R=(0,ie.useMemo)(()=>$.find(W=>W.id===se),[$,se]),I=(0,ie.useMemo)(()=>c.find(W=>W.id===d),[c,d]),T=(0,ie.useCallback)(W=>{j?r?.(W):u(W),ee(!1)},[j,r,u]),le=(0,ie.useCallback)(()=>{j?r?.(null):u(null)},[j,r,u]),k=(0,ie.useCallback)(()=>{ee(W=>!W)},[]),oe=(0,ie.useCallback)(()=>{O(W=>!W)},[]),D=(0,ie.useCallback)(W=>{let fe=W.trim();return fe?fe.length>zn?`Name must be ${zn} characters or less`:null:"Project name is required"},[]),U=(0,ie.useCallback)(W=>{if(W.stopPropagation(),!d){q.warning("Please select a workspace first");return}F(""),Z(null),V(!0),setTimeout(()=>B.current?.input?.focus(),100)},[d]),Oe=(0,ie.useCallback)(()=>{V(!1),F(""),Z(null)},[]),Ke=W=>{let fe=W.target.value;F(fe),Z(D(fe))},Ze=(0,ie.useCallback)(async()=>{if(!d)return;let W=S.trim(),fe=D(W);if(fe){Z(fe);return}ae(!0),Z(null);try{let rt=await m(d,{name:W});V(!1),F(""),Z(null),j?r?.(rt.id):u(rt.id),q.success(`Project "${rt.name}" created`)}catch(rt){let Qe=rt instanceof Error?rt.message:"Failed to create project";Z(Qe)}finally{ae(!1)}},[d,S,D,m,u,j,r]),gt=W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),D(S.trim())||Ze())},nt=!D(S.trim());return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("div",{className:i.container,ref:E,children:(0,Q.jsxs)("div",{className:i.selectorWrapper,children:[t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("div",{style:{position:"relative"},ref:_,children:(0,Q.jsx)("button",{className:i.workspaceButton,onClick:le,title:I?.name||"Select Workspace",children:(0,Q.jsx)("div",{className:i.workspaceButtonIcon,children:(0,Q.jsx)(cr,{size:16})})})}),(0,Q.jsx)("span",{className:i.divider,children:"/"})]}),(0,Q.jsxs)("div",{className:i.projectTrigger,onClick:e?void 0:k,style:{cursor:e?"default":"pointer"},children:[(0,Q.jsx)("div",{className:i.projectTriggerIcon,children:(0,Q.jsx)(jo,{size:16})}),(0,Q.jsx)("div",{className:i.projectTriggerInfo,children:(0,Q.jsx)("div",{className:i.projectTriggerName,children:R?.name||"Select Project"})}),!e&&(0,Q.jsx)("div",{className:`${i.projectTriggerArrow} ${Y?"expanded":""}`,children:(0,Q.jsx)(Xt,{size:14})})]}),!e&&Y&&(0,Q.jsxs)("div",{className:i.projectDropdown,children:[$.map(W=>(0,Q.jsxs)("div",{className:`${i.projectDropdownItem} ${W.id===se?"active":""}`,onClick:()=>T(W.id),children:[(0,Q.jsx)("div",{className:i.projectDropdownItemIcon,children:(0,Q.jsx)(jo,{size:14})}),(0,Q.jsx)("div",{className:W.id===se?i.projectDropdownItemNameActive:i.projectDropdownItemName,children:W.name})]},W.id)),$.length===0&&(0,Q.jsx)("div",{className:i.emptyState,children:"No projects"})]})]})}),(0,Q.jsxs)(pe,{title:"Create New Project",open:de,onCancel:Oe,wrapClassName:i.modalWrap,centered:!0,destroyOnClose:!0,maskClosable:!A,keyboard:!0,closable:!0,footer:(0,Q.jsxs)("div",{className:i.modalFooter,children:[(0,Q.jsx)(z,{onClick:Oe,disabled:A,children:"Cancel"}),(0,Q.jsx)(z,{type:"primary",onClick:Ze,loading:A,disabled:!nt,children:"Create"})]}),children:[(0,Q.jsx)(H,{ref:B,value:S,onChange:Ke,onKeyDown:gt,placeholder:"Enter project name",maxLength:zn+10,status:J?"error":void 0}),J&&(0,Q.jsx)("div",{style:{color:"#ff4d4f",fontSize:"12px",marginTop:"4px"},children:J})]})]})};var Me=n(C());var Qi=n(s()),Gi=()=>{let{config:e}=Ce(),{openSideApp:t}=Se(),{workspaceId:o,projectId:r,listPath:a,listPathByFolder:i,getFileViewUrl:d,getFileDownloadUrl:c,uploadFileToFolder:p}=Ie(),{currentAssistant:g}=et(),[b,x]=(0,Me.useState)({}),[h,u]=(0,Me.useState)({}),[m,v]=(0,Me.useState)({}),[O,_]=(0,Me.useState)({}),[E,Y]=(0,Me.useState)({}),[ee,de]=(0,Me.useState)(null),V=(0,Me.useMemo)(()=>e.resourceFolders&&e.resourceFolders.length>0?e.resourceFolders:[{name:"/",displayName:"Project Assets",allowUpload:!0}],[e.resourceFolders]),S=(0,Me.useCallback)(async(A,ae=!0)=>{if(!o||!r){x(B=>({...B,[A.name]:[]}));return}u(B=>({...B,[A.name]:!0}));try{let B=await i(A.name,g?.id);if(x(j=>({...j,[A.name]:B})),ae){let j=A.name==="/"?"/":A.name.replace(/\/$/,"");v(se=>{let $={...se};return Object.keys($).forEach(R=>{(R===j||R.startsWith(`${j}/`))&&delete $[R]}),$}),Y(se=>{let $={...se};return Object.keys($).forEach(R=>{(R===j||R.startsWith(`${j}/`))&&delete $[R]}),$})}}catch(B){console.error(`Failed to load assets for folder ${A.name}:`,B),x(j=>({...j,[A.name]:[]}))}finally{u(B=>({...B,[A.name]:!1}))}},[o,r,i,g?.id]),F=(0,Me.useCallback)(async A=>{if(E[A]||!1){Y(B=>({...B,[A]:!1}));return}Y(B=>({...B,[A]:!0})),_(B=>({...B,[A]:!0}));try{let B=await a(A,g?.id);v(j=>({...j,[A]:B}))}catch(B){console.error(`Failed to load directory ${A}:`,B),v(j=>({...j,[A]:[]}))}finally{_(B=>({...B,[A]:!1}))}},[E,a,g?.id]);(0,Me.useEffect)(()=>{V.forEach(A=>{S(A,!1)})},[V,S]);let J=(0,Me.useCallback)(A=>{let ae=d(A.path,g?.id),B=c(A.path,g?.id);if(!ae||!B){q.warning("Please select a workspace and project first.");return}t({component_key:"attachments",data:{file_id:A.path,message:`Preview: ${A.name||A.path}`,full_url:ae,download_url:B},message:`Preview: ${A.name||A.path}`})},[d,c,t,g?.id]),Z=(0,Me.useCallback)(async A=>{if(!o||!r){q.warning("Please select a workspace and project before uploading.");return}let ae=document.createElement("input");ae.type="file",ae.onchange=async B=>{let se=B.target?.files?.[0];if(se){de(A);try{await p(A,se,g?.id),q.success(`Uploaded "${se.name}" successfully`);let $=V.find(R=>R.name===A);$&&await S($)}catch($){let R=$ instanceof Error?$.message:"Failed to upload file";q.error(R)}finally{de(null),ae.remove()}}},ae.click()},[o,r,p,V,S,g?.id]);return(0,Qi.jsx)(en,{workspaceId:o,projectId:r,resourceFolders:V,folderEntries:b,folderLoading:h,directoryChildren:m,directoryLoading:O,directoryExpanded:E,uploadingFolder:ee,onRefreshFolder:S,onUploadFolder:Z,onToggleDirectory:F,onAssetClick:J})};var Co=n(C());var Ge=n(s()),{Text:Cs,Paragraph:Ss}=P,Yi={185:"Maximum update depth exceeded \u2014 likely an infinite re-render loop",31:"Objects are not valid as a React child",130:"Element type is invalid \u2014 check render method",152:"Too many re-renders \u2014 React limits renders to prevent an infinite loop",301:"Rendered fewer hooks than expected",306:"Rendered more hooks than during the previous render",310:"Rendered more hooks than during the previous render",321:"Invalid hook call \u2014 hooks can only be called inside function components",418:"Hydration failed because the server rendered content didn't match the client",423:"Hydration error \u2014 server/client mismatch in suspense boundary",424:"Could not find recovery element for hydrated instance",425:"Text content doesn't match server-rendered HTML"};function ks(e){if(!e)return"";let t=e.message?.match(/Minified React error #(\d+)/);return t&&Yi[t[1]]?`${e.name}: Minified React error #${t[1]} \u2014 ${Yi[t[1]]}`:`${e.name}: ${e.message}`}var ut=class extends Co.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null,retryKey:0}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){let r=this.props.name||"ChatErrorBoundary";console.error(`[${r}] Caught rendering error:`,t,o),this.setState({errorInfo:o}),this.props.onError?.(t,o)}handleRetry=()=>{this.setState(t=>({hasError:!1,error:null,errorInfo:null,retryKey:t.retryKey+1}))};handleCopyError=()=>{let{error:t,errorInfo:o}=this.state,a=[`[${this.props.name||"ChatErrorBoundary"}]`,`Error: ${t?.name}: ${t?.message}`,`Stack: ${t?.stack}`,`Component Stack: ${o?.componentStack}`].join(`
2333
+ `})),Co=({disableDropdown:e=!0,showWorkspace:t=!0,value:o,onChange:r,kind:s})=>{let{styles:i}=Es(),{workspaceId:d,workspaces:c,projectId:p,projects:g,trainingProjects:v=[],personalProjects:x=[],setWorkspace:h,setProject:u,createProject:m}=Ie(),[b,O]=(0,ie.useState)(!1),L=(0,ie.useRef)(null),N=(0,ie.useRef)(null),[X,ee]=(0,ie.useState)(!1),[de,Q]=(0,ie.useState)(!1),[S,B]=(0,ie.useState)(""),[J,Z]=(0,ie.useState)(null),[A,ae]=(0,ie.useState)(!1),D=(0,ie.useRef)(null),$=o!==void 0,se=$?o:p,_=(0,ie.useMemo)(()=>{if(s==="business")return g;if(s==="training")return v;if(s==="personal")return x;let W=new Map;for(let fe of[...g,...v,...x])W.has(fe.id)||W.set(fe.id,fe);return Array.from(W.values())},[s,g,v,x]);(0,ie.useEffect)(()=>{let W=fe=>{N.current&&!N.current.contains(fe.target)&&(ee(!1),O(!1))};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[]);let R=(0,ie.useMemo)(()=>_.find(W=>W.id===se),[_,se]),I=(0,ie.useMemo)(()=>c.find(W=>W.id===d),[c,d]),T=(0,ie.useCallback)(W=>{$?r?.(W):u(W),ee(!1)},[$,r,u]),le=(0,ie.useCallback)(()=>{$?r?.(null):u(null)},[$,r,u]),k=(0,ie.useCallback)(()=>{ee(W=>!W)},[]),oe=(0,ie.useCallback)(()=>{O(W=>!W)},[]),z=(0,ie.useCallback)(W=>{let fe=W.trim();return fe?fe.length>jn?`Name must be ${jn} characters or less`:null:"Project name is required"},[]),U=(0,ie.useCallback)(W=>{if(W.stopPropagation(),!d){q.warning("Please select a workspace first");return}B(""),Z(null),Q(!0),setTimeout(()=>D.current?.input?.focus(),100)},[d]),We=(0,ie.useCallback)(()=>{Q(!1),B(""),Z(null)},[]),Ke=W=>{let fe=W.target.value;B(fe),Z(z(fe))},Ze=(0,ie.useCallback)(async()=>{if(!d)return;let W=S.trim(),fe=z(W);if(fe){Z(fe);return}ae(!0),Z(null);try{let rt=await m(d,{name:W});Q(!1),B(""),Z(null),$?r?.(rt.id):u(rt.id),q.success(`Project "${rt.name}" created`)}catch(rt){let Qe=rt instanceof Error?rt.message:"Failed to create project";Z(Qe)}finally{ae(!1)}},[d,S,z,m,u,$,r]),ft=W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),z(S.trim())||Ze())},nt=!z(S.trim());return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("div",{className:i.container,ref:N,children:(0,G.jsxs)("div",{className:i.selectorWrapper,children:[t&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("div",{style:{position:"relative"},ref:L,children:(0,G.jsx)("button",{className:i.workspaceButton,onClick:le,title:I?.name||"Select Workspace",children:(0,G.jsx)("div",{className:i.workspaceButtonIcon,children:(0,G.jsx)(dr,{size:16})})})}),(0,G.jsx)("span",{className:i.divider,children:"/"})]}),(0,G.jsxs)("div",{className:i.projectTrigger,onClick:e?void 0:k,style:{cursor:e?"default":"pointer"},children:[(0,G.jsx)("div",{className:i.projectTriggerIcon,children:(0,G.jsx)(Lo,{size:16})}),(0,G.jsx)("div",{className:i.projectTriggerInfo,children:(0,G.jsx)("div",{className:i.projectTriggerName,children:R?.name||"Select Project"})}),!e&&(0,G.jsx)("div",{className:`${i.projectTriggerArrow} ${X?"expanded":""}`,children:(0,G.jsx)(eo,{size:14})})]}),!e&&X&&(0,G.jsxs)("div",{className:i.projectDropdown,children:[_.map(W=>(0,G.jsxs)("div",{className:`${i.projectDropdownItem} ${W.id===se?"active":""}`,onClick:()=>T(W.id),children:[(0,G.jsx)("div",{className:i.projectDropdownItemIcon,children:(0,G.jsx)(Lo,{size:14})}),(0,G.jsx)("div",{className:W.id===se?i.projectDropdownItemNameActive:i.projectDropdownItemName,children:W.name})]},W.id)),_.length===0&&(0,G.jsx)("div",{className:i.emptyState,children:"No projects"})]})]})}),(0,G.jsxs)(pe,{title:"Create New Project",open:de,onCancel:We,wrapClassName:i.modalWrap,centered:!0,destroyOnClose:!0,maskClosable:!A,keyboard:!0,closable:!0,footer:(0,G.jsxs)("div",{className:i.modalFooter,children:[(0,G.jsx)(F,{onClick:We,disabled:A,children:"Cancel"}),(0,G.jsx)(F,{type:"primary",onClick:Ze,loading:A,disabled:!nt,children:"Create"})]}),children:[(0,G.jsx)(H,{ref:D,value:S,onChange:Ke,onKeyDown:ft,placeholder:"Enter project name",maxLength:jn+10,status:J?"error":void 0}),J&&(0,G.jsx)("div",{style:{color:"#ff4d4f",fontSize:"12px",marginTop:"4px"},children:J})]})]})};var Me=n(w());var Zi=n(a()),Ji=()=>{let{config:e}=Ce(),{openSideApp:t}=Se(),{workspaceId:o,projectId:r,listPath:s,listPathByFolder:i,getFileViewUrl:d,getFileDownloadUrl:c,uploadFileToFolder:p}=Ie(),{currentAssistant:g}=et(),[v,x]=(0,Me.useState)({}),[h,u]=(0,Me.useState)({}),[m,b]=(0,Me.useState)({}),[O,L]=(0,Me.useState)({}),[N,X]=(0,Me.useState)({}),[ee,de]=(0,Me.useState)(null),Q=(0,Me.useMemo)(()=>e.resourceFolders&&e.resourceFolders.length>0?e.resourceFolders:[{name:"/",displayName:"Project Assets",allowUpload:!0}],[e.resourceFolders]),S=(0,Me.useCallback)(async(A,ae=!0)=>{if(!o||!r){x(D=>({...D,[A.name]:[]}));return}u(D=>({...D,[A.name]:!0}));try{let D=await i(A.name,g?.id);if(x($=>({...$,[A.name]:D})),ae){let $=A.name==="/"?"/":A.name.replace(/\/$/,"");b(se=>{let _={...se};return Object.keys(_).forEach(R=>{(R===$||R.startsWith(`${$}/`))&&delete _[R]}),_}),X(se=>{let _={...se};return Object.keys(_).forEach(R=>{(R===$||R.startsWith(`${$}/`))&&delete _[R]}),_})}}catch(D){console.error(`Failed to load assets for folder ${A.name}:`,D),x($=>({...$,[A.name]:[]}))}finally{u(D=>({...D,[A.name]:!1}))}},[o,r,i,g?.id]),B=(0,Me.useCallback)(async A=>{if(N[A]||!1){X(D=>({...D,[A]:!1}));return}X(D=>({...D,[A]:!0})),L(D=>({...D,[A]:!0}));try{let D=await s(A,g?.id);b($=>({...$,[A]:D}))}catch(D){console.error(`Failed to load directory ${A}:`,D),b($=>({...$,[A]:[]}))}finally{L(D=>({...D,[A]:!1}))}},[N,s,g?.id]);(0,Me.useEffect)(()=>{Q.forEach(A=>{S(A,!1)})},[Q,S]);let J=(0,Me.useCallback)(A=>{let ae=d(A.path,g?.id),D=c(A.path,g?.id);if(!ae||!D){q.warning("Please select a workspace and project first.");return}t({component_key:"attachments",data:{file_id:A.path,message:`Preview: ${A.name||A.path}`,full_url:ae,download_url:D},message:`Preview: ${A.name||A.path}`})},[d,c,t,g?.id]),Z=(0,Me.useCallback)(async A=>{if(!o||!r){q.warning("Please select a workspace and project before uploading.");return}let ae=document.createElement("input");ae.type="file",ae.onchange=async D=>{let se=D.target?.files?.[0];if(se){de(A);try{await p(A,se,g?.id),q.success(`Uploaded "${se.name}" successfully`);let _=Q.find(R=>R.name===A);_&&await S(_)}catch(_){let R=_ instanceof Error?_.message:"Failed to upload file";q.error(R)}finally{de(null),ae.remove()}}},ae.click()},[o,r,p,Q,S,g?.id]);return(0,Zi.jsx)(nn,{workspaceId:o,projectId:r,resourceFolders:Q,folderEntries:v,folderLoading:h,directoryChildren:m,directoryLoading:O,directoryExpanded:N,uploadingFolder:ee,onRefreshFolder:S,onUploadFolder:Z,onToggleDirectory:B,onAssetClick:J})};var So=n(w());var Ge=n(a()),{Text:Ns,Paragraph:Ms}=P,ea={185:"Maximum update depth exceeded \u2014 likely an infinite re-render loop",31:"Objects are not valid as a React child",130:"Element type is invalid \u2014 check render method",152:"Too many re-renders \u2014 React limits renders to prevent an infinite loop",301:"Rendered fewer hooks than expected",306:"Rendered more hooks than during the previous render",310:"Rendered more hooks than during the previous render",321:"Invalid hook call \u2014 hooks can only be called inside function components",418:"Hydration failed because the server rendered content didn't match the client",423:"Hydration error \u2014 server/client mismatch in suspense boundary",424:"Could not find recovery element for hydrated instance",425:"Text content doesn't match server-rendered HTML"};function Bs(e){if(!e)return"";let t=e.message?.match(/Minified React error #(\d+)/);return t&&ea[t[1]]?`${e.name}: Minified React error #${t[1]} \u2014 ${ea[t[1]]}`:`${e.name}: ${e.message}`}var gt=class extends So.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null,retryKey:0}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){let r=this.props.name||"ChatErrorBoundary";console.error(`[${r}] Caught rendering error:`,t,o),this.setState({errorInfo:o}),this.props.onError?.(t,o)}handleRetry=()=>{this.setState(t=>({hasError:!1,error:null,errorInfo:null,retryKey:t.retryKey+1}))};handleCopyError=()=>{let{error:t,errorInfo:o}=this.state,s=[`[${this.props.name||"ChatErrorBoundary"}]`,`Error: ${t?.name}: ${t?.message}`,`Stack: ${t?.stack}`,`Component Stack: ${o?.componentStack}`].join(`
2167
2334
 
2168
- `);navigator.clipboard.writeText(a).then(()=>{q.success("Error details copied")}).catch(()=>{q.error("Failed to copy")})};render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;let{error:t,errorInfo:o}=this.state,r=this.props.name||"this section";return(0,Ge.jsx)($n,{status:"error",title:`Failed to render ${r}`,subTitle:(0,Ge.jsxs)(ce,{direction:"vertical",size:"small",style:{textAlign:"left"},children:[(0,Ge.jsx)(Cs,{type:"danger",strong:!0,children:ks(t)}),(t?.stack||o?.componentStack)&&(0,Ge.jsx)(At,{size:"small",ghost:!0,items:[{key:"details",label:"Error details",children:(0,Ge.jsxs)(Ss,{code:!0,style:{maxHeight:200,overflow:"auto",whiteSpace:"pre-wrap",fontSize:12},children:[t?.stack||"",t?.stack&&o?.componentStack?`
2335
+ `);navigator.clipboard.writeText(s).then(()=>{q.success("Error details copied")}).catch(()=>{q.error("Failed to copy")})};render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;let{error:t,errorInfo:o}=this.state,r=this.props.name||"this section";return(0,Ge.jsx)(Wn,{status:"error",title:`Failed to render ${r}`,subTitle:(0,Ge.jsxs)(ce,{direction:"vertical",size:"small",style:{textAlign:"left"},children:[(0,Ge.jsx)(Ns,{type:"danger",strong:!0,children:Bs(t)}),(t?.stack||o?.componentStack)&&(0,Ge.jsx)(Et,{size:"small",ghost:!0,items:[{key:"details",label:"Error details",children:(0,Ge.jsxs)(Ms,{code:!0,style:{maxHeight:200,overflow:"auto",whiteSpace:"pre-wrap",fontSize:12},children:[t?.stack||"",t?.stack&&o?.componentStack?`
2169
2336
 
2170
- `:"",o?.componentStack||""]})}]})]}),extra:[(0,Ge.jsx)(z,{icon:(0,Ge.jsx)(Xn,{}),onClick:this.handleCopyError,children:"Copy Details"},"copy"),(0,Ge.jsx)(z,{type:"primary",onClick:this.handleRetry,children:"Retry"},"retry")]})}return(0,Ge.jsx)(Co.default.Fragment,{children:this.props.children},this.state.retryKey)}};var te=n(s()),Rs=w(({css:e})=>({wrapper:e`
2337
+ `:"",o?.componentStack||""]})}]})]}),extra:[(0,Ge.jsx)(F,{icon:(0,Ge.jsx)(Jn,{}),onClick:this.handleCopyError,children:"Copy Details"},"copy"),(0,Ge.jsx)(F,{type:"primary",onClick:this.handleRetry,children:"Retry"},"retry")]})}return(0,Ge.jsx)(So.default.Fragment,{children:this.props.children},this.state.retryKey)}};var te=n(a()),Ds=C(({css:e})=>({wrapper:e`
2171
2338
  display: flex;
2172
2339
  flex-direction: column;
2173
2340
  width: 100%;
@@ -2188,5 +2355,5 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
2188
2355
  align-items: center;
2189
2356
  justify-content: flex-end;
2190
2357
  flex-shrink: 0;
2191
- `})),Ts=e=>{let{assistant_id:t,thread_id:o="",menu:r,header:a,headerRight:i,showProjectSelector:d,headerSelector:c,emptyPlaceholder:p,...g}=e,{config:b}=Ce(),{styles:x}=Rs(),h=d??b.enableWorkspace,u=(0,te.jsxs)("div",{className:x.headerBar,children:[(0,te.jsx)("div",{className:x.headerLeft,children:c??(h?(0,te.jsx)(wo,{}):null)}),(0,te.jsx)("div",{className:x.headerRight,children:i!==void 0?i:(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(vn,{assistantId:t}),(0,te.jsx)(Pn,{}),(0,te.jsx)(Uo,{})]})})]});return(0,te.jsxs)("div",{className:x.wrapper,children:[a,(0,te.jsx)(yt,{menu:r?(0,te.jsx)(ut,{name:"Sidebar",children:r}):void 0,header:u,main:(0,te.jsx)(ut,{name:"Chat panel",children:o?(0,te.jsx)(Br,{...g}):p??(0,te.jsx)("div",{children:"Please create a conversation first"})}),detail:(0,te.jsx)(ut,{name:"Detail panel",children:(0,te.jsx)(ao,{})}),tools:(0,te.jsx)(ut,{name:"Tools panel",children:(0,te.jsx)(Gi,{})})})]})},So=e=>(0,te.jsx)(ut,{name:"Thread",children:(0,te.jsx)($o,{assistantId:e.assistant_id,threadId:e.thread_id||"",options:{streaming:!0,enableReturnStateWhenStreamCompleted:!0,enableResumeStream:!0},children:(0,te.jsx)(oo.Provider,{value:null,children:(0,te.jsx)(st,{children:(0,te.jsx)(Ts,{...e})})})})});var ot=n(s()),Ps=({thread_id:e,name:t,description:o,headerSelector:r,...a})=>{let{currentAssistant:i}=et(),{thread:d}=tt(),c=e??d?.id??"";return c?(0,ot.jsx)(So,{thread_id:c,name:t??i?.name,description:o??i?.description,headerSelector:r??(0,ot.jsx)(wo,{showWorkspace:!1,disableDropdown:!1}),...a}):(0,ot.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,ot.jsx)(ne,{tip:"Creating conversation..."})})},zi=({defaultWorkspaceId:e,defaultProjectId:t,assistant_id:o,...r})=>(0,ot.jsx)(Dr,{defaultWorkspaceId:e,defaultProjectId:t,children:(0,ot.jsx)(Vn,{autoLoad:!0,initialAssistantId:o,children:(0,ot.jsx)(eo,{children:(0,ot.jsx)(Ps,{assistant_id:o,...r})})})});var Fe=n(C());var Be=class extends Error{code;retryable;status;constructor(t,o,r,a){super(o),this.name="AgentWebAppRuntimeClientError",this.code=t,this.retryable=r,this.status=a}};function xt(){return new Be("STREAM_FAILED","Stream failed",!0)}var Is=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function Pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Je(e,t){return Object.keys(e).length===t.length&&t.every(r=>r in e)}function As(e){return Pt(e)&&Je(e,["code","message","retryable"])&&typeof e.code=="string"&&Is.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function Es(e){if(!Pt(e))return!1;let t=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return Je(e,t)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||Pt(e.data))}var Ns=new Set([it.HUMAN,it.AI,it.TOOL,it.INTERRUPT,it.MESSAGE_COMPLETED,it.MESSAGE_FAILED,it.THREAD_IDLE]);function Ms(e,t){let o;try{o=JSON.parse(e)}catch{throw xt()}if(!Pt(o)||typeof o.type!="string")throw xt();if(Ns.has(o.type)||o.type==="error"&&Pt(o.data)&&!Pt(o.error)){let r=Kn(o,t);return r.length===0?[]:r}switch(o.type){case"message.delta":if(Je(o,["type","text"])&&typeof o.text=="string")return[o];break;case"message.completed":if(Je(o,["type","messageId"])&&typeof o.messageId=="string")return[o];break;case"tool.started":if(Je(o,["type","id","name"])&&typeof o.id=="string"&&typeof o.name=="string")return[o];break;case"tool.completed":if(Je(o,["type","id"])&&typeof o.id=="string")return[o];break;case"interrupt.created":if(Je(o,["type","interrupt"])&&Es(o.interrupt))return[o];break;case"genui.render":if(Je(o,["type","block"])&&Ht(o.block))return[o];break;case"error":if(Je(o,["type","error"])&&As(o.error))return[o];break;case"stream.completed":if(Je(o,["type"]))return[o];break}throw xt()}function Bs(e){return e instanceof Error&&e.name==="AbortError"}async function Xi(e,t){let o=Un({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),a=new TextDecoder,i="",d=!1,c=!1;try{for(;!d;){let p;try{p=await r.read()}catch(b){if(Bs(b))return;throw xt()}p.done&&(c=!0);try{i+=a.decode(p.value,{stream:!p.done})}catch{throw xt()}let g=i.split(/\r?\n\r?\n/);i=p.done?"":g.pop()??"";for(let b of g){let x=b.split(/\r?\n/).filter(h=>h==="data"||h.startsWith("data:")).map(h=>h==="data"?"":h.slice(5).replace(/^ /,""));if(x.length!==0){for(let h of Ms(x.join(`
2192
- `),o))if(await t(h),d=h.type==="stream.completed",d)break;if(d)break}}if(p.done)break}if(!d)throw xt()}finally{if(!c)try{await r.cancel()}catch{}r.releaseLock()}}var Ds=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Le(e,t,o=[]){let r=Object.keys(e);return t.every(a=>a in e)&&r.every(a=>t.includes(a)||o.includes(a))}function ge(e){return typeof e=="string"}function ko(e){if(!De(e)||!Le(e,["id","projectId","createdAt","updatedAt"],["label"])||!ge(e.id)||!ge(e.projectId)||e.label!==void 0&&!ge(e.label)||!ge(e.createdAt)||!ge(e.updatedAt))return;let t=new Date(e.createdAt),o=new Date(e.updatedAt);if(!(Number.isNaN(t.getTime())||Number.isNaN(o.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:t,updatedAt:o}}function Ji(e){if(!De(e)||e.success!==!1||!De(e.error))return!1;let t=e.error;return Le(e,["success","error"])&&Le(t,["code","message","retryable"])&&typeof t.code=="string"&&Ds.has(t.code)&&typeof t.message=="string"&&typeof t.retryable=="boolean"}function Fs(e){if(!De(e))return!1;let t=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return Le(e,t,["files"])&&t.every(o=>typeof e[o]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function zs(e){return De(e)&&Le(e,[],["title","welcomeMessage","primaryColor"])&&Object.values(e).every(ge)}function js(e){if(!De(e)||!Le(e,["webApp","projects","models"],["thread"])||!De(e.webApp))return;let t=e.webApp;if(!Le(t,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!ge(t.id)||!ge(t.name)||!ge(t.defaultProjectId)||t.description!==void 0&&!ge(t.description)||t.defaultModelKey!==void 0&&!ge(t.defaultModelKey)||t.identityAssurance!=="unverified"||!De(t.assistant)||!Le(t.assistant,["id","name"],["description"])||!ge(t.assistant.id)||!ge(t.assistant.name)||t.assistant.description!==void 0&&!ge(t.assistant.description)||!Fs(t.features)||!zs(t.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>De(r)&&Le(r,["id","name"])&&ge(r.id)&&ge(r.name))||!Array.isArray(e.models)||!e.models.every(r=>De(r)&&Le(r,["key","label"])&&ge(r.key)&&ge(r.label)))return;let o=e.thread===void 0?void 0:ko(e.thread);if(!(e.thread!==void 0&&!o))return{...e,...o?{thread:o}:{}}}function Ls(e){if(!De(e)||!Le(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let t=e.records.map(ko);return t.every(o=>o!==void 0)?{records:t,total:e.total}:void 0}function _s(e){return De(e)&&ge(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||ge(e.content)||Array.isArray(e.content)&&e.content.every(t=>Ht(t)!==void 0))}function $s(e){return De(e)&&Le(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(_s)?e:void 0}function Os(e){return De(e)&&Le(e,["ref","name","mimeType","size"])&&ge(e.ref)&&ge(e.name)&&ge(e.mimeType)&&typeof e.size=="number"?e:void 0}function Zi(e,t){return o=>De(o)&&Le(o,e)&&t(o)?o:void 0}var Ro=class{constructor(t){this.options=t;this.baseUrl=`${t.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(t.webAppId)}/runtime`,this.fetchImplementation=t.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(t={},o){return this.request("bootstrap",js,{query:t,signal:o})}async listThreads(t={},o){return this.request("threads",Ls,{query:t,signal:o})}async createThread(t={},o){return this.request("threads",ko,{method:"POST",body:t,signal:o})}async updateThread(t,o,r){return this.request(`threads/${encodeURIComponent(t)}`,ko,{method:"PATCH",body:o,signal:r})}async deleteThread(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}`,Zi(["id"],a=>ge(a.id)),{method:"DELETE",query:o,signal:r})}async getMessages(t,o={},r){return this.request(`threads/${encodeURIComponent(t)}/messages`,$s,{query:o,signal:r})}async streamMessage(t,o,r,a){return this.streamRequest(`threads/${encodeURIComponent(t)}/messages/stream`,o,r,a)}async resumeInterrupt(t,o,r,a,i){return this.streamRequest(`threads/${encodeURIComponent(t)}/interrupts/${encodeURIComponent(o)}/resume`,r,a,i)}async streamRequest(t,o,r,a){let i;try{i=await this.fetchRequest(t,{method:"POST",body:o,signal:a})}catch(d){throw ea(d)||d instanceof Be?d:new Be("STREAM_FAILED","Stream failed",!0)}if(i.ok||await this.throwResponseError(i),!i.body||!i.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(i.body)try{await i.body.cancel()}catch{}throw new Be("STREAM_FAILED","Stream failed",!0,i.status)}await Xi(i.body,r)}async abort(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}/abort`,Zi(["aborted"],a=>typeof a.aborted=="boolean"),{method:"POST",query:o,signal:r})}async uploadAttachment(t,o,r={},a){let i=new FormData,d=typeof File<"u"&&o instanceof File?o.name:"attachment";return i.append("file",o,d),this.request(`threads/${encodeURIComponent(t)}/attachments`,Os,{method:"POST",query:r,body:i,signal:a})}async request(t,o,r={}){let a;try{a=await this.fetchRequest(t,r)}catch(c){throw ea(c)||c instanceof Be?c:new Be("INTERNAL_ERROR","Request failed",!0)}let i;try{i=await a.json()}catch{throw this.internalError(a.status)}if(Ji(i))throw new Be(i.error.code,i.error.message,i.error.retryable,a.status);if(!a.ok||!De(i)||!Le(i,["success","data"])||i.success!==!0)throw this.internalError(a.status);let d=o(i.data);if(d===void 0)throw this.internalError(a.status);return d}async fetchRequest(t,o){let r=await this.options.identityProvider.getIdentity(o.signal),a=new URL(`${this.baseUrl}/${t}`);for(let[c,p]of Object.entries(o.query??{}))p!==void 0&&a.searchParams.set(c,p);let i=new Headers;r.bearerToken!==void 0?i.set("Authorization",`Bearer ${r.bearerToken}`):i.set("X-Axiom-External-User-Id",r.externalUserId??"");let d;return o.body instanceof FormData?d=o.body:o.body!==void 0&&(i.set("Content-Type","application/json"),d=JSON.stringify(o.body)),this.fetchImplementation(a,{method:o.method??"GET",headers:i,body:d,signal:o.signal,credentials:"omit"})}async throwResponseError(t){let o;try{o=await t.json()}catch{throw this.internalError(t.status)}throw Ji(o)?new Be(o.error.code,o.error.message,o.error.retryable,t.status):this.internalError(t.status)}internalError(t){return new Be("INTERNAL_ERROR","Invalid server response",!1,t)}};function ea(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var To=n(C());var It=n(s());function ta(){let{createThread:e}=tt(),{menuCollapsed:t,setMenuCollapsed:o}=Se();(0,To.useEffect)(()=>{t===void 0&&o(!0)},[t,o]);let r=(0,To.useCallback)(async()=>{try{await e("New Thread")}catch(g){console.error("Failed to create new thread:",g)}},[e]),a=t??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,It.jsx)(pr,{size:20}),order:0},...a?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,It.jsx)(St,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,It.jsx)(St,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,It.jsx)(En,{})}]];return(0,It.jsx)(ro,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!a,collapsed:a,onCollapsedChange:o,onNewAnalysis:r,onItemClick:g=>{g.type==="action"&&g.builtin==="new-analysis"?r():g.type==="action"&&g.id==="thread-history-toggle"&&o(!1)}},a?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function oa(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let t=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,o=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,a=new WeakMap;return XMLHttpRequest.prototype.open=function(d,c){a.set(this,String(c)),o.call(this,d,c,!0)},XMLHttpRequest.prototype.send=function(d){let c=a.get(this)??"";if(!c.startsWith(t)||!/\/sandbox\/uploadfile$/.test(c)){r.call(this,d);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,d);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,d)}).catch(()=>{r.call(this,d)})},()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=r}}var Re=n(s());function Ws(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function Us(e){return e instanceof Be?e:new Be("INTERNAL_ERROR","Request failed",!0)}function Ks(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function zw(e){Ws(e);let t=`${e.gatewayUrl}\0${e.webAppId}\0${Ks(e.identity)}`;return(0,Re.jsx)(Hs,{...e},t)}function Hs({gatewayUrl:e,webAppId:t,identity:o,onError:r,onChatReady:a,onChatMessage:i,fetch:d,className:c}){let[p,g]=(0,Fe.useState)({status:"loading"}),b=(0,Fe.useRef)(o);b.current=o;let x=(0,Fe.useRef)(r);x.current=r;let h=(0,Fe.useRef)();return h.current||(h.current=new Ro({gatewayUrl:e,webAppId:t,identityProvider:{getIdentity:async()=>{let u=b.current;if(u.mode!=="verified")return{externalUserId:u.userId};try{return{bearerToken:await u.tokenProvider()}}catch{throw new Be("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...d?{fetch:d}:{}})),(0,Fe.useEffect)(()=>oa({gatewayUrl:e,webAppId:t,identity:o}),[e,t,o]),(0,Fe.useEffect)(()=>{let u=!1,m=h.current;return(async()=>{try{let v=await m.bootstrap({});if(u)return;g({status:"ready",bootstrap:v})}catch(v){if(u)return;let O=Us(v);g({status:"error",error:O}),x.current?.(O)}})(),()=>{u=!0}},[]),p.status==="loading"?(0,Re.jsx)("div",{className:c}):p.status==="error"?(0,Re.jsxs)("div",{className:c,role:"alert",children:[(0,Re.jsx)("strong",{children:"Unable to load the assistant"}),(0,Re.jsx)("div",{children:p.error.code}),(0,Re.jsx)("button",{type:"button",onClick:()=>g({status:"loading"}),children:"Retry"})]}):(0,Re.jsx)(Vs,{className:c,gatewayUrl:e,webAppId:t,identity:o,bootstrap:p.bootstrap,onChatReady:a,onChatMessage:i})}function qs(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function Vs({gatewayUrl:e,webAppId:t,identity:o,bootstrap:r,onChatReady:a,onChatMessage:i,className:d}){let c=(0,Fe.useMemo)(()=>qs(r.webApp.assistant),[r.webApp.assistant]),p=(0,Fe.useMemo)(()=>o.mode==="unverified"?{mode:"unverified",userId:o.userId}:{mode:"verified",tokenProvider:o.tokenProvider},[o]),g=(0,Fe.useCallback)(h=>new Wn({gatewayUrl:e,webAppId:t,identity:p,assistantId:h.assistantId,transport:h.transport,...h.timeout!==void 0?{timeout:h.timeout}:{},...h.headers!==void 0?{headers:h.headers}:{}}),[e,t,p]),b=(0,Fe.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${t}/runtime`,apiKey:"",transport:"sse",assistantId:c.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[c.id,e,t]),x=(0,Fe.useMemo)(()=>({assistants:[c],currentAssistant:c,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>c,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[c]);return(0,Re.jsx)(Hn,{config:{baseURL:b.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:g,children:(0,Re.jsx)(Qn,{initialConfig:b,persistToLocalStorage:!1,children:(0,Re.jsx)(qn.Provider,{value:x,children:(0,Re.jsx)(eo,{children:(0,Re.jsx)(Gs,{className:d,onChatReady:a,onChatMessage:i})})})})})}function Gs({className:e,onChatReady:t,onChatMessage:o}){let{threadId:r}=tt(),{currentAssistant:a}=et();if(!a)return null;let i=r??"";return i?(0,Re.jsx)("div",{className:e,children:(0,Re.jsx)(So,{thread_id:i,assistant_id:a.id,name:a.name,description:a.description,menu:(0,Re.jsx)(ta,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,onChatReady:t,onChatMessage:o})}):(0,Re.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,Re.jsx)(ne,{tip:"Creating conversation..."})})}export{Ko as a,pi as b,mi as c,Oa as d,Qa as e,wo as f,zi as g,zw as h};
2358
+ `})),zs=e=>{let{assistant_id:t,thread_id:o="",menu:r,header:s,headerRight:i,showProjectSelector:d,headerSelector:c,emptyPlaceholder:p,...g}=e,{config:v}=Ce(),{styles:x}=Ds(),h=d??v.enableWorkspace,u=(0,te.jsxs)("div",{className:x.headerBar,children:[(0,te.jsx)("div",{className:x.headerLeft,children:c??(h?(0,te.jsx)(Co,{}):null)}),(0,te.jsx)("div",{className:x.headerRight,children:i!==void 0?i:(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(Cn,{assistantId:t}),(0,te.jsx)(Nn,{}),(0,te.jsx)(Ho,{})]})})]});return(0,te.jsxs)("div",{className:x.wrapper,children:[s,(0,te.jsx)(ht,{menu:r?(0,te.jsx)(gt,{name:"Sidebar",children:r}):void 0,header:u,main:(0,te.jsx)(gt,{name:"Chat panel",children:o?(0,te.jsx)(Dr,{...g}):p??(0,te.jsx)("div",{children:"Please create a conversation first"})}),detail:(0,te.jsx)(gt,{name:"Detail panel",children:(0,te.jsx)(co,{})}),tools:(0,te.jsx)(gt,{name:"Tools panel",children:(0,te.jsx)(Ji,{})})})]})},ko=e=>(0,te.jsx)(gt,{name:"Thread",children:(0,te.jsx)(Wo,{assistantId:e.assistant_id,threadId:e.thread_id||"",options:{streaming:!0,enableReturnStateWhenStreamCompleted:!0,enableResumeStream:!0},children:(0,te.jsx)(io.Provider,{value:null,children:(0,te.jsx)(st,{children:(0,te.jsx)(zs,{...e})})})})});var ot=n(a()),Fs=({thread_id:e,name:t,description:o,headerSelector:r,...s})=>{let{currentAssistant:i}=et(),{thread:d}=tt(),c=e??d?.id??"";return c?(0,ot.jsx)(ko,{thread_id:c,name:t??i?.name,description:o??i?.description,headerSelector:r??(0,ot.jsx)(Co,{showWorkspace:!1,disableDropdown:!1}),...s}):(0,ot.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,ot.jsx)(ne,{tip:"Creating conversation..."})})},ji=({defaultWorkspaceId:e,defaultProjectId:t,assistant_id:o,...r})=>(0,ot.jsx)(zr,{defaultWorkspaceId:e,defaultProjectId:t,children:(0,ot.jsx)(Do,{autoLoad:!0,initialAssistantId:o,children:(0,ot.jsx)(no,{children:(0,ot.jsx)(Fs,{assistant_id:o,...r})})})});var ze=n(w());var Be=class extends Error{code;retryable;status;constructor(t,o,r,s){super(o),this.name="AgentWebAppRuntimeClientError",this.code=t,this.retryable=r,this.status=s}};function wt(){return new Be("STREAM_FAILED","Stream failed",!0)}var $s=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function It(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Je(e,t){return Object.keys(e).length===t.length&&t.every(r=>r in e)}function js(e){return It(e)&&Je(e,["code","message","retryable"])&&typeof e.code=="string"&&$s.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function Ls(e){if(!It(e))return!1;let t=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return Je(e,t)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||It(e.data))}var _s=new Set([it.HUMAN,it.AI,it.TOOL,it.INTERRUPT,it.MESSAGE_COMPLETED,it.MESSAGE_FAILED,it.THREAD_IDLE]);function Os(e,t){let o;try{o=JSON.parse(e)}catch{throw wt()}if(!It(o)||typeof o.type!="string")throw wt();if(_s.has(o.type)||o.type==="error"&&It(o.data)&&!It(o.error)){let r=qn(o,t);return r.length===0?[]:r}switch(o.type){case"message.delta":if(Je(o,["type","text"])&&typeof o.text=="string")return[o];break;case"message.completed":if(Je(o,["type","messageId"])&&typeof o.messageId=="string")return[o];break;case"tool.started":if(Je(o,["type","id","name"])&&typeof o.id=="string"&&typeof o.name=="string")return[o];break;case"tool.completed":if(Je(o,["type","id"])&&typeof o.id=="string")return[o];break;case"interrupt.created":if(Je(o,["type","interrupt"])&&Ls(o.interrupt))return[o];break;case"genui.render":if(Je(o,["type","block"])&&Gt(o.block))return[o];break;case"error":if(Je(o,["type","error"])&&js(o.error))return[o];break;case"stream.completed":if(Je(o,["type"]))return[o];break}throw wt()}function Ws(e){return e instanceof Error&&e.name==="AbortError"}async function ta(e,t){let o=Hn({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),s=new TextDecoder,i="",d=!1,c=!1;try{for(;!d;){let p;try{p=await r.read()}catch(v){if(Ws(v))return;throw wt()}p.done&&(c=!0);try{i+=s.decode(p.value,{stream:!p.done})}catch{throw wt()}let g=i.split(/\r?\n\r?\n/);i=p.done?"":g.pop()??"";for(let v of g){let x=v.split(/\r?\n/).filter(h=>h==="data"||h.startsWith("data:")).map(h=>h==="data"?"":h.slice(5).replace(/^ /,""));if(x.length!==0){for(let h of Os(x.join(`
2359
+ `),o))if(await t(h),d=h.type==="stream.completed",d)break;if(d)break}}if(p.done)break}if(!d)throw wt()}finally{if(!c)try{await r.cancel()}catch{}r.releaseLock()}}var Us=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function je(e,t,o=[]){let r=Object.keys(e);return t.every(s=>s in e)&&r.every(s=>t.includes(s)||o.includes(s))}function ge(e){return typeof e=="string"}function Ro(e){if(!De(e)||!je(e,["id","projectId","createdAt","updatedAt"],["label"])||!ge(e.id)||!ge(e.projectId)||e.label!==void 0&&!ge(e.label)||!ge(e.createdAt)||!ge(e.updatedAt))return;let t=new Date(e.createdAt),o=new Date(e.updatedAt);if(!(Number.isNaN(t.getTime())||Number.isNaN(o.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:t,updatedAt:o}}function oa(e){if(!De(e)||e.success!==!1||!De(e.error))return!1;let t=e.error;return je(e,["success","error"])&&je(t,["code","message","retryable"])&&typeof t.code=="string"&&Us.has(t.code)&&typeof t.message=="string"&&typeof t.retryable=="boolean"}function Ks(e){if(!De(e))return!1;let t=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return je(e,t,["files"])&&t.every(o=>typeof e[o]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function Hs(e){return De(e)&&je(e,[],["title","welcomeMessage","primaryColor"])&&Object.values(e).every(ge)}function qs(e){if(!De(e)||!je(e,["webApp","projects","models"],["thread"])||!De(e.webApp))return;let t=e.webApp;if(!je(t,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!ge(t.id)||!ge(t.name)||!ge(t.defaultProjectId)||t.description!==void 0&&!ge(t.description)||t.defaultModelKey!==void 0&&!ge(t.defaultModelKey)||t.identityAssurance!=="unverified"||!De(t.assistant)||!je(t.assistant,["id","name"],["description"])||!ge(t.assistant.id)||!ge(t.assistant.name)||t.assistant.description!==void 0&&!ge(t.assistant.description)||!Ks(t.features)||!Hs(t.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>De(r)&&je(r,["id","name"])&&ge(r.id)&&ge(r.name))||!Array.isArray(e.models)||!e.models.every(r=>De(r)&&je(r,["key","label"])&&ge(r.key)&&ge(r.label)))return;let o=e.thread===void 0?void 0:Ro(e.thread);if(!(e.thread!==void 0&&!o))return{...e,...o?{thread:o}:{}}}function Vs(e){if(!De(e)||!je(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let t=e.records.map(Ro);return t.every(o=>o!==void 0)?{records:t,total:e.total}:void 0}function Gs(e){return De(e)&&ge(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||ge(e.content)||Array.isArray(e.content)&&e.content.every(t=>Gt(t)!==void 0))}function Qs(e){return De(e)&&je(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(Gs)?e:void 0}function Ys(e){return De(e)&&je(e,["ref","name","mimeType","size"])&&ge(e.ref)&&ge(e.name)&&ge(e.mimeType)&&typeof e.size=="number"?e:void 0}function na(e,t){return o=>De(o)&&je(o,e)&&t(o)?o:void 0}var To=class{constructor(t){this.options=t;this.baseUrl=`${t.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(t.webAppId)}/runtime`,this.fetchImplementation=t.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(t={},o){return this.request("bootstrap",qs,{query:t,signal:o})}async listThreads(t={},o){return this.request("threads",Vs,{query:t,signal:o})}async createThread(t={},o){return this.request("threads",Ro,{method:"POST",body:t,signal:o})}async updateThread(t,o,r){return this.request(`threads/${encodeURIComponent(t)}`,Ro,{method:"PATCH",body:o,signal:r})}async deleteThread(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}`,na(["id"],s=>ge(s.id)),{method:"DELETE",query:o,signal:r})}async getMessages(t,o={},r){return this.request(`threads/${encodeURIComponent(t)}/messages`,Qs,{query:o,signal:r})}async streamMessage(t,o,r,s){return this.streamRequest(`threads/${encodeURIComponent(t)}/messages/stream`,o,r,s)}async resumeInterrupt(t,o,r,s,i){return this.streamRequest(`threads/${encodeURIComponent(t)}/interrupts/${encodeURIComponent(o)}/resume`,r,s,i)}async streamRequest(t,o,r,s){let i;try{i=await this.fetchRequest(t,{method:"POST",body:o,signal:s})}catch(d){throw ra(d)||d instanceof Be?d:new Be("STREAM_FAILED","Stream failed",!0)}if(i.ok||await this.throwResponseError(i),!i.body||!i.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(i.body)try{await i.body.cancel()}catch{}throw new Be("STREAM_FAILED","Stream failed",!0,i.status)}await ta(i.body,r)}async abort(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}/abort`,na(["aborted"],s=>typeof s.aborted=="boolean"),{method:"POST",query:o,signal:r})}async uploadAttachment(t,o,r={},s){let i=new FormData,d=typeof File<"u"&&o instanceof File?o.name:"attachment";return i.append("file",o,d),this.request(`threads/${encodeURIComponent(t)}/attachments`,Ys,{method:"POST",query:r,body:i,signal:s})}async request(t,o,r={}){let s;try{s=await this.fetchRequest(t,r)}catch(c){throw ra(c)||c instanceof Be?c:new Be("INTERNAL_ERROR","Request failed",!0)}let i;try{i=await s.json()}catch{throw this.internalError(s.status)}if(oa(i))throw new Be(i.error.code,i.error.message,i.error.retryable,s.status);if(!s.ok||!De(i)||!je(i,["success","data"])||i.success!==!0)throw this.internalError(s.status);let d=o(i.data);if(d===void 0)throw this.internalError(s.status);return d}async fetchRequest(t,o){let r=await this.options.identityProvider.getIdentity(o.signal),s=new URL(`${this.baseUrl}/${t}`);for(let[c,p]of Object.entries(o.query??{}))p!==void 0&&s.searchParams.set(c,p);let i=new Headers;r.bearerToken!==void 0?i.set("Authorization",`Bearer ${r.bearerToken}`):i.set("X-Axiom-External-User-Id",r.externalUserId??"");let d;return o.body instanceof FormData?d=o.body:o.body!==void 0&&(i.set("Content-Type","application/json"),d=JSON.stringify(o.body)),this.fetchImplementation(s,{method:o.method??"GET",headers:i,body:d,signal:o.signal,credentials:"omit"})}async throwResponseError(t){let o;try{o=await t.json()}catch{throw this.internalError(t.status)}throw oa(o)?new Be(o.error.code,o.error.message,o.error.retryable,t.status):this.internalError(t.status)}internalError(t){return new Be("INTERNAL_ERROR","Invalid server response",!1,t)}};function ra(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var Po=n(w());var At=n(a());function ia(){let{createThread:e}=tt(),{menuCollapsed:t,setMenuCollapsed:o}=Se();(0,Po.useEffect)(()=>{t===void 0&&o(!0)},[t,o]);let r=(0,Po.useCallback)(async()=>{try{await e("New Thread")}catch(g){console.error("Failed to create new thread:",g)}},[e]),s=t??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,At.jsx)(mr,{size:20}),order:0},...s?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,At.jsx)(Dn,{})}]];return(0,At.jsx)(so,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!s,collapsed:s,onCollapsedChange:o,onNewAnalysis:r,onItemClick:g=>{g.type==="action"&&g.builtin==="new-analysis"?r():g.type==="action"&&g.id==="thread-history-toggle"&&o(!1)}},s?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function aa(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let t=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,o=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,s=new WeakMap;return XMLHttpRequest.prototype.open=function(d,c){s.set(this,String(c)),o.call(this,d,c,!0)},XMLHttpRequest.prototype.send=function(d){let c=s.get(this)??"";if(!c.startsWith(t)||!/\/sandbox\/uploadfile$/.test(c)){r.call(this,d);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,d);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,d)}).catch(()=>{r.call(this,d)})},()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=r}}var Re=n(a());function Xs(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function Js(e){return e instanceof Be?e:new Be("INTERNAL_ERROR","Request failed",!0)}function Zs(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function wC(e){Xs(e);let t=`${e.gatewayUrl}\0${e.webAppId}\0${Zs(e.identity)}`;return(0,Re.jsx)(el,{...e},t)}function el({gatewayUrl:e,webAppId:t,identity:o,onError:r,onChatReady:s,onChatMessage:i,fetch:d,className:c}){let[p,g]=(0,ze.useState)({status:"loading"}),v=(0,ze.useRef)(o);v.current=o;let x=(0,ze.useRef)(r);x.current=r;let h=(0,ze.useRef)();return h.current||(h.current=new To({gatewayUrl:e,webAppId:t,identityProvider:{getIdentity:async()=>{let u=v.current;if(u.mode!=="verified")return{externalUserId:u.userId};try{return{bearerToken:await u.tokenProvider()}}catch{throw new Be("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...d?{fetch:d}:{}})),(0,ze.useEffect)(()=>aa({gatewayUrl:e,webAppId:t,identity:o}),[e,t,o]),(0,ze.useEffect)(()=>{let u=!1,m=h.current;return(async()=>{try{let b=await m.bootstrap({});if(u)return;g({status:"ready",bootstrap:b})}catch(b){if(u)return;let O=Js(b);g({status:"error",error:O}),x.current?.(O)}})(),()=>{u=!0}},[]),p.status==="loading"?(0,Re.jsx)("div",{className:c}):p.status==="error"?(0,Re.jsxs)("div",{className:c,role:"alert",children:[(0,Re.jsx)("strong",{children:"Unable to load the assistant"}),(0,Re.jsx)("div",{children:p.error.code}),(0,Re.jsx)("button",{type:"button",onClick:()=>g({status:"loading"}),children:"Retry"})]}):(0,Re.jsx)(ol,{className:c,gatewayUrl:e,webAppId:t,identity:o,bootstrap:p.bootstrap,onChatReady:s,onChatMessage:i})}function tl(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function ol({gatewayUrl:e,webAppId:t,identity:o,bootstrap:r,onChatReady:s,onChatMessage:i,className:d}){let c=(0,ze.useMemo)(()=>tl(r.webApp.assistant),[r.webApp.assistant]),p=(0,ze.useMemo)(()=>o.mode==="unverified"?{mode:"unverified",userId:o.userId}:{mode:"verified",tokenProvider:o.tokenProvider},[o]),g=(0,ze.useCallback)(h=>new Kn({gatewayUrl:e,webAppId:t,identity:p,assistantId:h.assistantId,transport:h.transport,...h.timeout!==void 0?{timeout:h.timeout}:{},...h.headers!==void 0?{headers:h.headers}:{}}),[e,t,p]),v=(0,ze.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${t}/runtime`,apiKey:"",transport:"sse",assistantId:c.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[c.id,e,t]),x=(0,ze.useMemo)(()=>({assistants:[c],currentAssistant:c,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>c,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[c]);return(0,Re.jsx)(Vn,{config:{baseURL:v.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:g,children:(0,Re.jsx)(Yn,{initialConfig:v,persistToLocalStorage:!1,children:(0,Re.jsx)(Gn.Provider,{value:x,children:(0,Re.jsx)(no,{children:(0,Re.jsx)(nl,{className:d,onChatReady:s,onChatMessage:i})})})})})}function nl({className:e,onChatReady:t,onChatMessage:o}){let{threadId:r}=tt(),{currentAssistant:s}=et();if(!s)return null;let i=r??"";return i?(0,Re.jsx)("div",{className:e,children:(0,Re.jsx)(ko,{thread_id:i,assistant_id:s.id,name:s.name,description:s.description,menu:(0,Re.jsx)(ia,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,onChatReady:t,onChatMessage:o})}):(0,Re.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,Re.jsx)(ne,{tip:"Creating conversation..."})})}export{lt as a,mi as b,ui as c,ts as d,cs as e,Co as f,ji as g,wC as h};