solace-agent-mesh 1.4.4__py3-none-any.whl → 1.4.6__py3-none-any.whl

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.

Potentially problematic release.


This version of solace-agent-mesh might be problematic. Click here for more details.

Files changed (74) hide show
  1. solace_agent_mesh/agent/adk/setup.py +545 -470
  2. solace_agent_mesh/agent/sac/app.py +35 -15
  3. solace_agent_mesh/agent/sac/component.py +21 -20
  4. solace_agent_mesh/assets/docs/404.html +3 -3
  5. solace_agent_mesh/assets/docs/assets/images/sam-enterprise-credentials-b269f095349473118b2b33bdfcc40122.png +0 -0
  6. solace_agent_mesh/assets/docs/assets/js/{04989206.b9dfe831.js → 04989206.a248f00c.js} +1 -1
  7. solace_agent_mesh/assets/docs/assets/js/ae0e903d.c786e887.js +1 -0
  8. solace_agent_mesh/assets/docs/assets/js/{f284c35a.cad4dbf2.js → f284c35a.2b2f5048.js} +1 -1
  9. solace_agent_mesh/assets/docs/assets/js/{main.03fb0598.js → main.72d74e33.js} +2 -2
  10. solace_agent_mesh/assets/docs/assets/js/{runtime~main.4ee39c6f.js → runtime~main.3dcfaf51.js} +1 -1
  11. solace_agent_mesh/assets/docs/docs/documentation/Enterprise/installation/index.html +28 -11
  12. solace_agent_mesh/assets/docs/docs/documentation/Enterprise/single-sign-on/index.html +3 -3
  13. solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +3 -3
  14. solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-technical-migration-map/index.html +3 -3
  15. solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +3 -3
  16. solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +3 -3
  17. solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +3 -3
  18. solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +4 -4
  19. solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +3 -3
  20. solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +3 -3
  21. solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +3 -3
  22. solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +3 -3
  23. solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +3 -3
  24. solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +3 -3
  25. solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +3 -3
  26. solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +3 -3
  27. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +3 -3
  28. solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +3 -3
  29. solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +3 -3
  30. solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +3 -3
  31. solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +3 -3
  32. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +3 -3
  33. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +3 -3
  34. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +3 -3
  35. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +3 -3
  36. solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +3 -3
  37. solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +3 -3
  38. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +3 -3
  39. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +3 -3
  40. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +3 -3
  41. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +3 -3
  42. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +3 -3
  43. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +3 -3
  44. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +3 -3
  45. solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-python-tools/index.html +3 -3
  46. solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +3 -3
  47. solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +3 -3
  48. solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +3 -3
  49. solace_agent_mesh/assets/docs/img/sam-enterprise-credentials.png +0 -0
  50. solace_agent_mesh/assets/docs/lunr-index-1758893005563.json +1 -0
  51. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  52. solace_agent_mesh/assets/docs/search-doc-1758893005563.json +1 -0
  53. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  54. solace_agent_mesh/cli/__init__.py +1 -1
  55. solace_agent_mesh/cli/commands/eval_cmd.py +3 -3
  56. solace_agent_mesh/client/webui/frontend/static/assets/main-BKIoiLSu.js +339 -0
  57. solace_agent_mesh/client/webui/frontend/static/assets/main-ChRwcV89.css +1 -0
  58. solace_agent_mesh/client/webui/frontend/static/index.html +2 -2
  59. solace_agent_mesh/common/utils/type_utils.py +28 -0
  60. solace_agent_mesh/gateway/http_sse/component.py +29 -15
  61. solace_agent_mesh/gateway/http_sse/routers/sessions.py +39 -1
  62. solace_agent_mesh/gateway/http_sse/routers/tasks.py +30 -40
  63. solace_agent_mesh/gateway/http_sse/services/session_service.py +18 -2
  64. {solace_agent_mesh-1.4.4.dist-info → solace_agent_mesh-1.4.6.dist-info}/METADATA +3 -3
  65. {solace_agent_mesh-1.4.4.dist-info → solace_agent_mesh-1.4.6.dist-info}/RECORD +69 -66
  66. solace_agent_mesh/assets/docs/assets/js/ae0e903d.ac3b9419.js +0 -1
  67. solace_agent_mesh/assets/docs/lunr-index-1758293998763.json +0 -1
  68. solace_agent_mesh/assets/docs/search-doc-1758293998763.json +0 -1
  69. solace_agent_mesh/client/webui/frontend/static/assets/main-8xbvgfVK.css +0 -1
  70. solace_agent_mesh/client/webui/frontend/static/assets/main-Cv2k8j3R.js +0 -339
  71. /solace_agent_mesh/assets/docs/assets/js/{main.03fb0598.js.LICENSE.txt → main.72d74e33.js.LICENSE.txt} +0 -0
  72. {solace_agent_mesh-1.4.4.dist-info → solace_agent_mesh-1.4.6.dist-info}/WHEEL +0 -0
  73. {solace_agent_mesh-1.4.4.dist-info → solace_agent_mesh-1.4.6.dist-info}/entry_points.txt +0 -0
  74. {solace_agent_mesh-1.4.4.dist-info → solace_agent_mesh-1.4.6.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,339 @@
1
+ var jp=Object.defineProperty;var Rp=(e,t,n)=>t in e?jp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var fa=(e,t,n)=>Rp(e,typeof t!="symbol"?t+"":t,n);import{c as Mp}from"./client-B9p_nFNA.js";import{r as u,j as a,c as Ul,a as Wr,R as gi,b as Pp,N as ho,X as Lo,E as Lp,d as Ht,C as Hl,e as xi,f as Dp,A as Wl,L as vi,g as wi,P as Gl,B as Op,S as Fp,F as pa,h as zp,i as $p,k as ar,l as Bp,m as Up,n as Hp,o as Vl,D as bi,p as Yl,q as Wp,T as Gp,M as Kl,I as yi,s as ql,t as Vp,u as Yp,v as Kp,w as Xl,x as qp,y as Zl,z as Xp,G as Zp,H as ma,J as Jp,K as Jl,O as Ql,Q as Qp,U as Qe,V as et,W as ec,Y as em,Z as tm,_ as ha,$ as ga,a0 as ds,a1 as nm,a2 as rm,a3 as om,a4 as sm,a5 as im,a6 as am,a7 as lm,a8 as cm,a9 as um,aa as dm,ab as fm,ac as tc,ad as nc,ae as pm,af as xa,ag as va,ah as mm,ai as wa,aj as hm,ak as gm,al as xm}from"./vendor-CS5YMf8a.js";function ba(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rc(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ba(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ba(e[o],null)}}}}function $e(...e){return u.useCallback(rc(...e),e)}function Dn(e){const t=vm(e),n=u.forwardRef((r,o)=>{const{children:s,...i}=r,l=u.Children.toArray(s),c=l.find(bm);if(c){const d=c.props.children,f=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return a.jsx(t,{...i,ref:o,children:u.isValidElement(d)?u.cloneElement(d,void 0,f):null})}return a.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var oc=Dn("Slot");function vm(e){const t=u.forwardRef((n,r)=>{const{children:o,...s}=n;if(u.isValidElement(o)){const i=Sm(o),l=ym(s,o.props);return o.type!==u.Fragment&&(l.ref=r?rc(r,i):i),u.cloneElement(o,l)}return u.Children.count(o)>1?u.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var sc=Symbol("radix.slottable");function wm(e){const t=({children:n})=>a.jsx(a.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=sc,t}function bm(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===sc}function ym(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...l)=>{const c=s(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Sm(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const ya=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Sa=Ul,Nn=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Sa(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(d=>{const f=n==null?void 0:n[d],p=s==null?void 0:s[d];if(f===null)return null;const m=ya(f)||ya(p);return o[d][m]}),l=n&&Object.entries(n).reduce((d,f)=>{let[p,m]=f;return m===void 0||(d[p]=m),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:p,className:m,...g}=f;return Object.entries(g).every(x=>{let[h,v]=x;return Array.isArray(v)?v.includes({...s,...l}[h]):{...s,...l}[h]===v})?[...d,p,m]:d},[]);return Sa(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},Si=()=>localStorage.getItem("access_token"),Cm=()=>localStorage.getItem("refresh_token"),Em=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},Tm=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},Am=async()=>{const e=Cm();if(!e)return null;const t=await fetch("/api/v1/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(t.ok){const n=await t.json();return Em(n.access_token,n.refresh_token),n.access_token}return Tm(),window.location.href="/api/v1/auth/login",null},Fe=async(e,t={})=>{const n=Si();if(!n)return fetch(e,t);const r=await fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${n}`}});if(r.status===401){const o=await Am();if(o)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${o}`}})}return r},Ci="-",Nm=e=>{const t=_m(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(Ci);return l[0]===""&&l.length!==1&&l.shift(),ic(l,t)||km(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},ic=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?ic(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const s=e.join(Ci);return(i=t.validators.find(({validator:l})=>l(s)))==null?void 0:i.classGroupId},Ca=/^\[(.+)\]$/,km=e=>{if(Ca.test(e)){const t=Ca.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},_m=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const o in n)$s(n[o],r,o,t);return r},$s=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const s=o===""?t:Ea(t,o);s.classGroupId=n;return}if(typeof o=="function"){if(Im(o)){$s(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([s,i])=>{$s(i,Ea(t,s),n,r)})})},Ea=(e,t)=>{let n=e;return t.split(Ci).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Im=e=>e.isThemeGetter,jm=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=r.get(s))!==void 0)return o(s,i),i},set(s,i){n.has(s)?n.set(s,i):o(s,i)}}},Bs="!",Us=":",Rm=Us.length,Mm=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,l=0,c=0,d;for(let x=0;x<o.length;x++){let h=o[x];if(i===0&&l===0){if(h===Us){s.push(o.slice(c,x)),c=x+Rm;continue}if(h==="/"){d=x;continue}}h==="["?i++:h==="]"?i--:h==="("?l++:h===")"&&l--}const f=s.length===0?o:o.substring(c),p=Pm(f),m=p!==f,g=d&&d>c?d-c:void 0;return{modifiers:s,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:g}};if(t){const o=t+Us,s=r;r=i=>i.startsWith(o)?s(i.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},Pm=e=>e.endsWith(Bs)?e.substring(0,e.length-1):e.startsWith(Bs)?e.substring(1):e,Lm=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const o=[];let s=[];return r.forEach(i=>{i[0]==="["||t[i]?(o.push(...s.sort(),i),s=[]):s.push(i)}),o.push(...s.sort()),o}},Dm=e=>({cache:jm(e.cacheSize),parseClassName:Mm(e),sortModifiers:Lm(e),...Nm(e)}),Om=/\s+/,Fm=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],l=e.trim().split(Om);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:p,modifiers:m,hasImportantModifier:g,baseClassName:x,maybePostfixModifierPosition:h}=n(f);if(p){c=f+(c.length>0?" "+c:c);continue}let v=!!h,b=r(v?x.substring(0,h):x);if(!b){if(!v){c=f+(c.length>0?" "+c:c);continue}if(b=r(x),!b){c=f+(c.length>0?" "+c:c);continue}v=!1}const w=s(m).join(":"),y=g?w+Bs:w,E=y+b;if(i.includes(E))continue;i.push(E);const A=o(b,v);for(let j=0;j<A.length;++j){const N=A[j];i.push(y+N)}c=f+(c.length>0?" "+c:c)}return c};function zm(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=ac(t))&&(r&&(r+=" "),r+=n);return r}const ac=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=ac(e[r]))&&(n&&(n+=" "),n+=t);return n};function $m(e,...t){let n,r,o,s=i;function i(c){const d=t.reduce((f,p)=>p(f),e());return n=Dm(d),r=n.cache.get,o=n.cache.set,s=l,l(c)}function l(c){const d=r(c);if(d)return d;const f=Fm(c,n);return o(c,f),f}return function(){return s(zm.apply(null,arguments))}}const Ye=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},lc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,cc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Bm=/^\d+\/\d+$/,Um=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hm=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Wm=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Gm=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Vm=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Vn=e=>Bm.test(e),Ee=e=>!!e&&!Number.isNaN(Number(e)),vn=e=>!!e&&Number.isInteger(Number(e)),fs=e=>e.endsWith("%")&&Ee(e.slice(0,-1)),cn=e=>Um.test(e),Ym=()=>!0,Km=e=>Hm.test(e)&&!Wm.test(e),uc=()=>!1,qm=e=>Gm.test(e),Xm=e=>Vm.test(e),Zm=e=>!re(e)&&!oe(e),Jm=e=>hr(e,pc,uc),re=e=>lc.test(e),Rn=e=>hr(e,mc,Km),ps=e=>hr(e,rh,Ee),Ta=e=>hr(e,dc,uc),Qm=e=>hr(e,fc,Xm),Qr=e=>hr(e,hc,qm),oe=e=>cc.test(e),Cr=e=>gr(e,mc),eh=e=>gr(e,oh),Aa=e=>gr(e,dc),th=e=>gr(e,pc),nh=e=>gr(e,fc),eo=e=>gr(e,hc,!0),hr=(e,t,n)=>{const r=lc.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},gr=(e,t,n=!1)=>{const r=cc.exec(e);return r?r[1]?t(r[1]):n:!1},dc=e=>e==="position"||e==="percentage",fc=e=>e==="image"||e==="url",pc=e=>e==="length"||e==="size"||e==="bg-size",mc=e=>e==="length",rh=e=>e==="number",oh=e=>e==="family-name",hc=e=>e==="shadow",sh=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),o=Ye("tracking"),s=Ye("leading"),i=Ye("breakpoint"),l=Ye("container"),c=Ye("spacing"),d=Ye("radius"),f=Ye("shadow"),p=Ye("inset-shadow"),m=Ye("text-shadow"),g=Ye("drop-shadow"),x=Ye("blur"),h=Ye("perspective"),v=Ye("aspect"),b=Ye("ease"),w=Ye("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...E(),oe,re],j=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[oe,re,c],G=()=>[Vn,"full","auto",...T()],q=()=>[vn,"none","subgrid",oe,re],W=()=>["auto",{span:["full",vn,oe,re]},vn,oe,re],X=()=>[vn,"auto",oe,re],ee=()=>["auto","min","max","fr",oe,re],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],k=()=>["auto",...T()],$=()=>[Vn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],C=()=>[e,oe,re],_=()=>[...E(),Aa,Ta,{position:[oe,re]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],R=()=>["auto","cover","contain",th,Jm,{size:[oe,re]}],J=()=>[fs,Cr,Rn],P=()=>["","none","full",d,oe,re],B=()=>["",Ee,Cr,Rn],D=()=>["solid","dashed","dotted","double"],U=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],I=()=>[Ee,fs,Aa,Ta],V=()=>["","none",x,oe,re],Q=()=>["none",Ee,oe,re],te=()=>["none",Ee,oe,re],ae=()=>[Ee,oe,re],se=()=>[Vn,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[cn],breakpoint:[cn],color:[Ym],container:[cn],"drop-shadow":[cn],ease:["in","out","in-out"],font:[Zm],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[cn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[cn],shadow:[cn],spacing:["px",Ee],text:[cn],"text-shadow":[cn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Vn,re,oe,v]}],container:["container"],columns:[{columns:[Ee,re,oe,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:G()}],"inset-x":[{"inset-x":G()}],"inset-y":[{"inset-y":G()}],start:[{start:G()}],end:[{end:G()}],top:[{top:G()}],right:[{right:G()}],bottom:[{bottom:G()}],left:[{left:G()}],visibility:["visible","invisible","collapse"],z:[{z:[vn,"auto",oe,re]}],basis:[{basis:[Vn,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ee,Vn,"auto","initial","none",re]}],grow:[{grow:["",Ee,oe,re]}],shrink:[{shrink:["",Ee,oe,re]}],order:[{order:[vn,"first","last","none",oe,re]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ee()}],"auto-rows":[{"auto-rows":ee()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],w:[{w:[l,"screen",...$()]}],"min-w":[{"min-w":[l,"screen","none",...$()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh",...$()]}],"font-size":[{text:["base",n,Cr,Rn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,oe,ps]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",fs,re]}],"font-family":[{font:[eh,re,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,oe,re]}],"line-clamp":[{"line-clamp":[Ee,"none",oe,ps]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",oe,re]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",oe,re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:C()}],"text-color":[{text:C()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...D(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ee,"from-font","auto",oe,Rn]}],"text-decoration-color":[{decoration:C()}],"underline-offset":[{"underline-offset":[Ee,"auto",oe,re]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",oe,re]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",oe,re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:_()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:R()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vn,oe,re],radial:["",oe,re],conic:[vn,oe,re]},nh,Qm]}],"bg-color":[{bg:C()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:C()}],"gradient-via":[{via:C()}],"gradient-to":[{to:C()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...D(),"hidden","none"]}],"divide-style":[{divide:[...D(),"hidden","none"]}],"border-color":[{border:C()}],"border-color-x":[{"border-x":C()}],"border-color-y":[{"border-y":C()}],"border-color-s":[{"border-s":C()}],"border-color-e":[{"border-e":C()}],"border-color-t":[{"border-t":C()}],"border-color-r":[{"border-r":C()}],"border-color-b":[{"border-b":C()}],"border-color-l":[{"border-l":C()}],"divide-color":[{divide:C()}],"outline-style":[{outline:[...D(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ee,oe,re]}],"outline-w":[{outline:["",Ee,Cr,Rn]}],"outline-color":[{outline:C()}],shadow:[{shadow:["","none",f,eo,Qr]}],"shadow-color":[{shadow:C()}],"inset-shadow":[{"inset-shadow":["none",p,eo,Qr]}],"inset-shadow-color":[{"inset-shadow":C()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:C()}],"ring-offset-w":[{"ring-offset":[Ee,Rn]}],"ring-offset-color":[{"ring-offset":C()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":C()}],"text-shadow":[{"text-shadow":["none",m,eo,Qr]}],"text-shadow-color":[{"text-shadow":C()}],opacity:[{opacity:[Ee,oe,re]}],"mix-blend":[{"mix-blend":[...U(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":U()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ee]}],"mask-image-linear-from-pos":[{"mask-linear-from":I()}],"mask-image-linear-to-pos":[{"mask-linear-to":I()}],"mask-image-linear-from-color":[{"mask-linear-from":C()}],"mask-image-linear-to-color":[{"mask-linear-to":C()}],"mask-image-t-from-pos":[{"mask-t-from":I()}],"mask-image-t-to-pos":[{"mask-t-to":I()}],"mask-image-t-from-color":[{"mask-t-from":C()}],"mask-image-t-to-color":[{"mask-t-to":C()}],"mask-image-r-from-pos":[{"mask-r-from":I()}],"mask-image-r-to-pos":[{"mask-r-to":I()}],"mask-image-r-from-color":[{"mask-r-from":C()}],"mask-image-r-to-color":[{"mask-r-to":C()}],"mask-image-b-from-pos":[{"mask-b-from":I()}],"mask-image-b-to-pos":[{"mask-b-to":I()}],"mask-image-b-from-color":[{"mask-b-from":C()}],"mask-image-b-to-color":[{"mask-b-to":C()}],"mask-image-l-from-pos":[{"mask-l-from":I()}],"mask-image-l-to-pos":[{"mask-l-to":I()}],"mask-image-l-from-color":[{"mask-l-from":C()}],"mask-image-l-to-color":[{"mask-l-to":C()}],"mask-image-x-from-pos":[{"mask-x-from":I()}],"mask-image-x-to-pos":[{"mask-x-to":I()}],"mask-image-x-from-color":[{"mask-x-from":C()}],"mask-image-x-to-color":[{"mask-x-to":C()}],"mask-image-y-from-pos":[{"mask-y-from":I()}],"mask-image-y-to-pos":[{"mask-y-to":I()}],"mask-image-y-from-color":[{"mask-y-from":C()}],"mask-image-y-to-color":[{"mask-y-to":C()}],"mask-image-radial":[{"mask-radial":[oe,re]}],"mask-image-radial-from-pos":[{"mask-radial-from":I()}],"mask-image-radial-to-pos":[{"mask-radial-to":I()}],"mask-image-radial-from-color":[{"mask-radial-from":C()}],"mask-image-radial-to-color":[{"mask-radial-to":C()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[Ee]}],"mask-image-conic-from-pos":[{"mask-conic-from":I()}],"mask-image-conic-to-pos":[{"mask-conic-to":I()}],"mask-image-conic-from-color":[{"mask-conic-from":C()}],"mask-image-conic-to-color":[{"mask-conic-to":C()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:_()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:R()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",oe,re]}],filter:[{filter:["","none",oe,re]}],blur:[{blur:V()}],brightness:[{brightness:[Ee,oe,re]}],contrast:[{contrast:[Ee,oe,re]}],"drop-shadow":[{"drop-shadow":["","none",g,eo,Qr]}],"drop-shadow-color":[{"drop-shadow":C()}],grayscale:[{grayscale:["",Ee,oe,re]}],"hue-rotate":[{"hue-rotate":[Ee,oe,re]}],invert:[{invert:["",Ee,oe,re]}],saturate:[{saturate:[Ee,oe,re]}],sepia:[{sepia:["",Ee,oe,re]}],"backdrop-filter":[{"backdrop-filter":["","none",oe,re]}],"backdrop-blur":[{"backdrop-blur":V()}],"backdrop-brightness":[{"backdrop-brightness":[Ee,oe,re]}],"backdrop-contrast":[{"backdrop-contrast":[Ee,oe,re]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ee,oe,re]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ee,oe,re]}],"backdrop-invert":[{"backdrop-invert":["",Ee,oe,re]}],"backdrop-opacity":[{"backdrop-opacity":[Ee,oe,re]}],"backdrop-saturate":[{"backdrop-saturate":[Ee,oe,re]}],"backdrop-sepia":[{"backdrop-sepia":["",Ee,oe,re]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",oe,re]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ee,"initial",oe,re]}],ease:[{ease:["linear","initial",b,oe,re]}],delay:[{delay:[Ee,oe,re]}],animate:[{animate:["none",w,oe,re]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,oe,re]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:ae()}],"skew-x":[{"skew-x":ae()}],"skew-y":[{"skew-y":ae()}],transform:[{transform:[oe,re,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:se()}],"translate-x":[{"translate-x":se()}],"translate-y":[{"translate-y":se()}],"translate-z":[{"translate-z":se()}],"translate-none":["translate-none"],accent:[{accent:C()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:C()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",oe,re]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",oe,re]}],fill:[{fill:["none",...C()]}],"stroke-w":[{stroke:[Ee,Cr,Rn,ps]}],stroke:[{stroke:["none",...C()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ih=$m(sh);function be(...e){return ih(Ul(e))}const ah=e=>{try{const t=new URL(e);if(t.protocol!=="artifact:")return null;const n=t.pathname.split("/").filter(s=>s),r=n[n.length-1],o=t.searchParams.get("version");return{filename:r,version:o}}catch(t){return console.error("Invalid artifact URI:",t),null}},gc=(e,t)=>{try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t||"download",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch(n){console.error("Error downloading blob:",n)}},lh=async e=>{try{let t,n=e.name;if(e.content){const r=atob(e.content),o=new Array(r.length);for(let i=0;i<r.length;i++)o[i]=r.charCodeAt(i);const s=new Uint8Array(o);t=new Blob([s],{type:e.mime_type||"application/octet-stream"})}else if(e.uri){const r=ah(e.uri);if(!r)throw new Error(`Invalid or unhandled URI format: ${e.uri}`);n=r.filename;const o=r.version||"latest",s=`/api/v1/artifacts/${encodeURIComponent(n)}/versions/${o}`,i=await Fe(s,{credentials:"include"});if(!i.ok)throw new Error(`Failed to download file: ${i.statusText}`);t=await i.blob()}else throw new Error("File has no content or URI to download.");gc(t,n)}catch(t){console.error("Error creating download link:",t)}},xc=(e,t=2)=>{if(e===0)return"0 Bytes";if(e<0||!Number.isFinite(e))return"Invalid size";const n=1024,r=t<0?0:t,o=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],s=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,s)).toFixed(r))+" "+o[s]},Na=e=>{if(!e)return"N/A";try{const t=new Date(e);if(isNaN(t.getTime()))return"N/A";const r=Math.floor((new Date().getTime()-t.getTime())/1e3),o=Math.floor(r/60),s=Math.floor(o/60),i=Math.floor(s/24);return r<60?`${r}s ago`:o<60?`${o}m ago`:s<24?`${s}h ago`:i===1?"Yesterday":i<7?`${i}d ago`:t.toLocaleDateString()}catch(t){return console.error("Error formatting date:",t),"Invalid date"}},ch=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}},ka=(e="")=>`
2
+ whitespace-normal
3
+ break-words
4
+ leading-[24px]
5
+
6
+ /* Typography */
7
+ [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mb-4 [&_h1]:mt-6 [&_h1]:text-foreground
8
+ [&_h2]:text-xl [&_h2]:font-bold [&_h2]:mb-3 [&_h2]:mt-5 [&_h2]:text-foreground
9
+ [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-foreground
10
+ [&_h4]:text-base [&_h4]:font-semibold [&_h4]:mb-2 [&_h4]:mt-3 [&_h4]:text-foreground
11
+ [&_h5]:text-sm [&_h5]:font-semibold [&_h5]:mb-1 [&_h5]:mt-2 [&_h5]:text-foreground
12
+ [&_h6]:text-xs [&_h6]:font-semibold [&_h6]:mb-1 [&_h6]:mt-2 [&_h6]:text-foreground
13
+
14
+ /* Paragraphs */
15
+ [&_p]:mb-2 [&_p]:leading-[24px] [&_p]:text-foreground
16
+
17
+ /* Text formatting */
18
+ [&_strong]:font-semibold [&_strong]:text-foreground
19
+ [&_em]:italic
20
+ [&_del]:line-through [&_del]:text-foreground
21
+
22
+ /* Links */
23
+ [&_a]:text-[var(--color-primary-wMain)] [&_a]:underline [&_a]:decoration-[var(--color-primary-wMain)] dark:[&_a]:text-[var(--color-primary-w20)] dark:[&_a]:decoration-[var(--color-primary-w20)]
24
+ [&_a:hover]:text-[var(--color-primary-w100)] [&_a:hover]:decoration-[var(--color-primary-w100)] dark:[&_a:hover]:text-[var(--color-primary-w10)] dark:[&_a:hover]:decoration-[var(--color-primary-w10)]
25
+
26
+ /* Lists */
27
+ [&_ul]:mb-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1
28
+ [&_ol]:mb-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1
29
+ [&_li]:text-foreground [&_li]:leading-[24px]
30
+ [&_ul_ul]:mt-1 [&_ul_ul]:mb-1
31
+ [&_ol_ol]:mt-1 [&_ol_ol]:mb-1
32
+
33
+ /* Code */
34
+ [&_code]:bg-transparent [&_code]:py-0.5 [&_code]:rounded
35
+ [&_code]:text-sm [&_code]:font-mono [&_code]:font-semibold [&_code]:text-foreground [&_code]:break-words
36
+ [&_pre]:bg-transparent [&_pre]:p-4 [&_pre]:rounded-lg [&_pre]:overflow-x-auto [&_pre]:max-w-full
37
+ [&_pre]:mb-4 [&_pre]:border [&_pre]:border-border [&_pre]:whitespace-pre-wrap
38
+ [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-sm [&_pre_code]:break-words
39
+
40
+ /* Blockquotes */
41
+ [&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4
42
+ [&_blockquote]:py-2 [&_blockquote]:mb-4 [&_blockquote]:italic
43
+ [&_blockquote]:text-foreground [&_blockquote]:bg-transparent
44
+
45
+ /* Tables */
46
+ [&_table]:w-full [&_table]:mb-4 [&_table]:border-collapse [&_table]:table-fixed [&_table]:max-w-full
47
+ [&_th]:border [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:break-words
48
+ [&_th]:bg-transparent [&_th]:font-semibold [&_th]:text-left
49
+ [&_td]:border [&_td]:border-border [&_td]:px-3 [&_td]:py-2 [&_td]:break-words
50
+ [&_tr:nth-child(even)]:bg-transparent
51
+
52
+ /* Horizontal rules */
53
+ [&_hr]:border-0 [&_hr]:border-t [&_hr]:border-border [&_hr]:my-6
54
+
55
+ /* Images */
56
+ [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded [&_img]:my-2 [&_img]:object-contain
57
+
58
+ ${e}
59
+ `.trim().replace(/\s+/g," "),uh=(e="")=>`
60
+ /* Buttons - "important" overrides for flow controls */
61
+ [&>button]:bg-[var(--color-background-w10)]
62
+ [&>button]:dark:!bg-[var(--color-background-w100)]
63
+ [&>button]:hover:bg-[var(--color-background-w20)]
64
+ [&>button]:dark:hover:!bg-[var(--color-primary-w60)]
65
+ [&>button]:text-[var(--color-primary-text-wMain)]
66
+ [&>button]:dark:text-[var(--color-primary-text-w10)]
67
+ [&>button]:!border
68
+ [&>button]:!border-[var(--color-secondary-w40)]
69
+ [&>button]:dark:!border-[var(--color-secondary-w70)]
70
+
71
+ ${e}
72
+ `.trim().replace(/\s+/g," ");function ge(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function dh(e,t){const n=u.createContext(t),r=s=>{const{children:i,...l}=s,c=u.useMemo(()=>l,Object.values(l));return a.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=u.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function kn(e,t=[]){let n=[];function r(s,i){const l=u.createContext(i),c=n.length;n=[...n,i];const d=p=>{var b;const{scope:m,children:g,...x}=p,h=((b=m==null?void 0:m[e])==null?void 0:b[c])||l,v=u.useMemo(()=>x,Object.values(x));return a.jsx(h.Provider,{value:v,children:g})};d.displayName=s+"Provider";function f(p,m){var h;const g=((h=m==null?void 0:m[e])==null?void 0:h[c])||l,x=u.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[d,f]}const o=()=>{const s=n.map(i=>u.createContext(i));return function(l){const c=(l==null?void 0:l[e])||s;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[r,fh(o,...t)]}function fh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((l,{useScope:c,scopeName:d})=>{const p=c(s)[`__scope${d}`];return{...l,...p}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var ph=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ke=ph.reduce((e,t)=>{const n=Dn(`Primitive.${t}`),r=u.forwardRef((o,s)=>{const{asChild:i,...l}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(c,{...l,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mh(e,t){e&&Wr.flushSync(()=>e.dispatchEvent(t))}function Cn(e){const t=u.useRef(e);return u.useEffect(()=>{t.current=e}),u.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function hh(e,t=globalThis==null?void 0:globalThis.document){const n=Cn(e);u.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var gh="DismissableLayer",Hs="dismissableLayer.update",xh="dismissableLayer.pointerDownOutside",vh="dismissableLayer.focusOutside",_a,vc=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Gr=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:l,...c}=e,d=u.useContext(vc),[f,p]=u.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=u.useState({}),x=$e(t,N=>p(N)),h=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=h.indexOf(v),w=f?h.indexOf(f):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,E=w>=b,A=yh(N=>{const T=N.target,G=[...d.branches].some(q=>q.contains(T));!E||G||(o==null||o(N),i==null||i(N),N.defaultPrevented||l==null||l())},m),j=Sh(N=>{const T=N.target;[...d.branches].some(q=>q.contains(T))||(s==null||s(N),i==null||i(N),N.defaultPrevented||l==null||l())},m);return hh(N=>{w===d.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&l&&(N.preventDefault(),l()))},m),u.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(_a=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Ia(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=_a)}},[f,m,n,d]),u.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Ia())},[f,d]),u.useEffect(()=>{const N=()=>g({});return document.addEventListener(Hs,N),()=>document.removeEventListener(Hs,N)},[]),a.jsx(ke.div,{...c,ref:x,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:ge(e.onFocusCapture,j.onFocusCapture),onBlurCapture:ge(e.onBlurCapture,j.onBlurCapture),onPointerDownCapture:ge(e.onPointerDownCapture,A.onPointerDownCapture)})});Gr.displayName=gh;var wh="DismissableLayerBranch",bh=u.forwardRef((e,t)=>{const n=u.useContext(vc),r=u.useRef(null),o=$e(t,r);return u.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),a.jsx(ke.div,{...e,ref:o})});bh.displayName=wh;function yh(e,t=globalThis==null?void 0:globalThis.document){const n=Cn(e),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){wc(xh,n,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Sh(e,t=globalThis==null?void 0:globalThis.document){const n=Cn(e),r=u.useRef(!1);return u.useEffect(()=>{const o=s=>{s.target&&!r.current&&wc(vh,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Ia(){const e=new CustomEvent(Hs);document.dispatchEvent(e)}function wc(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?mh(o,s):o.dispatchEvent(s)}var st=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},Ch=gi[" useId ".trim().toString()]||(()=>{}),Eh=0;function en(e){const[t,n]=u.useState(Ch());return st(()=>{n(r=>r??String(Eh++))},[e]),t?`radix-${t}`:""}const Th=["top","right","bottom","left"],En=Math.min,vt=Math.max,yo=Math.round,to=Math.floor,tn=e=>({x:e,y:e}),Ah={left:"right",right:"left",bottom:"top",top:"bottom"},Nh={start:"end",end:"start"};function Ws(e,t,n){return vt(e,En(t,n))}function mn(e,t){return typeof e=="function"?e(t):e}function hn(e){return e.split("-")[0]}function xr(e){return e.split("-")[1]}function Ei(e){return e==="x"?"y":"x"}function Ti(e){return e==="y"?"height":"width"}const kh=new Set(["top","bottom"]);function Jt(e){return kh.has(hn(e))?"y":"x"}function Ai(e){return Ei(Jt(e))}function _h(e,t,n){n===void 0&&(n=!1);const r=xr(e),o=Ai(e),s=Ti(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=So(i)),[i,So(i)]}function Ih(e){const t=So(e);return[Gs(e),t,Gs(t)]}function Gs(e){return e.replace(/start|end/g,t=>Nh[t])}const ja=["left","right"],Ra=["right","left"],jh=["top","bottom"],Rh=["bottom","top"];function Mh(e,t,n){switch(e){case"top":case"bottom":return n?t?Ra:ja:t?ja:Ra;case"left":case"right":return t?jh:Rh;default:return[]}}function Ph(e,t,n,r){const o=xr(e);let s=Mh(hn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Gs)))),s}function So(e){return e.replace(/left|right|bottom|top/g,t=>Ah[t])}function Lh(e){return{top:0,right:0,bottom:0,left:0,...e}}function bc(e){return typeof e!="number"?Lh(e):{top:e,right:e,bottom:e,left:e}}function Co(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ma(e,t,n){let{reference:r,floating:o}=e;const s=Jt(t),i=Ai(t),l=Ti(i),c=hn(t),d=s==="y",f=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let g;switch(c){case"top":g={x:f,y:r.y-o.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:p};break;case"left":g={x:r.x-o.width,y:p};break;default:g={x:r.x,y:r.y}}switch(xr(t)){case"start":g[i]-=m*(n&&d?-1:1);break;case"end":g[i]+=m*(n&&d?-1:1);break}return g}const Dh=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,l=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:p}=Ma(d,r,c),m=r,g={},x=0;for(let h=0;h<l.length;h++){const{name:v,fn:b}=l[h],{x:w,y,data:E,reset:A}=await b({x:f,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});f=w??f,p=y??p,g={...g,[v]:{...g[v],...E}},A&&x<=50&&(x++,typeof A=="object"&&(A.placement&&(m=A.placement),A.rects&&(d=A.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):A.rects),{x:f,y:p}=Ma(d,m,c)),h=-1)}return{x:f,y:p,placement:m,strategy:o,middlewareData:g}};async function Lr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:m=!1,padding:g=0}=mn(t,e),x=bc(g),v=l[m?p==="floating"?"reference":"floating":p],b=Co(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},A=Co(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:y,strategy:c}):w);return{top:(b.top-A.top+x.top)/E.y,bottom:(A.bottom-b.bottom+x.bottom)/E.y,left:(b.left-A.left+x.left)/E.x,right:(A.right-b.right+x.right)/E.x}}const Oh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=mn(e,t)||{};if(d==null)return{};const p=bc(f),m={x:n,y:r},g=Ai(o),x=Ti(g),h=await i.getDimensions(d),v=g==="y",b=v?"top":"left",w=v?"bottom":"right",y=v?"clientHeight":"clientWidth",E=s.reference[x]+s.reference[g]-m[g]-s.floating[x],A=m[g]-s.reference[g],j=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let N=j?j[y]:0;(!N||!await(i.isElement==null?void 0:i.isElement(j)))&&(N=l.floating[y]||s.floating[x]);const T=E/2-A/2,G=N/2-h[x]/2-1,q=En(p[b],G),W=En(p[w],G),X=q,ee=N-h[x]-W,O=N/2-h[x]/2+T,Y=Ws(X,O,ee),k=!c.arrow&&xr(o)!=null&&O!==Y&&s.reference[x]/2-(O<X?q:W)-h[x]/2<0,$=k?O<X?O-X:O-ee:0;return{[g]:m[g]+$,data:{[g]:Y,centerOffset:O-Y-$,...k&&{alignmentOffset:$}},reset:k}}}),Fh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:h=!0,...v}=mn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=hn(o),w=Jt(l),y=hn(l)===l,E=await(c.isRTL==null?void 0:c.isRTL(d.floating)),A=m||(y||!h?[So(l)]:Ih(l)),j=x!=="none";!m&&j&&A.push(...Ph(l,h,x,E));const N=[l,...A],T=await Lr(t,v),G=[];let q=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&G.push(T[b]),p){const O=_h(o,i,E);G.push(T[O[0]],T[O[1]])}if(q=[...q,{placement:o,overflows:G}],!G.every(O=>O<=0)){var W,X;const O=(((W=s.flip)==null?void 0:W.index)||0)+1,Y=N[O];if(Y&&(!(p==="alignment"?w!==Jt(Y):!1)||q.every(C=>Jt(C.placement)===w?C.overflows[0]>0:!0)))return{data:{index:O,overflows:q},reset:{placement:Y}};let k=(X=q.filter($=>$.overflows[0]<=0).sort(($,C)=>$.overflows[1]-C.overflows[1])[0])==null?void 0:X.placement;if(!k)switch(g){case"bestFit":{var ee;const $=(ee=q.filter(C=>{if(j){const _=Jt(C.placement);return _===w||_==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(_=>_>0).reduce((_,L)=>_+L,0)]).sort((C,_)=>C[1]-_[1])[0])==null?void 0:ee[0];$&&(k=$);break}case"initialPlacement":k=l;break}if(o!==k)return{reset:{placement:k}}}return{}}}};function Pa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function La(e){return Th.some(t=>e[t]>=0)}const zh=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=mn(e,t);switch(r){case"referenceHidden":{const s=await Lr(t,{...o,elementContext:"reference"}),i=Pa(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:La(i)}}}case"escaped":{const s=await Lr(t,{...o,altBoundary:!0}),i=Pa(s,n.floating);return{data:{escapedOffsets:i,escaped:La(i)}}}default:return{}}}}},yc=new Set(["left","top"]);async function $h(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=hn(n),l=xr(n),c=Jt(n)==="y",d=yc.has(i)?-1:1,f=s&&c?-1:1,p=mn(t,e);let{mainAxis:m,crossAxis:g,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof x=="number"&&(g=l==="end"?x*-1:x),c?{x:g*f,y:m*d}:{x:m*d,y:g*f}}const Bh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:l}=t,c=await $h(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},Uh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:v=>{let{x:b,y:w}=v;return{x:b,y:w}}},...c}=mn(e,t),d={x:n,y:r},f=await Lr(t,c),p=Jt(hn(o)),m=Ei(p);let g=d[m],x=d[p];if(s){const v=m==="y"?"top":"left",b=m==="y"?"bottom":"right",w=g+f[v],y=g-f[b];g=Ws(w,g,y)}if(i){const v=p==="y"?"top":"left",b=p==="y"?"bottom":"right",w=x+f[v],y=x-f[b];x=Ws(w,x,y)}const h=l.fn({...t,[m]:g,[p]:x});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[p]:i}}}}}},Hh=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=mn(e,t),f={x:n,y:r},p=Jt(o),m=Ei(p);let g=f[m],x=f[p];const h=mn(l,t),v=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const y=m==="y"?"height":"width",E=s.reference[m]-s.floating[y]+v.mainAxis,A=s.reference[m]+s.reference[y]-v.mainAxis;g<E?g=E:g>A&&(g=A)}if(d){var b,w;const y=m==="y"?"width":"height",E=yc.has(hn(o)),A=s.reference[p]-s.floating[y]+(E&&((b=i.offset)==null?void 0:b[p])||0)+(E?0:v.crossAxis),j=s.reference[p]+s.reference[y]+(E?0:((w=i.offset)==null?void 0:w[p])||0)-(E?v.crossAxis:0);x<A?x=A:x>j&&(x=j)}return{[m]:g,[p]:x}}}},Wh=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:l}=t,{apply:c=()=>{},...d}=mn(e,t),f=await Lr(t,d),p=hn(o),m=xr(o),g=Jt(o)==="y",{width:x,height:h}=s.floating;let v,b;p==="top"||p==="bottom"?(v=p,b=m===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=p,v=m==="end"?"top":"bottom");const w=h-f.top-f.bottom,y=x-f.left-f.right,E=En(h-f[v],w),A=En(x-f[b],y),j=!t.middlewareData.shift;let N=E,T=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=w),j&&!m){const q=vt(f.left,0),W=vt(f.right,0),X=vt(f.top,0),ee=vt(f.bottom,0);g?T=x-2*(q!==0||W!==0?q+W:vt(f.left,f.right)):N=h-2*(X!==0||ee!==0?X+ee:vt(f.top,f.bottom))}await c({...t,availableWidth:T,availableHeight:N});const G=await i.getDimensions(l.floating);return x!==G.width||h!==G.height?{reset:{rects:!0}}:{}}}};function Do(){return typeof window<"u"}function vr(e){return Sc(e)?(e.nodeName||"").toLowerCase():"#document"}function bt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function on(e){var t;return(t=(Sc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Sc(e){return Do()?e instanceof Node||e instanceof bt(e).Node:!1}function Gt(e){return Do()?e instanceof Element||e instanceof bt(e).Element:!1}function rn(e){return Do()?e instanceof HTMLElement||e instanceof bt(e).HTMLElement:!1}function Da(e){return!Do()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof bt(e).ShadowRoot}const Gh=new Set(["inline","contents"]);function Vr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Vt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Gh.has(o)}const Vh=new Set(["table","td","th"]);function Yh(e){return Vh.has(vr(e))}const Kh=[":popover-open",":modal"];function Oo(e){return Kh.some(t=>{try{return e.matches(t)}catch{return!1}})}const qh=["transform","translate","scale","rotate","perspective"],Xh=["transform","translate","scale","rotate","perspective","filter"],Zh=["paint","layout","strict","content"];function Ni(e){const t=ki(),n=Gt(e)?Vt(e):e;return qh.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Xh.some(r=>(n.willChange||"").includes(r))||Zh.some(r=>(n.contain||"").includes(r))}function Jh(e){let t=Tn(e);for(;rn(t)&&!lr(t);){if(Ni(t))return t;if(Oo(t))return null;t=Tn(t)}return null}function ki(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Qh=new Set(["html","body","#document"]);function lr(e){return Qh.has(vr(e))}function Vt(e){return bt(e).getComputedStyle(e)}function Fo(e){return Gt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Da(e)&&e.host||on(e);return Da(t)?t.host:t}function Cc(e){const t=Tn(e);return lr(t)?e.ownerDocument?e.ownerDocument.body:e.body:rn(t)&&Vr(t)?t:Cc(t)}function Dr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Cc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=bt(o);if(s){const l=Vs(i);return t.concat(i,i.visualViewport||[],Vr(o)?o:[],l&&n?Dr(l):[])}return t.concat(o,Dr(o,[],n))}function Vs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ec(e){const t=Vt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=rn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=yo(n)!==s||yo(r)!==i;return l&&(n=s,r=i),{width:n,height:r,$:l}}function _i(e){return Gt(e)?e:e.contextElement}function rr(e){const t=_i(e);if(!rn(t))return tn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Ec(t);let i=(s?yo(n.width):n.width)/r,l=(s?yo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const eg=tn(0);function Tc(e){const t=bt(e);return!ki()||!t.visualViewport?eg:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function tg(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==bt(e)?!1:t}function On(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=_i(e);let i=tn(1);t&&(r?Gt(r)&&(i=rr(r)):i=rr(e));const l=tg(s,n,r)?Tc(s):tn(0);let c=(o.left+l.x)/i.x,d=(o.top+l.y)/i.y,f=o.width/i.x,p=o.height/i.y;if(s){const m=bt(s),g=r&&Gt(r)?bt(r):r;let x=m,h=Vs(x);for(;h&&r&&g!==x;){const v=rr(h),b=h.getBoundingClientRect(),w=Vt(h),y=b.left+(h.clientLeft+parseFloat(w.paddingLeft))*v.x,E=b.top+(h.clientTop+parseFloat(w.paddingTop))*v.y;c*=v.x,d*=v.y,f*=v.x,p*=v.y,c+=y,d+=E,x=bt(h),h=Vs(x)}}return Co({width:f,height:p,x:c,y:d})}function zo(e,t){const n=Fo(e).scrollLeft;return t?t.left+n:On(on(e)).left+n}function Ac(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-zo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ng(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=on(r),l=t?Oo(t.floating):!1;if(r===i||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=tn(1);const f=tn(0),p=rn(r);if((p||!p&&!s)&&((vr(r)!=="body"||Vr(i))&&(c=Fo(r)),rn(r))){const g=On(r);d=rr(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const m=i&&!p&&!s?Ac(i,c):tn(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+m.x,y:n.y*d.y-c.scrollTop*d.y+f.y+m.y}}function rg(e){return Array.from(e.getClientRects())}function og(e){const t=on(e),n=Fo(e),r=e.ownerDocument.body,o=vt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=vt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+zo(e);const l=-n.scrollTop;return Vt(r).direction==="rtl"&&(i+=vt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:l}}const Oa=25;function sg(e,t){const n=bt(e),r=on(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,l=0,c=0;if(o){s=o.width,i=o.height;const f=ki();(!f||f&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const d=zo(r);if(d<=0){const f=r.ownerDocument,p=f.body,m=getComputedStyle(p),g=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-g);x<=Oa&&(s-=x)}else d<=Oa&&(s+=d);return{width:s,height:i,x:l,y:c}}const ig=new Set(["absolute","fixed"]);function ag(e,t){const n=On(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=rn(e)?rr(e):tn(1),i=e.clientWidth*s.x,l=e.clientHeight*s.y,c=o*s.x,d=r*s.y;return{width:i,height:l,x:c,y:d}}function Fa(e,t,n){let r;if(t==="viewport")r=sg(e,n);else if(t==="document")r=og(on(e));else if(Gt(t))r=ag(t,n);else{const o=Tc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Co(r)}function Nc(e,t){const n=Tn(e);return n===t||!Gt(n)||lr(n)?!1:Vt(n).position==="fixed"||Nc(n,t)}function lg(e,t){const n=t.get(e);if(n)return n;let r=Dr(e,[],!1).filter(l=>Gt(l)&&vr(l)!=="body"),o=null;const s=Vt(e).position==="fixed";let i=s?Tn(e):e;for(;Gt(i)&&!lr(i);){const l=Vt(i),c=Ni(i);!c&&l.position==="fixed"&&(o=null),(s?!c&&!o:!c&&l.position==="static"&&!!o&&ig.has(o.position)||Vr(i)&&!c&&Nc(e,i))?r=r.filter(f=>f!==i):o=l,i=Tn(i)}return t.set(e,r),r}function cg(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Oo(t)?[]:lg(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((d,f)=>{const p=Fa(t,f,o);return d.top=vt(p.top,d.top),d.right=En(p.right,d.right),d.bottom=En(p.bottom,d.bottom),d.left=vt(p.left,d.left),d},Fa(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function ug(e){const{width:t,height:n}=Ec(e);return{width:t,height:n}}function dg(e,t,n){const r=rn(t),o=on(t),s=n==="fixed",i=On(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=tn(0);function d(){c.x=zo(o)}if(r||!r&&!s)if((vr(t)!=="body"||Vr(o))&&(l=Fo(t)),r){const g=On(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&d();s&&!r&&o&&d();const f=o&&!r&&!s?Ac(o,l):tn(0),p=i.left+l.scrollLeft-c.x-f.x,m=i.top+l.scrollTop-c.y-f.y;return{x:p,y:m,width:i.width,height:i.height}}function ms(e){return Vt(e).position==="static"}function za(e,t){if(!rn(e)||Vt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return on(e)===n&&(n=n.ownerDocument.body),n}function kc(e,t){const n=bt(e);if(Oo(e))return n;if(!rn(e)){let o=Tn(e);for(;o&&!lr(o);){if(Gt(o)&&!ms(o))return o;o=Tn(o)}return n}let r=za(e,t);for(;r&&Yh(r)&&ms(r);)r=za(r,t);return r&&lr(r)&&ms(r)&&!Ni(r)?n:r||Jh(e)||n}const fg=async function(e){const t=this.getOffsetParent||kc,n=this.getDimensions,r=await n(e.floating);return{reference:dg(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pg(e){return Vt(e).direction==="rtl"}const mg={convertOffsetParentRelativeRectToViewportRelativeRect:ng,getDocumentElement:on,getClippingRect:cg,getOffsetParent:kc,getElementRects:fg,getClientRects:rg,getDimensions:ug,getScale:rr,isElement:Gt,isRTL:pg};function _c(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function hg(e,t){let n=null,r;const o=on(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=e.getBoundingClientRect(),{left:f,top:p,width:m,height:g}=d;if(l||t(),!m||!g)return;const x=to(p),h=to(o.clientWidth-(f+m)),v=to(o.clientHeight-(p+g)),b=to(f),y={rootMargin:-x+"px "+-h+"px "+-v+"px "+-b+"px",threshold:vt(0,En(1,c))||1};let E=!0;function A(j){const N=j[0].intersectionRatio;if(N!==c){if(!E)return i();N?i(!1,N):r=setTimeout(()=>{i(!1,1e-7)},1e3)}N===1&&!_c(d,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(A,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(A,y)}n.observe(e)}return i(!0),s}function gg(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=_i(e),f=o||s?[...d?Dr(d):[],...Dr(t)]:[];f.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const p=d&&l?hg(d,n):null;let m=-1,g=null;i&&(g=new ResizeObserver(b=>{let[w]=b;w&&w.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=g)==null||y.observe(t)})),n()}),d&&!c&&g.observe(d),g.observe(t));let x,h=c?On(e):null;c&&v();function v(){const b=On(e);h&&!_c(h,b)&&n(),h=b,x=requestAnimationFrame(v)}return n(),()=>{var b;f.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(b=g)==null||b.disconnect(),g=null,c&&cancelAnimationFrame(x)}}const xg=Bh,vg=Uh,wg=Fh,bg=Wh,yg=zh,$a=Oh,Sg=Hh,Cg=(e,t,n)=>{const r=new Map,o={platform:mg,...n},s={...o.platform,_c:r};return Dh(e,t,{...o,platform:s})};var Eg=typeof document<"u",Tg=function(){},go=Eg?u.useLayoutEffect:Tg;function Eo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Eo(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Eo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ic(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ba(e,t){const n=Ic(e);return Math.round(t*n)/n}function hs(e){const t=u.useRef(e);return go(()=>{t.current=e}),t}function Ag(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,p]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,g]=u.useState(r);Eo(m,r)||g(r);const[x,h]=u.useState(null),[v,b]=u.useState(null),w=u.useCallback(C=>{C!==j.current&&(j.current=C,h(C))},[]),y=u.useCallback(C=>{C!==N.current&&(N.current=C,b(C))},[]),E=s||x,A=i||v,j=u.useRef(null),N=u.useRef(null),T=u.useRef(f),G=c!=null,q=hs(c),W=hs(o),X=hs(d),ee=u.useCallback(()=>{if(!j.current||!N.current)return;const C={placement:t,strategy:n,middleware:m};W.current&&(C.platform=W.current),Cg(j.current,N.current,C).then(_=>{const L={..._,isPositioned:X.current!==!1};O.current&&!Eo(T.current,L)&&(T.current=L,Wr.flushSync(()=>{p(L)}))})},[m,t,n,W,X]);go(()=>{d===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,p(C=>({...C,isPositioned:!1})))},[d]);const O=u.useRef(!1);go(()=>(O.current=!0,()=>{O.current=!1}),[]),go(()=>{if(E&&(j.current=E),A&&(N.current=A),E&&A){if(q.current)return q.current(E,A,ee);ee()}},[E,A,ee,q,G]);const Y=u.useMemo(()=>({reference:j,floating:N,setReference:w,setFloating:y}),[w,y]),k=u.useMemo(()=>({reference:E,floating:A}),[E,A]),$=u.useMemo(()=>{const C={position:n,left:0,top:0};if(!k.floating)return C;const _=Ba(k.floating,f.x),L=Ba(k.floating,f.y);return l?{...C,transform:"translate("+_+"px, "+L+"px)",...Ic(k.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:L}},[n,l,k.floating,f.x,f.y]);return u.useMemo(()=>({...f,update:ee,refs:Y,elements:k,floatingStyles:$}),[f,ee,Y,k,$])}const Ng=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?$a({element:r.current,padding:o}).fn(n):{}:r?$a({element:r,padding:o}).fn(n):{}}}},kg=(e,t)=>({...xg(e),options:[e,t]}),_g=(e,t)=>({...vg(e),options:[e,t]}),Ig=(e,t)=>({...Sg(e),options:[e,t]}),jg=(e,t)=>({...wg(e),options:[e,t]}),Rg=(e,t)=>({...bg(e),options:[e,t]}),Mg=(e,t)=>({...yg(e),options:[e,t]}),Pg=(e,t)=>({...Ng(e),options:[e,t]});var Lg="Arrow",jc=u.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return a.jsx(ke.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:a.jsx("polygon",{points:"0,0 30,0 15,10"})})});jc.displayName=Lg;var Dg=jc;function Og(e){const[t,n]=u.useState(void 0);return st(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,l;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;i=d.inlineSize,l=d.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ii="Popper",[Rc,wr]=kn(Ii),[Fg,Mc]=Rc(Ii),Pc=e=>{const{__scopePopper:t,children:n}=e,[r,o]=u.useState(null);return a.jsx(Fg,{scope:t,anchor:r,onAnchorChange:o,children:n})};Pc.displayName=Ii;var Lc="PopperAnchor",Dc=u.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Mc(Lc,n),i=u.useRef(null),l=$e(t,i),c=u.useRef(null);return u.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||i.current,d!==c.current&&s.onAnchorChange(c.current)}),r?null:a.jsx(ke.div,{...o,ref:l})});Dc.displayName=Lc;var ji="PopperContent",[zg,$g]=Rc(ji),Oc=u.forwardRef((e,t)=>{var I,V,Q,te,ae,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:x,...h}=e,v=Mc(ji,n),[b,w]=u.useState(null),y=$e(t,pe=>w(pe)),[E,A]=u.useState(null),j=Og(E),N=(j==null?void 0:j.width)??0,T=(j==null?void 0:j.height)??0,G=r+(s!=="center"?"-"+s:""),q=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},W=Array.isArray(d)?d:[d],X=W.length>0,ee={padding:q,boundary:W.filter(Ug),altBoundary:X},{refs:O,floatingStyles:Y,placement:k,isPositioned:$,middlewareData:C}=Ag({strategy:"fixed",placement:G,whileElementsMounted:(...pe)=>gg(...pe,{animationFrame:g==="always"}),elements:{reference:v.anchor},middleware:[kg({mainAxis:o+T,alignmentAxis:i}),c&&_g({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Ig():void 0,...ee}),c&&jg({...ee}),Rg({...ee,apply:({elements:pe,rects:ye,availableWidth:_e,availableHeight:Ie})=>{const{width:Pe,height:Re}=ye.reference,Be=pe.floating.style;Be.setProperty("--radix-popper-available-width",`${_e}px`),Be.setProperty("--radix-popper-available-height",`${Ie}px`),Be.setProperty("--radix-popper-anchor-width",`${Pe}px`),Be.setProperty("--radix-popper-anchor-height",`${Re}px`)}}),E&&Pg({element:E,padding:l}),Hg({arrowWidth:N,arrowHeight:T}),m&&Mg({strategy:"referenceHidden",...ee})]}),[_,L]=$c(k),R=Cn(x);st(()=>{$&&(R==null||R())},[$,R]);const J=(I=C.arrow)==null?void 0:I.x,P=(V=C.arrow)==null?void 0:V.y,B=((Q=C.arrow)==null?void 0:Q.centerOffset)!==0,[D,U]=u.useState();return st(()=>{b&&U(window.getComputedStyle(b).zIndex)},[b]),a.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:$?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:D,"--radix-popper-transform-origin":[(te=C.transformOrigin)==null?void 0:te.x,(ae=C.transformOrigin)==null?void 0:ae.y].join(" "),...((se=C.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:a.jsx(zg,{scope:n,placedSide:_,onArrowChange:A,arrowX:J,arrowY:P,shouldHideArrow:B,children:a.jsx(ke.div,{"data-side":_,"data-align":L,...h,ref:y,style:{...h.style,animation:$?void 0:"none"}})})})});Oc.displayName=ji;var Fc="PopperArrow",Bg={top:"bottom",right:"left",bottom:"top",left:"right"},zc=u.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=$g(Fc,r),i=Bg[s.placedSide];return a.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:a.jsx(Dg,{...o,ref:n,style:{...o.style,display:"block"}})})});zc.displayName=Fc;function Ug(e){return e!==null}var Hg=e=>({name:"transformOrigin",options:e,fn(t){var v,b,w;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[d,f]=$c(n),p={start:"0%",center:"50%",end:"100%"}[f],m=(((b=o.arrow)==null?void 0:b.x)??0)+l/2,g=(((w=o.arrow)==null?void 0:w.y)??0)+c/2;let x="",h="";return d==="bottom"?(x=i?p:`${m}px`,h=`${-c}px`):d==="top"?(x=i?p:`${m}px`,h=`${r.floating.height+c}px`):d==="right"?(x=`${-c}px`,h=i?p:`${g}px`):d==="left"&&(x=`${r.floating.width+c}px`,h=i?p:`${g}px`),{data:{x,y:h}}}});function $c(e){const[t,n="center"]=e.split("-");return[t,n]}var Ri=Pc,$o=Dc,Mi=Oc,Pi=zc,Wg="Portal",Yr=u.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,s]=u.useState(!1);st(()=>s(!0),[]);const i=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?Pp.createPortal(a.jsx(ke.div,{...r,ref:t}),i):null});Yr.displayName=Wg;function Gg(e,t){return u.useReducer((n,r)=>t[n][r]??n,e)}var xn=e=>{const{present:t,children:n}=e,r=Vg(t),o=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),s=$e(r.ref,Yg(o));return typeof n=="function"||r.isPresent?u.cloneElement(o,{ref:s}):null};xn.displayName="Presence";function Vg(e){const[t,n]=u.useState(),r=u.useRef(null),o=u.useRef(e),s=u.useRef("none"),i=e?"mounted":"unmounted",[l,c]=Gg(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=no(r.current);s.current=l==="mounted"?d:"none"},[l]),st(()=>{const d=r.current,f=o.current;if(f!==e){const m=s.current,g=no(d);e?c("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(f&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),st(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,p=g=>{const h=no(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&h&&(c("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=g=>{g.target===t&&(s.current=no(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function no(e){return(e==null?void 0:e.animationName)||"none"}function Yg(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Kg=gi[" useInsertionEffect ".trim().toString()]||st;function Fn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=qg({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const f=u.useRef(e!==void 0);u.useEffect(()=>{const p=f.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,r])}const d=u.useCallback(f=>{var p;if(l){const m=Xg(f)?f(e):f;m!==e&&((p=i.current)==null||p.call(i,m))}else s(f)},[l,e,s,i]);return[c,d]}function qg({defaultProp:e,onChange:t}){const[n,r]=u.useState(e),o=u.useRef(n),s=u.useRef(t);return Kg(()=>{s.current=t},[t]),u.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Xg(e){return typeof e=="function"}var Bc=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Zg="VisuallyHidden",Uc=u.forwardRef((e,t)=>a.jsx(ke.span,{...e,ref:t,style:{...Bc,...e.style}}));Uc.displayName=Zg;var Jg=Uc,[Bo]=kn("Tooltip",[wr]),Uo=wr(),Hc="TooltipProvider",Qg=700,Ys="tooltip.open",[ex,Li]=Bo(Hc),Wc=e=>{const{__scopeTooltip:t,delayDuration:n=Qg,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=u.useRef(!0),l=u.useRef(!1),c=u.useRef(0);return u.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),a.jsx(ex,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:u.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:u.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:s})};Wc.displayName=Hc;var Or="Tooltip",[tx,Kr]=Bo(Or),Gc=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:l}=e,c=Li(Or,e.__scopeTooltip),d=Uo(t),[f,p]=u.useState(null),m=en(),g=u.useRef(0),x=i??c.disableHoverableContent,h=l??c.delayDuration,v=u.useRef(!1),[b,w]=Fn({prop:r,defaultProp:o??!1,onChange:N=>{N?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ys))):c.onClose(),s==null||s(N)},caller:Or}),y=u.useMemo(()=>b?v.current?"delayed-open":"instant-open":"closed",[b]),E=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,v.current=!1,w(!0)},[w]),A=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,w(!1)},[w]),j=u.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{v.current=!0,w(!0),g.current=0},h)},[h,w]);return u.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),a.jsx(Ri,{...d,children:a.jsx(tx,{scope:t,contentId:m,open:b,stateAttribute:y,trigger:f,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?j():E()},[c.isOpenDelayedRef,j,E]),onTriggerLeave:u.useCallback(()=>{x?A():(window.clearTimeout(g.current),g.current=0)},[A,x]),onOpen:E,onClose:A,disableHoverableContent:x,children:n})})};Gc.displayName=Or;var Ks="TooltipTrigger",Vc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Kr(Ks,n),s=Li(Ks,n),i=Uo(n),l=u.useRef(null),c=$e(t,l,o.onTriggerChange),d=u.useRef(!1),f=u.useRef(!1),p=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),a.jsx($o,{asChild:!0,...i,children:a.jsx(ke.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:ge(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:ge(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:ge(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ge(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:ge(e.onBlur,o.onClose),onClick:ge(e.onClick,o.onClose)})})});Vc.displayName=Ks;var Di="TooltipPortal",[nx,rx]=Bo(Di,{forceMount:void 0}),Yc=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=Kr(Di,t);return a.jsx(nx,{scope:t,forceMount:n,children:a.jsx(xn,{present:n||s.open,children:a.jsx(Yr,{asChild:!0,container:o,children:r})})})};Yc.displayName=Di;var cr="TooltipContent",Kc=u.forwardRef((e,t)=>{const n=rx(cr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Kr(cr,e.__scopeTooltip);return a.jsx(xn,{present:r||i.open,children:i.disableHoverableContent?a.jsx(qc,{side:o,...s,ref:t}):a.jsx(ox,{side:o,...s,ref:t})})}),ox=u.forwardRef((e,t)=>{const n=Kr(cr,e.__scopeTooltip),r=Li(cr,e.__scopeTooltip),o=u.useRef(null),s=$e(t,o),[i,l]=u.useState(null),{trigger:c,onClose:d}=n,f=o.current,{onPointerInTransitChange:p}=r,m=u.useCallback(()=>{l(null),p(!1)},[p]),g=u.useCallback((x,h)=>{const v=x.currentTarget,b={x:x.clientX,y:x.clientY},w=lx(b,v.getBoundingClientRect()),y=cx(b,w),E=ux(h.getBoundingClientRect()),A=fx([...y,...E]);l(A),p(!0)},[p]);return u.useEffect(()=>()=>m(),[m]),u.useEffect(()=>{if(c&&f){const x=v=>g(v,f),h=v=>g(v,c);return c.addEventListener("pointerleave",x),f.addEventListener("pointerleave",h),()=>{c.removeEventListener("pointerleave",x),f.removeEventListener("pointerleave",h)}}},[c,f,g,m]),u.useEffect(()=>{if(i){const x=h=>{const v=h.target,b={x:h.clientX,y:h.clientY},w=(c==null?void 0:c.contains(v))||(f==null?void 0:f.contains(v)),y=!dx(b,i);w?m():y&&(m(),d())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,f,i,d,m]),a.jsx(qc,{...e,ref:s})}),[sx,ix]=Bo(Or,{isInside:!1}),ax=wm("TooltipContent"),qc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...l}=e,c=Kr(cr,n),d=Uo(n),{onClose:f}=c;return u.useEffect(()=>(document.addEventListener(Ys,f),()=>document.removeEventListener(Ys,f)),[f]),u.useEffect(()=>{if(c.trigger){const p=m=>{const g=m.target;g!=null&&g.contains(c.trigger)&&f()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,f]),a.jsx(Gr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:a.jsxs(Mi,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[a.jsx(ax,{children:r}),a.jsx(sx,{scope:n,isInside:!0,children:a.jsx(Jg,{id:c.contentId,role:"tooltip",children:o||r})})]})})});Kc.displayName=cr;var Xc="TooltipArrow",Zc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Uo(n);return ix(Xc,n).isInside?null:a.jsx(Pi,{...o,...r,ref:t})});Zc.displayName=Xc;function lx(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function cx(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ux(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function dx(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const l=t[s],c=t[i],d=l.x,f=l.y,p=c.x,m=c.y;f>r!=m>r&&n<(p-d)*(r-f)/(m-f)+d&&(o=!o)}return o}function fx(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),px(t)}function px(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var mx=Wc,hx=Gc,gx=Vc,xx=Yc,vx=Kc,wx=Zc;function bx({delayDuration:e=0,...t}){return a.jsx(mx,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Oi({...e}){return a.jsx(bx,{delayDuration:500,children:a.jsx(hx,{"data-slot":"tooltip",...e})})}function Fi({...e}){return a.jsx(gx,{"data-slot":"tooltip-trigger",...e})}function zi({className:e,sideOffset:t=0,children:n,...r}){return a.jsx(xx,{children:a.jsxs(vx,{"data-slot":"tooltip-content",sideOffset:t,className:be("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,a.jsx(wx,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Jc="text-[var(--color-primary-wMain)] hover:text-[var(--color-primary-text-w60)] dark:text-[var(--color-primary-w20)] dark:hover:text-[var(--color-primary-text-w10)]",gs=Jc+" hover:bg-[var(--color-primary-w10)] dark:hover:bg-[var(--color-primary-w60)]",yx=Nn("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm font-semibold transition-all disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent",{variants:{variant:{default:"text-[var(--color-primary-text-w10)] bg-[var(--color-primary-wMain)] hover:bg-[var(--color-primary-w100)] dark:hover:bg-[var(--color-primary-w60)]",destructive:"text-[var(--color-primary-text-w10)] bg-[var(--color-error-wMain)] hover:bg-[var(--color-error-w70)]",outline:gs+" border border-1 border-[var(--color-primary-wMain)]",secondary:gs,ghost:gs,link:Jc+" underline-offset-4 hover:underline"},size:{default:"h-9 px-5 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function xe({className:e,variant:t,size:n,asChild:r=!1,tooltip:o="",testid:s="",...i}){const l=r?oc:"button",c=o?{...i,"aria-label":o}:i,d=a.jsx(l,{"data-slot":"button","data-testid":s||o||i.title,className:be(yx({variant:t,size:n,className:e})),...c});return o?a.jsxs(Oi,{children:[a.jsx(Fi,{asChild:!0,children:d}),a.jsx(zi,{children:o})]}):d}const Qc=({onClick:e,text:t="View Agent Workflow"})=>a.jsx(xe,{variant:"ghost",size:"sm",onClick:e,tooltip:t,children:a.jsx(ho,{className:"h-4 w-4"})}),eu=u.forwardRef(({className:e,...t},n)=>a.jsx("textarea",{className:be("flex min-h-[80px] w-full rounded-md border px-3 py-2 placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));eu.displayName="Textarea";var xs="focusScope.autoFocusOnMount",vs="focusScope.autoFocusOnUnmount",Ua={bubbles:!1,cancelable:!0},Sx="FocusScope",Ho=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[l,c]=u.useState(null),d=Cn(o),f=Cn(s),p=u.useRef(null),m=$e(t,h=>c(h)),g=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let h=function(y){if(g.paused||!l)return;const E=y.target;l.contains(E)?p.current=E:wn(p.current,{select:!0})},v=function(y){if(g.paused||!l)return;const E=y.relatedTarget;E!==null&&(l.contains(E)||wn(p.current,{select:!0}))},b=function(y){if(document.activeElement===document.body)for(const A of y)A.removedNodes.length>0&&wn(l)};document.addEventListener("focusin",h),document.addEventListener("focusout",v);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",v),w.disconnect()}}},[r,l,g.paused]),u.useEffect(()=>{if(l){Wa.add(g);const h=document.activeElement;if(!l.contains(h)){const b=new CustomEvent(xs,Ua);l.addEventListener(xs,d),l.dispatchEvent(b),b.defaultPrevented||(Cx(kx(tu(l)),{select:!0}),document.activeElement===h&&wn(l))}return()=>{l.removeEventListener(xs,d),setTimeout(()=>{const b=new CustomEvent(vs,Ua);l.addEventListener(vs,f),l.dispatchEvent(b),b.defaultPrevented||wn(h??document.body,{select:!0}),l.removeEventListener(vs,f),Wa.remove(g)},0)}}},[l,d,f,g]);const x=u.useCallback(h=>{if(!n&&!r||g.paused)return;const v=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,b=document.activeElement;if(v&&b){const w=h.currentTarget,[y,E]=Ex(w);y&&E?!h.shiftKey&&b===E?(h.preventDefault(),n&&wn(y,{select:!0})):h.shiftKey&&b===y&&(h.preventDefault(),n&&wn(E,{select:!0})):b===w&&h.preventDefault()}},[n,r,g.paused]);return a.jsx(ke.div,{tabIndex:-1,...i,ref:m,onKeyDown:x})});Ho.displayName=Sx;function Cx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(wn(r,{select:t}),document.activeElement!==n)return}function Ex(e){const t=tu(e),n=Ha(t,e),r=Ha(t.reverse(),e);return[n,r]}function tu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ha(e,t){for(const n of e)if(!Tx(n,{upTo:t}))return n}function Tx(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ax(e){return e instanceof HTMLInputElement&&"select"in e}function wn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ax(e)&&t&&e.select()}}var Wa=Nx();function Nx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ga(e,t),e.unshift(t)},remove(t){var n;e=Ga(e,t),(n=e[0])==null||n.resume()}}}function Ga(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function kx(e){return e.filter(t=>t.tagName!=="A")}var ws=0;function $i(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Va()),document.body.insertAdjacentElement("beforeend",e[1]??Va()),ws++,()=>{ws===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ws--}},[])}function Va(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Zt=function(){return Zt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Zt.apply(this,arguments)};function nu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function _x(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var xo="right-scroll-bar-position",vo="width-before-scroll-bar",Ix="with-scroll-bars-hidden",jx="--removed-body-scroll-bar-size";function bs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Rx(e,t){var n=u.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Mx=typeof window<"u"?u.useLayoutEffect:u.useEffect,Ya=new WeakMap;function Px(e,t){var n=Rx(null,function(r){return e.forEach(function(o){return bs(o,r)})});return Mx(function(){var r=Ya.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(l){s.has(l)||bs(l,null)}),s.forEach(function(l){o.has(l)||bs(l,i)})}Ya.set(n,e)},[e]),n}function Lx(e){return e}function Dx(e,t){t===void 0&&(t=Lx);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(s),i=n}var c=function(){var f=i;i=[],f.forEach(s)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(f){i.push(f),d()},filter:function(f){return i=i.filter(f),n}}}};return o}function Ox(e){e===void 0&&(e={});var t=Dx(null);return t.options=Zt({async:!0,ssr:!1},e),t}var ru=function(e){var t=e.sideCar,n=nu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,Zt({},n))};ru.isSideCarExport=!0;function Fx(e,t){return e.useMedium(t),ru}var ou=Ox(),ys=function(){},Wo=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:ys,onWheelCapture:ys,onTouchMoveCapture:ys}),o=r[0],s=r[1],i=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,f=e.enabled,p=e.shards,m=e.sideCar,g=e.noRelative,x=e.noIsolation,h=e.inert,v=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,y=e.gapMode,E=nu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=m,j=Px([n,t]),N=Zt(Zt({},E),o);return u.createElement(u.Fragment,null,f&&u.createElement(A,{sideCar:ou,removeScrollBar:d,shards:p,noRelative:g,noIsolation:x,inert:h,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:y}),i?u.cloneElement(u.Children.only(l),Zt(Zt({},N),{ref:j})):u.createElement(w,Zt({},N,{className:c,ref:j}),l))});Wo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Wo.classNames={fullWidth:vo,zeroRight:xo};var zx=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function $x(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=zx();return t&&e.setAttribute("nonce",t),e}function Bx(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ux(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Hx=function(){var e=0,t=null;return{add:function(n){e==0&&(t=$x())&&(Bx(t,n),Ux(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wx=function(){var e=Hx();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},su=function(){var e=Wx(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Gx={left:0,top:0,right:0,gap:0},Ss=function(e){return parseInt(e||"",10)||0},Vx=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Ss(n),Ss(r),Ss(o)]},Yx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gx;var t=Vx(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Kx=su(),or="data-scroll-locked",qx=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
73
+ .`.concat(Ix,` {
74
+ overflow: hidden `).concat(r,`;
75
+ padding-right: `).concat(l,"px ").concat(r,`;
76
+ }
77
+ body[`).concat(or,`] {
78
+ overflow: hidden `).concat(r,`;
79
+ overscroll-behavior: contain;
80
+ `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
81
+ padding-left: `.concat(o,`px;
82
+ padding-top: `).concat(s,`px;
83
+ padding-right: `).concat(i,`px;
84
+ margin-left:0;
85
+ margin-top:0;
86
+ margin-right: `).concat(l,"px ").concat(r,`;
87
+ `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
88
+ }
89
+
90
+ .`).concat(xo,` {
91
+ right: `).concat(l,"px ").concat(r,`;
92
+ }
93
+
94
+ .`).concat(vo,` {
95
+ margin-right: `).concat(l,"px ").concat(r,`;
96
+ }
97
+
98
+ .`).concat(xo," .").concat(xo,` {
99
+ right: 0 `).concat(r,`;
100
+ }
101
+
102
+ .`).concat(vo," .").concat(vo,` {
103
+ margin-right: 0 `).concat(r,`;
104
+ }
105
+
106
+ body[`).concat(or,`] {
107
+ `).concat(jx,": ").concat(l,`px;
108
+ }
109
+ `)},Ka=function(){var e=parseInt(document.body.getAttribute(or)||"0",10);return isFinite(e)?e:0},Xx=function(){u.useEffect(function(){return document.body.setAttribute(or,(Ka()+1).toString()),function(){var e=Ka()-1;e<=0?document.body.removeAttribute(or):document.body.setAttribute(or,e.toString())}},[])},Zx=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Xx();var s=u.useMemo(function(){return Yx(o)},[o]);return u.createElement(Kx,{styles:qx(s,!t,o,n?"":"!important")})},qs=!1;if(typeof window<"u")try{var ro=Object.defineProperty({},"passive",{get:function(){return qs=!0,!0}});window.addEventListener("test",ro,ro),window.removeEventListener("test",ro,ro)}catch{qs=!1}var Yn=qs?{passive:!1}:!1,Jx=function(e){return e.tagName==="TEXTAREA"},iu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Jx(e)&&n[t]==="visible")},Qx=function(e){return iu(e,"overflowY")},ev=function(e){return iu(e,"overflowX")},qa=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=au(e,r);if(o){var s=lu(e,r),i=s[1],l=s[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},tv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},nv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},au=function(e,t){return e==="v"?Qx(t):ev(t)},lu=function(e,t){return e==="v"?tv(t):nv(t)},rv=function(e,t){return e==="h"&&t==="rtl"?-1:1},ov=function(e,t,n,r,o){var s=rv(e,window.getComputedStyle(t).direction),i=s*r,l=n.target,c=t.contains(l),d=!1,f=i>0,p=0,m=0;do{if(!l)break;var g=lu(e,l),x=g[0],h=g[1],v=g[2],b=h-v-s*x;(x||b)&&au(e,l)&&(p+=b,m+=x);var w=l.parentNode;l=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(f&&Math.abs(p)<1||!f&&Math.abs(m)<1)&&(d=!0),d},oo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Xa=function(e){return[e.deltaX,e.deltaY]},Za=function(e){return e&&"current"in e?e.current:e},sv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},iv=function(e){return`
110
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
111
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
112
+ `)},av=0,Kn=[];function lv(e){var t=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(av++)[0],s=u.useState(su)[0],i=u.useRef(e);u.useEffect(function(){i.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=_x([e.lockRef.current],(e.shards||[]).map(Za),!0).filter(Boolean);return h.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=u.useCallback(function(h,v){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var b=oo(h),w=n.current,y="deltaX"in h?h.deltaX:w[0]-b[0],E="deltaY"in h?h.deltaY:w[1]-b[1],A,j=h.target,N=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in h&&N==="h"&&j.type==="range")return!1;var T=qa(N,j);if(!T)return!0;if(T?A=N:(A=N==="v"?"h":"v",T=qa(N,j)),!T)return!1;if(!r.current&&"changedTouches"in h&&(y||E)&&(r.current=A),!A)return!0;var G=r.current||A;return ov(G,v,h,G==="h"?y:E)},[]),c=u.useCallback(function(h){var v=h;if(!(!Kn.length||Kn[Kn.length-1]!==s)){var b="deltaY"in v?Xa(v):oo(v),w=t.current.filter(function(A){return A.name===v.type&&(A.target===v.target||v.target===A.shadowParent)&&sv(A.delta,b)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var y=(i.current.shards||[]).map(Za).filter(Boolean).filter(function(A){return A.contains(v.target)}),E=y.length>0?l(v,y[0]):!i.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),d=u.useCallback(function(h,v,b,w){var y={name:h,delta:v,target:b,should:w,shadowParent:cv(b)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),f=u.useCallback(function(h){n.current=oo(h),r.current=void 0},[]),p=u.useCallback(function(h){d(h.type,Xa(h),h.target,l(h,e.lockRef.current))},[]),m=u.useCallback(function(h){d(h.type,oo(h),h.target,l(h,e.lockRef.current))},[]);u.useEffect(function(){return Kn.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Yn),document.addEventListener("touchmove",c,Yn),document.addEventListener("touchstart",f,Yn),function(){Kn=Kn.filter(function(h){return h!==s}),document.removeEventListener("wheel",c,Yn),document.removeEventListener("touchmove",c,Yn),document.removeEventListener("touchstart",f,Yn)}},[]);var g=e.removeScrollBar,x=e.inert;return u.createElement(u.Fragment,null,x?u.createElement(s,{styles:iv(o)}):null,g?u.createElement(Zx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function cv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const uv=Fx(ou,lv);var Go=u.forwardRef(function(e,t){return u.createElement(Wo,Zt({},e,{ref:t,sideCar:uv}))});Go.classNames=Wo.classNames;var dv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},qn=new WeakMap,so=new WeakMap,io={},Cs=0,cu=function(e){return e&&(e.host||cu(e.parentNode))},fv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=cu(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},pv=function(e,t,n,r){var o=fv(t,Array.isArray(e)?e:[e]);io[n]||(io[n]=new WeakMap);var s=io[n],i=[],l=new Set,c=new Set(o),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};o.forEach(d);var f=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))f(m);else try{var g=m.getAttribute(r),x=g!==null&&g!=="false",h=(qn.get(m)||0)+1,v=(s.get(m)||0)+1;qn.set(m,h),s.set(m,v),i.push(m),h===1&&x&&so.set(m,!0),v===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return f(t),l.clear(),Cs++,function(){i.forEach(function(p){var m=qn.get(p)-1,g=s.get(p)-1;qn.set(p,m),s.set(p,g),m||(so.has(p)||p.removeAttribute(r),so.delete(p)),g||p.removeAttribute(n)}),Cs--,Cs||(qn=new WeakMap,qn=new WeakMap,so=new WeakMap,io={})}},Bi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=dv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),pv(r,o,n,"aria-hidden")):function(){return null}},Vo="Dialog",[uu]=kn(Vo),[mv,Yt]=uu(Vo),du=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,l=u.useRef(null),c=u.useRef(null),[d,f]=Fn({prop:r,defaultProp:o??!1,onChange:s,caller:Vo});return a.jsx(mv,{scope:t,triggerRef:l,contentRef:c,contentId:en(),titleId:en(),descriptionId:en(),open:d,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(p=>!p),[f]),modal:i,children:n})};du.displayName=Vo;var fu="DialogTrigger",hv=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Yt(fu,n),s=$e(t,o.triggerRef);return a.jsx(ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Wi(o.open),...r,ref:s,onClick:ge(e.onClick,o.onOpenToggle)})});hv.displayName=fu;var Ui="DialogPortal",[gv,pu]=uu(Ui,{forceMount:void 0}),mu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Yt(Ui,t);return a.jsx(gv,{scope:t,forceMount:n,children:u.Children.map(r,i=>a.jsx(xn,{present:n||s.open,children:a.jsx(Yr,{asChild:!0,container:o,children:i})}))})};mu.displayName=Ui;var To="DialogOverlay",hu=u.forwardRef((e,t)=>{const n=pu(To,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Yt(To,e.__scopeDialog);return s.modal?a.jsx(xn,{present:r||s.open,children:a.jsx(vv,{...o,ref:t})}):null});hu.displayName=To;var xv=Dn("DialogOverlay.RemoveScroll"),vv=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Yt(To,n);return a.jsx(Go,{as:xv,allowPinchZoom:!0,shards:[o.contentRef],children:a.jsx(ke.div,{"data-state":Wi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),zn="DialogContent",gu=u.forwardRef((e,t)=>{const n=pu(zn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Yt(zn,e.__scopeDialog);return a.jsx(xn,{present:r||s.open,children:s.modal?a.jsx(wv,{...o,ref:t}):a.jsx(bv,{...o,ref:t})})});gu.displayName=zn;var wv=u.forwardRef((e,t)=>{const n=Yt(zn,e.__scopeDialog),r=u.useRef(null),o=$e(t,n.contentRef,r);return u.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),a.jsx(xu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ge(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ge(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&s.preventDefault()}),onFocusOutside:ge(e.onFocusOutside,s=>s.preventDefault())})}),bv=u.forwardRef((e,t)=>{const n=Yt(zn,e.__scopeDialog),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(xu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),xu=u.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,l=Yt(zn,n),c=u.useRef(null),d=$e(t,c);return $i(),a.jsxs(a.Fragment,{children:[a.jsx(Ho,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(Gr,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Wi(l.open),...i,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),a.jsxs(a.Fragment,{children:[a.jsx(yv,{titleId:l.titleId}),a.jsx(Cv,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Hi="DialogTitle",vu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Yt(Hi,n);return a.jsx(ke.h2,{id:o.titleId,...r,ref:t})});vu.displayName=Hi;var wu="DialogDescription",bu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Yt(wu,n);return a.jsx(ke.p,{id:o.descriptionId,...r,ref:t})});bu.displayName=wu;var yu="DialogClose",Su=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Yt(yu,n);return a.jsx(ke.button,{type:"button",...r,ref:t,onClick:ge(e.onClick,()=>o.onOpenChange(!1))})});Su.displayName=yu;function Wi(e){return e?"open":"closed"}var Cu="DialogTitleWarning",[g1,Eu]=dh(Cu,{contentName:zn,titleName:Hi,docsSlug:"dialog"}),yv=({titleId:e})=>{const t=Eu(Cu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
113
+
114
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
115
+
116
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Sv="DialogDescriptionWarning",Cv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Eu(Sv).contentName}}.`;return u.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ev=du,Tv=mu,Av=hu,Nv=gu,kv=vu,_v=bu,Iv=Su;function Yo({...e}){return a.jsx(Ev,{"data-slot":"dialog",...e})}function jv({...e}){return a.jsx(Tv,{"data-slot":"dialog-portal",...e})}function Rv({className:e,...t}){return a.jsx(Av,{"data-slot":"dialog-overlay",className:be("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Ko({className:e,children:t,showCloseButton:n=!0,...r}){return a.jsxs(jv,{"data-slot":"dialog-portal",children:[a.jsx(Rv,{}),a.jsxs(Nv,{"data-slot":"dialog-content",className:be("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-md border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,n&&a.jsxs(Iv,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[a.jsx(Lo,{}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function qo({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-header",className:be("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Mv({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-footer",className:be("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Xo({className:e,...t}){return a.jsx(kv,{"data-slot":"dialog-title",className:be("text-lg leading-none font-semibold",e),...t})}function Zo({className:e,...t}){return a.jsx(_v,{"data-slot":"dialog-description",className:be("py-4 text-sm",e),...t})}const Jo=u.createContext(null);Jo.displayName="PanelGroupContext";const Ue={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},Gi=10,Pn=u.useLayoutEffect,Ja=gi.useId,Pv=typeof Ja=="function"?Ja:()=>null;let Lv=0;function Vi(e=null){const t=Pv(),n=u.useRef(e||t||null);return n.current===null&&(n.current=""+Lv++),e??n.current}function Tu({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:s,id:i,maxSize:l,minSize:c,onCollapse:d,onExpand:f,onResize:p,order:m,style:g,tagName:x="div",...h}){const v=u.useContext(Jo);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:w,getPanelSize:y,getPanelStyle:E,groupId:A,isPanelCollapsed:j,reevaluatePanelConstraints:N,registerPanel:T,resizePanel:G,unregisterPanel:q}=v,W=Vi(i),X=u.useRef({callbacks:{onCollapse:d,onExpand:f,onResize:p},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:l,minSize:c},id:W,idIsFromProps:i!==void 0,order:m});u.useRef({didLogMissingDefaultSizeWarning:!1}),Pn(()=>{const{callbacks:O,constraints:Y}=X.current,k={...Y};X.current.id=W,X.current.idIsFromProps=i!==void 0,X.current.order=m,O.onCollapse=d,O.onExpand=f,O.onResize=p,Y.collapsedSize=n,Y.collapsible=r,Y.defaultSize=o,Y.maxSize=l,Y.minSize=c,(k.collapsedSize!==Y.collapsedSize||k.collapsible!==Y.collapsible||k.maxSize!==Y.maxSize||k.minSize!==Y.minSize)&&N(X.current,k)}),Pn(()=>{const O=X.current;return T(O),()=>{q(O)}},[m,W,T,q]),u.useImperativeHandle(s,()=>({collapse:()=>{b(X.current)},expand:O=>{w(X.current,O)},getId(){return W},getSize(){return y(X.current)},isCollapsed(){return j(X.current)},isExpanded(){return!j(X.current)},resize:O=>{G(X.current,O)}}),[b,w,y,j,W,G]);const ee=E(X.current,o);return u.createElement(x,{...h,children:e,className:t,id:W,style:{...ee,...g},[Ue.groupId]:A,[Ue.panel]:"",[Ue.panelCollapsible]:r||void 0,[Ue.panelId]:W,[Ue.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const Au=u.forwardRef((e,t)=>u.createElement(Tu,{...e,forwardedRef:t}));Tu.displayName="Panel";Au.displayName="forwardRef(Panel)";let Xs=null,wo=-1,bn=null;function Dv(e,t,n){const r=(t&ju)!==0,o=(t&Ru)!==0,s=(t&Mu)!==0,i=(t&Pu)!==0;if(t){if(r)return s?"se-resize":i?"ne-resize":"e-resize";if(o)return s?"sw-resize":i?"nw-resize":"w-resize";if(s)return"s-resize";if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Ov(){bn!==null&&(document.head.removeChild(bn),Xs=null,bn=null,wo=-1)}function Es(e,t,n){var r,o;const s=Dv(e,t);if(Xs!==s){if(Xs=s,bn===null&&(bn=document.createElement("style"),document.head.appendChild(bn)),wo>=0){var i;(i=bn.sheet)===null||i===void 0||i.removeRule(wo)}wo=(r=(o=bn.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function Nu(e){return e.type==="keydown"}function ku(e){return e.type.startsWith("pointer")}function _u(e){return e.type.startsWith("mouse")}function Qo(e){if(ku(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(_u(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Fv(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function zv(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function $v(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:tl(e),b:tl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ce(r,"Stacking order can only be calculated for elements with a common ancestor");const o={a:el(Qa(n.a)),b:el(Qa(n.b))};if(o.a===o.b){const s=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=s.length;for(;l--;){const c=s[l];if(c===i.a)return 1;if(c===i.b)return-1}}return Math.sign(o.a-o.b)}const Bv=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Uv(e){var t;const n=getComputedStyle((t=Iu(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Hv(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Uv(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Bv.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Qa(e){let t=e.length;for(;t--;){const n=e[t];if(Ce(n,"Missing node"),Hv(n))return n}return null}function el(e){return e&&Number(getComputedStyle(e).zIndex)||0}function tl(e){const t=[];for(;e;)t.push(e),e=Iu(e);return t}function Iu(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const ju=1,Ru=2,Mu=4,Pu=8,Wv=Fv()==="coarse";let Wt=[],sr=!1,yn=new Map,es=new Map;const Fr=new Set;function Gv(e,t,n,r,o){var s;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},c=(s=yn.get(i))!==null&&s!==void 0?s:0;return yn.set(i,c+1),Fr.add(l),Ao(),function(){var f;es.delete(e),Fr.delete(l);const p=(f=yn.get(i))!==null&&f!==void 0?f:1;if(yn.set(i,p-1),Ao(),p===1&&yn.delete(i),Wt.includes(l)){const m=Wt.indexOf(l);m>=0&&Wt.splice(m,1),ts(),o("up",!0,null)}}}function Vv(e){const{target:t}=e,{x:n,y:r}=Qo(e);sr=!0,Yi({target:t,x:n,y:r}),Ao(),Wt.length>0&&(No("down",e),ts(),e.preventDefault(),Lu(t)||e.stopImmediatePropagation())}function Ts(e){const{x:t,y:n}=Qo(e);if(sr&&e.type!=="pointerleave"&&e.buttons===0&&(sr=!1,No("up",e)),!sr){const{target:r}=e;Yi({target:r,x:t,y:n})}No("move",e),ts(),Wt.length>0&&e.preventDefault()}function As(e){const{target:t}=e,{x:n,y:r}=Qo(e);es.clear(),sr=!1,Wt.length>0&&(e.preventDefault(),Lu(t)||e.stopImmediatePropagation()),No("up",e),Yi({target:t,x:n,y:r}),ts(),Ao()}function Lu(e){let t=e;for(;t;){if(t.hasAttribute(Ue.resizeHandle))return!0;t=t.parentElement}return!1}function Yi({target:e,x:t,y:n}){Wt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Fr.forEach(o=>{const{element:s,hitAreaMargins:i}=o,l=s.getBoundingClientRect(),{bottom:c,left:d,right:f,top:p}=l,m=Wv?i.coarse:i.fine;if(t>=d-m&&t<=f+m&&n>=p-m&&n<=c+m){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&$v(r,s)>0){let x=r,h=!1;for(;x&&!x.contains(s);){if(zv(x.getBoundingClientRect(),l)){h=!0;break}x=x.parentElement}if(h)return}Wt.push(o)}})}function Ns(e,t){es.set(e,t)}function ts(){let e=!1,t=!1;Wt.forEach(r=>{const{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;es.forEach(r=>{n|=r}),e&&t?Es("intersection",n):e?Es("horizontal",n):t?Es("vertical",n):Ov()}let ks;function Ao(){var e;(e=ks)===null||e===void 0||e.abort(),ks=new AbortController;const t={capture:!0,signal:ks.signal};Fr.size&&(sr?(Wt.length>0&&yn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("contextmenu",As,t),o.addEventListener("pointerleave",Ts,t),o.addEventListener("pointermove",Ts,t))}),yn.forEach((n,r)=>{const{body:o}=r;o.addEventListener("pointerup",As,t),o.addEventListener("pointercancel",As,t)})):yn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("pointerdown",Vv,t),o.addEventListener("pointermove",Ts,t))}))}function No(e,t){Fr.forEach(n=>{const{setResizeHandlerState:r}=n,o=Wt.includes(n);r(e,o,t)})}function Yv(){const[e,t]=u.useState(0);return u.useCallback(()=>t(n=>n+1),[])}function Ce(e,t){if(!e)throw console.error(t),Error(t)}function $n(e,t,n=Gi){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function fn(e,t,n=Gi){return $n(e,t,n)===0}function xt(e,t,n){return $n(e,t,n)===0}function Kv(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const o=e[r],s=t[r];if(!xt(o,s,n))return!1}return!0}function er({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ce(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:s,maxSize:i=100,minSize:l=0}=r;if($n(n,l)<0)if(s){const c=(o+l)/2;$n(n,c)<0?n=o:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(Gi)),n}function jr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:s}){if(xt(e,0))return t;const i=[...t],[l,c]=r;Ce(l!=null,"Invalid first pivot index"),Ce(c!=null,"Invalid second pivot index");let d=0;if(s==="keyboard"){{const p=e<0?c:l,m=n[p];Ce(m,`Panel constraints not found for index ${p}`);const{collapsedSize:g=0,collapsible:x,minSize:h=0}=m;if(x){const v=t[p];if(Ce(v!=null,`Previous layout not found for panel index ${p}`),xt(v,g)){const b=h-v;$n(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?l:c,m=n[p];Ce(m,`No panel constraints found for index ${p}`);const{collapsedSize:g=0,collapsible:x,minSize:h=0}=m;if(x){const v=t[p];if(Ce(v!=null,`Previous layout not found for panel index ${p}`),xt(v,h)){const b=v-g;$n(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let m=e<0?c:l,g=0;for(;;){const h=t[m];Ce(h!=null,`Previous layout not found for panel index ${m}`);const b=er({panelConstraints:n,panelIndex:m,size:100})-h;if(g+=b,m+=p,m<0||m>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-x:x}{let m=e<0?l:c;for(;m>=0&&m<n.length;){const g=Math.abs(e)-Math.abs(d),x=t[m];Ce(x!=null,`Previous layout not found for panel index ${m}`);const h=x-g,v=er({panelConstraints:n,panelIndex:m,size:h});if(!xt(x,v)&&(d+=x-v,i[m]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Kv(o,i))return o;{const p=e<0?c:l,m=t[p];Ce(m!=null,`Previous layout not found for panel index ${p}`);const g=m+d,x=er({panelConstraints:n,panelIndex:p,size:g});if(i[p]=x,!xt(x,g)){let h=g-x,b=e<0?c:l;for(;b>=0&&b<n.length;){const w=i[b];Ce(w!=null,`Previous layout not found for panel index ${b}`);const y=w+h,E=er({panelConstraints:n,panelIndex:b,size:y});if(xt(w,E)||(h-=E-w,i[b]=E),xt(h,0))break;e>0?b--:b++}}}const f=i.reduce((p,m)=>m+p,0);return xt(f,100)?i:o}function qv({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,s=0,i=0;const l=n[0];Ce(l!=null,"No pivot index found"),t.forEach((p,m)=>{const{constraints:g}=p,{maxSize:x=100,minSize:h=0}=g;m===l?(r=h,o=x):(s+=h,i+=x)});const c=Math.min(o,100-s),d=Math.max(r,100-i),f=e[l];return{valueMax:c,valueMin:d,valueNow:f}}function zr(e,t=document){return Array.from(t.querySelectorAll(`[${Ue.resizeHandleId}][data-panel-group-id="${e}"]`))}function Du(e,t,n=document){const o=zr(e,n).findIndex(s=>s.getAttribute(Ue.resizeHandleId)===t);return o??null}function Ou(e,t,n){const r=Du(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Xv(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Fu(e,t=document){if(Xv(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function ns(e,t=document){const n=t.querySelector(`[${Ue.resizeHandleId}="${e}"]`);return n||null}function Zv(e,t,n,r=document){var o,s,i,l;const c=ns(t,r),d=zr(e,r),f=c?d.indexOf(c):-1,p=(o=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,m=(i=(l=n[f+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[p,m]}function Jv({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:s,setLayout:i}){u.useRef({didWarnAboutMissingResizeHandle:!1}),Pn(()=>{if(!s)return;const l=zr(n,s);for(let c=0;c<o.length-1;c++){const{valueMax:d,valueMin:f,valueNow:p}=qv({layout:r,panelsArray:o,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const g=o[c];Ce(g,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",g.id),m.setAttribute("aria-valuemax",""+Math.round(d)),m.setAttribute("aria-valuemin",""+Math.round(f)),m.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{l.forEach((c,d)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,o,s]),u.useEffect(()=>{if(!s)return;const l=t.current;Ce(l,"Eager values not found");const{panelDataArray:c}=l,d=Fu(n,s);Ce(d!=null,`No group found for id "${n}"`);const f=zr(n,s);Ce(f,`No resize handles found for group id "${n}"`);const p=f.map(m=>{const g=m.getAttribute(Ue.resizeHandleId);Ce(g,"Resize handle element has no handle id attribute");const[x,h]=Zv(n,g,c,s);if(x==null||h==null)return()=>{};const v=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const w=c.findIndex(y=>y.id===x);if(w>=0){const y=c[w];Ce(y,`No panel data found for index ${w}`);const E=r[w],{collapsedSize:A=0,collapsible:j,minSize:N=0}=y.constraints;if(E!=null&&j){const T=jr({delta:xt(E,A)?N-A:A-E,initialLayout:r,panelConstraints:c.map(G=>G.constraints),pivotIndices:Ou(n,g,s),prevLayout:r,trigger:"keyboard"});r!==T&&i(T)}}break}}};return m.addEventListener("keydown",v),()=>{m.removeEventListener("keydown",v)}});return()=>{p.forEach(m=>m())}},[s,e,t,n,r,o,i])}function nl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function zu(e,t){const n=e==="horizontal",{x:r,y:o}=Qo(t);return n?r:o}function Qv(e,t,n,r,o){const s=n==="horizontal",i=ns(t,o);Ce(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(Ue.groupId);Ce(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const d=zu(n,e),f=Fu(l,o);Ce(f,`No group element found for id "${l}"`);const p=f.getBoundingClientRect(),m=s?p.width:p.height;return(d-c)/m*100}function ew(e,t,n,r,o,s){if(Nu(e)){const i=n==="horizontal";let l=0;e.shiftKey?l=100:o!=null?l=o:l=10;let c=0;switch(e.key){case"ArrowDown":c=i?0:l;break;case"ArrowLeft":c=i?-l:0;break;case"ArrowRight":c=i?l:0;break;case"ArrowUp":c=i?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:Qv(e,t,n,r,s)}function tw({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,o=100;for(let s=0;s<e.length;s++){const i=n[s];Ce(i,`Panel constraints not found for index ${s}`);const{defaultSize:l}=i;l!=null&&(r++,t[s]=l,o-=l)}for(let s=0;s<e.length;s++){const i=n[s];Ce(i,`Panel constraints not found for index ${s}`);const{defaultSize:l}=i;if(l!=null)continue;const c=e.length-r,d=o/c;r++,t[s]=d,o-=d}return t}function Xn(e,t,n){t.forEach((r,o)=>{const s=e[o];Ce(s,`Panel data not found for index ${o}`);const{callbacks:i,constraints:l,id:c}=s,{collapsedSize:d=0,collapsible:f}=l,p=n[c];if(p==null||r!==p){n[c]=r;const{onCollapse:m,onExpand:g,onResize:x}=i;x&&x(r,p),f&&(m||g)&&(g&&(p==null||fn(p,d))&&!fn(r,d)&&g(),m&&(p==null||!fn(p,d))&&fn(r,d)&&m())}})}function ao(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function nw({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:s=3}){const i=n[o];let l;return i==null?l=e!=null?e.toFixed(s):"1":r.length===1?l="1":l=i.toFixed(s),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function rw(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function rl(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function $u(e){return`react-resizable-panels:${e}`}function Bu(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:o,order:s}=t;return o?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Uu(e,t){try{const n=$u(e),r=t.getItem(n);if(r){const o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function ow(e,t,n){var r,o;const s=(r=Uu(e,n))!==null&&r!==void 0?r:{},i=Bu(t);return(o=s[i])!==null&&o!==void 0?o:null}function sw(e,t,n,r,o){var s;const i=$u(e),l=Bu(t),c=(s=Uu(e,o))!==null&&s!==void 0?s:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(c))}catch(d){console.error(d)}}function ol({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,i)=>s+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!xt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const i=n[s];Ce(i!=null,`No layout data found for index ${s}`);const l=100/r*i;n[s]=l}let o=0;for(let s=0;s<t.length;s++){const i=n[s];Ce(i!=null,`No layout data found for index ${s}`);const l=er({panelConstraints:t,panelIndex:s,size:i});i!=l&&(o+=i-l,n[s]=l)}if(!xt(o,0))for(let s=0;s<t.length;s++){const i=n[s];Ce(i!=null,`No layout data found for index ${s}`);const l=i+o,c=er({panelConstraints:t,panelIndex:s,size:l});if(i!==c&&(o-=c-i,n[s]=c,xt(o,0)))break}return n}const iw=100,Rr={getItem:e=>(rl(Rr),Rr.getItem(e)),setItem:(e,t)=>{rl(Rr),Rr.setItem(e,t)}},sl={};function Hu({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:s=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Rr,style:d,tagName:f="div",...p}){const m=Vi(s),g=u.useRef(null),[x,h]=u.useState(null),[v,b]=u.useState([]),w=Yv(),y=u.useRef({}),E=u.useRef(new Map),A=u.useRef(0),j=u.useRef({autoSaveId:e,direction:r,dragState:x,id:m,keyboardResizeBy:l,onLayout:i,storage:c}),N=u.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});u.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),u.useImperativeHandle(o,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:P}=N.current;return P},setLayout:P=>{const{onLayout:B}=j.current,{layout:D,panelDataArray:U}=N.current,I=ol({layout:P,panelConstraints:U.map(V=>V.constraints)});nl(D,I)||(b(I),N.current.layout=I,B&&B(I),Xn(U,I,y.current))}}),[]),Pn(()=>{j.current.autoSaveId=e,j.current.direction=r,j.current.dragState=x,j.current.id=m,j.current.onLayout=i,j.current.storage=c}),Jv({committedValuesRef:j,eagerValuesRef:N,groupId:m,layout:v,panelDataArray:N.current.panelDataArray,setLayout:b,panelGroupElement:g.current}),u.useEffect(()=>{const{panelDataArray:P}=N.current;if(e){if(v.length===0||v.length!==P.length)return;let B=sl[e];B==null&&(B=rw(sw,iw),sl[e]=B);const D=[...P],U=new Map(E.current);B(e,D,U,v,c)}},[e,v,c]),u.useEffect(()=>{});const T=u.useCallback(P=>{const{onLayout:B}=j.current,{layout:D,panelDataArray:U}=N.current;if(P.constraints.collapsible){const I=U.map(ae=>ae.constraints),{collapsedSize:V=0,panelSize:Q,pivotIndices:te}=Mn(U,P,D);if(Ce(Q!=null,`Panel size not found for panel "${P.id}"`),!fn(Q,V)){E.current.set(P.id,Q);const se=Jn(U,P)===U.length-1?Q-V:V-Q,pe=jr({delta:se,initialLayout:D,panelConstraints:I,pivotIndices:te,prevLayout:D,trigger:"imperative-api"});ao(D,pe)||(b(pe),N.current.layout=pe,B&&B(pe),Xn(U,pe,y.current))}}},[]),G=u.useCallback((P,B)=>{const{onLayout:D}=j.current,{layout:U,panelDataArray:I}=N.current;if(P.constraints.collapsible){const V=I.map(ye=>ye.constraints),{collapsedSize:Q=0,panelSize:te=0,minSize:ae=0,pivotIndices:se}=Mn(I,P,U),pe=B??ae;if(fn(te,Q)){const ye=E.current.get(P.id),_e=ye!=null&&ye>=pe?ye:pe,Pe=Jn(I,P)===I.length-1?te-_e:_e-te,Re=jr({delta:Pe,initialLayout:U,panelConstraints:V,pivotIndices:se,prevLayout:U,trigger:"imperative-api"});ao(U,Re)||(b(Re),N.current.layout=Re,D&&D(Re),Xn(I,Re,y.current))}}},[]),q=u.useCallback(P=>{const{layout:B,panelDataArray:D}=N.current,{panelSize:U}=Mn(D,P,B);return Ce(U!=null,`Panel size not found for panel "${P.id}"`),U},[]),W=u.useCallback((P,B)=>{const{panelDataArray:D}=N.current,U=Jn(D,P);return nw({defaultSize:B,dragState:x,layout:v,panelData:D,panelIndex:U})},[x,v]),X=u.useCallback(P=>{const{layout:B,panelDataArray:D}=N.current,{collapsedSize:U=0,collapsible:I,panelSize:V}=Mn(D,P,B);return Ce(V!=null,`Panel size not found for panel "${P.id}"`),I===!0&&fn(V,U)},[]),ee=u.useCallback(P=>{const{layout:B,panelDataArray:D}=N.current,{collapsedSize:U=0,collapsible:I,panelSize:V}=Mn(D,P,B);return Ce(V!=null,`Panel size not found for panel "${P.id}"`),!I||$n(V,U)>0},[]),O=u.useCallback(P=>{const{panelDataArray:B}=N.current;B.push(P),B.sort((D,U)=>{const I=D.order,V=U.order;return I==null&&V==null?0:I==null?-1:V==null?1:I-V}),N.current.panelDataArrayChanged=!0,w()},[w]);Pn(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:P,onLayout:B,storage:D}=j.current,{layout:U,panelDataArray:I}=N.current;let V=null;if(P){const te=ow(P,I,D);te&&(E.current=new Map(Object.entries(te.expandToSizes)),V=te.layout)}V==null&&(V=tw({panelDataArray:I}));const Q=ol({layout:V,panelConstraints:I.map(te=>te.constraints)});nl(U,Q)||(b(Q),N.current.layout=Q,B&&B(Q),Xn(I,Q,y.current))}}),Pn(()=>{const P=N.current;return()=>{P.layout=[]}},[]);const Y=u.useCallback(P=>{let B=!1;const D=g.current;return D&&window.getComputedStyle(D,null).getPropertyValue("direction")==="rtl"&&(B=!0),function(I){I.preventDefault();const V=g.current;if(!V)return()=>null;const{direction:Q,dragState:te,id:ae,keyboardResizeBy:se,onLayout:pe}=j.current,{layout:ye,panelDataArray:_e}=N.current,{initialLayout:Ie}=te??{},Pe=Ou(ae,P,V);let Re=ew(I,P,Q,te,se,V);const Be=Q==="horizontal";Be&&B&&(Re=-Re);const yt=_e.map(nt=>nt.constraints),We=jr({delta:Re,initialLayout:Ie??ye,panelConstraints:yt,pivotIndices:Pe,prevLayout:ye,trigger:Nu(I)?"keyboard":"mouse-or-touch"}),St=!ao(ye,We);(ku(I)||_u(I))&&A.current!=Re&&(A.current=Re,!St&&Re!==0?Be?Ns(P,Re<0?ju:Ru):Ns(P,Re<0?Mu:Pu):Ns(P,0)),St&&(b(We),N.current.layout=We,pe&&pe(We),Xn(_e,We,y.current))}},[]),k=u.useCallback((P,B)=>{const{onLayout:D}=j.current,{layout:U,panelDataArray:I}=N.current,V=I.map(ye=>ye.constraints),{panelSize:Q,pivotIndices:te}=Mn(I,P,U);Ce(Q!=null,`Panel size not found for panel "${P.id}"`);const se=Jn(I,P)===I.length-1?Q-B:B-Q,pe=jr({delta:se,initialLayout:U,panelConstraints:V,pivotIndices:te,prevLayout:U,trigger:"imperative-api"});ao(U,pe)||(b(pe),N.current.layout=pe,D&&D(pe),Xn(I,pe,y.current))},[]),$=u.useCallback((P,B)=>{const{layout:D,panelDataArray:U}=N.current,{collapsedSize:I=0,collapsible:V}=B,{collapsedSize:Q=0,collapsible:te,maxSize:ae=100,minSize:se=0}=P.constraints,{panelSize:pe}=Mn(U,P,D);pe!=null&&(V&&te&&fn(pe,I)?fn(I,Q)||k(P,Q):pe<se?k(P,se):pe>ae&&k(P,ae))},[k]),C=u.useCallback((P,B)=>{const{direction:D}=j.current,{layout:U}=N.current;if(!g.current)return;const I=ns(P,g.current);Ce(I,`Drag handle element not found for id "${P}"`);const V=zu(D,B);h({dragHandleId:P,dragHandleRect:I.getBoundingClientRect(),initialCursorPosition:V,initialLayout:U})},[]),_=u.useCallback(()=>{h(null)},[]),L=u.useCallback(P=>{const{panelDataArray:B}=N.current,D=Jn(B,P);D>=0&&(B.splice(D,1),delete y.current[P.id],N.current.panelDataArrayChanged=!0,w())},[w]),R=u.useMemo(()=>({collapsePanel:T,direction:r,dragState:x,expandPanel:G,getPanelSize:q,getPanelStyle:W,groupId:m,isPanelCollapsed:X,isPanelExpanded:ee,reevaluatePanelConstraints:$,registerPanel:O,registerResizeHandle:Y,resizePanel:k,startDragging:C,stopDragging:_,unregisterPanel:L,panelGroupElement:g.current}),[T,x,r,G,q,W,m,X,ee,$,O,Y,k,C,_,L]),J={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return u.createElement(Jo.Provider,{value:R},u.createElement(f,{...p,children:t,className:n,id:s,ref:g,style:{...J,...d},[Ue.group]:"",[Ue.groupDirection]:r,[Ue.groupId]:m}))}const Wu=u.forwardRef((e,t)=>u.createElement(Hu,{...e,forwardedRef:t}));Hu.displayName="PanelGroup";Wu.displayName="forwardRef(PanelGroup)";function Jn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Mn(e,t,n){const r=Jn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:s}}function aw({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){u.useEffect(()=>{if(e||n==null||r==null)return;const o=ns(t,r);if(o==null)return;const s=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const l=o.getAttribute(Ue.groupId);Ce(l,`No group element found for id "${l}"`);const c=zr(l,r),d=Du(l,t,r);Ce(d!==null,`No resize element found for id "${t}"`);const f=i.shiftKey?d>0?d-1:c.length-1:d+1<c.length?d+1:0;c[f].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[r,e,t,n])}function Gu({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:s,onClick:i,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:f,style:p={},tabIndex:m=0,tagName:g="div",...x}){var h,v;const b=u.useRef(null),w=u.useRef({onClick:i,onDragging:l,onPointerDown:d,onPointerUp:f});u.useEffect(()=>{w.current.onClick=i,w.current.onDragging=l,w.current.onPointerDown=d,w.current.onPointerUp=f});const y=u.useContext(Jo);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:A,registerResizeHandle:j,startDragging:N,stopDragging:T,panelGroupElement:G}=y,q=Vi(o),[W,X]=u.useState("inactive"),[ee,O]=u.useState(!1),[Y,k]=u.useState(null),$=u.useRef({state:W});Pn(()=>{$.current.state=W}),u.useEffect(()=>{if(n)k(null);else{const R=j(q);k(()=>R)}},[n,q,j]);const C=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,_=(v=r==null?void 0:r.fine)!==null&&v!==void 0?v:5;u.useEffect(()=>{if(n||Y==null)return;const R=b.current;Ce(R,"Element ref not attached");let J=!1;return Gv(q,R,E,{coarse:C,fine:_},(B,D,U)=>{if(!D){X("inactive");return}switch(B){case"down":{X("drag"),J=!1,Ce(U,'Expected event to be defined for "down" action'),N(q,U);const{onDragging:I,onPointerDown:V}=w.current;I==null||I(!0),V==null||V();break}case"move":{const{state:I}=$.current;J=!0,I!=="drag"&&X("hover"),Ce(U,'Expected event to be defined for "move" action'),Y(U);break}case"up":{X("hover"),T();const{onClick:I,onDragging:V,onPointerUp:Q}=w.current;V==null||V(!1),Q==null||Q(),J||I==null||I();break}}})},[C,E,n,_,j,q,Y,N,T]),aw({disabled:n,handleId:q,resizeHandler:Y,panelGroupElement:G});const L={touchAction:"none",userSelect:"none"};return u.createElement(g,{...x,children:e,className:t,id:o,onBlur:()=>{O(!1),s==null||s()},onFocus:()=>{O(!0),c==null||c()},ref:b,role:"separator",style:{...L,...p},tabIndex:m,[Ue.groupDirection]:E,[Ue.groupId]:A,[Ue.resizeHandle]:"",[Ue.resizeHandleActive]:W==="drag"?"pointer":ee?"keyboard":void 0,[Ue.resizeHandleEnabled]:!n,[Ue.resizeHandleId]:q,[Ue.resizeHandleState]:W})}Gu.displayName="PanelResizeHandle";function lw({className:e,...t}){return a.jsx(Wu,{"data-slot":"resizable-panel-group",className:be("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function il({...e}){return a.jsx(Au,{"data-slot":"resizable-panel",...e})}function cw({withHandle:e,className:t,...n}){return a.jsx(Gu,{"data-slot":"resizable-handle",className:be("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&a.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:a.jsx(Lp,{className:"size-2.5"})})})}const uw=u.forwardRef(({className:e,...t},n)=>a.jsx("ul",{ref:n,className:be("flex flex-row items-center gap-1",e),...t}));uw.displayName="PaginationContent";const dw=u.forwardRef(({className:e,...t},n)=>a.jsx("li",{ref:n,className:be("",e),...t}));dw.displayName="PaginationItem";function fw({ref:e,anchorRef:t,onClickOutside:n,enabled:r=!0}){u.useEffect(()=>{if(!r)return;const o=s=>{const i=s.target,l=e.current&&!e.current.contains(i),c=t!=null&&t.current?!t.current.contains(i):!0;l&&c&&n()};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[e,t,n,r])}function pw({onEscape:e,enabled:t=!0}){u.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[e,t])}const mw={x:0,y:0},kt=16,hw=["top-start","bottom-end","top-end"];function gw({anchorRef:e,placement:t="top-start",offset:n=mw,fallbackPlacements:r=hw}){const o=u.useCallback((c,d,f)=>{let p=0,m=0;switch(f){case"top":p=c.top-d.height-n.y,m=c.left+(c.width-d.width)/2+n.x;break;case"top-start":p=c.top-d.height-n.y,m=c.left+n.x;break;case"top-end":p=c.top-d.height-n.y,m=c.right-d.width-n.x;break;case"bottom":p=c.bottom+n.y,m=c.left+(c.width-d.width)/2+n.x;break;case"bottom-start":p=c.bottom+n.y,m=c.left+n.x;break;case"bottom-end":p=c.bottom+n.y,m=c.right-d.width-n.x;break;case"left":p=c.top+(c.height-d.height)/2+n.y,m=c.left-d.width-n.x;break;case"left-start":p=c.top+n.y,m=c.left-d.width-n.x;break;case"left-end":p=c.bottom-d.height-n.y,m=c.left-d.width-n.x;break;case"right":p=c.top+(c.height-d.height)/2+n.y,m=c.right+n.x;break;case"right-start":p=c.top+n.y,m=c.right+n.x;break;case"right-end":p=c.bottom-d.height-n.y,m=c.right+n.x;break}return console.log(`Calculated position for ${f}:`,{top:p,left:m}),{top:p,left:m,placement:f}},[n.x,n.y]),s=u.useCallback((c,d)=>{const f={width:window.innerWidth,height:window.innerHeight};return c.left<kt||c.top<kt||c.left+d.width>f.width-kt||c.top+d.height>f.height-kt},[]),i=u.useCallback(c=>{if(!e.current){const x={width:window.innerWidth,height:window.innerHeight};return{top:x.height/2-100,left:x.width/2-100,placement:t}}const d=e.current.getBoundingClientRect(),f=c.getBoundingClientRect(),p=o(d,f,t);if(!s(p,f))return p;for(const x of r){const h=o(d,f,x);if(!s(h,f))return h}const m={width:window.innerWidth,height:window.innerHeight},g={...p};return g.left<kt?g.left=kt:g.left+f.width>m.width-kt&&(g.left=m.width-f.width-kt),g.top<kt?g.top=kt:g.top+f.height>m.height-kt&&(g.top=m.height-f.height-kt),g},[e,t,r,o,s]);return{getPositionStyle:u.useCallback(c=>{const d=i(c);return{position:"fixed",top:d.top,left:d.left,zIndex:1e3}},[i]),getOptimalPosition:i}}function xw({defaultWidth:e,minWidth:t,maxWidth:n,position:r="left",onWidthChange:o}){const[s,i]=u.useState(e),[l,c]=u.useState(!1),d=u.useRef(0),f=u.useRef(e),p=u.useCallback(b=>{b.preventDefault(),c(!0),d.current=b.clientX,f.current=s},[s]),m=u.useCallback(b=>{if(!l)return;const w=b.clientX-d.current,y=r==="right"?-w:w,E=Math.min(Math.max(f.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),g=u.useCallback(()=>{c(!1)},[]),x=u.useCallback(b=>{b.preventDefault(),c(!0),d.current=b.touches[0].clientX,f.current=s},[s]),h=u.useCallback(b=>{if(!l)return;const w=b.touches[0].clientX-d.current,y=r==="right"?-w:w,E=Math.min(Math.max(f.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),v=u.useCallback(()=>{c(!1)},[]);return u.useEffect(()=>{if(l)return document.addEventListener("mousemove",m),document.addEventListener("mouseup",g),document.addEventListener("touchmove",h),document.addEventListener("touchend",v),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",h),document.removeEventListener("touchend",v),document.body.style.userSelect="",document.body.style.cursor=""}},[l,m,g,h,v]),{width:s,isResizing:l,handleMouseDown:p,handleTouchStart:x,setWidth:i}}const vw=u.forwardRef(({children:e,defaultWidth:t=300,minWidth:n=200,maxWidth:r=800,position:o="left",resizable:s=!0,className:i,onWidthChange:l,...c},d)=>{const{width:f,isResizing:p,handleMouseDown:m,handleTouchStart:g}=xw({defaultWidth:t,minWidth:n,maxWidth:r,position:o,onWidthChange:l}),x={width:`${f}px`},h=o==="left"?"right-0":"left-0";return a.jsxs("div",{ref:d,className:be("relative h-full flex-shrink-0 cursor-pointer",o==="left"?"border-r":"border-l",i),style:x,...c,children:[a.jsx("div",{className:be("h-full overflow-x-hidden overflow-y-auto"),children:e}),s&&a.jsx("div",{className:be("group absolute top-0 bottom-0 w-2",h,"cursor-col-resize","hover:bg-[var(--color-primary-wMain)]","transition-all duration-200",p&&"bg-[var(--color-primary-wMain)]"),onMouseDown:m,onTouchStart:g,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} panel`,tabIndex:0,onKeyDown:b=>{if(b.key==="ArrowLeft"||b.key==="ArrowRight"){b.preventDefault();const w=b.key==="ArrowRight"?10:-10,y=o==="right"?-w:w,E=Math.min(Math.max(f+y,n),r);l==null||l(E)}},children:a.jsx("div",{className:be("absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 transform","bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]","group-hover:bg-[var(--color-primary-wMain)]","transition-colors duration-200",p&&"bg-[var(--color-primary-wMain)]")})})]})});vw.displayName="SidePanel";const Vu=u.createContext(null),Yu=u.createContext(void 0),Ku=u.createContext(null),qu=u.createContext(null),Xu=u.createContext(void 0),Zu=u.createContext(null);function sn(){const e=u.useContext(Ku);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}const ww="https://solace.com/a2a/extensions/display-name",bw="https://solace.com/a2a/extensions/peer-agent-topology",yw="https://solace.com/a2a/extensions/sam/tools",Sw=e=>{var o,s,i,l;let t,n,r;if((o=e.capabilities)!=null&&o.extensions){const c=e.capabilities.extensions.find(p=>p.uri===ww);(s=c==null?void 0:c.params)!=null&&s.display_name&&(t=c.params.display_name);const d=e.capabilities.extensions.find(p=>p.uri===bw);(i=d==null?void 0:d.params)!=null&&i.peer_agent_names&&(n=d.params.peer_agent_names);const f=e.capabilities.extensions.find(p=>p.uri===yw);(l=f==null?void 0:f.params)!=null&&l.tools&&(r=f.params.tools)}return{...e,display_name:t,peer_agents:n||[],tools:r||[],displayName:t,peerAgents:n||[]}},Ju=()=>{const{configServerUrl:e}=sn(),[t,n]=u.useState([]),[r,o]=u.useState({}),[s,i]=u.useState(!0),[l,c]=u.useState(null),d=u.useCallback(async()=>{i(!0),c(null);try{const f=`${e}/api/v1`,p=await Fe(`${f}/agentCards`,{credentials:"include"});if(!p.ok){const h=await p.json().catch(()=>({message:`Failed to fetch agents: ${p.statusText}`}));throw new Error(h.message||`Failed to fetch agents: ${p.statusText}`)}const g=(await p.json()).map(Sw);n(g);const x={};g.forEach(h=>{h.name&&(x[h.name]=h.displayName||h.name)}),o(x)}catch(f){console.error("Error fetching agents:",f),c(f instanceof Error?f.message:"Could not load agent information."),n([])}finally{i(!1)}},[e]);return u.useEffect(()=>{d()},[d]),u.useMemo(()=>({agents:t,agentNameMap:r,isLoading:s,error:l,refetch:d}),[t,r,s,l,d])},Cw=e=>{const{configServerUrl:t}=sn(),[n,r]=u.useState([]),[o,s]=u.useState(!0),[i,l]=u.useState(null),c=`${t}/api/v1`,d=u.useCallback(async()=>{if(!e){r([]),s(!1);return}s(!0),l(null);try{const f=await Fe(`${c}/artifacts/${e}`,{credentials:"include"});if(!f.ok){const m=await f.json().catch(()=>({message:`Failed to fetch artifacts. ${f.statusText}`}));throw new Error(m.message||`Failed to fetch artifacts. ${f.statusText}`)}const p=await f.json();r(p)}catch(f){const p=f instanceof Error?f.message:"Failed to fetch artifacts.";l(p),r([])}finally{s(!1)}},[c,e]);return u.useEffect(()=>{d()},[d]),{artifacts:n,isLoading:o,error:i,refetch:d}},Ew=()=>{const e=u.useContext(Vu);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},He=()=>{const e=u.useContext(Yu);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e};function Tw(){const{messages:e}=He(),t=sn(),n=u.useCallback(r=>{if((t==null?void 0:t.persistenceEnabled)===!1&&!(e.length<=1))return r.preventDefault(),"Are you sure you want to leave? Your chat history will be lost."},[e.length,t==null?void 0:t.persistenceEnabled]);u.useEffect(()=>(window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}),[n])}function Qu(){const e=u.useContext(qu);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function Aw(e,t){const[n,r]=u.useState(e);return u.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const Nw=async(e,t,n)=>{const r=await Fe(`${e}/api/v1/artifacts/${t}/${encodeURIComponent(n.filename)}`,{credentials:"include"});if(!r.ok)throw new Error(`Failed to download artifact: ${n.filename}. Status: ${r.status}`);const o=await r.blob();gc(o,n.filename)},ed=()=>{const{configServerUrl:e}=sn(),{addNotification:t,sessionId:n}=He();return{onDownload:async o=>{if(!n){t("Cannot download artifact: No active session.","error");return}try{await Nw(e,n,o),t(`Downloaded artifact: ${o.filename}.`)}catch{t(`Failed to download artifact: ${o.filename}.`,"error")}}}},kw=({onFilesDropped:e,fileFilter:t,disabled:n=!1})=>{const[r,o]=u.useState(!1),s=u.useRef(0),i=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),s.current=(s.current||0)+1,f.dataTransfer.types.includes("Files")&&o(!0))},[n,s]),l=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),f.dataTransfer.types.includes("Files")&&(f.dataTransfer.dropEffect="copy"))},[n]),c=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),s.current=(s.current||0)-1,s.current===0&&o(!1))},[n,s]),d=u.useCallback(f=>{if(n||(f.preventDefault(),f.stopPropagation(),o(!1),s.current=0,!f.dataTransfer.files||f.dataTransfer.files.length===0))return;const p=Array.from(f.dataTransfer.files),m=t?p.filter(t):p;m.length!==0&&e(m)},[n,s,t,e]);return{isDragging:r,handleDragEnter:i,handleDragOver:l,handleDragLeave:c,handleDrop:d}},Ki=()=>{const e=u.useContext(Xu);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function td(){const e=u.useContext(Zu);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}u.createContext(null);function nd(e){const t=e+"CollectionProvider",[n,r]=kn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:v,children:b}=h,w=Ht.useRef(null),y=Ht.useRef(new Map).current;return a.jsx(o,{scope:v,itemMap:y,collectionRef:w,children:b})};i.displayName=t;const l=e+"CollectionSlot",c=Dn(l),d=Ht.forwardRef((h,v)=>{const{scope:b,children:w}=h,y=s(l,b),E=$e(v,y.collectionRef);return a.jsx(c,{ref:E,children:w})});d.displayName=l;const f=e+"CollectionItemSlot",p="data-radix-collection-item",m=Dn(f),g=Ht.forwardRef((h,v)=>{const{scope:b,children:w,...y}=h,E=Ht.useRef(null),A=$e(v,E),j=s(f,b);return Ht.useEffect(()=>(j.itemMap.set(E,{ref:E,...y}),()=>void j.itemMap.delete(E))),a.jsx(m,{[p]:"",ref:A,children:w})});g.displayName=f;function x(h){const v=s(e+"CollectionConsumer",h);return Ht.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((j,N)=>y.indexOf(j.ref.current)-y.indexOf(N.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:d,ItemSlot:g},x,r]}var _w=u.createContext(void 0);function qi(e){const t=u.useContext(_w);return e||t||"ltr"}const Xi=u.forwardRef(({actions:e,className:t,...n},r)=>{const o=(i,l)=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l.onClick())},s=(i,l)=>{var d,f,p,m,g;const c=(d=i.currentTarget.parentElement)==null?void 0:d.querySelectorAll('[role="menuitem"]');if(c)switch(i.key){case"ArrowDown":{i.preventDefault();const x=(l+1)%c.length;(f=c[x])==null||f.focus();break}case"ArrowUp":{i.preventDefault();const x=(l-1+c.length)%c.length;(p=c[x])==null||p.focus();break}case"Home":i.preventDefault(),(m=c[0])==null||m.focus();break;case"End":i.preventDefault(),(g=c[c.length-1])==null||g.focus();break;case"Escape":i.preventDefault(),i.currentTarget.blur();break}};return a.jsx("div",{ref:r,role:"menu",className:be("min-w-[8rem] overflow-hidden",t),...n,children:e.map((i,l)=>a.jsxs(u.Fragment,{children:[i.divider&&l>0&&a.jsx("div",{className:"my-1 h-px bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]"}),a.jsxs("div",{role:"menuitem",tabIndex:0,className:be("relative my-1.5 flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm transition-colors select-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)]"),onClick:i.onClick,onKeyDown:c=>{o(c,i),s(c,l)},children:[i.icon&&i.iconPosition!=="right"&&a.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon}),a.jsx("span",{className:"flex-1",children:i.label}),i.icon&&i.iconPosition==="right"&&a.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon})]})]},i.id))})});Xi.displayName="Menu";var rs="Popover",[rd]=kn(rs,[wr]),qr=wr(),[Iw,_n]=rd(rs),od=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,l=qr(t),c=u.useRef(null),[d,f]=u.useState(!1),[p,m]=Fn({prop:r,defaultProp:o??!1,onChange:s,caller:rs});return a.jsx(Ri,{...l,children:a.jsx(Iw,{scope:t,contentId:en(),triggerRef:c,open:p,onOpenChange:m,onOpenToggle:u.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>f(!0),[]),onCustomAnchorRemove:u.useCallback(()=>f(!1),[]),modal:i,children:n})})};od.displayName=rs;var sd="PopoverAnchor",jw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=_n(sd,n),s=qr(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return u.useEffect(()=>(i(),()=>l()),[i,l]),a.jsx($o,{...s,...r,ref:t})});jw.displayName=sd;var id="PopoverTrigger",ad=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=_n(id,n),s=qr(n),i=$e(t,o.triggerRef),l=a.jsx(ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":fd(o.open),...r,ref:i,onClick:ge(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:a.jsx($o,{asChild:!0,...s,children:l})});ad.displayName=id;var Zi="PopoverPortal",[Rw,Mw]=rd(Zi,{forceMount:void 0}),ld=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=_n(Zi,t);return a.jsx(Rw,{scope:t,forceMount:n,children:a.jsx(xn,{present:n||s.open,children:a.jsx(Yr,{asChild:!0,container:o,children:r})})})};ld.displayName=Zi;var ur="PopoverContent",cd=u.forwardRef((e,t)=>{const n=Mw(ur,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=_n(ur,e.__scopePopover);return a.jsx(xn,{present:r||s.open,children:s.modal?a.jsx(Lw,{...o,ref:t}):a.jsx(Dw,{...o,ref:t})})});cd.displayName=ur;var Pw=Dn("PopoverContent.RemoveScroll"),Lw=u.forwardRef((e,t)=>{const n=_n(ur,e.__scopePopover),r=u.useRef(null),o=$e(t,r),s=u.useRef(!1);return u.useEffect(()=>{const i=r.current;if(i)return Bi(i)},[]),a.jsx(Go,{as:Pw,allowPinchZoom:!0,children:a.jsx(ud,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ge(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:ge(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:ge(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),Dw=u.forwardRef((e,t)=>{const n=_n(ur,e.__scopePopover),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(ud,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),ud=u.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:f,...p}=e,m=_n(ur,n),g=qr(n);return $i(),a.jsx(Ho,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(Gr,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),children:a.jsx(Mi,{"data-state":fd(m.open),role:"dialog",id:m.contentId,...g,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),dd="PopoverClose",Ow=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=_n(dd,n);return a.jsx(ke.button,{type:"button",...r,ref:t,onClick:ge(e.onClick,()=>o.onOpenChange(!1))})});Ow.displayName=dd;var Fw="PopoverArrow",zw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=qr(n);return a.jsx(Pi,{...o,...r,ref:t})});zw.displayName=Fw;function fd(e){return e?"open":"closed"}var $w=od,Bw=ad,Uw=ld,Hw=cd;function pd({...e}){return a.jsx($w,{"data-slot":"popover",...e})}function md({...e}){return a.jsx(Bw,{"data-slot":"popover-trigger",...e})}function hd({className:e,align:t="center",sideOffset:n=4,...r}){return a.jsx(Uw,{children:a.jsx(Hw,{"data-slot":"popover-content",align:t,sideOffset:n,className:be("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background z-50 w-auto origin-(--radix-popover-content-transform-origin) rounded-sm border px-0 py-1 shadow-sm outline-hidden",e),...r})})}function Ww({isOpen:e,onClose:t,anchorRef:n,children:r,placement:o="bottom-start",offset:s,className:i,closeOnClickOutside:l=!0,closeOnEscape:c=!0,portal:d=!0,animationDuration:f=150,fallbackPlacements:p}){const m=u.useRef(null),[g,x]=u.useState({}),[h,v]=u.useState(!1);fw({ref:m,anchorRef:n,onClickOutside:t,enabled:e&&l}),pw({onEscape:t,enabled:e&&c});const{getPositionStyle:b}=gw({anchorRef:n,placement:o,offset:s,fallbackPlacements:p});if(u.useEffect(()=>{e&&m.current?(v(!1),requestAnimationFrame(()=>{if(m.current){const y=b(m.current);x(y),v(!0)}})):v(!1)},[e,b]),!e)return null;const w=a.jsx("div",{ref:m,role:"dialog","aria-modal":"false",className:be("bg-background min-w-[8rem] overflow-hidden border shadow-md",i),style:{...g,opacity:e&&h?1:0,transform:`scale(${e&&h?1:.95})`,transition:`opacity ${f}ms ease-in-out, transform ${f}ms ease-in-out`,pointerEvents:e&&h?"auto":"none",visibility:h?"visible":"hidden"},children:r});return d?Wr.createPortal(w,document.body):w}function al(e,[t,n]){return Math.min(n,Math.max(t,e))}function Gw(e){const t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Vw=[" ","Enter","ArrowUp","ArrowDown"],Yw=[" ","Enter"],Bn="Select",[os,ss,Kw]=nd(Bn),[br]=kn(Bn,[Kw,wr]),is=wr(),[qw,In]=br(Bn),[Xw,Zw]=br(Bn),gd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:l,onValueChange:c,dir:d,name:f,autoComplete:p,disabled:m,required:g,form:x}=e,h=is(t),[v,b]=u.useState(null),[w,y]=u.useState(null),[E,A]=u.useState(!1),j=qi(d),[N,T]=Fn({prop:r,defaultProp:o??!1,onChange:s,caller:Bn}),[G,q]=Fn({prop:i,defaultProp:l,onChange:c,caller:Bn}),W=u.useRef(null),X=v?x||!!v.closest("form"):!0,[ee,O]=u.useState(new Set),Y=Array.from(ee).map(k=>k.props.value).join(";");return a.jsx(Ri,{...h,children:a.jsxs(qw,{required:g,scope:t,trigger:v,onTriggerChange:b,valueNode:w,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:A,contentId:en(),value:G,onValueChange:q,open:N,onOpenChange:T,dir:j,triggerPointerDownPosRef:W,disabled:m,children:[a.jsx(os.Provider,{scope:t,children:a.jsx(Xw,{scope:e.__scopeSelect,onNativeOptionAdd:u.useCallback(k=>{O($=>new Set($).add(k))},[]),onNativeOptionRemove:u.useCallback(k=>{O($=>{const C=new Set($);return C.delete(k),C})},[]),children:n})}),X?a.jsxs(Fd,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:p,value:G,onChange:k=>q(k.target.value),disabled:m,form:x,children:[G===void 0?a.jsx("option",{value:""}):null,Array.from(ee)]},Y):null]})})};gd.displayName=Bn;var xd="SelectTrigger",vd=u.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=is(n),i=In(xd,n),l=i.disabled||r,c=$e(t,i.onTriggerChange),d=ss(n),f=u.useRef("touch"),[p,m,g]=$d(h=>{const v=d().filter(y=>!y.disabled),b=v.find(y=>y.value===i.value),w=Bd(v,h,b);w!==void 0&&i.onValueChange(w.value)}),x=h=>{l||(i.onOpenChange(!0),g()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return a.jsx($o,{asChild:!0,...s,children:a.jsx(ke.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":zd(i.value)?"":void 0,...o,ref:c,onClick:ge(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&x(h)}),onPointerDown:ge(o.onPointerDown,h=>{f.current=h.pointerType;const v=h.target;v.hasPointerCapture(h.pointerId)&&v.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(x(h),h.preventDefault())}),onKeyDown:ge(o.onKeyDown,h=>{const v=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(v&&h.key===" ")&&Vw.includes(h.key)&&(x(),h.preventDefault())})})})});vd.displayName=xd;var wd="SelectValue",bd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...l}=e,c=In(wd,n),{onValueNodeHasChildrenChange:d}=c,f=s!==void 0,p=$e(t,c.onValueNodeChange);return st(()=>{d(f)},[d,f]),a.jsx(ke.span,{...l,ref:p,style:{pointerEvents:"none"},children:zd(c.value)?a.jsx(a.Fragment,{children:i}):s})});bd.displayName=wd;var Jw="SelectIcon",yd=u.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return a.jsx(ke.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});yd.displayName=Jw;var Qw="SelectPortal",Sd=e=>a.jsx(Yr,{asChild:!0,...e});Sd.displayName=Qw;var Un="SelectContent",Cd=u.forwardRef((e,t)=>{const n=In(Un,e.__scopeSelect),[r,o]=u.useState();if(st(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Wr.createPortal(a.jsx(Ed,{scope:e.__scopeSelect,children:a.jsx(os.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),s):null}return a.jsx(Td,{...e,ref:t})});Cd.displayName=Un;var Bt=10,[Ed,jn]=br(Un),e0="SelectContentImpl",t0=Dn("SelectContent.RemoveScroll"),Td=u.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:x,hideWhenDetached:h,avoidCollisions:v,...b}=e,w=In(Un,n),[y,E]=u.useState(null),[A,j]=u.useState(null),N=$e(t,I=>E(I)),[T,G]=u.useState(null),[q,W]=u.useState(null),X=ss(n),[ee,O]=u.useState(!1),Y=u.useRef(!1);u.useEffect(()=>{if(y)return Bi(y)},[y]),$i();const k=u.useCallback(I=>{const[V,...Q]=X().map(se=>se.ref.current),[te]=Q.slice(-1),ae=document.activeElement;for(const se of I)if(se===ae||(se==null||se.scrollIntoView({block:"nearest"}),se===V&&A&&(A.scrollTop=0),se===te&&A&&(A.scrollTop=A.scrollHeight),se==null||se.focus(),document.activeElement!==ae))return},[X,A]),$=u.useCallback(()=>k([T,y]),[k,T,y]);u.useEffect(()=>{ee&&$()},[ee,$]);const{onOpenChange:C,triggerPointerDownPosRef:_}=w;u.useEffect(()=>{if(y){let I={x:0,y:0};const V=te=>{var ae,se;I={x:Math.abs(Math.round(te.pageX)-(((ae=_.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(te.pageY)-(((se=_.current)==null?void 0:se.y)??0))}},Q=te=>{I.x<=10&&I.y<=10?te.preventDefault():y.contains(te.target)||C(!1),document.removeEventListener("pointermove",V),_.current=null};return _.current!==null&&(document.addEventListener("pointermove",V),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",V),document.removeEventListener("pointerup",Q,{capture:!0})}}},[y,C,_]),u.useEffect(()=>{const I=()=>C(!1);return window.addEventListener("blur",I),window.addEventListener("resize",I),()=>{window.removeEventListener("blur",I),window.removeEventListener("resize",I)}},[C]);const[L,R]=$d(I=>{const V=X().filter(ae=>!ae.disabled),Q=V.find(ae=>ae.ref.current===document.activeElement),te=Bd(V,I,Q);te&&setTimeout(()=>te.ref.current.focus())}),J=u.useCallback((I,V,Q)=>{const te=!Y.current&&!Q;(w.value!==void 0&&w.value===V||te)&&(G(I),te&&(Y.current=!0))},[w.value]),P=u.useCallback(()=>y==null?void 0:y.focus(),[y]),B=u.useCallback((I,V,Q)=>{const te=!Y.current&&!Q;(w.value!==void 0&&w.value===V||te)&&W(I)},[w.value]),D=r==="popper"?Zs:Ad,U=D===Zs?{side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:x,hideWhenDetached:h,avoidCollisions:v}:{};return a.jsx(Ed,{scope:n,content:y,viewport:A,onViewportChange:j,itemRefCallback:J,selectedItem:T,onItemLeave:P,itemTextRefCallback:B,focusSelectedItem:$,selectedItemText:q,position:r,isPositioned:ee,searchRef:L,children:a.jsx(Go,{as:t0,allowPinchZoom:!0,children:a.jsx(Ho,{asChild:!0,trapped:w.open,onMountAutoFocus:I=>{I.preventDefault()},onUnmountAutoFocus:ge(o,I=>{var V;(V=w.trigger)==null||V.focus({preventScroll:!0}),I.preventDefault()}),children:a.jsx(Gr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:I=>I.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:a.jsx(D,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:I=>I.preventDefault(),...b,...U,onPlaced:()=>O(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:ge(b.onKeyDown,I=>{const V=I.ctrlKey||I.altKey||I.metaKey;if(I.key==="Tab"&&I.preventDefault(),!V&&I.key.length===1&&R(I.key),["ArrowUp","ArrowDown","Home","End"].includes(I.key)){let te=X().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(I.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(I.key)){const ae=I.target,se=te.indexOf(ae);te=te.slice(se+1)}setTimeout(()=>k(te)),I.preventDefault()}})})})})})})});Td.displayName=e0;var n0="SelectItemAlignedPosition",Ad=u.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=In(Un,n),i=jn(Un,n),[l,c]=u.useState(null),[d,f]=u.useState(null),p=$e(t,N=>f(N)),m=ss(n),g=u.useRef(!1),x=u.useRef(!0),{viewport:h,selectedItem:v,selectedItemText:b,focusSelectedItem:w}=i,y=u.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&h&&v&&b){const N=s.trigger.getBoundingClientRect(),T=d.getBoundingClientRect(),G=s.valueNode.getBoundingClientRect(),q=b.getBoundingClientRect();if(s.dir!=="rtl"){const ae=q.left-T.left,se=G.left-ae,pe=N.left-se,ye=N.width+pe,_e=Math.max(ye,T.width),Ie=window.innerWidth-Bt,Pe=al(se,[Bt,Math.max(Bt,Ie-_e)]);l.style.minWidth=ye+"px",l.style.left=Pe+"px"}else{const ae=T.right-q.right,se=window.innerWidth-G.right-ae,pe=window.innerWidth-N.right-se,ye=N.width+pe,_e=Math.max(ye,T.width),Ie=window.innerWidth-Bt,Pe=al(se,[Bt,Math.max(Bt,Ie-_e)]);l.style.minWidth=ye+"px",l.style.right=Pe+"px"}const W=m(),X=window.innerHeight-Bt*2,ee=h.scrollHeight,O=window.getComputedStyle(d),Y=parseInt(O.borderTopWidth,10),k=parseInt(O.paddingTop,10),$=parseInt(O.borderBottomWidth,10),C=parseInt(O.paddingBottom,10),_=Y+k+ee+C+$,L=Math.min(v.offsetHeight*5,_),R=window.getComputedStyle(h),J=parseInt(R.paddingTop,10),P=parseInt(R.paddingBottom,10),B=N.top+N.height/2-Bt,D=X-B,U=v.offsetHeight/2,I=v.offsetTop+U,V=Y+k+I,Q=_-V;if(V<=B){const ae=W.length>0&&v===W[W.length-1].ref.current;l.style.bottom="0px";const se=d.clientHeight-h.offsetTop-h.offsetHeight,pe=Math.max(D,U+(ae?P:0)+se+$),ye=V+pe;l.style.height=ye+"px"}else{const ae=W.length>0&&v===W[0].ref.current;l.style.top="0px";const pe=Math.max(B,Y+h.offsetTop+(ae?J:0)+U)+Q;l.style.height=pe+"px",h.scrollTop=V-B+h.offsetTop}l.style.margin=`${Bt}px 0`,l.style.minHeight=L+"px",l.style.maxHeight=X+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[m,s.trigger,s.valueNode,l,d,h,v,b,s.dir,r]);st(()=>y(),[y]);const[E,A]=u.useState();st(()=>{d&&A(window.getComputedStyle(d).zIndex)},[d]);const j=u.useCallback(N=>{N&&x.current===!0&&(y(),w==null||w(),x.current=!1)},[y,w]);return a.jsx(o0,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:j,children:a.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:a.jsx(ke.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ad.displayName=n0;var r0="SelectPopperPosition",Zs=u.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Bt,...s}=e,i=is(n);return a.jsx(Mi,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Zs.displayName=r0;var[o0,Ji]=br(Un,{}),Js="SelectViewport",Nd=u.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=jn(Js,n),i=Ji(Js,n),l=$e(t,s.onViewportChange),c=u.useRef(0);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),a.jsx(os.Slot,{scope:n,children:a.jsx(ke.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ge(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const g=Math.abs(c.current-f.scrollTop);if(g>0){const x=window.innerHeight-Bt*2,h=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),b=Math.max(h,v);if(b<x){const w=b+g,y=Math.min(x,w),E=w-y;p.style.height=y+"px",p.style.bottom==="0px"&&(f.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});Nd.displayName=Js;var kd="SelectGroup",[s0,i0]=br(kd),a0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=en();return a.jsx(s0,{scope:n,id:o,children:a.jsx(ke.div,{role:"group","aria-labelledby":o,...r,ref:t})})});a0.displayName=kd;var _d="SelectLabel",l0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=i0(_d,n);return a.jsx(ke.div,{id:o.id,...r,ref:t})});l0.displayName=_d;var ko="SelectItem",[c0,Id]=br(ko),jd=u.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,l=In(ko,n),c=jn(ko,n),d=l.value===r,[f,p]=u.useState(s??""),[m,g]=u.useState(!1),x=$e(t,w=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,w,r,o)}),h=en(),v=u.useRef("touch"),b=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return a.jsx(c0,{scope:n,value:r,disabled:o,textId:h,isSelected:d,onItemTextChange:u.useCallback(w=>{p(y=>y||((w==null?void 0:w.textContent)??"").trim())},[]),children:a.jsx(os.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:a.jsx(ke.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:ge(i.onFocus,()=>g(!0)),onBlur:ge(i.onBlur,()=>g(!1)),onClick:ge(i.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:ge(i.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:ge(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:ge(i.onPointerMove,w=>{var y;v.current=w.pointerType,o?(y=c.onItemLeave)==null||y.call(c):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ge(i.onPointerLeave,w=>{var y;w.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:ge(i.onKeyDown,w=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(Yw.includes(w.key)&&b(),w.key===" "&&w.preventDefault())})})})})});jd.displayName=ko;var Mr="SelectItemText",Rd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=In(Mr,n),l=jn(Mr,n),c=Id(Mr,n),d=Zw(Mr,n),[f,p]=u.useState(null),m=$e(t,b=>p(b),c.onItemTextChange,b=>{var w;return(w=l.itemTextRefCallback)==null?void 0:w.call(l,b,c.value,c.disabled)}),g=f==null?void 0:f.textContent,x=u.useMemo(()=>a.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:h,onNativeOptionRemove:v}=d;return st(()=>(h(x),()=>v(x)),[h,v,x]),a.jsxs(a.Fragment,{children:[a.jsx(ke.span,{id:c.textId,...s,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Wr.createPortal(s.children,i.valueNode):null]})});Rd.displayName=Mr;var Md="SelectItemIndicator",Pd=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Id(Md,n).isSelected?a.jsx(ke.span,{"aria-hidden":!0,...r,ref:t}):null});Pd.displayName=Md;var Qs="SelectScrollUpButton",Ld=u.forwardRef((e,t)=>{const n=jn(Qs,e.__scopeSelect),r=Ji(Qs,e.__scopeSelect),[o,s]=u.useState(!1),i=$e(t,r.onScrollButtonChange);return st(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollTop>0;s(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Od,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});Ld.displayName=Qs;var ei="SelectScrollDownButton",Dd=u.forwardRef((e,t)=>{const n=jn(ei,e.__scopeSelect),r=Ji(ei,e.__scopeSelect),[o,s]=u.useState(!1),i=$e(t,r.onScrollButtonChange);return st(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<d;s(f)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Od,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});Dd.displayName=ei;var Od=u.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=jn("SelectScrollButton",n),i=u.useRef(null),l=ss(n),c=u.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),st(()=>{var f;const d=l().find(p=>p.ref.current===document.activeElement);(f=d==null?void 0:d.ref.current)==null||f.scrollIntoView({block:"nearest"})},[l]),a.jsx(ke.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ge(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ge(o.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ge(o.onPointerLeave,()=>{c()})})}),u0="SelectSeparator",d0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return a.jsx(ke.div,{"aria-hidden":!0,...r,ref:t})});d0.displayName=u0;var ti="SelectArrow",f0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=is(n),s=In(ti,n),i=jn(ti,n);return s.open&&i.position==="popper"?a.jsx(Pi,{...o,...r,ref:t}):null});f0.displayName=ti;var p0="SelectBubbleInput",Fd=u.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=u.useRef(null),s=$e(r,o),i=Gw(t);return u.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const p=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(p)}},[i,t]),a.jsx(ke.select,{...n,style:{...Bc,...n.style},ref:s,defaultValue:t})});Fd.displayName=p0;function zd(e){return e===""||e===void 0}function $d(e){const t=Cn(e),n=u.useRef(""),r=u.useRef(0),o=u.useCallback(i=>{const l=n.current+i;t(l),(function c(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),s=u.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return u.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Bd(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=m0(e,Math.max(s,0));o.length===1&&(i=i.filter(d=>d!==n));const c=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function m0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var h0=gd,g0=vd,x0=bd,v0=yd,w0=Sd,b0=Cd,y0=Nd,S0=jd,C0=Rd,E0=Pd,T0=Ld,A0=Dd;function Ud({...e}){return a.jsx(h0,{"data-slot":"select",...e})}function Hd({...e}){return a.jsx(x0,{"data-slot":"select-value",...e})}function Wd({className:e,size:t="default",children:n,...r}){return a.jsxs(g0,{"data-slot":"select-trigger","data-size":t,className:be("flex w-fit items-center justify-between gap-2 border px-3 py-2 text-sm whitespace-nowrap shadow-xs disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,a.jsx(v0,{asChild:!0,children:a.jsx(Hl,{className:"size-4 opacity-50"})})]})}function Gd({className:e,children:t,position:n="popper",...r}){return a.jsx(w0,{children:a.jsxs(b0,{"data-slot":"select-content",className:be("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[a.jsx(N0,{}),a.jsx(y0,{className:be("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),a.jsx(k0,{})]})})}function Vd({className:e,children:t,...n}){return a.jsxs(S0,{"data-slot":"select-item",className:be("[&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 py-1.5 pr-8 pl-2 text-sm select-none hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[a.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:a.jsx(E0,{children:a.jsx(xi,{className:"size-4"})})}),a.jsx(C0,{children:t})]})}function N0({className:e,...t}){return a.jsx(T0,{"data-slot":"select-scroll-up-button",className:be("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Dp,{className:"size-4"})})}function k0({className:e,...t}){return a.jsx(A0,{"data-slot":"select-scroll-down-button",className:be("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Hl,{className:"size-4"})})}var _s="rovingFocusGroup.onEntryFocus",_0={bubbles:!1,cancelable:!0},Xr="RovingFocusGroup",[ni,Yd,I0]=nd(Xr),[j0,Kd]=kn(Xr,[I0]),[R0,M0]=j0(Xr),qd=u.forwardRef((e,t)=>a.jsx(ni.Provider,{scope:e.__scopeRovingFocusGroup,children:a.jsx(ni.Slot,{scope:e.__scopeRovingFocusGroup,children:a.jsx(P0,{...e,ref:t})})}));qd.displayName=Xr;var P0=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,m=u.useRef(null),g=$e(t,m),x=qi(s),[h,v]=Fn({prop:i,defaultProp:l??null,onChange:c,caller:Xr}),[b,w]=u.useState(!1),y=Cn(d),E=Yd(n),A=u.useRef(!1),[j,N]=u.useState(0);return u.useEffect(()=>{const T=m.current;if(T)return T.addEventListener(_s,y),()=>T.removeEventListener(_s,y)},[y]),a.jsx(R0,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:h,onItemFocus:u.useCallback(T=>v(T),[v]),onItemShiftTab:u.useCallback(()=>w(!0),[]),onFocusableItemAdd:u.useCallback(()=>N(T=>T+1),[]),onFocusableItemRemove:u.useCallback(()=>N(T=>T-1),[]),children:a.jsx(ke.div,{tabIndex:b||j===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:ge(e.onMouseDown,()=>{A.current=!0}),onFocus:ge(e.onFocus,T=>{const G=!A.current;if(T.target===T.currentTarget&&G&&!b){const q=new CustomEvent(_s,_0);if(T.currentTarget.dispatchEvent(q),!q.defaultPrevented){const W=E().filter(k=>k.focusable),X=W.find(k=>k.active),ee=W.find(k=>k.id===h),Y=[X,ee,...W].filter(Boolean).map(k=>k.ref.current);Jd(Y,f)}}A.current=!1}),onBlur:ge(e.onBlur,()=>w(!1))})})}),Xd="RovingFocusGroupItem",Zd=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...l}=e,c=en(),d=s||c,f=M0(Xd,n),p=f.currentTabStopId===d,m=Yd(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:h}=f;return u.useEffect(()=>{if(r)return g(),()=>x()},[r,g,x]),a.jsx(ni.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:a.jsx(ke.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:ge(e.onMouseDown,v=>{r?f.onItemFocus(d):v.preventDefault()}),onFocus:ge(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:ge(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=O0(v,f.orientation,f.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let y=m().filter(E=>E.focusable).map(E=>E.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const E=y.indexOf(v.currentTarget);y=f.loop?F0(y,E+1):y.slice(E+1)}setTimeout(()=>Jd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:h!=null}):i})})});Zd.displayName=Xd;var L0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function D0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function O0(e,t,n){const r=D0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return L0[r]}function Jd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function F0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var z0=qd,$0=Zd,as="Tabs",[B0]=kn(as,[Kd]),Qd=Kd(),[U0,Qi]=B0(as),ef=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:l,activationMode:c="automatic",...d}=e,f=qi(l),[p,m]=Fn({prop:r,onChange:o,defaultProp:s??"",caller:as});return a.jsx(U0,{scope:n,baseId:en(),value:p,onValueChange:m,orientation:i,dir:f,activationMode:c,children:a.jsx(ke.div,{dir:f,"data-orientation":i,...d,ref:t})})});ef.displayName=as;var tf="TabsList",nf=u.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=Qi(tf,n),i=Qd(n);return a.jsx(z0,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:a.jsx(ke.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});nf.displayName=tf;var rf="TabsTrigger",of=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=Qi(rf,n),l=Qd(n),c=lf(i.baseId,r),d=cf(i.baseId,r),f=r===i.value;return a.jsx($0,{asChild:!0,...l,focusable:!o,active:f,children:a.jsx(ke.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:t,onMouseDown:ge(e.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?i.onValueChange(r):p.preventDefault()}),onKeyDown:ge(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&i.onValueChange(r)}),onFocus:ge(e.onFocus,()=>{const p=i.activationMode!=="manual";!f&&!o&&p&&i.onValueChange(r)})})})});of.displayName=rf;var sf="TabsContent",af=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,l=Qi(sf,n),c=lf(l.baseId,r),d=cf(l.baseId,r),f=r===l.value,p=u.useRef(f);return u.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),a.jsx(xn,{present:o||f,children:({present:m})=>a.jsx(ke.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&s})})});af.displayName=sf;function lf(e,t){return`${e}-trigger-${t}`}function cf(e,t){return`${e}-content-${t}`}var H0=ef,W0=nf,G0=of,V0=af;function Y0({className:e,...t}){return a.jsx(H0,{"data-slot":"tabs",className:be("flex flex-col gap-2",e),...t})}function K0({className:e,...t}){return a.jsx(W0,{"data-slot":"tabs-list",className:be("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function ll({className:e,...t}){return a.jsx(G0,{"data-slot":"tabs-trigger","data-testid":t.value,"aria-label":t.value,title:t.title,className:be("data-[state=active]:bg-background dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow,background-color] hover:bg-[var(--color-brand-w10)] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-[var(--color-brand-wMain)] data-[state=active]:shadow-sm dark:hover:bg-[var(--color-brand-wMain30)] dark:data-[state=active]:text-[var(--color-brand-wMain)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function cl({className:e,...t}){return a.jsx(V0,{"data-slot":"tabs-content",className:be("flex-1 outline-none",e),...t})}const uf=u.forwardRef(({className:e,...t},n)=>a.jsx(eu,{autoComplete:"off",ref:n,name:"message","data-testid":"chat-input",className:be("flex w-full items-center rounded-md px-4 py-3 placeholder:text-[var(--color-secondary-wMain)] disabled:cursor-not-allowed disabled:opacity-50",e),...t}));uf.displayName="ChatInput";const q0=Nn("flex gap-2 max-w-[90%] items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),df=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:be(q0({variant:t,layout:n,className:e}),"group relative"),ref:s,...o,children:u.Children.map(r,i=>u.isValidElement(i)&&typeof i.type!="string"?u.cloneElement(i,{variant:t,layout:n}):i)}));df.displayName="ChatBubble";const X0=Nn("p-4",{variants:{variant:{received:"rounded-r-lg rounded-tl-lg",sent:"rounded-l-lg rounded-tr-lg justify-end bg-[var(--message-background)]"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),ff=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:be(X0({variant:t,layout:n,className:e}),"relative max-w-full break-words whitespace-pre-wrap"),ref:s,...o,children:a.jsx(a.Fragment,{children:r})}));ff.displayName="ChatBubbleMessage";const Z0=u.forwardRef(({variant:e,className:t,children:n,...r},o)=>a.jsx("div",{ref:o,className:be("absolute top-1/2 flex -translate-y-1/2 opacity-0 transition-opacity duration-200 group-hover:opacity-100",e==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",t),...r,children:n}));Z0.displayName="ChatBubbleActionWrapper";const pf={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},mf=Ht.forwardRef(({className:e="",children:t,...n},r)=>{const{scrollRef:o,isAtBottom:s,disableAutoScroll:i,scrollToBottom:l,userHasScrolled:c}=lb({smooth:!0,content:t});return u.useImperativeHandle(r,()=>({scrollToBottom:l})),a.jsxs("div",{className:`fade-both-mask relative h-full min-h-0 w-full flex-1 py-3 ${e}`,children:[a.jsx("div",{className:"flex h-full w-full flex-col overflow-y-auto p-4",ref:o,onWheel:i,onTouchMove:i,...n,style:{scrollBehavior:"smooth"},children:a.jsx("div",{className:"flex flex-col gap-6",style:pf,children:t})}),!s&&c&&a.jsx(xe,{onClick:()=>{l()},size:"icon",variant:"outline",className:"bg-background absolute bottom-2 left-1/2 z-20 inline-flex -translate-x-1/2 transform rounded-full shadow-md","aria-label":"Scroll to bottom",children:a.jsx(Wl,{className:"h-4 w-4"})})]})});mf.displayName="ChatMessageList";const J0=Nn("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),Q0=Nn("animate-spin",{variants:{size:{small:"size-4",medium:"size-8",large:"size-12"},variant:{primary:"text-[var(--color-brand-wMain)]",secondary:"text-[var(--color-primary-wMain)]",muted:"text-[var(--color-secondary-text-wMain)] dark:text-[var(--color-secondary-text-w50)]",foreground:"text-foreground"}},defaultVariants:{size:"medium",variant:"primary"}});function eb({size:e,show:t,children:n,className:r,variant:o}){return a.jsxs("span",{className:J0({show:t}),children:[a.jsx(vi,{className:be(Q0({size:e,variant:o}),r)}),n]})}function tb({className:e=""}){return a.jsx(eb,{size:"small",variant:"primary",className:e})}const lo={error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-wMain)]"},nb=Nn("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent [a&]:hover:bg-primary/90",secondary:"border-transparent [a&]:hover:bg-secondary/90",destructive:"border-transparent [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"},type:{error:lo.error,warning:lo.warning,info:lo.info,success:lo.success}},defaultVariants:{variant:"default"}});function hf({className:e,variant:t,type:n,asChild:r=!1,...o}){const s=r?oc:"span";return a.jsx(s,{"data-slot":"badge",className:be(nb({variant:t,type:n}),e),...o})}const rb=Nn("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function ob({className:e,variant:t,...n}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:be(rb({variant:t}),e),...n})}function sb({className:e,...t}){return a.jsx("div",{"data-slot":"alert-title",className:be("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function ib({message:e,type:t}){return a.jsx("div",{className:"transform transition-all duration-200 ease-in-out",children:a.jsx(ob,{className:"border-border bg-accent max-w-80 rounded-sm shadow-md",children:a.jsxs(sb,{className:"flex items-center text-sm",children:[t==="error"&&a.jsx(wi,{className:"mr-2 text-[var(--color-error-wMain)]"}),a.jsx("div",{className:"truncate",children:e})]})})})}function ab(){const{notifications:e}=He();return e.length===0?null:a.jsx("div",{className:"pointer-events-none fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 transform flex-col-reverse gap-2",children:e.map(t=>a.jsx("div",{className:"pointer-events-auto",children:a.jsx(ib,{id:t.id,message:t.message,type:t.type,duration:t.type==="error"?5e3:3e3})},t.id))})}function lb(e={}){const{offset:t=20,smooth:n=!1,content:r,autoScrollOnNewContent:o=!1}=e,s=u.useRef(null),i=u.useRef(0),l=u.useRef(!1),[c,d]=u.useState({isAtBottom:!0,autoScrollEnabled:!0}),f=u.useCallback(x=>{const{scrollTop:h,scrollHeight:v,clientHeight:b}=x;return Math.abs(v-h-b)<=t},[t]),p=u.useCallback(x=>{if(!s.current)return;const h=s.current.scrollHeight-s.current.clientHeight;x?s.current.scrollTop=h:s.current.scrollTo({top:h,behavior:n?"smooth":"auto"}),d({isAtBottom:!0,autoScrollEnabled:!0}),l.current=!1},[n]),m=u.useCallback(()=>{if(!s.current)return;const x=f(s.current);d(h=>({isAtBottom:x,autoScrollEnabled:x?!0:h.autoScrollEnabled}))},[f]);u.useEffect(()=>{const x=s.current;if(x)return x.addEventListener("scroll",m,{passive:!0}),()=>x.removeEventListener("scroll",m)},[m]),u.useEffect(()=>{const x=s.current;if(!x)return;const h=x.scrollHeight;h!==i.current&&((c.autoScrollEnabled||o)&&requestAnimationFrame(()=>{p(i.current===0)}),i.current=h)},[r,c.autoScrollEnabled,p,o]),u.useEffect(()=>{const x=s.current;if(!x)return;const h=new ResizeObserver(()=>{c.autoScrollEnabled&&p(!0)});return h.observe(x),()=>h.disconnect()},[c.autoScrollEnabled,p]);const g=u.useCallback(()=>{(s.current?f(s.current):!1)||(l.current=!0,d(h=>({...h,autoScrollEnabled:!1})))},[f]);return{scrollRef:s,isAtBottom:c.isAtBottom,autoScrollEnabled:c.autoScrollEnabled,scrollToBottom:()=>p(),disableAutoScroll:g,userHasScrolled:l.current}}const cb=({fileName:e,onRemove:t})=>a.jsxs(hf,{className:"bg-muted max-w-50 gap-1.5 rounded-full pr-1",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs md:text-sm",title:e,children:e}),t&&a.jsx(xe,{variant:"ghost",size:"icon",onClick:t,className:"h-2 min-h-0 w-2 min-w-0 p-2",title:"Remove file",children:a.jsx(Lo,{})})]}),ub=({agents:e=[],scrollToBottom:t})=>{const{isResponding:n,isCancelling:r,userInput:o,selectedAgentName:s,setSelectedAgentName:i,setUserInput:l,handleSubmit:c,handleCancel:d}=He(),f=u.useRef(null),[p,m]=u.useState([]),g=u.useRef(null),x=u.useRef(n),[h,v]=u.useState(o),b=Aw(h,300);u.useEffect(()=>{l(b)},[b,l]),u.useEffect(()=>{v(o)},[o]),u.useEffect(()=>{x.current&&!n&&setTimeout(()=>{var O;(O=g.current)==null||O.focus()},100),x.current=n},[n]);const w=()=>{var O;n||(O=f.current)==null||O.click()},y=O=>{const Y=O.target.files;if(Y){const k=Array.from(Y).filter($=>!p.some(C=>C.name===$.name&&C.size===$.size&&C.lastModified===$.lastModified));k.length>0&&m($=>[...$,...k])}O.target&&(O.target.value=""),setTimeout(()=>{var k;(k=g.current)==null||k.focus()},100)},E=O=>{if(n)return;const Y=O.clipboardData;if(!Y||!Y.files||Y.files.length===0)return;Y.files.length>0&&O.preventDefault();const k=Array.from(Y.files).filter($=>!p.some(C=>C.name===$.name&&C.size===$.size&&C.lastModified===$.lastModified));k.length>0&&m($=>[...$,...k])},A=O=>{m(Y=>Y.filter((k,$)=>$!==O))},j=u.useMemo(()=>!n&&((h==null?void 0:h.trim())||p.length!==0),[n,h,p]),N=async O=>{O.preventDefault(),j&&(await c(O,p,h.trim()),m([]),v(""),t==null||t())},T=O=>{if(n)return;const Y=O.filter(k=>!p.some($=>$.name===k.name&&$.size===k.size&&$.lastModified===k.lastModified));Y.length>0&&m(k=>[...k,...Y])},{isDragging:G,handleDragEnter:q,handleDragOver:W,handleDragLeave:X,handleDrop:ee}=kw({onFilesDropped:T,disabled:n});return a.jsxs("div",{className:`rounded-lg border p-4 shadow-sm ${G?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:q,onDragOver:W,onDragLeave:X,onDrop:ee,children:[a.jsx("input",{type:"file",ref:f,className:"hidden",multiple:!0,onChange:y,accept:"*/*",disabled:n}),p.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:p.map((O,Y)=>a.jsx(cb,{fileName:O.name,onRemove:()=>A(Y)},`${O.name}-${O.lastModified}-${Y}`))}),a.jsx(uf,{ref:g,value:h,onChange:O=>v(O.target.value),placeholder:"How can I help you today?",className:"field-sizing-content max-h-50 min-h-0 resize-none rounded-2xl border-none p-3 text-base/normal shadow-none transition-[height] duration-500 ease-in-out focus-visible:outline-none",rows:1,onPaste:E,onKeyDown:O=>{O.key==="Enter"&&!O.shiftKey&&j&&N(O)}}),a.jsxs("div",{className:"m-2 flex items-center gap-2",children:[a.jsx(xe,{variant:"ghost",onClick:w,disabled:n,tooltip:"Attach file",children:a.jsx(Gl,{className:"size-4"})}),a.jsx("div",{children:"Agent: "}),a.jsxs(Ud,{value:s,onValueChange:i,disabled:n||e.length===0,children:[a.jsx(Wd,{className:"w-[250px]",children:a.jsx(Hd,{defaultValue:s})}),a.jsx(Gd,{children:e.map(O=>a.jsx(Vd,{value:O.name,children:O.displayName||O.name},O.name))})]}),n&&!r?a.jsxs(xe,{className:"ml-auto gap-1.5",onClick:d,variant:"outline",disabled:r,tooltip:"Cancel",children:[a.jsx(Op,{className:"size-4"}),"Stop"]}):a.jsx(xe,{variant:"ghost",className:"ml-auto gap-1.5",onClick:N,disabled:!j,tooltip:"Send message",children:a.jsx(Fp,{className:"size-4"})})]})]})};function db(e,t){return t&&t.toLowerCase().startsWith("text/")?!0:e?e.toLowerCase().endsWith(".txt")||e.toLowerCase().endsWith(".text"):!1}function fb(e,t){if(t){const n=t.toLowerCase();if(n==="text/html"||n==="application/xhtml+xml")return!0}return e?e.toLowerCase().endsWith(".html")||e.toLowerCase().endsWith(".htm"):!1}function pb(e,t){if(t){const n=t.toLowerCase();if(n==="text/x-mermaid"||n==="application/x-mermaid")return!0}return e?e.toLowerCase().endsWith(".mermaid")||e.toLowerCase().endsWith(".mmd"):!1}function mb(e,t){if(t){const n=t.toLowerCase();if(n==="text/csv"||n==="application/csv")return!0}return e?e.toLowerCase().endsWith(".csv"):!1}function hb(e,t){if(t&&t.toLowerCase().startsWith("image/"))return!0;if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".png")||n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".gif")||n.endsWith(".bmp")||n.endsWith(".webp")||n.endsWith(".svg")}function gb(e,t){if(t){const n=t.toLowerCase();if(n==="application/json"||n==="text/json")return!0}return e?e.toLowerCase().endsWith(".json"):!1}function xb(e,t){if(t){const r=t.toLowerCase();if(r==="application/yaml"||r==="text/yaml"||r==="application/x-yaml"||r==="text/x-yaml")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".yaml")||n.endsWith(".yml")}function vb(e,t){if(t){const r=t.toLowerCase();if(r==="text/markdown"||r==="application/markdown"||r==="text/x-markdown")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function wb(e,t){if(t&&t.toLowerCase().startsWith("audio/"))return!0;if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".mp3")||n.endsWith(".wav")||n.endsWith(".ogg")||n.endsWith(".aac")||n.endsWith(".flac")||n.endsWith(".m4a")}function Zr(e,t){return fb(e,t)?"html":pb(e,t)?"mermaid":hb(e,t)?"image":vb(e,t)?"markdown":wb(e,t)?"audio":gb(e,t)?"json":xb(e,t)?"yaml":mb(e,t)?"csv":db(e,t)?"text":null}function gf(e){try{const t=Uint8Array.from(atob(e),n=>n.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!1}).decode(t)}catch(t){console.warn("TextDecoder failed (potentially non-UTF8 data), falling back to simple atob:",t);try{return atob(e)}catch(n){return console.error("Failed to decode base64 content with atob fallback:",n),e}}}const xf=["csv","html","json","mermaid","image","markdown","audio","text","yaml"],bb=["image","audio"],yb=e=>{if(!e||!e.content)return"";const t=Zr(e.name,e.mime_type);if(!t||!xf.includes(t))return"";if(bb.includes(t))return e.content;try{return gf(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},vf=5*1024*1024,Sb=xc(vf);function Cb(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=Zr(e.filename,e.mime_type);return!t||!xf.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>vf?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${Sb}.`}:{canPreview:!0}}const wf=(e,t="h-4 w-4")=>{if(!e)return a.jsx(pa,{className:t});switch(Zr(e.filename,e.mime_type)){case"image":case"mermaid":return a.jsx(Hp,{className:t});case"audio":return a.jsx(Up,{className:t});case"html":return a.jsx(Bp,{className:t});case"text":return a.jsx(ar,{className:t});case"csv":return a.jsx($p,{className:t});case"json":return a.jsx(zp,{className:t});default:return a.jsx(pa,{className:t})}},bf=({fileAttachment:e,isEmbedded:t=!1})=>a.jsx(yf,{filename:e.name,mimeType:e.mime_type,onDownload:()=>lh(e),className:"ml-4",isEmbedded:t}),yf=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:o=!1})=>{const{artifacts:s,setPreviewArtifact:i,openSidePanelTab:l}=He(),c=u.useMemo(()=>s.find(f=>f.filename===e),[s,e]),d=u.useMemo(()=>wf(c||{filename:e,mime_type:t||""}),[c,e,t]);return a.jsxs("div",{className:`flex h-11 max-w-xs flex-shrink items-center gap-2 rounded-lg bg-[var(--accent-background)] px-2 py-1 ${n||""}`,children:[d,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-9",title:e,children:a.jsx("strong",{children:a.jsx("code",{children:e})})}),c&&!o&&a.jsx(xe,{variant:"ghost",onClick:f=>{f.stopPropagation(),l("files"),i(c)},tooltip:"Preview",children:a.jsx(Vl,{className:"h-4 w-4"})}),r&&a.jsx(xe,{variant:"ghost",onClick:()=>r(),tooltip:"Download file",children:a.jsx(bi,{className:"h-4 w-4"})})]})},Eb=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"audio/mpeg"};base64,${e}`;return a.jsx("div",{className:"flex h-auto max-w-[100vw] items-center justify-center p-4",children:a.jsxs("audio",{controls:!0,className:"w-full",onLoad:()=>n(null),onError:()=>n("Failed to load audio content."),children:[a.jsx("source",{src:r,type:t||"audio/mpeg"}),"Your browser does not support the audio element."]})})},Tb=e=>{if(!e)return[];const t=[];let n=[],r="",o=!1;for(let s=0;s<e.length;s++){const i=e[s],l=s<e.length-1?e[s+1]:"";i==='"'?l==='"'?(r+='"',s++):o=!o:i===","&&!o?(n.push(r.trim()),r=""):(i===`
117
+ `||i==="\r"&&l===`
118
+ `)&&!o?(i==="\r"&&l===`
119
+ `&&s++,n.push(r.trim()),r="",n.some(c=>c.trim())?(t.push(n),n=[]):n=[]):r+=i}return(r||n.length>0)&&(n.push(r.trim()),n.some(s=>s.trim())&&t.push(n)),t},Ab=({content:e,setRenderError:t})=>{u.useEffect(()=>{t(null)},[e,t]);const n=u.useMemo(()=>{try{return Tb(e)}catch(r){return console.error("Error parsing CSV:",r),t("Failed to parse CSV content."),[]}},[e,t]);return n.length?a.jsx("div",{className:"block w-full overflow-x-scroll p-4",children:a.jsx("div",{style:{minWidth:"min(100%, max-content)"},children:a.jsxs("table",{className:"w-full border text-sm",children:[a.jsx("thead",{className:"sticky top-0 z-10 shadow-sm",children:n.length>0&&a.jsx("tr",{children:n[0].map((r,o)=>a.jsx("th",{className:"border-b p-2 text-left font-medium whitespace-nowrap",title:r,children:(r==null?void 0:r.trim())||""},`header-${o}`))})}),a.jsx("tbody",{children:n.slice(1).map((r,o)=>a.jsx("tr",{className:o%2===0?"bg-muted dark:bg-gray-700":"",children:r.map((s,i)=>a.jsx("td",{className:"min-w-0 border-b p-2 align-top break-words",title:s,children:(s==null?void 0:s.trim())||""},`cell-${o}-${i}`))},`row-${o}`))})]})})}):a.jsx("div",{children:"No valid CSV content found or failed to parse."})},Nb=({content:e,setRenderError:t})=>{const n=u.useMemo(()=>e.replace(/<script(?:\s[^>]*)?>([\s\S]*?)<\/script>/gi,(s,i)=>{const l=s.match(/<script(\s[^>]*)?>/i);return`<script${l&&l[1]?l[1]:""}>(function() {
120
+ try {
121
+ ${i}
122
+ } catch (e) { console.error('Error in sandboxed script:', e); }
123
+ })();<\/script>`}),[e]);return a.jsx("div",{className:"h-full w-full overflow-hidden border dark:bg-gray-400",children:a.jsx("iframe",{srcDoc:n,title:"HTML Preview",sandbox:"allow-scripts allow-same-origin allow-downloads allow-forms allow-popups",allow:"autoplay",className:"h-full w-full border-none",onError:()=>t("Failed to load HTML content."),onLoad:()=>t(null)})})},kb=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"image/png"};base64,${e}`;return a.jsx("div",{className:"flex h-auto w-auto max-w-[100vw] items-center justify-center p-4",children:a.jsx("img",{src:r,onError:()=>n("Failed to load image"),onLoad:()=>n(null),alt:"Preview",className:"h-full w-full object-contain"})})};function Sf(){const e=u.useRef(null),t=()=>{if(e.current){const r=document.createRange();r.selectNodeContents(e.current);const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(r))}};return{ref:e,handleKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="a"&&(r.preventDefault(),t())},selectAllContent:t}}const _b=({content:e})=>{const{ref:t,handleKeyDown:n}=Sf();return a.jsx("div",{className:"w-full p-4",children:a.jsx("div",{ref:t,className:"max-w-full overflow-hidden select-text focus-visible:outline-none",tabIndex:0,onKeyDown:n,children:a.jsx(ir,{className:"max-w-full break-words",children:e})})})};/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:Cf,setPrototypeOf:ul,isFrozen:Ib,getPrototypeOf:jb,getOwnPropertyDescriptor:Rb}=Object;let{freeze:ut,seal:It,create:Ef}=Object,{apply:ri,construct:oi}=typeof Reflect<"u"&&Reflect;ut||(ut=function(t){return t});It||(It=function(t){return t});ri||(ri=function(t,n,r){return t.apply(n,r)});oi||(oi=function(t,n){return new t(...n)});const co=dt(Array.prototype.forEach),Mb=dt(Array.prototype.lastIndexOf),dl=dt(Array.prototype.pop),Er=dt(Array.prototype.push),Pb=dt(Array.prototype.splice),bo=dt(String.prototype.toLowerCase),Is=dt(String.prototype.toString),fl=dt(String.prototype.match),Tr=dt(String.prototype.replace),Lb=dt(String.prototype.indexOf),Db=dt(String.prototype.trim),Ut=dt(Object.prototype.hasOwnProperty),at=dt(RegExp.prototype.test),Ar=Ob(TypeError);function dt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return ri(e,t,r)}}function Ob(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return oi(e,n)}}function Ae(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bo;ul&&ul(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(Ib(t)||(t[r]=s),o=s)}e[o]=!0}return e}function Fb(e){for(let t=0;t<e.length;t++)Ut(e,t)||(e[t]=null);return e}function dn(e){const t=Ef(null);for(const[n,r]of Cf(e))Ut(e,n)&&(Array.isArray(r)?t[n]=Fb(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=dn(r):t[n]=r);return t}function Nr(e,t){for(;e!==null;){const r=Rb(e,t);if(r){if(r.get)return dt(r.get);if(typeof r.value=="function")return dt(r.value)}e=jb(e)}function n(){return null}return n}const pl=ut(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),js=ut(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Rs=ut(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),zb=ut(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ms=ut(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$b=ut(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ml=ut(["#text"]),hl=ut(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Ps=ut(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),gl=ut(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),uo=ut(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Bb=It(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ub=It(/<%[\w\W]*|[\w\W]*%>/gm),Hb=It(/\$\{[\w\W]*/gm),Wb=It(/^data-[\-\w.\u00B7-\uFFFF]+$/),Gb=It(/^aria-[\-\w]+$/),Tf=It(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Vb=It(/^(?:\w+script|data):/i),Yb=It(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Af=It(/^html$/i),Kb=It(/^[a-z][.\w]*(-[.\w]+)+$/i);var xl=Object.freeze({__proto__:null,ARIA_ATTR:Gb,ATTR_WHITESPACE:Yb,CUSTOM_ELEMENT:Kb,DATA_ATTR:Wb,DOCTYPE_NAME:Af,ERB_EXPR:Ub,IS_ALLOWED_URI:Tf,IS_SCRIPT_OR_DATA:Vb,MUSTACHE_EXPR:Bb,TMPLIT_EXPR:Hb});const kr={element:1,text:3,progressingInstruction:7,comment:8,document:9},qb=function(){return typeof window>"u"?null:window},Xb=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},vl=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Nf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qb();const t=Z=>Nf(Z);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==kr.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:d,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:g}=e,x=c.prototype,h=Nr(x,"cloneNode"),v=Nr(x,"remove"),b=Nr(x,"nextSibling"),w=Nr(x,"childNodes"),y=Nr(x,"parentNode");if(typeof i=="function"){const Z=n.createElement("template");Z.content&&Z.content.ownerDocument&&(n=Z.content.ownerDocument)}let E,A="";const{implementation:j,createNodeIterator:N,createDocumentFragment:T,getElementsByTagName:G}=n,{importNode:q}=r;let W=vl();t.isSupported=typeof Cf=="function"&&typeof y=="function"&&j&&j.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:X,ERB_EXPR:ee,TMPLIT_EXPR:O,DATA_ATTR:Y,ARIA_ATTR:k,IS_SCRIPT_OR_DATA:$,ATTR_WHITESPACE:C,CUSTOM_ELEMENT:_}=xl;let{IS_ALLOWED_URI:L}=xl,R=null;const J=Ae({},[...pl,...js,...Rs,...Ms,...ml]);let P=null;const B=Ae({},[...hl,...Ps,...gl,...uo]);let D=Object.seal(Ef(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),U=null,I=null,V=!0,Q=!0,te=!1,ae=!0,se=!1,pe=!0,ye=!1,_e=!1,Ie=!1,Pe=!1,Re=!1,Be=!1,yt=!0,We=!1;const St="user-content-";let nt=!0,rt=!1,ot={},le=null;const jt=Ae({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ct=null;const Rt=Ae({},["audio","video","img","source","image","track"]);let Mt=null;const Et=Ae({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Tt="http://www.w3.org/1998/Math/MathML",At="http://www.w3.org/2000/svg",Xe="http://www.w3.org/1999/xhtml";let pt=Xe,Pt=!1,Lt=null;const an=Ae({},[Tt,At,Xe],Is);let De=Ae({},["mi","mo","mn","ms","mtext"]),Ge=Ae({},["annotation-xml"]);const Dt=Ae({},["title","style","font","a","script"]);let gt=null;const Ot=["application/xhtml+xml","text/html"],Ft="text/html";let ze=null,mt=null;const ln=n.createElement("form"),Kt=function(S){return S instanceof RegExp||S instanceof Function},Nt=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(mt&&mt===S)){if((!S||typeof S!="object")&&(S={}),S=dn(S),gt=Ot.indexOf(S.PARSER_MEDIA_TYPE)===-1?Ft:S.PARSER_MEDIA_TYPE,ze=gt==="application/xhtml+xml"?Is:bo,R=Ut(S,"ALLOWED_TAGS")?Ae({},S.ALLOWED_TAGS,ze):J,P=Ut(S,"ALLOWED_ATTR")?Ae({},S.ALLOWED_ATTR,ze):B,Lt=Ut(S,"ALLOWED_NAMESPACES")?Ae({},S.ALLOWED_NAMESPACES,Is):an,Mt=Ut(S,"ADD_URI_SAFE_ATTR")?Ae(dn(Et),S.ADD_URI_SAFE_ATTR,ze):Et,Ct=Ut(S,"ADD_DATA_URI_TAGS")?Ae(dn(Rt),S.ADD_DATA_URI_TAGS,ze):Rt,le=Ut(S,"FORBID_CONTENTS")?Ae({},S.FORBID_CONTENTS,ze):jt,U=Ut(S,"FORBID_TAGS")?Ae({},S.FORBID_TAGS,ze):dn({}),I=Ut(S,"FORBID_ATTR")?Ae({},S.FORBID_ATTR,ze):dn({}),ot=Ut(S,"USE_PROFILES")?S.USE_PROFILES:!1,V=S.ALLOW_ARIA_ATTR!==!1,Q=S.ALLOW_DATA_ATTR!==!1,te=S.ALLOW_UNKNOWN_PROTOCOLS||!1,ae=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,se=S.SAFE_FOR_TEMPLATES||!1,pe=S.SAFE_FOR_XML!==!1,ye=S.WHOLE_DOCUMENT||!1,Pe=S.RETURN_DOM||!1,Re=S.RETURN_DOM_FRAGMENT||!1,Be=S.RETURN_TRUSTED_TYPE||!1,Ie=S.FORCE_BODY||!1,yt=S.SANITIZE_DOM!==!1,We=S.SANITIZE_NAMED_PROPS||!1,nt=S.KEEP_CONTENT!==!1,rt=S.IN_PLACE||!1,L=S.ALLOWED_URI_REGEXP||Tf,pt=S.NAMESPACE||Xe,De=S.MATHML_TEXT_INTEGRATION_POINTS||De,Ge=S.HTML_INTEGRATION_POINTS||Ge,D=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&Kt(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(D.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&Kt(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(D.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(D.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),se&&(Q=!1),Re&&(Pe=!0),ot&&(R=Ae({},ml),P=[],ot.html===!0&&(Ae(R,pl),Ae(P,hl)),ot.svg===!0&&(Ae(R,js),Ae(P,Ps),Ae(P,uo)),ot.svgFilters===!0&&(Ae(R,Rs),Ae(P,Ps),Ae(P,uo)),ot.mathMl===!0&&(Ae(R,Ms),Ae(P,gl),Ae(P,uo))),S.ADD_TAGS&&(R===J&&(R=dn(R)),Ae(R,S.ADD_TAGS,ze)),S.ADD_ATTR&&(P===B&&(P=dn(P)),Ae(P,S.ADD_ATTR,ze)),S.ADD_URI_SAFE_ATTR&&Ae(Mt,S.ADD_URI_SAFE_ATTR,ze),S.FORBID_CONTENTS&&(le===jt&&(le=dn(le)),Ae(le,S.FORBID_CONTENTS,ze)),nt&&(R["#text"]=!0),ye&&Ae(R,["html","head","body"]),R.table&&(Ae(R,["tbody"]),delete U.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ar('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ar('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=S.TRUSTED_TYPES_POLICY,A=E.createHTML("")}else E===void 0&&(E=Xb(g,o)),E!==null&&typeof A=="string"&&(A=E.createHTML(""));ut&&ut(S),mt=S}},zt=Ae({},[...js,...Rs,...zb]),qt=Ae({},[...Ms,...$b]),Se=function(S){let M=y(S);(!M||!M.tagName)&&(M={namespaceURI:pt,tagName:"template"});const K=bo(S.tagName),Ne=bo(M.tagName);return Lt[S.namespaceURI]?S.namespaceURI===At?M.namespaceURI===Xe?K==="svg":M.namespaceURI===Tt?K==="svg"&&(Ne==="annotation-xml"||De[Ne]):!!zt[K]:S.namespaceURI===Tt?M.namespaceURI===Xe?K==="math":M.namespaceURI===At?K==="math"&&Ge[Ne]:!!qt[K]:S.namespaceURI===Xe?M.namespaceURI===At&&!Ge[Ne]||M.namespaceURI===Tt&&!De[Ne]?!1:!qt[K]&&(Dt[K]||!zt[K]):!!(gt==="application/xhtml+xml"&&Lt[S.namespaceURI]):!1},z=function(S){Er(t.removed,{element:S});try{y(S).removeChild(S)}catch{v(S)}},H=function(S,M){try{Er(t.removed,{attribute:M.getAttributeNode(S),from:M})}catch{Er(t.removed,{attribute:null,from:M})}if(M.removeAttribute(S),S==="is")if(Pe||Re)try{z(M)}catch{}else try{M.setAttribute(S,"")}catch{}},F=function(S){let M=null,K=null;if(Ie)S="<remove></remove>"+S;else{const ue=fl(S,/^[\r\n\t ]+/);K=ue&&ue[0]}gt==="application/xhtml+xml"&&pt===Xe&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const Ne=E?E.createHTML(S):S;if(pt===Xe)try{M=new m().parseFromString(Ne,gt)}catch{}if(!M||!M.documentElement){M=j.createDocument(pt,"template",null);try{M.documentElement.innerHTML=Pt?A:Ne}catch{}}const Oe=M.body||M.documentElement;return S&&K&&Oe.insertBefore(n.createTextNode(K),Oe.childNodes[0]||null),pt===Xe?G.call(M,ye?"html":"body")[0]:ye?M.documentElement:Oe},ie=function(S){return N.call(S.ownerDocument||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},de=function(S){return S instanceof p&&(typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||!(S.attributes instanceof f)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function")},ce=function(S){return typeof l=="function"&&S instanceof l};function ve(Z,S,M){co(Z,K=>{K.call(t,S,M,mt)})}const he=function(S){let M=null;if(ve(W.beforeSanitizeElements,S,null),de(S))return z(S),!0;const K=ze(S.nodeName);if(ve(W.uponSanitizeElement,S,{tagName:K,allowedTags:R}),pe&&S.hasChildNodes()&&!ce(S.firstElementChild)&&at(/<[/\w!]/g,S.innerHTML)&&at(/<[/\w!]/g,S.textContent)||S.nodeType===kr.progressingInstruction||pe&&S.nodeType===kr.comment&&at(/<[/\w]/g,S.data))return z(S),!0;if(!R[K]||U[K]){if(!U[K]&&ne(K)&&(D.tagNameCheck instanceof RegExp&&at(D.tagNameCheck,K)||D.tagNameCheck instanceof Function&&D.tagNameCheck(K)))return!1;if(nt&&!le[K]){const Ne=y(S)||S.parentNode,Oe=w(S)||S.childNodes;if(Oe&&Ne){const ue=Oe.length;for(let we=ue-1;we>=0;--we){const Te=h(Oe[we],!0);Te.__removalCount=(S.__removalCount||0)+1,Ne.insertBefore(Te,b(S))}}}return z(S),!0}return S instanceof c&&!Se(S)||(K==="noscript"||K==="noembed"||K==="noframes")&&at(/<\/no(script|embed|frames)/i,S.innerHTML)?(z(S),!0):(se&&S.nodeType===kr.text&&(M=S.textContent,co([X,ee,O],Ne=>{M=Tr(M,Ne," ")}),S.textContent!==M&&(Er(t.removed,{element:S.cloneNode()}),S.textContent=M)),ve(W.afterSanitizeElements,S,null),!1)},je=function(S,M,K){if(yt&&(M==="id"||M==="name")&&(K in n||K in ln))return!1;if(!(Q&&!I[M]&&at(Y,M))){if(!(V&&at(k,M))){if(!P[M]||I[M]){if(!(ne(S)&&(D.tagNameCheck instanceof RegExp&&at(D.tagNameCheck,S)||D.tagNameCheck instanceof Function&&D.tagNameCheck(S))&&(D.attributeNameCheck instanceof RegExp&&at(D.attributeNameCheck,M)||D.attributeNameCheck instanceof Function&&D.attributeNameCheck(M))||M==="is"&&D.allowCustomizedBuiltInElements&&(D.tagNameCheck instanceof RegExp&&at(D.tagNameCheck,K)||D.tagNameCheck instanceof Function&&D.tagNameCheck(K))))return!1}else if(!Mt[M]){if(!at(L,Tr(K,C,""))){if(!((M==="src"||M==="xlink:href"||M==="href")&&S!=="script"&&Lb(K,"data:")===0&&Ct[S])){if(!(te&&!at($,Tr(K,C,"")))){if(K)return!1}}}}}}return!0},ne=function(S){return S!=="annotation-xml"&&fl(S,_)},me=function(S){ve(W.beforeSanitizeAttributes,S,null);const{attributes:M}=S;if(!M||de(S))return;const K={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P,forceKeepAttr:void 0};let Ne=M.length;for(;Ne--;){const Oe=M[Ne],{name:ue,namespaceURI:we,value:Te}=Oe,Ze=ze(ue),$t=Te;let Me=ue==="value"?$t:Db($t);if(K.attrName=Ze,K.attrValue=Me,K.keepAttr=!0,K.forceKeepAttr=void 0,ve(W.uponSanitizeAttribute,S,K),Me=K.attrValue,We&&(Ze==="id"||Ze==="name")&&(H(ue,S),Me=St+Me),pe&&at(/((--!?|])>)|<\/(style|title)/i,Me)){H(ue,S);continue}if(K.forceKeepAttr)continue;if(!K.keepAttr){H(ue,S);continue}if(!ae&&at(/\/>/i,Me)){H(ue,S);continue}se&&co([X,ee,O],yr=>{Me=Tr(Me,yr," ")});const us=ze(S.nodeName);if(!je(us,Ze,Me)){H(ue,S);continue}if(E&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!we)switch(g.getAttributeType(us,Ze)){case"TrustedHTML":{Me=E.createHTML(Me);break}case"TrustedScriptURL":{Me=E.createScriptURL(Me);break}}if(Me!==$t)try{we?S.setAttributeNS(we,ue,Me):S.setAttribute(ue,Me),de(S)?z(S):dl(t.removed)}catch{H(ue,S)}}ve(W.afterSanitizeAttributes,S,null)},Le=function Z(S){let M=null;const K=ie(S);for(ve(W.beforeSanitizeShadowDOM,S,null);M=K.nextNode();)ve(W.uponSanitizeShadowNode,M,null),he(M),me(M),M.content instanceof s&&Z(M.content);ve(W.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(Z){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=null,K=null,Ne=null,Oe=null;if(Pt=!Z,Pt&&(Z="<!-->"),typeof Z!="string"&&!ce(Z))if(typeof Z.toString=="function"){if(Z=Z.toString(),typeof Z!="string")throw Ar("dirty is not a string, aborting")}else throw Ar("toString is not a function");if(!t.isSupported)return Z;if(_e||Nt(S),t.removed=[],typeof Z=="string"&&(rt=!1),rt){if(Z.nodeName){const Te=ze(Z.nodeName);if(!R[Te]||U[Te])throw Ar("root node is forbidden and cannot be sanitized in-place")}}else if(Z instanceof l)M=F("<!---->"),K=M.ownerDocument.importNode(Z,!0),K.nodeType===kr.element&&K.nodeName==="BODY"||K.nodeName==="HTML"?M=K:M.appendChild(K);else{if(!Pe&&!se&&!ye&&Z.indexOf("<")===-1)return E&&Be?E.createHTML(Z):Z;if(M=F(Z),!M)return Pe?null:Be?A:""}M&&Ie&&z(M.firstChild);const ue=ie(rt?Z:M);for(;Ne=ue.nextNode();)he(Ne),me(Ne),Ne.content instanceof s&&Le(Ne.content);if(rt)return Z;if(Pe){if(Re)for(Oe=T.call(M.ownerDocument);M.firstChild;)Oe.appendChild(M.firstChild);else Oe=M;return(P.shadowroot||P.shadowrootmode)&&(Oe=q.call(r,Oe,!0)),Oe}let we=ye?M.outerHTML:M.innerHTML;return ye&&R["!doctype"]&&M.ownerDocument&&M.ownerDocument.doctype&&M.ownerDocument.doctype.name&&at(Af,M.ownerDocument.doctype.name)&&(we="<!DOCTYPE "+M.ownerDocument.doctype.name+`>
124
+ `+we),se&&co([X,ee,O],Te=>{we=Tr(we,Te," ")}),E&&Be?E.createHTML(we):we},t.setConfig=function(){let Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Nt(Z),_e=!0},t.clearConfig=function(){mt=null,_e=!1},t.isValidAttribute=function(Z,S,M){mt||Nt({});const K=ze(Z),Ne=ze(S);return je(K,Ne,M)},t.addHook=function(Z,S){typeof S=="function"&&Er(W[Z],S)},t.removeHook=function(Z,S){if(S!==void 0){const M=Mb(W[Z],S);return M===-1?void 0:Pb(W[Z],M,1)[0]}return dl(W[Z])},t.removeHooks=function(Z){W[Z]=[]},t.removeAllHooks=function(){W=vl()},t}var kf=Nf();const Zb=({content:e,setRenderError:t})=>{const[n,r]=u.useState(""),o=u.useMemo(()=>kf.sanitize(e,{USE_PROFILES:{html:!1},ALLOWED_TAGS:["br","em","strong","b","i"],ALLOWED_ATTR:[]}),[e]);return u.useEffect(()=>{r(`<!DOCTYPE html>
125
+ <html>
126
+ <head>
127
+ <meta charset="utf-8">
128
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
129
+ <title>Mermaid Preview</title>
130
+ <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"><\/script>
131
+ <script src="https://cdn.jsdelivr.net/npm/panzoom@9.4.0/dist/panzoom.min.js"><\/script>
132
+ <script>
133
+ document.addEventListener('DOMContentLoaded', function() {
134
+ try {
135
+ mermaid.initialize({
136
+ startOnLoad: true,
137
+ theme: 'default',
138
+ fontFamily: 'arial, sans-serif',
139
+ logLevel: 'error',
140
+ securityLevel: 'strict'
141
+ });
142
+
143
+ // Initialize panzoom after Mermaid rendering
144
+ mermaid.run().then(() => {
145
+ const diagramContainer = document.getElementById('diagram-container');
146
+ if (diagramContainer) {
147
+ const pz = panzoom(diagramContainer, {
148
+ maxZoom: 10,
149
+ minZoom: 0.1,
150
+ smoothScroll: true,
151
+ bounds: true,
152
+ boundsPadding: 0.1
153
+ });
154
+ // Add zoom controls (old version had only reset)
155
+ const resetButton = document.getElementById('reset');
156
+ if (resetButton) {
157
+ resetButton.addEventListener('click', () => {
158
+ pz.moveTo(0, 0);
159
+ pz.zoomAbs(0, 0, 1);
160
+ });
161
+ }
162
+ }
163
+ }).catch(err => {
164
+ console.error("Mermaid rendering failed inside iframe:", err);
165
+ const mermaidDiv = document.querySelector('.mermaid');
166
+ if (mermaidDiv) mermaidDiv.innerText = "Error rendering diagram: " + err.message;
167
+ });
168
+
169
+ window.addEventListener('message', function(event) {
170
+ if (event.data && event.data.action === 'getMermaidSvg') {
171
+ const svgElement = document.querySelector('.mermaid svg');
172
+ if (svgElement) {
173
+ if (!svgElement.getAttribute('xmlns')) { // Ensure xmlns for standalone SVG
174
+ svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
175
+ }
176
+ const svgData = new XMLSerializer().serializeToString(svgElement);
177
+ window.parent.postMessage({
178
+ action: 'downloadSvg',
179
+ svgData: svgData,
180
+ filename: event.data.filename || 'mermaid-diagram.svg'
181
+ }, '*');
182
+ } else {
183
+ console.error('SVG element not found for download inside iframe.');
184
+ }
185
+ }
186
+ });
187
+ } catch (e) {
188
+ console.error("Error initializing Mermaid or Panzoom inside iframe:", e);
189
+ const mermaidDiv = document.querySelector('.mermaid');
190
+ if (mermaidDiv) mermaidDiv.innerText = "Failed to initialize diagram viewer: " + e.message;
191
+ }
192
+ });
193
+ <\/script>
194
+ <style>
195
+ /* Styles from old code */
196
+ html, body {
197
+ height: 100%;
198
+ margin: 0;
199
+ padding: 0;
200
+ overflow: hidden;
201
+ font-family: Arial, sans-serif; /* Old font */
202
+ }
203
+ .container {
204
+ display: flex;
205
+ flex-direction: column;
206
+ height: 100vh;
207
+ overflow: hidden;
208
+ }
209
+ .diagram-wrapper {
210
+ flex: 1;
211
+ overflow: hidden;
212
+ position: relative;
213
+ display: flex;
214
+ justify-content: center;
215
+ align-items: center;
216
+ background-color: #f9f9f9;
217
+ }
218
+ #diagram-container {
219
+ transform-origin: 0 0;
220
+ cursor: grab;
221
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
222
+ background-color: white;
223
+ padding: 20px;
224
+ border-radius: 5px;
225
+ /* Ensure diagram container can hold the content */
226
+ width: auto; /* Adjust as needed, or let content define it */
227
+ height: auto;
228
+ max-width: 100%;
229
+ max-height: 100%;
230
+ }
231
+ #diagram-container:active {
232
+ cursor: grabbing;
233
+ }
234
+ .mermaid {
235
+ display: flex; /* Helps in centering if SVG is smaller */
236
+ justify-content: center;
237
+ align-items: center;
238
+ /* width: 100%; Ensures mermaid div takes space, SVG might scale within it */
239
+ /* height: 100%; */
240
+ }
241
+ .mermaid svg {
242
+ max-width: 100%; /* Ensure SVG scales down if too large */
243
+ max-height: 100%;
244
+ }
245
+ .controls{
246
+ position: fixed;
247
+ bottom: 20px;
248
+ right: 20px;
249
+ z-index: 1000;
250
+ display: flex;
251
+ gap: 5px;
252
+ }
253
+ .control-btn {
254
+ width: 40px;
255
+ height: 40px;
256
+ border-radius: 50%;
257
+ border: none;
258
+ background-color: white;
259
+ box-shadow: 0 2px 5px rgba(0,0,0,0.2);
260
+ cursor: pointer;
261
+ font-size: 18px;
262
+ display: flex;
263
+ align-items: center;
264
+ justify-content: center;
265
+ }
266
+ .control-btn:hover {
267
+ background-color: #f0f0f0;
268
+ }
269
+ .instructions {
270
+ position: fixed;
271
+ top: 10px;
272
+ left: 10px;
273
+ background-color: rgba(255,255,255,0.8);
274
+ padding: 5px 10px;
275
+ border-radius: 4px;
276
+ font-size: 12px;
277
+ color: #666;
278
+ }
279
+ </style>
280
+ </head>
281
+ <body>
282
+ <div class="container">
283
+ <div class="diagram-wrapper">
284
+ <div id="diagram-container">
285
+ <div class="mermaid">
286
+ ${o}
287
+ </div>
288
+ </div>
289
+ </div>
290
+ <div class="instructions">
291
+ Drag to pan and scroll to zoom
292
+ </div>
293
+ <div class="controls">
294
+ <button id="reset" class="control-btn" title="Reset View">↺</button>
295
+ </div>
296
+ </div>
297
+ </body>
298
+ </html>`)},[o]),a.jsx("div",{className:"bg-background h-full p-4",children:a.jsx("iframe",{srcDoc:n,title:"Mermaid Diagram Preview",sandbox:"allow-scripts allow-same-origin allow-downloads",className:"h-96 w-full resize border-none",onError:()=>t("Failed to load Mermaid content."),onLoad:()=>t(null)})})};/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function _f(e){return typeof e>"u"||e===null}function Jb(e){return typeof e=="object"&&e!==null}function Qb(e){return Array.isArray(e)?e:_f(e)?[]:[e]}function ey(e,t){var n,r,o,s;if(t)for(s=Object.keys(t),n=0,r=s.length;n<r;n+=1)o=s[n],e[o]=t[o];return e}function ty(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function ny(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var ry=_f,oy=Jb,sy=Qb,iy=ty,ay=ny,ly=ey,Ke={isNothing:ry,isObject:oy,toArray:sy,repeat:iy,isNegativeZero:ay,extend:ly};function If(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
299
+
300
+ `+e.mark.snippet),r+" "+n):r}function $r(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=If(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}$r.prototype=Object.create(Error.prototype);$r.prototype.constructor=$r;$r.prototype.toString=function(t){return this.name+": "+If(this,t)};var ct=$r;function Ls(e,t,n,r,o){var s="",i="",l=Math.floor(o/2)-1;return r-t>l&&(s=" ... ",t=r-l+s.length),n-r>l&&(i=" ...",n=r+l-i.length),{str:s+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+s.length}}function Ds(e,t){return Ke.repeat(" ",t-e.length)+e}function cy(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],s,i=-1;s=n.exec(e.buffer);)o.push(s.index),r.push(s.index+s[0].length),e.position<=s.index&&i<0&&(i=r.length-2);i<0&&(i=r.length-1);var l="",c,d,f=Math.min(e.line+t.linesAfter,o.length).toString().length,p=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)d=Ls(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),p),l=Ke.repeat(" ",t.indent)+Ds((e.line-c+1).toString(),f)+" | "+d.str+`
301
+ `+l;for(d=Ls(e.buffer,r[i],o[i],e.position,p),l+=Ke.repeat(" ",t.indent)+Ds((e.line+1).toString(),f)+" | "+d.str+`
302
+ `,l+=Ke.repeat("-",t.indent+f+3+d.pos)+`^
303
+ `,c=1;c<=t.linesAfter&&!(i+c>=o.length);c++)d=Ls(e.buffer,r[i+c],o[i+c],e.position-(r[i]-r[i+c]),p),l+=Ke.repeat(" ",t.indent)+Ds((e.line+c+1).toString(),f)+" | "+d.str+`
304
+ `;return l.replace(/\n$/,"")}var uy=cy,dy=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],fy=["scalar","sequence","mapping"];function py(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function my(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(dy.indexOf(n)===-1)throw new ct('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=py(t.styleAliases||null),fy.indexOf(this.kind)===-1)throw new ct('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var tt=my;function wl(e,t){var n=[];return e[t].forEach(function(r){var o=n.length;n.forEach(function(s,i){s.tag===r.tag&&s.kind===r.kind&&s.multi===r.multi&&(o=i)}),n[o]=r}),n}function hy(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function si(e){return this.extend(e)}si.prototype.extend=function(t){var n=[],r=[];if(t instanceof tt)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new ct("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(s){if(!(s instanceof tt))throw new ct("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(s.loadKind&&s.loadKind!=="scalar")throw new ct("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(s.multi)throw new ct("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(s){if(!(s instanceof tt))throw new ct("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(si.prototype);return o.implicit=(this.implicit||[]).concat(n),o.explicit=(this.explicit||[]).concat(r),o.compiledImplicit=wl(o,"implicit"),o.compiledExplicit=wl(o,"explicit"),o.compiledTypeMap=hy(o.compiledImplicit,o.compiledExplicit),o};var jf=si,Rf=new tt("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Mf=new tt("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Pf=new tt("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Lf=new jf({explicit:[Rf,Mf,Pf]});function gy(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function xy(){return null}function vy(e){return e===null}var Df=new tt("tag:yaml.org,2002:null",{kind:"scalar",resolve:gy,construct:xy,predicate:vy,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function wy(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function by(e){return e==="true"||e==="True"||e==="TRUE"}function yy(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Of=new tt("tag:yaml.org,2002:bool",{kind:"scalar",resolve:wy,construct:by,predicate:yy,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function Sy(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Cy(e){return 48<=e&&e<=55}function Ey(e){return 48<=e&&e<=57}function Ty(e){if(e===null)return!1;var t=e.length,n=0,r=!1,o;if(!t)return!1;if(o=e[n],(o==="-"||o==="+")&&(o=e[++n]),o==="0"){if(n+1===t)return!0;if(o=e[++n],o==="b"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(o!=="0"&&o!=="1")return!1;r=!0}return r&&o!=="_"}if(o==="x"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!Sy(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}if(o==="o"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!Cy(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}}if(o==="_")return!1;for(;n<t;n++)if(o=e[n],o!=="_"){if(!Ey(e.charCodeAt(n)))return!1;r=!0}return!(!r||o==="_")}function Ay(e){var t=e,n=1,r;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),r=t[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),t=t.slice(1),r=t[0]),t==="0")return 0;if(r==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function Ny(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Ke.isNegativeZero(e)}var Ff=new tt("tag:yaml.org,2002:int",{kind:"scalar",resolve:Ty,construct:Ay,predicate:Ny,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),ky=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function _y(e){return!(e===null||!ky.test(e)||e[e.length-1]==="_")}function Iy(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var jy=/^[-+]?[0-9]+e/;function Ry(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Ke.isNegativeZero(e))return"-0.0";return n=e.toString(10),jy.test(n)?n.replace("e",".e"):n}function My(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Ke.isNegativeZero(e))}var zf=new tt("tag:yaml.org,2002:float",{kind:"scalar",resolve:_y,construct:Iy,predicate:My,represent:Ry,defaultStyle:"lowercase"}),$f=Lf.extend({implicit:[Df,Of,Ff,zf]}),Bf=$f,Uf=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Hf=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Py(e){return e===null?!1:Uf.exec(e)!==null||Hf.exec(e)!==null}function Ly(e){var t,n,r,o,s,i,l,c=0,d=null,f,p,m;if(t=Uf.exec(e),t===null&&(t=Hf.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,o=+t[3],!t[4])return new Date(Date.UTC(n,r,o));if(s=+t[4],i=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(f=+t[10],p=+(t[11]||0),d=(f*60+p)*6e4,t[9]==="-"&&(d=-d)),m=new Date(Date.UTC(n,r,o,s,i,l,c)),d&&m.setTime(m.getTime()-d),m}function Dy(e){return e.toISOString()}var Wf=new tt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Py,construct:Ly,instanceOf:Date,represent:Dy});function Oy(e){return e==="<<"||e===null}var Gf=new tt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Oy}),ea=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
305
+ \r`;function Fy(e){if(e===null)return!1;var t,n,r=0,o=e.length,s=ea;for(n=0;n<o;n++)if(t=s.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function zy(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,s=ea,i=0,l=[];for(t=0;t<o;t++)t%4===0&&t&&(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)),i=i<<6|s.indexOf(r.charAt(t));return n=o%4*6,n===0?(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)):n===18?(l.push(i>>10&255),l.push(i>>2&255)):n===12&&l.push(i>>4&255),new Uint8Array(l)}function $y(e){var t="",n=0,r,o,s=e.length,i=ea;for(r=0;r<s;r++)r%3===0&&r&&(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]),n=(n<<8)+e[r];return o=s%3,o===0?(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]):o===2?(t+=i[n>>10&63],t+=i[n>>4&63],t+=i[n<<2&63],t+=i[64]):o===1&&(t+=i[n>>2&63],t+=i[n<<4&63],t+=i[64],t+=i[64]),t}function By(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Vf=new tt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Fy,construct:zy,predicate:By,represent:$y}),Uy=Object.prototype.hasOwnProperty,Hy=Object.prototype.toString;function Wy(e){if(e===null)return!0;var t=[],n,r,o,s,i,l=e;for(n=0,r=l.length;n<r;n+=1){if(o=l[n],i=!1,Hy.call(o)!=="[object Object]")return!1;for(s in o)if(Uy.call(o,s))if(!i)i=!0;else return!1;if(!i)return!1;if(t.indexOf(s)===-1)t.push(s);else return!1}return!0}function Gy(e){return e!==null?e:[]}var Yf=new tt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Wy,construct:Gy}),Vy=Object.prototype.toString;function Yy(e){if(e===null)return!0;var t,n,r,o,s,i=e;for(s=new Array(i.length),t=0,n=i.length;t<n;t+=1){if(r=i[t],Vy.call(r)!=="[object Object]"||(o=Object.keys(r),o.length!==1))return!1;s[t]=[o[0],r[o[0]]]}return!0}function Ky(e){if(e===null)return[];var t,n,r,o,s,i=e;for(s=new Array(i.length),t=0,n=i.length;t<n;t+=1)r=i[t],o=Object.keys(r),s[t]=[o[0],r[o[0]]];return s}var Kf=new tt("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Yy,construct:Ky}),qy=Object.prototype.hasOwnProperty;function Xy(e){if(e===null)return!0;var t,n=e;for(t in n)if(qy.call(n,t)&&n[t]!==null)return!1;return!0}function Zy(e){return e!==null?e:{}}var qf=new tt("tag:yaml.org,2002:set",{kind:"mapping",resolve:Xy,construct:Zy}),ta=Bf.extend({implicit:[Wf,Gf],explicit:[Vf,Yf,Kf,qf]}),An=Object.prototype.hasOwnProperty,_o=1,Xf=2,Zf=3,Io=4,Os=1,Jy=2,bl=3,Qy=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,eS=/[\x85\u2028\u2029]/,tS=/[,\[\]\{\}]/,Jf=/^(?:!|!!|![a-z\-]+!)$/i,Qf=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function yl(e){return Object.prototype.toString.call(e)}function nn(e){return e===10||e===13}function Ln(e){return e===9||e===32}function ht(e){return e===9||e===32||e===10||e===13}function tr(e){return e===44||e===91||e===93||e===123||e===125}function nS(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function rS(e){return e===120?2:e===117?4:e===85?8:0}function oS(e){return 48<=e&&e<=57?e-48:-1}function Sl(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
306
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function sS(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var ep=new Array(256),tp=new Array(256);for(var Zn=0;Zn<256;Zn++)ep[Zn]=Sl(Zn)?1:0,tp[Zn]=Sl(Zn);function iS(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||ta,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function np(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=uy(n),new ct(t,n)}function fe(e,t){throw np(e,t)}function jo(e,t){e.onWarning&&e.onWarning.call(null,np(e,t))}var Cl={YAML:function(t,n,r){var o,s,i;t.version!==null&&fe(t,"duplication of %YAML directive"),r.length!==1&&fe(t,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),o===null&&fe(t,"ill-formed argument of the YAML directive"),s=parseInt(o[1],10),i=parseInt(o[2],10),s!==1&&fe(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&jo(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var o,s;r.length!==2&&fe(t,"TAG directive accepts exactly two arguments"),o=r[0],s=r[1],Jf.test(o)||fe(t,"ill-formed tag handle (first argument) of the TAG directive"),An.call(t.tagMap,o)&&fe(t,'there is a previously declared suffix for "'+o+'" tag handle'),Qf.test(s)||fe(t,"ill-formed tag prefix (second argument) of the TAG directive");try{s=decodeURIComponent(s)}catch{fe(t,"tag prefix is malformed: "+s)}t.tagMap[o]=s}};function Sn(e,t,n,r){var o,s,i,l;if(t<n){if(l=e.input.slice(t,n),r)for(o=0,s=l.length;o<s;o+=1)i=l.charCodeAt(o),i===9||32<=i&&i<=1114111||fe(e,"expected valid JSON character");else Qy.test(l)&&fe(e,"the stream contains non-printable characters");e.result+=l}}function El(e,t,n,r){var o,s,i,l;for(Ke.isObject(n)||fe(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(n),i=0,l=o.length;i<l;i+=1)s=o[i],An.call(t,s)||(t[s]=n[s],r[s]=!0)}function nr(e,t,n,r,o,s,i,l,c){var d,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),d=0,f=o.length;d<f;d+=1)Array.isArray(o[d])&&fe(e,"nested arrays are not supported inside keys"),typeof o=="object"&&yl(o[d])==="[object Object]"&&(o[d]="[object Object]");if(typeof o=="object"&&yl(o)==="[object Object]"&&(o="[object Object]"),o=String(o),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(s))for(d=0,f=s.length;d<f;d+=1)El(e,t,s[d],n);else El(e,t,s,n);else!e.json&&!An.call(n,o)&&An.call(t,o)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,fe(e,"duplicated mapping key")),o==="__proto__"?Object.defineProperty(t,o,{configurable:!0,enumerable:!0,writable:!0,value:s}):t[o]=s,delete n[o];return t}function na(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):fe(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Ve(e,t,n){for(var r=0,o=e.input.charCodeAt(e.position);o!==0;){for(;Ln(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(t&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(nn(o))for(na(e),o=e.input.charCodeAt(e.position),r++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&jo(e,"deficient indentation"),r}function ls(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||ht(n)))}function ra(e,t){t===1?e.result+=" ":t>1&&(e.result+=Ke.repeat(`
307
+ `,t-1))}function aS(e,t,n){var r,o,s,i,l,c,d,f,p=e.kind,m=e.result,g;if(g=e.input.charCodeAt(e.position),ht(g)||tr(g)||g===35||g===38||g===42||g===33||g===124||g===62||g===39||g===34||g===37||g===64||g===96||(g===63||g===45)&&(o=e.input.charCodeAt(e.position+1),ht(o)||n&&tr(o)))return!1;for(e.kind="scalar",e.result="",s=i=e.position,l=!1;g!==0;){if(g===58){if(o=e.input.charCodeAt(e.position+1),ht(o)||n&&tr(o))break}else if(g===35){if(r=e.input.charCodeAt(e.position-1),ht(r))break}else{if(e.position===e.lineStart&&ls(e)||n&&tr(g))break;if(nn(g))if(c=e.line,d=e.lineStart,f=e.lineIndent,Ve(e,!1,-1),e.lineIndent>=t){l=!0,g=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=d,e.lineIndent=f;break}}l&&(Sn(e,s,i,!1),ra(e,e.line-c),s=i=e.position,l=!1),Ln(g)||(i=e.position+1),g=e.input.charCodeAt(++e.position)}return Sn(e,s,i,!1),e.result?!0:(e.kind=p,e.result=m,!1)}function lS(e,t){var n,r,o;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=o=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(Sn(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,o=e.position;else return!0;else nn(n)?(Sn(e,r,o,!0),ra(e,Ve(e,!1,t)),r=o=e.position):e.position===e.lineStart&&ls(e)?fe(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);fe(e,"unexpected end of the stream within a single quoted scalar")}function cS(e,t){var n,r,o,s,i,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return Sn(e,n,e.position,!0),e.position++,!0;if(l===92){if(Sn(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),nn(l))Ve(e,!1,t);else if(l<256&&ep[l])e.result+=tp[l],e.position++;else if((i=rS(l))>0){for(o=i,s=0;o>0;o--)l=e.input.charCodeAt(++e.position),(i=nS(l))>=0?s=(s<<4)+i:fe(e,"expected hexadecimal character");e.result+=sS(s),e.position++}else fe(e,"unknown escape sequence");n=r=e.position}else nn(l)?(Sn(e,n,r,!0),ra(e,Ve(e,!1,t)),n=r=e.position):e.position===e.lineStart&&ls(e)?fe(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}fe(e,"unexpected end of the stream within a double quoted scalar")}function uS(e,t){var n=!0,r,o,s,i=e.tag,l,c=e.anchor,d,f,p,m,g,x=Object.create(null),h,v,b,w;if(w=e.input.charCodeAt(e.position),w===91)f=93,g=!1,l=[];else if(w===123)f=125,g=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),w=e.input.charCodeAt(++e.position);w!==0;){if(Ve(e,!0,t),w=e.input.charCodeAt(e.position),w===f)return e.position++,e.tag=i,e.anchor=c,e.kind=g?"mapping":"sequence",e.result=l,!0;n?w===44&&fe(e,"expected the node content, but found ','"):fe(e,"missed comma between flow collection entries"),v=h=b=null,p=m=!1,w===63&&(d=e.input.charCodeAt(e.position+1),ht(d)&&(p=m=!0,e.position++,Ve(e,!0,t))),r=e.line,o=e.lineStart,s=e.position,dr(e,t,_o,!1,!0),v=e.tag,h=e.result,Ve(e,!0,t),w=e.input.charCodeAt(e.position),(m||e.line===r)&&w===58&&(p=!0,w=e.input.charCodeAt(++e.position),Ve(e,!0,t),dr(e,t,_o,!1,!0),b=e.result),g?nr(e,l,x,v,h,b,r,o,s):p?l.push(nr(e,null,x,v,h,b,r,o,s)):l.push(h),Ve(e,!0,t),w=e.input.charCodeAt(e.position),w===44?(n=!0,w=e.input.charCodeAt(++e.position)):n=!1}fe(e,"unexpected end of the stream within a flow collection")}function dS(e,t){var n,r,o=Os,s=!1,i=!1,l=t,c=0,d=!1,f,p;if(p=e.input.charCodeAt(e.position),p===124)r=!1;else if(p===62)r=!0;else return!1;for(e.kind="scalar",e.result="";p!==0;)if(p=e.input.charCodeAt(++e.position),p===43||p===45)Os===o?o=p===43?bl:Jy:fe(e,"repeat of a chomping mode identifier");else if((f=oS(p))>=0)f===0?fe(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?fe(e,"repeat of an indentation width identifier"):(l=t+f-1,i=!0);else break;if(Ln(p)){do p=e.input.charCodeAt(++e.position);while(Ln(p));if(p===35)do p=e.input.charCodeAt(++e.position);while(!nn(p)&&p!==0)}for(;p!==0;){for(na(e),e.lineIndent=0,p=e.input.charCodeAt(e.position);(!i||e.lineIndent<l)&&p===32;)e.lineIndent++,p=e.input.charCodeAt(++e.position);if(!i&&e.lineIndent>l&&(l=e.lineIndent),nn(p)){c++;continue}if(e.lineIndent<l){o===bl?e.result+=Ke.repeat(`
308
+ `,s?1+c:c):o===Os&&s&&(e.result+=`
309
+ `);break}for(r?Ln(p)?(d=!0,e.result+=Ke.repeat(`
310
+ `,s?1+c:c)):d?(d=!1,e.result+=Ke.repeat(`
311
+ `,c+1)):c===0?s&&(e.result+=" "):e.result+=Ke.repeat(`
312
+ `,c):e.result+=Ke.repeat(`
313
+ `,s?1+c:c),s=!0,i=!0,c=0,n=e.position;!nn(p)&&p!==0;)p=e.input.charCodeAt(++e.position);Sn(e,n,e.position,!1)}return!0}function Tl(e,t){var n,r=e.tag,o=e.anchor,s=[],i,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,fe(e,"tab characters must not be used in indentation")),!(c!==45||(i=e.input.charCodeAt(e.position+1),!ht(i))));){if(l=!0,e.position++,Ve(e,!0,-1)&&e.lineIndent<=t){s.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,dr(e,t,Zf,!1,!0),s.push(e.result),Ve(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)fe(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=o,e.kind="sequence",e.result=s,!0):!1}function fS(e,t,n){var r,o,s,i,l,c,d=e.tag,f=e.anchor,p={},m=Object.create(null),g=null,x=null,h=null,v=!1,b=!1,w;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=p),w=e.input.charCodeAt(e.position);w!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,fe(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),s=e.line,(w===63||w===58)&&ht(r))w===63?(v&&(nr(e,p,m,g,x,null,i,l,c),g=x=h=null),b=!0,v=!0,o=!0):v?(v=!1,o=!0):fe(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,w=r;else{if(i=e.line,l=e.lineStart,c=e.position,!dr(e,n,Xf,!1,!0))break;if(e.line===s){for(w=e.input.charCodeAt(e.position);Ln(w);)w=e.input.charCodeAt(++e.position);if(w===58)w=e.input.charCodeAt(++e.position),ht(w)||fe(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(nr(e,p,m,g,x,null,i,l,c),g=x=h=null),b=!0,v=!1,o=!1,g=e.tag,x=e.result;else if(b)fe(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(b)fe(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=f,!0}if((e.line===s||e.lineIndent>t)&&(v&&(i=e.line,l=e.lineStart,c=e.position),dr(e,t,Io,!0,o)&&(v?x=e.result:h=e.result),v||(nr(e,p,m,g,x,h,i,l,c),g=x=h=null),Ve(e,!0,-1),w=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&w!==0)fe(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&nr(e,p,m,g,x,null,i,l,c),b&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=p),b}function pS(e){var t,n=!1,r=!1,o,s,i;if(i=e.input.charCodeAt(e.position),i!==33)return!1;if(e.tag!==null&&fe(e,"duplication of a tag property"),i=e.input.charCodeAt(++e.position),i===60?(n=!0,i=e.input.charCodeAt(++e.position)):i===33?(r=!0,o="!!",i=e.input.charCodeAt(++e.position)):o="!",t=e.position,n){do i=e.input.charCodeAt(++e.position);while(i!==0&&i!==62);e.position<e.length?(s=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):fe(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!ht(i);)i===33&&(r?fe(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(t-1,e.position+1),Jf.test(o)||fe(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);s=e.input.slice(t,e.position),tS.test(s)&&fe(e,"tag suffix cannot contain flow indicator characters")}s&&!Qf.test(s)&&fe(e,"tag name cannot contain such characters: "+s);try{s=decodeURIComponent(s)}catch{fe(e,"tag name is malformed: "+s)}return n?e.tag=s:An.call(e.tagMap,o)?e.tag=e.tagMap[o]+s:o==="!"?e.tag="!"+s:o==="!!"?e.tag="tag:yaml.org,2002:"+s:fe(e,'undeclared tag handle "'+o+'"'),!0}function mS(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&fe(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!ht(n)&&!tr(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&fe(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function hS(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!ht(r)&&!tr(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&fe(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),An.call(e.anchorMap,n)||fe(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Ve(e,!0,-1),!0}function dr(e,t,n,r,o){var s,i,l,c=1,d=!1,f=!1,p,m,g,x,h,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,s=i=l=Io===n||Zf===n,r&&Ve(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;pS(e)||mS(e);)Ve(e,!0,-1)?(d=!0,l=s,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||o),(c===1||Io===n)&&(_o===n||Xf===n?h=t:h=t+1,v=e.position-e.lineStart,c===1?l&&(Tl(e,v)||fS(e,v,h))||uS(e,h)?f=!0:(i&&dS(e,h)||lS(e,h)||cS(e,h)?f=!0:hS(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&fe(e,"alias node should not have any properties")):aS(e,h,_o===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&Tl(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&fe(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),p=0,m=e.implicitTypes.length;p<m;p+=1)if(x=e.implicitTypes[p],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(An.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,g=e.typeMap.multi[e.kind||"fallback"],p=0,m=g.length;p<m;p+=1)if(e.tag.slice(0,g[p].tag.length)===g[p].tag){x=g[p];break}x||fe(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&fe(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):fe(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function gS(e){var t=e.position,n,r,o,s=!1,i;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(i=e.input.charCodeAt(e.position))!==0&&(Ve(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(s=!0,i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!ht(i);)i=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),o=[],r.length<1&&fe(e,"directive name must not be less than one character in length");i!==0;){for(;Ln(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!nn(i));break}if(nn(i))break;for(n=e.position;i!==0&&!ht(i);)i=e.input.charCodeAt(++e.position);o.push(e.input.slice(n,e.position))}i!==0&&na(e),An.call(Cl,r)?Cl[r](e,r,o):jo(e,'unknown document directive "'+r+'"')}if(Ve(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,Ve(e,!0,-1)):s&&fe(e,"directives end mark is expected"),dr(e,e.lineIndent-1,Io,!1,!0),Ve(e,!0,-1),e.checkLineBreaks&&eS.test(e.input.slice(t,e.position))&&jo(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ls(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Ve(e,!0,-1));return}if(e.position<e.length-1)fe(e,"end of the stream or a document separator is expected");else return}function rp(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
314
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new iS(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,fe(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)gS(n);return n.documents}function xS(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=rp(e,n);if(typeof t!="function")return r;for(var o=0,s=r.length;o<s;o+=1)t(r[o])}function vS(e,t){var n=rp(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new ct("expected a single document in the stream, but found more")}}var wS=xS,bS=vS,op={loadAll:wS,load:bS},sp=Object.prototype.toString,ip=Object.prototype.hasOwnProperty,oa=65279,yS=9,Br=10,SS=13,CS=32,ES=33,TS=34,ii=35,AS=37,NS=38,kS=39,_S=42,ap=44,IS=45,Ro=58,jS=61,RS=62,MS=63,PS=64,lp=91,cp=93,LS=96,up=123,DS=124,dp=125,it={};it[0]="\\0";it[7]="\\a";it[8]="\\b";it[9]="\\t";it[10]="\\n";it[11]="\\v";it[12]="\\f";it[13]="\\r";it[27]="\\e";it[34]='\\"';it[92]="\\\\";it[133]="\\N";it[160]="\\_";it[8232]="\\L";it[8233]="\\P";var OS=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],FS=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function zS(e,t){var n,r,o,s,i,l,c;if(t===null)return{};for(n={},r=Object.keys(t),o=0,s=r.length;o<s;o+=1)i=r[o],l=String(t[i]),i.slice(0,2)==="!!"&&(i="tag:yaml.org,2002:"+i.slice(2)),c=e.compiledTypeMap.fallback[i],c&&ip.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function $S(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new ct("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Ke.repeat("0",r-t.length)+t}var BS=1,Ur=2;function US(e){this.schema=e.schema||ta,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Ke.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=zS(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?Ur:BS,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Al(e,t){for(var n=Ke.repeat(" ",t),r=0,o=-1,s="",i,l=e.length;r<l;)o=e.indexOf(`
315
+ `,r),o===-1?(i=e.slice(r),r=l):(i=e.slice(r,o+1),r=o+1),i.length&&i!==`
316
+ `&&(s+=n),s+=i;return s}function ai(e,t){return`
317
+ `+Ke.repeat(" ",e.indent*t)}function HS(e,t){var n,r,o;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(o=e.implicitTypes[n],o.resolve(t))return!0;return!1}function Mo(e){return e===CS||e===yS}function Hr(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==oa||65536<=e&&e<=1114111}function Nl(e){return Hr(e)&&e!==oa&&e!==SS&&e!==Br}function kl(e,t,n){var r=Nl(e),o=r&&!Mo(e);return(n?r:r&&e!==ap&&e!==lp&&e!==cp&&e!==up&&e!==dp)&&e!==ii&&!(t===Ro&&!o)||Nl(t)&&!Mo(t)&&e===ii||t===Ro&&o}function WS(e){return Hr(e)&&e!==oa&&!Mo(e)&&e!==IS&&e!==MS&&e!==Ro&&e!==ap&&e!==lp&&e!==cp&&e!==up&&e!==dp&&e!==ii&&e!==NS&&e!==_S&&e!==ES&&e!==DS&&e!==jS&&e!==RS&&e!==kS&&e!==TS&&e!==AS&&e!==PS&&e!==LS}function GS(e){return!Mo(e)&&e!==Ro}function Pr(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function fp(e){var t=/^\n* /;return t.test(e)}var pp=1,li=2,mp=3,hp=4,Qn=5;function VS(e,t,n,r,o,s,i,l){var c,d=0,f=null,p=!1,m=!1,g=r!==-1,x=-1,h=WS(Pr(e,0))&&GS(Pr(e,e.length-1));if(t||i)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Pr(e,c),!Hr(d))return Qn;h=h&&kl(d,f,l),f=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Pr(e,c),d===Br)p=!0,g&&(m=m||c-x-1>r&&e[x+1]!==" ",x=c);else if(!Hr(d))return Qn;h=h&&kl(d,f,l),f=d}m=m||g&&c-x-1>r&&e[x+1]!==" "}return!p&&!m?h&&!i&&!o(e)?pp:s===Ur?Qn:li:n>9&&fp(e)?Qn:i?s===Ur?Qn:li:m?hp:mp}function YS(e,t,n,r,o){e.dump=(function(){if(t.length===0)return e.quotingType===Ur?'""':"''";if(!e.noCompatMode&&(OS.indexOf(t)!==-1||FS.test(t)))return e.quotingType===Ur?'"'+t+'"':"'"+t+"'";var s=e.indent*Math.max(1,n),i=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return HS(e,d)}switch(VS(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,o)){case pp:return t;case li:return"'"+t.replace(/'/g,"''")+"'";case mp:return"|"+_l(t,e.indent)+Il(Al(t,s));case hp:return">"+_l(t,e.indent)+Il(Al(KS(t,i),s));case Qn:return'"'+qS(t)+'"';default:throw new ct("impossible error: invalid scalar style")}})()}function _l(e,t){var n=fp(e)?String(t):"",r=e[e.length-1]===`
318
+ `,o=r&&(e[e.length-2]===`
319
+ `||e===`
320
+ `),s=o?"+":r?"":"-";return n+s+`
321
+ `}function Il(e){return e[e.length-1]===`
322
+ `?e.slice(0,-1):e}function KS(e,t){for(var n=/(\n+)([^\n]*)/g,r=(function(){var d=e.indexOf(`
323
+ `);return d=d!==-1?d:e.length,n.lastIndex=d,jl(e.slice(0,d),t)})(),o=e[0]===`
324
+ `||e[0]===" ",s,i;i=n.exec(e);){var l=i[1],c=i[2];s=c[0]===" ",r+=l+(!o&&!s&&c!==""?`
325
+ `:"")+jl(c,t),o=s}return r}function jl(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,o=0,s,i=0,l=0,c="";r=n.exec(e);)l=r.index,l-o>t&&(s=i>o?i:l,c+=`
326
+ `+e.slice(o,s),o=s+1),i=l;return c+=`
327
+ `,e.length-o>t&&i>o?c+=e.slice(o,i)+`
328
+ `+e.slice(i+1):c+=e.slice(o),c.slice(1)}function qS(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Pr(e,o),r=it[n],!r&&Hr(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||$S(n);return t}function XS(e,t,n){var r="",o=e.tag,s,i,l;for(s=0,i=n.length;s<i;s+=1)l=n[s],e.replacer&&(l=e.replacer.call(n,String(s),l)),(gn(e,t,l,!1,!1)||typeof l>"u"&&gn(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function Rl(e,t,n,r){var o="",s=e.tag,i,l,c;for(i=0,l=n.length;i<l;i+=1)c=n[i],e.replacer&&(c=e.replacer.call(n,String(i),c)),(gn(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&gn(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=ai(e,t)),e.dump&&Br===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=s,e.dump=o||"[]"}function ZS(e,t,n){var r="",o=e.tag,s=Object.keys(n),i,l,c,d,f;for(i=0,l=s.length;i<l;i+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=s[i],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),gn(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),gn(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function JS(e,t,n,r){var o="",s=e.tag,i=Object.keys(n),l,c,d,f,p,m;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new ct("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)m="",(!r||o!=="")&&(m+=ai(e,t)),d=i[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),gn(e,t+1,d,!0,!0,!0)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&Br===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,p&&(m+=ai(e,t)),gn(e,t+1,f,!0,p)&&(e.dump&&Br===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=s,e.dump=o||"{}"}function Ml(e,t,n){var r,o,s,i,l,c;for(o=n?e.explicitTypes:e.implicitTypes,s=0,i=o.length;s<i;s+=1)if(l=o[s],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,sp.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(ip.call(l.represent,c))r=l.represent[c](t,c);else throw new ct("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function gn(e,t,n,r,o,s,i){e.tag=null,e.dump=n,Ml(e,n,!1)||Ml(e,n,!0);var l=sp.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",p,m;if(f&&(p=e.duplicates.indexOf(n),m=p!==-1),(e.tag!==null&&e.tag!=="?"||m||e.indent!==2&&t>0)&&(o=!1),m&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(f&&m&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(JS(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(ZS(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?Rl(e,t-1,e.dump,o):Rl(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(XS(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&YS(e,e.dump,t,s,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new ct("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function QS(e,t){var n=[],r=[],o,s;for(ci(e,n,r),o=0,s=r.length;o<s;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(s)}function ci(e,t,n){var r,o,s;if(e!==null&&typeof e=="object")if(o=t.indexOf(e),o!==-1)n.indexOf(o)===-1&&n.push(o);else if(t.push(e),Array.isArray(e))for(o=0,s=e.length;o<s;o+=1)ci(e[o],t,n);else for(r=Object.keys(e),o=0,s=r.length;o<s;o+=1)ci(e[r[o]],t,n)}function eC(e,t){t=t||{};var n=new US(t);n.noRefs||QS(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),gn(n,0,r,!0,!0)?n.dump+`
329
+ `:""}var tC=eC,nC={dump:tC};function sa(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var rC=tt,oC=jf,sC=Lf,iC=$f,aC=Bf,lC=ta,cC=op.load,uC=op.loadAll,dC=nC.dump,fC=ct,pC={binary:Vf,float:zf,map:Pf,null:Df,pairs:Kf,set:qf,timestamp:Wf,bool:Of,int:Ff,merge:Gf,omap:Yf,seq:Mf,str:Rf},mC=sa("safeLoad","load"),hC=sa("safeLoadAll","loadAll"),gC=sa("safeDump","dump"),xC={Type:rC,Schema:oC,FAILSAFE_SCHEMA:sC,JSON_SCHEMA:iC,CORE_SCHEMA:aC,DEFAULT_SCHEMA:lC,load:cC,loadAll:uC,dump:dC,YAMLException:fC,types:pC,safeLoad:mC,safeLoadAll:hC,safeDump:gC};const vC=({content:e,rendererType:t,setRenderError:n})=>{const[r,o]=u.useState(!1);u.useEffect(()=>{n(null)},[e,n]);const[s,i]=u.useMemo(()=>{try{if(t==="yaml"){const l=xC.load(e);return[e,l]}else if(t==="json"){const l=JSON.parse(e);return[JSON.stringify(l,null,2),l]}throw new Error(`Unsupported renderer type: ${t}`)}catch(l){const c=t==="yaml"?"YAML":"JSON";console.error(`Error parsing ${c} for panel:`,l);const d={[`${c}_Parsing_Error`]:`The provided content is not valid ${c}.`,Details:l.message,Content_Snippet:e.substring(0,500)+(e.length>500?"...":"")};return n(`${c} parsing failed: ${l.message}`),[e,d]}},[e,t,n]);return a.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(xe,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Vl,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(Yl,{})," Raw Text"]})})}),a.jsx("div",{className:"flex min-h-0 flex-col",children:a.jsx("div",{className:"flex-1 overflow-auto",children:r?a.jsx(gp,{content:s,setRenderError:n}):a.jsx(hi,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},gp=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=Sf();return a.jsx("div",{className:`overflow-auto p-4 ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},xp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(Ab,{content:e,setRenderError:r});case"mermaid":return a.jsx(Zb,{content:e,setRenderError:r});case"html":return a.jsx(Nb,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(vC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(kb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(_b,{content:e,setRenderError:r});case"audio":return a.jsx(Eb,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(gp,{content:e,setRenderError:r})}},wC={"application/pdf":"pdf","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/x-markdown":"md","application/json":"json","application/yaml":"yaml","text/yaml":"yaml","application/xml":"xml","text/xml":"xml","image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff","audio/mpeg":"mp3","audio/wav":"wav","audio/ogg":"ogg","audio/aac":"aac","audio/flac":"flac","audio/x-m4a":"m4a","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","application/javascript":"js","application/gzip":"gz","application/x-tar":"tar","application/rtf":"rtf"};function bC(e,t){const n=wC[e]||"bin";return`embedded_file_${t+1}.${n}`}function yC(e){if(!e||typeof e!="string")return[];const t=[],n=/data:([a-zA-Z0-9/.-]+);base64,([A-Za-z0-9+/=]+)/g;let r,o=0;for(;(r=n.exec(e))!==null;){const[s,i,l]=r,c=e[r.index-1],d=e[r.index+s.length];if(!(c==='"'&&d==='"'||c==="'"&&d==="'")&&l&&l.length>10){const f=Zr(void 0,i);f?t.push({type:f,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:bC(i,o++)})}}return t}function SC(e){if(!e||typeof e!="string")return[];const t=[],n=/<html[\s\S]*?<\/html>/gi;let r;for(;(r=n.exec(e))!==null;)t.push({type:"html",content:r[0].trim(),originalMatch:r[0]});return t}function CC(e){if(!e||typeof e!="string")return[];const t=[],n=/```mermaid\s*\n([\s\S]*?)```/gi;let r;for(;(r=n.exec(e))!==null;){const[o,s]=r;t.push({type:"mermaid",content:s.trim(),originalMatch:o})}return t}function EC(e){return!e||typeof e!="string"?[]:[...yC(e),...SC(e),...CC(e)]}const TC=["image","audio"],AC=({message:e})=>{var d;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(d=e.parts)==null?void 0:d.filter(f=>f.kind==="text"),o=(r==null?void 0:r.map(f=>f.text).join(""))||"";if(e.isUser)return a.jsx("span",{children:o});const s=o.trim();if(!s)return null;if(e.isError)return a.jsxs("div",{className:"flex items-center",children:[a.jsx(wi,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(ir,{children:s})]});const i=EC(s);if(i.length===0)return a.jsx(ir,{children:s});let l=s;const c=[];return i.forEach((f,p)=>{if(l=l.replace(f.originalMatch,""),f.type==="file"){const m={name:f.filename||"downloaded_file",content:f.content,mime_type:f.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(bf,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!TC.includes(f.type)){const m=gf(f.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:a.jsx(xp,{content:m,rendererType:f.type,mime_type:f.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(ia,{variant:"error",message:"Error rendering preview"}),a.jsx(ir,{children:l}),c]})},vp=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),NC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(vp,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(yf,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,kC=e=>e.files&&e.files.length>0?a.jsx(vp,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(bf,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,_C=(e,t,n)=>{var d,f;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(d=e.parts)==null?void 0:d.some(p=>p.kind==="text"&&p.text.trim());if(!s&&!e.artifactNotification)return null;const i=e.isUser?"sent":"received",l=!e.isUser&&e.isComplete&&!!e.taskId&&n,c=()=>{e.taskId&&(o(e.taskId),r("workflow"))};return a.jsx(df,{variant:i,children:a.jsxs(ff,{variant:i,children:[s&&a.jsx(AC,{message:e}),e.artifactNotification&&a.jsxs("div",{className:"my-1 flex items-center rounded-md bg-blue-100 p-2 dark:bg-blue-900/50",children:[a.jsx(ar,{className:"mr-2 text-blue-500 dark:text-blue-400"}),a.jsxs("span",{className:"text-sm",children:["Artifact created: ",a.jsx("strong",{children:e.artifactNotification.name}),e.artifactNotification.version&&` (v${e.artifactNotification.version})`]})]}),l&&a.jsx("div",{className:"mt-3",children:a.jsx(Qc,{onClick:c})})]})},(f=e.metadata)==null?void 0:f.messageId)},IC=({message:e,isLastWithTaskId:t})=>{const n=He();return e?a.jsxs(a.Fragment,{children:[_C(e,n,t),NC(e),kC(e)]}):null},jC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=He(),{configServerUrl:r}=sn(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[d,f]=u.useState(""),p=u.useCallback(async()=>{const w=`${r}/api/v1/sessions`;try{const y=await Fe(w);if(y.ok){const E=await y.json();i(E.sessions||[])}else console.error(`Failed to fetch sessions: ${y.status} ${y.statusText}`)}catch(y){console.error("An error occurred while fetching sessions:",y)}},[r]);u.useEffect(()=>{p();const w=()=>{p()},y=E=>{const{sessionId:A}=E.detail;i(j=>{const N=j.find(T=>T.id===A);if(N){const T=j.filter(G=>G.id!==A);return[N,...T]}return j})};return window.addEventListener("new-chat-session",w),window.addEventListener("session-updated",y),()=>{window.removeEventListener("new-chat-session",w),window.removeEventListener("session-updated",y)}},[p]),u.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const m=async w=>{l!==w&&await e(w)},g=w=>{c(w.id),f(w.name||"")},x=async()=>{l&&(await t(l,d),c(null),p())},h=w=>{n(w)},v=w=>ch(w),b=w=>{if(w.name&&w.name.trim())return w.name;const y=w.id;return y.startsWith("web-session-")?`Chat ${y.replace("web-session-","").substring(0,8)}`:`Session ${y.substring(0,8)}`};return a.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.length>0&&a.jsx("ul",{children:s.map(w=>a.jsx("li",{className:"group my-2 pr-4",children:a.jsxs("div",{className:"flex items-center justify-between rounded px-4 py-2 hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===w.id?a.jsx("input",{ref:o,type:"text",value:d,onChange:y=>f(y.target.value),onKeyDown:y=>y.key==="Enter"&&x(),onBlur:x,className:"flex-grow bg-transparent focus:outline-none"}):a.jsx("button",{onClick:()=>m(w.id),className:"flex-grow text-left",children:a.jsxs("div",{className:"flex max-w-50 flex-col",children:[a.jsx("span",{className:"truncate font-semibold",title:b(w),children:b(w)}),a.jsx("span",{className:"text-muted-foreground text-xs",children:v(w.updatedTime)})]})}),a.jsx("div",{className:"flex items-center opacity-0 transition-opacity group-hover:opacity-100",children:l===w.id?a.jsxs(a.Fragment,{children:[a.jsx(xe,{variant:"ghost",onClick:x,children:a.jsx(xi,{size:16})}),a.jsx(xe,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Lo,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(xe,{variant:"ghost",onClick:()=>g(w),children:a.jsx(Wp,{size:16})}),a.jsx(xe,{variant:"ghost",onClick:()=>h(w),children:a.jsx(Gp,{size:16})})]})})]})},w.id))}),s.length===0&&a.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[a.jsx(Kl,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]})]})]})},RC=()=>{const{persistenceEnabled:e}=sn(),{sessionName:t}=He();return e===!1?a.jsx("div",{className:"flex h-full flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[a.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[a.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t||"New Chat"}),a.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),a.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Multi-session support coming soon"})]})}):a.jsx(jC,{})},MC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=He(),d=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),a.jsx("div",{className:"truncate text-xs",title:Na(e.last_modified),children:Na(e.last_modified)})]}),t&&d.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(Ud,{value:l==null?void 0:l.toString(),onValueChange:f=>{c(e.filename,parseInt(f))},children:[a.jsx(Wd,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(Hd,{placeholder:"Version"})}),a.jsx(Gd,{children:d.map(f=>a.jsxs(Vd,{value:f.toString(),children:["Version ",f]},f))})]})})]}),a.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[s&&a.jsx(xe,{variant:"ghost",size:"sm",onClick:f=>{f.stopPropagation(),f.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(yi,{})}),o&&a.jsx(xe,{variant:"ghost",size:"sm",onClick:async f=>{f.stopPropagation(),f.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(bi,{})}),r&&a.jsx(xe,{variant:"ghost",size:"sm",onClick:f=>{f.preventDefault(),f.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(ql,{})})]})]})},Pl=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=He(),{onDownload:o}=ed(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=d=>{if(!d||typeof d=="object"&&Object.keys(d).length===0)return a.jsx("span",{children:"Not available"});const f=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&f(p[0],m+1),p.length>1&&a.jsx("span",{children:", ..."}),"]"]}):typeof p=="object"&&p!==null?a.jsx("div",{className:`ml-${m*2} border-l pl-2`,children:Object.entries(p).map(([g,x],h)=>a.jsxs("div",{className:"text-xs",children:[a.jsxs("span",{className:"font-semibold",children:[g,":"]})," ",f(x,m+1)]},h))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof d=="object"&&d.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",d.type," ",d.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof d=="object"&&d.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",d.columns.join(", ")]}),typeof d=="object"&&d.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),f(d.structure)]}),typeof d=="object"&&d.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",d.error]}),typeof d=="string"&&a.jsx("p",{children:d})]})};return a.jsx("div",{className:`group relative w-full border-b px-4 py-3 transition-all duration-150 ${t?"":"cursor-pointer hover:bg-[var(--accent-background)]"}`,onClick:d=>{d.stopPropagation(),r(e)},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),r(e))},tabIndex:0,role:"button","aria-expanded":s,children:a.jsxs("div",{className:"flex items-start space-x-2",children:[a.jsx("div",{className:"flex-shrink-0 pt-0.5",children:wf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(MC,{artifactInfo:e,isExpanded:s,onDelete:l,onDownload:o,setIsExpanded:i,isPreview:t}),s&&a.jsxs("div",{className:"text-xs",children:[a.jsx("div",{className:"mt-1 text-xs break-words whitespace-pre-wrap italic",children:e.description||"No description."}),a.jsxs("div",{className:"mt-2 space-y-1 pt-2",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Size: "}),xc(e.size)]}),e.uri&&a.jsxs("div",{children:[a.jsx("strong",{children:"URI: "}),a.jsx("span",{className:"break-all",children:e.uri||"None"})]}),e.schema&&a.jsx("div",{children:c(e.schema)})]})]})]})]})})},PC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=He();return!e||!t?null:a.jsx(Yo,{open:e,onOpenChange:n,children:a.jsxs(Ko,{children:[a.jsxs(qo,{children:[a.jsxs(Xo,{className:"flex max-w-[400px] flex-row gap-1",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(Zo,{className:"flex flex-col gap-2",children:a.jsx("div",{children:"This file will be permanently deleted. "})})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(xe,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(xe,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},LC={replace:e=>{e instanceof Kp.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function ir({children:e,className:t}){if(!e)return null;try{const n=Vp.parse(e,{gfm:!0}),r=kf.sanitize(n,{USE_PROFILES:{html:!0}}),o=Yp(r,LC);return a.jsx("div",{className:ka(t),children:o})}catch{return a.jsx("div",{className:ka(t),children:e})}}const DC=Nn("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:{error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-w10)]"}},defaultVariants:{variant:"error"}}),OC={error:wi,warning:qp,info:yi,success:Xl};function ia({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=OC[t||"error"];return a.jsxs("div",{className:be(DC({variant:t,className:e})),role:"alert","aria-live":"polite",...s,children:[a.jsx(i,{className:"size-5 shrink-0"}),a.jsx("span",{className:"flex-1",children:n}),r&&o&&a.jsx(xe,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Lo,{className:"size-3"})})]})}const FC=({artifact:e,message:t})=>{const{onDownload:n}=ed();return a.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[a.jsx("div",{className:"mb-1 font-semibold",children:"Preview Coming Soon"}),a.jsx("div",{children:t}),a.jsx("div",{className:"mb-4",children:"Download file to view."}),a.jsxs(xe,{onClick:()=>n(e),children:[a.jsx(bi,{className:"h-4 w-4"}),"Download"]})]})},Fs=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),zC=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=He(),r=u.useMemo(()=>Cb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function f(){try{s(!0),l(null),await t(e.filename)}catch(p){console.error("Error fetching artifact content:",p),l(p instanceof Error?p.message:"Failed to load artifact content")}finally{s(!1)}}r!=null&&r.canPreview&&f()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(ia,{variant:"error",message:"Error rendering preview"}),a.jsx(Fs,{children:"No preview available"})]});if(o)return a.jsx(Fs,{children:a.jsx(vi,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(FC,{artifact:e,message:r.reason??""});const c=Zr(e.filename,e.mime_type),d=yb(n);return!c||!d?a.jsx(Fs,{children:"No preview available"}):a.jsx(xp,{content:d,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},Qt={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},$C=e=>{switch(e){case Qt.NameAsc:return"Name (A-Z)";case Qt.NameDesc:return"Name (Z-A)";case Qt.DateAsc:return"Date (oldest first)";case Qt.DateDesc:return"Date (newest first)"}},BC=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Qt).map(o=>({id:o,label:$C(o),onClick:()=>t(o),icon:e===o?a.jsx(xi,{}):void 0,iconPosition:"right"}));return a.jsxs(pd,{children:[a.jsx(md,{asChild:!0,children:n}),a.jsx(hd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Xi,{actions:r})})]})},UC=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=He(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(Zl,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(ql,{}),iconPosition:"left",divider:!0}];return a.jsxs(pd,{children:[a.jsx(md,{asChild:!0,children:e}),a.jsx(hd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Xi,{actions:r})})]})},HC=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=He();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Yo,{open:t,onOpenChange:n,children:a.jsxs(Ko,{children:[a.jsxs(qo,{children:[a.jsx(Xo,{children:"Delete All?"}),a.jsxs(Zo,{children:[e.length===1?"One file":`All ${e.length} files`," will be permanently deleted."]})]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx(xe,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(xe,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},WC={[Qt.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Qt.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Qt.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Qt.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},GC=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=He(),[o,s]=u.useState(Qt.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(WC[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(xe,{variant:"ghost",onClick:()=>r(null),children:a.jsx(Xp,{})}),a.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):i.length>0&&a.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[a.jsx(BC,{currentSortOption:o,onSortChange:s,children:a.jsxs(xe,{variant:"ghost",title:"Sort By",children:[a.jsx(Wl,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(UC,{children:a.jsx(xe,{variant:"ghost",tooltip:"More",children:a.jsx(Zp,{className:"h-5 w-5"})})},"more-popover")]}),[n,i.length,o,r]);return a.jsxs("div",{className:"flex h-full flex-col",children:[l,a.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(c=>a.jsx(Pl,{artifact:c},c.filename)),i.length===0&&a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&a.jsx(vi,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(ar,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Files"}),a.jsx("div",{className:"mt-2 text-sm",children:"No files available"})]})]})})]}),n&&a.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Pl,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:a.jsx(zC,{artifact:n})})]})]}),a.jsx(PC,{}),a.jsx(HC,{})]})},VC=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=He(),{isReconnecting:c,isTaskMonitorConnecting:d,isTaskMonitorConnected:f,monitoredTasks:p,connectTaskMonitorStream:m}=Ki(),[g,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const y=p[l],E=NE(y.events||[],p,y);x(E)}else x(null)},[l,p]);const h=()=>c||d?{message:"Connecting to task monitor ...",showButton:!1}:f?l?g?null:{message:"No workflow data available for the selected task",showButton:!1}:{message:"No task selected to display",showButton:!1}:{message:"No connection to task monitor",showButton:!0,buttonText:"Reconnect",buttonIcon:Jp,buttonAction:m},v=()=>{const y=!t;n(y),e(y)},b=y=>{y==="files"&&i(null),s(y)},w=y=>{t&&(n(!1),e==null||e(!1)),b(y)};return t?a.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[a.jsx(xe,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(ma,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(ar,{className:"size-5"})}),a.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(ho,{className:"size-5"})})]}):a.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:a.jsx("div",{className:"m-1 min-h-0 flex-1",children:a.jsxs(Y0,{value:o,onValueChange:y=>b(y),className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex gap-2 p-2",children:[a.jsx(xe,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(ma,{className:"size-5"})}),a.jsxs(K0,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(ll,{value:"files",title:"Files",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-l-md border border-r-0 data-[state=active]:z-10 data-[state=active]:border-r-0",children:[a.jsx(ar,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(ll,{value:"workflow",title:"Workflow",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-r-md border border-l-0 data-[state=active]:z-10 data-[state=active]:border-l-0",children:[a.jsx(ho,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(cl,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(GC,{})})}),a.jsx(cl,{value:"workflow",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:(()=>{const y=h();return!y&&g?a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx(qC,{task:g}),a.jsx(AE,{processedSteps:g.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[a.jsx(ho,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),a.jsx("div",{className:"mt-2 text-sm",children:y==null?void 0:y.message}),(y==null?void 0:y.showButton)&&a.jsx("div",{className:"mt-4",children:a.jsxs(xe,{onClick:y.buttonAction,children:[y.buttonIcon&&(()=>{const E=y.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),y.buttonText]})})]})})})()})})]})]})})})},ui=({statusText:e,onViewWorkflow:t})=>a.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?a.jsx(Qc,{onClick:t}):a.jsx(tb,{className:"mr-3 ml-2"}),a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&a.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]}),wp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=He(),{persistenceEnabled:r}=sn();return a.jsx(Yo,{open:e,onOpenChange:t,children:a.jsxs(Ko,{children:[a.jsxs(qo,{children:[a.jsx(Xo,{className:"flex max-w-[400px] flex-row gap-1",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(Zo,{className:"flex flex-col gap-2",children:r===!1?"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?":"This will create a new chat session. Your current chat will be saved in the sessions panel."})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(xe,{variant:"outline",onClick:t,children:"Cancel"}),a.jsx(xe,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},YC=({onToggle:e})=>{const[t,n]=u.useState(!1);return a.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 pt-[35px] pb-3",children:[a.jsx(xe,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(Jl,{className:"size-5"})}),a.jsxs(xe,{variant:"ghost",onClick:()=>n(!0),tooltip:"Start New Chat Session",children:[a.jsx(Ql,{className:"size-5"}),"New chat"]})]}),a.jsx("div",{className:"mt-1 min-h-0 flex-1",children:a.jsx(RC,{})}),a.jsx(wp,{isOpen:t,onClose:()=>n(!1)})]})},_r=(e,t)=>a.jsx(hf,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),KC=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(ui,{statusText:e.currentStatusText})});const n=(r=t==null?void 0:t.parts)==null?void 0:r.filter(o=>o.kind==="text").map(o=>o.text).join("");switch(e.status){case"submitted":case"working":return a.jsx("div",{title:n||e.status,children:a.jsx(ui,{statusText:n||e.status})});case"input-required":return _r("Input Required","info");case"completed":return _r("Completed","success");case"canceled":return _r("Canceled","info");case"failed":return _r("Failed","error");default:return _r("Unknown","info")}},qC=({task:e})=>{const{messages:t}=He(),n=u.useMemo(()=>{const r=t.find(o=>o.isStatusBubble);return e?KC(e,r):null},[t,e]);return e?a.jsxs("div",{className:"grid grid-cols-[auto_1fr] grid-rows-[32px_32px] gap-x-8 border-b p-4 leading-[32px]",children:[a.jsx("div",{className:"text-muted-foreground",children:"User"}),a.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),a.jsx("div",{className:"text-muted-foreground",children:"Status"}),a.jsx("div",{className:"truncate",children:n})]}):null};class bp{getEdgeAnimationState(t,n,r){const o=r.find(l=>l.id===t);if(!o)return{isAnimated:!1,animationType:"static"};if(!this.isAgentToToolRequest(o))return{isAnimated:!1,animationType:"static"};const s=r.slice(0,n+1);return this.hasMatchingResponse(o,s)?{isAnimated:!1,animationType:"static"}:{isAnimated:!0,animationType:"request"}}isAgentToToolRequest(t){var n,r;switch(t.type){case"AGENT_LLM_CALL":return!0;case"AGENT_TOOL_INVOCATION_START":return!(((n=t.data.toolDecision)==null?void 0:n.isPeerDelegation)||((r=t.data.toolInvocationStart)==null?void 0:r.isPeerInvocation)||t.target&&t.target.startsWith("peer_"));default:return!1}}hasMatchingResponse(t,n){switch(t.type){case"AGENT_LLM_CALL":return this.hasLLMResponse(t,n);case"AGENT_TOOL_INVOCATION_START":return this.hasToolResponse(t,n);default:return!1}}hasLLMResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.source;return n.some(s=>{var f;if(new Date(s.timestamp).getTime()<r)return!1;const l=(s.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||s.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&s.target===o,c=s.source===o&&(s.type==="AGENT_TOOL_INVOCATION_START"||s.type==="TASK_COMPLETED"),d=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((f=s.data.toolResult)==null?void 0:f.isPeerResponse);return l||c||d})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.target,s=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===o&&i.target===s)}isRequestStep(t){return this.isAgentToToolRequest(t)}isResponseStep(t){return["AGENT_TOOL_EXECUTION_RESULT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_LLM_RESPONSE_TO_AGENT"].includes(t.type)}}function yp(e,t){return(t==null?void 0:t[e])||e}const pn={USER:50,MAIN_FLOW:300,TOOLS:600},XC=50,qe=50,_t=330,Hn=50,Xt=20,fr=10,Ll=qe+20,ZC=90;function Wn(e,t,n){return e.push(n),t.add(n.id),n}function JC(e,t){return e.push(t),t}function Gn(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function ft(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function Jr(e){const t=ft(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function QC(e,t,n){var r;for(let o=e.length-1;o>=0;o--){const s=e[o],i=n.find(l=>l.id===s.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return s}return null}function eE(e,t){if(!t)return null;const n=ft(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function tE(e,t){if(!t)return null;const n=ft(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function cs(e,t){var o;const n=ft(e);if(!n)return null;if(t.functionCallId){const s=eE(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=tE(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=Jr(e);if(r&&t.source){const s=t.source.replace(/[^a-zA-Z0-9_]/g,"_"),i=(o=t.target)==null?void 0:o.replace(/[^a-zA-Z0-9_]/g,"_"),l=r.peerAgent.id;if(l.includes(s)||i&&l.includes(i))return r}return r||null}function Sp(e,t){var r,o,s;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(s=(o=e.data)==null?void 0:o.toolInvocationStart)==null?void 0:s.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function Cp(e,t,n,r){var o;if(r)for(let s=e.length-1;s>=0;s--){const i=e[s];if(i.functionCallId===r){const l=n.find(c=>c.id===i.id);if(((o=l==null?void 0:l.data)==null?void 0:o.toolName)===t||t==="LLM")return i}}return QC(e,t,n)}function nE(e,t,n){const r=ft(e);if(!r)return null;const o=t.replace(/[^a-zA-Z0-9_]/g,"_"),s=n==null?void 0:n.replace(/[^a-zA-Z0-9_]/g,"_");let i=null;for(const l of r.subflows)if(l.peerAgent.id.includes(o)||s&&l.peerAgent.id.includes(s)){i=l;break}if(!i)return null;if(i.isParallel)return i;if(i.parentSubflowId){const l=r.subflows.find(c=>c.id===i.parentSubflowId);if(l&&l.isParallel)return l;if(l)return Ep(r,l)}return null}function Ep(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return Ep(e,n)}return null}function pr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Gn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l=yp(t,e.agentNameMap),c={id:s,type:"orchestratorNode",position:{x:pn.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};Wn(r,e.allCreatedNodeIds,c),e.nodePositions.set(s,c.position);const d={id:s,yPosition:i,height:qe,width:_t},f={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:d};e.agentRegistry.registerAgent(f);const p={id:o,orchestratorAgent:d,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+qe};return e.phases.push(p),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=p.maxY+Hn,p}function di(e,t,n,r,o){var q,W,X,ee,O;const s=ft(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((q=n.data.toolResult)==null?void 0:q.isPeerResponse)===!0,l=n.source||"",c=n.target||"",d=mr(l);!i&&!d&&!o&&e.indentationLevel++;const f=((X=(W=n.delegationInfo)==null?void 0:W[0])==null?void 0:X.subTaskId)||n.owningTaskId,p=Gn(e,`${t}_${f}`),m=Gn(e,`group_${t}_${f}`),g=((O=(ee=n.data)==null?void 0:ee.toolInvocationStart)==null?void 0:O.functionCallId)||n.functionCallId||"";let x,h,v;const b=Array.from(e.parallelFlows.values()).find(Y=>Y.subflowFunctionCallIds.includes(g)),w=Jr(e),y=nE(e,l,c);o&&b?(x=b.startX+b.currentXOffset,h=b.startY,v=h+Xt,b.currentXOffset+=(_t+fr)*2.2):y?(v=e.nextAvailableGlobalY,x=(y.groupNode.xPosition||pn.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,h=v-Xt):(v=e.nextAvailableGlobalY,x=pn.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,h=v-Xt);const E=yp(t,e.agentNameMap),A={id:p,type:"genericAgentNode",position:{x:50,y:Xt},data:{label:E,visualizerStepId:n.id},parentId:m},j={id:m,type:"group",position:{x,y:h},data:{label:`${E} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${qe+2*Xt}px`}};Wn(r,e.allCreatedNodeIds,j),Wn(r,e.allCreatedNodeIds,A),e.nodePositions.set(p,A.position),e.nodePositions.set(m,j.position);const N={id:p,xPosition:pn.MAIN_FLOW,yPosition:v,height:qe,width:_t},T={id:p,name:t,type:"peer",phaseId:s.id,subflowId:f,context:"subflow",nodeInstance:N};e.agentRegistry.registerAgent(T);const G={id:f,functionCallId:g,isParallel:o,peerAgent:N,groupNode:{id:m,xPosition:x,yPosition:h,height:qe+2*Xt,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+qe,maxContentXRelative:A.position.x+_t,callingPhaseId:s.id,parentSubflowId:w==null?void 0:w.id,inheritedXOffset:y==null?void 0:y.groupNode.xPosition};return s.subflows.push(G),y&&(y.lastSubflow=G),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,G.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+Hn):e.nextAvailableGlobalY=G.groupNode.yPosition+G.groupNode.height+Hn,G}function Tp(e,t,n,r,o,s,i=!1){const l=ft(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,d=i?"LLM":`Tool: ${t}`,f=i?"LLM":t,p=s?s.groupNode.id:void 0;let m,g,x,h;if(s){if(m=s.peerAgent.yPosition+s.currentToolYOffset,s.currentToolYOffset+=Ll,x=50+300,s.groupNode.xPosition===void 0||s.groupNode.yPosition===void 0)return null;g=s.groupNode.xPosition+x,h=m-s.groupNode.yPosition}else g=pn.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Ll,x=g,h=m;const v=Gn(e,`${f}_${r.id}`),b={id:v,type:n,position:{x,y:h},data:{label:d,visualizerStepId:r.id,toolName:t},parentId:p};Wn(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:h});const w={id:v,xPosition:g,yPosition:m,height:qe,width:_t,functionCallId:r.functionCallId};c.push(w);const y=m+qe;if(s){s.maxY=Math.max(s.maxY,y),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+_t);const E=s.maxY-s.groupNode.yPosition+Xt;s.groupNode.height=Math.max(s.groupNode.height,E);const A=s.maxContentXRelative+fr;s.groupNode.width=Math.max(s.groupNode.width||0,A);const j=o.find(N=>N.id===s.groupNode.id);j&&(j.style={...j.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+Hn)}else l.maxY=Math.max(l.maxY,y),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Hn);return w}function aa(e,t,n,r){e.userNodeCounter++;const o=Gn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:pn.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Wn(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:qe,width:_t};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+qe;return t.maxY=Math.max(t.maxY,c),l}function wt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const d=o.allCreatedNodeIds.has(e),f=o.allCreatedNodeIds.has(t);if(!d||!f)return;const p=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(g=>g.id===p)){const g=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",x=s.isRequestStep(n),h={id:p,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:x,animationType:x?"request":"static",duration:1}};l&&(h.sourceHandle=l),c&&(h.targetHandle=c),JC(r,h)}}function rE(){const e=new Map;return{agents:e,findAgentByName(t){const n=t.startsWith("peer_")?t.substring(5):t,r=[];for(const[,o]of e)(o.name===n||o.name===t)&&r.push(o);return r.length===0?null:r.reduce((o,s)=>{const i=parseInt(o.id.split("_").pop()||"0");return parseInt(s.id.split("_").pop()||"0")>i?s:o})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function fi(e,t,n){return e==="orchestrator"?t==="output"?n==="bottom"?"orch-bottom-output":"orch-right-output-tools":n==="top"?"orch-top-input":"orch-right-input-tools":t==="output"?n==="bottom"?"peer-bottom-output":"peer-right-output-tools":n==="top"?"peer-top-input":"peer-right-input-tools"}function mr(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const oE=["USER_REQUEST","AGENT_LLM_CALL","AGENT_LLM_RESPONSE_TO_AGENT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_TOOL_INVOCATION_START","AGENT_TOOL_EXECUTION_RESULT","AGENT_RESPONSE_TEXT","TASK_COMPLETED","TASK_FAILED"];function sE(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=ft(t),d=Jr(t);let f,p=!1;if(d?(f=d.peerAgent,f.id.startsWith(l+"_")&&(p=!0)):c&&(f=c.orchestratorAgent,f.id.startsWith(l+"_")&&(p=!0)),p&&f&&c){t.userNodeCounter++;const m=Gn(t,`User_continue_${t.userNodeCounter}`),g=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:pn.USER,y:g},data:{label:"User",visualizerStepId:e.id}};Wn(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const h={id:m,yPosition:g,height:qe,width:_t};c.userNodes.push(h),t.allUserNodes.push(h);const v=g+qe;f.yPosition=Math.max(f.yPosition,g),c.maxY=Math.max(c.maxY,v,f.yPosition+qe),t.nextAvailableGlobalY=c.maxY+Hn;const b=mr(i)?"orch-left-input":"peer-left-input";wt(h.id,f.id,e,r,t,o,s,"user-right-output",b)}else{const m=pr(t,i,e,n),g=Gn(t,`User_${m.id}`),x={id:g,type:"userNode",position:{x:pn.USER,y:m.orchestratorAgent.yPosition-ZC},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Wn(n,t.allCreatedNodeIds,x),t.nodePositions.set(g,x.position);const h={id:g,yPosition:x.position.y,height:qe,width:_t};m.userNodes.push(h),t.allUserNodes.push(h),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+qe),t.nextAvailableGlobalY=m.maxY+Hn,wt(g,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function iE(e,t,n,r,o,s){const i=ft(t);if(!i)return;const l=cs(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,d=Tp(t,"LLM","llmNode",e,n,l,!0);d&&wt(c,d.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function aE(e,t,n,r,o,s){var x;if(e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"&&((x=e.data.toolDecision)!=null&&x.isParallel)){const h=`parallel-${e.id}`;e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).length>1&&t.parallelFlows.set(h,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).map(v=>v.functionCallId),completedSubflows:new Set,startX:pn.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=ft(t);if(!i)return;const l=cs(t,e);let c;const f=Cp((l||i).toolInstances,"LLM",n,e.functionCallId);if(f)c=f.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const p=e.target||"UnknownAgent";let m,g;l?(m=l.peerAgent.id,g="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(p.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(m=i.orchestratorAgent.id,g="orch-right-input-tools"),c&&m&&g?wt(c,m,e,r,t,o,s,"llm-bottom-output",g):console.error(`[Timeline] Could not determine target agent node ID or handle for step type ${e.type}: ${e.id}. Target agent name: ${p}. Edge will be missing.`)}function lE(e,t,n,r,o,s){var f;const i=ft(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((f=e.data.toolInvocationStart)==null?void 0:f.isPeerInvocation)||c.startsWith("peer_")){const p=c.startsWith("peer_")?c.substring(5):c,m=t.agentRegistry.findAgentByName(l);if(!m){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const g=m.nodeInstance,x=fi(m.type,"output","bottom"),h=Sp(e,t),v=di(t,p,e,n,h);v&&wt(g.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=cs(t,e);let m,g;if(p)m=p.peerAgent.id,g="peer-right-output-tools";else{const h=t.agentRegistry.findAgentByName(l);h?(m=h.id,g=fi(h.type,"output","right")):(m=i.orchestratorAgent.id,g="orch-right-output-tools")}const x=Tp(t,c,"genericToolNode",e,n,p);x&&wt(m,x.id,e,r,t,o,s,g,`${x.id}-tool-left-input`)}}function cE(e,t,n,r,o,s){var d,f;const i=ft(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((d=e.data.toolResult)!=null&&d.isPeerResponse){const p=(f=e.data.toolResult)==null?void 0:f.functionCallId,m=Array.from(t.parallelFlows.entries()).find(([x,h])=>h.subflowFunctionCallIds.includes(p||""));if(m){const[x,h]=m;if(h.completedSubflows.add(p||""),h.completedSubflows.size<h.subflowFunctionCallIds.length)return;const v=i.subflows.filter(E=>h.subflowFunctionCallIds.includes(E.functionCallId)),b=e.target||"OrchestratorAgent";let w,y;if(mr(b))t.indentationLevel=0,w=pr(t,b,e,n).orchestratorAgent,y="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=di(t,b,e,n,!1);if(!E)return;w=E.peerAgent,y="peer-top-input"}v.forEach(E=>{var A;wt(((A=E.lastSubflow)==null?void 0:A.peerAgent.id)??E.peerAgent.id,w.id,e,r,t,o,s,"peer-bottom-output",y)}),t.parallelFlows.delete(x);return}const g=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!g){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(mr(c)){t.indentationLevel=0;const x=pr(t,c,e,n);wt(g.id,x.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const x=Sp(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),h=di(t,c,e,n,x);h&&wt(g.id,h.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=cs(t,e),x=Cp((m||i).toolInstances,l,n,e.functionCallId);if(x&&(p=x.id),p){let h,v;if(m)h=m.peerAgent.id,v="peer-right-input-tools";else{const b=t.agentRegistry.findAgentByName(c);b?(h=b.id,v=fi(b.type,"input","right")):(h=i.orchestratorAgent.id,v="orch-right-input-tools")}wt(p,h,e,r,t,o,s,l==="LLM"?"llm-bottom-output":`${p}-tool-bottom-output`,v)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function uE(e,t,n,r,o,s){const i=ft(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=aa(t,i,e,n);wt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function dE(e,t,n,r,o,s){const i=ft(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(g=>g.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const g=pr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&wt(x.peerAgent.id,g.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=Jr(t);if(!c){console.warn(`[Timeline] TASK_COMPLETED with isSubTaskStep=true but no active subflow. Step ID: ${e.id}`);return}if(!i){console.error(`[Timeline] No current phase found for TASK_COMPLETED. Step ID: ${e.id}`);return}const d=c.peerAgent,f=n.some(g=>typeof g.data.label=="string"&&mr(g.data.label));let p,m;f?(t.indentationLevel=0,p=pr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=aa(t,i,e,n).id,m="user-top-input"),wt(d.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function fE(e,t,n,r){const o=ft(t);if(!o)return;const s=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const d=Jr(t);if(d&&d.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=d.peerAgent,c="peer-bottom-output";else if(o.orchestratorAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=o.orchestratorAgent,c="orch-bottom-output";else for(const m of o.subflows)if(m.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_"))){l=m.peerAgent,c="peer-bottom-output";break}if(!l){console.error(`[Timeline] Could not find source agent node for TASK_FAILED: ${s}`);return}let f,p;mr(i)?(t.indentationLevel=0,f=pr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(f=aa(t,o,e,n).id,p="user-top-input"),pE(l.id,f,e,r,t,c,p)}function pE(e,t,n,r,o,s,i){var p;if(!e||!t||e===t)return;const l=o.allCreatedNodeIds.has(e),c=o.allCreatedNodeIds.has(t);if(!l||!c)return;const d=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===d)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",g=m.length>30?"Error":m,x={id:d,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:m}};s&&(x.sourceHandle=s),i&&(x.targetHandle=i),r.push(x)}}const mE=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const o=new bp,s={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:XC,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:rE(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(d=>oE.includes(d.type)),l=i.findIndex(d=>d.type==="USER_REQUEST");let c=i;l>0&&(c=[i[l],...i.slice(0,l),...i.slice(l+1)]);for(const d of c)switch(d.type){case"USER_REQUEST":sE(d,s,n,r,o,e);break;case"AGENT_LLM_CALL":iE(d,s,n,r,o,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":aE(d,s,n,r,o,e);break;case"AGENT_TOOL_INVOCATION_START":lE(d,s,n,r,o,e);break;case"AGENT_TOOL_EXECUTION_RESULT":cE(d,s,n,r,o,e);break;case"AGENT_RESPONSE_TEXT":uE(d,s,n,r,o,e);break;case"TASK_COMPLETED":dE(d,s,n,r,o,e);break;case"TASK_FAILED":fE(d,s,n,r);break}return s.phases.forEach(d=>{d.subflows.forEach(f=>{const p=n.find(m=>m.id===f.groupNode.id);if(p&&p.style){const g=f.maxY-f.groupNode.yPosition+Xt;p.style.height=`${Math.max(qe+2*Xt,g)}px`;const x=f.maxContentXRelative+fr,h=_t+2*fr+s.indentationLevel*s.indentationStep;p.style.width=`${Math.max(x,h)}px`}})}),{nodes:n,edges:r}},hE=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:d})=>{const[f,p]=u.useState(!1),[m]=Qp({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),g=()=>{const v={strokeWidth:f?3:2,stroke:"var(--color-muted-foreground)",...l},b=d;return b!=null&&b.isError?{...v,stroke:f?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:f?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:f?"#1d4ed8":"#3b82f6",strokeWidth:f?4:3}:f?{...v,stroke:"var(--edge-hover-color)"}:v},x=()=>p(!0),h=()=>p(!1);return a.jsxs(a.Fragment,{children:[a.jsx("path",{id:`${e}-interaction`,style:{strokeWidth:16,stroke:"transparent",fill:"none",cursor:"pointer"},className:"react-flow__edge-interaction",d:m,onMouseEnter:x,onMouseLeave:h}),a.jsx("path",{id:e,style:{...g(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:m,markerEnd:c,onMouseEnter:x,onMouseLeave:h})]})},gE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-blue-700 bg-white px-5 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-blue-600 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"180px",textAlign:"center"},children:[a.jsx(Qe,{type:"target",position:et.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Qe,{type:"source",position:et.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(Qe,{type:"target",position:et.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(Qe,{type:"source",position:et.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Qe,{type:"target",position:et.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md font-semibold truncate",style:{maxWidth:"200px"},children:e.label})})]}),xE=({data:e,id:t})=>{const n=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-cyan-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-cyan-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-cyan-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Qe,{type:"target",position:et.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),a.jsx("div",{className:"text-md truncate",style:{maxWidth:"200px"},children:e.label})]}),a.jsx(Qe,{type:"source",position:et.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},vE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-teal-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-teal-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-teal-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Qe,{type:"target",position:et.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(Qe,{type:"source",position:et.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},wE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-lg border-indigo-600 bg-gradient-to-r from-indigo-50 to-purple-50 px-5 py-3 text-gray-900 shadow-xl transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-2xl dark:border-indigo-400 dark:bg-gradient-to-r dark:from-indigo-900 dark:to-purple-900 dark:text-gray-100",style:{minWidth:"180px",textAlign:"center",borderWidth:"2px",borderStyle:"solid",boxShadow:"0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:[a.jsx(Qe,{type:"source",position:et.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(Qe,{type:"target",position:et.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(Qe,{type:"target",position:et.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Qe,{type:"source",position:et.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Qe,{type:"target",position:et.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md font-bold truncate",style:{maxWidth:"200px"},children:e.label})})]}),bE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-purple-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-purple-600 bg-white px-4 py-3 text-gray-800 shadow-lg transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-700 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[e.isTopNode&&a.jsx(Qe,{type:"source",position:et.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(Qe,{type:"target",position:et.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(Qe,{type:"source",position:et.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),a.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},yE=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,y,E;switch(e.type){case"USER_REQUEST":return a.jsx(rm,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(ds,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(Xl,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(nm,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(ds,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(ds,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const A=(y=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:y[0];return(A==null?void 0:A.isPeerDelegation)?a.jsx(ha,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(ga,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(E=e.data.toolInvocationStart)!=null&&E.isPeerInvocation?a.jsx(ha,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(ga,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(tm,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(ar,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(em,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},s=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),i=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),l=`${s}.${i}`,c=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Prompt Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.promptPreview})]}),d=({data:w})=>{const[y,E]=Ht.useState(!1),A=j=>{j.stopPropagation(),E(!y)};return y?a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[a.jsx("strong",{children:"LLM Response Details:"}),a.jsx("button",{onClick:A,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),w.modelName&&a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsxs("div",{className:"mt-1",children:[a.jsx("p",{children:a.jsx("strong",{children:"Response Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.responsePreview})]}),w.isFinalResponse!==void 0&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Final Response:"})," ",w.isFinalResponse?"Yes":"No"]})]}):a.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"italic",children:"Internal LLM response"}),a.jsx("button",{onClick:A,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},f=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-blue-50 p-2 font-mono text-xs text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{children:["🔧 ",w.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),a.jsx("ul",{className:"space-y-1 pl-2",children:w.decisions.map(y=>a.jsxs("li",{className:"flex items-center",children:[a.jsx("span",{className:"mr-2",children:"•"}),a.jsx("code",{children:y.toolName})]},y.functionCallId))})]}),p=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Arguments:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:a.jsx(hi,{data:w.toolArguments})})]}),m=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Result:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:typeof w.resultData=="object"?a.jsx(hi,{data:w.resultData}):a.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(w.resultData)})})]}),g=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Artifact:"})," ",w.artifactName,w.version!==void 0&&a.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",w.version,")"]})]}),w.mimeType&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",w.mimeType]}),w.description&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Description:"})," ",w.description]})]}),x=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},h=r==="popover"?`
330
+ p-3 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors duration-150
331
+ ${n?"cursor-pointer":""}
332
+ `:`
333
+ mb-3 p-3 border rounded-lg shadow-sm
334
+ bg-white dark:bg-gray-800 hover:shadow-md transition-shadow duration-150
335
+ ${t?"border-blue-500 dark:border-blue-400 ring-2 ring-blue-500 dark:ring-blue-400":"border-gray-200 dark:border-gray-700"}
336
+ ${n?"cursor-pointer":""}
337
+ `,v=()=>e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||e.type==="AGENT_TOOL_INVOCATION_START"?"Delegated to: ":e.type==="AGENT_TOOL_EXECUTION_RESULT"?"Response from: ":"Peer Interaction with: ",b=e.title;return a.jsxs("div",{className:h,style:x,onClick:n,children:[a.jsxs("div",{className:"mb-1.5 flex items-center",children:[o(),a.jsx("h4",{className:"flex-grow text-sm font-semibold text-gray-700 dark:text-gray-200",title:e.title,children:b}),a.jsx("span",{className:"font-mono text-xs text-gray-500 dark:text-gray-400",children:l})]}),e.delegationInfo&&e.delegationInfo.length>0&&a.jsx("div",{className:"mt-2 mb-1.5 space-y-2 rounded-r-md border-l-4 border-blue-500 bg-blue-50 p-2 text-sm dark:border-blue-400 dark:bg-gray-700/60",children:e.delegationInfo.map(w=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center font-semibold text-blue-700 dark:text-blue-300",children:[a.jsx(ec,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.jsxs("span",{children:[v(),w.peerAgentName]})]}),w.subTaskId&&a.jsxs("div",{className:"mt-0.5 ml-[24px] text-xs text-blue-600 dark:text-blue-400",children:["Sub-Task:"," ",a.jsxs("span",{className:"font-mono",title:w.subTaskId,children:[w.subTaskId.substring(0,15),"..."]})]})]},w.functionCallId))}),e.data.text&&a.jsx("div",{className:"max-h-20 overflow-y-auto pl-1 text-sm text-gray-800 dark:text-gray-100",children:a.jsx(ir,{children:e.data.text})}),e.data.finalMessage&&a.jsx("div",{className:"pl-1 text-sm text-gray-800 dark:text-gray-100",children:a.jsx(ir,{children:e.data.finalMessage})}),e.type==="TASK_COMPLETED"&&!e.data.finalMessage&&a.jsx("div",{className:"pl-1 text-sm text-gray-600 italic dark:text-gray-300",children:"Task completed successfully."}),e.data.errorDetails&&a.jsxs("div",{className:"mt-1 rounded-md bg-red-50 p-2 pl-1 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Error:"})," ",e.data.errorDetails.message]}),e.data.errorDetails.code&&a.jsxs("p",{className:"text-xs",children:["Code: ",e.data.errorDetails.code]})]}),e.data.llmCall&&c(e.data.llmCall),e.data.llmResponseToAgent&&a.jsx(d,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&f(e.data.toolDecision),e.data.toolInvocationStart&&p(e.data.toolInvocationStart),e.data.toolResult&&m(e.data.toolResult),e.data.artifactNotification&&g(e.data.artifactNotification)]})},SE={genericAgentNode:gE,userNode:bE,llmNode:vE,orchestratorNode:wE,genericToolNode:xE},CE={defaultFlowEdge:hE},EE={x:16,y:0},TE=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,o,s]=sm([]),[i,l,c]=im([]),{fitView:d}=am(),{highlightedStepId:f,setHighlightedStepId:p}=Ki(),{taskIdInSidePanel:m}=He(),{agentNameMap:g}=Ju(),x=u.useRef([]),[h,v]=u.useState(!1),[b,w]=u.useState(null),[y,E]=u.useState(!1),A=u.useRef(null),[j,N]=u.useState(null),T=u.useRef(new bp),G=u.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:mE(e,g),[e,g]),q=u.useMemo(()=>G.edges.length?G.edges.map(C=>{const _=C.data;let L={isAnimated:!1,animationType:"none"};if(_!=null&&_.visualizerStepId){const J=e.length-1;L=T.current.getEdgeAnimationState(_.visualizerStepId,J,e)}let R=C.id===j;return f&&(_==null?void 0:_.visualizerStepId)===f&&(R=!0),{...C,animated:L.isAnimated,data:{..._,isAnimated:L.isAnimated,animationType:L.animationType,isSelected:R}}}):[],[G.edges,e,j,f]),W=u.useCallback(()=>{o(C=>C.map(_=>{var ae,se,pe,ye;if(_.type!=="group")return _;const L=C.filter(_e=>_e.parentId===_.id);if(L.length===0)return _;let R=0,J=0;L.forEach(_e=>{const Ie=_e.position.x+_t,Pe=_e.position.y+qe;R=Math.max(R,Ie),J=Math.max(J,Pe)});const P=R+fr,B=J+Xt;let D=0;const U=_.id.split("_");if(U.length>2){const _e=U.find(Ie=>Ie.startsWith("subflow"));if(_e){const Ie=parseInt(_e.replace("subflow",""));isNaN(Ie)||(D=Ie)}}const I=_t+2*fr+D*50,V=Math.max(P,I),Q=parseInt(((se=(ae=_.style)==null?void 0:ae.width)==null?void 0:se.toString().replace("px",""))||"0"),te=parseInt(((ye=(pe=_.style)==null?void 0:pe.height)==null?void 0:ye.toString().replace("px",""))||"0");return Q!==V||te!==B?{..._,style:{..._.style,width:`${V}px`,height:`${B}px`}}:_}))},[o]);u.useEffect(()=>{o(G.nodes),l(q),W()},[G.nodes,q,o,l,W]);const X=u.useCallback((C,_)=>i.find(L=>L.source===C&&(_?L.sourceHandle===_:!0))||null,[i]),ee=u.useCallback((C,_)=>{var R;v(!0);const L=(R=_.data)==null?void 0:R.visualizerStepId;if(L){const J=e.find(P=>P.id===L);J&&(N(_.id),t?p(L):(p(L),w(J),E(!0)))}},[e,t,p]),O=u.useCallback(C=>{switch(C.type){case"userNode":{const _=C.data;return _!=null&&_.isTopNode?["user-bottom-output"]:_!=null&&_.isBottomNode?["user-top-input"]:["user-right-output"]}case"orchestratorNode":return["orch-right-output-tools","orch-bottom-output"];case"genericAgentNode":return["peer-right-output-tools","peer-bottom-output"];case"llmNode":return["llm-bottom-output"];case"genericToolNode":return[`${C.id}-tool-bottom-output`];default:return[]}},[]),Y=u.useCallback(()=>{E(!1),w(null)},[]),k=u.useCallback((C,_)=>{if(v(!0),_.type==="group"){p(null),N(null),Y();return}const L=O(_);let R=null;for(const J of L)if(R=X(_.id,J),R)break;if(!R&&_.type==="userNode"){const J=_.data;J!=null&&J.isBottomNode&&(R=i.find(P=>P.target===_.id)||null)}R&&ee(C,R)},[O,p,Y,X,i,ee]),$=u.useCallback(C=>{C!=null&&C.isTrusted&&v(!0)},[]);return u.useEffect(()=>{v(!1)},[m]),u.useEffect(()=>{!n&&d&&r.length>0&&x.current!==e&&h===!1&&(d({duration:200,padding:.1,maxZoom:1.2}),x.current=e)},[r.length,d,e,n,h]),u.useEffect(()=>{if(o(C=>C.map(_=>{var P;const L=((P=_.data)==null?void 0:P.visualizerStepId)&&_.data.visualizerStepId===f,R=G.nodes.find(B=>B.id===_.id),J=(R==null?void 0:R.style)||{};return{..._,style:{...J,boxShadow:L?"0px 4px 12px rgba(0, 0, 0, 0.2)":J.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),f){const C=q.find(_=>{const L=_.data;return(L==null?void 0:L.visualizerStepId)===f});C&&N(C.id)}else N(null)},[f,o,G.nodes,q]),!e||e.length===0?a.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:Object.keys(e).length>0?"Processing flow data...":"No steps to display in flow chart."}):G.nodes.length===0&&e.length>0?a.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:"Generating flow chart..."}):a.jsxs("div",{style:{height:"100%",width:"100%"},className:"relative",children:[a.jsxs(lm,{nodes:r,edges:i.map(C=>({...C,markerEnd:{type:fm.ArrowClosed,color:"#888"}})),onNodesChange:s,onEdgesChange:c,onEdgeClick:ee,onNodeClick:k,onPaneClick:()=>{p(null),N(null),Y()},onMoveStart:$,nodeTypes:SE,edgeTypes:CE,fitViewOptions:{padding:.1},className:"bg-gray-50 dark:bg-gray-900 [&>button]:dark:bg-gray-700",proOptions:{hideAttribution:!0},nodesDraggable:!1,elementsSelectable:!1,nodesConnectable:!1,minZoom:.2,children:[a.jsx(cm,{}),a.jsx(um,{className:uh()}),a.jsx(dm,{position:"top-right",className:"flex items-center space-x-4",children:a.jsx("div",{ref:A})})]}),a.jsx(Ww,{isOpen:y,onClose:Y,anchorRef:A,offset:EE,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:b&&a.jsx(yE,{step:b,variant:"popover"})})]})},AE=e=>a.jsx(om,{children:a.jsx(TE,{...e})}),Ap=e=>{var t,n,r,o;if(e.events&&e.events.length>0){const s=e.events[0];if((o=(r=(n=(t=s.full_payload)==null?void 0:t.params)==null?void 0:n.message)==null?void 0:r.metadata)!=null&&o.parentTaskId)return s.full_payload.params.message.metadata.parentTaskId}},Ir=e=>{var t,n,r;return((r=(n=(t=e.full_payload)==null?void 0:t.result)==null?void 0:n.status)==null?void 0:r.timestamp)||e.timestamp},Np=(e,t,n,r)=>{const o=t[e];if(!o)return console.warn(`[collectAllDescendantEvents] Task not found in allMonitoredTasks: ${e}`),[];n.set(e,r);let s=[...o.events||[]];for(const i in t){const l=t[i];if(l.taskId===e)continue;Ap(l)===e&&(s=s.concat(Np(l.taskId,t,n,r+1)))}return s},NE=(e,t,n)=>{if(!n)return null;const r={overall:{totalTaskDurationMs:0},agents:{}},o=new Map,s=new Map,i=(k,$)=>(r.agents[k]||(r.agents[k]={agentName:$,instanceId:k,displayName:$,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),r.agents[k]),l=new Map,c=Np(n.taskId,t,l,0);if(c.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const d=c.sort((k,$)=>new Date(Ir(k)).getTime()-new Date(Ir($)).getTime()),f=[];let p,m="",g,x,h=[],v=null,b;const w=new Map,y=new Map,E=new Map,A=k=>{if(m.trim()&&g&&x){const $=m.trim();let C=n.taskId;if(h.length>0){const R=h[0].split("-");R.length>2&&R[1]!=="global"&&(C=R.slice(1,R.length-1).join("-"))}else k&&(C=k);const _=l.get(C)??0,L=w.get(C)||E.get(C);f.push({id:`vstep-agenttext-${f.length}-${h[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:x,title:`${g}: Response`,source:g,target:"User",data:{text:$},rawEventIds:[...h],isSubTaskStep:_>0,nestingLevel:_,owningTaskId:C,functionCallId:L}),v=$}m="",g=void 0,x=void 0,h=[],b=void 0};d.forEach((k,$)=>{var I,V,Q,te,ae,se,pe,ye,_e,Ie,Pe,Re,Be,yt,We,St,nt,rt,ot,le,jt,Ct,Rt,Mt,Et,Tt,At,Xe,pt,Pt,Lt,an,De,Ge,Dt,gt,Ot,Ft,ze,mt,ln,Kt,Nt,zt,qt;const C=Ir(k),_=`raw-${k.task_id||"global"}-${$}`,L=k.full_payload,R=k.task_id||n.taskId,J=l.get(R)??0;let P=k.source_entity||"UnknownAgent";(Q=(V=(I=L==null?void 0:L.params)==null?void 0:I.message)==null?void 0:V.metadata)!=null&&Q.agent_name?P=L.params.message.metadata.agent_name:(ae=(te=L==null?void 0:L.result)==null?void 0:te.metadata)!=null&&ae.agent_name?P=L.result.metadata.agent_name:(_e=(ye=(pe=(se=L==null?void 0:L.result)==null?void 0:se.status)==null?void 0:pe.message)==null?void 0:ye.metadata)!=null&&_e.agent_name?P=L.result.status.message.metadata.agent_name:(Re=(Pe=(Ie=L==null?void 0:L.result)==null?void 0:Ie.artifact)==null?void 0:Pe.metadata)!=null&&Re.agent_name&&(P=L.result.artifact.metadata.agent_name);let B;if(J>0?B=w.get(R):B=E.get(R),k.direction==="request"&&J>0){const Se=(Be=L.params)==null?void 0:Be.metadata,z=Se==null?void 0:Se.function_call_id,H=k.task_id;if(H&&z){w.set(H,z);return}}if(k.direction==="request"&&J===0&&k.task_id===n.taskId){A(R),v=null;const Se=L.params;let z="User request";if((yt=Se==null?void 0:Se.message)!=null&&yt.parts){const H=Se.message.parts.filter(F=>F.kind==="text"&&F.text);H.length>0&&(z=H[H.length-1].text)}f.push({id:`vstep-userreq-${f.length}-${_}`,type:"USER_REQUEST",timestamp:C,title:"User Input",source:"User",target:k.target_entity||P,data:{text:z},rawEventIds:[_],isSubTaskStep:!1,nestingLevel:0,owningTaskId:R});return}if(k.direction==="status-update"&&(L!=null&&L.result)){const Se=L.result,z=(We=Se.status)==null?void 0:We.message,H=z==null?void 0:z.metadata;let F;const ie=!!(H!=null&&H.forwarded_from_peer);ie?F=H.forwarded_from_peer:(St=Se.metadata)!=null&&St.agent_name?F=Se.metadata.agent_name:H!=null&&H.agent_name?F=H.agent_name:F=k.source_entity||"Agent";const de=`${F}:${R}`;if(!ie&&(z!=null&&z.parts))for(const ce of z.parts){if(ce.kind==="data"){const ve=ce.data;ve.type==="agent_progress_update"?p=ve.status_text:ve.type==="artifact_creation_progress"&&(p=`Saving artifact: ${ve.filename} (${ve.bytes_saved} bytes)`)}if(ce.kind==="data"){A(R);const he=ce.data;switch(he==null?void 0:he.type){case"agent_progress_update":{f.push({id:`vstep-progress-${f.length}-${_}`,type:"AGENT_RESPONSE_TEXT",timestamp:C,title:`${F}: Progress Update`,source:F,target:"User",data:{text:he.status_text},rawEventIds:[_],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B});break}case"llm_invocation":{const ne=he.request;let me="System-initiated LLM call";if(ne!=null&&ne.contents&&Array.isArray(ne.contents)&&ne.contents.length>0){const Z=[...ne.contents].reverse().find(S=>S.role==="user");Z&&Z.parts&&(me=Z.parts.map(S=>S.text||"").join(`
338
+ `).trim())}const Le={modelName:(ne==null?void 0:ne.model)||"Unknown Model",promptPreview:me||"No text in user prompt."};i(de,F),o.set(de,{timestamp:C,modelName:Le.modelName}),f.push({id:`vstep-llmcall-${f.length}-${_}`,type:"AGENT_LLM_CALL",timestamp:C,title:`${F}: LLM Call`,source:F,target:"LLM",data:{llmCall:Le},rawEventIds:[_],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B});break}case"llm_response":{const ne=o.get(de);if(ne){const S=new Date(C).getTime()-new Date(ne.timestamp).getTime();i(de,F).llmCalls.push({modelName:ne.modelName,durationMs:S,timestamp:ne.timestamp}),o.delete(de)}const me=he.data,Le=(nt=me.content)==null?void 0:nt.parts,Z=Le==null?void 0:Le.filter(S=>S.function_call);if(Z&&Z.length>0){A(R),v=null,E.delete(R);const S=Z.map(Te=>{var Ze;return{functionCallId:Te.function_call.id,toolName:Te.function_call.name,toolArguments:Te.function_call.args||{},isPeerDelegation:(Ze=Te.function_call.name)==null?void 0:Ze.startsWith("peer_")}}),M={decisions:S,isParallel:S.length>1},K=[],Ne=new Set;S.forEach(Te=>{if(Te.isPeerDelegation){const Ze=Te.toolName.substring(5);for(const $t in t){const Me=t[$t];if(Ne.has(Me.taskId))continue;if(Ap(Me)===R&&Me.events&&Me.events.length>0){const yr=Me.events.find(Sr=>{var la,ca,ua,da;return Sr.direction==="request"&&((da=(ua=(ca=(la=Sr.full_payload)==null?void 0:la.params)==null?void 0:ca.message)==null?void 0:ua.metadata)==null?void 0:da.function_call_id)===Te.functionCallId});if(yr&&new Date(Ir(yr)).getTime()>=new Date(C).getTime()){const Sr={functionCallId:Te.functionCallId,peerAgentName:Ze,subTaskId:Me.taskId};K.push(Sr),y.set(Te.functionCallId,Sr),Me.taskId&&(w.set(Me.taskId,Te.functionCallId),Ne.add(Me.taskId));break}}}}});const Oe={id:`vstep-tooldecision-${f.length}-${_}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:C,title:`LLM: Tool Decision${M.isParallel?" (Parallel)":""}`,source:"LLM",target:F,data:{toolDecision:M},rawEventIds:[_],delegationInfo:K.length>0?K:void 0,isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B};f.push(Oe);const ue=M.isParallel?Oe.id:void 0,we=de;i(we,F),S.forEach(Te=>{var $t;const Ze=Te.isPeerDelegation?($t=y.get(Te.functionCallId))==null?void 0:$t.subTaskId:void 0;s.has(Te.functionCallId)||s.set(Te.functionCallId,{timestamp:C,toolName:Te.toolName,isPeer:Te.isPeerDelegation,invokingAgentInstanceId:we,subTaskId:Ze,parallelBlockId:ue})})}else{const S=(Le==null?void 0:Le.filter(K=>K.text).map(K=>K.text).join(`
339
+ `))||"",M={responsePreview:S.substring(0,200)+(S.length>200?"...":""),isFinalResponse:(me==null?void 0:me.partial)===!1};f.push({id:`vstep-llmrespagent-${f.length}-${_}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:C,title:`${F}: LLM Response`,source:"LLM",target:F,data:{llmResponseToAgent:M},rawEventIds:[_],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B})}break}case"tool_invocation_start":{const ne={functionCallId:he.function_call_id,toolName:he.tool_name,toolArguments:he.tool_args,isPeerInvocation:(rt=he.tool_name)==null?void 0:rt.startsWith("peer_")};f.push({id:`vstep-toolinvokestart-${f.length}-${_}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:C,title:`${F}: Executing tool ${ne.toolName}`,source:F,target:ne.toolName,data:{toolInvocationStart:ne},rawEventIds:[_],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B});break}case"tool_result":{const ne=he.function_call_id,me=s.get(ne);if(me){const Z=new Date(C).getTime()-new Date(me.timestamp).getTime(),S=r.agents[me.invokingAgentInstanceId];if(S){const M={toolName:me.toolName,durationMs:Z,isPeer:me.isPeer,timestamp:me.timestamp,peerAgentName:me.isPeer?me.toolName.substring(5):void 0,subTaskId:me.subTaskId,parallelBlockId:me.parallelBlockId};S.toolCalls.push(M)}s.delete(ne)}const Le={toolName:he.tool_name,functionCallId:ne,resultData:he.result_data,isPeerResponse:(ot=he.tool_name)==null?void 0:ot.startsWith("peer_")};f.push({id:`vstep-toolresult-${f.length}-${_}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:C,title:`${F}: Tool Result - ${Le.toolName}`,source:Le.toolName,target:F,data:{toolResult:Le},rawEventIds:[_],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B});break}}}else ce.kind==="text"&&ce.text&&(g&&g!==F&&(A(R),v=null),g||(g=F,x=C,b=ie),m+=ce.text,h.push(_))}return}if(k.direction==="artifact_update"&&((le=L==null?void 0:L.result)!=null&&le.artifact)){A(R);const Se=L.result.artifact,z=((jt=Se.metadata)==null?void 0:jt.agent_name)||k.source_entity||"Agent";let H;if(Se.parts&&Se.parts.length>0){const ie=Se.parts[0];ie.kind==="file"?H=ie.file.mimeType||void 0:(Ct=ie.metadata)!=null&&Ct.mime_type&&(H=ie.metadata.mime_type)}const F={artifactName:Se.name||"Unnamed Artifact",version:typeof((Rt=Se.metadata)==null?void 0:Rt.version)=="number"?Se.metadata.version:void 0,description:Se.description||void 0,mimeType:H};f.push({id:`vstep-artifactnotify-${f.length}-${_}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:C,title:`${z}: Artifact Update - ${F.artifactName}`,source:z,target:"User/System",data:{artifactNotification:F},rawEventIds:[_],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B});return}if(["response","task"].includes(k.direction)&&((Et=(Mt=L==null?void 0:L.result)==null?void 0:Mt.status)!=null&&Et.state)){m.trim()&&A(R);const Se=L.result,z=Se.status.state,H=((Tt=Se.metadata)==null?void 0:Tt.agent_name)||((pt=(Xe=(At=Se.status)==null?void 0:At.message)==null?void 0:Xe.metadata)==null?void 0:pt.agent_name)||k.source_entity||"Agent";if(["completed","failed","canceled"].includes(z)&&J==0){const F=z==="completed"?"TASK_COMPLETED":"TASK_FAILED",ie=`${H}: Task ${z.charAt(0).toUpperCase()+z.slice(1)}`;let de={},ce="";if((Pt=Se.status.message)!=null&&Pt.parts){const je=Se.status.message.parts.find(ne=>ne.kind==="text");je!=null&&je.text&&(ce=je.text.trim())}const ve=R===n.taskId,he=ce&&(!ve||ce!==v);if(F==="TASK_COMPLETED")de={finalMessage:he?ce:void 0};else{const ne={message:he?ce:`Task ${z}.`},me=L.error;me&&(ne.message=me.message||ne.message,ne.code=me.code,me.data&&(ne.details=me.data)),Se.error&&(ne.message=Se.error.message||ne.message,ne.code=Se.error.code||ne.code,ne.details=Se.error.data||ne.details),de={errorDetails:ne}}f.push({id:`vstep-${z}-${f.length}-${_}`,type:F,timestamp:C,title:ie,source:H,target:"User",data:de,rawEventIds:[_],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:R,functionCallId:B}),ve&&(v=null);return}}const D=k.direction==="status-update"&&((Ge=(De=(an=(Lt=L==null?void 0:L.result)==null?void 0:Lt.status)==null?void 0:an.message)==null?void 0:De.parts)==null?void 0:Ge.some(Se=>Se.kind==="text"));let U=k.source_entity;(Ft=(Ot=(gt=(Dt=L==null?void 0:L.result)==null?void 0:Dt.status)==null?void 0:gt.message)==null?void 0:Ot.metadata)!=null&&Ft.forwarded_from_peer?U=L.result.status.message.metadata.forwarded_from_peer:(mt=(ze=L==null?void 0:L.result)==null?void 0:ze.metadata)!=null&&mt.agent_name?U=L.result.metadata.agent_name:(zt=(Nt=(Kt=(ln=L==null?void 0:L.result)==null?void 0:ln.status)==null?void 0:Kt.message)==null?void 0:Nt.metadata)!=null&&zt.agent_name&&(U=L.result.status.message.metadata.agent_name),m.trim()&&g&&(!D||D&&U!==g)&&(A(R),l.get(((qt=h[0])==null?void 0:qt.split("-")[1])||n.taskId)===0&&!b&&(v=null))});const j=d.length>0&&d[d.length-1].task_id||n.taskId;A(j);const N=d[0]?Ir(d[0]):n.firstSeen.toISOString();let T,G="working";const q=f.filter(k=>k.owningTaskId===n.taskId),W=q.length>0?q[q.length-1]:null;if(W&&(W.type==="TASK_COMPLETED"?(G="completed",T=W.timestamp):W.type==="TASK_FAILED"&&(G="failed",T=W.timestamp)),G==="working"&&d.length>0){const k=d[d.length-1];t[k.task_id||n.taskId]}let X;N&&T&&(X=new Date(T).getTime()-new Date(N).getTime()),["completed","failed","canceled","rejected"].includes(G)&&(p=void 0);const ee={taskId:n.taskId,initialRequestText:n.initialRequestText,status:G,currentStatusText:p,startTime:N,endTime:T,durationMs:X,steps:f};ee.steps.forEach((k,$)=>{if(k.type==="TASK_COMPLETED"){let C="";for(let _=$-1;_>=0;_--){const L=ee.steps[_];if(L.type!=="AGENT_RESPONSE_TEXT"||L.source!==k.source)break;C=L.data.text+C}k.data.finalMessage&&(C+=k.data.finalMessage),k.data.finalMessage=C.trim()||void 0}}),Object.values(r.agents).forEach(k=>{k.totalLlmTimeMs=k.llmCalls.reduce((R,J)=>R+J.durationMs,0);const $=k.toolCalls.filter(R=>!R.parallelBlockId),C=new Map;k.toolCalls.forEach(R=>{R.parallelBlockId&&(C.has(R.parallelBlockId)||C.set(R.parallelBlockId,[]),C.get(R.parallelBlockId).push(R))});const _=$.reduce((R,J)=>R+J.durationMs,0);let L=0;C.forEach(R=>{if(R.length>0){const J=Math.min(...R.map(B=>new Date(B.timestamp).getTime())),P=Math.max(...R.map(B=>new Date(B.timestamp).getTime()+B.durationMs));L+=P-J}}),k.totalToolTimeMs=_+L});const O=new Map;Object.values(r.agents).forEach(k=>{O.has(k.agentName)||O.set(k.agentName,[]),O.get(k.agentName).push(k)}),O.forEach(k=>{k.length>1&&(k.sort(($,C)=>{const _=L=>{const R=[...L.llmCalls.map(J=>new Date(J.timestamp).getTime()),...L.toolCalls.map(J=>new Date(J.timestamp).getTime())];return R.length>0?Math.min(...R):1/0};return _($)-_(C)}),k.forEach(($,C)=>{$.displayName=`${$.agentName} (${C+1})`}))});const Y=new Map;return Object.values(r.agents).forEach(k=>{const $=k.instanceId.split(":").slice(1).join(":");$&&Y.set($,k.displayName)}),Object.values(r.agents).forEach(k=>{k.toolCalls.forEach($=>{if($.isPeer&&$.subTaskId){const C=Y.get($.subTaskId);C&&($.peerAgentName=C)}})}),X!==void 0&&(r.overall.totalTaskDurationMs=X),ee.performanceReport=r,ee},kE=({items:e,bottomItems:t,activeItem:n,onItemChange:r,onHeaderClick:o})=>{const s=i=>{r(i)};return a.jsxs("aside",{className:"flex h-screen w-[100px] flex-col border-r border-[var(--color-secondary-w70)] bg-[var(--color-primary-w100)]",children:[a.jsx(IE,{onClick:o}),a.jsx(RE,{items:e,bottomItems:t,activeItem:n,onItemClick:s})]})},_E=a.jsxs("svg",{id:"header-icon",xmlns:"http://www.w3.org/2000/svg",version:"1.1",viewBox:"0 0 500 150",width:"100%",height:"100%",children:[a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M14.3,82.5c0-4.4,1-8.2,2.9-11.3,1.9-3.1,4.4-5.7,7.5-7.8,3.1-2,6.5-3.6,10.4-4.6,3.8-1,7.7-1.5,11.5-1.5s7.1.3,10.2.9c3.1.6,5.9,1.5,8.2,2.6,2.4,1.1,4.2,2.4,5.6,3.8,1.4,1.4,2,3,2,4.6,0,2.4,0,4.3-.2,5.7-.1,1.4-.3,2.4-.6,3.1-.3.7-.7,1.1-1.1,1.3-.4.2-.9.2-1.6.2-1.8,0-3.2-.7-4.3-2-1.1-1.3-2.3-2.8-3.7-4.4-1.4-1.6-3.1-3.1-5.3-4.4-2.1-1.3-5.3-2-9.3-2s-4.4.3-6,.9c-1.6.6-2.9,1.5-3.8,2.5-.9,1-1.6,2.2-2,3.4-.4,1.2-.6,2.4-.6,3.5,0,2.5,1,4.4,3.1,5.7,2.1,1.3,4.7,2.3,7.8,3.2,3.1.9,6.5,1.7,10.1,2.5,3.6.8,7,1.9,10.1,3.4,3.1,1.5,5.8,3.5,7.9,6.1,2.1,2.6,3.1,6.1,3.1,10.5s-.8,8-2.5,11.3c-1.7,3.4-4,6.2-7,8.5-3,2.3-6.6,4.1-10.8,5.3-4.2,1.3-8.9,1.9-13.9,1.9s-8.8-.6-12.5-1.9c-3.7-1.3-6.9-2.8-9.6-4.6-2.7-1.8-4.7-3.7-6.2-5.6-1.5-1.9-2.2-3.5-2.2-4.7,0-1.8.5-3.6,1.6-5.3,1-1.8,2.6-2.7,4.7-2.7s2.5.4,3.5,1.2c.9.8,1.8,1.7,2.7,2.8.8,1.1,1.7,2.3,2.6,3.7.9,1.4,2,2.6,3.3,3.7,1.3,1.1,2.9,2,4.7,2.8,1.8.8,4.1,1.2,6.8,1.2,4.1,0,7.5-1,10.3-3.1,2.8-2.1,4.2-4.8,4.2-8s-1-4.9-3.1-6.4c-2-1.4-4.6-2.6-7.7-3.5-3.1-.9-6.4-1.7-10-2.4-3.6-.7-7-1.8-10-3.2-3.1-1.4-5.7-3.4-7.7-6-2-2.6-3.1-6.3-3.1-11"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M124.6,66.8c-4,0-7.3.9-9.9,2.7-2.6,1.8-4.7,4.2-6.4,7.1-1.6,2.9-2.8,6.1-3.5,9.7-.7,3.5-1,6.9-1,10.1,0,4.9.5,9.2,1.6,13,1,3.7,2.5,6.8,4.4,9.3,1.9,2.5,4.1,4.3,6.7,5.6,2.6,1.3,5.3,1.9,8.2,1.9s5.7-.6,8.2-1.9c2.6-1.3,4.8-3.1,6.7-5.6,1.9-2.5,3.3-5.5,4.4-9.3,1-3.7,1.6-8,1.6-13,0-9.5-1.9-16.9-5.8-22-3.9-5.1-8.9-7.7-15.2-7.7M82.2,96.5c0-5.8,1.1-11,3.3-15.9,2.2-4.8,5.2-8.9,9.1-12.4,3.9-3.5,8.4-6.1,13.6-8,5.2-1.9,10.7-2.8,16.6-2.8s11.4.9,16.6,2.8c5.2,1.9,9.7,4.6,13.5,8,3.8,3.5,6.9,7.6,9.1,12.4,2.2,4.8,3.4,10.1,3.4,15.9s-1.1,11.2-3.4,15.9c-2.3,4.8-5.3,8.9-9.1,12.3-3.8,3.5-8.3,6.1-13.5,8-5.2,1.9-10.7,2.8-16.6,2.8s-11.4-.9-16.6-2.8c-5.2-1.9-9.7-4.6-13.6-8-3.9-3.5-6.9-7.6-9.1-12.3-2.2-4.8-3.3-10.1-3.3-15.9"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M172.3,23.3c0-.8.9-1.8,2.7-2.8,1.8-1,4-2,6.5-2.9,2.5-.9,5.1-1.6,7.7-2.3,2.6-.6,4.7-.9,6.3-.9s1.3,0,1.9.2c.6.2,1.2.5,1.8,1.2.6.6,1,1.6,1.4,2.9.4,1.3.5,3.1.5,5.4v94.7c0,2.4.4,4.1,1.2,4.9.8.9,1.6,1.5,2.5,2,.9.4,1.7.8,2.5,1.3.8.4,1.2,1.4,1.2,2.8s-.5,2.5-1.6,3.2c-1,.7-2.4,1-3.9,1h-24.2c-1.6,0-2.9-.3-3.9-1-1-.7-1.6-1.8-1.6-3.2s.4-2.3,1.2-2.7c.8-.5,1.6-.9,2.5-1.3.9-.4,1.7-1.1,2.5-2,.8-.9,1.2-2.5,1.2-4.9V34.5c0-2-.4-3.4-1.3-4.2-.9-.8-1.9-1.4-2.9-1.9-1-.5-2-1-2.9-1.6-.9-.6-1.3-1.8-1.3-3.5"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M254.4,93.3c-3.7,1.2-6.8,2.8-9.4,4.7-2.6,1.9-4.6,4.1-6,6.6-1.4,2.5-2.1,5-2.1,7.6s.3,3.6,1,5.3c.7,1.8,1.6,3.4,2.9,4.7,1.3,1.4,2.7,2.5,4.5,3.3,1.7.8,3.6,1.3,5.7,1.3s5.2-.7,7.2-2c2-1.3,3.6-2.9,4.9-4.7,1.3-1.8,2.2-3.7,2.7-5.7.6-1.9.9-3.6.9-4.9v-18.2c-4.5.1-8.6.8-12.2,2M220.5,69.7c0-1.9.9-3.6,2.6-5.1,1.7-1.5,4-2.8,6.8-3.8,2.8-1,6-1.9,9.5-2.4,3.5-.6,7-.9,10.4-.9,7,0,12.9.8,17.6,2.3,4.7,1.5,8.5,3.6,11.5,6.1,2.9,2.6,5,5.5,6.3,8.7,1.3,3.2,1.9,6.6,1.9,10v34.5c0,1.9.4,3.2,1.3,4.1.8.8,1.7,1.5,2.7,2,.9.5,1.8,1,2.7,1.5.8.5,1.3,1.4,1.3,2.7s-.4,2.5-1.2,3.4c-.8.9-2.7,1.3-5.7,1.3h-13.2c-2.4,0-4.1-.5-5.1-1.6-1-1-1.5-2.8-1.5-5.2v-1.7h-.6c-2.4,3.5-5.9,6-10.4,7.6-4.6,1.6-9.3,2.4-14.4,2.4s-8.5-.6-11.9-1.9c-3.4-1.3-6.3-3-8.6-5.1-2.4-2.1-4.1-4.6-5.3-7.5-1.2-2.8-1.8-5.8-1.8-8.8,0-5.2,1.6-9.7,4.8-13.5,3.2-3.8,7.3-6.8,12.2-9.2,5-2.4,10.5-4.1,16.6-5.2,6.1-1.1,12-1.6,17.9-1.6,0-4.7-1.3-8.6-4-11.5-2.7-3-6.6-4.5-11.7-4.5s-5.7.5-7.5,1.4c-1.9.9-3.6,2-5.1,3.1-1.5,1.2-3.1,2.2-4.7,3.1-1.6.9-3.7,1.4-6.2,1.4s-3.8-.5-5-1.6c-1.3-1.1-1.9-2.6-1.9-4.6"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M301.5,97.6c0-5.9,1-11.3,3.1-16.2,2.1-4.9,4.9-9.2,8.6-12.7,3.6-3.6,7.9-6.3,12.9-8.3,5-2,10.4-3,16.2-3s7.2.4,10.8,1.3c3.5.9,6.6,2.1,9.3,3.5,2.7,1.5,4.9,3.2,6.5,5.2,1.6,2,2.4,4.1,2.4,6.3s-.9,4.1-2.7,5.5c-1.8,1.4-4.2,2-7.2,2s-4.1-.8-5.3-2.4c-1.2-1.6-2.4-3.4-3.5-5.3-1.1-1.9-2.4-3.6-4-5.3-1.6-1.6-3.9-2.4-7.1-2.4s-5.2.8-7.5,2.3c-2.3,1.5-4.2,3.7-5.9,6.5-1.7,2.8-3,6.2-3.8,10-.9,3.9-1.3,8.2-1.3,12.9s.6,7.9,1.8,11.2c1.2,3.3,2.8,6.1,4.8,8.4,2,2.3,4.3,4.1,6.9,5.3,2.6,1.2,5.4,1.8,8.3,1.8s6.9-.6,9.4-1.9c2.5-1.3,4.7-2.6,6.4-4.2,1.8-1.5,3.3-2.9,4.6-4.2,1.3-1.3,2.6-1.9,4-1.9s2,.3,2.7,1c.8.7,1.2,1.6,1.2,2.7,0,1.7-.8,3.6-2.5,5.9-1.7,2.3-4,4.4-6.9,6.4-2.9,2-6.4,3.8-10.4,5.2-4,1.4-8.4,2.1-13.1,2.1s-10.7-.9-15.5-2.7c-4.8-1.8-8.9-4.4-12.3-7.8-3.5-3.3-6.2-7.4-8.2-12-2-4.7-3-9.8-3-15.5"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M423.2,65.9c-3.4,0-6.3.7-8.9,2.2-2.6,1.5-4.9,3.5-6.8,6.1-1.9,2.6-3.3,5.8-4.3,9.4-1,3.7-1.5,7.7-1.5,12.1v.9c3.5-.3,7.1-.9,11-1.7,3.9-.8,7.4-2,10.7-3.5,3.2-1.5,5.9-3.4,8.1-5.7,2.1-2.4,3.2-5.3,3.2-8.7s-.9-5.9-2.7-8c-1.8-2.1-4.7-3.1-8.7-3.1M380,98.4c0-5.7.9-11,2.7-15.9,1.8-5,4.5-9.3,8.2-13,3.7-3.7,8.3-6.6,13.9-8.8,5.6-2.1,12.2-3.2,19.9-3.2s6.8.4,10.4,1.2c3.6.8,6.8,2,9.8,3.8,3,1.7,5.4,4,7.4,6.8,1.9,2.8,2.9,6.1,2.9,10s-1.6,9-4.9,12.2c-3.3,3.2-7.5,5.8-12.6,7.7-5.1,1.9-10.8,3.4-16.9,4.3-6.1.9-12,1.6-17.7,1.9.5,3.1,1.5,5.9,2.9,8.3,1.4,2.4,3.1,4.4,5.2,6,2,1.6,4.2,2.8,6.6,3.6,2.4.8,4.7,1.2,7.1,1.2s5-.3,7.2-.9c2.2-.6,4.2-1.3,6-2.3,1.8-.9,3.5-2,4.9-3.1,1.5-1.1,2.8-2.2,3.9-3.2,1-1,2-1.9,2.8-2.4.8-.6,1.8-.9,3-.9,2.4,0,3.6,1.2,3.6,3.6s-1,4-3,6.4c-2,2.4-4.7,4.6-8,6.7-3.4,2-7.2,3.8-11.5,5.2-4.3,1.4-8.9,2.1-13.7,2.1s-10.9-.9-15.8-2.8c-4.9-1.9-9.1-4.5-12.7-7.8-3.6-3.3-6.4-7.2-8.5-11.8-2-4.6-3.1-9.5-3.1-14.8"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M464.7,123.7c0-6.5,5.3-11.8,11.8-11.8s11.8,5.3,11.8,11.8-5.3,11.8-11.8,11.8-11.8-5.3-11.8-11.8"})]}),IE=({onClick:e})=>a.jsx("div",{className:"flex h-[80px] min-h-[80px] cursor-pointer items-center justify-center border-b",onClick:e,children:a.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-full",children:_E})}),jE=()=>{const{currentTheme:e,toggleTheme:t}=td(),n=`Toggle theme (currently ${e})`;return a.jsxs(Oi,{children:[a.jsx(Fi,{asChild:!0,children:a.jsx("button",{type:"button",onClick:t,className:"relative mx-auto flex w-full cursor-pointer flex-col items-center bg-[var(--color-primary-w100)] px-3 py-5 text-xs text-[var(--color-primary-text-w10)] transition-colors hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":n,title:n,children:a.jsx(tc,{className:"mb-1 h-6 w-6"})})}),a.jsx(zi,{side:"right",children:n})]})},RE=({items:e,bottomItems:t,activeItem:n,onItemClick:r})=>a.jsxs("nav",{className:"flex flex-1 flex-col",role:"navigation","aria-label":"Main navigation",children:[a.jsx("ul",{className:"space-y-1",children:e.map(o=>a.jsxs("li",{children:[a.jsx(Dl,{item:o,isActive:n===o.id,onItemClick:r}),o.showDividerAfter&&a.jsx("div",{className:"mx-4 my-3 border-t border-[var(--color-secondary-w70)]"})]},o.id))}),t&&t.length>0&&a.jsx("div",{className:"flex-1"}),t&&t.length>0&&a.jsx("ul",{className:"space-y-1",children:t.map(o=>a.jsx("li",{className:"my-4",children:o.id==="theme-toggle"?a.jsx(jE,{}):a.jsx(Dl,{item:o,isActive:n===o.id,onItemClick:r},o.id)},o.id))})]}),Dl=({item:e,isActive:t,onItemClick:n})=>{const{id:r,label:o,icon:s,disabled:i}=e,l=()=>{!i&&n&&n(r)},c=d=>{(d.key==="Enter"||d.key===" ")&&l()};return a.jsxs(Oi,{children:[a.jsx(Fi,{asChild:!0,children:a.jsxs("button",{type:"button",onClick:n?l:void 0,onKeyDown:n?c:void 0,disabled:i,className:be("relative mx-auto flex w-full cursor-pointer flex-col items-center border-l-4 border-[var(--color-primary-w100)] px-3 py-5 text-xs transition-colors","bg-[var(--color-primary-w100)] hover:bg-[var(--color-primary-w90)]","text-[var(--color-primary-text-w10)] hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)]","disabled:cursor-not-allowed disabled:opacity-50",t?"border-l-4 border-[var(--color-brand-wMain)] bg-[var(--color-primary-w90)]":""),"aria-label":o,"aria-current":t?"page":void 0,children:[a.jsx(s,{className:be("mb-1 h-6 w-6",t&&"text-[var(--color-brand-wMain)]")}),a.jsx("span",{className:"text-center text-[13px] leading-tight",children:o})]})}),a.jsx(zi,{side:"right",children:o})]})},Ol=[{id:"chat",label:"Chat",icon:Kl},{id:"agentMesh",label:"Agents",icon:nc}],Fl=[{id:"theme-toggle",label:"Theme",icon:tc,onClick:()=>{}}],kp=({title:e,breadcrumbs:t,tabs:n,buttons:r,leadingAction:o})=>a.jsxs("div",{className:"relative flex max-h-[80px] min-h-[80px] w-full items-center border-b px-8",children:[t&&t.length>0&&a.jsx("div",{className:"absolute top-1 left-8 flex h-8 items-center",children:t.map((s,i)=>a.jsxs(Ht.Fragment,{children:[i>0&&a.jsx("span",{className:"mx-1",children:a.jsx(pm,{size:16})}),s.onClick?a.jsx(xe,{variant:"link",className:"m-0 p-0",onClick:s.onClick,children:s.label}):a.jsx("div",{children:s.label})]},i))}),o&&a.jsx("div",{className:"mr-4 flex items-center pt-[35px]",children:o}),a.jsx("div",{className:"truncate pt-[35px] text-xl text-nowrap",children:e}),n&&n.length>0&&a.jsx("div",{className:"ml-8 flex items-center pt-[35px]",role:"tablist",children:n.map((s,i)=>a.jsxs("button",{role:"tab","aria-selected":s.isActive,onClick:s.onClick,className:`relative cursor-pointer px-4 py-3 font-medium transition-colors duration-200 ${s.isActive?"border-b-2 border-[var(--color-brand-wMain)] font-semibold":""} ${i>0?"ml-6":""}`,children:[s.label,s.isActive&&a.jsx("div",{className:"absolute right-0 bottom-0 left-0 h-0.5"})]},s.id))}),a.jsx("div",{className:"flex-1"}),r&&r.length>0&&a.jsx("div",{className:"flex items-center gap-2 pt-[35px]",children:r.map((s,i)=>a.jsx(Ht.Fragment,{children:s},i))})]}),lt=({label:e,value:t,icon:n,fullWidthValue:r=!1})=>t==null||typeof t=="string"&&!t.trim()?null:a.jsxs("div",{className:`mb-1.5 flex text-sm ${r?"flex-col items-start":"items-center"}`,children:[a.jsxs("div",{className:"flex w-36 flex-shrink-0 items-center text-sm font-semibold text-nowrap",children:[n&&a.jsx("span",{className:"mr-2",children:n}),e,":"]}),a.jsx("div",{className:`text-accent-foreground text-sm ${r?"mt-1 w-full":"truncate"}`,title:typeof t=="string"?t:void 0,children:t})]}),ME=({agent:e,isExpanded:t,onToggleExpand:n})=>{const r=l=>!l||Object.keys(l).length===0?a.jsx("span",{className:"text-sm",children:"N/A"}):a.jsx("ul",{className:"list-inside list-disc pl-1",children:Object.entries(l).map(([c,d])=>a.jsxs("li",{className:"text-sm",children:[a.jsxs("span",{className:"capitalize",children:[c.replace(/_/g," "),":"]})," ",d?"Yes":"No"]},c))}),o=(l,c="None")=>!l||l.length===0?a.jsx("span",{children:c}):l.map(d=>a.jsx("span",{className:"mr-1 mb-1 inline-block rounded-full px-2 py-0.5 text-xs font-medium",children:d},d)),s=l=>!l||l.length===0?a.jsx("span",{children:"No skills listed"}):a.jsx("div",{className:"space-y-1",children:l.map(c=>a.jsxs("div",{className:"rounded p-1.5 text-xs",children:[a.jsx("p",{className:"font-semibold",children:c.name}),a.jsx("p",{children:c.description})]},c.id||c.name))}),i=l=>!l||l.length===0?a.jsx("span",{children:"No tools listed"}):a.jsx("div",{className:"space-y-1",children:l.map(c=>a.jsxs("div",{className:"rounded p-1.5 text-xs",children:[a.jsx("p",{className:"text-foreground font-semibold",children:c.name}),a.jsx("p",{className:"mb-1",children:c.description})]},c.name))});return a.jsx("div",{className:"bg-card h-[400px] w-full flex-shrink-0 cursor-pointer rounded-lg sm:w-[380px]",onClick:n,role:"button",tabIndex:0,"aria-expanded":t,children:a.jsxs("div",{className:`transform-style-preserve-3d relative h-full w-full transition-transform duration-700 ${t?"rotate-y-180":""}`,style:{transformStyle:"preserve-3d"},children:[a.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(0deg)"},children:[a.jsx("div",{className:"flex items-center p-4",children:a.jsxs("div",{className:"flex min-w-0 items-center",children:[a.jsx(nc,{className:"mr-3 h-8 w-8 flex-shrink-0 text-[var(--color-brand-wMain)]"}),a.jsx("div",{className:"min-w-0",children:a.jsx("h2",{className:"truncate text-xl font-semibold",title:e.name,children:e.displayName||e.name})})]})}),a.jsxs("div",{className:"scrollbar-themed flex-grow space-y-3 overflow-y-auto p-4",children:[a.jsx("div",{className:"mb-2 line-clamp-4 text-base",children:e.description||"No description provided."}),a.jsx(lt,{label:"Version",value:e.version,icon:a.jsx(xa,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&a.jsx(lt,{label:"Key Capabilities",value:r(e.capabilities),icon:a.jsx(va,{size:14}),fullWidthValue:!0})]}),a.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for details"})]}),a.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[a.jsx("div",{className:"flex items-center p-3",children:a.jsxs("h3",{className:"text-md truncate font-semibold",title:e.name,children:["Details: ",e.displayName||e.name]})}),a.jsxs("div",{className:"scrollbar-themed flex-grow space-y-1.5 overflow-y-auto p-3 text-xs",children:[a.jsx(lt,{label:"Name",value:e.name,icon:a.jsx(yi,{size:14})}),a.jsx(lt,{label:"Description",value:e.description,icon:a.jsx(mm,{size:14}),fullWidthValue:!0}),a.jsx(lt,{label:"Version",value:e.version,icon:a.jsx(xa,{size:14})}),a.jsx(lt,{label:"Endpoint",value:e.url||"N/A",icon:a.jsx(ec,{size:14})}),a.jsx(lt,{label:"Docs",value:e.documentationUrl?a.jsx("a",{href:e.documentationUrl,target:"_blank",rel:"noopener noreferrer",className:"break-all",children:"View Docs"}):"N/A",icon:a.jsx(Gl,{size:14})}),e.provider&&a.jsxs("div",{className:"mt-1.5 border-t pt-1.5",children:[a.jsx("h4",{className:"mb-0.5 text-xs font-semibold",children:"Provider"}),a.jsx(lt,{label:"Name",value:e.provider.organization}),a.jsx(lt,{label:"URL",value:e.provider.url||"N/A"})]}),a.jsx(lt,{label:"Capabilities",value:r(e.capabilities),icon:a.jsx(va,{size:14}),fullWidthValue:!0}),a.jsx(lt,{label:"Input Modes",value:o(e.defaultInputModes),icon:a.jsx(wa,{size:14}),fullWidthValue:!0}),a.jsx(lt,{label:"Output Modes",value:o(e.defaultOutputModes),icon:a.jsx(wa,{size:14}),fullWidthValue:!0}),a.jsx(lt,{label:"Skills",value:s(e.skills),icon:a.jsx(hm,{size:14}),fullWidthValue:!0}),a.jsx(lt,{label:"Tools Info",value:i(e.tools),icon:a.jsx(Yl,{size:14}),fullWidthValue:!0}),a.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:a.jsx(lt,{label:"A2A Protocol",value:e.protocolVersion})})]}),a.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for summary"})]})]})})},pi=({agents:e})=>{const[t,n]=u.useState(null),[r,o]=u.useState(""),s=l=>{n(c=>c===l?null:l)},i=e.filter(l=>{var c;return(c=l.displayName||l.name)==null?void 0:c.toLowerCase().includes(r.toLowerCase())});return a.jsx("div",{children:e.length===0?a.jsx("div",{className:"flex h-[calc(100vh-250px)] items-center justify-center",children:"No agents discovered in the current namespace."}):a.jsxs("div",{className:"mx-auto mt-[50px] ml-[50px]",children:[a.jsx("div",{className:"my-4",children:a.jsx("input",{type:"text","data-testid":"agent-search-input",placeholder:"Search...",value:r,onChange:l=>o(l.target.value),className:"bg-background rounded-md border px-3 py-2"})}),i.length===0&&r?a.jsxs("div",{className:"flex h-[calc(100vh-250px)] flex-col items-center justify-center gap-6",children:["No agents match your search.",a.jsx(xe,{variant:"outline",title:"Clear Search",onClick:()=>o(""),children:"Clear Search"})]}):a.jsx("div",{className:"max-h-[calc(100vh-250px)] overflow-y-auto",children:a.jsx("div",{className:"flex flex-wrap gap-10",children:i.map(l=>a.jsx(ME,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>s(l.name)},l.name))})})]})})},_p={LAYOUT:"layout"};class PE{constructor(){fa(this,"_plugins",{});this.registerDefaultPlugins()}get plugins(){return Object.values(this._plugins)}registerPlugin(t){this._plugins[t.id]&&console.warn(`Plugin with ID ${t.id} already exists. Overwriting.`),this._plugins[t.id]=t}getPluginById(t){return this._plugins[t]}getPluginsByType(t){return Object.values(this._plugins).filter(n=>n.type===t)}registerDefaultPlugins(){this.registerPlugin({type:_p.LAYOUT,id:"cards",label:"Cards",icon:gm,priority:100,render:t=>a.jsx(pi,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}const Ip=new PE,LE=({currentLayout:e,onLayoutChange:t,className:n=""})=>{const r=Ip.getPluginsByType(_p.LAYOUT);return r&&r.length>1?a.jsxs("div",{className:`flex items-center space-x-1 ${n}`,children:[a.jsx("span",{className:"text-sm font-semibold",children:"Layout:"}),a.jsx("div",{className:"flex gap-1 rounded-sm p-1",children:r.map(o=>{const s=o.icon,i=e===o.id;return a.jsxs(xe,{variant:"ghost",size:"sm",onClick:()=>t(o.id),title:o.label,className:i?"bg-[var(--color-secondary-w20)] dark:bg-[var(--color-secondary-w80)]":"",children:[s&&a.jsx(s,{size:14}),a.jsx("span",{children:o.label})]},o.id)})})]}):null},zl={CARDS:"cards"};function DE(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=He(),[o,s]=u.useState("cards");if(t)return a.jsx("div",{className:"space-y-6",children:a.jsx("div",{className:"flex h-96 items-center justify-center",children:a.jsx("div",{children:"Loading agents..."})})});if(n)return a.jsx("div",{className:"space-y-6",children:a.jsx("div",{className:"flex h-96 items-center justify-center",children:a.jsx(ia,{variant:"error",message:`Error loading agents. ${n}`})})});const i=()=>{if(o===zl.CARDS)return a.jsx(pi,{agents:e});const l=Ip.getPluginById(o);return l?l.render({agents:e}):(console.warn(`Layout ${o} not found, falling back to cards layout`),a.jsx(pi,{agents:e}))};return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(kp,{title:"Agents",buttons:[a.jsxs(xe,{variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[a.jsx(Zl,{className:"size-4"}),"Refresh Agents"]})]}),a.jsxs("div",{className:`relative flex-1 p-4 ${o===zl.CARDS?"":"bg-[var(--muted)] dark:bg-[var(--color-bg-wMain)]"}`,children:[a.jsx("div",{className:"absolute right-8 z-20 flex items-center space-x-4",children:a.jsx(LE,{currentLayout:o,onLayoutChange:s})}),i()]})]})}const OE=({isOpen:e,onClose:t,onConfirm:n,sessionName:r})=>e?a.jsx(Yo,{open:e,onOpenChange:t,children:a.jsxs(Ko,{children:[a.jsxs(qo,{children:[a.jsx(Xo,{children:"Delete Chat Session?"}),a.jsxs(Zo,{children:["This action cannot be undone. This chat session and any associated artifacts will be permanently deleted: ",a.jsx("strong",{children:r})]})]}),a.jsxs(Mv,{children:[a.jsx(xe,{variant:"outline",onClick:t,title:"Cancel",children:"Cancel"}),a.jsx(xe,{onClick:n,title:"Delete",children:"Delete"})]})]})}):null,fo=4,mi={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},FE={chatPanelSizes:{...mi.chatPanelSizes,min:50},sidePanelSizes:{...mi.sidePanelSizes,max:50}};function zE(){var B;const{agents:e,sessionId:t,messages:n,setMessages:r,selectedAgentName:o,setSelectedAgentName:s,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,openSidePanelTab:c,setTaskIdInSidePanel:d,isResponding:f,latestStatusText:p,sessionToDelete:m,closeSessionDeleteModal:g,confirmSessionDelete:x,sessionName:h}=He(),{isTaskMonitorConnected:v,isTaskMonitorConnecting:b,taskMonitorSseError:w,connectTaskMonitorStream:y}=Ki(),[E,A]=u.useState(!0),[j,N]=u.useState(!1),[T,G]=u.useState(!1),q=u.useRef(null),W=u.useRef(null),X=u.useRef(null),{chatPanelSizes:ee,sidePanelSizes:O}=u.useMemo(()=>E?mi:FE,[E]),Y=u.useCallback(D=>{if(N(!0),W.current)if(D)W.current.resize(fo);else{const U=X.current||O.default;W.current.resize(U)}setTimeout(()=>N(!1),300)},[O.default]),k=u.useCallback(()=>{l(!0)},[l]),$=u.useCallback(()=>{l(!1)},[l]),C=u.useCallback(D=>{D>fo+1&&(X.current=D)},[]),_=u.useCallback(()=>{A(!E)},[E]);u.useEffect(()=>{W.current&&i&&W.current.resize(fo);const D=()=>{if(W.current&&i){N(!0);const U=X.current||O.default;W.current.resize(U),l(!1),setTimeout(()=>N(!1),300)}};return window.addEventListener("expand-side-panel",D),()=>{window.removeEventListener("expand-side-panel",D)}},[i,l,O.default]),u.useEffect(()=>{if(!o&&e.length>0){const D=e.find(Q=>Q.name==="OrchestratorAgent"),U=D?D.name:e[0].name;s(U);const I=e.find(Q=>Q.name===U),V=I!=null&&I.displayName?`Hi! I'm the ${I==null?void 0:I.displayName} Agent. How can I help?`:`Hi! I'm ${U}. How can I help?`;r(Q=>[...Q.filter(ae=>!ae.isStatusBubble),{role:"agent",kind:"message",messageId:`welcome-${Date.now()}`,parts:[{kind:"text",text:V}],isUser:!1,isComplete:!0,metadata:{sessionId:t,lastProcessedEventSequence:0}}])}},[e,o,t,r,s]);const L=u.useMemo(()=>{const D=new Map;return n.forEach((U,I)=>{U.taskId&&D.set(U.taskId,I)}),D},[n]),R=u.useMemo(()=>n.find(D=>D.isStatusBubble),[n]),J=u.useMemo(()=>{if(!R||!R.parts)return null;const D=R.parts.find(U=>U.kind==="text");return(D==null?void 0:D.text)||null},[R]),P=u.useMemo(()=>{if(R!=null&&R.taskId)return()=>{d(R.taskId),c("workflow")}},[R==null?void 0:R.taskId,d,c]);return u.useEffect(()=>{const D=()=>{!v&&!b&&w&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),y())};return window.addEventListener("focus",D),()=>{window.removeEventListener("focus",D)}},[v,b,w,y]),a.jsxs("div",{className:"relative flex h-screen w-full flex-col overflow-hidden",children:[a.jsx("div",{className:`absolute top-0 left-0 z-20 h-screen transition-transform duration-300 ${E?"-translate-x-full":"translate-x-0"}`,children:a.jsx(YC,{onToggle:_})}),a.jsx("div",{className:`transition-all duration-300 ${E?"ml-0":"ml-100"}`,children:a.jsx(kp,{title:h||"New Chat",leadingAction:E?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xe,{variant:"ghost",onClick:_,className:"h-10 w-10 p-0",tooltip:"Show Sessions Panel",children:a.jsx(Jl,{className:"size-5"})}),a.jsx("div",{className:"h-6 w-px bg-gray-300 dark:bg-gray-600"}),a.jsx(xe,{variant:"ghost",onClick:()=>G(!0),className:"h-10 w-10 p-0",tooltip:"Start New Chat Session",children:a.jsx(Ql,{className:"size-5"})})]}):null})}),a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsx("div",{className:`min-h-0 flex-1 overflow-x-auto transition-all duration-300 ${E?"ml-0":"ml-100"}`,children:a.jsxs(lw,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[a.jsx(il,{defaultSize:ee.default,minSize:ee.min,maxSize:ee.max,id:"chat-panel",children:a.jsxs("div",{className:"flex h-full w-full flex-col py-6",children:[a.jsx(mf,{className:"text-base",ref:q,children:n.map((D,U)=>{var V;const I=!!(D.taskId&&L.get(D.taskId)===U);return a.jsx(IC,{message:D,isLastWithTaskId:I},`${((V=D.metadata)==null?void 0:V.sessionId)||"session"}-${U}-${D.isUser?"received":"sent"}`)})}),a.jsxs("div",{style:pf,children:[f&&a.jsx(ui,{statusText:(J||p.current)??void 0,onViewWorkflow:P}),a.jsx(ub,{agents:e,scrollToBottom:(B=q.current)==null?void 0:B.scrollToBottom})]})]})}),a.jsx(cw,{}),a.jsx(il,{ref:W,defaultSize:O.default,minSize:O.min,maxSize:O.max,collapsedSize:fo,collapsible:!0,onCollapse:k,onExpand:$,onResize:C,id:"chat-side-panel",className:j?"transition-all duration-300 ease-in-out":"",children:a.jsx("div",{className:"h-full",children:a.jsx(VC,{onCollapsedToggle:Y,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,isSidePanelTransitioning:j})})})]})})}),a.jsx(wp,{isOpen:T,onClose:()=>G(!1)}),a.jsx(OE,{isOpen:!!m,onClose:g,onConfirm:x,sessionName:(m==null?void 0:m.name)||`Session ${m==null?void 0:m.id.substring(0,8)}`})]})}const $E=e=>({displayName:e?"Solace Dark JER":"Solace Light JER",styles:{container:{backgroundColor:"transparent",fontFamily:"monospace",fontSize:"14px"},property:e?"var(--color-primary-text-w10)":"var(--color-primary-text-wMain)",bracket:"var(--color-secondary-text-w50)",itemCount:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},string:e?"var(--color-success-w70)":"var(--color-success-wMain)",number:"var(--color-accent-n0-wMain)",boolean:e?"var(--color-warning-w70)":"var(--color-warning-wMain)",null:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},iconCollection:"var(--color-secondary-text-w50)",iconCopy:"var(--color-secondary-text-w50)"}}),hi=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=td(),o=u.useMemo(()=>$E(r==="dark"),[r]),s=u.useMemo(()=>t===void 0||t<0?!1:t,[t]),i=u.useMemo(()=>e===null||typeof e!="object"?{value:e}:e,[e]),l=`rounded-lg border overflow-auto ${n}`.trim();return e===void 0?a.jsx("div",{className:l,children:a.jsx("span",{className:"italic",children:"No JSON data"})}):a.jsx("div",{className:l,children:a.jsx(xm,{data:i,theme:o,viewOnly:!0,collapse:s,showStringQuotes:!0,showCollectionCount:"when-closed"})})};let po=null,mo=null;function BE({children:e}){const{fetchCsrfToken:t}=Qu(),[n,r]=u.useState(po),[o,s]=u.useState(!po&&!mo),[i,l]=u.useState(mo);return u.useEffect(()=>{if(po||mo)return;let c=!0;return(async()=>{s(!0),l(null);try{let f=await Fe("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"}}),p;if(f.ok)p=await f.json();else{const x=await f.text();if(console.error("Initial config fetch failed:",f.status,x),f.status===403){console.log("Config fetch failed with 403, attempting to get CSRF token first...");const h=await t();if(!h)throw new Error("Failed to obtain CSRF token after config fetch failed.");if(console.log("Retrying config fetch with CSRF token..."),f=await Fe("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":h,Accept:"application/json"}}),!f.ok){const v=await f.text();throw console.error("Config fetch retry failed:",f.status,v),new Error(`Failed to fetch config on retry: ${f.status} ${v}`)}p=await f.json()}else throw new Error(`Failed to fetch config: ${f.status} ${x}`)}const m=p.frontend_use_authorization??!1;m&&(console.log("Fetching CSRF token for config-related requests..."),await t());const g={configServerUrl:p.frontend_server_url,configAuthLoginUrl:p.frontend_auth_login_url,configUseAuthorization:m,configWelcomeMessage:p.frontend_welcome_message,configRedirectUrl:p.frontend_redirect_url,configCollectFeedback:p.frontend_collect_feedback,configBotName:p.frontend_bot_name,configFeatureEnablement:p.frontend_feature_enablement??{},frontend_use_authorization:p.frontend_use_authorization,persistenceEnabled:p.persistence_enabled??!0};c&&(po=g,r(g)),console.log("App config processed and set:",g)}catch(f){if(console.error("Error initializing app:",f),c){const p=f.message||"Failed to load application configuration.";mo=p,l(p)}}finally{c&&s(!1)}})(),()=>{c=!1}},[t]),n?a.jsx(Ku.Provider,{value:n,children:e}):o?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Loading Configuration..."})]})}):i?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-red-100 dark:bg-red-900",children:a.jsxs("div",{className:"rounded border border-red-400 bg-white p-4 text-center dark:bg-gray-800",children:[a.jsx("h1",{className:"text-xl font-bold text-red-700 dark:text-red-300",children:"Configuration Error"}),a.jsx("p",{className:"mt-2 text-red-600 dark:text-red-200",children:i}),a.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:"Please check the backend server and network connection, then refresh the page."})]})}):a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl",children:"Initializing Application..."})]})})}const UE=({children:e})=>{const{configServerUrl:t}=sn(),n=`${t}/api/v1`,[r,o]=u.useState(null),[s,i]=u.useState(!1),[l,c]=u.useState(!1),[d,f]=u.useState(null),[p,m]=u.useState({}),[g,x]=u.useState([]),[h,v]=u.useState(null),[b,w]=u.useState(0),[y,E]=u.useState(!1),A=10,j=u.useRef(null),N=u.useRef(null),T=u.useRef(null);u.useEffect(()=>{N.current=r},[r]);const G=u.useCallback(C=>{m(_=>{var P,B,D;const L=C.task_id;if(!L)return C.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",C),_;const R=_[L],J=new Date(C.timestamp);if(R){const U=[...R.events,C].sort((I,V)=>new Date(I.timestamp).getTime()-new Date(V.timestamp).getTime());return{..._,[L]:{...R,events:U,lastUpdated:J}}}else{let U="Task started...";if(C.direction==="request"&&((B=(P=C.full_payload)==null?void 0:P.method)!=null&&B.startsWith("message/"))){const V=C.full_payload.params;if((D=V==null?void 0:V.message)!=null&&D.parts){const Q=V.message.parts.filter(te=>te.kind==="text"&&te.text);Q.length>0&&(U=Q[Q.length-1].text)}}const I={taskId:L,initialRequestText:U,events:[C],firstSeen:J,lastUpdated:J};return x(V=>[L,...V.filter(Q=>Q!==L)]),{..._,[L]:I}}})},[]),q=u.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),i(!1),c(!0),f(null),w(0),E(!1),T.current&&(clearTimeout(T.current),T.current=null)},[]),W=u.useCallback(C=>{try{const _=JSON.parse(C.data);G(_)}catch(_){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",_,"Raw data:",C.data),f("Received unparseable 'a2a_message' event from server.")}},[G]),X=u.useCallback(C=>{console.error("TaskMonitorContext: SSE connection error:",C),i(!1),c(!1),j.current&&j.current.readyState===EventSource.CLOSED?f("Task Monitor SSE connection closed by server or network issue."):f("Task Monitor SSE connection error occurred."),j.current&&(j.current.close(),j.current=null),T.current&&(clearTimeout(T.current),T.current=null)},[]),ee=u.useCallback(async()=>{if(l||s){console.warn("TaskMonitorContext: Stream is already active or connecting.");return}console.log("TaskMonitorContext: Attempting to connect stream..."),i(!0);try{const C={subscription_targets:[{type:"my_a2a_messages"}]},_=await Fe(`${n}/visualization/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C),credentials:"include"});if(!_.ok){const D=await _.json().catch(()=>({detail:"Failed to subscribe"}));if(D.error_type==="authorization_failure"){const U=D.message||"Access denied: insufficient permissions",I=D.suggested_action?` ${D.suggested_action}`:"";throw new Error(`${U}${I}`)}else if(D.error_type==="subscription_failure"){const U=D.message||"Subscription failed",I=D.suggested_action?` ${D.suggested_action}`:"";throw new Error(`${U}${I}`)}else throw new Error(D.detail||D.message||`Subscription failed: ${_.statusText}`)}const L=await _.json();o(L.stream_id);const R=L.sse_endpoint_url.startsWith("/")?`${t||""}${L.sse_endpoint_url}`:L.sse_endpoint_url;j.current&&j.current.close();const J=Si(),P=`${R}${J?`?token=${J}`:""}`,B=new EventSource(P,{withCredentials:!0});j.current=B,B.onopen=q,B.addEventListener("a2a_message",W),B.onerror=X}catch(C){console.error("TaskMonitorContext: Error connecting stream:",C),f(C instanceof Error?C.message:String(C)),i(!1),c(!1),o(null),j.current&&(j.current.close(),j.current=null),T.current&&(clearTimeout(T.current),T.current=null)}},[n,t,l,s,q,W,X]),O=u.useCallback(()=>{if(T.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(b>=A){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),E(!1),f(`Connection lost. Max reconnection attempts (${A}) reached.`);return}const C=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${b+1}/${A} in ${C}ms...`),E(!0),w(_=>_+1),T.current=setTimeout(()=>{ee()},C)},[b,ee]),Y=u.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),T.current&&(clearTimeout(T.current),T.current=null),j.current&&(j.current.close(),j.current=null);const C=N.current;if(C)try{await Fe(`${n}/visualization/${C}/unsubscribe`,{method:"DELETE",credentials:"include"})}catch(_){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${C}`,_)}o(null),i(!1),c(!1),f(null),m({}),x([]),v(null),w(0),E(!1)},[n]);u.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),j.current&&(j.current.close(),j.current=null);const C=N.current;if(C)if(navigator.sendBeacon){const _=new FormData;navigator.sendBeacon(`${n}/visualization/${C}/unsubscribe`,_)}else Fe(`${n}/visualization/${C}/unsubscribe`,{method:"DELETE",credentials:"include",keepalive:!0}).catch(_=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",_))},[n]),u.useEffect(()=>{!l&&!s&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),ee())},[]),u.useEffect(()=>{!l&&!s&&d&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),O())},[l,s,d,O]),u.useEffect(()=>()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]);const k=u.useCallback(C=>{v(C)},[]),$={isTaskMonitorConnecting:s,isTaskMonitorConnected:l,taskMonitorSseError:d,monitoredTasks:p,monitoredTaskOrder:g,highlightedStepId:h,isReconnecting:y,reconnectionAttempts:b,connectTaskMonitorStream:ee,disconnectTaskMonitorStream:Y,setHighlightedStepId:k};return a.jsx(Xu.Provider,{value:$,children:e})},Je=[];for(let e=0;e<256;++e)Je.push((e+256).toString(16).slice(1));function HE(e,t=0){return(Je[e[t+0]]+Je[e[t+1]]+Je[e[t+2]]+Je[e[t+3]]+"-"+Je[e[t+4]]+Je[e[t+5]]+"-"+Je[e[t+6]]+Je[e[t+7]]+"-"+Je[e[t+8]]+Je[e[t+9]]+"-"+Je[e[t+10]]+Je[e[t+11]]+Je[e[t+12]]+Je[e[t+13]]+Je[e[t+14]]+Je[e[t+15]]).toLowerCase()}let zs;const WE=new Uint8Array(16);function GE(){if(!zs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");zs=crypto.getRandomValues.bind(crypto)}return zs(WE)}const VE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$l={randomUUID:VE};function YE(e,t,n){var o;e=e||{};const r=e.random??((o=e.rng)==null?void 0:o.call(e))??GE();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,HE(r)}function un(e,t,n){return $l.randomUUID&&!e?$l.randomUUID():YE(e)}const KE=1*1024*1024,qE=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result.split(",")[1]),r.onerror=o=>n(o)}),XE=({children:e})=>{const{configWelcomeMessage:t,configServerUrl:n,persistenceEnabled:r}=sn(),o=u.useMemo(()=>`${n}/api/v1`,[n]),[s,i]=u.useState(""),[l,c]=u.useState([]),[d,f]=u.useState(""),[p,m]=u.useState(!1),[g,x]=u.useState([]),[h,v]=u.useState(null),b=u.useRef(null),[w,y]=u.useState(""),[E,A]=u.useState(!1),[j,N]=u.useState(null),T=u.useRef(null),G=u.useRef(!1),q=u.useRef(null),W=u.useRef(0),X=u.useRef(E);u.useEffect(()=>{X.current=E},[E]);const{agents:ee,error:O,isLoading:Y,refetch:k}=Ju(),{artifacts:$,isLoading:C,refetch:_}=Cw(s),[L,R]=u.useState(!0),[J,P]=u.useState("files"),[B,D]=u.useState(!1),[U,I]=u.useState(null),[V,Q]=u.useState(!1),[te,ae]=u.useState(new Set),[se,pe]=u.useState(!1),[ye,_e]=u.useState(null),[Ie,Pe]=u.useState(null),[Re,Be]=u.useState(null),[yt,We]=u.useState(null),[St,nt]=u.useState(null),[rt,ot]=u.useState(null),le=u.useCallback((z,H)=>{x(F=>{if(F.find(ve=>ve.message===z))return F;const de=Date.now().toString(),ce={id:de,message:z,type:H||"info"};return setTimeout(()=>{x(ve=>ve.filter(he=>he.id!==de))},3e3),[...F,ce]})},[]),jt=u.useCallback(async z=>{const H=await Fe(`${o}/sessions/${z}/messages`);if(!H.ok){const F=await H.json().catch(()=>({detail:"Failed to fetch session history"}));throw new Error(F.detail||`HTTP error ${H.status}`)}return H.json()},[o]),Ct=u.useCallback(async(z,H)=>{const F=H||s;if(!F)throw new Error("Session ID is missing for file upload.");const ie=new FormData;ie.append("upload_file",z);try{const de=await Fe(`${o}/artifacts/${F}/${encodeURIComponent(z.name)}`,{method:"POST",body:ie,credentials:"include"});if(!de.ok){const ve=await de.json().catch(()=>({detail:`Failed to upload ${z.name}`}));throw new Error(ve.detail||`HTTP error ${de.status}`)}const ce=await de.json();return le(`Artifact "${z.name}" uploaded successfully.`),await _(),ce.uri||null}catch(de){return le(`Error uploading artifact "${z.name}": ${de instanceof Error?de.message:"Unknown error"}`),null}},[o,s,le,_]),Rt=u.useCallback(async z=>{try{const H=await Fe(`${o}/artifacts/${s}/${encodeURIComponent(z)}`,{method:"DELETE",credentials:"include"});if(!H.ok&&H.status!==204){const F=await H.json().catch(()=>({detail:`Failed to delete ${z}`}));throw new Error(F.detail||`HTTP error ${H.status}`)}le(`File "${z}" deleted successfully.`),_()}catch(H){le(`Error deleting file "${z}": ${H instanceof Error?H.message:"Unknown error"}`)}},[o,s,le,_]),Mt=u.useCallback(z=>{I(z),D(!0)},[]),Et=u.useCallback(()=>{I(null),D(!1)},[]),Tt=u.useCallback(async()=>{U&&await Rt(U.filename),Et()},[U,Rt,Et]),At=u.useCallback(()=>{if(te.size===0){le("No files selected for deletion.");return}pe(!0)},[te,le]),Xe=u.useCallback(async()=>{pe(!1);const z=Array.from(te);let H=0,F=0;for(const ie of z)try{const de=await Fe(`${o}/artifacts/${encodeURIComponent(ie)}`,{method:"DELETE",credentials:"include"});if(!de.ok&&de.status!==204)throw new Error(`Failed to delete ${ie}`);H++}catch(de){console.error(de),F++}H>0&&le(`${H} files(s) deleted successfully.`),F>0&&le(`Failed to delete ${F} files(s).`),_(),ae(new Set),Q(!1)},[te,o,le,_]),pt=u.useCallback(async z=>{Pe(null),Be(null),We(null);try{const H=await Fe(`${o}/artifacts/${s}/${encodeURIComponent(z)}/versions`,{credentials:"include"});if(!H.ok)throw new Error("Error fetching version list");const F=await H.json();if(!F||F.length===0)throw new Error("No versions available");Pe(F.sort((ne,me)=>ne-me));const ie=Math.max(...F);Be(ie);const de=await Fe(`${o}/artifacts/${s}/${encodeURIComponent(z)}/versions/${ie}`,{credentials:"include"});if(!de.ok)throw new Error("Error fetching latest version content");const ce=await de.blob(),ve=await new Promise((ne,me)=>{const Le=new FileReader;Le.onloadend=()=>{var Z;return ne(((Z=Le.result)==null?void 0:Z.toString().split(",")[1])||"")},Le.onerror=me,Le.readAsDataURL(ce)}),he=$.find(ne=>ne.filename===z),je={name:z,mime_type:(he==null?void 0:he.mime_type)||"application/octet-stream",content:ve,last_modified:(he==null?void 0:he.last_modified)||new Date().toISOString()};return We(je),je}catch(H){return le(`Error loading preview for ${z}: ${H instanceof Error?H.message:"Unknown error"}`),null}},[o,s,$,le]),Pt=u.useCallback(async(z,H)=>{if(!Ie||!Ie.includes(H))return le(`Version ${H} is not available for ${z}.`),null;We(null);try{const F=await Fe(`${o}/artifacts/${s}/${encodeURIComponent(z)}/versions/${H}`,{credentials:"include"});if(!F.ok)throw new Error(`Error fetching version ${H}`);const ie=await F.blob(),de=await new Promise((he,je)=>{const ne=new FileReader;ne.onloadend=()=>{var me;return he(((me=ne.result)==null?void 0:me.toString().split(",")[1])||"")},ne.onerror=je,ne.readAsDataURL(ie)}),ce=$.find(he=>he.filename===z),ve={name:z,mime_type:(ce==null?void 0:ce.mime_type)||"application/octet-stream",content:de,last_modified:(ce==null?void 0:ce.last_modified)||new Date().toISOString()};return Be(H),We(ve),ve}catch(F){return le(`Error loading version ${H}: ${F instanceof Error?F.message:"Unknown error"}`),null}},[o,le,$,Ie,s]),Lt=u.useCallback(z=>{le(`Loading preview for attached file: ${z.name}`),We(z),Pe(null),Be(null)},[le]),an=u.useCallback(z=>{R(!1),P(z),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:z}}))},[]),De=u.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null),b.current&&(b.current.close(),b.current=null),G.current=!1},[]),Ge=u.useCallback(z=>{var Le;W.current+=1;const H=W.current;let F;try{console.log("TEST-SSE ChatProvider Raw Message:",z.data),F=JSON.parse(z.data)}catch(Z){console.error("Failed to parse SSE message:",Z),le("Received unparseable agent update.","error");return}if("error"in F&&F.error){const S=`Error: ${F.error.message}`;c(M=>{const K=M.filter(Ne=>!Ne.isStatusBubble);return K.push({role:"agent",parts:[{kind:"text",text:S}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${un()}`,lastProcessedEventSequence:H}}),K}),m(!1),De(),v(null);return}if(!("result"in F)||!F.result){console.warn("Received SSE message without a result or error field.",F);return}const ie=F.result;let de=!1,ce,ve,he;switch(ie.kind){case"task":de=!0,ce=void 0,he=ie.id,ie.artifacts&&ie.artifacts.length>0&&console.log("Final task has artifacts to process:",ie.artifacts);break;case"status-update":de=ie.final,ce=(Le=ie.status)==null?void 0:Le.message,he=ie.taskId;break;case"artifact-update":ve=ie.artifact,he=ie.taskId;break;default:console.warn("Received unknown result kind in SSE message:",ie);return}const je=[],ne=[];let me=null;if(ce!=null&&ce.parts)for(const Z of ce.parts)if(Z.kind==="data"){const S=Z.data;if(S&&typeof S=="object"&&"type"in S)switch(S.type){case"agent_progress_update":me=String((S==null?void 0:S.status_text)??"Processing...");break;case"artifact_creation_progress":me=`Saving artifact: ${String((S==null?void 0:S.filename)??"unknown file")} (${Number((S==null?void 0:S.bytes_saved)??0)} bytes)`;break;case"tool_invocation_start":break;default:je.push(Z)}}else if(Z.kind==="file"){const M=Z.file,K={name:M.name||"untitled_file",mime_type:M.mimeType};"bytes"in M&&M.bytes?K.content=M.bytes:"uri"in M&&M.uri&&(K.uri=M.uri),ne.push(K)}else je.push(Z);me&&(q.current=me),c(Z=>{var Oe;const S=[...Z];let M=S[S.length-1];M!=null&&M.isStatusBubble&&(S.pop(),M=S[S.length-1]);const K=je.find(ue=>ue.kind==="text"),Ne=je.filter(ue=>ue.kind!=="text");if(M&&!M.isUser&&!M.isComplete&&M.taskId===ie.taskId&&(K||ne.length>0)){const ue={...M,parts:[...M.parts],files:M.files?[...M.files]:[],isComplete:de||ne.length>0,metadata:{...M.metadata,lastProcessedEventSequence:H}};if(K){const we=ue.parts[ue.parts.length-1];(we==null?void 0:we.kind)==="text"?ue.parts[ue.parts.length-1]={...we,text:we.text+K.text}:ue.parts.push(K)}Ne.length>0&&ue.parts.push(...Ne),ne.length>0&&ue.files.push(...ne),S[S.length-1]=ue}else if(je.some(we=>we.kind==="text"&&we.text.trim())||ne.length>0||ve){const we={role:"agent",parts:je,files:ne.length>0?ne:void 0,taskId:ie.taskId,isUser:!1,isComplete:de||ne.length>0,metadata:{messageId:((Oe=F.id)==null?void 0:Oe.toString())||`msg-${un()}`,sessionId:ie.contextId,lastProcessedEventSequence:H}};ve&&(we.artifactNotification={name:ve.name||ve.artifactId}),S.push(we)}if(!de&&q.current)S.push({role:"agent",parts:[{kind:"text",text:q.current}],taskId:ie.taskId,isUser:!1,isStatusBubble:!0,isComplete:!1,metadata:{messageId:`status-${un()}`,lastProcessedEventSequence:H}});else if(de){q.current=null;const ue=S.findLastIndex(we=>!we.isUser&&we.taskId===he);ue!==-1&&(S[ue]={...S[ue],isComplete:!0,metadata:{...S[ue].metadata,lastProcessedEventSequence:H}})}return S}),de&&(X.current&&(le("Task successfully cancelled."),T.current&&clearTimeout(T.current),A(!1)),m(!1),De(),v(null),G.current=!0,_(),setTimeout(()=>{G.current=!1},100))},[le,De,_]),Dt=u.useCallback(async()=>{const z="ChatProvider.handleNewSession:";if(console.log(`${z} Starting new session process...`),De(),p&&h&&w&&!E){console.log(`${z} Cancelling current task ${h}`);try{const F={jsonrpc:"2.0",id:`req-${un()}`,method:"tasks/cancel",params:{id:h}};Fe(`${o}/tasks/${h}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F),credentials:"include"})}catch(F){console.warn(`${z} Failed to cancel current task:`,F)}}T.current&&(clearTimeout(T.current),T.current=null),A(!1),console.log(`${z} Resetting session state - new session will be created when first message is sent`),i(""),nt(null),c(t?[{parts:[{kind:"text",text:t}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}]:[]),f(""),m(!1),v(null),N(null),_e(null),G.current=!1,q.current=null,W.current=0,console.log(`${z} Refreshing artifacts for new session...`),await _(),le("New session started successfully."),console.log(`${z} New session setup complete - session will be created on first message.`)},[o,p,h,w,E,t,le,_,De]),gt=u.useCallback(async z=>{const H="ChatProvider.handleSwitchSession:";if(console.log(`${H} Switching to session ${z}...`),De(),p&&h&&w&&!E){console.log(`${H} Cancelling current task ${h}`);try{const F={jsonrpc:"2.0",id:`req-${un()}`,method:"tasks/cancel",params:{id:h}};await Fe(`${o}/tasks/${h}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F),credentials:"include"})}catch(F){console.warn(`${H} Failed to cancel current task:`,F)}}T.current&&(clearTimeout(T.current),T.current=null),A(!1);try{const ie=(await jt(z)).map(ce=>({parts:[{kind:"text",text:ce.message}],isUser:ce.senderType==="user",isComplete:!0,role:ce.senderType==="user"?"user":"agent",metadata:{sessionId:ce.sessionId,messageId:ce.id,lastProcessedEventSequence:0}})),de=await Fe(`${o}/sessions/${z}`);if(de.ok){const ce=await de.json();nt(ce.name)}i(z),c(ie),f(""),m(!1),v(null),N(null),_e(null),G.current=!1,q.current=null,W.current=0}catch(F){console.error(`${H} Failed to fetch session history:`,F),le("Error switching session. Please try again.","error")}},[De,p,h,w,E,o,le,jt]),Ot=u.useCallback(async(z,H,F=!0)=>{if(r)try{const ie=await Fe(`${o}/sessions/${z}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H})});if(!ie.ok){const de=await ie.json().catch(()=>({detail:"Failed to update session name"}));throw new Error(de.detail||`HTTP error ${ie.status}`)}F&&le("Session name updated successfully."),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(ie){le(`Error updating session name: ${ie instanceof Error?ie.message:"Unknown error"}`)}},[o,r,le]),Ft=u.useCallback(async z=>{try{const H=await Fe(`${o}/sessions/${z}`,{method:"DELETE"});if(!H.ok){const F=await H.json().catch(()=>({detail:"Failed to delete session"}));throw new Error(F.detail||`HTTP error ${H.status}`)}le("Session deleted successfully."),z===s&&Dt(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(H){le(`Error deleting session: ${H instanceof Error?H.message:"Unknown error"}`)}},[o,le,Dt,s]),ze=u.useCallback(z=>{ot(z)},[]),mt=u.useCallback(()=>{ot(null)},[]),ln=u.useCallback(async()=>{rt&&(await Ft(rt.id),ot(null))},[rt,Ft]),Kt=u.useCallback(async()=>{if(!p&&!E||!h){le("No active task to cancel.");return}if(E){le("Cancellation already in progress.");return}le(`Requesting cancellation for task ${h}...`),A(!0);try{const z={jsonrpc:"2.0",id:`req-${un()}`,method:"tasks/cancel",params:{id:h}},H=await Fe(`${o}/tasks/${h}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)});if(H.status===202)T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{le(`Cancellation for task ${h} timed out. Allowing new input.`),A(!1),m(!1),De(),v(null),T.current=null,c(F=>F.filter(ie=>!ie.isStatusBubble))},15e3);else{const F=await H.json().catch(()=>({detail:"Unknown cancellation error"}));le(`Failed to request cancellation: ${F.detail||H.statusText}`),A(!1)}}catch(z){le(`Error sending cancellation request: ${z instanceof Error?z.message:"Network error"}`),A(!1)}},[p,E,h,o,le,De]),Nt=u.useCallback(()=>{},[]),zt=u.useCallback(()=>{p&&!G.current&&!X.current&&le("Connection error with agent updates."),G.current||(m(!1),X.current||(De(),v(null)),q.current=null),c(z=>z.filter(H=>!H.isStatusBubble).map((H,F,ie)=>F===ie.length-1&&!H.isUser?{...H,isComplete:!0}:H))},[le,De,p]),qt=u.useCallback(async(z,H,F)=>{z.preventDefault();const ie=(F==null?void 0:F.trim())||d.trim(),de=H||[];if(!ie&&de.length===0||p||E||!w){w||le("Please select an agent first."),E&&le("Cannot send new message while a task is being cancelled.");return}De(),G.current=!1,m(!0),v(null),q.current=null,W.current=0;let ce=s;const ve=!ce,he={role:"user",parts:[{kind:"text",text:ie}],isUser:!0,uploadedFiles:de.length>0?de:void 0,metadata:{messageId:`msg-${un()}`,sessionId:ce,lastProcessedEventSequence:0}};q.current="Thinking",c(je=>[...je,he]),f("");try{if(ve){const ue=await Fe(`${o}/sessions/new`,{method:"POST"});if(!ue.ok)throw new Error("Failed to create a new session on the backend.");ce=(await ue.json()).result.id,i(ce),console.log("Created new session on-demand:",ce),c(Te=>Te.map(Ze=>{var $t,Me;return(($t=Ze.metadata)==null?void 0:$t.messageId)===((Me=he.metadata)==null?void 0:Me.messageId)?{...Ze,metadata:{...Ze.metadata,sessionId:ce}}:Ze}))}const je=de.map(async ue=>{if(ue.size<KE)return{kind:"file",file:{bytes:await qE(ue),name:ue.name,mimeType:ue.type}};{const we=await Ct(ue,ce);return we?{kind:"file",file:{uri:we,name:ue.name,mimeType:ue.type}}:(le(`Failed to upload large file: ${ue.name}`,"error"),null)}}),ne=(await Promise.all(je)).filter(ue=>ue!==null),me=[];if(ie&&me.push({kind:"text",text:ie}),me.push(...ne),me.length===0)throw new Error("Cannot send an empty message.");const Le={role:"user",parts:me,messageId:`msg-${un()}`,kind:"message",contextId:ce,metadata:{agent_name:w}},Z={jsonrpc:"2.0",id:`req-${un()}`,method:"message/stream",params:{message:Le}},S=await Fe(`${o}/message:stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)});if(!S.ok){const ue=await S.json().catch(()=>({detail:"Unknown error"}));throw new Error(ue.detail||`HTTP error ${S.status}`)}const M=await S.json(),K=M==null?void 0:M.result,Ne=K==null?void 0:K.id,Oe=K==null?void 0:K.contextId;if(!Ne)throw new Error("Backend did not return a valid taskId.");if(Oe&&Oe!==ce&&(console.warn(`Backend returned a different session ID (${Oe}) than expected (${ce}). This should not happen.`),i(Oe)),ve){const we=he.parts.filter(Te=>Te.kind==="text").map(Te=>Te.text).join(" ").trim();if(we){const Te=we.length>100?`${we.substring(0,100)}...`:we;nt(Te),Ot(ce,Te,!1)}typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}v(Ne),N(Ne)}catch(je){le(`Error: ${je instanceof Error?je.message:"Unknown error"}`),m(!1),c(ne=>ne.filter(me=>!me.isStatusBubble)),v(null),G.current=!1,q.current=null}},[s,d,p,E,w,De,le,o,Ct,Ot]);u.useEffect(()=>{if(h&&o){console.log(`ChatProvider Effect: currentTaskId is ${h}. Setting up EventSource.`);const z=Si(),H=`${o}/sse/subscribe/${h}${z?`?token=${z}`:""}`,F=new EventSource(H,{withCredentials:!0});return b.current=F,F.onopen=Nt,F.onerror=zt,F.addEventListener("status_update",Ge),F.addEventListener("artifact_update",Ge),F.addEventListener("final_response",Ge),F.addEventListener("error",Ge),()=>{console.log(`ChatProvider Effect Cleanup: currentTaskId was ${h}. Closing EventSource.`),F.removeEventListener("status_update",Ge),F.removeEventListener("artifact_update",Ge),F.removeEventListener("final_response",Ge),F.removeEventListener("error",Ge),De()}}else console.log("ChatProvider Effect: currentTaskId is null or apiPrefix missing. Ensuring EventSource is closed."),De()},[h,o,Ge,Nt,zt,De]);const Se={sessionId:s,setSessionId:i,sessionName:St,setSessionName:nt,messages:l,setMessages:c,userInput:d,setUserInput:f,isResponding:p,currentTaskId:h,isCancelling:E,latestStatusText:q,agents:ee,agentsLoading:Y,agentsError:O,agentsRefetch:k,handleNewSession:Dt,handleSwitchSession:gt,handleSubmit:qt,handleCancel:Kt,notifications:g,addNotification:le,selectedAgentName:w,setSelectedAgentName:y,artifacts:$,artifactsLoading:C,artifactsRefetch:_,uploadArtifactFile:Ct,isSidePanelCollapsed:L,activeSidePanelTab:J,setIsSidePanelCollapsed:R,setActiveSidePanelTab:P,openSidePanelTab:an,taskIdInSidePanel:j,setTaskIdInSidePanel:N,isDeleteModalOpen:B,artifactToDelete:U,openDeleteModal:Mt,closeDeleteModal:Et,confirmDelete:Tt,openSessionDeleteModal:ze,closeSessionDeleteModal:mt,confirmSessionDelete:ln,sessionToDelete:rt,isArtifactEditMode:V,setIsArtifactEditMode:Q,selectedArtifactFilenames:te,setSelectedArtifactFilenames:ae,handleDeleteSelectedArtifacts:At,confirmBatchDeleteArtifacts:Xe,isBatchDeleteModalOpen:se,setIsBatchDeleteModalOpen:pe,previewedArtifactAvailableVersions:Ie,currentPreviewedVersionNumber:Re,previewFileContent:yt,openArtifactForPreview:pt,navigateArtifactVersion:Pt,openMessageAttachmentForPreview:Lt,previewArtifact:ye,setPreviewArtifact:_e,updateSessionName:Ot,deleteSession:Ft};return a.jsx(Yu.Provider,{value:Se,children:e})},ZE=({children:e})=>{const{frontend_use_authorization:t,configAuthLoginUrl:n}=sn(),{fetchCsrfToken:r,clearCsrfToken:o}=Qu(),[s,i]=u.useState(!1),[l,c]=u.useState(!0),[d,f]=u.useState(null);u.useEffect(()=>{let g=!0;const x=async()=>{if(!t){g&&(i(!0),c(!1));return}try{const v=await Fe("/api/v1/users/me",{credentials:"include",headers:{Accept:"application/json"}});if(v.ok){const b=await v.json();console.log("User is authenticated:",b),g&&(f(b),i(!0)),console.log("Fetching CSRF token for authenticated requests..."),await r()}else v.status===401?(console.log("User is not authenticated"),g&&i(!1)):(console.error("Unexpected response from /users/me:",v.status),g&&i(!1))}catch(v){console.error("Error checking authentication:",v),g&&i(!1)}finally{g&&c(!1)}};x();const h=v=>{v.key==="access_token"&&x()};return window.addEventListener("storage",h),()=>{g=!1,window.removeEventListener("storage",h)}},[t,n,r]);const p=()=>{window.location.href=n},m=()=>{i(!1),f(null),o()};return l?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Checking Authentication..."})]})}):a.jsx(Vu.Provider,{value:{isAuthenticated:s,useAuthorization:t,login:p,logout:m,userInfo:d},children:e})};function JE(e){var r;if(typeof document>"u")return null;const n=`; ${document.cookie}`.split(`; ${e}=`);return n.length===2&&((r=n.pop())==null?void 0:r.split(";").shift())||null}const QE=e=>new Promise(t=>setTimeout(t,e)),e1=async(e=5,t=50)=>{try{const n=await Fe("/api/v1/csrf-token",{credentials:"include"});if(!n.ok)throw new Error(`CSRF endpoint returned status ${n.status}`);const r=await n.json();if(r.csrf_token)return console.log("CSRF token found in response body:",r.csrf_token),r.csrf_token;for(let o=0;o<e;o++){const s=JE("csrf_token");if(s)return console.log(`CSRF token found in cookie after ${o} retries:`,s),s;console.log(`CSRF token not found in cookie, attempt ${o+1}/${e}. Waiting ${t}ms...`),await QE(t)}throw new Error("CSRF token not available in response or cookie after retries")}catch(n){return console.error("Error fetching/reading CSRF token:",n),null}};function t1({children:e}){const[t,n]=u.useState(null),r=u.useCallback(async()=>{if(t)return t;const i=await e1();if(i)n(i);else throw new Error("Failed to obtain CSRF token after config fetch failed.");return i},[t]),o=u.useCallback(()=>{n(null)},[]),s={fetchCsrfToken:r,clearCsrfToken:o};return a.jsx(qu.Provider,{value:s,children:e})}const n1={brand:{wMain:"#00C895",w30:"#B3EFDF",wMain30:"#00C8954d",w10:"#E6FAF4",w60:"#66DEBF",w100:"#00AD93"},primary:{w100:"#01374E",w90:"#014968",wMain:"#015B82",w60:"#679DB4",w40:"#99BDCD",w20:"#CCDEE6",w10:"#E6EFF2",text:{wMain:"#273749",w100:"#000000",w10:"#CCCCCC"}},secondary:{w70:"#536574",w80:"#354E62",w8040:"#354E6240",w100:"#000000",wMain:"#8790A0",w40:"#CFD3D9",w20:"#E7E9EC",w10:"#F3F4F6",text:{wMain:"#647481",w50:"#B1B9C0"}},background:{w100:"#021B2F",wMain:"#03223B",w20:"#F7F8F9",w10:"#FFFFFF"},info:{w100:"#2B71B1",wMain:"#0591D3",w70:"#7CD3F6",w30:"#B4DEF2",w20:"#CDE9F6",w10:"#E6F4FB"},error:{w100:"#C33135",wMain:"#E94C4E",w70:"#ED9B9D",w30:"#F8C9CA",w20:"#FBDBDC",w10:"#FDEDED"},warning:{w100:"#E1681F",wMain:"#FF8E2B",w70:"#F8C785",w30:"#FFDDBF",w20:"#FFE8D5",w10:"#FFF4EA"},success:{w100:"#006B53",wMain:"#009A80",w70:"#6FCCBC",w30:"#B3E1D9",w20:"#CCEBE6",w10:"#E6F5F2"},stateLayer:{w10:"#03223B1a",w20:"#03223B33"},accent:{n0:{w100:"#2F51AD",wMain:"#3C69E1",w30:"#C5D2F6",w10:"#ECF0FC"},n1:{w100:"#1F284C",wMain:"#3A4880",w30:"#C4C8D9",w60:"#8991B3",w20:"#D8DAE6",w10:"#EBEDF2"},n2:{w100:"#165E64",wMain:"#009193",w30:"#B3DEDF",w20:"#CCE9E9",w10:"#E6F4F4"},n3:{w100:"#542D75",wMain:"#7841A8",w30:"#D7C6E5",w10:"#F2ECF6"},n4:{w100:"#951379",wMain:"#CB1AA5",w30:"#F2C4E8"},n5:{w100:"#D03C1B",wMain:"#F66651",w30:"#FCCEC7",w60:"#FAA397"},n6:{w100:"#DE7E00",wMain:"#FCA829",w30:"#FEE5BF"},n7:{w100:"#2DADE1",wMain:"#7CD3F6",w30:"#CBEDFB"},n8:{w100:"#4F5A63",wMain:"#86939E",w30:"#DBDFE2"},n9:{wMain:"#DA162D"}},learning:{wMain:"#033A6F",w90:"#022E59",w100:"#022343",w20:"#CDD8E2",w10:"#E6EBF1"}},r1={light:{background:"background.w10",foreground:"primary.text.wMain",card:"background.w10","card-foreground":"primary.text.wMain",popover:"background.w10","popover-foreground":"primary.text.wMain",primary:"primary.wMain","primary-foreground":"primary.text.w10",secondary:"secondary.w10","secondary-foreground":"secondary.text.wMain",muted:"secondary.w10","muted-foreground":"secondary.text.wMain",accent:"secondary.w40","accent-foreground":"secondary.text.wMain",destructive:"error.wMain",border:"secondary.w40",input:"secondary.w40",ring:"brand.wMain","ring-offset":"brand.wMain","accent-background":"background.w20","message-background":"secondary.w20","chart-1":"brand.w60","chart-2":"primary.wMain","chart-3":"accent.n3.wMain","chart-4":"accent.n6.wMain","chart-5":"accent.n5.wMain",sidebar:"background.w20","sidebar-foreground":"primary.text.wMain","sidebar-primary":"primary.wMain","sidebar-primary-foreground":"primary.text.w10","sidebar-accent":"secondary.w10","sidebar-accent-foreground":"secondary.text.wMain","sidebar-border":"secondary.w40","sidebar-ring":"brand.wMain"},dark:{background:"background.w100",foreground:"primary.text.w10",card:"background.wMain","card-foreground":"primary.text.w10",popover:"background.wMain","popover-foreground":"primary.text.w10",primary:"primary.w60","primary-foreground":"primary.text.wMain",secondary:"secondary.w80","secondary-foreground":"secondary.text.w50",muted:"secondary.w80","muted-foreground":"secondary.text.w50",accent:"secondary.w80","accent-foreground":"secondary.text.w50",destructive:"error.w70",border:"secondary.w70",input:"secondary.w70",ring:"brand.w60","ring-offset":"brand.w60","accent-background":"primary.w90","message-background":"secondary.w70","chart-1":"brand.w100","chart-2":"primary.wMain","chart-3":"accent.n3.w100","chart-4":"accent.n6.w30","chart-5":"accent.n5.w60",sidebar:"background.wMain","sidebar-foreground":"primary.text.w10","sidebar-primary":"primary.w60","sidebar-primary-foreground":"primary.text.wMain","sidebar-accent":"secondary.w80","sidebar-accent-foreground":"secondary.text.w50","sidebar-border":"secondary.w70","sidebar-ring":"brand.w60"}},o1={"error-text-wMain":"error.wMain","error-text-w50":"error.w70","warning-text-wMain":"warning.wMain","warning-text-w50":"warning.w70","success-text-wMain":"success.wMain","success-text-w50":"success.w70","info-text-wMain":"info.wMain","info-text-w50":"info.w70"};function Bl(e,t){const n=t.split(".");let r=e;for(const o of n)if(r&&typeof r=="object"&&o in r)r=r[o];else return console.warn(`Color path not found: ${t}`),"#000000";return typeof r=="string"?r:"#000000"}function s1(e,t){const n={},r=r1[t];for(const[o,s]of Object.entries(r)){const i=Bl(e,s);n[`--${o}`]=i}for(const[o,s]of Object.entries(o1)){const i=Bl(e,s);n[`--color-${o}`]=i}return n}const Po="sam-theme";function i1(e){var n,r,o,s,i,l,c,d,f,p,m,g,x,h,v,b,w,y,E,A,j,N,T,G,q,W,X,ee,O,Y,k,$,C,_,L,R,J,P,B,D,U,I,V,Q,te,ae,se,pe,ye,_e,Ie,Pe,Re,Be,yt,We,St,nt,rt,ot,le,jt,Ct,Rt,Mt,Et,Tt,At,Xe,pt,Pt,Lt,an,De,Ge,Dt,gt,Ot,Ft,ze,mt,ln,Kt,Nt,zt,qt,Se,z,H,F,ie,de,ce,ve,he,je,ne,me,Le,Z,S,M,K;const t={};return e.brand.wMain&&(t["--color-brand-wMain"]=e.brand.wMain),e.brand.wMain30&&(t["--color-brand-wMain30"]=e.brand.wMain30),e.brand.w100&&(t["--color-brand-w100"]=e.brand.w100),e.brand.w60&&(t["--color-brand-w60"]=e.brand.w60),e.brand.w30&&(t["--color-brand-w30"]=e.brand.w30),e.brand.w10&&(t["--color-brand-w10"]=e.brand.w10),e.primary.wMain&&(t["--color-primary-wMain"]=e.primary.wMain),e.primary.w100&&(t["--color-primary-w100"]=e.primary.w100),e.primary.w90&&(t["--color-primary-w90"]=e.primary.w90),e.primary.w60&&(t["--color-primary-w60"]=e.primary.w60),e.primary.w40&&(t["--color-primary-w40"]=e.primary.w40),e.primary.w20&&(t["--color-primary-w20"]=e.primary.w20),e.primary.w10&&(t["--color-primary-w10"]=e.primary.w10),e.primary.text.wMain&&(t["--color-primary-text-wMain"]=e.primary.text.wMain),e.primary.text.w100&&(t["--color-primary-text-w100"]=e.primary.text.w100),e.primary.text.w10&&(t["--color-primary-text-w10"]=e.primary.text.w10),e.secondary.wMain&&(t["--color-secondary-wMain"]=e.secondary.wMain),e.secondary.w100&&(t["--color-secondary-w100"]=e.secondary.w100),e.secondary.w80&&(t["--color-secondary-w80"]=e.secondary.w80),e.secondary.w8040&&(t["--color-secondary-w8040"]=e.secondary.w8040),e.secondary.w70&&(t["--color-secondary-w70"]=e.secondary.w70),e.secondary.w40&&(t["--color-secondary-w40"]=e.secondary.w40),e.secondary.w20&&(t["--color-secondary-w20"]=e.secondary.w20),e.secondary.w10&&(t["--color-secondary-w10"]=e.secondary.w10),e.secondary.text.wMain&&(t["--color-secondary-text-wMain"]=e.secondary.text.wMain),e.secondary.text.w50&&(t["--color-secondary-text-w50"]=e.secondary.text.w50),e.background.wMain&&(t["--color-background-wMain"]=e.background.wMain),e.background.w100&&(t["--color-background-w100"]=e.background.w100),e.background.w20&&(t["--color-background-w20"]=e.background.w20),e.background.w10&&(t["--color-background-w10"]=e.background.w10),(n=e.info)!=null&&n.wMain&&(t["--color-info-wMain"]=e.info.wMain),(r=e.info)!=null&&r.w100&&(t["--color-info-w100"]=e.info.w100),(o=e.info)!=null&&o.w70&&(t["--color-info-w70"]=e.info.w70),(s=e.info)!=null&&s.w30&&(t["--color-info-w30"]=e.info.w30),(i=e.info)!=null&&i.w20&&(t["--color-info-w20"]=e.info.w20),(l=e.info)!=null&&l.w10&&(t["--color-info-w10"]=e.info.w10),(c=e.error)!=null&&c.wMain&&(t["--color-error-wMain"]=e.error.wMain),(d=e.error)!=null&&d.w100&&(t["--color-error-w100"]=e.error.w100),(f=e.error)!=null&&f.w70&&(t["--color-error-w70"]=e.error.w70),(p=e.error)!=null&&p.w30&&(t["--color-error-w30"]=e.error.w30),(m=e.error)!=null&&m.w20&&(t["--color-error-w20"]=e.error.w20),(g=e.error)!=null&&g.w10&&(t["--color-error-w10"]=e.error.w10),(x=e.warning)!=null&&x.wMain&&(t["--color-warning-wMain"]=e.warning.wMain),(h=e.warning)!=null&&h.w100&&(t["--color-warning-w100"]=e.warning.w100),(v=e.warning)!=null&&v.w70&&(t["--color-warning-w70"]=e.warning.w70),(b=e.warning)!=null&&b.w30&&(t["--color-warning-w30"]=e.warning.w30),(w=e.warning)!=null&&w.w20&&(t["--color-warning-w20"]=e.warning.w20),(y=e.warning)!=null&&y.w10&&(t["--color-warning-w10"]=e.warning.w10),(E=e.success)!=null&&E.wMain&&(t["--color-success-wMain"]=e.success.wMain),(A=e.success)!=null&&A.w100&&(t["--color-success-w100"]=e.success.w100),(j=e.success)!=null&&j.w70&&(t["--color-success-w70"]=e.success.w70),(N=e.success)!=null&&N.w30&&(t["--color-success-w30"]=e.success.w30),(T=e.success)!=null&&T.w20&&(t["--color-success-w20"]=e.success.w20),(G=e.success)!=null&&G.w10&&(t["--color-success-w10"]=e.success.w10),(q=e.stateLayer)!=null&&q.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(W=e.stateLayer)!=null&&W.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(ee=(X=e.accent)==null?void 0:X.n0)!=null&&ee.wMain&&(t["--color-accent-n0-wMain"]=e.accent.n0.wMain),(Y=(O=e.accent)==null?void 0:O.n0)!=null&&Y.w100&&(t["--color-accent-n0-w100"]=e.accent.n0.w100),($=(k=e.accent)==null?void 0:k.n0)!=null&&$.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(_=(C=e.accent)==null?void 0:C.n0)!=null&&_.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),(R=(L=e.accent)==null?void 0:L.n1)!=null&&R.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(P=(J=e.accent)==null?void 0:J.n1)!=null&&P.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(D=(B=e.accent)==null?void 0:B.n1)!=null&&D.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),(I=(U=e.accent)==null?void 0:U.n1)!=null&&I.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(Q=(V=e.accent)==null?void 0:V.n1)!=null&&Q.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(ae=(te=e.accent)==null?void 0:te.n1)!=null&&ae.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(pe=(se=e.accent)==null?void 0:se.n2)!=null&&pe.wMain&&(t["--color-accent-n2-wMain"]=e.accent.n2.wMain),(_e=(ye=e.accent)==null?void 0:ye.n2)!=null&&_e.w100&&(t["--color-accent-n2-w100"]=e.accent.n2.w100),(Pe=(Ie=e.accent)==null?void 0:Ie.n2)!=null&&Pe.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(Be=(Re=e.accent)==null?void 0:Re.n2)!=null&&Be.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(We=(yt=e.accent)==null?void 0:yt.n2)!=null&&We.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(nt=(St=e.accent)==null?void 0:St.n3)!=null&&nt.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(ot=(rt=e.accent)==null?void 0:rt.n3)!=null&&ot.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(jt=(le=e.accent)==null?void 0:le.n3)!=null&&jt.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(Rt=(Ct=e.accent)==null?void 0:Ct.n3)!=null&&Rt.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(Et=(Mt=e.accent)==null?void 0:Mt.n4)!=null&&Et.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(At=(Tt=e.accent)==null?void 0:Tt.n4)!=null&&At.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(pt=(Xe=e.accent)==null?void 0:Xe.n4)!=null&&pt.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(Lt=(Pt=e.accent)==null?void 0:Pt.n5)!=null&&Lt.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(De=(an=e.accent)==null?void 0:an.n5)!=null&&De.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(Dt=(Ge=e.accent)==null?void 0:Ge.n5)!=null&&Dt.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(Ot=(gt=e.accent)==null?void 0:gt.n5)!=null&&Ot.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(ze=(Ft=e.accent)==null?void 0:Ft.n6)!=null&&ze.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(ln=(mt=e.accent)==null?void 0:mt.n6)!=null&&ln.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(Nt=(Kt=e.accent)==null?void 0:Kt.n6)!=null&&Nt.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),(qt=(zt=e.accent)==null?void 0:zt.n7)!=null&&qt.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),(z=(Se=e.accent)==null?void 0:Se.n7)!=null&&z.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),(F=(H=e.accent)==null?void 0:H.n7)!=null&&F.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(de=(ie=e.accent)==null?void 0:ie.n8)!=null&&de.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),(ve=(ce=e.accent)==null?void 0:ce.n8)!=null&&ve.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(je=(he=e.accent)==null?void 0:he.n8)!=null&&je.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),(me=(ne=e.accent)==null?void 0:ne.n9)!=null&&me.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(Le=e.learning)!=null&&Le.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(Z=e.learning)!=null&&Z.w100&&(t["--color-learning-w100"]=e.learning.w100),(S=e.learning)!=null&&S.w90&&(t["--color-learning-w90"]=e.learning.w90),(M=e.learning)!=null&&M.w20&&(t["--color-learning-w20"]=e.learning.w20),(K=e.learning)!=null&&K.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function a1(e,t="light"){const n={};if(e){const o=i1(e);Object.assign(n,o)}const r=s1(e,t);return Object.assign(n,r),n}function l1(){const e=localStorage.getItem(Po);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function c1(e,t){const n=a1(e,t),r=document.documentElement;for(const[o,s]of Object.entries(n))r.style.setProperty(o,s);requestAnimationFrame(()=>{console.log(`Applying ${t} theme with palette`),r.classList.remove("light","dark"),r.classList.add(t),localStorage.setItem(Po,t)})}const u1=({children:e})=>{const t=u.useMemo(()=>n1,[]),[n,r]=u.useState(()=>l1()),o=u.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const s=n==="light"?"dark":"light";r(s),localStorage.setItem(Po,s)}}),[n]);return u.useEffect(()=>{if(!(localStorage.getItem(Po)!==null)){const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{r(c.matches?"dark":"light")};return i.addEventListener?i.addEventListener("change",l):i.addListener(l),()=>{i.removeEventListener?i.removeEventListener("change",l):i.removeListener(l)}}},[]),u.useEffect(()=>{document.documentElement.classList.remove("light","dark"),c1(t,n)},[n,t]),a.jsx(Zu.Provider,{value:o,children:e})};function d1(){const[e,t]=u.useState("chat"),{isAuthenticated:n,login:r,useAuthorization:o}=Ew();if(Tw(),o&&!n)return a.jsx("div",{className:"bg-background flex h-screen items-center justify-center",children:a.jsx(xe,{onClick:r,children:"Login"})});const s=c=>{const d=Ol.find(f=>f.id===c)||Fl.find(f=>f.id===c);d!=null&&d.onClick&&c!=="settings"?d.onClick():c!=="settings"&&t(c)},i=()=>{t("chat")},l=()=>{switch(e){case"chat":return a.jsx(zE,{});case"agentMesh":return a.jsx(DE,{})}};return a.jsxs("div",{className:"relative flex h-screen",children:[a.jsx(kE,{items:Ol,bottomItems:Fl,activeItem:e,onItemChange:s,onHeaderClick:i}),a.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:l()}),a.jsx(ab,{})]})}function f1(){return a.jsx(u1,{children:a.jsx(t1,{children:a.jsx(BE,{children:a.jsx(ZE,{children:a.jsx(XE,{children:a.jsx(UE,{children:a.jsx(d1,{})})})})})})})}Mp.createRoot(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(f1,{})}));