solace-agent-mesh 1.3.3__py3-none-any.whl → 1.4.1__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.
- solace_agent_mesh/agent/adk/setup.py +183 -8
- solace_agent_mesh/agent/sac/app.py +337 -622
- solace_agent_mesh/agent/sac/component.py +47 -1
- solace_agent_mesh/agent/tools/dynamic_tool.py +36 -5
- solace_agent_mesh/agent/tools/tool_config_types.py +58 -0
- solace_agent_mesh/assets/docs/404.html +3 -3
- solace_agent_mesh/assets/docs/assets/js/42b3f8d8.508ae8db.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9a09e75d.92de8cf5.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ae4415af.16cc58d3.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{main.e82b32e6.js → main.9bc1a102.js} +2 -2
- solace_agent_mesh/assets/docs/assets/js/{runtime~main.aad1f874.js → runtime~main.f2b4ea70.js} +1 -1
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/installation/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/Enterprise/single-sign-on/index.html +3 -3
- 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
- solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-technical-migration-map/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +20 -5
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +5 -5
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-python-tools/index.html +68 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +3 -3
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +3 -3
- solace_agent_mesh/assets/docs/lunr-index-1758036158289.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/search-doc-1758036158289.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/plugin_cmd/__init__.py +2 -0
- solace_agent_mesh/cli/commands/plugin_cmd/add_cmd.py +10 -245
- solace_agent_mesh/cli/commands/plugin_cmd/install_cmd.py +283 -0
- solace_agent_mesh/cli/commands/run_cmd.py +4 -7
- solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-CAX9u8a7.js → authCallback-j1LW-wlq.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/{client-DXU9SPI5.js → client-B9p_nFNA.js} +1 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-B6BpuH9K.js +339 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-B9s_V9tJ.css +1 -0
- solace_agent_mesh/client/webui/frontend/static/assets/{vendor-B0BEKoAR.js → vendor-CS5YMf8a.js} +74 -69
- solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
- solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
- solace_agent_mesh/common/services/identity_service.py +2 -1
- solace_agent_mesh/common/services/providers/local_file_identity_service.py +1 -1
- solace_agent_mesh/common/utils/pydantic_utils.py +60 -0
- solace_agent_mesh/config_portal/backend/plugin_catalog/registry_manager.py +6 -4
- solace_agent_mesh/gateway/base/app.py +69 -120
- solace_agent_mesh/gateway/http_sse/app.py +99 -150
- solace_agent_mesh/gateway/http_sse/component.py +57 -30
- solace_agent_mesh/gateway/http_sse/main.py +337 -375
- solace_agent_mesh/gateway/http_sse/sse_event_buffer.py +87 -0
- solace_agent_mesh/gateway/http_sse/sse_manager.py +44 -23
- solace_agent_mesh/templates/webui.yaml +1 -1
- {solace_agent_mesh-1.3.3.dist-info → solace_agent_mesh-1.4.1.dist-info}/METADATA +7 -1
- {solace_agent_mesh-1.3.3.dist-info → solace_agent_mesh-1.4.1.dist-info}/RECORD +82 -78
- solace_agent_mesh/assets/docs/assets/js/42b3f8d8.3f34bf76.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/9a09e75d.5a319fd4.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/ae4415af.24cdc514.js +0 -1
- solace_agent_mesh/assets/docs/lunr-index-1757873594308.json +0 -1
- solace_agent_mesh/assets/docs/search-doc-1757873594308.json +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-C03yrETa.css +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-DjoMeldu.js +0 -339
- /solace_agent_mesh/assets/docs/assets/js/{main.e82b32e6.js.LICENSE.txt → main.9bc1a102.js.LICENSE.txt} +0 -0
- {solace_agent_mesh-1.3.3.dist-info → solace_agent_mesh-1.4.1.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-1.3.3.dist-info → solace_agent_mesh-1.4.1.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.3.3.dist-info → solace_agent_mesh-1.4.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
var Ap=Object.defineProperty;var Np=(e,t,n)=>t in e?Ap(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ca=(e,t,n)=>Np(e,typeof t!="symbol"?t+"":t,n);import{c as kp}from"./client-B9p_nFNA.js";import{r as u,j as a,c as Fl,a as Ur,R as pi,b as _p,N as po,X as Ro,E as Ip,d as Ft,C as zl,e as mi,f as jp,A as $l,L as hi,g as gi,P as Bl,B as Mp,S as Rp,F as ua,h as Pp,i as Lp,k as sr,l as Dp,m as Op,n as Fp,o as Ul,D as xi,p as Hl,q as zp,T as $p,M as Wl,I as vi,s as Gl,t as Bp,u as Up,v as Hp,w as Vl,x as Wp,y as Yl,z as Gp,G as Vp,H as da,J as Yp,K as Kl,O as ql,Q as Kp,U as Xe,V as Ze,W as Xl,Y as qp,Z as Xp,_ as fa,$ as pa,a0 as cs,a1 as Zp,a2 as Jp,a3 as Qp,a4 as em,a5 as tm,a6 as nm,a7 as rm,a8 as om,a9 as sm,aa as im,ab as am,ac as Zl,ad as Jl,ae as lm,af as ma,ag as ha,ah as cm,ai as ga,aj as um,ak as dm,al as fm}from"./vendor-CS5YMf8a.js";function xa(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ql(...e){return t=>{let n=!1;const r=e.map(o=>{const s=xa(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():xa(e[o],null)}}}}function Oe(...e){return u.useCallback(Ql(...e),e)}function Pn(e){const t=pm(e),n=u.forwardRef((r,o)=>{const{children:s,...i}=r,l=u.Children.toArray(s),c=l.find(hm);if(c){const f=c.props.children,d=l.map(p=>p===c?u.Children.count(f)>1?u.Children.only(null):u.isValidElement(f)?f.props.children:null:p);return a.jsx(t,{...i,ref:o,children:u.isValidElement(f)?u.cloneElement(f,void 0,d):null})}return a.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var ec=Pn("Slot");function pm(e){const t=u.forwardRef((n,r)=>{const{children:o,...s}=n;if(u.isValidElement(o)){const i=xm(o),l=gm(s,o.props);return o.type!==u.Fragment&&(l.ref=r?Ql(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 tc=Symbol("radix.slottable");function mm(e){const t=({children:n})=>a.jsx(a.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=tc,t}function hm(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tc}function gm(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 xm(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 va=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,wa=Fl,Tn=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return wa(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(f=>{const d=n==null?void 0:n[f],p=s==null?void 0:s[f];if(d===null)return null;const m=va(d)||va(p);return o[f][m]}),l=n&&Object.entries(n).reduce((f,d)=>{let[p,m]=d;return m===void 0||(f[p]=m),f},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((f,d)=>{let{class:p,className:m,...g}=d;return Object.entries(g).every(x=>{let[h,v]=x;return Array.isArray(v)?v.includes({...s,...l}[h]):{...s,...l}[h]===v})?[...f,p,m]:f},[]);return wa(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},wi=()=>localStorage.getItem("access_token"),vm=()=>localStorage.getItem("refresh_token"),wm=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},bm=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},ym=async()=>{const e=vm();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 wm(n.access_token,n.refresh_token),n.access_token}return bm(),window.location.href="/api/v1/auth/login",null},De=async(e,t={})=>{const n=wi();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 ym();if(o)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${o}`}})}return r},bi="-",Sm=e=>{const t=Em(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(bi);return l[0]===""&&l.length!==1&&l.shift(),nc(l,t)||Cm(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},nc=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?nc(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const s=e.join(bi);return(i=t.validators.find(({validator:l})=>l(s)))==null?void 0:i.classGroupId},ba=/^\[(.+)\]$/,Cm=e=>{if(ba.test(e)){const t=ba.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Em=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const o in n)Os(n[o],r,o,t);return r},Os=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const s=o===""?t:ya(t,o);s.classGroupId=n;return}if(typeof o=="function"){if(Tm(o)){Os(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([s,i])=>{Os(i,ya(t,s),n,r)})})},ya=(e,t)=>{let n=e;return t.split(bi).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Tm=e=>e.isThemeGetter,Am=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)}}},Fs="!",zs=":",Nm=zs.length,km=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,l=0,c=0,f;for(let x=0;x<o.length;x++){let h=o[x];if(i===0&&l===0){if(h===zs){s.push(o.slice(c,x)),c=x+Nm;continue}if(h==="/"){f=x;continue}}h==="["?i++:h==="]"?i--:h==="("?l++:h===")"&&l--}const d=s.length===0?o:o.substring(c),p=_m(d),m=p!==d,g=f&&f>c?f-c:void 0;return{modifiers:s,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:g}};if(t){const o=t+zs,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},_m=e=>e.endsWith(Fs)?e.substring(0,e.length-1):e.startsWith(Fs)?e.substring(1):e,Im=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}},jm=e=>({cache:Am(e.cacheSize),parseClassName:km(e),sortModifiers:Im(e),...Sm(e)}),Mm=/\s+/,Rm=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],l=e.trim().split(Mm);let c="";for(let f=l.length-1;f>=0;f-=1){const d=l[f],{isExternal:p,modifiers:m,hasImportantModifier:g,baseClassName:x,maybePostfixModifierPosition:h}=n(d);if(p){c=d+(c.length>0?" "+c:c);continue}let v=!!h,b=r(v?x.substring(0,h):x);if(!b){if(!v){c=d+(c.length>0?" "+c:c);continue}if(b=r(x),!b){c=d+(c.length>0?" "+c:c);continue}v=!1}const w=s(m).join(":"),y=g?w+Fs:w,E=y+b;if(i.includes(E))continue;i.push(E);const k=o(b,v);for(let I=0;I<k.length;++I){const A=k[I];i.push(y+A)}c=d+(c.length>0?" "+c:c)}return c};function Pm(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=rc(t))&&(r&&(r+=" "),r+=n);return r}const rc=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=rc(e[r]))&&(n&&(n+=" "),n+=t);return n};function Lm(e,...t){let n,r,o,s=i;function i(c){const f=t.reduce((d,p)=>p(d),e());return n=jm(f),r=n.cache.get,o=n.cache.set,s=l,l(c)}function l(c){const f=r(c);if(f)return f;const d=Rm(c,n);return o(c,d),d}return function(){return s(Pm.apply(null,arguments))}}const Ve=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},oc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,sc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Dm=/^\d+\/\d+$/,Om=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Fm=/\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$/,zm=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$m=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Bm=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Wn=e=>Dm.test(e),Te=e=>!!e&&!Number.isNaN(Number(e)),gn=e=>!!e&&Number.isInteger(Number(e)),us=e=>e.endsWith("%")&&Te(e.slice(0,-1)),an=e=>Om.test(e),Um=()=>!0,Hm=e=>Fm.test(e)&&!zm.test(e),ic=()=>!1,Wm=e=>$m.test(e),Gm=e=>Bm.test(e),Vm=e=>!oe(e)&&!se(e),Ym=e=>pr(e,cc,ic),oe=e=>oc.test(e),In=e=>pr(e,uc,Hm),ds=e=>pr(e,Jm,Te),Sa=e=>pr(e,ac,ic),Km=e=>pr(e,lc,Gm),Zr=e=>pr(e,dc,Wm),se=e=>sc.test(e),yr=e=>mr(e,uc),qm=e=>mr(e,Qm),Ca=e=>mr(e,ac),Xm=e=>mr(e,cc),Zm=e=>mr(e,lc),Jr=e=>mr(e,dc,!0),pr=(e,t,n)=>{const r=oc.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},mr=(e,t,n=!1)=>{const r=sc.exec(e);return r?r[1]?t(r[1]):n:!1},ac=e=>e==="position"||e==="percentage",lc=e=>e==="image"||e==="url",cc=e=>e==="length"||e==="size"||e==="bg-size",uc=e=>e==="length",Jm=e=>e==="number",Qm=e=>e==="family-name",dc=e=>e==="shadow",eh=()=>{const e=Ve("color"),t=Ve("font"),n=Ve("text"),r=Ve("font-weight"),o=Ve("tracking"),s=Ve("leading"),i=Ve("breakpoint"),l=Ve("container"),c=Ve("spacing"),f=Ve("radius"),d=Ve("shadow"),p=Ve("inset-shadow"),m=Ve("text-shadow"),g=Ve("drop-shadow"),x=Ve("blur"),h=Ve("perspective"),v=Ve("aspect"),b=Ve("ease"),w=Ve("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"],k=()=>[...E(),se,oe],I=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],T=()=>[se,oe,c],Y=()=>[Wn,"full","auto",...T()],Z=()=>[gn,"none","subgrid",se,oe],G=()=>["auto",{span:["full",gn,se,oe]},gn,se,oe],q=()=>[gn,"auto",se,oe],te=()=>["auto","min","max","fr",se,oe],D=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],N=()=>["auto",...T()],M=()=>[Wn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],S=()=>[e,se,oe],O=()=>[...E(),Ca,Sa,{position:[se,oe]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],R=()=>["auto","cover","contain",Xm,Ym,{size:[se,oe]}],ee=()=>[us,yr,In],L=()=>["","none","full",f,se,oe],H=()=>["",Te,yr,In],j=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],_=()=>[Te,us,Ca,Sa],V=()=>["","none",x,se,oe],J=()=>["none",Te,se,oe],ne=()=>["none",Te,se,oe],ie=()=>[Te,se,oe],re=()=>[Wn,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[an],breakpoint:[an],color:[Um],container:[an],"drop-shadow":[an],ease:["in","out","in-out"],font:[Vm],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[an],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[an],shadow:[an],spacing:["px",Te],text:[an],"text-shadow":[an],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Wn,oe,se,v]}],container:["container"],columns:[{columns:[Te,oe,se,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:k()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Y()}],"inset-x":[{"inset-x":Y()}],"inset-y":[{"inset-y":Y()}],start:[{start:Y()}],end:[{end:Y()}],top:[{top:Y()}],right:[{right:Y()}],bottom:[{bottom:Y()}],left:[{left:Y()}],visibility:["visible","invisible","collapse"],z:[{z:[gn,"auto",se,oe]}],basis:[{basis:[Wn,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Te,Wn,"auto","initial","none",oe]}],grow:[{grow:["",Te,se,oe]}],shrink:[{shrink:["",Te,se,oe]}],order:[{order:[gn,"first","last","none",se,oe]}],"grid-cols":[{"grid-cols":Z()}],"col-start-end":[{col:G()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":Z()}],"row-start-end":[{row:G()}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":te()}],"auto-rows":[{"auto-rows":te()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...D(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...D()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":D()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],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:N()}],mx:[{mx:N()}],my:[{my:N()}],ms:[{ms:N()}],me:[{me:N()}],mt:[{mt:N()}],mr:[{mr:N()}],mb:[{mb:N()}],ml:[{ml:N()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:M()}],w:[{w:[l,"screen",...M()]}],"min-w":[{"min-w":[l,"screen","none",...M()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...M()]}],h:[{h:["screen","lh",...M()]}],"min-h":[{"min-h":["screen","lh","none",...M()]}],"max-h":[{"max-h":["screen","lh",...M()]}],"font-size":[{text:["base",n,yr,In]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,se,ds]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",us,oe]}],"font-family":[{font:[qm,oe,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,se,oe]}],"line-clamp":[{"line-clamp":[Te,"none",se,ds]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",se,oe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",se,oe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:S()}],"text-color":[{text:S()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...j(),"wavy"]}],"text-decoration-thickness":[{decoration:[Te,"from-font","auto",se,In]}],"text-decoration-color":[{decoration:S()}],"underline-offset":[{"underline-offset":[Te,"auto",se,oe]}],"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",se,oe]}],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",se,oe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:O()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:R()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},gn,se,oe],radial:["",se,oe],conic:[gn,se,oe]},Zm,Km]}],"bg-color":[{bg:S()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:S()}],"gradient-via":[{via:S()}],"gradient-to":[{to:S()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":H()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...j(),"hidden","none"]}],"divide-style":[{divide:[...j(),"hidden","none"]}],"border-color":[{border:S()}],"border-color-x":[{"border-x":S()}],"border-color-y":[{"border-y":S()}],"border-color-s":[{"border-s":S()}],"border-color-e":[{"border-e":S()}],"border-color-t":[{"border-t":S()}],"border-color-r":[{"border-r":S()}],"border-color-b":[{"border-b":S()}],"border-color-l":[{"border-l":S()}],"divide-color":[{divide:S()}],"outline-style":[{outline:[...j(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Te,se,oe]}],"outline-w":[{outline:["",Te,yr,In]}],"outline-color":[{outline:S()}],shadow:[{shadow:["","none",d,Jr,Zr]}],"shadow-color":[{shadow:S()}],"inset-shadow":[{"inset-shadow":["none",p,Jr,Zr]}],"inset-shadow-color":[{"inset-shadow":S()}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:S()}],"ring-offset-w":[{"ring-offset":[Te,In]}],"ring-offset-color":[{"ring-offset":S()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":S()}],"text-shadow":[{"text-shadow":["none",m,Jr,Zr]}],"text-shadow-color":[{"text-shadow":S()}],opacity:[{opacity:[Te,se,oe]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"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":[Te]}],"mask-image-linear-from-pos":[{"mask-linear-from":_()}],"mask-image-linear-to-pos":[{"mask-linear-to":_()}],"mask-image-linear-from-color":[{"mask-linear-from":S()}],"mask-image-linear-to-color":[{"mask-linear-to":S()}],"mask-image-t-from-pos":[{"mask-t-from":_()}],"mask-image-t-to-pos":[{"mask-t-to":_()}],"mask-image-t-from-color":[{"mask-t-from":S()}],"mask-image-t-to-color":[{"mask-t-to":S()}],"mask-image-r-from-pos":[{"mask-r-from":_()}],"mask-image-r-to-pos":[{"mask-r-to":_()}],"mask-image-r-from-color":[{"mask-r-from":S()}],"mask-image-r-to-color":[{"mask-r-to":S()}],"mask-image-b-from-pos":[{"mask-b-from":_()}],"mask-image-b-to-pos":[{"mask-b-to":_()}],"mask-image-b-from-color":[{"mask-b-from":S()}],"mask-image-b-to-color":[{"mask-b-to":S()}],"mask-image-l-from-pos":[{"mask-l-from":_()}],"mask-image-l-to-pos":[{"mask-l-to":_()}],"mask-image-l-from-color":[{"mask-l-from":S()}],"mask-image-l-to-color":[{"mask-l-to":S()}],"mask-image-x-from-pos":[{"mask-x-from":_()}],"mask-image-x-to-pos":[{"mask-x-to":_()}],"mask-image-x-from-color":[{"mask-x-from":S()}],"mask-image-x-to-color":[{"mask-x-to":S()}],"mask-image-y-from-pos":[{"mask-y-from":_()}],"mask-image-y-to-pos":[{"mask-y-to":_()}],"mask-image-y-from-color":[{"mask-y-from":S()}],"mask-image-y-to-color":[{"mask-y-to":S()}],"mask-image-radial":[{"mask-radial":[se,oe]}],"mask-image-radial-from-pos":[{"mask-radial-from":_()}],"mask-image-radial-to-pos":[{"mask-radial-to":_()}],"mask-image-radial-from-color":[{"mask-radial-from":S()}],"mask-image-radial-to-color":[{"mask-radial-to":S()}],"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":[Te]}],"mask-image-conic-from-pos":[{"mask-conic-from":_()}],"mask-image-conic-to-pos":[{"mask-conic-to":_()}],"mask-image-conic-from-color":[{"mask-conic-from":S()}],"mask-image-conic-to-color":[{"mask-conic-to":S()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:O()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:R()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",se,oe]}],filter:[{filter:["","none",se,oe]}],blur:[{blur:V()}],brightness:[{brightness:[Te,se,oe]}],contrast:[{contrast:[Te,se,oe]}],"drop-shadow":[{"drop-shadow":["","none",g,Jr,Zr]}],"drop-shadow-color":[{"drop-shadow":S()}],grayscale:[{grayscale:["",Te,se,oe]}],"hue-rotate":[{"hue-rotate":[Te,se,oe]}],invert:[{invert:["",Te,se,oe]}],saturate:[{saturate:[Te,se,oe]}],sepia:[{sepia:["",Te,se,oe]}],"backdrop-filter":[{"backdrop-filter":["","none",se,oe]}],"backdrop-blur":[{"backdrop-blur":V()}],"backdrop-brightness":[{"backdrop-brightness":[Te,se,oe]}],"backdrop-contrast":[{"backdrop-contrast":[Te,se,oe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Te,se,oe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Te,se,oe]}],"backdrop-invert":[{"backdrop-invert":["",Te,se,oe]}],"backdrop-opacity":[{"backdrop-opacity":[Te,se,oe]}],"backdrop-saturate":[{"backdrop-saturate":[Te,se,oe]}],"backdrop-sepia":[{"backdrop-sepia":["",Te,se,oe]}],"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",se,oe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Te,"initial",se,oe]}],ease:[{ease:["linear","initial",b,se,oe]}],delay:[{delay:[Te,se,oe]}],animate:[{animate:["none",w,se,oe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,se,oe]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:ne()}],"scale-x":[{"scale-x":ne()}],"scale-y":[{"scale-y":ne()}],"scale-z":[{"scale-z":ne()}],"scale-3d":["scale-3d"],skew:[{skew:ie()}],"skew-x":[{"skew-x":ie()}],"skew-y":[{"skew-y":ie()}],transform:[{transform:[se,oe,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:re()}],"translate-x":[{"translate-x":re()}],"translate-y":[{"translate-y":re()}],"translate-z":[{"translate-z":re()}],"translate-none":["translate-none"],accent:[{accent:S()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:S()}],"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",se,oe]}],"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",se,oe]}],fill:[{fill:["none",...S()]}],"stroke-w":[{stroke:[Te,yr,In,ds]}],stroke:[{stroke:["none",...S()]}],"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"]}},th=Lm(eh);function Se(...e){return th(Fl(e))}const nh=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}},fc=(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)}},rh=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=nh(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 De(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.");fc(t,n)}catch(t){console.error("Error creating download link:",t)}},pc=(e,t=2)=>{if(e===0)return"0 Bytes";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]},Ea=e=>{try{const t=new Date(e),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),e}},Ta=(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," "),oh=(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 me(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 sh(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 An(e,t=[]){let n=[];function r(s,i){const l=u.createContext(i),c=n.length;n=[...n,i];const f=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})};f.displayName=s+"Provider";function d(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[f,d]}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,ih(o,...t)]}function ih(...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:f})=>{const p=c(s)[`__scope${f}`];return{...l,...p}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var ah=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_e=ah.reduce((e,t)=>{const n=Pn(`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 lh(e,t){e&&Ur.flushSync(()=>e.dispatchEvent(t))}function yn(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 ch(e,t=globalThis==null?void 0:globalThis.document){const n=yn(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 uh="DismissableLayer",$s="dismissableLayer.update",dh="dismissableLayer.pointerDownOutside",fh="dismissableLayer.focusOutside",Aa,mc=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Hr=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:l,...c}=e,f=u.useContext(mc),[d,p]=u.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=u.useState({}),x=Oe(t,A=>p(A)),h=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=h.indexOf(v),w=d?h.indexOf(d):-1,y=f.layersWithOutsidePointerEventsDisabled.size>0,E=w>=b,k=hh(A=>{const T=A.target,Y=[...f.branches].some(Z=>Z.contains(T));!E||Y||(o==null||o(A),i==null||i(A),A.defaultPrevented||l==null||l())},m),I=gh(A=>{const T=A.target;[...f.branches].some(Z=>Z.contains(T))||(s==null||s(A),i==null||i(A),A.defaultPrevented||l==null||l())},m);return ch(A=>{w===f.layers.size-1&&(r==null||r(A),!A.defaultPrevented&&l&&(A.preventDefault(),l()))},m),u.useEffect(()=>{if(d)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Aa=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(d)),f.layers.add(d),Na(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Aa)}},[d,m,n,f]),u.useEffect(()=>()=>{d&&(f.layers.delete(d),f.layersWithOutsidePointerEventsDisabled.delete(d),Na())},[d,f]),u.useEffect(()=>{const A=()=>g({});return document.addEventListener($s,A),()=>document.removeEventListener($s,A)},[]),a.jsx(_e.div,{...c,ref:x,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:me(e.onFocusCapture,I.onFocusCapture),onBlurCapture:me(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:me(e.onPointerDownCapture,k.onPointerDownCapture)})});Hr.displayName=uh;var ph="DismissableLayerBranch",mh=u.forwardRef((e,t)=>{const n=u.useContext(mc),r=u.useRef(null),o=Oe(t,r);return u.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),a.jsx(_e.div,{...e,ref:o})});mh.displayName=ph;function hh(e,t=globalThis==null?void 0:globalThis.document){const n=yn(e),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){hc(dh,n,f,{discrete:!0})};const f={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 gh(e,t=globalThis==null?void 0:globalThis.document){const n=yn(e),r=u.useRef(!1);return u.useEffect(()=>{const o=s=>{s.target&&!r.current&&hc(fh,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 Na(){const e=new CustomEvent($s);document.dispatchEvent(e)}function hc(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?lh(o,s):o.dispatchEvent(s)}var nt=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},xh=pi[" useId ".trim().toString()]||(()=>{}),vh=0;function Zt(e){const[t,n]=u.useState(xh());return nt(()=>{n(r=>r??String(vh++))},[e]),t?`radix-${t}`:""}const wh=["top","right","bottom","left"],Sn=Math.min,bt=Math.max,wo=Math.round,Qr=Math.floor,Jt=e=>({x:e,y:e}),bh={left:"right",right:"left",bottom:"top",top:"bottom"},yh={start:"end",end:"start"};function Bs(e,t,n){return bt(e,Sn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function hr(e){return e.split("-")[1]}function yi(e){return e==="x"?"y":"x"}function Si(e){return e==="y"?"height":"width"}const Sh=new Set(["top","bottom"]);function qt(e){return Sh.has(fn(e))?"y":"x"}function Ci(e){return yi(qt(e))}function Ch(e,t,n){n===void 0&&(n=!1);const r=hr(e),o=Ci(e),s=Si(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=bo(i)),[i,bo(i)]}function Eh(e){const t=bo(e);return[Us(e),t,Us(t)]}function Us(e){return e.replace(/start|end/g,t=>yh[t])}const ka=["left","right"],_a=["right","left"],Th=["top","bottom"],Ah=["bottom","top"];function Nh(e,t,n){switch(e){case"top":case"bottom":return n?t?_a:ka:t?ka:_a;case"left":case"right":return t?Th:Ah;default:return[]}}function kh(e,t,n,r){const o=hr(e);let s=Nh(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Us)))),s}function bo(e){return e.replace(/left|right|bottom|top/g,t=>bh[t])}function _h(e){return{top:0,right:0,bottom:0,left:0,...e}}function gc(e){return typeof e!="number"?_h(e):{top:e,right:e,bottom:e,left:e}}function yo(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 Ia(e,t,n){let{reference:r,floating:o}=e;const s=qt(t),i=Ci(t),l=Si(i),c=fn(t),f=s==="y",d=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:d,y:r.y-o.height};break;case"bottom":g={x:d,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(hr(t)){case"start":g[i]-=m*(n&&f?-1:1);break;case"end":g[i]+=m*(n&&f?-1:1);break}return g}const Ih=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 f=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=Ia(f,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:k}=await b({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:f,platform:i,elements:{reference:e,floating:t}});d=w??d,p=y??p,g={...g,[v]:{...g[v],...E}},k&&x<=50&&(x++,typeof k=="object"&&(k.placement&&(m=k.placement),k.rects&&(f=k.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:d,y:p}=Ia(f,m,c)),h=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:g}};async function Rr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:l,strategy:c}=e,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:g=0}=dn(t,e),x=gc(g),v=l[m?p==="floating"?"reference":"floating":p],b=yo(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:f,rootBoundary:d,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},k=yo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:y,strategy:c}):w);return{top:(b.top-k.top+x.top)/E.y,bottom:(k.bottom-b.bottom+x.bottom)/E.y,left:(b.left-k.left+x.left)/E.x,right:(k.right-b.right+x.right)/E.x}}const jh=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:f,padding:d=0}=dn(e,t)||{};if(f==null)return{};const p=gc(d),m={x:n,y:r},g=Ci(o),x=Si(g),h=await i.getDimensions(f),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],k=m[g]-s.reference[g],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f));let A=I?I[y]:0;(!A||!await(i.isElement==null?void 0:i.isElement(I)))&&(A=l.floating[y]||s.floating[x]);const T=E/2-k/2,Y=A/2-h[x]/2-1,Z=Sn(p[b],Y),G=Sn(p[w],Y),q=Z,te=A-h[x]-G,D=A/2-h[x]/2+T,X=Bs(q,D,te),N=!c.arrow&&hr(o)!=null&&D!==X&&s.reference[x]/2-(D<q?Z:G)-h[x]/2<0,M=N?D<q?D-q:D-te:0;return{[g]:m[g]+M,data:{[g]:X,centerOffset:D-X-M,...N&&{alignmentOffset:M}},reset:N}}}),Mh=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:f}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:h=!0,...v}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=fn(o),w=qt(l),y=fn(l)===l,E=await(c.isRTL==null?void 0:c.isRTL(f.floating)),k=m||(y||!h?[bo(l)]:Eh(l)),I=x!=="none";!m&&I&&k.push(...kh(l,h,x,E));const A=[l,...k],T=await Rr(t,v),Y=[];let Z=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&Y.push(T[b]),p){const D=Ch(o,i,E);Y.push(T[D[0]],T[D[1]])}if(Z=[...Z,{placement:o,overflows:Y}],!Y.every(D=>D<=0)){var G,q;const D=(((G=s.flip)==null?void 0:G.index)||0)+1,X=A[D];if(X&&(!(p==="alignment"?w!==qt(X):!1)||Z.every(S=>qt(S.placement)===w?S.overflows[0]>0:!0)))return{data:{index:D,overflows:Z},reset:{placement:X}};let N=(q=Z.filter(M=>M.overflows[0]<=0).sort((M,S)=>M.overflows[1]-S.overflows[1])[0])==null?void 0:q.placement;if(!N)switch(g){case"bestFit":{var te;const M=(te=Z.filter(S=>{if(I){const O=qt(S.placement);return O===w||O==="y"}return!0}).map(S=>[S.placement,S.overflows.filter(O=>O>0).reduce((O,P)=>O+P,0)]).sort((S,O)=>S[1]-O[1])[0])==null?void 0:te[0];M&&(N=M);break}case"initialPlacement":N=l;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function ja(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ma(e){return wh.some(t=>e[t]>=0)}const Rh=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dn(e,t);switch(r){case"referenceHidden":{const s=await Rr(t,{...o,elementContext:"reference"}),i=ja(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Ma(i)}}}case"escaped":{const s=await Rr(t,{...o,altBoundary:!0}),i=ja(s,n.floating);return{data:{escapedOffsets:i,escaped:Ma(i)}}}default:return{}}}}},xc=new Set(["left","top"]);async function Ph(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),l=hr(n),c=qt(n)==="y",f=xc.has(i)?-1:1,d=s&&c?-1:1,p=dn(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*d,y:m*f}:{x:m*f,y:g*d}}const Lh=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 Ph(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}}}}},Dh=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}=dn(e,t),f={x:n,y:r},d=await Rr(t,c),p=qt(fn(o)),m=yi(p);let g=f[m],x=f[p];if(s){const v=m==="y"?"top":"left",b=m==="y"?"bottom":"right",w=g+d[v],y=g-d[b];g=Bs(w,g,y)}if(i){const v=p==="y"?"top":"left",b=p==="y"?"bottom":"right",w=x+d[v],y=x-d[b];x=Bs(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}}}}}},Oh=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:f=!0}=dn(e,t),d={x:n,y:r},p=qt(o),m=yi(p);let g=d[m],x=d[p];const h=dn(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,k=s.reference[m]+s.reference[y]-v.mainAxis;g<E?g=E:g>k&&(g=k)}if(f){var b,w;const y=m==="y"?"width":"height",E=xc.has(fn(o)),k=s.reference[p]-s.floating[y]+(E&&((b=i.offset)==null?void 0:b[p])||0)+(E?0:v.crossAxis),I=s.reference[p]+s.reference[y]+(E?0:((w=i.offset)==null?void 0:w[p])||0)-(E?v.crossAxis:0);x<k?x=k:x>I&&(x=I)}return{[m]:g,[p]:x}}}},Fh=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=()=>{},...f}=dn(e,t),d=await Rr(t,f),p=fn(o),m=hr(o),g=qt(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-d.top-d.bottom,y=x-d.left-d.right,E=Sn(h-d[v],w),k=Sn(x-d[b],y),I=!t.middlewareData.shift;let A=E,T=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(A=w),I&&!m){const Z=bt(d.left,0),G=bt(d.right,0),q=bt(d.top,0),te=bt(d.bottom,0);g?T=x-2*(Z!==0||G!==0?Z+G:bt(d.left,d.right)):A=h-2*(q!==0||te!==0?q+te:bt(d.top,d.bottom))}await c({...t,availableWidth:T,availableHeight:A});const Y=await i.getDimensions(l.floating);return x!==Y.width||h!==Y.height?{reset:{rects:!0}}:{}}}};function Po(){return typeof window<"u"}function gr(e){return vc(e)?(e.nodeName||"").toLowerCase():"#document"}function St(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function tn(e){var t;return(t=(vc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vc(e){return Po()?e instanceof Node||e instanceof St(e).Node:!1}function $t(e){return Po()?e instanceof Element||e instanceof St(e).Element:!1}function en(e){return Po()?e instanceof HTMLElement||e instanceof St(e).HTMLElement:!1}function Ra(e){return!Po()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof St(e).ShadowRoot}const zh=new Set(["inline","contents"]);function Wr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Bt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!zh.has(o)}const $h=new Set(["table","td","th"]);function Bh(e){return $h.has(gr(e))}const Uh=[":popover-open",":modal"];function Lo(e){return Uh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Hh=["transform","translate","scale","rotate","perspective"],Wh=["transform","translate","scale","rotate","perspective","filter"],Gh=["paint","layout","strict","content"];function Ei(e){const t=Ti(),n=$t(e)?Bt(e):e;return Hh.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)||Wh.some(r=>(n.willChange||"").includes(r))||Gh.some(r=>(n.contain||"").includes(r))}function Vh(e){let t=Cn(e);for(;en(t)&&!ir(t);){if(Ei(t))return t;if(Lo(t))return null;t=Cn(t)}return null}function Ti(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Yh=new Set(["html","body","#document"]);function ir(e){return Yh.has(gr(e))}function Bt(e){return St(e).getComputedStyle(e)}function Do(e){return $t(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Cn(e){if(gr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ra(e)&&e.host||tn(e);return Ra(t)?t.host:t}function wc(e){const t=Cn(e);return ir(t)?e.ownerDocument?e.ownerDocument.body:e.body:en(t)&&Wr(t)?t:wc(t)}function Pr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=St(o);if(s){const l=Hs(i);return t.concat(i,i.visualViewport||[],Wr(o)?o:[],l&&n?Pr(l):[])}return t.concat(o,Pr(o,[],n))}function Hs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bc(e){const t=Bt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=en(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=wo(n)!==s||wo(r)!==i;return l&&(n=s,r=i),{width:n,height:r,$:l}}function Ai(e){return $t(e)?e:e.contextElement}function tr(e){const t=Ai(e);if(!en(t))return Jt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=bc(t);let i=(s?wo(n.width):n.width)/r,l=(s?wo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Kh=Jt(0);function yc(e){const t=St(e);return!Ti()||!t.visualViewport?Kh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function qh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==St(e)?!1:t}function Ln(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ai(e);let i=Jt(1);t&&(r?$t(r)&&(i=tr(r)):i=tr(e));const l=qh(s,n,r)?yc(s):Jt(0);let c=(o.left+l.x)/i.x,f=(o.top+l.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=St(s),g=r&&$t(r)?St(r):r;let x=m,h=Hs(x);for(;h&&r&&g!==x;){const v=tr(h),b=h.getBoundingClientRect(),w=Bt(h),y=b.left+(h.clientLeft+parseFloat(w.paddingLeft))*v.x,E=b.top+(h.clientTop+parseFloat(w.paddingTop))*v.y;c*=v.x,f*=v.y,d*=v.x,p*=v.y,c+=y,f+=E,x=St(h),h=Hs(x)}}return yo({width:d,height:p,x:c,y:f})}function Oo(e,t){const n=Do(e).scrollLeft;return t?t.left+n:Ln(tn(e)).left+n}function Sc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Oo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Xh(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=tn(r),l=t?Lo(t.floating):!1;if(r===i||l&&s)return n;let c={scrollLeft:0,scrollTop:0},f=Jt(1);const d=Jt(0),p=en(r);if((p||!p&&!s)&&((gr(r)!=="body"||Wr(i))&&(c=Do(r)),en(r))){const g=Ln(r);f=tr(r),d.x=g.x+r.clientLeft,d.y=g.y+r.clientTop}const m=i&&!p&&!s?Sc(i,c):Jt(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-c.scrollLeft*f.x+d.x+m.x,y:n.y*f.y-c.scrollTop*f.y+d.y+m.y}}function Zh(e){return Array.from(e.getClientRects())}function Jh(e){const t=tn(e),n=Do(e),r=e.ownerDocument.body,o=bt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=bt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Oo(e);const l=-n.scrollTop;return Bt(r).direction==="rtl"&&(i+=bt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:l}}const Pa=25;function Qh(e,t){const n=St(e),r=tn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,l=0,c=0;if(o){s=o.width,i=o.height;const d=Ti();(!d||d&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const f=Oo(r);if(f<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),g=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-g);x<=Pa&&(s-=x)}else f<=Pa&&(s+=f);return{width:s,height:i,x:l,y:c}}const eg=new Set(["absolute","fixed"]);function tg(e,t){const n=Ln(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=en(e)?tr(e):Jt(1),i=e.clientWidth*s.x,l=e.clientHeight*s.y,c=o*s.x,f=r*s.y;return{width:i,height:l,x:c,y:f}}function La(e,t,n){let r;if(t==="viewport")r=Qh(e,n);else if(t==="document")r=Jh(tn(e));else if($t(t))r=tg(t,n);else{const o=yc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return yo(r)}function Cc(e,t){const n=Cn(e);return n===t||!$t(n)||ir(n)?!1:Bt(n).position==="fixed"||Cc(n,t)}function ng(e,t){const n=t.get(e);if(n)return n;let r=Pr(e,[],!1).filter(l=>$t(l)&&gr(l)!=="body"),o=null;const s=Bt(e).position==="fixed";let i=s?Cn(e):e;for(;$t(i)&&!ir(i);){const l=Bt(i),c=Ei(i);!c&&l.position==="fixed"&&(o=null),(s?!c&&!o:!c&&l.position==="static"&&!!o&&eg.has(o.position)||Wr(i)&&!c&&Cc(e,i))?r=r.filter(d=>d!==i):o=l,i=Cn(i)}return t.set(e,r),r}function rg(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Lo(t)?[]:ng(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((f,d)=>{const p=La(t,d,o);return f.top=bt(p.top,f.top),f.right=Sn(p.right,f.right),f.bottom=Sn(p.bottom,f.bottom),f.left=bt(p.left,f.left),f},La(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function og(e){const{width:t,height:n}=bc(e);return{width:t,height:n}}function sg(e,t,n){const r=en(t),o=tn(t),s=n==="fixed",i=Ln(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=Jt(0);function f(){c.x=Oo(o)}if(r||!r&&!s)if((gr(t)!=="body"||Wr(o))&&(l=Do(t)),r){const g=Ln(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&f();s&&!r&&o&&f();const d=o&&!r&&!s?Sc(o,l):Jt(0),p=i.left+l.scrollLeft-c.x-d.x,m=i.top+l.scrollTop-c.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function fs(e){return Bt(e).position==="static"}function Da(e,t){if(!en(e)||Bt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return tn(e)===n&&(n=n.ownerDocument.body),n}function Ec(e,t){const n=St(e);if(Lo(e))return n;if(!en(e)){let o=Cn(e);for(;o&&!ir(o);){if($t(o)&&!fs(o))return o;o=Cn(o)}return n}let r=Da(e,t);for(;r&&Bh(r)&&fs(r);)r=Da(r,t);return r&&ir(r)&&fs(r)&&!Ei(r)?n:r||Vh(e)||n}const ig=async function(e){const t=this.getOffsetParent||Ec,n=this.getDimensions,r=await n(e.floating);return{reference:sg(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ag(e){return Bt(e).direction==="rtl"}const lg={convertOffsetParentRelativeRectToViewportRelativeRect:Xh,getDocumentElement:tn,getClippingRect:rg,getOffsetParent:Ec,getElementRects:ig,getClientRects:Zh,getDimensions:og,getScale:tr,isElement:$t,isRTL:ag};function Tc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cg(e,t){let n=null,r;const o=tn(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 f=e.getBoundingClientRect(),{left:d,top:p,width:m,height:g}=f;if(l||t(),!m||!g)return;const x=Qr(p),h=Qr(o.clientWidth-(d+m)),v=Qr(o.clientHeight-(p+g)),b=Qr(d),y={rootMargin:-x+"px "+-h+"px "+-v+"px "+-b+"px",threshold:bt(0,Sn(1,c))||1};let E=!0;function k(I){const A=I[0].intersectionRatio;if(A!==c){if(!E)return i();A?i(!1,A):r=setTimeout(()=>{i(!1,1e-7)},1e3)}A===1&&!Tc(f,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(k,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,y)}n.observe(e)}return i(!0),s}function ug(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,f=Ai(e),d=o||s?[...f?Pr(f):[],...Pr(t)]:[];d.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const p=f&&l?cg(f,n):null;let m=-1,g=null;i&&(g=new ResizeObserver(b=>{let[w]=b;w&&w.target===f&&g&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=g)==null||y.observe(t)})),n()}),f&&!c&&g.observe(f),g.observe(t));let x,h=c?Ln(e):null;c&&v();function v(){const b=Ln(e);h&&!Tc(h,b)&&n(),h=b,x=requestAnimationFrame(v)}return n(),()=>{var b;d.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 dg=Lh,fg=Dh,pg=Mh,mg=Fh,hg=Rh,Oa=jh,gg=Oh,xg=(e,t,n)=>{const r=new Map,o={platform:lg,...n},s={...o.platform,_c:r};return Ih(e,t,{...o,platform:s})};var vg=typeof document<"u",wg=function(){},mo=vg?u.useLayoutEffect:wg;function So(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(!So(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)&&!So(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ac(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fa(e,t){const n=Ac(e);return Math.round(t*n)/n}function ps(e){const t=u.useRef(e);return mo(()=>{t.current=e}),t}function bg(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:f}=e,[d,p]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,g]=u.useState(r);So(m,r)||g(r);const[x,h]=u.useState(null),[v,b]=u.useState(null),w=u.useCallback(S=>{S!==I.current&&(I.current=S,h(S))},[]),y=u.useCallback(S=>{S!==A.current&&(A.current=S,b(S))},[]),E=s||x,k=i||v,I=u.useRef(null),A=u.useRef(null),T=u.useRef(d),Y=c!=null,Z=ps(c),G=ps(o),q=ps(f),te=u.useCallback(()=>{if(!I.current||!A.current)return;const S={placement:t,strategy:n,middleware:m};G.current&&(S.platform=G.current),xg(I.current,A.current,S).then(O=>{const P={...O,isPositioned:q.current!==!1};D.current&&!So(T.current,P)&&(T.current=P,Ur.flushSync(()=>{p(P)}))})},[m,t,n,G,q]);mo(()=>{f===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,p(S=>({...S,isPositioned:!1})))},[f]);const D=u.useRef(!1);mo(()=>(D.current=!0,()=>{D.current=!1}),[]),mo(()=>{if(E&&(I.current=E),k&&(A.current=k),E&&k){if(Z.current)return Z.current(E,k,te);te()}},[E,k,te,Z,Y]);const X=u.useMemo(()=>({reference:I,floating:A,setReference:w,setFloating:y}),[w,y]),N=u.useMemo(()=>({reference:E,floating:k}),[E,k]),M=u.useMemo(()=>{const S={position:n,left:0,top:0};if(!N.floating)return S;const O=Fa(N.floating,d.x),P=Fa(N.floating,d.y);return l?{...S,transform:"translate("+O+"px, "+P+"px)",...Ac(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:O,top:P}},[n,l,N.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:te,refs:X,elements:N,floatingStyles:M}),[d,te,X,N,M])}const yg=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?Oa({element:r.current,padding:o}).fn(n):{}:r?Oa({element:r,padding:o}).fn(n):{}}}},Sg=(e,t)=>({...dg(e),options:[e,t]}),Cg=(e,t)=>({...fg(e),options:[e,t]}),Eg=(e,t)=>({...gg(e),options:[e,t]}),Tg=(e,t)=>({...pg(e),options:[e,t]}),Ag=(e,t)=>({...mg(e),options:[e,t]}),Ng=(e,t)=>({...hg(e),options:[e,t]}),kg=(e,t)=>({...yg(e),options:[e,t]});var _g="Arrow",Nc=u.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return a.jsx(_e.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"})})});Nc.displayName=_g;var Ig=Nc;function jg(e){const[t,n]=u.useState(void 0);return nt(()=>{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,f=Array.isArray(c)?c[0]:c;i=f.inlineSize,l=f.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 Ni="Popper",[kc,xr]=An(Ni),[Mg,_c]=kc(Ni),Ic=e=>{const{__scopePopper:t,children:n}=e,[r,o]=u.useState(null);return a.jsx(Mg,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ic.displayName=Ni;var jc="PopperAnchor",Mc=u.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=_c(jc,n),i=u.useRef(null),l=Oe(t,i),c=u.useRef(null);return u.useEffect(()=>{const f=c.current;c.current=(r==null?void 0:r.current)||i.current,f!==c.current&&s.onAnchorChange(c.current)}),r?null:a.jsx(_e.div,{...o,ref:l})});Mc.displayName=jc;var ki="PopperContent",[Rg,Pg]=kc(ki),Rc=u.forwardRef((e,t)=>{var _,V,J,ne,ie,re;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:f=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:x,...h}=e,v=_c(ki,n),[b,w]=u.useState(null),y=Oe(t,ue=>w(ue)),[E,k]=u.useState(null),I=jg(E),A=(I==null?void 0:I.width)??0,T=(I==null?void 0:I.height)??0,Y=r+(s!=="center"?"-"+s:""),Z=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},G=Array.isArray(f)?f:[f],q=G.length>0,te={padding:Z,boundary:G.filter(Dg),altBoundary:q},{refs:D,floatingStyles:X,placement:N,isPositioned:M,middlewareData:S}=bg({strategy:"fixed",placement:Y,whileElementsMounted:(...ue)=>ug(...ue,{animationFrame:g==="always"}),elements:{reference:v.anchor},middleware:[Sg({mainAxis:o+T,alignmentAxis:i}),c&&Cg({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Eg():void 0,...te}),c&&Tg({...te}),Ag({...te,apply:({elements:ue,rects:de,availableWidth:Ie,availableHeight:Re})=>{const{width:Fe,height:je}=de.reference,Ue=ue.floating.style;Ue.setProperty("--radix-popper-available-width",`${Ie}px`),Ue.setProperty("--radix-popper-available-height",`${Re}px`),Ue.setProperty("--radix-popper-anchor-width",`${Fe}px`),Ue.setProperty("--radix-popper-anchor-height",`${je}px`)}}),E&&kg({element:E,padding:l}),Og({arrowWidth:A,arrowHeight:T}),m&&Ng({strategy:"referenceHidden",...te})]}),[O,P]=Dc(N),R=yn(x);nt(()=>{M&&(R==null||R())},[M,R]);const ee=(_=S.arrow)==null?void 0:_.x,L=(V=S.arrow)==null?void 0:V.y,H=((J=S.arrow)==null?void 0:J.centerOffset)!==0,[j,W]=u.useState();return nt(()=>{b&&W(window.getComputedStyle(b).zIndex)},[b]),a.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:M?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:j,"--radix-popper-transform-origin":[(ne=S.transformOrigin)==null?void 0:ne.x,(ie=S.transformOrigin)==null?void 0:ie.y].join(" "),...((re=S.hide)==null?void 0:re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:a.jsx(Rg,{scope:n,placedSide:O,onArrowChange:k,arrowX:ee,arrowY:L,shouldHideArrow:H,children:a.jsx(_e.div,{"data-side":O,"data-align":P,...h,ref:y,style:{...h.style,animation:M?void 0:"none"}})})})});Rc.displayName=ki;var Pc="PopperArrow",Lg={top:"bottom",right:"left",bottom:"top",left:"right"},Lc=u.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Pg(Pc,r),i=Lg[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(Ig,{...o,ref:n,style:{...o.style,display:"block"}})})});Lc.displayName=Pc;function Dg(e){return e!==null}var Og=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,[f,d]=Dc(n),p={start:"0%",center:"50%",end:"100%"}[d],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 f==="bottom"?(x=i?p:`${m}px`,h=`${-c}px`):f==="top"?(x=i?p:`${m}px`,h=`${r.floating.height+c}px`):f==="right"?(x=`${-c}px`,h=i?p:`${g}px`):f==="left"&&(x=`${r.floating.width+c}px`,h=i?p:`${g}px`),{data:{x,y:h}}}});function Dc(e){const[t,n="center"]=e.split("-");return[t,n]}var _i=Ic,Fo=Mc,Ii=Rc,ji=Lc,Fg="Portal",Gr=u.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,s]=u.useState(!1);nt(()=>s(!0),[]);const i=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?_p.createPortal(a.jsx(_e.div,{...r,ref:t}),i):null});Gr.displayName=Fg;function zg(e,t){return u.useReducer((n,r)=>t[n][r]??n,e)}var mn=e=>{const{present:t,children:n}=e,r=$g(t),o=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),s=Oe(r.ref,Bg(o));return typeof n=="function"||r.isPresent?u.cloneElement(o,{ref:s}):null};mn.displayName="Presence";function $g(e){const[t,n]=u.useState(),r=u.useRef(null),o=u.useRef(e),s=u.useRef("none"),i=e?"mounted":"unmounted",[l,c]=zg(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const f=eo(r.current);s.current=l==="mounted"?f:"none"},[l]),nt(()=>{const f=r.current,d=o.current;if(d!==e){const m=s.current,g=eo(f);e?c("MOUNT"):g==="none"||(f==null?void 0:f.display)==="none"?c("UNMOUNT"):c(d&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),nt(()=>{if(t){let f;const d=t.ownerDocument.defaultView??window,p=g=>{const h=eo(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",f=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=g=>{g.target===t&&(s.current=eo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(f),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(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function eo(e){return(e==null?void 0:e.animationName)||"none"}function Bg(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 Ug=pi[" useInsertionEffect ".trim().toString()]||nt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Hg({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const d=u.useRef(e!==void 0);u.useEffect(()=>{const p=d.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.`),d.current=l},[l,r])}const f=u.useCallback(d=>{var p;if(l){const m=Wg(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[l,e,s,i]);return[c,f]}function Hg({defaultProp:e,onChange:t}){const[n,r]=u.useState(e),o=u.useRef(n),s=u.useRef(t);return Ug(()=>{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 Wg(e){return typeof e=="function"}var Oc=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"}),Gg="VisuallyHidden",Fc=u.forwardRef((e,t)=>a.jsx(_e.span,{...e,ref:t,style:{...Oc,...e.style}}));Fc.displayName=Gg;var Vg=Fc,[zo,o1]=An("Tooltip",[xr]),$o=xr(),zc="TooltipProvider",Yg=700,Ws="tooltip.open",[Kg,Mi]=zo(zc),$c=e=>{const{__scopeTooltip:t,delayDuration:n=Yg,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 f=c.current;return()=>window.clearTimeout(f)},[]),a.jsx(Kg,{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(f=>{l.current=f},[]),disableHoverableContent:o,children:s})};$c.displayName=zc;var Lr="Tooltip",[qg,Vr]=zo(Lr),Bc=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:l}=e,c=Mi(Lr,e.__scopeTooltip),f=$o(t),[d,p]=u.useState(null),m=Zt(),g=u.useRef(0),x=i??c.disableHoverableContent,h=l??c.delayDuration,v=u.useRef(!1),[b,w]=Dn({prop:r,defaultProp:o??!1,onChange:A=>{A?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ws))):c.onClose(),s==null||s(A)},caller:Lr}),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]),k=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,w(!1)},[w]),I=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(_i,{...f,children:a.jsx(qg,{scope:t,contentId:m,open:b,stateAttribute:y,trigger:d,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?I():E()},[c.isOpenDelayedRef,I,E]),onTriggerLeave:u.useCallback(()=>{x?k():(window.clearTimeout(g.current),g.current=0)},[k,x]),onOpen:E,onClose:k,disableHoverableContent:x,children:n})})};Bc.displayName=Lr;var Gs="TooltipTrigger",Uc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Vr(Gs,n),s=Mi(Gs,n),i=$o(n),l=u.useRef(null),c=Oe(t,l,o.onTriggerChange),f=u.useRef(!1),d=u.useRef(!1),p=u.useCallback(()=>f.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),a.jsx(Fo,{asChild:!0,...i,children:a.jsx(_e.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:me(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:me(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:me(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:me(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:me(e.onBlur,o.onClose),onClick:me(e.onClick,o.onClose)})})});Uc.displayName=Gs;var Ri="TooltipPortal",[Xg,Zg]=zo(Ri,{forceMount:void 0}),Hc=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=Vr(Ri,t);return a.jsx(Xg,{scope:t,forceMount:n,children:a.jsx(mn,{present:n||s.open,children:a.jsx(Gr,{asChild:!0,container:o,children:r})})})};Hc.displayName=Ri;var ar="TooltipContent",Wc=u.forwardRef((e,t)=>{const n=Zg(ar,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Vr(ar,e.__scopeTooltip);return a.jsx(mn,{present:r||i.open,children:i.disableHoverableContent?a.jsx(Gc,{side:o,...s,ref:t}):a.jsx(Jg,{side:o,...s,ref:t})})}),Jg=u.forwardRef((e,t)=>{const n=Vr(ar,e.__scopeTooltip),r=Mi(ar,e.__scopeTooltip),o=u.useRef(null),s=Oe(t,o),[i,l]=u.useState(null),{trigger:c,onClose:f}=n,d=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=nx(b,v.getBoundingClientRect()),y=rx(b,w),E=ox(h.getBoundingClientRect()),k=ix([...y,...E]);l(k),p(!0)},[p]);return u.useEffect(()=>()=>m(),[m]),u.useEffect(()=>{if(c&&d){const x=v=>g(v,d),h=v=>g(v,c);return c.addEventListener("pointerleave",x),d.addEventListener("pointerleave",h),()=>{c.removeEventListener("pointerleave",x),d.removeEventListener("pointerleave",h)}}},[c,d,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))||(d==null?void 0:d.contains(v)),y=!sx(b,i);w?m():y&&(m(),f())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,d,i,f,m]),a.jsx(Gc,{...e,ref:s})}),[Qg,ex]=zo(Lr,{isInside:!1}),tx=mm("TooltipContent"),Gc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...l}=e,c=Vr(ar,n),f=$o(n),{onClose:d}=c;return u.useEffect(()=>(document.addEventListener(Ws,d),()=>document.removeEventListener(Ws,d)),[d]),u.useEffect(()=>{if(c.trigger){const p=m=>{const g=m.target;g!=null&&g.contains(c.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,d]),a.jsx(Hr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:a.jsxs(Ii,{"data-state":c.stateAttribute,...f,...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(tx,{children:r}),a.jsx(Qg,{scope:n,isInside:!0,children:a.jsx(Vg,{id:c.contentId,role:"tooltip",children:o||r})})]})})});Wc.displayName=ar;var Vc="TooltipArrow",Yc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=$o(n);return ex(Vc,n).isInside?null:a.jsx(ji,{...o,...r,ref:t})});Yc.displayName=Vc;function nx(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 rx(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 ox(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 sx(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],f=l.x,d=l.y,p=c.x,m=c.y;d>r!=m>r&&n<(p-f)*(r-d)/(m-d)+f&&(o=!o)}return o}function ix(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),ax(t)}function ax(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 lx=$c,cx=Bc,ux=Uc,dx=Hc,fx=Wc,px=Yc;function mx({delayDuration:e=0,...t}){return a.jsx(lx,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Pi({...e}){return a.jsx(mx,{delayDuration:500,children:a.jsx(cx,{"data-slot":"tooltip",...e})})}function Li({...e}){return a.jsx(ux,{"data-slot":"tooltip-trigger",...e})}function Di({className:e,sideOffset:t=0,children:n,...r}){return a.jsx(dx,{children:a.jsxs(fx,{"data-slot":"tooltip-content",sideOffset:t,className:Se("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(px,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Kc="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)]",ms=Kc+" hover:bg-[var(--color-primary-w10)] dark:hover:bg-[var(--color-primary-w60)]",hx=Tn("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:ms+" border border-1 border-[var(--color-primary-wMain)]",secondary:ms,ghost:ms,link:Kc+" 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 ve({className:e,variant:t,size:n,asChild:r=!1,tooltip:o="",testid:s="",...i}){const l=r?ec:"button",c=o?{...i,"aria-label":o}:i,f=a.jsx(l,{"data-slot":"button","data-testid":s||o||i.title,className:Se(hx({variant:t,size:n,className:e})),...c});return o?a.jsxs(Pi,{children:[a.jsx(Li,{asChild:!0,children:f}),a.jsx(Di,{children:o})]}):f}const qc=({onClick:e,text:t="View Agent Workflow"})=>a.jsx(ve,{variant:"ghost",size:"sm",onClick:e,tooltip:t,children:a.jsx(po,{className:"h-4 w-4"})}),Xc=u.forwardRef(({className:e,...t},n)=>a.jsx("textarea",{className:Se("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}));Xc.displayName="Textarea";var hs="focusScope.autoFocusOnMount",gs="focusScope.autoFocusOnUnmount",za={bubbles:!1,cancelable:!0},gx="FocusScope",Bo=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[l,c]=u.useState(null),f=yn(o),d=yn(s),p=u.useRef(null),m=Oe(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:xn(p.current,{select:!0})},v=function(y){if(g.paused||!l)return;const E=y.relatedTarget;E!==null&&(l.contains(E)||xn(p.current,{select:!0}))},b=function(y){if(document.activeElement===document.body)for(const k of y)k.removedNodes.length>0&&xn(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){Ba.add(g);const h=document.activeElement;if(!l.contains(h)){const b=new CustomEvent(hs,za);l.addEventListener(hs,f),l.dispatchEvent(b),b.defaultPrevented||(xx(Sx(Zc(l)),{select:!0}),document.activeElement===h&&xn(l))}return()=>{l.removeEventListener(hs,f),setTimeout(()=>{const b=new CustomEvent(gs,za);l.addEventListener(gs,d),l.dispatchEvent(b),b.defaultPrevented||xn(h??document.body,{select:!0}),l.removeEventListener(gs,d),Ba.remove(g)},0)}}},[l,f,d,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]=vx(w);y&&E?!h.shiftKey&&b===E?(h.preventDefault(),n&&xn(y,{select:!0})):h.shiftKey&&b===y&&(h.preventDefault(),n&&xn(E,{select:!0})):b===w&&h.preventDefault()}},[n,r,g.paused]);return a.jsx(_e.div,{tabIndex:-1,...i,ref:m,onKeyDown:x})});Bo.displayName=gx;function xx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(xn(r,{select:t}),document.activeElement!==n)return}function vx(e){const t=Zc(e),n=$a(t,e),r=$a(t.reverse(),e);return[n,r]}function Zc(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 $a(e,t){for(const n of e)if(!wx(n,{upTo:t}))return n}function wx(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 bx(e){return e instanceof HTMLInputElement&&"select"in e}function xn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bx(e)&&t&&e.select()}}var Ba=yx();function yx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ua(e,t),e.unshift(t)},remove(t){var n;e=Ua(e,t),(n=e[0])==null||n.resume()}}}function Ua(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Sx(e){return e.filter(t=>t.tagName!=="A")}var xs=0;function Oi(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ha()),document.body.insertAdjacentElement("beforeend",e[1]??Ha()),xs++,()=>{xs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),xs--}},[])}function Ha(){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 Kt=function(){return Kt=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},Kt.apply(this,arguments)};function Jc(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 Cx(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 ho="right-scroll-bar-position",go="width-before-scroll-bar",Ex="with-scroll-bars-hidden",Tx="--removed-body-scroll-bar-size";function vs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ax(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 Nx=typeof window<"u"?u.useLayoutEffect:u.useEffect,Wa=new WeakMap;function kx(e,t){var n=Ax(null,function(r){return e.forEach(function(o){return vs(o,r)})});return Nx(function(){var r=Wa.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(l){s.has(l)||vs(l,null)}),s.forEach(function(l){o.has(l)||vs(l,i)})}Wa.set(n,e)},[e]),n}function _x(e){return e}function Ix(e,t){t===void 0&&(t=_x);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 d=i;i=[],d.forEach(s)},f=function(){return Promise.resolve().then(c)};f(),n={push:function(d){i.push(d),f()},filter:function(d){return i=i.filter(d),n}}}};return o}function jx(e){e===void 0&&(e={});var t=Ix(null);return t.options=Kt({async:!0,ssr:!1},e),t}var Qc=function(e){var t=e.sideCar,n=Jc(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,Kt({},n))};Qc.isSideCarExport=!0;function Mx(e,t){return e.useMedium(t),Qc}var eu=jx(),ws=function(){},Uo=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:ws,onWheelCapture:ws,onTouchMoveCapture:ws}),o=r[0],s=r[1],i=e.forwardProps,l=e.children,c=e.className,f=e.removeScrollBar,d=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=Jc(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=m,I=kx([n,t]),A=Kt(Kt({},E),o);return u.createElement(u.Fragment,null,d&&u.createElement(k,{sideCar:eu,removeScrollBar:f,shards:p,noRelative:g,noIsolation:x,inert:h,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:y}),i?u.cloneElement(u.Children.only(l),Kt(Kt({},A),{ref:I})):u.createElement(w,Kt({},A,{className:c,ref:I}),l))});Uo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Uo.classNames={fullWidth:go,zeroRight:ho};var Rx=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Px(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Rx();return t&&e.setAttribute("nonce",t),e}function Lx(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Dx(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ox=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Px())&&(Lx(t,n),Dx(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Fx=function(){var e=Ox();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},tu=function(){var e=Fx(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},zx={left:0,top:0,right:0,gap:0},bs=function(e){return parseInt(e||"",10)||0},$x=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[bs(n),bs(r),bs(o)]},Bx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return zx;var t=$x(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])}},Ux=tu(),nr="data-scroll-locked",Hx=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(Ex,` {
|
|
74
|
+
overflow: hidden `).concat(r,`;
|
|
75
|
+
padding-right: `).concat(l,"px ").concat(r,`;
|
|
76
|
+
}
|
|
77
|
+
body[`).concat(nr,`] {
|
|
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(ho,` {
|
|
91
|
+
right: `).concat(l,"px ").concat(r,`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.`).concat(go,` {
|
|
95
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.`).concat(ho," .").concat(ho,` {
|
|
99
|
+
right: 0 `).concat(r,`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.`).concat(go," .").concat(go,` {
|
|
103
|
+
margin-right: 0 `).concat(r,`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
body[`).concat(nr,`] {
|
|
107
|
+
`).concat(Tx,": ").concat(l,`px;
|
|
108
|
+
}
|
|
109
|
+
`)},Ga=function(){var e=parseInt(document.body.getAttribute(nr)||"0",10);return isFinite(e)?e:0},Wx=function(){u.useEffect(function(){return document.body.setAttribute(nr,(Ga()+1).toString()),function(){var e=Ga()-1;e<=0?document.body.removeAttribute(nr):document.body.setAttribute(nr,e.toString())}},[])},Gx=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Wx();var s=u.useMemo(function(){return Bx(o)},[o]);return u.createElement(Ux,{styles:Hx(s,!t,o,n?"":"!important")})},Vs=!1;if(typeof window<"u")try{var to=Object.defineProperty({},"passive",{get:function(){return Vs=!0,!0}});window.addEventListener("test",to,to),window.removeEventListener("test",to,to)}catch{Vs=!1}var Gn=Vs?{passive:!1}:!1,Vx=function(e){return e.tagName==="TEXTAREA"},nu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Vx(e)&&n[t]==="visible")},Yx=function(e){return nu(e,"overflowY")},Kx=function(e){return nu(e,"overflowX")},Va=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ru(e,r);if(o){var s=ou(e,r),i=s[1],l=s[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qx=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Xx=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ru=function(e,t){return e==="v"?Yx(t):Kx(t)},ou=function(e,t){return e==="v"?qx(t):Xx(t)},Zx=function(e,t){return e==="h"&&t==="rtl"?-1:1},Jx=function(e,t,n,r,o){var s=Zx(e,window.getComputedStyle(t).direction),i=s*r,l=n.target,c=t.contains(l),f=!1,d=i>0,p=0,m=0;do{if(!l)break;var g=ou(e,l),x=g[0],h=g[1],v=g[2],b=h-v-s*x;(x||b)&&ru(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(d&&Math.abs(p)<1||!d&&Math.abs(m)<1)&&(f=!0),f},no=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ya=function(e){return[e.deltaX,e.deltaY]},Ka=function(e){return e&&"current"in e?e.current:e},Qx=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ev=function(e){return`
|
|
110
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
111
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
112
|
+
`)},tv=0,Vn=[];function nv(e){var t=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(tv++)[0],s=u.useState(tu)[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=Cx([e.lockRef.current],(e.shards||[]).map(Ka),!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=no(h),w=n.current,y="deltaX"in h?h.deltaX:w[0]-b[0],E="deltaY"in h?h.deltaY:w[1]-b[1],k,I=h.target,A=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in h&&A==="h"&&I.type==="range")return!1;var T=Va(A,I);if(!T)return!0;if(T?k=A:(k=A==="v"?"h":"v",T=Va(A,I)),!T)return!1;if(!r.current&&"changedTouches"in h&&(y||E)&&(r.current=k),!k)return!0;var Y=r.current||k;return Jx(Y,v,h,Y==="h"?y:E)},[]),c=u.useCallback(function(h){var v=h;if(!(!Vn.length||Vn[Vn.length-1]!==s)){var b="deltaY"in v?Ya(v):no(v),w=t.current.filter(function(k){return k.name===v.type&&(k.target===v.target||v.target===k.shadowParent)&&Qx(k.delta,b)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var y=(i.current.shards||[]).map(Ka).filter(Boolean).filter(function(k){return k.contains(v.target)}),E=y.length>0?l(v,y[0]):!i.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),f=u.useCallback(function(h,v,b,w){var y={name:h,delta:v,target:b,should:w,shadowParent:rv(b)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),d=u.useCallback(function(h){n.current=no(h),r.current=void 0},[]),p=u.useCallback(function(h){f(h.type,Ya(h),h.target,l(h,e.lockRef.current))},[]),m=u.useCallback(function(h){f(h.type,no(h),h.target,l(h,e.lockRef.current))},[]);u.useEffect(function(){return Vn.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Gn),document.addEventListener("touchmove",c,Gn),document.addEventListener("touchstart",d,Gn),function(){Vn=Vn.filter(function(h){return h!==s}),document.removeEventListener("wheel",c,Gn),document.removeEventListener("touchmove",c,Gn),document.removeEventListener("touchstart",d,Gn)}},[]);var g=e.removeScrollBar,x=e.inert;return u.createElement(u.Fragment,null,x?u.createElement(s,{styles:ev(o)}):null,g?u.createElement(Gx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function rv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ov=Mx(eu,nv);var Ho=u.forwardRef(function(e,t){return u.createElement(Uo,Kt({},e,{ref:t,sideCar:ov}))});Ho.classNames=Uo.classNames;var sv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Yn=new WeakMap,ro=new WeakMap,oo={},ys=0,su=function(e){return e&&(e.host||su(e.parentNode))},iv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=su(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})},av=function(e,t,n,r){var o=iv(t,Array.isArray(e)?e:[e]);oo[n]||(oo[n]=new WeakMap);var s=oo[n],i=[],l=new Set,c=new Set(o),f=function(p){!p||l.has(p)||(l.add(p),f(p.parentNode))};o.forEach(f);var d=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))d(m);else try{var g=m.getAttribute(r),x=g!==null&&g!=="false",h=(Yn.get(m)||0)+1,v=(s.get(m)||0)+1;Yn.set(m,h),s.set(m,v),i.push(m),h===1&&x&&ro.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 d(t),l.clear(),ys++,function(){i.forEach(function(p){var m=Yn.get(p)-1,g=s.get(p)-1;Yn.set(p,m),s.set(p,g),m||(ro.has(p)||p.removeAttribute(r),ro.delete(p)),g||p.removeAttribute(n)}),ys--,ys||(Yn=new WeakMap,Yn=new WeakMap,ro=new WeakMap,oo={})}},Fi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=sv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),av(r,o,n,"aria-hidden")):function(){return null}},Wo="Dialog",[iu,s1]=An(Wo),[lv,Ut]=iu(Wo),au=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,l=u.useRef(null),c=u.useRef(null),[f,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Wo});return a.jsx(lv,{scope:t,triggerRef:l,contentRef:c,contentId:Zt(),titleId:Zt(),descriptionId:Zt(),open:f,onOpenChange:d,onOpenToggle:u.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};au.displayName=Wo;var lu="DialogTrigger",cv=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ut(lu,n),s=Oe(t,o.triggerRef);return a.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Bi(o.open),...r,ref:s,onClick:me(e.onClick,o.onOpenToggle)})});cv.displayName=lu;var zi="DialogPortal",[uv,cu]=iu(zi,{forceMount:void 0}),uu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Ut(zi,t);return a.jsx(uv,{scope:t,forceMount:n,children:u.Children.map(r,i=>a.jsx(mn,{present:n||s.open,children:a.jsx(Gr,{asChild:!0,container:o,children:i})}))})};uu.displayName=zi;var Co="DialogOverlay",du=u.forwardRef((e,t)=>{const n=cu(Co,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ut(Co,e.__scopeDialog);return s.modal?a.jsx(mn,{present:r||s.open,children:a.jsx(fv,{...o,ref:t})}):null});du.displayName=Co;var dv=Pn("DialogOverlay.RemoveScroll"),fv=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ut(Co,n);return a.jsx(Ho,{as:dv,allowPinchZoom:!0,shards:[o.contentRef],children:a.jsx(_e.div,{"data-state":Bi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),On="DialogContent",fu=u.forwardRef((e,t)=>{const n=cu(On,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ut(On,e.__scopeDialog);return a.jsx(mn,{present:r||s.open,children:s.modal?a.jsx(pv,{...o,ref:t}):a.jsx(mv,{...o,ref:t})})});fu.displayName=On;var pv=u.forwardRef((e,t)=>{const n=Ut(On,e.__scopeDialog),r=u.useRef(null),o=Oe(t,n.contentRef,r);return u.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),a.jsx(pu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:me(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&s.preventDefault()}),onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault())})}),mv=u.forwardRef((e,t)=>{const n=Ut(On,e.__scopeDialog),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(pu,{...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,f;(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;((f=n.triggerRef.current)==null?void 0:f.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),pu=u.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,l=Ut(On,n),c=u.useRef(null),f=Oe(t,c);return Oi(),a.jsxs(a.Fragment,{children:[a.jsx(Bo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(Hr,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Bi(l.open),...i,ref:f,onDismiss:()=>l.onOpenChange(!1)})}),a.jsxs(a.Fragment,{children:[a.jsx(hv,{titleId:l.titleId}),a.jsx(xv,{contentRef:c,descriptionId:l.descriptionId})]})]})}),$i="DialogTitle",mu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ut($i,n);return a.jsx(_e.h2,{id:o.titleId,...r,ref:t})});mu.displayName=$i;var hu="DialogDescription",gu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ut(hu,n);return a.jsx(_e.p,{id:o.descriptionId,...r,ref:t})});gu.displayName=hu;var xu="DialogClose",vu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ut(xu,n);return a.jsx(_e.button,{type:"button",...r,ref:t,onClick:me(e.onClick,()=>o.onOpenChange(!1))})});vu.displayName=xu;function Bi(e){return e?"open":"closed"}var wu="DialogTitleWarning",[i1,bu]=sh(wu,{contentName:On,titleName:$i,docsSlug:"dialog"}),hv=({titleId:e})=>{const t=bu(wu),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},gv="DialogDescriptionWarning",xv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${bu(gv).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},vv=au,wv=uu,bv=du,yv=fu,Sv=mu,Cv=gu,Ev=vu;function Go({...e}){return a.jsx(vv,{"data-slot":"dialog",...e})}function Tv({...e}){return a.jsx(wv,{"data-slot":"dialog-portal",...e})}function Av({className:e,...t}){return a.jsx(bv,{"data-slot":"dialog-overlay",className:Se("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 Vo({className:e,children:t,showCloseButton:n=!0,...r}){return a.jsxs(Tv,{"data-slot":"dialog-portal",children:[a.jsx(Av,{}),a.jsxs(yv,{"data-slot":"dialog-content",className:Se("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(Ev,{"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(Ro,{}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Yo({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-header",className:Se("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Nv({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-footer",className:Se("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Ko({className:e,...t}){return a.jsx(Sv,{"data-slot":"dialog-title",className:Se("text-lg leading-none font-semibold",e),...t})}function qo({className:e,...t}){return a.jsx(Cv,{"data-slot":"dialog-description",className:Se("py-4 text-sm",e),...t})}const Xo=u.createContext(null);Xo.displayName="PanelGroupContext";const $e={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"},Ui=10,Mn=u.useLayoutEffect,qa=pi.useId,kv=typeof qa=="function"?qa:()=>null;let _v=0;function Hi(e=null){const t=kv(),n=u.useRef(e||t||null);return n.current===null&&(n.current=""+_v++),e??n.current}function yu({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:s,id:i,maxSize:l,minSize:c,onCollapse:f,onExpand:d,onResize:p,order:m,style:g,tagName:x="div",...h}){const v=u.useContext(Xo);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:w,getPanelSize:y,getPanelStyle:E,groupId:k,isPanelCollapsed:I,reevaluatePanelConstraints:A,registerPanel:T,resizePanel:Y,unregisterPanel:Z}=v,G=Hi(i),q=u.useRef({callbacks:{onCollapse:f,onExpand:d,onResize:p},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:l,minSize:c},id:G,idIsFromProps:i!==void 0,order:m});u.useRef({didLogMissingDefaultSizeWarning:!1}),Mn(()=>{const{callbacks:D,constraints:X}=q.current,N={...X};q.current.id=G,q.current.idIsFromProps=i!==void 0,q.current.order=m,D.onCollapse=f,D.onExpand=d,D.onResize=p,X.collapsedSize=n,X.collapsible=r,X.defaultSize=o,X.maxSize=l,X.minSize=c,(N.collapsedSize!==X.collapsedSize||N.collapsible!==X.collapsible||N.maxSize!==X.maxSize||N.minSize!==X.minSize)&&A(q.current,N)}),Mn(()=>{const D=q.current;return T(D),()=>{Z(D)}},[m,G,T,Z]),u.useImperativeHandle(s,()=>({collapse:()=>{b(q.current)},expand:D=>{w(q.current,D)},getId(){return G},getSize(){return y(q.current)},isCollapsed(){return I(q.current)},isExpanded(){return!I(q.current)},resize:D=>{Y(q.current,D)}}),[b,w,y,I,G,Y]);const te=E(q.current,o);return u.createElement(x,{...h,children:e,className:t,id:G,style:{...te,...g},[$e.groupId]:k,[$e.panel]:"",[$e.panelCollapsible]:r||void 0,[$e.panelId]:G,[$e.panelSize]:parseFloat(""+te.flexGrow).toFixed(1)})}const Su=u.forwardRef((e,t)=>u.createElement(yu,{...e,forwardedRef:t}));yu.displayName="Panel";Su.displayName="forwardRef(Panel)";let Ys=null,xo=-1,vn=null;function Iv(e,t,n){const r=(t&Nu)!==0,o=(t&ku)!==0,s=(t&_u)!==0,i=(t&Iu)!==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 jv(){vn!==null&&(document.head.removeChild(vn),Ys=null,vn=null,xo=-1)}function Ss(e,t,n){var r,o;const s=Iv(e,t);if(Ys!==s){if(Ys=s,vn===null&&(vn=document.createElement("style"),document.head.appendChild(vn)),xo>=0){var i;(i=vn.sheet)===null||i===void 0||i.removeRule(xo)}xo=(r=(o=vn.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function Cu(e){return e.type==="keydown"}function Eu(e){return e.type.startsWith("pointer")}function Tu(e){return e.type.startsWith("mouse")}function Zo(e){if(Eu(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Tu(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Mv(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Rv(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 Pv(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Ja(e),b:Ja(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;ye(r,"Stacking order can only be calculated for elements with a common ancestor");const o={a:Za(Xa(n.a)),b:Za(Xa(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 Lv=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Dv(e){var t;const n=getComputedStyle((t=Au(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Ov(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Dv(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"||Lv.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Xa(e){let t=e.length;for(;t--;){const n=e[t];if(ye(n,"Missing node"),Ov(n))return n}return null}function Za(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ja(e){const t=[];for(;e;)t.push(e),e=Au(e);return t}function Au(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Nu=1,ku=2,_u=4,Iu=8,Fv=Mv()==="coarse";let zt=[],rr=!1,wn=new Map,Jo=new Map;const Dr=new Set;function zv(e,t,n,r,o){var s;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},c=(s=wn.get(i))!==null&&s!==void 0?s:0;return wn.set(i,c+1),Dr.add(l),Eo(),function(){var d;Jo.delete(e),Dr.delete(l);const p=(d=wn.get(i))!==null&&d!==void 0?d:1;if(wn.set(i,p-1),Eo(),p===1&&wn.delete(i),zt.includes(l)){const m=zt.indexOf(l);m>=0&&zt.splice(m,1),Qo(),o("up",!0,null)}}}function $v(e){const{target:t}=e,{x:n,y:r}=Zo(e);rr=!0,Wi({target:t,x:n,y:r}),Eo(),zt.length>0&&(To("down",e),Qo(),e.preventDefault(),ju(t)||e.stopImmediatePropagation())}function Cs(e){const{x:t,y:n}=Zo(e);if(rr&&e.buttons===0&&(rr=!1,To("up",e)),!rr){const{target:r}=e;Wi({target:r,x:t,y:n})}To("move",e),Qo(),zt.length>0&&e.preventDefault()}function Es(e){const{target:t}=e,{x:n,y:r}=Zo(e);Jo.clear(),rr=!1,zt.length>0&&(e.preventDefault(),ju(t)||e.stopImmediatePropagation()),To("up",e),Wi({target:t,x:n,y:r}),Qo(),Eo()}function ju(e){let t=e;for(;t;){if(t.hasAttribute($e.resizeHandle))return!0;t=t.parentElement}return!1}function Wi({target:e,x:t,y:n}){zt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Dr.forEach(o=>{const{element:s,hitAreaMargins:i}=o,l=s.getBoundingClientRect(),{bottom:c,left:f,right:d,top:p}=l,m=Fv?i.coarse:i.fine;if(t>=f-m&&t<=d+m&&n>=p-m&&n<=c+m){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Pv(r,s)>0){let x=r,h=!1;for(;x&&!x.contains(s);){if(Rv(x.getBoundingClientRect(),l)){h=!0;break}x=x.parentElement}if(h)return}zt.push(o)}})}function Ts(e,t){Jo.set(e,t)}function Qo(){let e=!1,t=!1;zt.forEach(r=>{const{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;Jo.forEach(r=>{n|=r}),e&&t?Ss("intersection",n):e?Ss("horizontal",n):t?Ss("vertical",n):jv()}let As;function Eo(){var e;(e=As)===null||e===void 0||e.abort(),As=new AbortController;const t={capture:!0,signal:As.signal};Dr.size&&(rr?(zt.length>0&&wn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("contextmenu",Es,t),o.addEventListener("pointerleave",Cs,t),o.addEventListener("pointermove",Cs,t))}),wn.forEach((n,r)=>{const{body:o}=r;o.addEventListener("pointerup",Es,t),o.addEventListener("pointercancel",Es,t)})):wn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("pointerdown",$v,t),o.addEventListener("pointermove",Cs,t))}))}function To(e,t){Dr.forEach(n=>{const{setResizeHandlerState:r}=n,o=zt.includes(n);r(e,o,t)})}function Bv(){const[e,t]=u.useState(0);return u.useCallback(()=>t(n=>n+1),[])}function ye(e,t){if(!e)throw console.error(t),Error(t)}function Fn(e,t,n=Ui){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function cn(e,t,n=Ui){return Fn(e,t,n)===0}function wt(e,t,n){return Fn(e,t,n)===0}function Uv(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(!wt(o,s,n))return!1}return!0}function Jn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];ye(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:s,maxSize:i=100,minSize:l=0}=r;if(Fn(n,l)<0)if(s){const c=(o+l)/2;Fn(n,c)<0?n=o:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(Ui)),n}function _r({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:s}){if(wt(e,0))return t;const i=[...t],[l,c]=r;ye(l!=null,"Invalid first pivot index"),ye(c!=null,"Invalid second pivot index");let f=0;if(s==="keyboard"){{const p=e<0?c:l,m=n[p];ye(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(ye(v!=null,`Previous layout not found for panel index ${p}`),wt(v,g)){const b=h-v;Fn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?l:c,m=n[p];ye(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(ye(v!=null,`Previous layout not found for panel index ${p}`),wt(v,h)){const b=v-g;Fn(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];ye(h!=null,`Previous layout not found for panel index ${m}`);const b=Jn({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(f),x=t[m];ye(x!=null,`Previous layout not found for panel index ${m}`);const h=x-g,v=Jn({panelConstraints:n,panelIndex:m,size:h});if(!wt(x,v)&&(f+=x-v,i[m]=v,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Uv(o,i))return o;{const p=e<0?c:l,m=t[p];ye(m!=null,`Previous layout not found for panel index ${p}`);const g=m+f,x=Jn({panelConstraints:n,panelIndex:p,size:g});if(i[p]=x,!wt(x,g)){let h=g-x,b=e<0?c:l;for(;b>=0&&b<n.length;){const w=i[b];ye(w!=null,`Previous layout not found for panel index ${b}`);const y=w+h,E=Jn({panelConstraints:n,panelIndex:b,size:y});if(wt(w,E)||(h-=E-w,i[b]=E),wt(h,0))break;e>0?b--:b++}}}const d=i.reduce((p,m)=>m+p,0);return wt(d,100)?i:o}function Hv({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,s=0,i=0;const l=n[0];ye(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),f=Math.max(r,100-i),d=e[l];return{valueMax:c,valueMin:f,valueNow:d}}function Or(e,t=document){return Array.from(t.querySelectorAll(`[${$e.resizeHandleId}][data-panel-group-id="${e}"]`))}function Mu(e,t,n=document){const o=Or(e,n).findIndex(s=>s.getAttribute($e.resizeHandleId)===t);return o??null}function Ru(e,t,n){const r=Mu(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Wv(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Pu(e,t=document){if(Wv(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function es(e,t=document){const n=t.querySelector(`[${$e.resizeHandleId}="${e}"]`);return n||null}function Gv(e,t,n,r=document){var o,s,i,l;const c=es(t,r),f=Or(e,r),d=c?f.indexOf(c):-1,p=(o=(s=n[d])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,m=(i=(l=n[d+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[p,m]}function Vv({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:s,setLayout:i}){u.useRef({didWarnAboutMissingResizeHandle:!1}),Mn(()=>{if(!s)return;const l=Or(n,s);for(let c=0;c<o.length-1;c++){const{valueMax:f,valueMin:d,valueNow:p}=Hv({layout:r,panelsArray:o,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const g=o[c];ye(g,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",g.id),m.setAttribute("aria-valuemax",""+Math.round(f)),m.setAttribute("aria-valuemin",""+Math.round(d)),m.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{l.forEach((c,f)=>{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;ye(l,"Eager values not found");const{panelDataArray:c}=l,f=Pu(n,s);ye(f!=null,`No group found for id "${n}"`);const d=Or(n,s);ye(d,`No resize handles found for group id "${n}"`);const p=d.map(m=>{const g=m.getAttribute($e.resizeHandleId);ye(g,"Resize handle element has no handle id attribute");const[x,h]=Gv(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];ye(y,`No panel data found for index ${w}`);const E=r[w],{collapsedSize:k=0,collapsible:I,minSize:A=0}=y.constraints;if(E!=null&&I){const T=_r({delta:wt(E,k)?A-k:k-E,initialLayout:r,panelConstraints:c.map(Y=>Y.constraints),pivotIndices:Ru(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 Qa(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 Lu(e,t){const n=e==="horizontal",{x:r,y:o}=Zo(t);return n?r:o}function Yv(e,t,n,r,o){const s=n==="horizontal",i=es(t,o);ye(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute($e.groupId);ye(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const f=Lu(n,e),d=Pu(l,o);ye(d,`No group element found for id "${l}"`);const p=d.getBoundingClientRect(),m=s?p.width:p.height;return(f-c)/m*100}function Kv(e,t,n,r,o,s){if(Cu(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:Yv(e,t,n,r,s)}function qv({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];ye(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];ye(i,`Panel constraints not found for index ${s}`);const{defaultSize:l}=i;if(l!=null)continue;const c=e.length-r,f=o/c;r++,t[s]=f,o-=f}return t}function Kn(e,t,n){t.forEach((r,o)=>{const s=e[o];ye(s,`Panel data not found for index ${o}`);const{callbacks:i,constraints:l,id:c}=s,{collapsedSize:f=0,collapsible:d}=l,p=n[c];if(p==null||r!==p){n[c]=r;const{onCollapse:m,onExpand:g,onResize:x}=i;x&&x(r,p),d&&(m||g)&&(g&&(p==null||cn(p,f))&&!cn(r,f)&&g(),m&&(p==null||!cn(p,f))&&cn(r,f)&&m())}})}function so(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 Xv({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 Zv(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function el(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 Du(e){return`react-resizable-panels:${e}`}function Ou(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 Fu(e,t){try{const n=Du(e),r=t.getItem(n);if(r){const o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Jv(e,t,n){var r,o;const s=(r=Fu(e,n))!==null&&r!==void 0?r:{},i=Ou(t);return(o=s[i])!==null&&o!==void 0?o:null}function Qv(e,t,n,r,o){var s;const i=Du(e),l=Ou(t),c=(s=Fu(e,o))!==null&&s!==void 0?s:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(c))}catch(f){console.error(f)}}function tl({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(!wt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const i=n[s];ye(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];ye(i!=null,`No layout data found for index ${s}`);const l=Jn({panelConstraints:t,panelIndex:s,size:i});i!=l&&(o+=i-l,n[s]=l)}if(!wt(o,0))for(let s=0;s<t.length;s++){const i=n[s];ye(i!=null,`No layout data found for index ${s}`);const l=i+o,c=Jn({panelConstraints:t,panelIndex:s,size:l});if(i!==c&&(o-=c-i,n[s]=c,wt(o,0)))break}return n}const ew=100,Ir={getItem:e=>(el(Ir),Ir.getItem(e)),setItem:(e,t)=>{el(Ir),Ir.setItem(e,t)}},nl={};function zu({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:s=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Ir,style:f,tagName:d="div",...p}){const m=Hi(s),g=u.useRef(null),[x,h]=u.useState(null),[v,b]=u.useState([]),w=Bv(),y=u.useRef({}),E=u.useRef(new Map),k=u.useRef(0),I=u.useRef({autoSaveId:e,direction:r,dragState:x,id:m,keyboardResizeBy:l,onLayout:i,storage:c}),A=u.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});u.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),u.useImperativeHandle(o,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:L}=A.current;return L},setLayout:L=>{const{onLayout:H}=I.current,{layout:j,panelDataArray:W}=A.current,_=tl({layout:L,panelConstraints:W.map(V=>V.constraints)});Qa(j,_)||(b(_),A.current.layout=_,H&&H(_),Kn(W,_,y.current))}}),[]),Mn(()=>{I.current.autoSaveId=e,I.current.direction=r,I.current.dragState=x,I.current.id=m,I.current.onLayout=i,I.current.storage=c}),Vv({committedValuesRef:I,eagerValuesRef:A,groupId:m,layout:v,panelDataArray:A.current.panelDataArray,setLayout:b,panelGroupElement:g.current}),u.useEffect(()=>{const{panelDataArray:L}=A.current;if(e){if(v.length===0||v.length!==L.length)return;let H=nl[e];H==null&&(H=Zv(Qv,ew),nl[e]=H);const j=[...L],W=new Map(E.current);H(e,j,W,v,c)}},[e,v,c]),u.useEffect(()=>{});const T=u.useCallback(L=>{const{onLayout:H}=I.current,{layout:j,panelDataArray:W}=A.current;if(L.constraints.collapsible){const _=W.map(ie=>ie.constraints),{collapsedSize:V=0,panelSize:J,pivotIndices:ne}=jn(W,L,j);if(ye(J!=null,`Panel size not found for panel "${L.id}"`),!cn(J,V)){E.current.set(L.id,J);const re=Xn(W,L)===W.length-1?J-V:V-J,ue=_r({delta:re,initialLayout:j,panelConstraints:_,pivotIndices:ne,prevLayout:j,trigger:"imperative-api"});so(j,ue)||(b(ue),A.current.layout=ue,H&&H(ue),Kn(W,ue,y.current))}}},[]),Y=u.useCallback((L,H)=>{const{onLayout:j}=I.current,{layout:W,panelDataArray:_}=A.current;if(L.constraints.collapsible){const V=_.map(de=>de.constraints),{collapsedSize:J=0,panelSize:ne=0,minSize:ie=0,pivotIndices:re}=jn(_,L,W),ue=H??ie;if(cn(ne,J)){const de=E.current.get(L.id),Ie=de!=null&&de>=ue?de:ue,Fe=Xn(_,L)===_.length-1?ne-Ie:Ie-ne,je=_r({delta:Fe,initialLayout:W,panelConstraints:V,pivotIndices:re,prevLayout:W,trigger:"imperative-api"});so(W,je)||(b(je),A.current.layout=je,j&&j(je),Kn(_,je,y.current))}}},[]),Z=u.useCallback(L=>{const{layout:H,panelDataArray:j}=A.current,{panelSize:W}=jn(j,L,H);return ye(W!=null,`Panel size not found for panel "${L.id}"`),W},[]),G=u.useCallback((L,H)=>{const{panelDataArray:j}=A.current,W=Xn(j,L);return Xv({defaultSize:H,dragState:x,layout:v,panelData:j,panelIndex:W})},[x,v]),q=u.useCallback(L=>{const{layout:H,panelDataArray:j}=A.current,{collapsedSize:W=0,collapsible:_,panelSize:V}=jn(j,L,H);return ye(V!=null,`Panel size not found for panel "${L.id}"`),_===!0&&cn(V,W)},[]),te=u.useCallback(L=>{const{layout:H,panelDataArray:j}=A.current,{collapsedSize:W=0,collapsible:_,panelSize:V}=jn(j,L,H);return ye(V!=null,`Panel size not found for panel "${L.id}"`),!_||Fn(V,W)>0},[]),D=u.useCallback(L=>{const{panelDataArray:H}=A.current;H.push(L),H.sort((j,W)=>{const _=j.order,V=W.order;return _==null&&V==null?0:_==null?-1:V==null?1:_-V}),A.current.panelDataArrayChanged=!0,w()},[w]);Mn(()=>{if(A.current.panelDataArrayChanged){A.current.panelDataArrayChanged=!1;const{autoSaveId:L,onLayout:H,storage:j}=I.current,{layout:W,panelDataArray:_}=A.current;let V=null;if(L){const ne=Jv(L,_,j);ne&&(E.current=new Map(Object.entries(ne.expandToSizes)),V=ne.layout)}V==null&&(V=qv({panelDataArray:_}));const J=tl({layout:V,panelConstraints:_.map(ne=>ne.constraints)});Qa(W,J)||(b(J),A.current.layout=J,H&&H(J),Kn(_,J,y.current))}}),Mn(()=>{const L=A.current;return()=>{L.layout=[]}},[]);const X=u.useCallback(L=>{let H=!1;const j=g.current;return j&&window.getComputedStyle(j,null).getPropertyValue("direction")==="rtl"&&(H=!0),function(_){_.preventDefault();const V=g.current;if(!V)return()=>null;const{direction:J,dragState:ne,id:ie,keyboardResizeBy:re,onLayout:ue}=I.current,{layout:de,panelDataArray:Ie}=A.current,{initialLayout:Re}=ne??{},Fe=Ru(ie,L,V);let je=Kv(_,L,J,ne,re,V);const Ue=J==="horizontal";Ue&&H&&(je=-je);const Qe=Ie.map(tt=>tt.constraints),et=_r({delta:je,initialLayout:Re??de,panelConstraints:Qe,pivotIndices:Fe,prevLayout:de,trigger:Cu(_)?"keyboard":"mouse-or-touch"}),gt=!so(de,et);(Eu(_)||Tu(_))&&k.current!=je&&(k.current=je,!gt&&je!==0?Ue?Ts(L,je<0?Nu:ku):Ts(L,je<0?_u:Iu):Ts(L,0)),gt&&(b(et),A.current.layout=et,ue&&ue(et),Kn(Ie,et,y.current))}},[]),N=u.useCallback((L,H)=>{const{onLayout:j}=I.current,{layout:W,panelDataArray:_}=A.current,V=_.map(de=>de.constraints),{panelSize:J,pivotIndices:ne}=jn(_,L,W);ye(J!=null,`Panel size not found for panel "${L.id}"`);const re=Xn(_,L)===_.length-1?J-H:H-J,ue=_r({delta:re,initialLayout:W,panelConstraints:V,pivotIndices:ne,prevLayout:W,trigger:"imperative-api"});so(W,ue)||(b(ue),A.current.layout=ue,j&&j(ue),Kn(_,ue,y.current))},[]),M=u.useCallback((L,H)=>{const{layout:j,panelDataArray:W}=A.current,{collapsedSize:_=0,collapsible:V}=H,{collapsedSize:J=0,collapsible:ne,maxSize:ie=100,minSize:re=0}=L.constraints,{panelSize:ue}=jn(W,L,j);ue!=null&&(V&&ne&&cn(ue,_)?cn(_,J)||N(L,J):ue<re?N(L,re):ue>ie&&N(L,ie))},[N]),S=u.useCallback((L,H)=>{const{direction:j}=I.current,{layout:W}=A.current;if(!g.current)return;const _=es(L,g.current);ye(_,`Drag handle element not found for id "${L}"`);const V=Lu(j,H);h({dragHandleId:L,dragHandleRect:_.getBoundingClientRect(),initialCursorPosition:V,initialLayout:W})},[]),O=u.useCallback(()=>{h(null)},[]),P=u.useCallback(L=>{const{panelDataArray:H}=A.current,j=Xn(H,L);j>=0&&(H.splice(j,1),delete y.current[L.id],A.current.panelDataArrayChanged=!0,w())},[w]),R=u.useMemo(()=>({collapsePanel:T,direction:r,dragState:x,expandPanel:Y,getPanelSize:Z,getPanelStyle:G,groupId:m,isPanelCollapsed:q,isPanelExpanded:te,reevaluatePanelConstraints:M,registerPanel:D,registerResizeHandle:X,resizePanel:N,startDragging:S,stopDragging:O,unregisterPanel:P,panelGroupElement:g.current}),[T,x,r,Y,Z,G,m,q,te,M,D,X,N,S,O,P]),ee={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return u.createElement(Xo.Provider,{value:R},u.createElement(d,{...p,children:t,className:n,id:s,ref:g,style:{...ee,...f},[$e.group]:"",[$e.groupDirection]:r,[$e.groupId]:m}))}const $u=u.forwardRef((e,t)=>u.createElement(zu,{...e,forwardedRef:t}));zu.displayName="PanelGroup";$u.displayName="forwardRef(PanelGroup)";function Xn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function jn(e,t,n){const r=Xn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:s}}function tw({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){u.useEffect(()=>{if(e||n==null||r==null)return;const o=es(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($e.groupId);ye(l,`No group element found for id "${l}"`);const c=Or(l,r),f=Mu(l,t,r);ye(f!==null,`No resize element found for id "${t}"`);const d=i.shiftKey?f>0?f-1:c.length-1:f+1<c.length?f+1:0;c[d].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[r,e,t,n])}function Bu({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:s,onClick:i,onDragging:l,onFocus:c,onPointerDown:f,onPointerUp:d,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:f,onPointerUp:d});u.useEffect(()=>{w.current.onClick=i,w.current.onDragging=l,w.current.onPointerDown=f,w.current.onPointerUp=d});const y=u.useContext(Xo);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:k,registerResizeHandle:I,startDragging:A,stopDragging:T,panelGroupElement:Y}=y,Z=Hi(o),[G,q]=u.useState("inactive"),[te,D]=u.useState(!1),[X,N]=u.useState(null),M=u.useRef({state:G});Mn(()=>{M.current.state=G}),u.useEffect(()=>{if(n)N(null);else{const R=I(Z);N(()=>R)}},[n,Z,I]);const S=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,O=(v=r==null?void 0:r.fine)!==null&&v!==void 0?v:5;u.useEffect(()=>{if(n||X==null)return;const R=b.current;ye(R,"Element ref not attached");let ee=!1;return zv(Z,R,E,{coarse:S,fine:O},(H,j,W)=>{if(!j){q("inactive");return}switch(H){case"down":{q("drag"),ee=!1,ye(W,'Expected event to be defined for "down" action'),A(Z,W);const{onDragging:_,onPointerDown:V}=w.current;_==null||_(!0),V==null||V();break}case"move":{const{state:_}=M.current;ee=!0,_!=="drag"&&q("hover"),ye(W,'Expected event to be defined for "move" action'),X(W);break}case"up":{q("hover"),T();const{onClick:_,onDragging:V,onPointerUp:J}=w.current;V==null||V(!1),J==null||J(),ee||_==null||_();break}}})},[S,E,n,O,I,Z,X,A,T]),tw({disabled:n,handleId:Z,resizeHandler:X,panelGroupElement:Y});const P={touchAction:"none",userSelect:"none"};return u.createElement(g,{...x,children:e,className:t,id:o,onBlur:()=>{D(!1),s==null||s()},onFocus:()=>{D(!0),c==null||c()},ref:b,role:"separator",style:{...P,...p},tabIndex:m,[$e.groupDirection]:E,[$e.groupId]:k,[$e.resizeHandle]:"",[$e.resizeHandleActive]:G==="drag"?"pointer":te?"keyboard":void 0,[$e.resizeHandleEnabled]:!n,[$e.resizeHandleId]:Z,[$e.resizeHandleState]:G})}Bu.displayName="PanelResizeHandle";function nw({className:e,...t}){return a.jsx($u,{"data-slot":"resizable-panel-group",className:Se("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function rl({...e}){return a.jsx(Su,{"data-slot":"resizable-panel",...e})}function rw({withHandle:e,className:t,...n}){return a.jsx(Bu,{"data-slot":"resizable-handle",className:Se("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(Ip,{className:"size-2.5"})})})}function ow({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 sw({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 iw={x:0,y:0},kt=16,aw=["top-start","bottom-end","top-end"];function lw({anchorRef:e,placement:t="top-start",offset:n=iw,fallbackPlacements:r=aw}){const o=u.useCallback((c,f,d)=>{let p=0,m=0;switch(d){case"top":p=c.top-f.height-n.y,m=c.left+(c.width-f.width)/2+n.x;break;case"top-start":p=c.top-f.height-n.y,m=c.left+n.x;break;case"top-end":p=c.top-f.height-n.y,m=c.right-f.width-n.x;break;case"bottom":p=c.bottom+n.y,m=c.left+(c.width-f.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-f.width-n.x;break;case"left":p=c.top+(c.height-f.height)/2+n.y,m=c.left-f.width-n.x;break;case"left-start":p=c.top+n.y,m=c.left-f.width-n.x;break;case"left-end":p=c.bottom-f.height-n.y,m=c.left-f.width-n.x;break;case"right":p=c.top+(c.height-f.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-f.height-n.y,m=c.right+n.x;break}return console.log(`Calculated position for ${d}:`,{top:p,left:m}),{top:p,left:m,placement:d}},[n.x,n.y]),s=u.useCallback((c,f)=>{const d={width:window.innerWidth,height:window.innerHeight};return c.left<kt||c.top<kt||c.left+f.width>d.width-kt||c.top+f.height>d.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 f=e.current.getBoundingClientRect(),d=c.getBoundingClientRect(),p=o(f,d,t);if(!s(p,d))return p;for(const x of r){const h=o(f,d,x);if(!s(h,d))return h}const m={width:window.innerWidth,height:window.innerHeight},g={...p};return g.left<kt?g.left=kt:g.left+d.width>m.width-kt&&(g.left=m.width-d.width-kt),g.top<kt?g.top=kt:g.top+d.height>m.height-kt&&(g.top=m.height-d.height-kt),g},[e,t,r,o,s]);return{getPositionStyle:u.useCallback(c=>{const f=i(c);return{position:"fixed",top:f.top,left:f.left,zIndex:1e3}},[i]),getOptimalPosition:i}}function cw({defaultWidth:e,minWidth:t,maxWidth:n,position:r="left",onWidthChange:o}){const[s,i]=u.useState(e),[l,c]=u.useState(!1),f=u.useRef(0),d=u.useRef(e),p=u.useCallback(b=>{b.preventDefault(),c(!0),f.current=b.clientX,d.current=s},[s]),m=u.useCallback(b=>{if(!l)return;const w=b.clientX-f.current,y=r==="right"?-w:w,E=Math.min(Math.max(d.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),f.current=b.touches[0].clientX,d.current=s},[s]),h=u.useCallback(b=>{if(!l)return;const w=b.touches[0].clientX-f.current,y=r==="right"?-w:w,E=Math.min(Math.max(d.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 uw=u.forwardRef(({children:e,defaultWidth:t=300,minWidth:n=200,maxWidth:r=800,position:o="left",resizable:s=!0,className:i,onWidthChange:l,...c},f)=>{const{width:d,isResizing:p,handleMouseDown:m,handleTouchStart:g}=cw({defaultWidth:t,minWidth:n,maxWidth:r,position:o,onWidthChange:l}),x={width:`${d}px`},h=o==="left"?"right-0":"left-0";return a.jsxs("div",{ref:f,className:Se("relative h-full flex-shrink-0 cursor-pointer",o==="left"?"border-r":"border-l",i),style:x,...c,children:[a.jsx("div",{className:Se("h-full overflow-x-hidden overflow-y-auto"),children:e}),s&&a.jsx("div",{className:Se("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(d+y,n),r);l==null||l(E)}},children:a.jsx("div",{className:Se("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)]")})})]})});uw.displayName="SidePanel";const Uu=u.createContext(null),Hu=u.createContext(void 0),Wu=u.createContext(null),Gu=u.createContext(null),Vu=u.createContext(void 0),Yu=u.createContext(null);function nn(){const e=u.useContext(Wu);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}const dw="https://solace.com/a2a/extensions/display-name",fw="https://solace.com/a2a/extensions/peer-agent-topology",pw="https://solace.com/a2a/extensions/sam/tools",mw=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===dw);(s=c==null?void 0:c.params)!=null&&s.display_name&&(t=c.params.display_name);const f=e.capabilities.extensions.find(p=>p.uri===fw);(i=f==null?void 0:f.params)!=null&&i.peer_agent_names&&(n=f.params.peer_agent_names);const d=e.capabilities.extensions.find(p=>p.uri===pw);(l=d==null?void 0:d.params)!=null&&l.tools&&(r=d.params.tools)}return{...e,display_name:t,peer_agents:n||[],tools:r||[],displayName:t,peerAgents:n||[]}},hw=()=>{const{configServerUrl:e}=nn(),[t,n]=u.useState([]),[r,o]=u.useState({}),[s,i]=u.useState(!0),[l,c]=u.useState(null),f=u.useCallback(async()=>{i(!0),c(null);try{const d=`${e}/api/v1`,p=await De(`${d}/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(mw);n(g);const x={};g.forEach(h=>{h.name&&(x[h.name]=h.displayName||h.name)}),o(x)}catch(d){console.error("Error fetching agents:",d),c(d instanceof Error?d.message:"Could not load agent information."),n([])}finally{i(!1)}},[e]);return u.useEffect(()=>{f()},[f]),u.useMemo(()=>({agents:t,agentNameMap:r,isLoading:s,error:l,refetch:f}),[t,r,s,l,f])},gw=e=>{const{configServerUrl:t}=nn(),[n,r]=u.useState([]),[o,s]=u.useState(!0),[i,l]=u.useState(null),c=`${t}/api/v1`,f=u.useCallback(async()=>{if(!e){r([]),s(!1);return}s(!0),l(null);try{const d=await De(`${c}/artifacts/${e}`,{credentials:"include"});if(!d.ok){const m=await d.json().catch(()=>({message:`Failed to fetch artifacts. ${d.statusText}`}));throw new Error(m.message||`Failed to fetch artifacts. ${d.statusText}`)}const p=await d.json();r(p)}catch(d){const p=d instanceof Error?d.message:"Failed to fetch artifacts.";l(p),r([])}finally{s(!1)}},[c,e]);return u.useEffect(()=>{f()},[f]),{artifacts:n,isLoading:o,error:i,refetch:f}},xw=()=>{const e=u.useContext(Uu);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Be=()=>{const e=u.useContext(Hu);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e};function vw(){const{messages:e}=Be(),t=nn(),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 Ku(){const e=u.useContext(Gu);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function ww(e,t){const[n,r]=u.useState(e);return u.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const bw=async(e,t,n)=>{const r=await De(`${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();fc(o,n.filename)},qu=()=>{const{configServerUrl:e}=nn(),{addNotification:t,sessionId:n}=Be();return{onDownload:async o=>{if(!n){t("Cannot download artifact: No active session.","error");return}try{await bw(e,n,o),t(`Downloaded artifact: ${o.filename}.`)}catch{t(`Failed to download artifact: ${o.filename}.`,"error")}}}},yw=({onFilesDropped:e,fileFilter:t,disabled:n=!1})=>{const[r,o]=u.useState(!1),s=u.useRef(0),i=u.useCallback(d=>{n||(d.preventDefault(),d.stopPropagation(),s.current=(s.current||0)+1,d.dataTransfer.types.includes("Files")&&o(!0))},[n,s]),l=u.useCallback(d=>{n||(d.preventDefault(),d.stopPropagation(),d.dataTransfer.types.includes("Files")&&(d.dataTransfer.dropEffect="copy"))},[n]),c=u.useCallback(d=>{n||(d.preventDefault(),d.stopPropagation(),s.current=(s.current||0)-1,s.current===0&&o(!1))},[n,s]),f=u.useCallback(d=>{if(n||(d.preventDefault(),d.stopPropagation(),o(!1),s.current=0,!d.dataTransfer.files||d.dataTransfer.files.length===0))return;const p=Array.from(d.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:f}},Xu=()=>{const{messages:e}=Be();return u.useMemo(()=>{const t=e.find(n=>n.isUser?n.parts.some(r=>r.kind==="text"&&r.text.trim()):!1);if(t){const r=t.parts.filter(o=>o.kind==="text").map(o=>o.text).join(" ").trim();if(r)return r.length>100?`${r.substring(0,100)}...`:r}return"New Chat"},[e])},Gi=()=>{const e=u.useContext(Vu);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function Zu(){const e=u.useContext(Yu);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}u.createContext(null);function Ju(e){const t=e+"CollectionProvider",[n,r]=An(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:v,children:b}=h,w=Ft.useRef(null),y=Ft.useRef(new Map).current;return a.jsx(o,{scope:v,itemMap:y,collectionRef:w,children:b})};i.displayName=t;const l=e+"CollectionSlot",c=Pn(l),f=Ft.forwardRef((h,v)=>{const{scope:b,children:w}=h,y=s(l,b),E=Oe(v,y.collectionRef);return a.jsx(c,{ref:E,children:w})});f.displayName=l;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Pn(d),g=Ft.forwardRef((h,v)=>{const{scope:b,children:w,...y}=h,E=Ft.useRef(null),k=Oe(v,E),I=s(d,b);return Ft.useEffect(()=>(I.itemMap.set(E,{ref:E,...y}),()=>void I.itemMap.delete(E))),a.jsx(m,{[p]:"",ref:k,children:w})});g.displayName=d;function x(h){const v=s(e+"CollectionConsumer",h);return Ft.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((I,A)=>y.indexOf(I.ref.current)-y.indexOf(A.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:f,ItemSlot:g},x,r]}var Sw=u.createContext(void 0);function Vi(e){const t=u.useContext(Sw);return e||t||"ltr"}const Yi=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 f,d,p,m,g;const c=(f=i.currentTarget.parentElement)==null?void 0:f.querySelectorAll('[role="menuitem"]');if(c)switch(i.key){case"ArrowDown":{i.preventDefault();const x=(l+1)%c.length;(d=c[x])==null||d.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:Se("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:Se("relative flex cursor-pointer items-center gap-2 px-3 py-1.5 my-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))})});Yi.displayName="Menu";var ts="Popover",[Qu,a1]=An(ts,[xr]),Yr=xr(),[Cw,Nn]=Qu(ts),ed=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,l=Yr(t),c=u.useRef(null),[f,d]=u.useState(!1),[p,m]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ts});return a.jsx(_i,{...l,children:a.jsx(Cw,{scope:t,contentId:Zt(),triggerRef:c,open:p,onOpenChange:m,onOpenToggle:u.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:f,onCustomAnchorAdd:u.useCallback(()=>d(!0),[]),onCustomAnchorRemove:u.useCallback(()=>d(!1),[]),modal:i,children:n})})};ed.displayName=ts;var td="PopoverAnchor",Ew=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Nn(td,n),s=Yr(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return u.useEffect(()=>(i(),()=>l()),[i,l]),a.jsx(Fo,{...s,...r,ref:t})});Ew.displayName=td;var nd="PopoverTrigger",rd=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Nn(nd,n),s=Yr(n),i=Oe(t,o.triggerRef),l=a.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ld(o.open),...r,ref:i,onClick:me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:a.jsx(Fo,{asChild:!0,...s,children:l})});rd.displayName=nd;var Ki="PopoverPortal",[Tw,Aw]=Qu(Ki,{forceMount:void 0}),od=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=Nn(Ki,t);return a.jsx(Tw,{scope:t,forceMount:n,children:a.jsx(mn,{present:n||s.open,children:a.jsx(Gr,{asChild:!0,container:o,children:r})})})};od.displayName=Ki;var lr="PopoverContent",sd=u.forwardRef((e,t)=>{const n=Aw(lr,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=Nn(lr,e.__scopePopover);return a.jsx(mn,{present:r||s.open,children:s.modal?a.jsx(kw,{...o,ref:t}):a.jsx(_w,{...o,ref:t})})});sd.displayName=lr;var Nw=Pn("PopoverContent.RemoveScroll"),kw=u.forwardRef((e,t)=>{const n=Nn(lr,e.__scopePopover),r=u.useRef(null),o=Oe(t,r),s=u.useRef(!1);return u.useEffect(()=>{const i=r.current;if(i)return Fi(i)},[]),a.jsx(Ho,{as:Nw,allowPinchZoom:!0,children:a.jsx(id,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:me(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:me(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,f=l.button===2||c;s.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:me(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),_w=u.forwardRef((e,t)=>{const n=Nn(lr,e.__scopePopover),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(id,{...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,f;(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;((f=n.triggerRef.current)==null?void 0:f.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),id=u.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:f,onInteractOutside:d,...p}=e,m=Nn(lr,n),g=Yr(n);return Oi(),a.jsx(Bo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(Hr,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:f,onDismiss:()=>m.onOpenChange(!1),children:a.jsx(Ii,{"data-state":ld(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)"}})})})}),ad="PopoverClose",Iw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Nn(ad,n);return a.jsx(_e.button,{type:"button",...r,ref:t,onClick:me(e.onClick,()=>o.onOpenChange(!1))})});Iw.displayName=ad;var jw="PopoverArrow",Mw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Yr(n);return a.jsx(ji,{...o,...r,ref:t})});Mw.displayName=jw;function ld(e){return e?"open":"closed"}var Rw=ed,Pw=rd,Lw=od,Dw=sd;function cd({...e}){return a.jsx(Rw,{"data-slot":"popover",...e})}function ud({...e}){return a.jsx(Pw,{"data-slot":"popover-trigger",...e})}function dd({className:e,align:t="center",sideOffset:n=4,...r}){return a.jsx(Lw,{children:a.jsx(Dw,{"data-slot":"popover-content",align:t,sideOffset:n,className:Se("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 z-50 w-auto origin-(--radix-popover-content-transform-origin) bg-background rounded-sm border px-0 py-1 shadow-sm outline-hidden",e),...r})})}function Ow({isOpen:e,onClose:t,anchorRef:n,children:r,placement:o="bottom-start",offset:s,className:i,closeOnClickOutside:l=!0,closeOnEscape:c=!0,portal:f=!0,animationDuration:d=150,fallbackPlacements:p}){const m=u.useRef(null),[g,x]=u.useState({}),[h,v]=u.useState(!1);ow({ref:m,anchorRef:n,onClickOutside:t,enabled:e&&l}),sw({onEscape:t,enabled:e&&c});const{getPositionStyle:b}=lw({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:Se("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 ${d}ms ease-in-out, transform ${d}ms ease-in-out`,pointerEvents:e&&h?"auto":"none",visibility:h?"visible":"hidden"},children:r});return f?Ur.createPortal(w,document.body):w}function ol(e,[t,n]){return Math.min(n,Math.max(t,e))}function Fw(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 zw=[" ","Enter","ArrowUp","ArrowDown"],$w=[" ","Enter"],zn="Select",[ns,rs,Bw]=Ju(zn),[vr,l1]=An(zn,[Bw,xr]),os=xr(),[Uw,kn]=vr(zn),[Hw,Ww]=vr(zn),fd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:l,onValueChange:c,dir:f,name:d,autoComplete:p,disabled:m,required:g,form:x}=e,h=os(t),[v,b]=u.useState(null),[w,y]=u.useState(null),[E,k]=u.useState(!1),I=Vi(f),[A,T]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:zn}),[Y,Z]=Dn({prop:i,defaultProp:l,onChange:c,caller:zn}),G=u.useRef(null),q=v?x||!!v.closest("form"):!0,[te,D]=u.useState(new Set),X=Array.from(te).map(N=>N.props.value).join(";");return a.jsx(_i,{...h,children:a.jsxs(Uw,{required:g,scope:t,trigger:v,onTriggerChange:b,valueNode:w,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:k,contentId:Zt(),value:Y,onValueChange:Z,open:A,onOpenChange:T,dir:I,triggerPointerDownPosRef:G,disabled:m,children:[a.jsx(ns.Provider,{scope:t,children:a.jsx(Hw,{scope:e.__scopeSelect,onNativeOptionAdd:u.useCallback(N=>{D(M=>new Set(M).add(N))},[]),onNativeOptionRemove:u.useCallback(N=>{D(M=>{const S=new Set(M);return S.delete(N),S})},[]),children:n})}),q?a.jsxs(Pd,{"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:p,value:Y,onChange:N=>Z(N.target.value),disabled:m,form:x,children:[Y===void 0?a.jsx("option",{value:""}):null,Array.from(te)]},X):null]})})};fd.displayName=zn;var pd="SelectTrigger",md=u.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=os(n),i=kn(pd,n),l=i.disabled||r,c=Oe(t,i.onTriggerChange),f=rs(n),d=u.useRef("touch"),[p,m,g]=Dd(h=>{const v=f().filter(y=>!y.disabled),b=v.find(y=>y.value===i.value),w=Od(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(Fo,{asChild:!0,...s,children:a.jsx(_e.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":Ld(i.value)?"":void 0,...o,ref:c,onClick:me(o.onClick,h=>{h.currentTarget.focus(),d.current!=="mouse"&&x(h)}),onPointerDown:me(o.onPointerDown,h=>{d.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:me(o.onKeyDown,h=>{const v=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(v&&h.key===" ")&&zw.includes(h.key)&&(x(),h.preventDefault())})})})});md.displayName=pd;var hd="SelectValue",gd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...l}=e,c=kn(hd,n),{onValueNodeHasChildrenChange:f}=c,d=s!==void 0,p=Oe(t,c.onValueNodeChange);return nt(()=>{f(d)},[f,d]),a.jsx(_e.span,{...l,ref:p,style:{pointerEvents:"none"},children:Ld(c.value)?a.jsx(a.Fragment,{children:i}):s})});gd.displayName=hd;var Gw="SelectIcon",xd=u.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return a.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});xd.displayName=Gw;var Vw="SelectPortal",vd=e=>a.jsx(Gr,{asChild:!0,...e});vd.displayName=Vw;var $n="SelectContent",wd=u.forwardRef((e,t)=>{const n=kn($n,e.__scopeSelect),[r,o]=u.useState();if(nt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(a.jsx(bd,{scope:e.__scopeSelect,children:a.jsx(ns.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),s):null}return a.jsx(yd,{...e,ref:t})});wd.displayName=$n;var Dt=10,[bd,_n]=vr($n),Yw="SelectContentImpl",Kw=Pn("SelectContent.RemoveScroll"),yd=u.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:l,sideOffset:c,align:f,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:x,hideWhenDetached:h,avoidCollisions:v,...b}=e,w=kn($n,n),[y,E]=u.useState(null),[k,I]=u.useState(null),A=Oe(t,_=>E(_)),[T,Y]=u.useState(null),[Z,G]=u.useState(null),q=rs(n),[te,D]=u.useState(!1),X=u.useRef(!1);u.useEffect(()=>{if(y)return Fi(y)},[y]),Oi();const N=u.useCallback(_=>{const[V,...J]=q().map(re=>re.ref.current),[ne]=J.slice(-1),ie=document.activeElement;for(const re of _)if(re===ie||(re==null||re.scrollIntoView({block:"nearest"}),re===V&&k&&(k.scrollTop=0),re===ne&&k&&(k.scrollTop=k.scrollHeight),re==null||re.focus(),document.activeElement!==ie))return},[q,k]),M=u.useCallback(()=>N([T,y]),[N,T,y]);u.useEffect(()=>{te&&M()},[te,M]);const{onOpenChange:S,triggerPointerDownPosRef:O}=w;u.useEffect(()=>{if(y){let _={x:0,y:0};const V=ne=>{var ie,re;_={x:Math.abs(Math.round(ne.pageX)-(((ie=O.current)==null?void 0:ie.x)??0)),y:Math.abs(Math.round(ne.pageY)-(((re=O.current)==null?void 0:re.y)??0))}},J=ne=>{_.x<=10&&_.y<=10?ne.preventDefault():y.contains(ne.target)||S(!1),document.removeEventListener("pointermove",V),O.current=null};return O.current!==null&&(document.addEventListener("pointermove",V),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",V),document.removeEventListener("pointerup",J,{capture:!0})}}},[y,S,O]),u.useEffect(()=>{const _=()=>S(!1);return window.addEventListener("blur",_),window.addEventListener("resize",_),()=>{window.removeEventListener("blur",_),window.removeEventListener("resize",_)}},[S]);const[P,R]=Dd(_=>{const V=q().filter(ie=>!ie.disabled),J=V.find(ie=>ie.ref.current===document.activeElement),ne=Od(V,_,J);ne&&setTimeout(()=>ne.ref.current.focus())}),ee=u.useCallback((_,V,J)=>{const ne=!X.current&&!J;(w.value!==void 0&&w.value===V||ne)&&(Y(_),ne&&(X.current=!0))},[w.value]),L=u.useCallback(()=>y==null?void 0:y.focus(),[y]),H=u.useCallback((_,V,J)=>{const ne=!X.current&&!J;(w.value!==void 0&&w.value===V||ne)&&G(_)},[w.value]),j=r==="popper"?Ks:Sd,W=j===Ks?{side:l,sideOffset:c,align:f,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:x,hideWhenDetached:h,avoidCollisions:v}:{};return a.jsx(bd,{scope:n,content:y,viewport:k,onViewportChange:I,itemRefCallback:ee,selectedItem:T,onItemLeave:L,itemTextRefCallback:H,focusSelectedItem:M,selectedItemText:Z,position:r,isPositioned:te,searchRef:P,children:a.jsx(Ho,{as:Kw,allowPinchZoom:!0,children:a.jsx(Bo,{asChild:!0,trapped:w.open,onMountAutoFocus:_=>{_.preventDefault()},onUnmountAutoFocus:me(o,_=>{var V;(V=w.trigger)==null||V.focus({preventScroll:!0}),_.preventDefault()}),children:a.jsx(Hr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:_=>_.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:a.jsx(j,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:_=>_.preventDefault(),...b,...W,onPlaced:()=>D(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:me(b.onKeyDown,_=>{const V=_.ctrlKey||_.altKey||_.metaKey;if(_.key==="Tab"&&_.preventDefault(),!V&&_.key.length===1&&R(_.key),["ArrowUp","ArrowDown","Home","End"].includes(_.key)){let ne=q().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);if(["ArrowUp","End"].includes(_.key)&&(ne=ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(_.key)){const ie=_.target,re=ne.indexOf(ie);ne=ne.slice(re+1)}setTimeout(()=>N(ne)),_.preventDefault()}})})})})})})});yd.displayName=Yw;var qw="SelectItemAlignedPosition",Sd=u.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=kn($n,n),i=_n($n,n),[l,c]=u.useState(null),[f,d]=u.useState(null),p=Oe(t,A=>d(A)),m=rs(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&&f&&h&&v&&b){const A=s.trigger.getBoundingClientRect(),T=f.getBoundingClientRect(),Y=s.valueNode.getBoundingClientRect(),Z=b.getBoundingClientRect();if(s.dir!=="rtl"){const ie=Z.left-T.left,re=Y.left-ie,ue=A.left-re,de=A.width+ue,Ie=Math.max(de,T.width),Re=window.innerWidth-Dt,Fe=ol(re,[Dt,Math.max(Dt,Re-Ie)]);l.style.minWidth=de+"px",l.style.left=Fe+"px"}else{const ie=T.right-Z.right,re=window.innerWidth-Y.right-ie,ue=window.innerWidth-A.right-re,de=A.width+ue,Ie=Math.max(de,T.width),Re=window.innerWidth-Dt,Fe=ol(re,[Dt,Math.max(Dt,Re-Ie)]);l.style.minWidth=de+"px",l.style.right=Fe+"px"}const G=m(),q=window.innerHeight-Dt*2,te=h.scrollHeight,D=window.getComputedStyle(f),X=parseInt(D.borderTopWidth,10),N=parseInt(D.paddingTop,10),M=parseInt(D.borderBottomWidth,10),S=parseInt(D.paddingBottom,10),O=X+N+te+S+M,P=Math.min(v.offsetHeight*5,O),R=window.getComputedStyle(h),ee=parseInt(R.paddingTop,10),L=parseInt(R.paddingBottom,10),H=A.top+A.height/2-Dt,j=q-H,W=v.offsetHeight/2,_=v.offsetTop+W,V=X+N+_,J=O-V;if(V<=H){const ie=G.length>0&&v===G[G.length-1].ref.current;l.style.bottom="0px";const re=f.clientHeight-h.offsetTop-h.offsetHeight,ue=Math.max(j,W+(ie?L:0)+re+M),de=V+ue;l.style.height=de+"px"}else{const ie=G.length>0&&v===G[0].ref.current;l.style.top="0px";const ue=Math.max(H,X+h.offsetTop+(ie?ee:0)+W)+J;l.style.height=ue+"px",h.scrollTop=V-H+h.offsetTop}l.style.margin=`${Dt}px 0`,l.style.minHeight=P+"px",l.style.maxHeight=q+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[m,s.trigger,s.valueNode,l,f,h,v,b,s.dir,r]);nt(()=>y(),[y]);const[E,k]=u.useState();nt(()=>{f&&k(window.getComputedStyle(f).zIndex)},[f]);const I=u.useCallback(A=>{A&&x.current===!0&&(y(),w==null||w(),x.current=!1)},[y,w]);return a.jsx(Zw,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:I,children:a.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:a.jsx(_e.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Sd.displayName=qw;var Xw="SelectPopperPosition",Ks=u.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Dt,...s}=e,i=os(n);return a.jsx(Ii,{...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)"}})});Ks.displayName=Xw;var[Zw,qi]=vr($n,{}),qs="SelectViewport",Cd=u.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=_n(qs,n),i=qi(qs,n),l=Oe(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(ns.Slot,{scope:n,children:a.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:me(o.onScroll,f=>{const d=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const g=Math.abs(c.current-d.scrollTop);if(g>0){const x=window.innerHeight-Dt*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"&&(d.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Cd.displayName=qs;var Ed="SelectGroup",[Jw,Qw]=vr(Ed),e0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Zt();return a.jsx(Jw,{scope:n,id:o,children:a.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});e0.displayName=Ed;var Td="SelectLabel",t0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Qw(Td,n);return a.jsx(_e.div,{id:o.id,...r,ref:t})});t0.displayName=Td;var Ao="SelectItem",[n0,Ad]=vr(Ao),Nd=u.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,l=kn(Ao,n),c=_n(Ao,n),f=l.value===r,[d,p]=u.useState(s??""),[m,g]=u.useState(!1),x=Oe(t,w=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,w,r,o)}),h=Zt(),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(n0,{scope:n,value:r,disabled:o,textId:h,isSelected:f,onItemTextChange:u.useCallback(w=>{p(y=>y||((w==null?void 0:w.textContent)??"").trim())},[]),children:a.jsx(ns.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:a.jsx(_e.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":f&&m,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:me(i.onFocus,()=>g(!0)),onBlur:me(i.onBlur,()=>g(!1)),onClick:me(i.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:me(i.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:me(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:me(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:me(i.onPointerLeave,w=>{var y;w.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:me(i.onKeyDown,w=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&w.key===" "||($w.includes(w.key)&&b(),w.key===" "&&w.preventDefault())})})})})});Nd.displayName=Ao;var jr="SelectItemText",kd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=kn(jr,n),l=_n(jr,n),c=Ad(jr,n),f=Ww(jr,n),[d,p]=u.useState(null),m=Oe(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=d==null?void 0:d.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}=f;return nt(()=>(h(x),()=>v(x)),[h,v,x]),a.jsxs(a.Fragment,{children:[a.jsx(_e.span,{id:c.textId,...s,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ur.createPortal(s.children,i.valueNode):null]})});kd.displayName=jr;var _d="SelectItemIndicator",Id=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Ad(_d,n).isSelected?a.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});Id.displayName=_d;var Xs="SelectScrollUpButton",jd=u.forwardRef((e,t)=>{const n=_n(Xs,e.__scopeSelect),r=qi(Xs,e.__scopeSelect),[o,s]=u.useState(!1),i=Oe(t,r.onScrollButtonChange);return nt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=c.scrollTop>0;s(f)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Rd,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});jd.displayName=Xs;var Zs="SelectScrollDownButton",Md=u.forwardRef((e,t)=>{const n=_n(Zs,e.__scopeSelect),r=qi(Zs,e.__scopeSelect),[o,s]=u.useState(!1),i=Oe(t,r.onScrollButtonChange);return nt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<f;s(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Rd,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});Md.displayName=Zs;var Rd=u.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=_n("SelectScrollButton",n),i=u.useRef(null),l=rs(n),c=u.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),nt(()=>{var d;const f=l().find(p=>p.ref.current===document.activeElement);(d=f==null?void 0:f.ref.current)==null||d.scrollIntoView({block:"nearest"})},[l]),a.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:me(o.onPointerMove,()=>{var f;(f=s.onItemLeave)==null||f.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:me(o.onPointerLeave,()=>{c()})})}),r0="SelectSeparator",o0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return a.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});o0.displayName=r0;var Js="SelectArrow",s0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=os(n),s=kn(Js,n),i=_n(Js,n);return s.open&&i.position==="popper"?a.jsx(ji,{...o,...r,ref:t}):null});s0.displayName=Js;var i0="SelectBubbleInput",Pd=u.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=u.useRef(null),s=Oe(r,o),i=Fw(t);return u.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(p)}},[i,t]),a.jsx(_e.select,{...n,style:{...Oc,...n.style},ref:s,defaultValue:t})});Pd.displayName=i0;function Ld(e){return e===""||e===void 0}function Dd(e){const t=yn(e),n=u.useRef(""),r=u.useRef(0),o=u.useCallback(i=>{const l=n.current+i;t(l),(function c(f){n.current=f,window.clearTimeout(r.current),f!==""&&(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 Od(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=a0(e,Math.max(s,0));o.length===1&&(i=i.filter(f=>f!==n));const c=i.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function a0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var l0=fd,c0=md,u0=gd,d0=xd,f0=vd,p0=wd,m0=Cd,h0=Nd,g0=kd,x0=Id,v0=jd,w0=Md;function Fd({...e}){return a.jsx(l0,{"data-slot":"select",...e})}function zd({...e}){return a.jsx(u0,{"data-slot":"select-value",...e})}function $d({className:e,size:t="default",children:n,...r}){return a.jsxs(c0,{"data-slot":"select-trigger","data-size":t,className:Se("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(d0,{asChild:!0,children:a.jsx(zl,{className:"size-4 opacity-50"})})]})}function Bd({className:e,children:t,position:n="popper",...r}){return a.jsx(f0,{children:a.jsxs(p0,{"data-slot":"select-content",className:Se("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(b0,{}),a.jsx(m0,{className:Se("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(y0,{})]})})}function Ud({className:e,children:t,...n}){return a.jsxs(h0,{"data-slot":"select-item",className:Se("[&_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 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 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)]",e),...n,children:[a.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:a.jsx(x0,{children:a.jsx(mi,{className:"size-4"})})}),a.jsx(g0,{children:t})]})}function b0({className:e,...t}){return a.jsx(v0,{"data-slot":"select-scroll-up-button",className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(jp,{className:"size-4"})})}function y0({className:e,...t}){return a.jsx(w0,{"data-slot":"select-scroll-down-button",className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(zl,{className:"size-4"})})}var Ns="rovingFocusGroup.onEntryFocus",S0={bubbles:!1,cancelable:!0},Kr="RovingFocusGroup",[Qs,Hd,C0]=Ju(Kr),[E0,Wd]=An(Kr,[C0]),[T0,A0]=E0(Kr),Gd=u.forwardRef((e,t)=>a.jsx(Qs.Provider,{scope:e.__scopeRovingFocusGroup,children:a.jsx(Qs.Slot,{scope:e.__scopeRovingFocusGroup,children:a.jsx(N0,{...e,ref:t})})}));Gd.displayName=Kr;var N0=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:f,preventScrollOnEntryFocus:d=!1,...p}=e,m=u.useRef(null),g=Oe(t,m),x=Vi(s),[h,v]=Dn({prop:i,defaultProp:l??null,onChange:c,caller:Kr}),[b,w]=u.useState(!1),y=yn(f),E=Hd(n),k=u.useRef(!1),[I,A]=u.useState(0);return u.useEffect(()=>{const T=m.current;if(T)return T.addEventListener(Ns,y),()=>T.removeEventListener(Ns,y)},[y]),a.jsx(T0,{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(()=>A(T=>T+1),[]),onFocusableItemRemove:u.useCallback(()=>A(T=>T-1),[]),children:a.jsx(_e.div,{tabIndex:b||I===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:me(e.onMouseDown,()=>{k.current=!0}),onFocus:me(e.onFocus,T=>{const Y=!k.current;if(T.target===T.currentTarget&&Y&&!b){const Z=new CustomEvent(Ns,S0);if(T.currentTarget.dispatchEvent(Z),!Z.defaultPrevented){const G=E().filter(N=>N.focusable),q=G.find(N=>N.active),te=G.find(N=>N.id===h),X=[q,te,...G].filter(Boolean).map(N=>N.ref.current);Kd(X,d)}}k.current=!1}),onBlur:me(e.onBlur,()=>w(!1))})})}),Vd="RovingFocusGroupItem",Yd=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...l}=e,c=Zt(),f=s||c,d=A0(Vd,n),p=d.currentTabStopId===f,m=Hd(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:h}=d;return u.useEffect(()=>{if(r)return g(),()=>x()},[r,g,x]),a.jsx(Qs.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:a.jsx(_e.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:me(e.onMouseDown,v=>{r?d.onItemFocus(f):v.preventDefault()}),onFocus:me(e.onFocus,()=>d.onItemFocus(f)),onKeyDown:me(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=I0(v,d.orientation,d.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=d.loop?j0(y,E+1):y.slice(E+1)}setTimeout(()=>Kd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:h!=null}):i})})});Yd.displayName=Vd;var k0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function I0(e,t,n){const r=_0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return k0[r]}function Kd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function j0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var M0=Gd,R0=Yd,ss="Tabs",[P0,c1]=An(ss,[Wd]),qd=Wd(),[L0,Xi]=P0(ss),Xd=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:l,activationMode:c="automatic",...f}=e,d=Vi(l),[p,m]=Dn({prop:r,onChange:o,defaultProp:s??"",caller:ss});return a.jsx(L0,{scope:n,baseId:Zt(),value:p,onValueChange:m,orientation:i,dir:d,activationMode:c,children:a.jsx(_e.div,{dir:d,"data-orientation":i,...f,ref:t})})});Xd.displayName=ss;var Zd="TabsList",Jd=u.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=Xi(Zd,n),i=qd(n);return a.jsx(M0,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:a.jsx(_e.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});Jd.displayName=Zd;var Qd="TabsTrigger",ef=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=Xi(Qd,n),l=qd(n),c=rf(i.baseId,r),f=of(i.baseId,r),d=r===i.value;return a.jsx(R0,{asChild:!0,...l,focusable:!o,active:d,children:a.jsx(_e.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":f,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:t,onMouseDown:me(e.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?i.onValueChange(r):p.preventDefault()}),onKeyDown:me(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&i.onValueChange(r)}),onFocus:me(e.onFocus,()=>{const p=i.activationMode!=="manual";!d&&!o&&p&&i.onValueChange(r)})})})});ef.displayName=Qd;var tf="TabsContent",nf=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,l=Xi(tf,n),c=rf(l.baseId,r),f=of(l.baseId,r),d=r===l.value,p=u.useRef(d);return u.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),a.jsx(mn,{present:o||d,children:({present:m})=>a.jsx(_e.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:f,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&s})})});nf.displayName=tf;function rf(e,t){return`${e}-trigger-${t}`}function of(e,t){return`${e}-content-${t}`}var D0=Xd,O0=Jd,F0=ef,z0=nf;function $0({className:e,...t}){return a.jsx(D0,{"data-slot":"tabs",className:Se("flex flex-col gap-2",e),...t})}function B0({className:e,...t}){return a.jsx(O0,{"data-slot":"tabs-list",className:Se("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function sl({className:e,...t}){return a.jsx(F0,{"data-slot":"tabs-trigger","data-testid":t.value,"aria-label":t.value,title:t.title,className:Se("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 il({className:e,...t}){return a.jsx(z0,{"data-slot":"tabs-content",className:Se("flex-1 outline-none",e),...t})}const sf=u.forwardRef(({className:e,...t},n)=>a.jsx(Xc,{autoComplete:"off",ref:n,name:"message","data-testid":"chat-input",className:Se("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}));sf.displayName="ChatInput";const U0=Tn("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"}}),af=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:Se(U0({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)}));af.displayName="ChatBubble";const H0=Tn("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"}}),lf=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:Se(H0({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})}));lf.displayName="ChatBubbleMessage";const W0=u.forwardRef(({variant:e,className:t,children:n,...r},o)=>a.jsx("div",{ref:o,className:Se("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}));W0.displayName="ChatBubbleActionWrapper";const cf={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},uf=Ft.forwardRef(({className:e="",children:t,...n},r)=>{const{scrollRef:o,isAtBottom:s,disableAutoScroll:i,scrollToBottom:l,userHasScrolled:c}=tb({smooth:!0,content:t});return u.useImperativeHandle(r,()=>({scrollToBottom:l})),a.jsxs("div",{className:`fade-both-mask min-h-0 flex-1 py-3 relative h-full w-full ${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:cf,children:t})}),!s&&c&&a.jsx(ve,{onClick:()=>{l()},size:"icon",variant:"outline",className:"absolute bottom-2 left-1/2 z-20 inline-flex -translate-x-1/2 transform rounded-full shadow-md bg-background","aria-label":"Scroll to bottom",children:a.jsx($l,{className:"h-4 w-4"})})]})});uf.displayName="ChatMessageList";const G0=Tn("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),V0=Tn("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 Y0({size:e,show:t,children:n,className:r,variant:o}){return a.jsxs("span",{className:G0({show:t}),children:[a.jsx(hi,{className:Se(V0({size:e,variant:o}),r)}),n]})}function K0({className:e=""}){return a.jsx(Y0,{size:"small",variant:"primary",className:e})}const io={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)]"},q0=Tn("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:io.error,warning:io.warning,info:io.info,success:io.success}},defaultVariants:{variant:"default"}});function df({className:e,variant:t,type:n,asChild:r=!1,...o}){const s=r?ec:"span";return a.jsx(s,{"data-slot":"badge",className:Se(q0({variant:t,type:n}),e),...o})}const X0=Tn("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 Z0({className:e,variant:t,...n}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:Se(X0({variant:t}),e),...n})}function J0({className:e,...t}){return a.jsx("div",{"data-slot":"alert-title",className:Se("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function Q0({message:e,type:t}){return a.jsx("div",{className:"transform transition-all duration-200 ease-in-out",children:a.jsx(Z0,{className:"border-border bg-accent max-w-80 rounded-sm shadow-md",children:a.jsxs(J0,{className:"flex items-center text-sm",children:[t==="error"&&a.jsx(gi,{className:"mr-2 text-[var(--color-error-wMain)]"}),a.jsx("div",{className:"truncate",children:e})]})})})}function eb(){const{notifications:e}=Be();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(Q0,{id:t.id,message:t.message,type:t.type,duration:t.type==="error"?5e3:3e3})},t.id))})}function tb(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,f]=u.useState({isAtBottom:!0,autoScrollEnabled:!0}),d=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"}),f({isAtBottom:!0,autoScrollEnabled:!0}),l.current=!1},[n]),m=u.useCallback(()=>{if(!s.current)return;const x=d(s.current);f(h=>({isAtBottom:x,autoScrollEnabled:x?!0:h.autoScrollEnabled}))},[d]);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?d(s.current):!1)||(l.current=!0,f(h=>({...h,autoScrollEnabled:!1})))},[d]);return{scrollRef:s,isAtBottom:c.isAtBottom,autoScrollEnabled:c.autoScrollEnabled,scrollToBottom:()=>p(),disableAutoScroll:g,userHasScrolled:l.current}}const nb=({fileName:e,onRemove:t})=>a.jsxs(df,{className:"max-w-50 gap-1.5 rounded-full bg-muted 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(ve,{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(Ro,{})})]}),rb=({agents:e=[],scrollToBottom:t})=>{const{isResponding:n,isCancelling:r,userInput:o,selectedAgentName:s,setSelectedAgentName:i,setUserInput:l,handleSubmit:c,handleCancel:f}=Be(),d=u.useRef(null),[p,m]=u.useState([]),g=u.useRef(null),x=u.useRef(n),[h,v]=u.useState(o),b=ww(h,300);u.useEffect(()=>{l(b)},[b,l]),u.useEffect(()=>{v(o)},[o]),u.useEffect(()=>{x.current&&!n&&setTimeout(()=>{var D;(D=g.current)==null||D.focus()},100),x.current=n},[n]);const w=()=>{var D;n||(D=d.current)==null||D.click()},y=D=>{const X=D.target.files;if(X){const N=Array.from(X).filter(M=>!p.some(S=>S.name===M.name&&S.size===M.size&&S.lastModified===M.lastModified));N.length>0&&m(M=>[...M,...N])}D.target&&(D.target.value=""),setTimeout(()=>{var N;(N=g.current)==null||N.focus()},100)},E=D=>{if(n)return;const X=D.clipboardData;if(!X||!X.files||X.files.length===0)return;X.files.length>0&&D.preventDefault();const N=Array.from(X.files).filter(M=>!p.some(S=>S.name===M.name&&S.size===M.size&&S.lastModified===M.lastModified));N.length>0&&m(M=>[...M,...N])},k=D=>{m(X=>X.filter((N,M)=>M!==D))},I=u.useMemo(()=>!n&&((h==null?void 0:h.trim())||p.length!==0),[n,h,p]),A=async D=>{D.preventDefault(),I&&(await c(D,p,h.trim()),m([]),v(""),t==null||t())},T=D=>{if(n)return;const X=D.filter(N=>!p.some(M=>M.name===N.name&&M.size===N.size&&M.lastModified===N.lastModified));X.length>0&&m(N=>[...N,...X])},{isDragging:Y,handleDragEnter:Z,handleDragOver:G,handleDragLeave:q,handleDrop:te}=yw({onFilesDropped:T,disabled:n});return a.jsxs("div",{className:`rounded-lg border p-4 shadow-sm ${Y?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:Z,onDragOver:G,onDragLeave:q,onDrop:te,children:[a.jsx("input",{type:"file",ref:d,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((D,X)=>a.jsx(nb,{fileName:D.name,onRemove:()=>k(X)},`${D.name}-${D.lastModified}-${X}`))}),a.jsx(sf,{ref:g,value:h,onChange:D=>v(D.target.value),placeholder:"How can I help you today?",className:"text-base/normal min-h-0 max-h-50 resize-none border-none p-3 shadow-none rounded-2xl focus-visible:outline-none field-sizing-content transition-[height] duration-500 ease-in-out",rows:1,onPaste:E,onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&I&&A(D)}}),a.jsxs("div",{className:"flex items-center gap-2 m-2",children:[a.jsx(ve,{variant:"ghost",onClick:w,disabled:n,tooltip:"Attach file",children:a.jsx(Bl,{className:"size-4"})}),a.jsx("div",{children:"Agent: "}),a.jsxs(Fd,{value:s,onValueChange:i,disabled:n||e.length===0,children:[a.jsx($d,{className:"w-[250px]",children:a.jsx(zd,{defaultValue:s})}),a.jsx(Bd,{children:e.map(D=>a.jsx(Ud,{value:D.name,children:D.displayName||D.name},D.name))})]}),n&&!r?a.jsxs(ve,{className:"ml-auto gap-1.5",onClick:f,variant:"outline",disabled:r,tooltip:"Cancel",children:[a.jsx(Mp,{className:"size-4"}),"Stop"]}):a.jsx(ve,{variant:"ghost",className:"ml-auto gap-1.5",onClick:A,disabled:!I,tooltip:"Send message",children:a.jsx(Rp,{className:"size-4"})})]})]})};function ob(e,t){return t&&t.toLowerCase().startsWith("text/")?!0:e?e.toLowerCase().endsWith(".txt")||e.toLowerCase().endsWith(".text"):!1}function sb(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 ib(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 ab(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 lb(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 cb(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 ub(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 db(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 fb(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 qr(e,t){return sb(e,t)?"html":ib(e,t)?"mermaid":lb(e,t)?"image":db(e,t)?"markdown":fb(e,t)?"audio":cb(e,t)?"json":ub(e,t)?"yaml":ab(e,t)?"csv":ob(e,t)?"text":null}function ff(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 pf=["csv","html","json","mermaid","image","markdown","audio","text","yaml"],pb=["image","audio"],mb=e=>{if(!e||!e.content)return"";const t=qr(e.name,e.mime_type);if(!t||!pf.includes(t))return"";if(pb.includes(t))return e.content;try{return ff(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},mf=5*1024*1024,hb=pc(mf);function gb(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=qr(e.filename,e.mime_type);return!t||!pf.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>mf?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${hb}.`}:{canPreview:!0}}const hf=(e,t="h-4 w-4")=>{if(!e)return a.jsx(ua,{className:t});switch(qr(e.filename,e.mime_type)){case"image":case"mermaid":return a.jsx(Fp,{className:t});case"audio":return a.jsx(Op,{className:t});case"html":return a.jsx(Dp,{className:t});case"text":return a.jsx(sr,{className:t});case"csv":return a.jsx(Lp,{className:t});case"json":return a.jsx(Pp,{className:t});default:return a.jsx(ua,{className:t})}},gf=({fileAttachment:e,isEmbedded:t=!1})=>a.jsx(xf,{filename:e.name,mimeType:e.mime_type,onDownload:()=>rh(e),className:"ml-4",isEmbedded:t}),xf=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:o=!1})=>{const{artifacts:s,setPreviewArtifact:i,openSidePanelTab:l}=Be(),c=u.useMemo(()=>s.find(d=>d.filename===e),[s,e]),f=u.useMemo(()=>hf(c||{filename:e,mime_type:t||""}),[c,e,t]);return a.jsxs("div",{className:`flex flex-shrink items-center gap-2 rounded-lg bg-[var(--accent-background)] px-2 py-1 h-11 max-w-xs ${n||""}`,children:[f,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(ve,{variant:"ghost",onClick:d=>{d.stopPropagation(),l("files"),i(c)},tooltip:"Preview",children:a.jsx(Ul,{className:"h-4 w-4"})}),r&&a.jsx(ve,{variant:"ghost",onClick:()=>r(),tooltip:"Download file",children:a.jsx(xi,{className:"h-4 w-4"})})]})},xb=({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."]})})},vb=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},wb=({content:e,setRenderError:t})=>{u.useEffect(()=>{t(null)},[e,t]);const n=u.useMemo(()=>{try{return vb(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:"border text-sm w-full",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 break-words align-top",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."})},bb=({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 dark:bg-gray-400 border",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)})})},yb=({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 vf(){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 Sb=({content:e})=>{const{ref:t,handleKeyDown:n}=vf();return a.jsx("div",{className:"w-full p-4",children:a.jsx("div",{ref:t,className:"max-w-full overflow-hidden focus-visible:outline-none select-text",tabIndex:0,onKeyDown:n,children:a.jsx(or,{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:wf,setPrototypeOf:al,isFrozen:Cb,getPrototypeOf:Eb,getOwnPropertyDescriptor:Tb}=Object;let{freeze:ct,seal:It,create:bf}=Object,{apply:ei,construct:ti}=typeof Reflect<"u"&&Reflect;ct||(ct=function(t){return t});It||(It=function(t){return t});ei||(ei=function(t,n,r){return t.apply(n,r)});ti||(ti=function(t,n){return new t(...n)});const ao=ut(Array.prototype.forEach),Ab=ut(Array.prototype.lastIndexOf),ll=ut(Array.prototype.pop),Sr=ut(Array.prototype.push),Nb=ut(Array.prototype.splice),vo=ut(String.prototype.toLowerCase),ks=ut(String.prototype.toString),cl=ut(String.prototype.match),Cr=ut(String.prototype.replace),kb=ut(String.prototype.indexOf),_b=ut(String.prototype.trim),Ot=ut(Object.prototype.hasOwnProperty),it=ut(RegExp.prototype.test),Er=Ib(TypeError);function ut(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 ei(e,t,r)}}function Ib(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ti(e,n)}}function Ae(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:vo;al&&al(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(Cb(t)||(t[r]=s),o=s)}e[o]=!0}return e}function jb(e){for(let t=0;t<e.length;t++)Ot(e,t)||(e[t]=null);return e}function ln(e){const t=bf(null);for(const[n,r]of wf(e))Ot(e,n)&&(Array.isArray(r)?t[n]=jb(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=ln(r):t[n]=r);return t}function Tr(e,t){for(;e!==null;){const r=Tb(e,t);if(r){if(r.get)return ut(r.get);if(typeof r.value=="function")return ut(r.value)}e=Eb(e)}function n(){return null}return n}const ul=ct(["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"]),_s=ct(["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"]),Is=ct(["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"]),Mb=ct(["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"]),js=ct(["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"]),Rb=ct(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),dl=ct(["#text"]),fl=ct(["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"]),Ms=ct(["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"]),pl=ct(["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"]),lo=ct(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Pb=It(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Lb=It(/<%[\w\W]*|[\w\W]*%>/gm),Db=It(/\$\{[\w\W]*/gm),Ob=It(/^data-[\-\w.\u00B7-\uFFFF]+$/),Fb=It(/^aria-[\-\w]+$/),yf=It(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),zb=It(/^(?:\w+script|data):/i),$b=It(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Sf=It(/^html$/i),Bb=It(/^[a-z][.\w]*(-[.\w]+)+$/i);var ml=Object.freeze({__proto__:null,ARIA_ATTR:Fb,ATTR_WHITESPACE:$b,CUSTOM_ELEMENT:Bb,DATA_ATTR:Ob,DOCTYPE_NAME:Sf,ERB_EXPR:Lb,IS_ALLOWED_URI:yf,IS_SCRIPT_OR_DATA:zb,MUSTACHE_EXPR:Pb,TMPLIT_EXPR:Db});const Ar={element:1,text:3,progressingInstruction:7,comment:8,document:9},Ub=function(){return typeof window>"u"?null:window},Hb=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}},hl=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Cf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ub();const t=U=>Cf(U);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==Ar.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:f,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:g}=e,x=c.prototype,h=Tr(x,"cloneNode"),v=Tr(x,"remove"),b=Tr(x,"nextSibling"),w=Tr(x,"childNodes"),y=Tr(x,"parentNode");if(typeof i=="function"){const U=n.createElement("template");U.content&&U.content.ownerDocument&&(n=U.content.ownerDocument)}let E,k="";const{implementation:I,createNodeIterator:A,createDocumentFragment:T,getElementsByTagName:Y}=n,{importNode:Z}=r;let G=hl();t.isSupported=typeof wf=="function"&&typeof y=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:q,ERB_EXPR:te,TMPLIT_EXPR:D,DATA_ATTR:X,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:M,ATTR_WHITESPACE:S,CUSTOM_ELEMENT:O}=ml;let{IS_ALLOWED_URI:P}=ml,R=null;const ee=Ae({},[...ul,..._s,...Is,...js,...dl]);let L=null;const H=Ae({},[...fl,...Ms,...pl,...lo]);let j=Object.seal(bf(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}})),W=null,_=null,V=!0,J=!0,ne=!1,ie=!0,re=!1,ue=!0,de=!1,Ie=!1,Re=!1,Fe=!1,je=!1,Ue=!1,Qe=!0,et=!1;const gt="user-content-";let tt=!0,ot=!1,ae={},st=null;const Ct=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 jt=null;const Ht=Ae({},["audio","video","img","source","image","track"]);let xt=null;const Wt=Ae({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Et="http://www.w3.org/1998/Math/MathML",Tt="http://www.w3.org/2000/svg",qe="http://www.w3.org/1999/xhtml";let ft=qe,Mt=!1,Rt=null;const ze=Ae({},[Et,Tt,qe],ks);let He=Ae({},["mi","mo","mn","ms","mtext"]),pt=Ae({},["annotation-xml"]);const rn=Ae({},["title","style","font","a","script"]);let vt=null;const Pt=["application/xhtml+xml","text/html"],on="text/html";let Pe=null,mt=null;const sn=n.createElement("form"),Lt=function(C){return C instanceof RegExp||C instanceof Function},At=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(mt&&mt===C)){if((!C||typeof C!="object")&&(C={}),C=ln(C),vt=Pt.indexOf(C.PARSER_MEDIA_TYPE)===-1?on:C.PARSER_MEDIA_TYPE,Pe=vt==="application/xhtml+xml"?ks:vo,R=Ot(C,"ALLOWED_TAGS")?Ae({},C.ALLOWED_TAGS,Pe):ee,L=Ot(C,"ALLOWED_ATTR")?Ae({},C.ALLOWED_ATTR,Pe):H,Rt=Ot(C,"ALLOWED_NAMESPACES")?Ae({},C.ALLOWED_NAMESPACES,ks):ze,xt=Ot(C,"ADD_URI_SAFE_ATTR")?Ae(ln(Wt),C.ADD_URI_SAFE_ATTR,Pe):Wt,jt=Ot(C,"ADD_DATA_URI_TAGS")?Ae(ln(Ht),C.ADD_DATA_URI_TAGS,Pe):Ht,st=Ot(C,"FORBID_CONTENTS")?Ae({},C.FORBID_CONTENTS,Pe):Ct,W=Ot(C,"FORBID_TAGS")?Ae({},C.FORBID_TAGS,Pe):ln({}),_=Ot(C,"FORBID_ATTR")?Ae({},C.FORBID_ATTR,Pe):ln({}),ae=Ot(C,"USE_PROFILES")?C.USE_PROFILES:!1,V=C.ALLOW_ARIA_ATTR!==!1,J=C.ALLOW_DATA_ATTR!==!1,ne=C.ALLOW_UNKNOWN_PROTOCOLS||!1,ie=C.ALLOW_SELF_CLOSE_IN_ATTR!==!1,re=C.SAFE_FOR_TEMPLATES||!1,ue=C.SAFE_FOR_XML!==!1,de=C.WHOLE_DOCUMENT||!1,Fe=C.RETURN_DOM||!1,je=C.RETURN_DOM_FRAGMENT||!1,Ue=C.RETURN_TRUSTED_TYPE||!1,Re=C.FORCE_BODY||!1,Qe=C.SANITIZE_DOM!==!1,et=C.SANITIZE_NAMED_PROPS||!1,tt=C.KEEP_CONTENT!==!1,ot=C.IN_PLACE||!1,P=C.ALLOWED_URI_REGEXP||yf,ft=C.NAMESPACE||qe,He=C.MATHML_TEXT_INTEGRATION_POINTS||He,pt=C.HTML_INTEGRATION_POINTS||pt,j=C.CUSTOM_ELEMENT_HANDLING||{},C.CUSTOM_ELEMENT_HANDLING&&Lt(C.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=C.CUSTOM_ELEMENT_HANDLING.tagNameCheck),C.CUSTOM_ELEMENT_HANDLING&&Lt(C.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=C.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),C.CUSTOM_ELEMENT_HANDLING&&typeof C.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(j.allowCustomizedBuiltInElements=C.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),re&&(J=!1),je&&(Fe=!0),ae&&(R=Ae({},dl),L=[],ae.html===!0&&(Ae(R,ul),Ae(L,fl)),ae.svg===!0&&(Ae(R,_s),Ae(L,Ms),Ae(L,lo)),ae.svgFilters===!0&&(Ae(R,Is),Ae(L,Ms),Ae(L,lo)),ae.mathMl===!0&&(Ae(R,js),Ae(L,pl),Ae(L,lo))),C.ADD_TAGS&&(R===ee&&(R=ln(R)),Ae(R,C.ADD_TAGS,Pe)),C.ADD_ATTR&&(L===H&&(L=ln(L)),Ae(L,C.ADD_ATTR,Pe)),C.ADD_URI_SAFE_ATTR&&Ae(xt,C.ADD_URI_SAFE_ATTR,Pe),C.FORBID_CONTENTS&&(st===Ct&&(st=ln(st)),Ae(st,C.FORBID_CONTENTS,Pe)),tt&&(R["#text"]=!0),de&&Ae(R,["html","head","body"]),R.table&&(Ae(R,["tbody"]),delete W.tbody),C.TRUSTED_TYPES_POLICY){if(typeof C.TRUSTED_TYPES_POLICY.createHTML!="function")throw Er('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof C.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Er('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=C.TRUSTED_TYPES_POLICY,k=E.createHTML("")}else E===void 0&&(E=Hb(g,o)),E!==null&&typeof k=="string"&&(k=E.createHTML(""));ct&&ct(C),mt=C}},Gt=Ae({},[..._s,...Is,...Mb]),Vt=Ae({},[...js,...Rb]),$=function(C){let F=y(C);(!F||!F.tagName)&&(F={namespaceURI:ft,tagName:"template"});const K=vo(C.tagName),Ne=vo(F.tagName);return Rt[C.namespaceURI]?C.namespaceURI===Tt?F.namespaceURI===qe?K==="svg":F.namespaceURI===Et?K==="svg"&&(Ne==="annotation-xml"||He[Ne]):!!Gt[K]:C.namespaceURI===Et?F.namespaceURI===qe?K==="math":F.namespaceURI===Tt?K==="math"&&pt[Ne]:!!Vt[K]:C.namespaceURI===qe?F.namespaceURI===Tt&&!pt[Ne]||F.namespaceURI===Et&&!He[Ne]?!1:!Vt[K]&&(rn[K]||!Gt[K]):!!(vt==="application/xhtml+xml"&&Rt[C.namespaceURI]):!1},B=function(C){Sr(t.removed,{element:C});try{y(C).removeChild(C)}catch{v(C)}},z=function(C,F){try{Sr(t.removed,{attribute:F.getAttributeNode(C),from:F})}catch{Sr(t.removed,{attribute:null,from:F})}if(F.removeAttribute(C),C==="is")if(Fe||je)try{B(F)}catch{}else try{F.setAttribute(C,"")}catch{}},Q=function(C){let F=null,K=null;if(Re)C="<remove></remove>"+C;else{const Ee=cl(C,/^[\r\n\t ]+/);K=Ee&&Ee[0]}vt==="application/xhtml+xml"&&ft===qe&&(C='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+C+"</body></html>");const Ne=E?E.createHTML(C):C;if(ft===qe)try{F=new m().parseFromString(Ne,vt)}catch{}if(!F||!F.documentElement){F=I.createDocument(ft,"template",null);try{F.documentElement.innerHTML=Mt?k:Ne}catch{}}const xe=F.body||F.documentElement;return C&&K&&xe.insertBefore(n.createTextNode(K),xe.childNodes[0]||null),ft===qe?Y.call(F,de?"html":"body")[0]:de?F.documentElement:xe},fe=function(C){return A.call(C.ownerDocument||C,C,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},pe=function(C){return C instanceof p&&(typeof C.nodeName!="string"||typeof C.textContent!="string"||typeof C.removeChild!="function"||!(C.attributes instanceof d)||typeof C.removeAttribute!="function"||typeof C.setAttribute!="function"||typeof C.namespaceURI!="string"||typeof C.insertBefore!="function"||typeof C.hasChildNodes!="function")},we=function(C){return typeof l=="function"&&C instanceof l};function he(U,C,F){ao(U,K=>{K.call(t,C,F,mt)})}const be=function(C){let F=null;if(he(G.beforeSanitizeElements,C,null),pe(C))return B(C),!0;const K=Pe(C.nodeName);if(he(G.uponSanitizeElement,C,{tagName:K,allowedTags:R}),ue&&C.hasChildNodes()&&!we(C.firstElementChild)&&it(/<[/\w!]/g,C.innerHTML)&&it(/<[/\w!]/g,C.textContent)||C.nodeType===Ar.progressingInstruction||ue&&C.nodeType===Ar.comment&&it(/<[/\w]/g,C.data))return B(C),!0;if(!R[K]||W[K]){if(!W[K]&&le(K)&&(j.tagNameCheck instanceof RegExp&&it(j.tagNameCheck,K)||j.tagNameCheck instanceof Function&&j.tagNameCheck(K)))return!1;if(tt&&!st[K]){const Ne=y(C)||C.parentNode,xe=w(C)||C.childNodes;if(xe&&Ne){const Ee=xe.length;for(let We=Ee-1;We>=0;--We){const Me=h(xe[We],!0);Me.__removalCount=(C.__removalCount||0)+1,Ne.insertBefore(Me,b(C))}}}return B(C),!0}return C instanceof c&&!$(C)||(K==="noscript"||K==="noembed"||K==="noframes")&&it(/<\/no(script|embed|frames)/i,C.innerHTML)?(B(C),!0):(re&&C.nodeType===Ar.text&&(F=C.textContent,ao([q,te,D],Ne=>{F=Cr(F,Ne," ")}),C.textContent!==F&&(Sr(t.removed,{element:C.cloneNode()}),C.textContent=F)),he(G.afterSanitizeElements,C,null),!1)},ke=function(C,F,K){if(Qe&&(F==="id"||F==="name")&&(K in n||K in sn))return!1;if(!(J&&!_[F]&&it(X,F))){if(!(V&&it(N,F))){if(!L[F]||_[F]){if(!(le(C)&&(j.tagNameCheck instanceof RegExp&&it(j.tagNameCheck,C)||j.tagNameCheck instanceof Function&&j.tagNameCheck(C))&&(j.attributeNameCheck instanceof RegExp&&it(j.attributeNameCheck,F)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(F))||F==="is"&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&it(j.tagNameCheck,K)||j.tagNameCheck instanceof Function&&j.tagNameCheck(K))))return!1}else if(!xt[F]){if(!it(P,Cr(K,S,""))){if(!((F==="src"||F==="xlink:href"||F==="href")&&C!=="script"&&kb(K,"data:")===0&&jt[C])){if(!(ne&&!it(M,Cr(K,S,"")))){if(K)return!1}}}}}}return!0},le=function(C){return C!=="annotation-xml"&&cl(C,O)},ge=function(C){he(G.beforeSanitizeAttributes,C,null);const{attributes:F}=C;if(!F||pe(C))return;const K={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0};let Ne=F.length;for(;Ne--;){const xe=F[Ne],{name:Ee,namespaceURI:We,value:Me}=xe,Nt=Pe(Ee),hn=Me;let Le=Ee==="value"?hn:_b(hn);if(K.attrName=Nt,K.attrValue=Le,K.keepAttr=!0,K.forceKeepAttr=void 0,he(G.uponSanitizeAttribute,C,K),Le=K.attrValue,et&&(Nt==="id"||Nt==="name")&&(z(Ee,C),Le=gt+Le),ue&&it(/((--!?|])>)|<\/(style|title)/i,Le)){z(Ee,C);continue}if(K.forceKeepAttr)continue;if(!K.keepAttr){z(Ee,C);continue}if(!ie&&it(/\/>/i,Le)){z(Ee,C);continue}re&&ao([q,te,D],wr=>{Le=Cr(Le,wr," ")});const ls=Pe(C.nodeName);if(!ke(ls,Nt,Le)){z(Ee,C);continue}if(E&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!We)switch(g.getAttributeType(ls,Nt)){case"TrustedHTML":{Le=E.createHTML(Le);break}case"TrustedScriptURL":{Le=E.createScriptURL(Le);break}}if(Le!==hn)try{We?C.setAttributeNS(We,Ee,Le):C.setAttribute(Ee,Le),pe(C)?B(C):ll(t.removed)}catch{z(Ee,C)}}he(G.afterSanitizeAttributes,C,null)},Ce=function U(C){let F=null;const K=fe(C);for(he(G.beforeSanitizeShadowDOM,C,null);F=K.nextNode();)he(G.uponSanitizeShadowNode,F,null),be(F),ge(F),F.content instanceof s&&U(F.content);he(G.afterSanitizeShadowDOM,C,null)};return t.sanitize=function(U){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},F=null,K=null,Ne=null,xe=null;if(Mt=!U,Mt&&(U="<!-->"),typeof U!="string"&&!we(U))if(typeof U.toString=="function"){if(U=U.toString(),typeof U!="string")throw Er("dirty is not a string, aborting")}else throw Er("toString is not a function");if(!t.isSupported)return U;if(Ie||At(C),t.removed=[],typeof U=="string"&&(ot=!1),ot){if(U.nodeName){const Me=Pe(U.nodeName);if(!R[Me]||W[Me])throw Er("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof l)F=Q("<!---->"),K=F.ownerDocument.importNode(U,!0),K.nodeType===Ar.element&&K.nodeName==="BODY"||K.nodeName==="HTML"?F=K:F.appendChild(K);else{if(!Fe&&!re&&!de&&U.indexOf("<")===-1)return E&&Ue?E.createHTML(U):U;if(F=Q(U),!F)return Fe?null:Ue?k:""}F&&Re&&B(F.firstChild);const Ee=fe(ot?U:F);for(;Ne=Ee.nextNode();)be(Ne),ge(Ne),Ne.content instanceof s&&Ce(Ne.content);if(ot)return U;if(Fe){if(je)for(xe=T.call(F.ownerDocument);F.firstChild;)xe.appendChild(F.firstChild);else xe=F;return(L.shadowroot||L.shadowrootmode)&&(xe=Z.call(r,xe,!0)),xe}let We=de?F.outerHTML:F.innerHTML;return de&&R["!doctype"]&&F.ownerDocument&&F.ownerDocument.doctype&&F.ownerDocument.doctype.name&&it(Sf,F.ownerDocument.doctype.name)&&(We="<!DOCTYPE "+F.ownerDocument.doctype.name+`>
|
|
124
|
+
`+We),re&&ao([q,te,D],Me=>{We=Cr(We,Me," ")}),E&&Ue?E.createHTML(We):We},t.setConfig=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};At(U),Ie=!0},t.clearConfig=function(){mt=null,Ie=!1},t.isValidAttribute=function(U,C,F){mt||At({});const K=Pe(U),Ne=Pe(C);return ke(K,Ne,F)},t.addHook=function(U,C){typeof C=="function"&&Sr(G[U],C)},t.removeHook=function(U,C){if(C!==void 0){const F=Ab(G[U],C);return F===-1?void 0:Nb(G[U],F,1)[0]}return ll(G[U])},t.removeHooks=function(U){G[U]=[]},t.removeAllHooks=function(){G=hl()},t}var Ef=Cf();const Wb=({content:e,setRenderError:t})=>{const[n,r]=u.useState(""),o=u.useMemo(()=>Ef.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 Tf(e){return typeof e>"u"||e===null}function Gb(e){return typeof e=="object"&&e!==null}function Vb(e){return Array.isArray(e)?e:Tf(e)?[]:[e]}function Yb(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 Kb(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function qb(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Xb=Tf,Zb=Gb,Jb=Vb,Qb=Kb,ey=qb,ty=Yb,Ye={isNothing:Xb,isObject:Zb,toArray:Jb,repeat:Qb,isNegativeZero:ey,extend:ty};function Af(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 Fr(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Af(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Fr.prototype=Object.create(Error.prototype);Fr.prototype.constructor=Fr;Fr.prototype.toString=function(t){return this.name+": "+Af(this,t)};var lt=Fr;function Rs(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 Ps(e,t){return Ye.repeat(" ",t-e.length)+e}function ny(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,f,d=Math.min(e.line+t.linesAfter,o.length).toString().length,p=t.maxLength-(t.indent+d+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)f=Rs(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),p),l=Ye.repeat(" ",t.indent)+Ps((e.line-c+1).toString(),d)+" | "+f.str+`
|
|
301
|
+
`+l;for(f=Rs(e.buffer,r[i],o[i],e.position,p),l+=Ye.repeat(" ",t.indent)+Ps((e.line+1).toString(),d)+" | "+f.str+`
|
|
302
|
+
`,l+=Ye.repeat("-",t.indent+d+3+f.pos)+`^
|
|
303
|
+
`,c=1;c<=t.linesAfter&&!(i+c>=o.length);c++)f=Rs(e.buffer,r[i+c],o[i+c],e.position-(r[i]-r[i+c]),p),l+=Ye.repeat(" ",t.indent)+Ps((e.line+c+1).toString(),d)+" | "+f.str+`
|
|
304
|
+
`;return l.replace(/\n$/,"")}var ry=ny,oy=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],sy=["scalar","sequence","mapping"];function iy(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function ay(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(oy.indexOf(n)===-1)throw new lt('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=iy(t.styleAliases||null),sy.indexOf(this.kind)===-1)throw new lt('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Je=ay;function gl(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 ly(){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 ni(e){return this.extend(e)}ni.prototype.extend=function(t){var n=[],r=[];if(t instanceof Je)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 lt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(s){if(!(s instanceof Je))throw new lt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(s.loadKind&&s.loadKind!=="scalar")throw new lt("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 lt("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 Je))throw new lt("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(ni.prototype);return o.implicit=(this.implicit||[]).concat(n),o.explicit=(this.explicit||[]).concat(r),o.compiledImplicit=gl(o,"implicit"),o.compiledExplicit=gl(o,"explicit"),o.compiledTypeMap=ly(o.compiledImplicit,o.compiledExplicit),o};var Nf=ni,kf=new Je("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),_f=new Je("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),If=new Je("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),jf=new Nf({explicit:[kf,_f,If]});function cy(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function uy(){return null}function dy(e){return e===null}var Mf=new Je("tag:yaml.org,2002:null",{kind:"scalar",resolve:cy,construct:uy,predicate:dy,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function fy(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 py(e){return e==="true"||e==="True"||e==="TRUE"}function my(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Rf=new Je("tag:yaml.org,2002:bool",{kind:"scalar",resolve:fy,construct:py,predicate:my,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 hy(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function gy(e){return 48<=e&&e<=55}function xy(e){return 48<=e&&e<=57}function vy(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(!hy(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}if(o==="o"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!gy(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}}if(o==="_")return!1;for(;n<t;n++)if(o=e[n],o!=="_"){if(!xy(e.charCodeAt(n)))return!1;r=!0}return!(!r||o==="_")}function wy(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 by(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Ye.isNegativeZero(e)}var Pf=new Je("tag:yaml.org,2002:int",{kind:"scalar",resolve:vy,construct:wy,predicate:by,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"]}}),yy=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Sy(e){return!(e===null||!yy.test(e)||e[e.length-1]==="_")}function Cy(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 Ey=/^[-+]?[0-9]+e/;function Ty(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(Ye.isNegativeZero(e))return"-0.0";return n=e.toString(10),Ey.test(n)?n.replace("e",".e"):n}function Ay(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Ye.isNegativeZero(e))}var Lf=new Je("tag:yaml.org,2002:float",{kind:"scalar",resolve:Sy,construct:Cy,predicate:Ay,represent:Ty,defaultStyle:"lowercase"}),Df=jf.extend({implicit:[Mf,Rf,Pf,Lf]}),Of=Df,Ff=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),zf=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 Ny(e){return e===null?!1:Ff.exec(e)!==null||zf.exec(e)!==null}function ky(e){var t,n,r,o,s,i,l,c=0,f=null,d,p,m;if(t=Ff.exec(e),t===null&&(t=zf.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]&&(d=+t[10],p=+(t[11]||0),f=(d*60+p)*6e4,t[9]==="-"&&(f=-f)),m=new Date(Date.UTC(n,r,o,s,i,l,c)),f&&m.setTime(m.getTime()-f),m}function _y(e){return e.toISOString()}var $f=new Je("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Ny,construct:ky,instanceOf:Date,represent:_y});function Iy(e){return e==="<<"||e===null}var Bf=new Je("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Iy}),Zi=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
305
|
+
\r`;function jy(e){if(e===null)return!1;var t,n,r=0,o=e.length,s=Zi;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 My(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,s=Zi,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 Ry(e){var t="",n=0,r,o,s=e.length,i=Zi;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 Py(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Uf=new Je("tag:yaml.org,2002:binary",{kind:"scalar",resolve:jy,construct:My,predicate:Py,represent:Ry}),Ly=Object.prototype.hasOwnProperty,Dy=Object.prototype.toString;function Oy(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,Dy.call(o)!=="[object Object]")return!1;for(s in o)if(Ly.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 Fy(e){return e!==null?e:[]}var Hf=new Je("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Oy,construct:Fy}),zy=Object.prototype.toString;function $y(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],zy.call(r)!=="[object Object]"||(o=Object.keys(r),o.length!==1))return!1;s[t]=[o[0],r[o[0]]]}return!0}function By(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 Wf=new Je("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:$y,construct:By}),Uy=Object.prototype.hasOwnProperty;function Hy(e){if(e===null)return!0;var t,n=e;for(t in n)if(Uy.call(n,t)&&n[t]!==null)return!1;return!0}function Wy(e){return e!==null?e:{}}var Gf=new Je("tag:yaml.org,2002:set",{kind:"mapping",resolve:Hy,construct:Wy}),Ji=Of.extend({implicit:[$f,Bf],explicit:[Uf,Hf,Wf,Gf]}),En=Object.prototype.hasOwnProperty,No=1,Vf=2,Yf=3,ko=4,Ls=1,Gy=2,xl=3,Vy=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Yy=/[\x85\u2028\u2029]/,Ky=/[,\[\]\{\}]/,Kf=/^(?:!|!!|![a-z\-]+!)$/i,qf=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function vl(e){return Object.prototype.toString.call(e)}function Qt(e){return e===10||e===13}function Rn(e){return e===9||e===32}function ht(e){return e===9||e===32||e===10||e===13}function Qn(e){return e===44||e===91||e===93||e===123||e===125}function qy(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function Xy(e){return e===120?2:e===117?4:e===85?8:0}function Zy(e){return 48<=e&&e<=57?e-48:-1}function wl(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 Jy(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var Xf=new Array(256),Zf=new Array(256);for(var qn=0;qn<256;qn++)Xf[qn]=wl(qn)?1:0,Zf[qn]=wl(qn);function Qy(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Ji,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 Jf(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=ry(n),new lt(t,n)}function ce(e,t){throw Jf(e,t)}function _o(e,t){e.onWarning&&e.onWarning.call(null,Jf(e,t))}var bl={YAML:function(t,n,r){var o,s,i;t.version!==null&&ce(t,"duplication of %YAML directive"),r.length!==1&&ce(t,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),o===null&&ce(t,"ill-formed argument of the YAML directive"),s=parseInt(o[1],10),i=parseInt(o[2],10),s!==1&&ce(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&_o(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var o,s;r.length!==2&&ce(t,"TAG directive accepts exactly two arguments"),o=r[0],s=r[1],Kf.test(o)||ce(t,"ill-formed tag handle (first argument) of the TAG directive"),En.call(t.tagMap,o)&&ce(t,'there is a previously declared suffix for "'+o+'" tag handle'),qf.test(s)||ce(t,"ill-formed tag prefix (second argument) of the TAG directive");try{s=decodeURIComponent(s)}catch{ce(t,"tag prefix is malformed: "+s)}t.tagMap[o]=s}};function bn(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||ce(e,"expected valid JSON character");else Vy.test(l)&&ce(e,"the stream contains non-printable characters");e.result+=l}}function yl(e,t,n,r){var o,s,i,l;for(Ye.isObject(n)||ce(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],En.call(t,s)||(t[s]=n[s],r[s]=!0)}function er(e,t,n,r,o,s,i,l,c){var f,d;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),f=0,d=o.length;f<d;f+=1)Array.isArray(o[f])&&ce(e,"nested arrays are not supported inside keys"),typeof o=="object"&&vl(o[f])==="[object Object]"&&(o[f]="[object Object]");if(typeof o=="object"&&vl(o)==="[object Object]"&&(o="[object Object]"),o=String(o),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(s))for(f=0,d=s.length;f<d;f+=1)yl(e,t,s[f],n);else yl(e,t,s,n);else!e.json&&!En.call(n,o)&&En.call(t,o)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,ce(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 Qi(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++):ce(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Ge(e,t,n){for(var r=0,o=e.input.charCodeAt(e.position);o!==0;){for(;Rn(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(Qt(o))for(Qi(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&&_o(e,"deficient indentation"),r}function is(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 ea(e,t){t===1?e.result+=" ":t>1&&(e.result+=Ye.repeat(`
|
|
307
|
+
`,t-1))}function eS(e,t,n){var r,o,s,i,l,c,f,d,p=e.kind,m=e.result,g;if(g=e.input.charCodeAt(e.position),ht(g)||Qn(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&&Qn(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&&Qn(o))break}else if(g===35){if(r=e.input.charCodeAt(e.position-1),ht(r))break}else{if(e.position===e.lineStart&&is(e)||n&&Qn(g))break;if(Qt(g))if(c=e.line,f=e.lineStart,d=e.lineIndent,Ge(e,!1,-1),e.lineIndent>=t){l=!0,g=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=f,e.lineIndent=d;break}}l&&(bn(e,s,i,!1),ea(e,e.line-c),s=i=e.position,l=!1),Rn(g)||(i=e.position+1),g=e.input.charCodeAt(++e.position)}return bn(e,s,i,!1),e.result?!0:(e.kind=p,e.result=m,!1)}function tS(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(bn(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 Qt(n)?(bn(e,r,o,!0),ea(e,Ge(e,!1,t)),r=o=e.position):e.position===e.lineStart&&is(e)?ce(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);ce(e,"unexpected end of the stream within a single quoted scalar")}function nS(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 bn(e,n,e.position,!0),e.position++,!0;if(l===92){if(bn(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),Qt(l))Ge(e,!1,t);else if(l<256&&Xf[l])e.result+=Zf[l],e.position++;else if((i=Xy(l))>0){for(o=i,s=0;o>0;o--)l=e.input.charCodeAt(++e.position),(i=qy(l))>=0?s=(s<<4)+i:ce(e,"expected hexadecimal character");e.result+=Jy(s),e.position++}else ce(e,"unknown escape sequence");n=r=e.position}else Qt(l)?(bn(e,n,r,!0),ea(e,Ge(e,!1,t)),n=r=e.position):e.position===e.lineStart&&is(e)?ce(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}ce(e,"unexpected end of the stream within a double quoted scalar")}function rS(e,t){var n=!0,r,o,s,i=e.tag,l,c=e.anchor,f,d,p,m,g,x=Object.create(null),h,v,b,w;if(w=e.input.charCodeAt(e.position),w===91)d=93,g=!1,l=[];else if(w===123)d=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(Ge(e,!0,t),w=e.input.charCodeAt(e.position),w===d)return e.position++,e.tag=i,e.anchor=c,e.kind=g?"mapping":"sequence",e.result=l,!0;n?w===44&&ce(e,"expected the node content, but found ','"):ce(e,"missed comma between flow collection entries"),v=h=b=null,p=m=!1,w===63&&(f=e.input.charCodeAt(e.position+1),ht(f)&&(p=m=!0,e.position++,Ge(e,!0,t))),r=e.line,o=e.lineStart,s=e.position,cr(e,t,No,!1,!0),v=e.tag,h=e.result,Ge(e,!0,t),w=e.input.charCodeAt(e.position),(m||e.line===r)&&w===58&&(p=!0,w=e.input.charCodeAt(++e.position),Ge(e,!0,t),cr(e,t,No,!1,!0),b=e.result),g?er(e,l,x,v,h,b,r,o,s):p?l.push(er(e,null,x,v,h,b,r,o,s)):l.push(h),Ge(e,!0,t),w=e.input.charCodeAt(e.position),w===44?(n=!0,w=e.input.charCodeAt(++e.position)):n=!1}ce(e,"unexpected end of the stream within a flow collection")}function oS(e,t){var n,r,o=Ls,s=!1,i=!1,l=t,c=0,f=!1,d,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)Ls===o?o=p===43?xl:Gy:ce(e,"repeat of a chomping mode identifier");else if((d=Zy(p))>=0)d===0?ce(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?ce(e,"repeat of an indentation width identifier"):(l=t+d-1,i=!0);else break;if(Rn(p)){do p=e.input.charCodeAt(++e.position);while(Rn(p));if(p===35)do p=e.input.charCodeAt(++e.position);while(!Qt(p)&&p!==0)}for(;p!==0;){for(Qi(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),Qt(p)){c++;continue}if(e.lineIndent<l){o===xl?e.result+=Ye.repeat(`
|
|
308
|
+
`,s?1+c:c):o===Ls&&s&&(e.result+=`
|
|
309
|
+
`);break}for(r?Rn(p)?(f=!0,e.result+=Ye.repeat(`
|
|
310
|
+
`,s?1+c:c)):f?(f=!1,e.result+=Ye.repeat(`
|
|
311
|
+
`,c+1)):c===0?s&&(e.result+=" "):e.result+=Ye.repeat(`
|
|
312
|
+
`,c):e.result+=Ye.repeat(`
|
|
313
|
+
`,s?1+c:c),s=!0,i=!0,c=0,n=e.position;!Qt(p)&&p!==0;)p=e.input.charCodeAt(++e.position);bn(e,n,e.position,!1)}return!0}function Sl(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,ce(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++,Ge(e,!0,-1)&&e.lineIndent<=t){s.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,cr(e,t,Yf,!1,!0),s.push(e.result),Ge(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)ce(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 sS(e,t,n){var r,o,s,i,l,c,f=e.tag,d=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,ce(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&&(er(e,p,m,g,x,null,i,l,c),g=x=h=null),b=!0,v=!0,o=!0):v?(v=!1,o=!0):ce(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,!cr(e,n,Vf,!1,!0))break;if(e.line===s){for(w=e.input.charCodeAt(e.position);Rn(w);)w=e.input.charCodeAt(++e.position);if(w===58)w=e.input.charCodeAt(++e.position),ht(w)||ce(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(er(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)ce(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=f,e.anchor=d,!0}else if(b)ce(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=f,e.anchor=d,!0}if((e.line===s||e.lineIndent>t)&&(v&&(i=e.line,l=e.lineStart,c=e.position),cr(e,t,ko,!0,o)&&(v?x=e.result:h=e.result),v||(er(e,p,m,g,x,h,i,l,c),g=x=h=null),Ge(e,!0,-1),w=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&w!==0)ce(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&er(e,p,m,g,x,null,i,l,c),b&&(e.tag=f,e.anchor=d,e.kind="mapping",e.result=p),b}function iS(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&&ce(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)):ce(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!ht(i);)i===33&&(r?ce(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(t-1,e.position+1),Kf.test(o)||ce(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),Ky.test(s)&&ce(e,"tag suffix cannot contain flow indicator characters")}s&&!qf.test(s)&&ce(e,"tag name cannot contain such characters: "+s);try{s=decodeURIComponent(s)}catch{ce(e,"tag name is malformed: "+s)}return n?e.tag=s:En.call(e.tagMap,o)?e.tag=e.tagMap[o]+s:o==="!"?e.tag="!"+s:o==="!!"?e.tag="tag:yaml.org,2002:"+s:ce(e,'undeclared tag handle "'+o+'"'),!0}function aS(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&ce(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!ht(n)&&!Qn(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ce(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function lS(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)&&!Qn(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&ce(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),En.call(e.anchorMap,n)||ce(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Ge(e,!0,-1),!0}function cr(e,t,n,r,o){var s,i,l,c=1,f=!1,d=!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=ko===n||Yf===n,r&&Ge(e,!0,-1)&&(f=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;iS(e)||aS(e);)Ge(e,!0,-1)?(f=!0,l=s,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=f||o),(c===1||ko===n)&&(No===n||Vf===n?h=t:h=t+1,v=e.position-e.lineStart,c===1?l&&(Sl(e,v)||sS(e,v,h))||rS(e,h)?d=!0:(i&&oS(e,h)||tS(e,h)||nS(e,h)?d=!0:lS(e)?(d=!0,(e.tag!==null||e.anchor!==null)&&ce(e,"alias node should not have any properties")):eS(e,h,No===n)&&(d=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(d=l&&Sl(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"&&ce(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(En.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||ce(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&ce(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)):ce(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function cS(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&&(Ge(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&&ce(e,"directive name must not be less than one character in length");i!==0;){for(;Rn(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!Qt(i));break}if(Qt(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&&Qi(e),En.call(bl,r)?bl[r](e,r,o):_o(e,'unknown document directive "'+r+'"')}if(Ge(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,Ge(e,!0,-1)):s&&ce(e,"directives end mark is expected"),cr(e,e.lineIndent-1,ko,!1,!0),Ge(e,!0,-1),e.checkLineBreaks&&Yy.test(e.input.slice(t,e.position))&&_o(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&is(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Ge(e,!0,-1));return}if(e.position<e.length-1)ce(e,"end of the stream or a document separator is expected");else return}function Qf(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 Qy(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,ce(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;)cS(n);return n.documents}function uS(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=Qf(e,n);if(typeof t!="function")return r;for(var o=0,s=r.length;o<s;o+=1)t(r[o])}function dS(e,t){var n=Qf(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new lt("expected a single document in the stream, but found more")}}var fS=uS,pS=dS,ep={loadAll:fS,load:pS},tp=Object.prototype.toString,np=Object.prototype.hasOwnProperty,ta=65279,mS=9,zr=10,hS=13,gS=32,xS=33,vS=34,ri=35,wS=37,bS=38,yS=39,SS=42,rp=44,CS=45,Io=58,ES=61,TS=62,AS=63,NS=64,op=91,sp=93,kS=96,ip=123,_S=124,ap=125,rt={};rt[0]="\\0";rt[7]="\\a";rt[8]="\\b";rt[9]="\\t";rt[10]="\\n";rt[11]="\\v";rt[12]="\\f";rt[13]="\\r";rt[27]="\\e";rt[34]='\\"';rt[92]="\\\\";rt[133]="\\N";rt[160]="\\_";rt[8232]="\\L";rt[8233]="\\P";var IS=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],jS=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function MS(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&&np.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function RS(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 lt("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Ye.repeat("0",r-t.length)+t}var PS=1,$r=2;function LS(e){this.schema=e.schema||Ji,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Ye.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=MS(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==='"'?$r:PS,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 Cl(e,t){for(var n=Ye.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 oi(e,t){return`
|
|
317
|
+
`+Ye.repeat(" ",e.indent*t)}function DS(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 jo(e){return e===gS||e===mS}function Br(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==ta||65536<=e&&e<=1114111}function El(e){return Br(e)&&e!==ta&&e!==hS&&e!==zr}function Tl(e,t,n){var r=El(e),o=r&&!jo(e);return(n?r:r&&e!==rp&&e!==op&&e!==sp&&e!==ip&&e!==ap)&&e!==ri&&!(t===Io&&!o)||El(t)&&!jo(t)&&e===ri||t===Io&&o}function OS(e){return Br(e)&&e!==ta&&!jo(e)&&e!==CS&&e!==AS&&e!==Io&&e!==rp&&e!==op&&e!==sp&&e!==ip&&e!==ap&&e!==ri&&e!==bS&&e!==SS&&e!==xS&&e!==_S&&e!==ES&&e!==TS&&e!==yS&&e!==vS&&e!==wS&&e!==NS&&e!==kS}function FS(e){return!jo(e)&&e!==Io}function Mr(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 lp(e){var t=/^\n* /;return t.test(e)}var cp=1,si=2,up=3,dp=4,Zn=5;function zS(e,t,n,r,o,s,i,l){var c,f=0,d=null,p=!1,m=!1,g=r!==-1,x=-1,h=OS(Mr(e,0))&&FS(Mr(e,e.length-1));if(t||i)for(c=0;c<e.length;f>=65536?c+=2:c++){if(f=Mr(e,c),!Br(f))return Zn;h=h&&Tl(f,d,l),d=f}else{for(c=0;c<e.length;f>=65536?c+=2:c++){if(f=Mr(e,c),f===zr)p=!0,g&&(m=m||c-x-1>r&&e[x+1]!==" ",x=c);else if(!Br(f))return Zn;h=h&&Tl(f,d,l),d=f}m=m||g&&c-x-1>r&&e[x+1]!==" "}return!p&&!m?h&&!i&&!o(e)?cp:s===$r?Zn:si:n>9&&lp(e)?Zn:i?s===$r?Zn:si:m?dp:up}function $S(e,t,n,r,o){e.dump=(function(){if(t.length===0)return e.quotingType===$r?'""':"''";if(!e.noCompatMode&&(IS.indexOf(t)!==-1||jS.test(t)))return e.quotingType===$r?'"'+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(f){return DS(e,f)}switch(zS(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,o)){case cp:return t;case si:return"'"+t.replace(/'/g,"''")+"'";case up:return"|"+Al(t,e.indent)+Nl(Cl(t,s));case dp:return">"+Al(t,e.indent)+Nl(Cl(BS(t,i),s));case Zn:return'"'+US(t)+'"';default:throw new lt("impossible error: invalid scalar style")}})()}function Al(e,t){var n=lp(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 Nl(e){return e[e.length-1]===`
|
|
322
|
+
`?e.slice(0,-1):e}function BS(e,t){for(var n=/(\n+)([^\n]*)/g,r=(function(){var f=e.indexOf(`
|
|
323
|
+
`);return f=f!==-1?f:e.length,n.lastIndex=f,kl(e.slice(0,f),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
|
+
`:"")+kl(c,t),o=s}return r}function kl(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 US(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Mr(e,o),r=rt[n],!r&&Br(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||RS(n);return t}function HS(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)),(pn(e,t,l,!1,!1)||typeof l>"u"&&pn(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function _l(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)),(pn(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&pn(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=oi(e,t)),e.dump&&zr===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=s,e.dump=o||"[]"}function WS(e,t,n){var r="",o=e.tag,s=Object.keys(n),i,l,c,f,d;for(i=0,l=s.length;i<l;i+=1)d="",r!==""&&(d+=", "),e.condenseFlow&&(d+='"'),c=s[i],f=n[c],e.replacer&&(f=e.replacer.call(n,c,f)),pn(e,t,c,!1,!1)&&(e.dump.length>1024&&(d+="? "),d+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),pn(e,t,f,!1,!1)&&(d+=e.dump,r+=d));e.tag=o,e.dump="{"+r+"}"}function GS(e,t,n,r){var o="",s=e.tag,i=Object.keys(n),l,c,f,d,p,m;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new lt("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)m="",(!r||o!=="")&&(m+=oi(e,t)),f=i[l],d=n[f],e.replacer&&(d=e.replacer.call(n,f,d)),pn(e,t+1,f,!0,!0,!0)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&zr===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,p&&(m+=oi(e,t)),pn(e,t+1,d,!0,p)&&(e.dump&&zr===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=s,e.dump=o||"{}"}function Il(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,tp.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(np.call(l.represent,c))r=l.represent[c](t,c);else throw new lt("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function pn(e,t,n,r,o,s,i){e.tag=null,e.dump=n,Il(e,n,!1)||Il(e,n,!0);var l=tp.call(e.dump),c=r,f;r&&(r=e.flowLevel<0||e.flowLevel>t);var d=l==="[object Object]"||l==="[object Array]",p,m;if(d&&(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(d&&m&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(GS(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(WS(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?_l(e,t-1,e.dump,o):_l(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(HS(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&$S(e,e.dump,t,s,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new lt("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(f=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?f="!"+f:f.slice(0,18)==="tag:yaml.org,2002:"?f="!!"+f.slice(18):f="!<"+f+">",e.dump=f+" "+e.dump)}return!0}function VS(e,t){var n=[],r=[],o,s;for(ii(e,n,r),o=0,s=r.length;o<s;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(s)}function ii(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)ii(e[o],t,n);else for(r=Object.keys(e),o=0,s=r.length;o<s;o+=1)ii(e[r[o]],t,n)}function YS(e,t){t=t||{};var n=new LS(t);n.noRefs||VS(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),pn(n,0,r,!0,!0)?n.dump+`
|
|
329
|
+
`:""}var KS=YS,qS={dump:KS};function na(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 XS=Je,ZS=Nf,JS=jf,QS=Df,eC=Of,tC=Ji,nC=ep.load,rC=ep.loadAll,oC=qS.dump,sC=lt,iC={binary:Uf,float:Lf,map:If,null:Mf,pairs:Wf,set:Gf,timestamp:$f,bool:Rf,int:Pf,merge:Bf,omap:Hf,seq:_f,str:kf},aC=na("safeLoad","load"),lC=na("safeLoadAll","loadAll"),cC=na("safeDump","dump"),uC={Type:XS,Schema:ZS,FAILSAFE_SCHEMA:JS,JSON_SCHEMA:QS,CORE_SCHEMA:eC,DEFAULT_SCHEMA:tC,load:nC,loadAll:rC,dump:oC,YAMLException:sC,types:iC,safeLoad:aC,safeLoadAll:lC,safeDump:cC};const dC=({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=uC.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 f={[`${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,f]}},[e,t,n]);return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background relative",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(ve,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Ul,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(Hl,{})," 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(fp,{content:s,setRenderError:n}):a.jsx(fi,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},fp=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=vf();return a.jsx("div",{className:`p-4 overflow-auto ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap focus-visible:outline-none select-text",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},pp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(wb,{content:e,setRenderError:r});case"mermaid":return a.jsx(Wb,{content:e,setRenderError:r});case"html":return a.jsx(bb,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(dC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(yb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(Sb,{content:e,setRenderError:r});case"audio":return a.jsx(xb,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(fp,{content:e,setRenderError:r})}},fC={"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 pC(e,t){const n=fC[e]||"bin";return`embedded_file_${t+1}.${n}`}function mC(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],f=e[r.index+s.length];if(!(c==='"'&&f==='"'||c==="'"&&f==="'")&&l&&l.length>10){const d=qr(void 0,i);d?t.push({type:d,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:pC(i,o++)})}}return t}function hC(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 gC(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 xC(e){return!e||typeof e!="string"?[]:[...mC(e),...hC(e),...gC(e)]}const vC=["image","audio"],wC=({message:e})=>{var f;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(f=e.parts)==null?void 0:f.filter(d=>d.kind==="text"),o=(r==null?void 0:r.map(d=>d.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(gi,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(or,{children:s})]});const i=xC(s);if(i.length===0)return a.jsx(or,{children:s});let l=s;const c=[];return i.forEach((d,p)=>{if(l=l.replace(d.originalMatch,""),d.type==="file"){const m={name:d.filename||"downloaded_file",content:d.content,mime_type:d.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(gf,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!vC.includes(d.type)){const m=ff(d.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:a.jsx(pp,{content:m,rendererType:d.type,mime_type:d.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(or,{children:l}),c]})},mp=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),bC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(mp,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(xf,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,yC=e=>e.files&&e.files.length>0?a.jsx(mp,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(gf,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,SC=(e,t,n)=>{var f,d;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(f=e.parts)==null?void 0:f.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(af,{variant:i,children:a.jsxs(lf,{variant:i,children:[s&&a.jsx(wC,{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(sr,{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})})]})},(d=e.metadata)==null?void 0:d.messageId)},CC=({message:e,isLastWithTaskId:t})=>{const n=Be();return e?a.jsxs(a.Fragment,{children:[SC(e,n,t),bC(e),yC(e)]}):null},EC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=Be(),{configServerUrl:r}=nn(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[f,d]=u.useState(""),p=u.useCallback(async()=>{const w=`${r}/api/v1/sessions`;try{const y=await De(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:k}=E.detail;i(I=>{const A=I.find(T=>T.id===k);if(A){const T=I.filter(Y=>Y.id!==k);return[A,...T]}return I})};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),d(w.name||"")},x=async()=>{l&&(await t(l,f),c(null),p())},h=w=>{n(w)},v=w=>new Date(w).toLocaleString(),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:"p-4 flex flex-col h-full",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),s.length>0&&a.jsx("ul",{children:s.map(w=>a.jsx("li",{className:"my-2 group",children:a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 rounded hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===w.id?a.jsx("input",{ref:o,type:"text",value:f,onChange:y=>d(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 flex-col",children:[a.jsx("span",{className:"font-semibold",children:b(w)}),a.jsx("span",{className:"text-xs text-muted-foreground",children:v(w.updated_at)})]})}),a.jsx("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:l===w.id?a.jsxs(a.Fragment,{children:[a.jsx(ve,{variant:"ghost",onClick:x,children:a.jsx(mi,{size:16})}),a.jsx(ve,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Ro,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(ve,{variant:"ghost",onClick:()=>g(w),children:a.jsx(zp,{size:16})}),a.jsx(ve,{variant:"ghost",onClick:()=>h(w),children:a.jsx($p,{size:16})})]})})]})},w.id))}),s.length===0&&a.jsxs("div",{className:"flex flex-col flex-1 h-full text-sm text-muted-foreground items-center justify-center",children:[a.jsx(Wl,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]})]})},TC=()=>{const{persistenceEnabled:e}=nn(),t=Xu();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}),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("div",{className:"flex h-full flex-col",children:a.jsx("div",{className:"flex-1 overflow-y-auto px-4",children:a.jsx(EC,{})})})},AC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=Be(),f=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex items-center gap-4 min-w-0",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:Ea(e.last_modified),children:Ea(e.last_modified)})]}),t&&f.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(Fd,{value:l==null?void 0:l.toString(),onValueChange:d=>{c(e.filename,parseInt(d))},children:[a.jsx($d,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(zd,{placeholder:"Version"})}),a.jsx(Bd,{children:f.map(d=>a.jsxs(Ud,{value:d.toString(),children:["Version ",d]},d))})]})})]}),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(ve,{variant:"ghost",size:"sm",onClick:d=>{d.stopPropagation(),d.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(vi,{})}),o&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:async d=>{d.stopPropagation(),d.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(xi,{})}),r&&a.jsx(ve,{variant:"ghost",size:"sm",onClick:d=>{d.preventDefault(),d.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(Gl,{})})]})]})},jl=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=Be(),{onDownload:o}=qu(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=f=>{if(!f||typeof f=="object"&&Object.keys(f).length===0)return a.jsx("span",{children:"Not available"});const d=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&d(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,":"]})," ",d(x,m+1)]},h))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof f=="object"&&f.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",f.type," ",f.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof f=="object"&&f.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",f.columns.join(", ")]}),typeof f=="object"&&f.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),d(f.structure)]}),typeof f=="object"&&f.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",f.error]}),typeof f=="string"&&a.jsx("p",{children:f})]})};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:f=>{f.stopPropagation(),r(e)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.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:hf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(AC,{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: "}),pc(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)})]})]})]})]})})},NC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=Be();return!e||!t?null:a.jsx(Go,{open:e,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsxs(Ko,{className:"flex flex-row gap-1 max-w-[400px]",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(qo,{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(ve,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},kC={replace:e=>{e instanceof Hp.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function or({children:e,className:t}){if(!e)return null;try{const n=Bp.parse(e,{gfm:!0}),r=Ef.sanitize(n,{USE_PROFILES:{html:!0}}),o=Up(r,kC);return a.jsx("div",{className:Ta(t),children:o})}catch{return a.jsx("div",{className:Ta(t),children:e})}}const _C=Tn("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"}}),IC={error:gi,warning:Wp,info:vi,success:Vl};function ra({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=IC[t||"error"];return a.jsxs("div",{className:Se(_C({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(ve,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Ro,{className:"size-3"})})]})}const jC=({artifact:e,message:t})=>{const{onDownload:n}=qu();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(ve,{onClick:()=>n(e),children:[a.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})},Ds=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),MC=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=Be(),r=u.useMemo(()=>gb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function d(){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&&d()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(Ds,{children:"No preview available"})]});if(o)return a.jsx(Ds,{children:a.jsx(hi,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(jC,{artifact:e,message:r.reason??""});const c=qr(e.filename,e.mime_type),f=mb(n);return!c||!f?a.jsx(Ds,{children:"No preview available"}):a.jsx(pp,{content:f,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},Xt={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},RC=e=>{switch(e){case Xt.NameAsc:return"Name (A-Z)";case Xt.NameDesc:return"Name (Z-A)";case Xt.DateAsc:return"Date (oldest first)";case Xt.DateDesc:return"Date (newest first)"}},PC=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Xt).map(o=>({id:o,label:RC(o),onClick:()=>t(o),icon:e===o?a.jsx(mi,{}):void 0,iconPosition:"right"}));return a.jsxs(cd,{children:[a.jsx(ud,{asChild:!0,children:n}),a.jsx(dd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},LC=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=Be(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(Yl,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(Gl,{}),iconPosition:"left",divider:!0}];return a.jsxs(cd,{children:[a.jsx(ud,{asChild:!0,children:e}),a.jsx(dd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},DC=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=Be();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Go,{open:t,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{children:"Delete All?"}),a.jsxs(qo,{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(ve,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},OC={[Xt.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Xt.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Xt.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Xt.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},FC=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=Be(),[o,s]=u.useState(Xt.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(OC[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(ve,{variant:"ghost",onClick:()=>r(null),children:a.jsx(Gp,{})}),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(PC,{currentSortOption:o,onSortChange:s,children:a.jsxs(ve,{variant:"ghost",title:"Sort By",children:[a.jsx($l,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(LC,{children:a.jsx(ve,{variant:"ghost",tooltip:"More",children:a.jsx(Vp,{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(jl,{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(hi,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(sr,{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 flex-1 flex-col gap-2 min-h-0 min-w-0",children:[a.jsx(jl,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-y-auto",children:a.jsx(MC,{artifact:n})})]})]}),a.jsx(NC,{}),a.jsx(DC,{})]})},zC=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=Be(),{isReconnecting:c,isTaskMonitorConnecting:f,isTaskMonitorConnected:d,monitoredTasks:p,connectTaskMonitorStream:m}=Gi(),[g,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const y=p[l],E=bE(y.events||[],p,y);x(E)}else x(null)},[l,p]);const h=()=>c||f?{message:"Connecting to task monitor ...",showButton:!1}:d?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:Yp,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(ve,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(da,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(sr,{className:"size-5"})}),a.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(po,{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($0,{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(ve,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(da,{className:"size-5"})}),a.jsxs(B0,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(sl,{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(sr,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(sl,{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(po,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(il,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(FC,{})})}),a.jsx(il,{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(UC,{task:g}),a.jsx(wE,{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(po,{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(ve,{onClick:y.buttonAction,children:[y.buttonIcon&&(()=>{const E=y.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),y.buttonText]})})]})})})()})})]})]})})})},ai=({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(K0,{className:"ml-2 mr-3"}),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})})]}),hp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=Be(),{persistenceEnabled:r}=nn();return a.jsx(Go,{open:e,onOpenChange:t,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{className:"flex flex-row gap-1 max-w-[400px]",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(qo,{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(ve,{variant:"outline",onClick:t,children:"Cancel"}),a.jsx(ve,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},$C=({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(ve,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(Kl,{className:"size-5"})}),a.jsxs(ve,{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(TC,{})}),a.jsx(hp,{isOpen:t,onClose:()=>n(!1)})]})},Nr=(e,t)=>a.jsx(df,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),BC=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(ai,{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(ai,{statusText:n||e.status})});case"input-required":return Nr("Input Required","info");case"completed":return Nr("Completed","success");case"canceled":return Nr("Canceled","info");case"failed":return Nr("Failed","error");default:return Nr("Unknown","info")}},UC=({task:e})=>{const{messages:t}=Be(),n=u.useMemo(()=>{const r=t.find(o=>o.isStatusBubble);return e?BC(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 gp{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 d;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"),f=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((d=s.data.toolResult)==null?void 0:d.isPeerResponse);return l||c||f})}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)}}const un={USER:50,MAIN_FLOW:300,TOOLS:600},HC=50,Ke=50,_t=330,Bn=50,Yt=20,ur=10,Ml=Ke+20,WC=90;function Un(e,t,n){return e.push(n),t.add(n.id),n}function GC(e,t){return e.push(t),t}function Hn(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function dt(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function Xr(e){const t=dt(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function VC(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 YC(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function KC(e,t){if(!t)return null;const n=dt(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function as(e,t){var o;const n=dt(e);if(!n)return null;if(t.functionCallId){const s=YC(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=KC(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=Xr(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 xp(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 vp(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 VC(e,t,n)}function qC(e,t,n){const r=dt(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 wp(r,l)}return null}function wp(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return wp(e,n)}return null}function dr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Hn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l={id:s,type:"orchestratorNode",position:{x:un.MAIN_FLOW,y:i},data:{label:t,visualizerStepId:n.id}};Un(r,e.allCreatedNodeIds,l),e.nodePositions.set(s,l.position);const c={id:s,yPosition:i,height:Ke,width:_t},f={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:c};e.agentRegistry.registerAgent(f);const d={id:o,orchestratorAgent:c,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+Ke};return e.phases.push(d),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=d.maxY+Bn,d}function li(e,t,n,r,o){var Y,Z,G,q,te;const s=dt(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((Y=n.data.toolResult)==null?void 0:Y.isPeerResponse)===!0,l=n.source||"",c=n.target||"",f=fr(l);!i&&!f&&!o&&e.indentationLevel++;const d=((G=(Z=n.delegationInfo)==null?void 0:Z[0])==null?void 0:G.subTaskId)||n.owningTaskId,p=Hn(e,`${t}_${d}`),m=Hn(e,`group_${t}_${d}`),g=((te=(q=n.data)==null?void 0:q.toolInvocationStart)==null?void 0:te.functionCallId)||n.functionCallId||"";let x,h,v;const b=Array.from(e.parallelFlows.values()).find(D=>D.subflowFunctionCallIds.includes(g)),w=Xr(e),y=qC(e,l,c);o&&b?(x=b.startX+b.currentXOffset,h=b.startY,v=h+Yt,b.currentXOffset+=(_t+ur)*2.2):y?(v=e.nextAvailableGlobalY,x=(y.groupNode.xPosition||un.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,h=v-Yt):(v=e.nextAvailableGlobalY,x=un.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,h=v-Yt);const E={id:p,type:"genericAgentNode",position:{x:50,y:Yt},data:{label:t,visualizerStepId:n.id},parentId:m},k={id:m,type:"group",position:{x,y:h},data:{label:`${t} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${Ke+2*Yt}px`}};Un(r,e.allCreatedNodeIds,k),Un(r,e.allCreatedNodeIds,E),e.nodePositions.set(p,E.position),e.nodePositions.set(m,k.position);const I={id:p,xPosition:un.MAIN_FLOW,yPosition:v,height:Ke,width:_t},A={id:p,name:t,type:"peer",phaseId:s.id,subflowId:d,context:"subflow",nodeInstance:I};e.agentRegistry.registerAgent(A);const T={id:d,functionCallId:g,isParallel:o,peerAgent:I,groupNode:{id:m,xPosition:x,yPosition:h,height:Ke+2*Yt,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+Ke,maxContentXRelative:E.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(T),y&&(y.lastSubflow=T),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,T.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+Bn):e.nextAvailableGlobalY=T.groupNode.yPosition+T.groupNode.height+Bn,T}function bp(e,t,n,r,o,s,i=!1){const l=dt(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,f=i?"LLM":`Tool: ${t}`,d=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+=Ml,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=un.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Ml,x=g,h=m;const v=Hn(e,`${d}_${r.id}`),b={id:v,type:n,position:{x,y:h},data:{label:f,visualizerStepId:r.id,toolName:t},parentId:p};Un(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:h});const w={id:v,xPosition:g,yPosition:m,height:Ke,width:_t,functionCallId:r.functionCallId};c.push(w);const y=m+Ke;if(s){s.maxY=Math.max(s.maxY,y),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+_t);const E=s.maxY-s.groupNode.yPosition+Yt;s.groupNode.height=Math.max(s.groupNode.height,E);const k=s.maxContentXRelative+ur;s.groupNode.width=Math.max(s.groupNode.width||0,k);const I=o.find(A=>A.id===s.groupNode.id);I&&(I.style={...I.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+Bn)}else l.maxY=Math.max(l.maxY,y),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Bn);return w}function oa(e,t,n,r){e.userNodeCounter++;const o=Hn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:un.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Un(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:Ke,width:_t};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+Ke;return t.maxY=Math.max(t.maxY,c),l}function yt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const f=o.allCreatedNodeIds.has(e),d=o.allCreatedNodeIds.has(t);if(!f||!d)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),GC(r,h)}}function XC(){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 ci(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 fr(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const ZC=["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 JC(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=dt(t),f=Xr(t);let d,p=!1;if(f?(d=f.peerAgent,d.id.startsWith(l+"_")&&(p=!0)):c&&(d=c.orchestratorAgent,d.id.startsWith(l+"_")&&(p=!0)),p&&d&&c){t.userNodeCounter++;const m=Hn(t,`User_continue_${t.userNodeCounter}`),g=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:un.USER,y:g},data:{label:"User",visualizerStepId:e.id}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const h={id:m,yPosition:g,height:Ke,width:_t};c.userNodes.push(h),t.allUserNodes.push(h);const v=g+Ke;d.yPosition=Math.max(d.yPosition,g),c.maxY=Math.max(c.maxY,v,d.yPosition+Ke),t.nextAvailableGlobalY=c.maxY+Bn;const b=fr(i)?"orch-left-input":"peer-left-input";yt(h.id,d.id,e,r,t,o,s,"user-right-output",b)}else{const m=dr(t,i,e,n),g=Hn(t,`User_${m.id}`),x={id:g,type:"userNode",position:{x:un.USER,y:m.orchestratorAgent.yPosition-WC},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(g,x.position);const h={id:g,yPosition:x.position.y,height:Ke,width:_t};m.userNodes.push(h),t.allUserNodes.push(h),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+Ke),t.nextAvailableGlobalY=m.maxY+Bn,yt(g,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function QC(e,t,n,r,o,s){const i=dt(t);if(!i)return;const l=as(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,f=bp(t,"LLM","llmNode",e,n,l,!0);f&&yt(c,f.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function eE(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:un.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=dt(t);if(!i)return;const l=as(t,e);let c;const d=vp((l||i).toolInstances,"LLM",n,e.functionCallId);if(d)c=d.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?yt(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 tE(e,t,n,r,o,s){var d;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((d=e.data.toolInvocationStart)==null?void 0:d.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=ci(m.type,"output","bottom"),h=xp(e,t),v=li(t,p,e,n,h);v&&yt(g.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=as(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=ci(h.type,"output","right")):(m=i.orchestratorAgent.id,g="orch-right-output-tools")}const x=bp(t,c,"genericToolNode",e,n,p);x&&yt(m,x.id,e,r,t,o,s,g,`${x.id}-tool-left-input`)}}function nE(e,t,n,r,o,s){var f,d;const i=dt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((f=e.data.toolResult)!=null&&f.isPeerResponse){const p=(d=e.data.toolResult)==null?void 0:d.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(fr(b))t.indentationLevel=0,w=dr(t,b,e,n).orchestratorAgent,y="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=li(t,b,e,n,!1);if(!E)return;w=E.peerAgent,y="peer-top-input"}v.forEach(E=>{var k;yt(((k=E.lastSubflow)==null?void 0:k.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(fr(c)){t.indentationLevel=0;const x=dr(t,c,e,n);yt(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=xp(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),h=li(t,c,e,n,x);h&&yt(g.id,h.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=as(t,e),x=vp((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=ci(b.type,"input","right")):(h=i.orchestratorAgent.id,v="orch-right-input-tools")}yt(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 rE(e,t,n,r,o,s){const i=dt(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=oa(t,i,e,n);yt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function oE(e,t,n,r,o,s){const i=dt(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=dr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&yt(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=Xr(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 f=c.peerAgent,d=n.some(g=>typeof g.data.label=="string"&&fr(g.data.label));let p,m;d?(t.indentationLevel=0,p=dr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=oa(t,i,e,n).id,m="user-top-input"),yt(f.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function sE(e,t,n,r){const o=dt(t);if(!o)return;const s=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const f=Xr(t);if(f&&f.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=f.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 d,p;fr(i)?(t.indentationLevel=0,d=dr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(d=oa(t,o,e,n).id,p="user-top-input"),iE(l.id,d,e,r,t,c,p)}function iE(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 f=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===f)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",g=m.length>30?"Error":m,x={id:f,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 aE=e=>{const t=[],n=[];if(!e||e.length===0)return{nodes:t,edges:n};const r=new gp,o={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:HC,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:XC(),indentationLevel:0,indentationStep:50},s=e.filter(c=>ZC.includes(c.type)),i=s.findIndex(c=>c.type==="USER_REQUEST");let l=s;i>0&&(l=[s[i],...s.slice(0,i),...s.slice(i+1)]);for(const c of l)switch(c.type){case"USER_REQUEST":JC(c,o,t,n,r,e);break;case"AGENT_LLM_CALL":QC(c,o,t,n,r,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":eE(c,o,t,n,r,e);break;case"AGENT_TOOL_INVOCATION_START":tE(c,o,t,n,r,e);break;case"AGENT_TOOL_EXECUTION_RESULT":nE(c,o,t,n,r,e);break;case"AGENT_RESPONSE_TEXT":rE(c,o,t,n,r,e);break;case"TASK_COMPLETED":oE(c,o,t,n,r,e);break;case"TASK_FAILED":sE(c,o,t,n);break}return o.phases.forEach(c=>{c.subflows.forEach(f=>{const d=t.find(p=>p.id===f.groupNode.id);if(d&&d.style){const m=f.maxY-f.groupNode.yPosition+Yt;d.style.height=`${Math.max(Ke+2*Yt,m)}px`;const g=f.maxContentXRelative+ur,x=_t+2*ur+o.indentationLevel*o.indentationStep;d.style.width=`${Math.max(g,x)}px`}})}),{nodes:t,edges:n}},lE=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:f})=>{const[d,p]=u.useState(!1),[m]=Kp({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),g=()=>{const v={strokeWidth:d?3:2,stroke:"var(--color-muted-foreground)",...l},b=f;return b!=null&&b.isError?{...v,stroke:d?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:d?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:d?"#1d4ed8":"#3b82f6",strokeWidth:d?4:3}:d?{...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})]})},cE=({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(Xe,{type:"target",position:Ze.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.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",children:e.label})})]}),uE=({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(Xe,{type:"target",position:Ze.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",children:e.label})]}),a.jsx(Xe,{type:"source",position:Ze.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},dE=({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(Xe,{type:"target",position:Ze.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(Xe,{type:"source",position:Ze.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},fE=({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(Xe,{type:"source",position:Ze.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Xe,{type:"source",position:Ze.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Xe,{type:"target",position:Ze.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 flex items-center font-bold",children:e.label})})]}),pE=({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(Xe,{type:"source",position:Ze.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(Xe,{type:"target",position:Ze.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(Xe,{type:"source",position:Ze.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})]})]})},mE=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,y,E;switch(e.type){case"USER_REQUEST":return a.jsx(Jp,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(Vl,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(Zp,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(cs,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const k=(y=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:y[0];return(k==null?void 0:k.isPeerDelegation)?a.jsx(fa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(pa,{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(fa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(pa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(Xp,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(sr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(qp,{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})]}),f=({data:w})=>{const[y,E]=Ft.useState(!1),k=I=>{I.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:k,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:k,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},d=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(fi,{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(fi,{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(Xl,{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(or,{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(or,{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(f,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&d(e.data.toolDecision),e.data.toolInvocationStart&&p(e.data.toolInvocationStart),e.data.toolResult&&m(e.data.toolResult),e.data.artifactNotification&&g(e.data.artifactNotification)]})},hE={genericAgentNode:cE,userNode:pE,llmNode:dE,orchestratorNode:fE,genericToolNode:uE},gE={defaultFlowEdge:lE},xE={x:16,y:0},vE=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,o,s]=em([]),[i,l,c]=tm([]),{fitView:f}=nm(),{highlightedStepId:d,setHighlightedStepId:p}=Gi(),{taskIdInSidePanel:m}=Be(),g=u.useRef([]),[x,h]=u.useState(!1),[v,b]=u.useState(null),[w,y]=u.useState(!1),E=u.useRef(null),[k,I]=u.useState(null),A=u.useRef(new gp),T=u.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:aE(e),[e]),Y=u.useMemo(()=>T.edges.length?T.edges.map(M=>{const S=M.data;let O={isAnimated:!1,animationType:"none"};if(S!=null&&S.visualizerStepId){const R=e.length-1;O=A.current.getEdgeAnimationState(S.visualizerStepId,R,e)}let P=M.id===k;return d&&(S==null?void 0:S.visualizerStepId)===d&&(P=!0),{...M,animated:O.isAnimated,data:{...S,isAnimated:O.isAnimated,animationType:O.animationType,isSelected:P}}}):[],[T.edges,e,k,d]),Z=u.useCallback(()=>{o(M=>M.map(S=>{var ne,ie,re,ue;if(S.type!=="group")return S;const O=M.filter(de=>de.parentId===S.id);if(O.length===0)return S;let P=0,R=0;O.forEach(de=>{const Ie=de.position.x+_t,Re=de.position.y+Ke;P=Math.max(P,Ie),R=Math.max(R,Re)});const ee=P+ur,L=R+Yt;let H=0;const j=S.id.split("_");if(j.length>2){const de=j.find(Ie=>Ie.startsWith("subflow"));if(de){const Ie=parseInt(de.replace("subflow",""));isNaN(Ie)||(H=Ie)}}const W=_t+2*ur+H*50,_=Math.max(ee,W),V=parseInt(((ie=(ne=S.style)==null?void 0:ne.width)==null?void 0:ie.toString().replace("px",""))||"0"),J=parseInt(((ue=(re=S.style)==null?void 0:re.height)==null?void 0:ue.toString().replace("px",""))||"0");return V!==_||J!==L?{...S,style:{...S.style,width:`${_}px`,height:`${L}px`}}:S}))},[o]);u.useEffect(()=>{o(T.nodes),l(Y),Z()},[T.nodes,Y,o,l,Z]);const G=u.useCallback((M,S)=>i.find(O=>O.source===M&&(S?O.sourceHandle===S:!0))||null,[i]),q=u.useCallback((M,S)=>{var P;h(!0);const O=(P=S.data)==null?void 0:P.visualizerStepId;if(O){const R=e.find(ee=>ee.id===O);R&&(I(S.id),t?p(O):(p(O),b(R),y(!0)))}},[e,t,p]),te=u.useCallback(M=>{switch(M.type){case"userNode":{const S=M.data;return S!=null&&S.isTopNode?["user-bottom-output"]:S!=null&&S.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[`${M.id}-tool-bottom-output`];default:return[]}},[]),D=u.useCallback(()=>{y(!1),b(null)},[]),X=u.useCallback((M,S)=>{if(h(!0),S.type==="group"){p(null),I(null),D();return}const O=te(S);let P=null;for(const R of O)if(P=G(S.id,R),P)break;if(!P&&S.type==="userNode"){const R=S.data;R!=null&&R.isBottomNode&&(P=i.find(ee=>ee.target===S.id)||null)}P&&q(M,P)},[te,p,D,G,i,q]),N=u.useCallback(M=>{M!=null&&M.isTrusted&&h(!0)},[]);return u.useEffect(()=>{h(!1)},[m]),u.useEffect(()=>{!n&&f&&r.length>0&&g.current!==e&&x===!1&&(f({duration:200,padding:.1,maxZoom:1.2}),g.current=e)},[r.length,f,e,n,x]),u.useEffect(()=>{if(o(M=>M.map(S=>{var ee;const O=((ee=S.data)==null?void 0:ee.visualizerStepId)&&S.data.visualizerStepId===d,P=T.nodes.find(L=>L.id===S.id),R=(P==null?void 0:P.style)||{};return{...S,style:{...R,boxShadow:O?"0px 4px 12px rgba(0, 0, 0, 0.2)":R.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),d){const M=Y.find(S=>{const O=S.data;return(O==null?void 0:O.visualizerStepId)===d});M&&I(M.id)}else I(null)},[d,o,T.nodes,Y]),!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."}):T.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(rm,{nodes:r,edges:i.map(M=>({...M,markerEnd:{type:am.ArrowClosed,color:"#888"}})),onNodesChange:s,onEdgesChange:c,onEdgeClick:q,onNodeClick:X,onPaneClick:()=>{p(null),I(null),D()},onMoveStart:N,nodeTypes:hE,edgeTypes:gE,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(om,{}),a.jsx(sm,{className:oh()}),a.jsx(im,{position:"top-right",className:"flex items-center space-x-4",children:a.jsx("div",{ref:E})})]}),a.jsx(Ow,{isOpen:w,onClose:D,anchorRef:E,offset:xE,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:v&&a.jsx(mE,{step:v,variant:"popover"})})]})},wE=e=>a.jsx(Qp,{children:a.jsx(vE,{...e})}),yp=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}},kr=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},Sp=(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;yp(l)===e&&(s=s.concat(Sp(l.taskId,t,n,r+1)))}return s},bE=(e,t,n)=>{if(!n)return null;const r={overall:{totalTaskDurationMs:0},agents:{}},o=new Map,s=new Map,i=(N,M)=>(r.agents[N]||(r.agents[N]={agentName:M,instanceId:N,displayName:M,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),r.agents[N]),l=new Map,c=Sp(n.taskId,t,l,0);if(c.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const f=c.sort((N,M)=>new Date(kr(N)).getTime()-new Date(kr(M)).getTime()),d=[];let p,m="",g,x,h=[],v=null,b;const w=new Map,y=new Map,E=new Map,k=N=>{if(m.trim()&&g&&x){const M=m.trim();let S=n.taskId;if(h.length>0){const R=h[0].split("-");R.length>2&&R[1]!=="global"&&(S=R.slice(1,R.length-1).join("-"))}else N&&(S=N);const O=l.get(S)??0,P=w.get(S)||E.get(S);d.push({id:`vstep-agenttext-${d.length}-${h[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:x,title:`${g}: Response`,source:g,target:"User",data:{text:M},rawEventIds:[...h],isSubTaskStep:O>0,nestingLevel:O,owningTaskId:S,functionCallId:P}),v=M}m="",g=void 0,x=void 0,h=[],b=void 0};f.forEach((N,M)=>{var _,V,J,ne,ie,re,ue,de,Ie,Re,Fe,je,Ue,Qe,et,gt,tt,ot,ae,st,Ct,jt,Ht,xt,Wt,Et,Tt,qe,ft,Mt,Rt,ze,He,pt,rn,vt,Pt,on,Pe,mt,sn,Lt,At,Gt,Vt;const S=kr(N),O=`raw-${N.task_id||"global"}-${M}`,P=N.full_payload,R=N.task_id||n.taskId,ee=l.get(R)??0;let L=N.source_entity||"UnknownAgent";(J=(V=(_=P==null?void 0:P.params)==null?void 0:_.message)==null?void 0:V.metadata)!=null&&J.agent_name?L=P.params.message.metadata.agent_name:(ie=(ne=P==null?void 0:P.result)==null?void 0:ne.metadata)!=null&&ie.agent_name?L=P.result.metadata.agent_name:(Ie=(de=(ue=(re=P==null?void 0:P.result)==null?void 0:re.status)==null?void 0:ue.message)==null?void 0:de.metadata)!=null&&Ie.agent_name?L=P.result.status.message.metadata.agent_name:(je=(Fe=(Re=P==null?void 0:P.result)==null?void 0:Re.artifact)==null?void 0:Fe.metadata)!=null&&je.agent_name&&(L=P.result.artifact.metadata.agent_name);let H;if(ee>0?H=w.get(R):H=E.get(R),N.direction==="request"&&ee>0){const $=(Ue=P.params)==null?void 0:Ue.metadata,B=$==null?void 0:$.function_call_id,z=N.task_id;if(z&&B){w.set(z,B);return}}if(N.direction==="request"&&ee===0&&N.task_id===n.taskId){k(R),v=null;const $=P.params;let B="User request";if((Qe=$==null?void 0:$.message)!=null&&Qe.parts){const z=$.message.parts.filter(Q=>Q.kind==="text"&&Q.text);z.length>0&&(B=z[z.length-1].text)}d.push({id:`vstep-userreq-${d.length}-${O}`,type:"USER_REQUEST",timestamp:S,title:"User Input",source:"User",target:N.target_entity||L,data:{text:B},rawEventIds:[O],isSubTaskStep:!1,nestingLevel:0,owningTaskId:R});return}if(N.direction==="status-update"&&(P!=null&&P.result)){const $=P.result,B=(et=$.status)==null?void 0:et.message,z=B==null?void 0:B.metadata;let Q;const fe=!!(z!=null&&z.forwarded_from_peer);fe?Q=z.forwarded_from_peer:(gt=$.metadata)!=null&>.agent_name?Q=$.metadata.agent_name:z!=null&&z.agent_name?Q=z.agent_name:Q=N.source_entity||"Agent";const pe=`${Q}:${R}`;if(!fe&&(B!=null&&B.parts))for(const we of B.parts){if(we.kind==="data"){const he=we.data;he.type==="agent_progress_update"?p=he.status_text:he.type==="artifact_creation_progress"&&(p=`Saving artifact: ${he.filename} (${he.bytes_saved} bytes)`)}if(we.kind==="data"){k(R);const be=we.data;switch(be==null?void 0:be.type){case"agent_progress_update":{d.push({id:`vstep-progress-${d.length}-${O}`,type:"AGENT_RESPONSE_TEXT",timestamp:S,title:`${Q}: Progress Update`,source:Q,target:"User",data:{text:be.status_text},rawEventIds:[O],isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H});break}case"llm_invocation":{const le=be.request;let ge="System-initiated LLM call";if(le!=null&&le.contents&&Array.isArray(le.contents)&&le.contents.length>0){const U=[...le.contents].reverse().find(C=>C.role==="user");U&&U.parts&&(ge=U.parts.map(C=>C.text||"").join(`
|
|
338
|
+
`).trim())}const Ce={modelName:(le==null?void 0:le.model)||"Unknown Model",promptPreview:ge||"No text in user prompt."};i(pe,Q),o.set(pe,{timestamp:S,modelName:Ce.modelName}),d.push({id:`vstep-llmcall-${d.length}-${O}`,type:"AGENT_LLM_CALL",timestamp:S,title:`${Q}: LLM Call`,source:Q,target:"LLM",data:{llmCall:Ce},rawEventIds:[O],isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H});break}case"llm_response":{const le=o.get(pe);if(le){const C=new Date(S).getTime()-new Date(le.timestamp).getTime();i(pe,Q).llmCalls.push({modelName:le.modelName,durationMs:C,timestamp:le.timestamp}),o.delete(pe)}const ge=be.data,Ce=(tt=ge.content)==null?void 0:tt.parts,U=Ce==null?void 0:Ce.filter(C=>C.function_call);if(U&&U.length>0){k(R),v=null,E.delete(R);const C=U.map(Me=>{var Nt;return{functionCallId:Me.function_call.id,toolName:Me.function_call.name,toolArguments:Me.function_call.args||{},isPeerDelegation:(Nt=Me.function_call.name)==null?void 0:Nt.startsWith("peer_")}}),F={decisions:C,isParallel:C.length>1},K=[],Ne=new Set;C.forEach(Me=>{if(Me.isPeerDelegation){const Nt=Me.toolName.substring(5);for(const hn in t){const Le=t[hn];if(Ne.has(Le.taskId))continue;if(yp(Le)===R&&Le.events&&Le.events.length>0){const wr=Le.events.find(br=>{var sa,ia,aa,la;return br.direction==="request"&&((la=(aa=(ia=(sa=br.full_payload)==null?void 0:sa.params)==null?void 0:ia.message)==null?void 0:aa.metadata)==null?void 0:la.function_call_id)===Me.functionCallId});if(wr&&new Date(kr(wr)).getTime()>=new Date(S).getTime()){const br={functionCallId:Me.functionCallId,peerAgentName:Nt,subTaskId:Le.taskId};K.push(br),y.set(Me.functionCallId,br),Le.taskId&&(w.set(Le.taskId,Me.functionCallId),Ne.add(Le.taskId));break}}}}});const xe={id:`vstep-tooldecision-${d.length}-${O}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:S,title:`LLM: Tool Decision${F.isParallel?" (Parallel)":""}`,source:"LLM",target:Q,data:{toolDecision:F},rawEventIds:[O],delegationInfo:K.length>0?K:void 0,isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H};d.push(xe);const Ee=F.isParallel?xe.id:void 0,We=pe;i(We,Q),C.forEach(Me=>{var hn;const Nt=Me.isPeerDelegation?(hn=y.get(Me.functionCallId))==null?void 0:hn.subTaskId:void 0;s.has(Me.functionCallId)||s.set(Me.functionCallId,{timestamp:S,toolName:Me.toolName,isPeer:Me.isPeerDelegation,invokingAgentInstanceId:We,subTaskId:Nt,parallelBlockId:Ee})})}else{const C=(Ce==null?void 0:Ce.filter(K=>K.text).map(K=>K.text).join(`
|
|
339
|
+
`))||"",F={responsePreview:C.substring(0,200)+(C.length>200?"...":""),isFinalResponse:(ge==null?void 0:ge.partial)===!1};d.push({id:`vstep-llmrespagent-${d.length}-${O}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:S,title:`${Q}: LLM Response`,source:"LLM",target:Q,data:{llmResponseToAgent:F},rawEventIds:[O],isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H})}break}case"tool_invocation_start":{const le={functionCallId:be.function_call_id,toolName:be.tool_name,toolArguments:be.tool_args,isPeerInvocation:(ot=be.tool_name)==null?void 0:ot.startsWith("peer_")};d.push({id:`vstep-toolinvokestart-${d.length}-${O}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:S,title:`${Q}: Executing tool ${le.toolName}`,source:Q,target:le.toolName,data:{toolInvocationStart:le},rawEventIds:[O],isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H});break}case"tool_result":{const le=be.function_call_id,ge=s.get(le);if(ge){const U=new Date(S).getTime()-new Date(ge.timestamp).getTime(),C=r.agents[ge.invokingAgentInstanceId];if(C){const F={toolName:ge.toolName,durationMs:U,isPeer:ge.isPeer,timestamp:ge.timestamp,peerAgentName:ge.isPeer?ge.toolName.substring(5):void 0,subTaskId:ge.subTaskId,parallelBlockId:ge.parallelBlockId};C.toolCalls.push(F)}s.delete(le)}const Ce={toolName:be.tool_name,functionCallId:le,resultData:be.result_data,isPeerResponse:(ae=be.tool_name)==null?void 0:ae.startsWith("peer_")};d.push({id:`vstep-toolresult-${d.length}-${O}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:S,title:`${Q}: Tool Result - ${Ce.toolName}`,source:Ce.toolName,target:Q,data:{toolResult:Ce},rawEventIds:[O],isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H});break}}}else we.kind==="text"&&we.text&&(g&&g!==Q&&(k(R),v=null),g||(g=Q,x=S,b=fe),m+=we.text,h.push(O))}return}if(N.direction==="artifact_update"&&((st=P==null?void 0:P.result)!=null&&st.artifact)){k(R);const $=P.result.artifact,B=((Ct=$.metadata)==null?void 0:Ct.agent_name)||N.source_entity||"Agent";let z;if($.parts&&$.parts.length>0){const fe=$.parts[0];fe.kind==="file"?z=fe.file.mimeType||void 0:(jt=fe.metadata)!=null&&jt.mime_type&&(z=fe.metadata.mime_type)}const Q={artifactName:$.name||"Unnamed Artifact",version:typeof((Ht=$.metadata)==null?void 0:Ht.version)=="number"?$.metadata.version:void 0,description:$.description||void 0,mimeType:z};d.push({id:`vstep-artifactnotify-${d.length}-${O}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:S,title:`${B}: Artifact Update - ${Q.artifactName}`,source:B,target:"User/System",data:{artifactNotification:Q},rawEventIds:[O],isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H});return}if(["response","task"].includes(N.direction)&&((Wt=(xt=P==null?void 0:P.result)==null?void 0:xt.status)!=null&&Wt.state)){m.trim()&&k(R);const $=P.result,B=$.status.state,z=((Et=$.metadata)==null?void 0:Et.agent_name)||((ft=(qe=(Tt=$.status)==null?void 0:Tt.message)==null?void 0:qe.metadata)==null?void 0:ft.agent_name)||N.source_entity||"Agent";if(["completed","failed","canceled"].includes(B)&&ee==0){const Q=B==="completed"?"TASK_COMPLETED":"TASK_FAILED",fe=`${z}: Task ${B.charAt(0).toUpperCase()+B.slice(1)}`;let pe={},we="";if((Mt=$.status.message)!=null&&Mt.parts){const ke=$.status.message.parts.find(le=>le.kind==="text");ke!=null&&ke.text&&(we=ke.text.trim())}const he=R===n.taskId,be=we&&(!he||we!==v);if(Q==="TASK_COMPLETED")pe={finalMessage:be?we:void 0};else{const le={message:be?we:`Task ${B}.`},ge=P.error;ge&&(le.message=ge.message||le.message,le.code=ge.code,ge.data&&(le.details=ge.data)),$.error&&(le.message=$.error.message||le.message,le.code=$.error.code||le.code,le.details=$.error.data||le.details),pe={errorDetails:le}}d.push({id:`vstep-${B}-${d.length}-${O}`,type:Q,timestamp:S,title:fe,source:z,target:"User",data:pe,rawEventIds:[O],isSubTaskStep:ee>0,nestingLevel:ee,owningTaskId:R,functionCallId:H}),he&&(v=null);return}}const j=N.direction==="status-update"&&((pt=(He=(ze=(Rt=P==null?void 0:P.result)==null?void 0:Rt.status)==null?void 0:ze.message)==null?void 0:He.parts)==null?void 0:pt.some($=>$.kind==="text"));let W=N.source_entity;(on=(Pt=(vt=(rn=P==null?void 0:P.result)==null?void 0:rn.status)==null?void 0:vt.message)==null?void 0:Pt.metadata)!=null&&on.forwarded_from_peer?W=P.result.status.message.metadata.forwarded_from_peer:(mt=(Pe=P==null?void 0:P.result)==null?void 0:Pe.metadata)!=null&&mt.agent_name?W=P.result.metadata.agent_name:(Gt=(At=(Lt=(sn=P==null?void 0:P.result)==null?void 0:sn.status)==null?void 0:Lt.message)==null?void 0:At.metadata)!=null&&Gt.agent_name&&(W=P.result.status.message.metadata.agent_name),m.trim()&&g&&(!j||j&&W!==g)&&(k(R),l.get(((Vt=h[0])==null?void 0:Vt.split("-")[1])||n.taskId)===0&&!b&&(v=null))});const I=f.length>0&&f[f.length-1].task_id||n.taskId;k(I);const A=f[0]?kr(f[0]):n.firstSeen.toISOString();let T,Y="working";const Z=d.filter(N=>N.owningTaskId===n.taskId),G=Z.length>0?Z[Z.length-1]:null;if(G&&(G.type==="TASK_COMPLETED"?(Y="completed",T=G.timestamp):G.type==="TASK_FAILED"&&(Y="failed",T=G.timestamp)),Y==="working"&&f.length>0){const N=f[f.length-1];t[N.task_id||n.taskId]}let q;A&&T&&(q=new Date(T).getTime()-new Date(A).getTime()),["completed","failed","canceled","rejected"].includes(Y)&&(p=void 0);const te={taskId:n.taskId,initialRequestText:n.initialRequestText,status:Y,currentStatusText:p,startTime:A,endTime:T,durationMs:q,steps:d};te.steps.forEach((N,M)=>{if(N.type==="TASK_COMPLETED"){let S="";for(let O=M-1;O>=0;O--){const P=te.steps[O];if(P.type!=="AGENT_RESPONSE_TEXT"||P.source!==N.source)break;S=P.data.text+S}N.data.finalMessage&&(S+=N.data.finalMessage),N.data.finalMessage=S.trim()||void 0}}),Object.values(r.agents).forEach(N=>{N.totalLlmTimeMs=N.llmCalls.reduce((R,ee)=>R+ee.durationMs,0);const M=N.toolCalls.filter(R=>!R.parallelBlockId),S=new Map;N.toolCalls.forEach(R=>{R.parallelBlockId&&(S.has(R.parallelBlockId)||S.set(R.parallelBlockId,[]),S.get(R.parallelBlockId).push(R))});const O=M.reduce((R,ee)=>R+ee.durationMs,0);let P=0;S.forEach(R=>{if(R.length>0){const ee=Math.min(...R.map(H=>new Date(H.timestamp).getTime())),L=Math.max(...R.map(H=>new Date(H.timestamp).getTime()+H.durationMs));P+=L-ee}}),N.totalToolTimeMs=O+P});const D=new Map;Object.values(r.agents).forEach(N=>{D.has(N.agentName)||D.set(N.agentName,[]),D.get(N.agentName).push(N)}),D.forEach(N=>{N.length>1&&(N.sort((M,S)=>{const O=P=>{const R=[...P.llmCalls.map(ee=>new Date(ee.timestamp).getTime()),...P.toolCalls.map(ee=>new Date(ee.timestamp).getTime())];return R.length>0?Math.min(...R):1/0};return O(M)-O(S)}),N.forEach((M,S)=>{M.displayName=`${M.agentName} (${S+1})`}))});const X=new Map;return Object.values(r.agents).forEach(N=>{const M=N.instanceId.split(":").slice(1).join(":");M&&X.set(M,N.displayName)}),Object.values(r.agents).forEach(N=>{N.toolCalls.forEach(M=>{if(M.isPeer&&M.subTaskId){const S=X.get(M.subTaskId);S&&(M.peerAgentName=S)}})}),q!==void 0&&(r.overall.totalTaskDurationMs=q),te.performanceReport=r,te},yE=({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(CE,{onClick:o}),a.jsx(TE,{items:e,bottomItems:t,activeItem:n,onItemClick:s})]})},SE=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"})]}),CE=({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:SE})}),EE=()=>{const{currentTheme:e,toggleTheme:t}=Zu(),n=`Toggle theme (currently ${e})`;return a.jsxs(Pi,{children:[a.jsx(Li,{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(Zl,{className:"mb-1 w-6 h-6"})})}),a.jsx(Di,{side:"right",children:n})]})},TE=({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(Rl,{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(EE,{}):a.jsx(Rl,{item:o,isActive:n===o.id,onItemClick:r},o.id)},o.id))})]}),Rl=({item:e,isActive:t,onItemClick:n})=>{const{id:r,label:o,icon:s,disabled:i}=e,l=()=>{!i&&n&&n(r)},c=f=>{(f.key==="Enter"||f.key===" ")&&l()};return a.jsxs(Pi,{children:[a.jsx(Li,{asChild:!0,children:a.jsxs("button",{type:"button",onClick:n?l:void 0,onKeyDown:n?c:void 0,disabled:i,className:Se("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:Se("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(Di,{side:"right",children:o})]})},Pl=[{id:"chat",label:"Chat",icon:Wl},{id:"agentMesh",label:"Agents",icon:Jl}],Ll=[{id:"theme-toggle",label:"Theme",icon:Zl,onClick:()=>{}}],Cp=({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 items-center h-8",children:t.map((s,i)=>a.jsxs(Ft.Fragment,{children:[i>0&&a.jsx("span",{className:"mx-1",children:a.jsx(lm,{size:16})}),s.onClick?a.jsx(ve,{variant:"link",className:"p-0 m-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 text-xl text-nowrap pt-[35px]",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",children:r.map((s,i)=>a.jsx(Ft.Fragment,{children:s},i))})]}),at=({label:e,value:t,icon:n,fullWidthValue:r=!1})=>t==null||typeof t=="string"&&!t.trim()?null:a.jsxs("div",{className:`flex mb-1.5 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})]}),AE=({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,f])=>a.jsxs("li",{className:"text-sm",children:[a.jsxs("span",{className:"capitalize",children:[c.replace(/_/g," "),":"]})," ",f?"Yes":"No"]},c))}),o=(l,c="None")=>!l||l.length===0?a.jsx("span",{children:c}):l.map(f=>a.jsx("span",{className:"mr-1 mb-1 inline-block rounded-full px-2 py-0.5 text-xs font-medium",children:f},f)),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:"font-semibold text-foreground",children:c.name}),a.jsx("p",{className:"mb-1",children:c.description})]},c.name))});return a.jsx("div",{className:"h-[400px] cursor-pointer w-full sm:w-[380px] flex-shrink-0 bg-card rounded-lg",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(Jl,{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(at,{label:"Version",value:e.version,icon:a.jsx(ma,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&a.jsx(at,{label:"Key Capabilities",value:r(e.capabilities),icon:a.jsx(ha,{size:14}),fullWidthValue:!0})]}),a.jsx("div",{className:"border-t p-2 text-center text-sm text-accent-foreground",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(at,{label:"Name",value:e.name,icon:a.jsx(vi,{size:14})}),a.jsx(at,{label:"Description",value:e.description,icon:a.jsx(cm,{size:14}),fullWidthValue:!0}),a.jsx(at,{label:"Version",value:e.version,icon:a.jsx(ma,{size:14})}),a.jsx(at,{label:"Endpoint",value:e.url||"N/A",icon:a.jsx(Xl,{size:14})}),a.jsx(at,{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(Bl,{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(at,{label:"Name",value:e.provider.organization}),a.jsx(at,{label:"URL",value:e.provider.url||"N/A"})]}),a.jsx(at,{label:"Capabilities",value:r(e.capabilities),icon:a.jsx(ha,{size:14}),fullWidthValue:!0}),a.jsx(at,{label:"Input Modes",value:o(e.defaultInputModes),icon:a.jsx(ga,{size:14}),fullWidthValue:!0}),a.jsx(at,{label:"Output Modes",value:o(e.defaultOutputModes),icon:a.jsx(ga,{size:14}),fullWidthValue:!0}),a.jsx(at,{label:"Skills",value:s(e.skills),icon:a.jsx(um,{size:14}),fullWidthValue:!0}),a.jsx(at,{label:"Tools Info",value:i(e.tools),icon:a.jsx(Hl,{size:14}),fullWidthValue:!0}),a.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:a.jsx(at,{label:"A2A Protocol",value:e.protocolVersion})})]}),a.jsx("div",{className:"border-t p-2 text-center text-sm text-accent-foreground",children:"Click for summary"})]})]})})},ui=({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(ve,{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(AE,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>s(l.name)},l.name))})})]})})},Ep={LAYOUT:"layout"};class NE{constructor(){ca(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:Ep.LAYOUT,id:"cards",label:"Cards",icon:dm,priority:100,render:t=>a.jsx(ui,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}const Tp=new NE,kE=({currentLayout:e,onLayoutChange:t,className:n=""})=>{const r=Tp.getPluginsByType(Ep.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(ve,{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},Dl={CARDS:"cards"};function _E(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=Be(),[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(ra,{variant:"error",message:`Error loading agents. ${n}`})})});const i=()=>{if(o===Dl.CARDS)return a.jsx(ui,{agents:e});const l=Tp.getPluginById(o);return l?l.render({agents:e}):(console.warn(`Layout ${o} not found, falling back to cards layout`),a.jsx(ui,{agents:e}))};return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(Cp,{title:"Agents",buttons:[a.jsxs(ve,{variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[a.jsx(Yl,{className:"size-4"}),"Refresh Agents"]})]}),a.jsxs("div",{className:`relative flex-1 p-4 ${o===Dl.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(kE,{currentLayout:o,onLayoutChange:s})}),i()]})]})}const IE=({isOpen:e,onClose:t,onConfirm:n,sessionName:r})=>e?a.jsx(Go,{open:e,onOpenChange:t,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{children:"Delete Chat Session?"}),a.jsxs(qo,{children:["This action cannot be undone. This chat session and any associated artifacts will be permanently deleted: ",a.jsx("strong",{children:r}),"."]})]}),a.jsxs(Nv,{children:[a.jsx(ve,{variant:"outline",onClick:t,title:"Cancel",children:"Cancel"}),a.jsx(ve,{onClick:n,title:"Delete",children:"Delete"})]})]})}):null,co=4,di={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},jE={chatPanelSizes:{...di.chatPanelSizes,min:50},sidePanelSizes:{...di.sidePanelSizes,max:50}};function ME(){var H;const{agents:e,sessionId:t,messages:n,setMessages:r,selectedAgentName:o,setSelectedAgentName:s,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,openSidePanelTab:c,setTaskIdInSidePanel:f,isResponding:d,latestStatusText:p,sessionToDelete:m,closeSessionDeleteModal:g,confirmSessionDelete:x}=Be(),{isTaskMonitorConnected:h,isTaskMonitorConnecting:v,taskMonitorSseError:b,connectTaskMonitorStream:w}=Gi(),[y,E]=u.useState(!0),[k,I]=u.useState(!1),A=Xu(),[T,Y]=u.useState(!1),Z=u.useRef(null),G=u.useRef(null),q=u.useRef(null),{chatPanelSizes:te,sidePanelSizes:D}=u.useMemo(()=>y?di:jE,[y]),X=u.useCallback(j=>{if(I(!0),G.current)if(j)G.current.resize(co);else{const W=q.current||D.default;G.current.resize(W)}setTimeout(()=>I(!1),300)},[D.default]),N=u.useCallback(()=>{l(!0)},[l]),M=u.useCallback(()=>{l(!1)},[l]),S=u.useCallback(j=>{j>co+1&&(q.current=j)},[]),O=u.useCallback(()=>{E(!y)},[y]);u.useEffect(()=>{G.current&&i&&G.current.resize(co);const j=()=>{if(G.current&&i){I(!0);const W=q.current||D.default;G.current.resize(W),l(!1),setTimeout(()=>I(!1),300)}};return window.addEventListener("expand-side-panel",j),()=>{window.removeEventListener("expand-side-panel",j)}},[i,l,D.default]),u.useEffect(()=>{if(!o&&e.length>0){const j=e.find(J=>J.name==="OrchestratorAgent"),W=j?j.name:e[0].name;s(W);const _=e.find(J=>J.name===W),V=_!=null&&_.displayName?`Hi! I'm the ${_==null?void 0:_.displayName} Agent. How can I help?`:`Hi! I'm ${W}. How can I help?`;r(J=>[...J.filter(ie=>!ie.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 P=u.useMemo(()=>{const j=new Map;return n.forEach((W,_)=>{W.taskId&&j.set(W.taskId,_)}),j},[n]),R=u.useMemo(()=>n.find(j=>j.isStatusBubble),[n]),ee=u.useMemo(()=>{if(!R||!R.parts)return null;const j=R.parts.find(W=>W.kind==="text");return(j==null?void 0:j.text)||null},[R]),L=u.useMemo(()=>{if(R!=null&&R.taskId)return()=>{f(R.taskId),c("workflow")}},[R==null?void 0:R.taskId,f,c]);return u.useEffect(()=>{const j=()=>{!h&&!v&&b&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),w())};return window.addEventListener("focus",j),()=>{window.removeEventListener("focus",j)}},[h,v,b,w]),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 ${y?"-translate-x-full":"translate-x-0"}`,children:a.jsx($C,{onToggle:O})}),a.jsx("div",{className:`transition-all duration-300 ${y?"ml-0":"ml-100"}`,children:a.jsx(Cp,{title:A,leadingAction:y?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ve,{variant:"ghost",onClick:O,className:"h-10 w-10 p-0",tooltip:"Show Sessions Panel",children:a.jsx(Kl,{className:"size-5"})}),a.jsx("div",{className:"h-6 w-px bg-gray-300 dark:bg-gray-600"}),a.jsx(ve,{variant:"ghost",onClick:()=>Y(!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 ${y?"ml-0":"ml-100"}`,children:a.jsxs(nw,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[a.jsx(rl,{defaultSize:te.default,minSize:te.min,maxSize:te.max,id:"chat-panel",children:a.jsxs("div",{className:"flex h-full w-full flex-col py-6",children:[a.jsx(uf,{className:"text-base",ref:Z,children:n.map((j,W)=>{var V;const _=!!(j.taskId&&P.get(j.taskId)===W);return a.jsx(CC,{message:j,isLastWithTaskId:_},`${((V=j.metadata)==null?void 0:V.sessionId)||"session"}-${W}-${j.isUser?"received":"sent"}`)})}),a.jsxs("div",{style:cf,children:[d&&a.jsx(ai,{statusText:(ee||p.current)??void 0,onViewWorkflow:L}),a.jsx(rb,{agents:e,scrollToBottom:(H=Z.current)==null?void 0:H.scrollToBottom})]})]})}),a.jsx(rw,{}),a.jsx(rl,{ref:G,defaultSize:D.default,minSize:D.min,maxSize:D.max,collapsedSize:co,collapsible:!0,onCollapse:N,onExpand:M,onResize:S,id:"chat-side-panel",className:k?"transition-all duration-300 ease-in-out":"",children:a.jsx("div",{className:"h-full",children:a.jsx(zC,{onCollapsedToggle:X,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,isSidePanelTransitioning:k})})})]})})}),a.jsx(hp,{isOpen:T,onClose:()=>Y(!1)}),a.jsx(IE,{isOpen:!!m,onClose:g,onConfirm:x,sessionName:(m==null?void 0:m.name)||`Session ${m==null?void 0:m.id.substring(0,8)}`})]})}const RE=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)"}}),fi=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=Zu(),o=u.useMemo(()=>RE(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(fm,{data:i,theme:o,viewOnly:!0,collapse:s,showStringQuotes:!0,showCollectionCount:"when-closed"})})};let uo=null,fo=null;function PE({children:e}){const{fetchCsrfToken:t}=Ku(),[n,r]=u.useState(uo),[o,s]=u.useState(!uo&&!fo),[i,l]=u.useState(fo);return u.useEffect(()=>{if(uo||fo)return;let c=!0;return(async()=>{s(!0),l(null);try{let d=await De("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"}}),p;if(d.ok)p=await d.json();else{const x=await d.text();if(console.error("Initial config fetch failed:",d.status,x),d.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..."),d=await De("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":h,Accept:"application/json"}}),!d.ok){const v=await d.text();throw console.error("Config fetch retry failed:",d.status,v),new Error(`Failed to fetch config on retry: ${d.status} ${v}`)}p=await d.json()}else throw new Error(`Failed to fetch config: ${d.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&&(uo=g,r(g)),console.log("App config processed and set:",g)}catch(d){if(console.error("Error initializing app:",d),c){const p=d.message||"Failed to load application configuration.";fo=p,l(p)}}finally{c&&s(!1)}})(),()=>{c=!1}},[t]),n?a.jsx(Wu.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 LE=({children:e})=>{const{configServerUrl:t}=nn(),n=`${t}/api/v1`,[r,o]=u.useState(null),[s,i]=u.useState(!1),[l,c]=u.useState(!1),[f,d]=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),k=10,I=u.useRef(null),A=u.useRef(null),T=u.useRef(null);u.useEffect(()=>{A.current=r},[r]);const Y=u.useCallback(S=>{m(O=>{var L,H,j;const P=S.task_id;if(!P)return S.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",S),O;const R=O[P],ee=new Date(S.timestamp);if(R){const W=[...R.events,S].sort((_,V)=>new Date(_.timestamp).getTime()-new Date(V.timestamp).getTime());return{...O,[P]:{...R,events:W,lastUpdated:ee}}}else{let W="Task started...";if(S.direction==="request"&&((H=(L=S.full_payload)==null?void 0:L.method)!=null&&H.startsWith("message/"))){const V=S.full_payload.params;if((j=V==null?void 0:V.message)!=null&&j.parts){const J=V.message.parts.filter(ne=>ne.kind==="text"&&ne.text);J.length>0&&(W=J[J.length-1].text)}}const _={taskId:P,initialRequestText:W,events:[S],firstSeen:ee,lastUpdated:ee};return x(V=>[P,...V.filter(J=>J!==P)]),{...O,[P]:_}}})},[]),Z=u.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),i(!1),c(!0),d(null),w(0),E(!1),T.current&&(clearTimeout(T.current),T.current=null)},[]),G=u.useCallback(S=>{try{const O=JSON.parse(S.data);Y(O)}catch(O){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",O,"Raw data:",S.data),d("Received unparseable 'a2a_message' event from server.")}},[Y]),q=u.useCallback(S=>{console.error("TaskMonitorContext: SSE connection error:",S),i(!1),c(!1),I.current&&I.current.readyState===EventSource.CLOSED?d("Task Monitor SSE connection closed by server or network issue."):d("Task Monitor SSE connection error occurred."),I.current&&(I.current.close(),I.current=null),T.current&&(clearTimeout(T.current),T.current=null)},[]),te=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 S={subscription_targets:[{type:"my_a2a_messages"}]},O=await De(`${n}/visualization/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S),credentials:"include"});if(!O.ok){const j=await O.json().catch(()=>({detail:"Failed to subscribe"}));if(j.error_type==="authorization_failure"){const W=j.message||"Access denied: insufficient permissions",_=j.suggested_action?` ${j.suggested_action}`:"";throw new Error(`${W}${_}`)}else if(j.error_type==="subscription_failure"){const W=j.message||"Subscription failed",_=j.suggested_action?` ${j.suggested_action}`:"";throw new Error(`${W}${_}`)}else throw new Error(j.detail||j.message||`Subscription failed: ${O.statusText}`)}const P=await O.json();o(P.stream_id);const R=P.sse_endpoint_url.startsWith("/")?`${t||""}${P.sse_endpoint_url}`:P.sse_endpoint_url;I.current&&I.current.close();const ee=wi(),L=`${R}${ee?`?token=${ee}`:""}`,H=new EventSource(L,{withCredentials:!0});I.current=H,H.onopen=Z,H.addEventListener("a2a_message",G),H.onerror=q}catch(S){console.error("TaskMonitorContext: Error connecting stream:",S),d(S instanceof Error?S.message:String(S)),i(!1),c(!1),o(null),I.current&&(I.current.close(),I.current=null),T.current&&(clearTimeout(T.current),T.current=null)}},[n,t,l,s,Z,G,q]),D=u.useCallback(()=>{if(T.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(b>=k){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),E(!1),d(`Connection lost. Max reconnection attempts (${k}) reached.`);return}const S=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${b+1}/${k} in ${S}ms...`),E(!0),w(O=>O+1),T.current=setTimeout(()=>{te()},S)},[b,te]),X=u.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),T.current&&(clearTimeout(T.current),T.current=null),I.current&&(I.current.close(),I.current=null);const S=A.current;if(S)try{await De(`${n}/visualization/${S}/unsubscribe`,{method:"DELETE",credentials:"include"})}catch(O){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${S}`,O)}o(null),i(!1),c(!1),d(null),m({}),x([]),v(null),w(0),E(!1)},[n]);u.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),I.current&&(I.current.close(),I.current=null);const S=A.current;if(S)if(navigator.sendBeacon){const O=new FormData;navigator.sendBeacon(`${n}/visualization/${S}/unsubscribe`,O)}else De(`${n}/visualization/${S}/unsubscribe`,{method:"DELETE",credentials:"include",keepalive:!0}).catch(O=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",O))},[n]),u.useEffect(()=>{!l&&!s&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),te())},[]),u.useEffect(()=>{!l&&!s&&f&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),D())},[l,s,f,D]),u.useEffect(()=>()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]);const N=u.useCallback(S=>{v(S)},[]),M={isTaskMonitorConnecting:s,isTaskMonitorConnected:l,taskMonitorSseError:f,monitoredTasks:p,monitoredTaskOrder:g,highlightedStepId:h,isReconnecting:y,reconnectionAttempts:b,connectTaskMonitorStream:te,disconnectTaskMonitorStream:X,setHighlightedStepId:N};return a.jsx(Vu.Provider,{value:M,children:e})},DE=1*1024*1024,OE=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result.split(",")[1]),r.onerror=o=>n(o)}),FE=({children:e})=>{const{configWelcomeMessage:t,configServerUrl:n}=nn(),r=u.useMemo(()=>`${n}/api/v1`,[n]),[o,s]=u.useState(""),[i,l]=u.useState([]),[c,f]=u.useState(""),[d,p]=u.useState(!1),[m,g]=u.useState([]),[x,h]=u.useState(null),v=u.useRef(null),[b,w]=u.useState(""),[y,E]=u.useState(!1),[k,I]=u.useState(null),A=u.useRef(null),T=u.useRef(!1),Y=u.useRef(null),Z=u.useRef(0),G=u.useRef(y);u.useEffect(()=>{G.current=y},[y]);const{agents:q,error:te,isLoading:D,refetch:X}=hw(),{artifacts:N,isLoading:M,refetch:S}=gw(o),[O,P]=u.useState(!0),[R,ee]=u.useState("files"),[L,H]=u.useState(!1),[j,W]=u.useState(null),[_,V]=u.useState(!1),[J,ne]=u.useState(new Set),[ie,re]=u.useState(!1),[ue,de]=u.useState(null),[Ie,Re]=u.useState(null),[Fe,je]=u.useState(null),[Ue,Qe]=u.useState(null),[et,gt]=u.useState(null),[tt,ot]=u.useState(null),ae=u.useCallback(($,B)=>{g(z=>{if(z.find(we=>we.message===$))return z;const fe=Date.now().toString(),pe={id:fe,message:$,type:B||"info"};return setTimeout(()=>{g(we=>we.filter(he=>he.id!==fe))},3e3),[...z,pe]})},[]),st=u.useCallback(async $=>{const B=await De(`${r}/sessions/${$}/messages`);if(!B.ok){const z=await B.json().catch(()=>({detail:"Failed to fetch session history"}));throw new Error(z.detail||`HTTP error ${B.status}`)}return B.json()},[r]),Ct=u.useCallback(async $=>{const B=new FormData;B.append("file",$);try{const z=await De(`${r}/artifacts/${o}/${encodeURIComponent($.name)}`,{method:"POST",body:B,credentials:"include"});if(!z.ok){const fe=await z.json().catch(()=>({detail:`Failed to upload ${$.name}`}));throw new Error(fe.detail||`HTTP error ${z.status}`)}const Q=await z.json();return ae(`Artifact "${$.name}" uploaded successfully.`),await S(),Q.uri||null}catch(z){return ae(`Error uploading artifact "${$.name}": ${z instanceof Error?z.message:"Unknown error"}`),null}},[r,o,ae,S]),jt=u.useCallback(async $=>{try{const B=await De(`${r}/artifacts/${o}/${encodeURIComponent($)}`,{method:"DELETE",credentials:"include"});if(!B.ok&&B.status!==204){const z=await B.json().catch(()=>({detail:`Failed to delete ${$}`}));throw new Error(z.detail||`HTTP error ${B.status}`)}ae(`File "${$}" deleted successfully.`),S()}catch(B){ae(`Error deleting file "${$}": ${B instanceof Error?B.message:"Unknown error"}`)}},[r,o,ae,S]),Ht=u.useCallback($=>{W($),H(!0)},[]),xt=u.useCallback(()=>{W(null),H(!1)},[]),Wt=u.useCallback(async()=>{j&&await jt(j.filename),xt()},[j,jt,xt]),Et=u.useCallback(()=>{if(J.size===0){ae("No files selected for deletion.");return}re(!0)},[J,ae]),Tt=u.useCallback(async()=>{re(!1);const $=Array.from(J);let B=0,z=0;for(const Q of $)try{const fe=await De(`${r}/artifacts/${encodeURIComponent(Q)}`,{method:"DELETE",credentials:"include"});if(!fe.ok&&fe.status!==204)throw new Error(`Failed to delete ${Q}`);B++}catch(fe){console.error(fe),z++}B>0&&ae(`${B} files(s) deleted successfully.`),z>0&&ae(`Failed to delete ${z} files(s).`),S(),ne(new Set),V(!1)},[J,r,ae,S]),qe=u.useCallback(async $=>{Re(null),je(null),Qe(null);try{const B=await De(`${r}/artifacts/${o}/${encodeURIComponent($)}/versions`,{credentials:"include"});if(!B.ok)throw new Error("Error fetching version list");const z=await B.json();if(!z||z.length===0)throw new Error("No versions available");Re(z.sort((ke,le)=>ke-le));const Q=Math.max(...z);je(Q);const fe=await De(`${r}/artifacts/${o}/${encodeURIComponent($)}/versions/${Q}`,{credentials:"include"});if(!fe.ok)throw new Error("Error fetching latest version content");const pe=await fe.blob(),we=await new Promise((ke,le)=>{const ge=new FileReader;ge.onloadend=()=>{var Ce;return ke(((Ce=ge.result)==null?void 0:Ce.toString().split(",")[1])||"")},ge.onerror=le,ge.readAsDataURL(pe)}),he=N.find(ke=>ke.filename===$),be={name:$,mime_type:(he==null?void 0:he.mime_type)||"application/octet-stream",content:we,last_modified:(he==null?void 0:he.last_modified)||new Date().toISOString()};return Qe(be),be}catch(B){return ae(`Error loading preview for ${$}: ${B instanceof Error?B.message:"Unknown error"}`),null}},[r,o,N,ae]),ft=u.useCallback(async($,B)=>{if(!Ie||!Ie.includes(B))return ae(`Version ${B} is not available for ${$}.`),null;Qe(null);try{const z=await De(`${r}/artifacts/${o}/${encodeURIComponent($)}/versions/${B}`,{credentials:"include"});if(!z.ok)throw new Error(`Error fetching version ${B}`);const Q=await z.blob(),fe=await new Promise((he,be)=>{const ke=new FileReader;ke.onloadend=()=>{var le;return he(((le=ke.result)==null?void 0:le.toString().split(",")[1])||"")},ke.onerror=be,ke.readAsDataURL(Q)}),pe=N.find(he=>he.filename===$),we={name:$,mime_type:(pe==null?void 0:pe.mime_type)||"application/octet-stream",content:fe,last_modified:(pe==null?void 0:pe.last_modified)||new Date().toISOString()};return je(B),Qe(we),we}catch(z){return ae(`Error loading version ${B}: ${z instanceof Error?z.message:"Unknown error"}`),null}},[r,ae,N,Ie,o]),Mt=u.useCallback($=>{ae(`Loading preview for attached file: ${$.name}`),Qe($),Re(null),je(null)},[ae]),Rt=u.useCallback($=>{P(!1),ee($),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:$}}))},[]),ze=u.useCallback(()=>{A.current&&(clearTimeout(A.current),A.current=null),v.current&&(v.current.close(),v.current=null),T.current=!1},[]),He=u.useCallback($=>{var ge;Z.current+=1;const B=Z.current;let z;try{console.log("TEST-SSE ChatProvider Raw Message:",$.data),z=JSON.parse($.data)}catch(Ce){console.error("Failed to parse SSE message:",Ce),ae("Received unparseable agent update.","error");return}if("error"in z&&z.error){const U=`Error: ${z.error.message}`;l(C=>{const F=C.filter(K=>!K.isStatusBubble);return F.push({role:"agent",parts:[{kind:"text",text:U}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${crypto.randomUUID()}`,lastProcessedEventSequence:B}}),F}),p(!1),ze(),h(null);return}if(!("result"in z)||!z.result){console.warn("Received SSE message without a result or error field.",z);return}const Q=z.result;let fe=!1,pe,we,he;switch(Q.kind){case"task":fe=!0,pe=void 0,he=Q.id,Q.artifacts&&Q.artifacts.length>0&&console.log("Final task has artifacts to process:",Q.artifacts);break;case"status-update":fe=Q.final,pe=(ge=Q.status)==null?void 0:ge.message,he=Q.taskId;break;case"artifact-update":we=Q.artifact,he=Q.taskId;break;default:console.warn("Received unknown result kind in SSE message:",Q);return}const be=[],ke=[];let le=null;if(pe!=null&&pe.parts)for(const Ce of pe.parts)if(Ce.kind==="data"){const U=Ce.data;if(U&&typeof U=="object"&&"type"in U)switch(U.type){case"agent_progress_update":le=String((U==null?void 0:U.status_text)??"Processing...");break;case"artifact_creation_progress":le=`Saving artifact: ${String((U==null?void 0:U.filename)??"unknown file")} (${Number((U==null?void 0:U.bytes_saved)??0)} bytes)`;break;case"tool_invocation_start":break;default:be.push(Ce)}}else if(Ce.kind==="file"){const C=Ce.file,F={name:C.name||"untitled_file",mime_type:C.mimeType};"bytes"in C&&C.bytes?F.content=C.bytes:"uri"in C&&C.uri&&(F.uri=C.uri),ke.push(F)}else be.push(Ce);le&&(Y.current=le),l(Ce=>{var Ne;const U=[...Ce];let C=U[U.length-1];C!=null&&C.isStatusBubble&&(U.pop(),C=U[U.length-1]);const F=be.find(xe=>xe.kind==="text"),K=be.filter(xe=>xe.kind!=="text");if(C&&!C.isUser&&!C.isComplete&&C.taskId===Q.taskId&&(F||ke.length>0)){const xe={...C,parts:[...C.parts],files:C.files?[...C.files]:[],isComplete:fe||ke.length>0,metadata:{...C.metadata,lastProcessedEventSequence:B}};if(F){const Ee=xe.parts[xe.parts.length-1];(Ee==null?void 0:Ee.kind)==="text"?xe.parts[xe.parts.length-1]={...Ee,text:Ee.text+F.text}:xe.parts.push(F)}K.length>0&&xe.parts.push(...K),ke.length>0&&xe.files.push(...ke),U[U.length-1]=xe}else if(be.some(Ee=>Ee.kind==="text"&&Ee.text.trim())||ke.length>0||we){const Ee={role:"agent",parts:be,files:ke.length>0?ke:void 0,taskId:Q.taskId,isUser:!1,isComplete:fe||ke.length>0,metadata:{messageId:((Ne=z.id)==null?void 0:Ne.toString())||`msg-${crypto.randomUUID()}`,sessionId:Q.contextId,lastProcessedEventSequence:B}};we&&(Ee.artifactNotification={name:we.name||we.artifactId}),U.push(Ee)}if(!fe&&Y.current)U.push({role:"agent",parts:[{kind:"text",text:Y.current}],taskId:Q.taskId,isUser:!1,isStatusBubble:!0,isComplete:!1,metadata:{messageId:`status-${crypto.randomUUID()}`,lastProcessedEventSequence:B}});else if(fe){Y.current=null;const xe=U.findLastIndex(Ee=>!Ee.isUser&&Ee.taskId===he);xe!==-1&&(U[xe]={...U[xe],isComplete:!0,metadata:{...U[xe].metadata,lastProcessedEventSequence:B}})}return U}),fe&&(G.current&&(ae("Task successfully cancelled."),A.current&&clearTimeout(A.current),E(!1)),p(!1),ze(),h(null),T.current=!0,S(),setTimeout(()=>{T.current=!1},100))},[ae,ze,S]),pt=u.useCallback(async()=>{const $="ChatProvider.handleNewSession:";if(console.log(`${$} Starting new session process...`),ze(),d&&x&&b&&!y){console.log(`${$} Cancelling current task ${x}`);try{const z={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:x}};De(`${r}/tasks/${x}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z),credentials:"include"})}catch(z){console.warn(`${$} Failed to cancel current task:`,z)}}A.current&&(clearTimeout(A.current),A.current=null),E(!1),console.log(`${$} Resetting session state - new session will be created when first message is sent`),s(""),l(t?[{parts:[{kind:"text",text:t}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}]:[]),f(""),p(!1),h(null),I(null),de(null),T.current=!1,Y.current=null,Z.current=0,console.log(`${$} Refreshing artifacts for new session...`),await S(),ae("New session started successfully."),console.log(`${$} New session setup complete - session will be created on first message.`)},[r,d,x,b,y,t,ae,S,ze]),rn=u.useCallback(async $=>{const B="ChatProvider.handleSwitchSession:";if(console.log(`${B} Switching to session ${$}...`),ze(),d&&x&&b&&!y){console.log(`${B} Cancelling current task ${x}`);try{const z={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:x}};await De(`${r}/tasks/${x}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z),credentials:"include"})}catch(z){console.warn(`${B} Failed to cancel current task:`,z)}}A.current&&(clearTimeout(A.current),A.current=null),E(!1);try{const Q=(await st($)).map(pe=>({parts:[{kind:"text",text:pe.message}],isUser:pe.sender_type==="user",isComplete:!0,role:pe.sender_type==="user"?"user":"agent",metadata:{sessionId:pe.session_id,messageId:pe.id,lastProcessedEventSequence:0}})),fe=await De(`${r}/sessions/${$}`);if(fe.ok){const pe=await fe.json();gt(pe.name)}s($),l(Q),f(""),p(!1),h(null),I(null),de(null),T.current=!1,Y.current=null,Z.current=0}catch(z){console.error(`${B} Failed to fetch session history:`,z),ae("Error switching session. Please try again.","error")}},[ze,d,x,b,y,r,ae,st]),vt=u.useCallback(async($,B)=>{try{const z=await De(`${r}/sessions/${$}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})});if(!z.ok){const Q=await z.json().catch(()=>({detail:"Failed to update session name"}));throw new Error(Q.detail||`HTTP error ${z.status}`)}ae("Session name updated successfully."),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(z){ae(`Error updating session name: ${z instanceof Error?z.message:"Unknown error"}`)}},[r,ae]),Pt=u.useCallback(async $=>{try{const B=await De(`${r}/sessions/${$}`,{method:"DELETE"});if(!B.ok){const z=await B.json().catch(()=>({detail:"Failed to delete session"}));throw new Error(z.detail||`HTTP error ${B.status}`)}ae("Session deleted successfully."),$===o&&pt(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(B){ae(`Error deleting session: ${B instanceof Error?B.message:"Unknown error"}`)}},[r,ae,pt,o]),on=u.useCallback($=>{ot($)},[]),Pe=u.useCallback(()=>{ot(null)},[]),mt=u.useCallback(async()=>{tt&&(await Pt(tt.id),ot(null))},[tt,Pt]),sn=u.useCallback(async()=>{if(!d&&!y||!x){ae("No active task to cancel.");return}if(y){ae("Cancellation already in progress.");return}ae(`Requesting cancellation for task ${x}...`),E(!0);try{const $={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:x}},B=await De(`${r}/tasks/${x}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(B.status===202)A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{ae(`Cancellation for task ${x} timed out. Allowing new input.`),E(!1),p(!1),ze(),h(null),A.current=null,l(z=>z.filter(Q=>!Q.isStatusBubble))},15e3);else{const z=await B.json().catch(()=>({detail:"Unknown cancellation error"}));ae(`Failed to request cancellation: ${z.detail||B.statusText}`),E(!1)}}catch($){ae(`Error sending cancellation request: ${$ instanceof Error?$.message:"Network error"}`),E(!1)}},[d,y,x,r,ae,ze]),Lt=u.useCallback(()=>{},[]),At=u.useCallback(()=>{d&&!T.current&&!G.current&&ae("Connection error with agent updates."),T.current||(p(!1),G.current||(ze(),h(null)),Y.current=null),l($=>$.filter(B=>!B.isStatusBubble).map((B,z,Q)=>z===Q.length-1&&!B.isUser?{...B,isComplete:!0}:B))},[ae,ze,d]),Gt=u.useCallback(async($,B,z)=>{console.log("handleSubmit: using sessionId",o),$.preventDefault();const Q=(z==null?void 0:z.trim())||c.trim(),fe=B||[];if(!Q&&fe.length===0||d||y||!b){b||ae("Please select an agent first."),y&&ae("Cannot send new message while a task is being cancelled.");return}ze(),T.current=!1,p(!0),h(null),Y.current=null,Z.current=0;const pe={role:"user",parts:[{kind:"text",text:Q}],isUser:!0,uploadedFiles:fe.length>0?fe:void 0,metadata:{messageId:`msg-${crypto.randomUUID()}`,sessionId:o,lastProcessedEventSequence:0}};Y.current="Thinking",l(we=>[...we,pe]),f("");try{const we=fe.map(async K=>{if(K.size<DE)return{kind:"file",file:{bytes:await OE(K),name:K.name,mimeType:K.type}};{const Ne=await Ct(K);return Ne?{kind:"file",file:{uri:Ne,name:K.name,mimeType:K.type}}:(ae(`Failed to upload large file: ${K.name}`,"error"),null)}}),he=(await Promise.all(we)).filter(K=>K!==null),be=[];if(Q&&be.push({kind:"text",text:Q}),be.push(...he),be.length===0)throw new Error("Cannot send an empty message.");console.log(`ChatProvider handleSubmit: Using sessionId for contextId: ${o}`);const ke={role:"user",parts:be,messageId:`msg-${crypto.randomUUID()}`,kind:"message",contextId:o,metadata:{agent_name:b}},le={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"message/stream",params:{message:ke}};console.log("ChatProvider handleSubmit: Sending POST to /message:stream");const ge=await De(`${r}/message:stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(le)});if(!ge.ok){const K=await ge.json().catch(()=>({detail:"Unknown error"}));throw console.error("ChatProvider handleSubmit: Error from /message:stream",ge.status,K),new Error(K.detail||`HTTP error ${ge.status}`)}const Ce=await ge.json(),U=Ce==null?void 0:Ce.result,C=U==null?void 0:U.id,F=U==null?void 0:U.contextId;if(console.log(`ChatProvider handleSubmit: Extracted responseSessionId: ${F}, current sessionId: ${o}`),console.log("ChatProvider handleSubmit: Full result object:",Ce),!C)throw console.error("ChatProvider handleSubmit: Backend did not return a valid taskId. Result:",Ce),new Error("Backend did not return a valid taskId.");if(console.log(`ChatProvider handleSubmit: Checking session update condition - responseSessionId: ${F}, sessionId: ${o}, different: ${F!==o}`),F&&F!==o){console.log(`ChatProvider handleSubmit: Updating sessionId from ${o} to ${F}`);const K=!o||o==="";s(F),l(Ne=>Ne.map(xe=>{var Ee,We;return((Ee=xe.metadata)==null?void 0:Ee.messageId)===((We=pe.metadata)==null?void 0:We.messageId)?{...xe,metadata:{...xe.metadata,sessionId:F}}:xe})),K&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}console.log(`ChatProvider handleSubmit: Received taskId ${C}. Setting currentTaskId and taskIdInSidePanel.`),h(C),I(C)}catch(we){console.error("ChatProvider handleSubmit: Catch block error",we),ae(`Error: ${we instanceof Error?we.message:"Unknown error"}`),p(!1),l(he=>he.filter(be=>!be.isStatusBubble)),h(null),T.current=!1,Y.current=null}},[c,d,y,o,b,r,ae,ze,Ct]);u.useEffect(()=>{if(x&&r){console.log(`ChatProvider Effect: currentTaskId is ${x}. Setting up EventSource.`);const $=wi(),B=`${r}/sse/subscribe/${x}${$?`?token=${$}`:""}`,z=new EventSource(B,{withCredentials:!0});return v.current=z,z.onopen=Lt,z.onerror=At,z.addEventListener("status_update",He),z.addEventListener("artifact_update",He),z.addEventListener("final_response",He),z.addEventListener("error",He),()=>{console.log(`ChatProvider Effect Cleanup: currentTaskId was ${x}. Closing EventSource.`),z.removeEventListener("status_update",He),z.removeEventListener("artifact_update",He),z.removeEventListener("final_response",He),z.removeEventListener("error",He),ze()}}else console.log("ChatProvider Effect: currentTaskId is null or apiPrefix missing. Ensuring EventSource is closed."),ze()},[x,r,He,Lt,At,ze]);const Vt={sessionId:o,setSessionId:s,sessionName:et,setSessionName:gt,messages:i,setMessages:l,userInput:c,setUserInput:f,isResponding:d,currentTaskId:x,isCancelling:y,latestStatusText:Y,agents:q,agentsLoading:D,agentsError:te,agentsRefetch:X,handleNewSession:pt,handleSwitchSession:rn,handleSubmit:Gt,handleCancel:sn,notifications:m,addNotification:ae,selectedAgentName:b,setSelectedAgentName:w,artifacts:N,artifactsLoading:M,artifactsRefetch:S,uploadArtifactFile:Ct,isSidePanelCollapsed:O,activeSidePanelTab:R,setIsSidePanelCollapsed:P,setActiveSidePanelTab:ee,openSidePanelTab:Rt,taskIdInSidePanel:k,setTaskIdInSidePanel:I,isDeleteModalOpen:L,artifactToDelete:j,openDeleteModal:Ht,closeDeleteModal:xt,confirmDelete:Wt,openSessionDeleteModal:on,closeSessionDeleteModal:Pe,confirmSessionDelete:mt,sessionToDelete:tt,isArtifactEditMode:_,setIsArtifactEditMode:V,selectedArtifactFilenames:J,setSelectedArtifactFilenames:ne,handleDeleteSelectedArtifacts:Et,confirmBatchDeleteArtifacts:Tt,isBatchDeleteModalOpen:ie,setIsBatchDeleteModalOpen:re,previewedArtifactAvailableVersions:Ie,currentPreviewedVersionNumber:Fe,previewFileContent:Ue,openArtifactForPreview:qe,navigateArtifactVersion:ft,openMessageAttachmentForPreview:Mt,previewArtifact:ue,setPreviewArtifact:de,updateSessionName:vt,deleteSession:Pt};return a.jsx(Hu.Provider,{value:Vt,children:e})},zE=({children:e})=>{const{frontend_use_authorization:t,configAuthLoginUrl:n}=nn(),{fetchCsrfToken:r,clearCsrfToken:o}=Ku(),[s,i]=u.useState(!1),[l,c]=u.useState(!0),[f,d]=u.useState(null);u.useEffect(()=>{let g=!0;const x=async()=>{if(!t){g&&(i(!0),c(!1));return}try{const v=await De("/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&&(d(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),d(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(Uu.Provider,{value:{isAuthenticated:s,useAuthorization:t,login:p,logout:m,userInfo:f},children:e})};function $E(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 BE=e=>new Promise(t=>setTimeout(t,e)),UE=async(e=5,t=50)=>{try{const n=await De("/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=$E("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 BE(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 HE({children:e}){const[t,n]=u.useState(null),r=u.useCallback(async()=>{if(t)return t;const i=await UE();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(Gu.Provider,{value:s,children:e})}const WE={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"}},GE={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"}},VE={"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 Ol(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 YE(e,t){const n={},r=GE[t];for(const[o,s]of Object.entries(r)){const i=Ol(e,s);n[`--${o}`]=i}for(const[o,s]of Object.entries(VE)){const i=Ol(e,s);n[`--color-${o}`]=i}return n}const Mo="sam-theme";function KE(e){var n,r,o,s,i,l,c,f,d,p,m,g,x,h,v,b,w,y,E,k,I,A,T,Y,Z,G,q,te,D,X,N,M,S,O,P,R,ee,L,H,j,W,_,V,J,ne,ie,re,ue,de,Ie,Re,Fe,je,Ue,Qe,et,gt,tt,ot,ae,st,Ct,jt,Ht,xt,Wt,Et,Tt,qe,ft,Mt,Rt,ze,He,pt,rn,vt,Pt,on,Pe,mt,sn,Lt,At,Gt,Vt,$,B,z,Q,fe,pe,we,he,be,ke,le,ge,Ce,U,C,F,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),(f=e.error)!=null&&f.w100&&(t["--color-error-w100"]=e.error.w100),(d=e.error)!=null&&d.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),(k=e.success)!=null&&k.w100&&(t["--color-success-w100"]=e.success.w100),(I=e.success)!=null&&I.w70&&(t["--color-success-w70"]=e.success.w70),(A=e.success)!=null&&A.w30&&(t["--color-success-w30"]=e.success.w30),(T=e.success)!=null&&T.w20&&(t["--color-success-w20"]=e.success.w20),(Y=e.success)!=null&&Y.w10&&(t["--color-success-w10"]=e.success.w10),(Z=e.stateLayer)!=null&&Z.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(G=e.stateLayer)!=null&&G.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(te=(q=e.accent)==null?void 0:q.n0)!=null&&te.wMain&&(t["--color-accent-n0-wMain"]=e.accent.n0.wMain),(X=(D=e.accent)==null?void 0:D.n0)!=null&&X.w100&&(t["--color-accent-n0-w100"]=e.accent.n0.w100),(M=(N=e.accent)==null?void 0:N.n0)!=null&&M.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(O=(S=e.accent)==null?void 0:S.n0)!=null&&O.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),(R=(P=e.accent)==null?void 0:P.n1)!=null&&R.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(L=(ee=e.accent)==null?void 0:ee.n1)!=null&&L.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(j=(H=e.accent)==null?void 0:H.n1)!=null&&j.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),(_=(W=e.accent)==null?void 0:W.n1)!=null&&_.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(J=(V=e.accent)==null?void 0:V.n1)!=null&&J.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(ie=(ne=e.accent)==null?void 0:ne.n1)!=null&&ie.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(ue=(re=e.accent)==null?void 0:re.n2)!=null&&ue.wMain&&(t["--color-accent-n2-wMain"]=e.accent.n2.wMain),(Ie=(de=e.accent)==null?void 0:de.n2)!=null&&Ie.w100&&(t["--color-accent-n2-w100"]=e.accent.n2.w100),(Fe=(Re=e.accent)==null?void 0:Re.n2)!=null&&Fe.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(Ue=(je=e.accent)==null?void 0:je.n2)!=null&&Ue.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(et=(Qe=e.accent)==null?void 0:Qe.n2)!=null&&et.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(tt=(gt=e.accent)==null?void 0:gt.n3)!=null&&tt.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(ae=(ot=e.accent)==null?void 0:ot.n3)!=null&&ae.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(Ct=(st=e.accent)==null?void 0:st.n3)!=null&&Ct.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(Ht=(jt=e.accent)==null?void 0:jt.n3)!=null&&Ht.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(Wt=(xt=e.accent)==null?void 0:xt.n4)!=null&&Wt.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(Tt=(Et=e.accent)==null?void 0:Et.n4)!=null&&Tt.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(ft=(qe=e.accent)==null?void 0:qe.n4)!=null&&ft.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(Rt=(Mt=e.accent)==null?void 0:Mt.n5)!=null&&Rt.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(He=(ze=e.accent)==null?void 0:ze.n5)!=null&&He.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(rn=(pt=e.accent)==null?void 0:pt.n5)!=null&&rn.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(Pt=(vt=e.accent)==null?void 0:vt.n5)!=null&&Pt.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(Pe=(on=e.accent)==null?void 0:on.n6)!=null&&Pe.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(sn=(mt=e.accent)==null?void 0:mt.n6)!=null&&sn.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(At=(Lt=e.accent)==null?void 0:Lt.n6)!=null&&At.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),(Vt=(Gt=e.accent)==null?void 0:Gt.n7)!=null&&Vt.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),(B=($=e.accent)==null?void 0:$.n7)!=null&&B.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),(Q=(z=e.accent)==null?void 0:z.n7)!=null&&Q.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(pe=(fe=e.accent)==null?void 0:fe.n8)!=null&&pe.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),(he=(we=e.accent)==null?void 0:we.n8)!=null&&he.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(ke=(be=e.accent)==null?void 0:be.n8)!=null&&ke.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),(ge=(le=e.accent)==null?void 0:le.n9)!=null&&ge.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(Ce=e.learning)!=null&&Ce.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(U=e.learning)!=null&&U.w100&&(t["--color-learning-w100"]=e.learning.w100),(C=e.learning)!=null&&C.w90&&(t["--color-learning-w90"]=e.learning.w90),(F=e.learning)!=null&&F.w20&&(t["--color-learning-w20"]=e.learning.w20),(K=e.learning)!=null&&K.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function qE(e,t="light"){const n={};if(e){const o=KE(e);Object.assign(n,o)}const r=YE(e,t);return Object.assign(n,r),n}function XE(){const e=localStorage.getItem(Mo);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ZE(e,t){const n=qE(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(Mo,t)})}const JE=({children:e})=>{const t=u.useMemo(()=>WE,[]),[n,r]=u.useState(()=>XE()),o=u.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const s=n==="light"?"dark":"light";r(s),localStorage.setItem(Mo,s)}}),[n]);return u.useEffect(()=>{if(!(localStorage.getItem(Mo)!==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"),ZE(t,n)},[n,t]),a.jsx(Yu.Provider,{value:o,children:e})};function QE(){const[e,t]=u.useState("chat"),{isAuthenticated:n,login:r,useAuthorization:o}=xw();if(vw(),o&&!n)return a.jsx("div",{className:"bg-background flex h-screen items-center justify-center",children:a.jsx(ve,{onClick:r,children:"Login"})});const s=c=>{const f=Pl.find(d=>d.id===c)||Ll.find(d=>d.id===c);f!=null&&f.onClick&&c!=="settings"?f.onClick():c!=="settings"&&t(c)},i=()=>{t("chat")},l=()=>{switch(e){case"chat":return a.jsx(ME,{});case"agentMesh":return a.jsx(_E,{})}};return a.jsxs("div",{className:"relative flex h-screen",children:[a.jsx(yE,{items:Pl,bottomItems:Ll,activeItem:e,onItemChange:s,onHeaderClick:i}),a.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:l()}),a.jsx(eb,{})]})}function e1(){return a.jsx(JE,{children:a.jsx(HE,{children:a.jsx(PE,{children:a.jsx(zE,{children:a.jsx(FE,{children:a.jsx(LE,{children:a.jsx(QE,{})})})})})})})}kp.createRoot(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(e1,{})}));
|