kifaru 1.0.188 → 1.0.189

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.
@@ -1,9 +1,9 @@
1
- import{i as e,n as t,o as n,r,t as i}from"./react-dom.B--7n7g5.js";import{_ as a,b as o,c as s,d as c,f as l,g as u,h as d,l as f,m as p,n as m,p as h,r as g,t as _,u as v,v as y,y as b}from"./label.BKu82TGK.js";var x=o(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),S=o(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),C=o(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),w=o(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),T=o(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),E=o(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),D=o(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),O=o(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),k=o(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),A=o(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),j=o(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),M=o(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ee=o(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),te=o(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),ne=o(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),re=o(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),ie=o(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ae=o(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),oe=o(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),se=o(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ce=o(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),le=o(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),ue=o(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),de=o(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),fe=o(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),pe=o(`key`,[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]),me=o(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),he=o(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),ge=o(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),_e=o(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),ve=o(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),ye=o(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),be=o(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),xe=o(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Se=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ce=o(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),we=o(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Te=o(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ee=o(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),De=o(`shield-question-mark`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Oe=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ke=o(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Ae=o(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),je=o(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),Me=o(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),Ne=o(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Pe=o(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Fe=o(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),Ie=o(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Le=o(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),N=n(t(),1),P=u(),Re=Object.defineProperty,ze=(e,t)=>Re(e,`name`,{value:t,configurable:!0}),Be=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`}),Ve=N.forwardRef(ze(function(e,t){return(0,P.jsx)(f.span,{...e,ref:t,style:{...Be,...e.style}})},`VisuallyHidden`)),He=Object.defineProperty,Ue=(e,t)=>He(e,`name`,{value:t,configurable:!0});function We(e,t){let n=N.createContext(t);n.displayName=e+`Context`;let r=Ue(e=>{let{children:t,...r}=e,i=N.useMemo(()=>r,Object.values(r));return(0,P.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=N.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return Ue(i,`useContext`),[r,i]}Ue(We,`createContext`);function Ge(e,t=[]){let n=[];function r(t,r){let i=N.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=Ue(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=N.useMemo(()=>o,Object.values(o));return(0,P.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=N.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return Ue(s,`useContext`),[o,s]}Ue(r,`createContext`);let i=Ue(()=>{let t=n.map(e=>N.createContext(e));return Ue(function(n){let r=n?.[e]||t;return N.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Ke(i,...t)]}Ue(Ge,`createContextScope`);function Ke(...e){let t=e[0];if(e.length===1)return t;let n=Ue(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return Ue(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return N.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}Ue(Ke,`composeContextScopes`);var qe=Object.defineProperty,Je=(e,t)=>qe(e,`name`,{value:t,configurable:!0});function Ye(e){let t=e+`CollectionProvider`,[n,r]=Ge(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Je(e=>{let{scope:t,children:n}=e,r=N.useRef(null),a=N.useRef(new Map).current;return(0,P.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=h(s),l=N.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=d(t,i.collectionRef);return(0,P.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=h(u),m=N.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=N.useRef(null),s=d(t,o),c=a(u,n);return N.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,P.jsx)(p,{[f]:``,ref:s,children:r})});m.displayName=u;function g(t){let n=a(e+`CollectionConsumer`,t);return N.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return Je(g,`useCollection`),[{Provider:o,Slot:l,ItemSlot:m},g,r]}Je(Ye,`createCollection`);var Xe=new WeakMap,Ze=class e extends Map{static{Je(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Xe.set(this,!0)}set(e,t){return Xe.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=et(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=Qe(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Qe(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Qe(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function Qe(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=$e(e,t);return n===-1?void 0:e[n]}Je(Qe,`at`);function $e(e,t){let n=e.length,r=et(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Je($e,`toSafeIndex`);function et(e){return e!==e||e===0?0:Math.trunc(e)}Je(et,`toSafeInteger`);function tt(e){let t=e+`CollectionProvider`,[n,r]=Ge(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ze,setItemMap:Je(()=>void 0,`setItemMap`)}),o=Je(({state:e,...t})=>e?(0,P.jsx)(c,{...t,state:e}):(0,P.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=Je(e=>{let t=_();return(0,P.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=Je(e=>{let{scope:t,children:n,state:r}=e,a=N.useRef(null),[o,s]=N.useState(null),c=d(a,s),[l,u]=r;return N.useEffect(()=>{if(!o)return;let e=at(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,P.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=h(l),f=N.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=d(t,i.collectionRef);return(0,P.jsx)(u,{ref:o,children:r})});f.displayName=l;let p=e+`CollectionItemSlot`,m=h(p),g=N.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=N.useRef(null),[s,c]=N.useState(null),l=d(t,o,c),{setItemMap:u}=a(p,n),f=N.useRef(i);nt(f.current,i)||(f.current=i);let h=f.current;return N.useEffect(()=>{let e=h;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(it):(t.set(s,{...e,element:s}),t.toSorted(it)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Ze(e)))}},[s,h,u]),(0,P.jsx)(m,{"data-radix-collection-item":``,ref:l,children:r})});g.displayName=p;function _(){return N.useState(new Ze)}Je(_,`useInitCollection`);function v(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Je(v,`useCollection`),[{Provider:o,Slot:f,ItemSlot:g},{createCollectionScope:r,useCollection:v,useInitCollection:_}]}Je(tt,`createCollection`);function nt(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}Je(nt,`shallowEqual`);function rt(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Je(rt,`isElementPreceding`);function it(e,t){return!e[1].element||!t[1].element?0:rt(e[1].element,t[1].element)?-1:1}Je(it,`sortByDocumentPosition`);function at(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Je(at,`getChildListObserver`);var ot=Object.defineProperty,st=(e,t)=>ot(e,`name`,{value:t,configurable:!0}),ct=!!(typeof window<`u`&&window.document&&window.document.createElement);function F(e,t,{checkForDefaultPrevented:n=!0}={}){return st(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}st(F,`composeEventHandlers`);function lt(e){if(!ct)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}st(lt,`getOwnerWindow`);function ut(e){if(!ct)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}st(ut,`getOwnerDocument`);function dt(e,t=!1){let{activeElement:n}=ut(e);if(!n?.nodeName)return null;if(ft(n)&&n.contentDocument)return dt(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=ut(n).getElementById(e);if(t)return t}}return n}st(dt,`getActiveElement`);function ft(e){return e.tagName===`IFRAME`}st(ft,`isFrame`);var pt=globalThis?.document?N.useLayoutEffect:()=>{},mt=Object.defineProperty,ht=(e,t)=>mt(e,`name`,{value:t,configurable:!0}),gt=N.useEffectEvent,_t=N.useInsertionEffect;function vt(e){if(typeof gt==`function`)return gt(e);let t=N.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof _t==`function`?_t(()=>{t.current=e}):pt(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}ht(vt,`useEffectEvent`);var yt=Object.defineProperty,bt=(e,t)=>yt(e,`name`,{value:t,configurable:!0}),xt=N.useInsertionEffect||pt;function St({prop:e,defaultProp:t,onChange:n=bt(()=>{},`onChange`),caller:r}){let[i,a,o]=Ct({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,N.useCallback(t=>{if(s){let n=wt(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}bt(St,`useControllableState`);function Ct({defaultProp:e,onChange:t}){let[n,r]=N.useState(e),i=N.useRef(n),a=N.useRef(t);return xt(()=>{a.current=t},[t]),N.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}bt(Ct,`useUncontrolledState`);function wt(e){return typeof e==`function`}bt(wt,`isFunction`);var Tt=Symbol(`RADIX:SYNC_STATE`);function Et(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=vt(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=N.useReducer((t,n)=>{if(n.type===Tt)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=N.useRef(p);N.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=N.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return N.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Tt,state:i})},[i,d.state,c]),[h,f]}bt(Et,`useControllableStateReducer`);var Dt=Object.defineProperty,Ot=(e,t)=>Dt(e,`name`,{value:t,configurable:!0});function kt(e,t){return N.useReducer((e,n)=>t[e][n]??e,e)}Ot(kt,`useStateMachine`);var At=Ot(e=>{let{present:t,children:n}=e,r=jt(t),i=typeof n==`function`?n({present:r.isPresent}):N.Children.only(n),a=Nt(r.ref,Ft(i));return typeof n==`function`||r.isPresent?N.cloneElement(i,{ref:a}):null},`Presence`);function jt(e){let[t,n]=N.useState(),r=N.useRef(null),i=N.useRef(e),a=N.useRef(`none`),o=N.useRef(void 0),[s,c]=kt(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return N.useEffect(()=>{s===`mounted`?(a.current=o.current??Pt(r.current),o.current=void 0):a.current=`none`},[s]),pt(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Pt(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),pt(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Ot(a=>{let o=Pt(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=Ot(e=>{e.target===t&&(a.current=Pt(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:N.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Pt(t)}else r.current=null;n(e)},[])}}Ot(jt,`usePresence`);function Mt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Ot(Mt,`setRef`);function Nt(...e){let t=N.useRef(e);return t.current=e,N.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Mt(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Mt(n[e],null)}}},[])}Ot(Nt,`useStableComposedRefs`);function Pt(e){return e?.animationName||`none`}Ot(Pt,`getAnimationName`);function Ft(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Ot(Ft,`getElementRef`);var It=Object.defineProperty,Lt=(e,t)=>It(e,`name`,{value:t,configurable:!0}),Rt=N.useId||(()=>void 0),zt=0;function Bt(e){let[t,n]=N.useState(Rt());return pt(()=>{e||n(e=>e??String(zt++))},[e]),e||(t?`radix-${t}`:``)}Lt(Bt,`useId`);var Vt=Object.defineProperty,Ht=(e,t)=>Vt(e,`name`,{value:t,configurable:!0}),Ut=`Collapsible`,[Wt,Gt]=Ge(Ut),[Kt,qt]=Wt(Ut),Jt=N.forwardRef(Ht(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=St({prop:r,defaultProp:i??!1,onChange:o,caller:Ut});return(0,P.jsx)(Kt,{scope:n,disabled:a,contentId:Bt(),open:c,onOpenToggle:N.useCallback(()=>l(e=>!e),[l]),children:(0,P.jsx)(f.div,{"data-state":en(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),Yt=`CollapsibleTrigger`,Xt=N.forwardRef(Ht(function(e,t){let{__scopeCollapsible:n,...r}=e,i=qt(Yt,n);return(0,P.jsx)(f.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":en(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:F(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),Zt=`CollapsibleContent`,Qt=N.forwardRef(Ht(function(e,t){let{forceMount:n,...r}=e,i=qt(Zt,e.__scopeCollapsible);return(0,P.jsx)(At,{present:n||i.open,children:({present:e})=>(0,P.jsx)($t,{...r,ref:t,present:e})})},`CollapsibleContent`)),$t=N.forwardRef(Ht(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=qt(Zt,n),[s,c]=N.useState(r),l=N.useRef(null),u=d(t,l),p=N.useRef(0),m=p.current,h=N.useRef(0),g=h.current,_=o.open||s,v=N.useRef(_),y=N.useRef(void 0);return N.useEffect(()=>{let e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),pt(()=>{let e=l.current;if(e){y.current=y.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();p.current=t.height,h.current=t.width,v.current||(e.style.transitionDuration=y.current.transitionDuration,e.style.animationName=y.current.animationName),c(r)}},[o.open,r]),(0,P.jsx)(f.div,{"data-state":en(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!_,...a,ref:u,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:_&&i})},`CollapsibleContentImpl`));function en(e){return e?`open`:`closed`}Ht(en,`getState`);var tn=Jt,nn=Object.defineProperty,rn=(e,t)=>nn(e,`name`,{value:t,configurable:!0}),an=N.createContext(void 0);function on(e){let t=N.useContext(an);return e||t||`ltr`}rn(on,`useDirection`);var sn=Object.defineProperty,cn=(e,t)=>sn(e,`name`,{value:t,configurable:!0});function ln(e){let t=N.useRef(e);return N.useEffect(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}cn(ln,`useCallbackRef`);var un=Object.defineProperty,dn=(e,t)=>un(e,`name`,{value:t,configurable:!0}),fn=`dismissableLayer.update`,pn=`dismissableLayer.pointerDownOutside`,mn=`dismissableLayer.focusOutside`,hn,gn=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),_n=N.forwardRef(dn(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=N.useContext(gn),[p,m]=N.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=N.useState({}),_=d(t,m),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=y?v.indexOf(y):-1,x=p?v.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,C=x>=b,w=N.useRef(!1),T=bn(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:w,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:N.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return C&&!t},[u.branches,C])}),E=xn(e=>{if(r&&w.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},h),D=p?x===v.length-1:!1,O=ln(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return N.useEffect(()=>{if(D)return h.addEventListener(`keydown`,O,{capture:!0}),()=>h.removeEventListener(`keydown`,O,{capture:!0})},[h,D,O]),N.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(hn=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),Sn(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=hn))}},[p,h,n,u]),N.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),Sn())},[p,u]),N.useEffect(()=>{let e=dn(()=>g({}),`handleUpdate`);return document.addEventListener(fn,e),()=>document.removeEventListener(fn,e)},[]),(0,P.jsx)(f.div,{...l,ref:_,style:{pointerEvents:S?C?`auto`:`none`:void 0,...e.style},onFocusCapture:F(e.onFocusCapture,E.onFocusCapture),onBlurCapture:F(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:F(e.onPointerDownCapture,T.onPointerDownCapture)})},`DismissableLayer`));function vn(){let e=N.useContext(gn),[t,n]=N.useState(null);return N.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}dn(vn,`useDismissableLayerSurface`);var yn=dn(()=>!0,`IS_TRUE`);function bn(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=yn}=t,s=ln(e),c=N.useRef(!1),l=N.useRef(!1),u=N.useRef(new Map),d=N.useRef(()=>{});return N.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}dn(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}dn(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}dn(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}dn(p,`handleInteractionBubble`);let m=dn(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Cn(pn,s,p,{discrete:!0})};if(dn(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:dn(()=>c.current=!0,`onPointerDownCapture`)}}dn(bn,`usePointerDownOutside`);function xn(e,t=globalThis?.document){let n=ln(e),r=N.useRef(!1);return N.useEffect(()=>{let e=dn(e=>{e.target&&!r.current&&Cn(mn,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:dn(()=>r.current=!0,`onFocusCapture`),onBlurCapture:dn(()=>r.current=!1,`onBlurCapture`)}}dn(xn,`useFocusOutside`);function Sn(){let e=new CustomEvent(fn);document.dispatchEvent(e)}dn(Sn,`dispatchUpdate`);function Cn(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?v(i,a):i.dispatchEvent(a)}dn(Cn,`handleAndDispatchCustomEvent`);var wn=Object.defineProperty,Tn=(e,t)=>wn(e,`name`,{value:t,configurable:!0}),En=`focusScope.autoFocusOnMount`,Dn=`focusScope.autoFocusOnUnmount`,On={bubbles:!1,cancelable:!0},kn=N.forwardRef(Tn(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=N.useState(null),l=ln(i),u=ln(a),p=N.useRef(null),m=d(t,c),h=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(r){let e=function(e){if(h.paused||!s)return;let t=e.target;s.contains(t)?p.current=t:In(p.current,{select:!0})},t=function(e){if(h.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||In(p.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&In(s)};Tn(e,`handleFocusIn`),Tn(t,`handleFocusOut`),Tn(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,h.paused]),N.useEffect(()=>{if(s){Ln.add(h);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(En,On);s.addEventListener(En,l),s.dispatchEvent(t),t.defaultPrevented||(An(Bn(Mn(s)),{select:!0}),document.activeElement===e&&In(s))}return()=>{s.removeEventListener(En,l),setTimeout(()=>{let t=new CustomEvent(Dn,On);s.addEventListener(Dn,u),s.dispatchEvent(t),t.defaultPrevented||In(e??document.body,{select:!0}),s.removeEventListener(Dn,u),Ln.remove(h)},0)}}},[s,l,u,h]);let g=N.useCallback(e=>{if(!n&&!r||h.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=jn(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&In(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&In(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,h.paused]);return(0,P.jsx)(f.div,{tabIndex:-1,...o,ref:m,onKeyDown:g})},`FocusScope`));function An(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(In(r,{select:t}),document.activeElement!==n)return}Tn(An,`focusFirst`);function jn(e){let t=Mn(e);return[Nn(t,e),Nn(t.reverse(),e)]}Tn(jn,`getTabbableEdges`);function Mn(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Tn(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}Tn(Mn,`getTabbableCandidates`);function Nn(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Pn(r,{upTo:t})))return r}Tn(Nn,`findVisible`);function Pn(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}Tn(Pn,`isHidden`);function Fn(e){return e instanceof HTMLInputElement&&`select`in e}Tn(Fn,`isSelectableInput`);function In(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Fn(e)&&t&&e.select()}}Tn(In,`focus`);var Ln=Rn();function Rn(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=zn(e,t),e.unshift(t)},remove(t){e=zn(e,t),e[0]?.resume()}}}Tn(Rn,`createFocusScopesStack`);function zn(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Tn(zn,`arrayRemove`);function Bn(e){return e.filter(e=>e.tagName!==`A`)}Tn(Bn,`removeLinks`);var Vn=n(i(),1),Hn=Object.defineProperty,Un=N.forwardRef(((e,t)=>Hn(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=N.useState(!1);pt(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Vn.createPortal((0,P.jsx)(f.div,{...r,ref:t}),o):null},`Portal`)),Wn=Object.defineProperty,Gn=(e,t)=>Wn(e,`name`,{value:t,configurable:!0}),Kn=0,qn=null;function Jn(e){return Yn(),e.children}Gn(Jn,`FocusGuards`);function Yn(){N.useEffect(()=>{qn||={start:Xn(),end:Xn()};let{start:e,end:t}=qn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Kn++,()=>{Kn===1&&(qn?.start.remove(),qn?.end.remove(),qn=null),Kn=Math.max(0,Kn-1)}},[])}Gn(Yn,`useFocusGuards`);function Xn(){let 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}Gn(Xn,`createFocusGuard`);var Zn=function(){return Zn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Zn.apply(this,arguments)};function Qn(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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function $n(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var er=`right-scroll-bar-position`,tr=`width-before-scroll-bar`,nr=`with-scroll-bars-hidden`,rr=`--removed-body-scroll-bar-size`;function ir(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ar(e,t){var n=(0,N.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var or=typeof window<`u`?N.useLayoutEffect:N.useEffect,sr=new WeakMap;function cr(e,t){var n=ar(t||null,function(t){return e.forEach(function(e){return ir(e,t)})});return or(function(){var t=sr.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||ir(e,null)}),i.forEach(function(e){r.has(e)||ir(e,a)})}sr.set(n,e)},[e]),n}function lr(e){return e}function ur(e,t){t===void 0&&(t=lr);var n=[],r=!1;return{read:function(){if(r)throw 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(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function dr(e){e===void 0&&(e={});var t=ur(null);return t.options=Zn({async:!0,ssr:!1},e),t}var fr=function(e){var t=e.sideCar,n=Qn(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return N.createElement(r,Zn({},n))};fr.isSideCarExport=!0;function pr(e,t){return e.useMedium(t),fr}var mr=dr(),hr=function(){},gr=N.forwardRef(function(e,t){var n=N.useRef(null),r=N.useState({onScrollCapture:hr,onWheelCapture:hr,onTouchMoveCapture:hr}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Qn(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=cr([n,t]),C=Zn(Zn({},b),i);return N.createElement(N.Fragment,null,u&&N.createElement(x,{sideCar:mr,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?N.cloneElement(N.Children.only(s),Zn(Zn({},C),{ref:S})):N.createElement(v,Zn({},C,{className:c,ref:S}),s))});gr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gr.classNames={fullWidth:tr,zeroRight:er};var _r=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function vr(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=_r();return t&&e.setAttribute(`nonce`,t),e}function yr(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function br(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var xr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vr())&&(yr(t,n),br(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Sr=function(){var e=xr();return function(t,n){N.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Cr=function(){var e=Sr();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},wr={left:0,top:0,right:0,gap:0},Tr=function(e){return parseInt(e||``,10)||0},Er=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Tr(n),Tr(r),Tr(i)]},Dr=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return wr;var t=Er(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])}},Or=Cr(),kr=`data-scroll-locked`,Ar=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
- .${nr} {
1
+ import{i as e,n as t,o as n,r,t as i}from"./react-dom.B--7n7g5.js";import{_ as a,b as o,c as s,d as c,f as l,g as u,h as d,l as f,m as p,n as m,p as h,r as g,t as _,u as v,v as y,y as b}from"./label.BKu82TGK.js";var x=o(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),S=o(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),C=o(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),w=o(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),T=o(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),E=o(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),D=o(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),O=o(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),k=o(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),A=o(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),j=o(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),M=o(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ee=o(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),te=o(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),ne=o(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),re=o(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),ie=o(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ae=o(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),oe=o(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),se=o(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ce=o(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),le=o(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ue=o(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),de=o(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),fe=o(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),pe=o(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),me=o(`key`,[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]),he=o(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),ge=o(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),_e=o(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),ve=o(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),ye=o(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),be=o(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),xe=o(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Se=o(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Ce=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),we=o(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Te=o(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Ee=o(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),De=o(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Oe=o(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ke=o(`shield-question-mark`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ae=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),je=o(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Me=o(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Ne=o(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),Pe=o(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),Fe=o(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Ie=o(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Le=o(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Re=o(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),ze=o(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Be=o(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),N=n(t(),1),P=u(),Ve=Object.defineProperty,He=(e,t)=>Ve(e,`name`,{value:t,configurable:!0}),Ue=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`}),We=N.forwardRef(He(function(e,t){return(0,P.jsx)(f.span,{...e,ref:t,style:{...Ue,...e.style}})},`VisuallyHidden`)),Ge=Object.defineProperty,Ke=(e,t)=>Ge(e,`name`,{value:t,configurable:!0});function qe(e,t){let n=N.createContext(t);n.displayName=e+`Context`;let r=Ke(e=>{let{children:t,...r}=e,i=N.useMemo(()=>r,Object.values(r));return(0,P.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=N.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return Ke(i,`useContext`),[r,i]}Ke(qe,`createContext`);function Je(e,t=[]){let n=[];function r(t,r){let i=N.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=Ke(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=N.useMemo(()=>o,Object.values(o));return(0,P.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=N.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return Ke(s,`useContext`),[o,s]}Ke(r,`createContext`);let i=Ke(()=>{let t=n.map(e=>N.createContext(e));return Ke(function(n){let r=n?.[e]||t;return N.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Ye(i,...t)]}Ke(Je,`createContextScope`);function Ye(...e){let t=e[0];if(e.length===1)return t;let n=Ke(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return Ke(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return N.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}Ke(Ye,`composeContextScopes`);var Xe=Object.defineProperty,Ze=(e,t)=>Xe(e,`name`,{value:t,configurable:!0});function Qe(e){let t=e+`CollectionProvider`,[n,r]=Je(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Ze(e=>{let{scope:t,children:n}=e,r=N.useRef(null),a=N.useRef(new Map).current;return(0,P.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=h(s),l=N.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=d(t,i.collectionRef);return(0,P.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=h(u),m=N.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=N.useRef(null),s=d(t,o),c=a(u,n);return N.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,P.jsx)(p,{[f]:``,ref:s,children:r})});m.displayName=u;function g(t){let n=a(e+`CollectionConsumer`,t);return N.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return Ze(g,`useCollection`),[{Provider:o,Slot:l,ItemSlot:m},g,r]}Ze(Qe,`createCollection`);var $e=new WeakMap,et=class e extends Map{static{Ze(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],$e.set(this,!0)}set(e,t){return $e.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=rt(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=tt(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=tt(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return tt(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function tt(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=nt(e,t);return n===-1?void 0:e[n]}Ze(tt,`at`);function nt(e,t){let n=e.length,r=rt(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Ze(nt,`toSafeIndex`);function rt(e){return e!==e||e===0?0:Math.trunc(e)}Ze(rt,`toSafeInteger`);function it(e){let t=e+`CollectionProvider`,[n,r]=Je(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new et,setItemMap:Ze(()=>void 0,`setItemMap`)}),o=Ze(({state:e,...t})=>e?(0,P.jsx)(c,{...t,state:e}):(0,P.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=Ze(e=>{let t=_();return(0,P.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=Ze(e=>{let{scope:t,children:n,state:r}=e,a=N.useRef(null),[o,s]=N.useState(null),c=d(a,s),[l,u]=r;return N.useEffect(()=>{if(!o)return;let e=ct(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,P.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=h(l),f=N.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=d(t,i.collectionRef);return(0,P.jsx)(u,{ref:o,children:r})});f.displayName=l;let p=e+`CollectionItemSlot`,m=h(p),g=N.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=N.useRef(null),[s,c]=N.useState(null),l=d(t,o,c),{setItemMap:u}=a(p,n),f=N.useRef(i);at(f.current,i)||(f.current=i);let h=f.current;return N.useEffect(()=>{let e=h;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(st):(t.set(s,{...e,element:s}),t.toSorted(st)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new et(e)))}},[s,h,u]),(0,P.jsx)(m,{"data-radix-collection-item":``,ref:l,children:r})});g.displayName=p;function _(){return N.useState(new et)}Ze(_,`useInitCollection`);function v(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Ze(v,`useCollection`),[{Provider:o,Slot:f,ItemSlot:g},{createCollectionScope:r,useCollection:v,useInitCollection:_}]}Ze(it,`createCollection`);function at(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}Ze(at,`shallowEqual`);function ot(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ze(ot,`isElementPreceding`);function st(e,t){return!e[1].element||!t[1].element?0:ot(e[1].element,t[1].element)?-1:1}Ze(st,`sortByDocumentPosition`);function ct(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Ze(ct,`getChildListObserver`);var lt=Object.defineProperty,ut=(e,t)=>lt(e,`name`,{value:t,configurable:!0}),dt=!!(typeof window<`u`&&window.document&&window.document.createElement);function F(e,t,{checkForDefaultPrevented:n=!0}={}){return ut(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}ut(F,`composeEventHandlers`);function ft(e){if(!dt)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}ut(ft,`getOwnerWindow`);function pt(e){if(!dt)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}ut(pt,`getOwnerDocument`);function mt(e,t=!1){let{activeElement:n}=pt(e);if(!n?.nodeName)return null;if(ht(n)&&n.contentDocument)return mt(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=pt(n).getElementById(e);if(t)return t}}return n}ut(mt,`getActiveElement`);function ht(e){return e.tagName===`IFRAME`}ut(ht,`isFrame`);var gt=globalThis?.document?N.useLayoutEffect:()=>{},_t=Object.defineProperty,vt=(e,t)=>_t(e,`name`,{value:t,configurable:!0}),yt=N.useEffectEvent,bt=N.useInsertionEffect;function xt(e){if(typeof yt==`function`)return yt(e);let t=N.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof bt==`function`?bt(()=>{t.current=e}):gt(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}vt(xt,`useEffectEvent`);var St=Object.defineProperty,Ct=(e,t)=>St(e,`name`,{value:t,configurable:!0}),wt=N.useInsertionEffect||gt;function Tt({prop:e,defaultProp:t,onChange:n=Ct(()=>{},`onChange`),caller:r}){let[i,a,o]=Et({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,N.useCallback(t=>{if(s){let n=Dt(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Ct(Tt,`useControllableState`);function Et({defaultProp:e,onChange:t}){let[n,r]=N.useState(e),i=N.useRef(n),a=N.useRef(t);return wt(()=>{a.current=t},[t]),N.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Ct(Et,`useUncontrolledState`);function Dt(e){return typeof e==`function`}Ct(Dt,`isFunction`);var Ot=Symbol(`RADIX:SYNC_STATE`);function kt(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=xt(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=N.useReducer((t,n)=>{if(n.type===Ot)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=N.useRef(p);N.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=N.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return N.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Ot,state:i})},[i,d.state,c]),[h,f]}Ct(kt,`useControllableStateReducer`);var At=Object.defineProperty,jt=(e,t)=>At(e,`name`,{value:t,configurable:!0});function Mt(e,t){return N.useReducer((e,n)=>t[e][n]??e,e)}jt(Mt,`useStateMachine`);var Nt=jt(e=>{let{present:t,children:n}=e,r=Pt(t),i=typeof n==`function`?n({present:r.isPresent}):N.Children.only(n),a=It(r.ref,Rt(i));return typeof n==`function`||r.isPresent?N.cloneElement(i,{ref:a}):null},`Presence`);function Pt(e){let[t,n]=N.useState(),r=N.useRef(null),i=N.useRef(e),a=N.useRef(`none`),o=N.useRef(void 0),[s,c]=Mt(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return N.useEffect(()=>{s===`mounted`?(a.current=o.current??Lt(r.current),o.current=void 0):a.current=`none`},[s]),gt(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Lt(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),gt(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=jt(a=>{let o=Lt(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=jt(e=>{e.target===t&&(a.current=Lt(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:N.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Lt(t)}else r.current=null;n(e)},[])}}jt(Pt,`usePresence`);function Ft(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}jt(Ft,`setRef`);function It(...e){let t=N.useRef(e);return t.current=e,N.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Ft(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Ft(n[e],null)}}},[])}jt(It,`useStableComposedRefs`);function Lt(e){return e?.animationName||`none`}jt(Lt,`getAnimationName`);function Rt(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}jt(Rt,`getElementRef`);var zt=Object.defineProperty,Bt=(e,t)=>zt(e,`name`,{value:t,configurable:!0}),Vt=N.useId||(()=>void 0),Ht=0;function Ut(e){let[t,n]=N.useState(Vt());return gt(()=>{e||n(e=>e??String(Ht++))},[e]),e||(t?`radix-${t}`:``)}Bt(Ut,`useId`);var Wt=Object.defineProperty,Gt=(e,t)=>Wt(e,`name`,{value:t,configurable:!0}),Kt=`Collapsible`,[qt,Jt]=Je(Kt),[Yt,Xt]=qt(Kt),Zt=N.forwardRef(Gt(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=Tt({prop:r,defaultProp:i??!1,onChange:o,caller:Kt});return(0,P.jsx)(Yt,{scope:n,disabled:a,contentId:Ut(),open:c,onOpenToggle:N.useCallback(()=>l(e=>!e),[l]),children:(0,P.jsx)(f.div,{"data-state":rn(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),Qt=`CollapsibleTrigger`,$t=N.forwardRef(Gt(function(e,t){let{__scopeCollapsible:n,...r}=e,i=Xt(Qt,n);return(0,P.jsx)(f.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":rn(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:F(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),en=`CollapsibleContent`,tn=N.forwardRef(Gt(function(e,t){let{forceMount:n,...r}=e,i=Xt(en,e.__scopeCollapsible);return(0,P.jsx)(Nt,{present:n||i.open,children:({present:e})=>(0,P.jsx)(nn,{...r,ref:t,present:e})})},`CollapsibleContent`)),nn=N.forwardRef(Gt(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Xt(en,n),[s,c]=N.useState(r),l=N.useRef(null),u=d(t,l),p=N.useRef(0),m=p.current,h=N.useRef(0),g=h.current,_=o.open||s,v=N.useRef(_),y=N.useRef(void 0);return N.useEffect(()=>{let e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),gt(()=>{let e=l.current;if(e){y.current=y.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();p.current=t.height,h.current=t.width,v.current||(e.style.transitionDuration=y.current.transitionDuration,e.style.animationName=y.current.animationName),c(r)}},[o.open,r]),(0,P.jsx)(f.div,{"data-state":rn(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!_,...a,ref:u,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:_&&i})},`CollapsibleContentImpl`));function rn(e){return e?`open`:`closed`}Gt(rn,`getState`);var an=Zt,on=Object.defineProperty,sn=(e,t)=>on(e,`name`,{value:t,configurable:!0}),cn=N.createContext(void 0);function ln(e){let t=N.useContext(cn);return e||t||`ltr`}sn(ln,`useDirection`);var un=Object.defineProperty,dn=(e,t)=>un(e,`name`,{value:t,configurable:!0});function fn(e){let t=N.useRef(e);return N.useEffect(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}dn(fn,`useCallbackRef`);var pn=Object.defineProperty,mn=(e,t)=>pn(e,`name`,{value:t,configurable:!0}),hn=`dismissableLayer.update`,gn=`dismissableLayer.pointerDownOutside`,_n=`dismissableLayer.focusOutside`,vn,yn=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),bn=N.forwardRef(mn(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=N.useContext(yn),[p,m]=N.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=N.useState({}),_=d(t,m),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=y?v.indexOf(y):-1,x=p?v.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,C=x>=b,w=N.useRef(!1),T=Cn(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:w,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:N.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return C&&!t},[u.branches,C])}),E=wn(e=>{if(r&&w.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},h),D=p?x===v.length-1:!1,O=fn(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return N.useEffect(()=>{if(D)return h.addEventListener(`keydown`,O,{capture:!0}),()=>h.removeEventListener(`keydown`,O,{capture:!0})},[h,D,O]),N.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(vn=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),Tn(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=vn))}},[p,h,n,u]),N.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),Tn())},[p,u]),N.useEffect(()=>{let e=mn(()=>g({}),`handleUpdate`);return document.addEventListener(hn,e),()=>document.removeEventListener(hn,e)},[]),(0,P.jsx)(f.div,{...l,ref:_,style:{pointerEvents:S?C?`auto`:`none`:void 0,...e.style},onFocusCapture:F(e.onFocusCapture,E.onFocusCapture),onBlurCapture:F(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:F(e.onPointerDownCapture,T.onPointerDownCapture)})},`DismissableLayer`));function xn(){let e=N.useContext(yn),[t,n]=N.useState(null);return N.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}mn(xn,`useDismissableLayerSurface`);var Sn=mn(()=>!0,`IS_TRUE`);function Cn(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Sn}=t,s=fn(e),c=N.useRef(!1),l=N.useRef(!1),u=N.useRef(new Map),d=N.useRef(()=>{});return N.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}mn(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}mn(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}mn(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}mn(p,`handleInteractionBubble`);let m=mn(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||En(gn,s,p,{discrete:!0})};if(mn(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:mn(()=>c.current=!0,`onPointerDownCapture`)}}mn(Cn,`usePointerDownOutside`);function wn(e,t=globalThis?.document){let n=fn(e),r=N.useRef(!1);return N.useEffect(()=>{let e=mn(e=>{e.target&&!r.current&&En(_n,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:mn(()=>r.current=!0,`onFocusCapture`),onBlurCapture:mn(()=>r.current=!1,`onBlurCapture`)}}mn(wn,`useFocusOutside`);function Tn(){let e=new CustomEvent(hn);document.dispatchEvent(e)}mn(Tn,`dispatchUpdate`);function En(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?v(i,a):i.dispatchEvent(a)}mn(En,`handleAndDispatchCustomEvent`);var Dn=Object.defineProperty,On=(e,t)=>Dn(e,`name`,{value:t,configurable:!0}),kn=`focusScope.autoFocusOnMount`,An=`focusScope.autoFocusOnUnmount`,jn={bubbles:!1,cancelable:!0},Mn=N.forwardRef(On(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=N.useState(null),l=fn(i),u=fn(a),p=N.useRef(null),m=d(t,c),h=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(r){let e=function(e){if(h.paused||!s)return;let t=e.target;s.contains(t)?p.current=t:zn(p.current,{select:!0})},t=function(e){if(h.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||zn(p.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&zn(s)};On(e,`handleFocusIn`),On(t,`handleFocusOut`),On(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,h.paused]),N.useEffect(()=>{if(s){Bn.add(h);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(kn,jn);s.addEventListener(kn,l),s.dispatchEvent(t),t.defaultPrevented||(Nn(Un(Fn(s)),{select:!0}),document.activeElement===e&&zn(s))}return()=>{s.removeEventListener(kn,l),setTimeout(()=>{let t=new CustomEvent(An,jn);s.addEventListener(An,u),s.dispatchEvent(t),t.defaultPrevented||zn(e??document.body,{select:!0}),s.removeEventListener(An,u),Bn.remove(h)},0)}}},[s,l,u,h]);let g=N.useCallback(e=>{if(!n&&!r||h.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Pn(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&zn(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&zn(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,h.paused]);return(0,P.jsx)(f.div,{tabIndex:-1,...o,ref:m,onKeyDown:g})},`FocusScope`));function Nn(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(zn(r,{select:t}),document.activeElement!==n)return}On(Nn,`focusFirst`);function Pn(e){let t=Fn(e);return[In(t,e),In(t.reverse(),e)]}On(Pn,`getTabbableEdges`);function Fn(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:On(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}On(Fn,`getTabbableCandidates`);function In(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Ln(r,{upTo:t})))return r}On(In,`findVisible`);function Ln(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}On(Ln,`isHidden`);function Rn(e){return e instanceof HTMLInputElement&&`select`in e}On(Rn,`isSelectableInput`);function zn(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rn(e)&&t&&e.select()}}On(zn,`focus`);var Bn=Vn();function Vn(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Hn(e,t),e.unshift(t)},remove(t){e=Hn(e,t),e[0]?.resume()}}}On(Vn,`createFocusScopesStack`);function Hn(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}On(Hn,`arrayRemove`);function Un(e){return e.filter(e=>e.tagName!==`A`)}On(Un,`removeLinks`);var Wn=n(i(),1),Gn=Object.defineProperty,Kn=N.forwardRef(((e,t)=>Gn(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=N.useState(!1);gt(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Wn.createPortal((0,P.jsx)(f.div,{...r,ref:t}),o):null},`Portal`)),qn=Object.defineProperty,Jn=(e,t)=>qn(e,`name`,{value:t,configurable:!0}),Yn=0,Xn=null;function Zn(e){return Qn(),e.children}Jn(Zn,`FocusGuards`);function Qn(){N.useEffect(()=>{Xn||={start:$n(),end:$n()};let{start:e,end:t}=Xn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Yn++,()=>{Yn===1&&(Xn?.start.remove(),Xn?.end.remove(),Xn=null),Yn=Math.max(0,Yn-1)}},[])}Jn(Qn,`useFocusGuards`);function $n(){let 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}Jn($n,`createFocusGuard`);var er=function(){return er=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},er.apply(this,arguments)};function tr(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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function nr(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var rr=`right-scroll-bar-position`,ir=`width-before-scroll-bar`,ar=`with-scroll-bars-hidden`,or=`--removed-body-scroll-bar-size`;function sr(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function cr(e,t){var n=(0,N.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var lr=typeof window<`u`?N.useLayoutEffect:N.useEffect,ur=new WeakMap;function dr(e,t){var n=cr(t||null,function(t){return e.forEach(function(e){return sr(e,t)})});return lr(function(){var t=ur.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||sr(e,null)}),i.forEach(function(e){r.has(e)||sr(e,a)})}ur.set(n,e)},[e]),n}function fr(e){return e}function pr(e,t){t===void 0&&(t=fr);var n=[],r=!1;return{read:function(){if(r)throw 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(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function mr(e){e===void 0&&(e={});var t=pr(null);return t.options=er({async:!0,ssr:!1},e),t}var hr=function(e){var t=e.sideCar,n=tr(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return N.createElement(r,er({},n))};hr.isSideCarExport=!0;function gr(e,t){return e.useMedium(t),hr}var _r=mr(),vr=function(){},yr=N.forwardRef(function(e,t){var n=N.useRef(null),r=N.useState({onScrollCapture:vr,onWheelCapture:vr,onTouchMoveCapture:vr}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=tr(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=dr([n,t]),C=er(er({},b),i);return N.createElement(N.Fragment,null,u&&N.createElement(x,{sideCar:_r,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?N.cloneElement(N.Children.only(s),er(er({},C),{ref:S})):N.createElement(v,er({},C,{className:c,ref:S}),s))});yr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},yr.classNames={fullWidth:ir,zeroRight:rr};var br=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function xr(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=br();return t&&e.setAttribute(`nonce`,t),e}function Sr(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Cr(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var wr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=xr())&&(Sr(t,n),Cr(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Tr=function(){var e=wr();return function(t,n){N.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Er=function(){var e=Tr();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Dr={left:0,top:0,right:0,gap:0},Or=function(e){return parseInt(e||``,10)||0},kr=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Or(n),Or(r),Or(i)]},Ar=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Dr;var t=kr(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])}},jr=Er(),Mr=`data-scroll-locked`,Nr=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
+ .${ar} {
3
3
  overflow: hidden ${r};
4
4
  padding-right: ${s}px ${r};
5
5
  }
6
- body[${kr}] {
6
+ body[${Mr}] {
7
7
  overflow: hidden ${r};
8
8
  overscroll-behavior: contain;
9
9
  ${[t&&`position: relative ${r};`,n===`margin`&&`
@@ -16,31 +16,31 @@ import{i as e,n as t,o as n,r,t as i}from"./react-dom.B--7n7g5.js";import{_ as a
16
16
  `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
17
17
  }
18
18
 
19
- .${er} {
19
+ .${rr} {
20
20
  right: ${s}px ${r};
21
21
  }
22
22
 
23
- .${tr} {
23
+ .${ir} {
24
24
  margin-right: ${s}px ${r};
25
25
  }
26
26
 
27
- .${er} .${er} {
27
+ .${rr} .${rr} {
28
28
  right: 0 ${r};
29
29
  }
30
30
 
31
- .${tr} .${tr} {
31
+ .${ir} .${ir} {
32
32
  margin-right: 0 ${r};
33
33
  }
34
34
 
35
- body[${kr}] {
36
- ${rr}: ${s}px;
35
+ body[${Mr}] {
36
+ ${or}: ${s}px;
37
37
  }
38
- `},jr=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Mr=function(){N.useEffect(function(){return document.body.setAttribute(kr,(jr()+1).toString()),function(){var e=jr()-1;e<=0?document.body.removeAttribute(kr):document.body.setAttribute(kr,e.toString())}},[])},Nr=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Mr();var a=N.useMemo(function(){return Dr(i)},[i]);return N.createElement(Or,{styles:Ar(a,!t,i,n?``:`!important`)})},Pr=!1;if(typeof window<`u`)try{var Fr=Object.defineProperty({},"passive",{get:function(){return Pr=!0,!0}});window.addEventListener(`test`,Fr,Fr),window.removeEventListener(`test`,Fr,Fr)}catch{Pr=!1}var Ir=Pr?{passive:!1}:!1,Lr=function(e){return e.tagName===`TEXTAREA`},Rr=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Lr(e)&&n[t]===`visible`)},zr=function(e){return Rr(e,`overflowY`)},Br=function(e){return Rr(e,`overflowX`)},Vr=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Wr(e,r)){var i=Gr(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Hr=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Ur=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Wr=function(e,t){return e===`v`?zr(t):Br(t)},Gr=function(e,t){return e===`v`?Hr(t):Ur(t)},Kr=function(e,t){return e===`h`&&t===`rtl`?-1:1},qr=function(e,t,n,r,i){var a=Kr(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Gr(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Wr(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Jr=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Yr=function(e){return[e.deltaX,e.deltaY]},Xr=function(e){return e&&`current`in e?e.current:e},Zr=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Qr=function(e){return`
38
+ `},Pr=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Fr=function(){N.useEffect(function(){return document.body.setAttribute(Mr,(Pr()+1).toString()),function(){var e=Pr()-1;e<=0?document.body.removeAttribute(Mr):document.body.setAttribute(Mr,e.toString())}},[])},Ir=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Fr();var a=N.useMemo(function(){return Ar(i)},[i]);return N.createElement(jr,{styles:Nr(a,!t,i,n?``:`!important`)})},Lr=!1;if(typeof window<`u`)try{var Rr=Object.defineProperty({},"passive",{get:function(){return Lr=!0,!0}});window.addEventListener(`test`,Rr,Rr),window.removeEventListener(`test`,Rr,Rr)}catch{Lr=!1}var zr=Lr?{passive:!1}:!1,Br=function(e){return e.tagName===`TEXTAREA`},Vr=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Br(e)&&n[t]===`visible`)},Hr=function(e){return Vr(e,`overflowY`)},Ur=function(e){return Vr(e,`overflowX`)},Wr=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),qr(e,r)){var i=Jr(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Gr=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Kr=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},qr=function(e,t){return e===`v`?Hr(t):Ur(t)},Jr=function(e,t){return e===`v`?Gr(t):Kr(t)},Yr=function(e,t){return e===`h`&&t===`rtl`?-1:1},Xr=function(e,t,n,r,i){var a=Yr(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Jr(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&qr(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Zr=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Qr=function(e){return[e.deltaX,e.deltaY]},$r=function(e){return e&&`current`in e?e.current:e},ei=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ti=function(e){return`
39
39
  .block-interactivity-${e} {pointer-events: none;}
40
40
  .allow-interactivity-${e} {pointer-events: all;}
41
- `},$r=0,ei=[];function ti(e){var t=N.useRef([]),n=N.useRef([0,0]),r=N.useRef(),i=N.useState($r++)[0],a=N.useState(Cr)[0],o=N.useRef(e);N.useEffect(function(){o.current=e},[e]),N.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=$n([e.lockRef.current],(e.shards||[]).map(Xr),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=N.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Jr(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Vr(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Vr(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return qr(h,t,e,h===`h`?s:c,!0)},[]),c=N.useCallback(function(e){var n=e;if(ei.length&&ei[ei.length-1]===a){var r=`deltaY`in n?Yr(n):Jr(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Zr(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Xr).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=N.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ni(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=N.useCallback(function(e){n.current=Jr(e),r.current=void 0},[]),d=N.useCallback(function(t){l(t.type,Yr(t),t.target,s(t,e.lockRef.current))},[]),f=N.useCallback(function(t){l(t.type,Jr(t),t.target,s(t,e.lockRef.current))},[]);N.useEffect(function(){return ei.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ir),document.addEventListener(`touchmove`,c,Ir),document.addEventListener(`touchstart`,u,Ir),function(){ei=ei.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ir),document.removeEventListener(`touchmove`,c,Ir),document.removeEventListener(`touchstart`,u,Ir)}},[]);var p=e.removeScrollBar,m=e.inert;return N.createElement(N.Fragment,null,m?N.createElement(a,{styles:Qr(i)}):null,p?N.createElement(Nr,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ni(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ri=pr(mr,ti),ii=N.forwardRef(function(e,t){return N.createElement(gr,Zn({},e,{ref:t,sideCar:ri}))});ii.classNames=gr.classNames;var ai=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},oi=new WeakMap,si=new WeakMap,ci={},li=0,ui=function(e){return e&&(e.host||ui(e.parentNode))},di=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ui(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},fi=function(e,t,n,r){var i=di(t,Array.isArray(e)?e:[e]);ci[n]||(ci[n]=new WeakMap);var a=ci[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(oi.get(e)||0)+1,l=(a.get(e)||0)+1;oi.set(e,c),a.set(e,l),o.push(e),c===1&&i&&si.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),li++,function(){o.forEach(function(e){var t=oi.get(e)-1,i=a.get(e)-1;oi.set(e,t),a.set(e,i),t||(si.has(e)||e.removeAttribute(r),si.delete(e)),i||e.removeAttribute(n)}),li--,li||(oi=new WeakMap,oi=new WeakMap,si=new WeakMap,ci={})}},pi=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||ai(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),fi(r,i,n,`aria-hidden`)):function(){return null}},mi=Object.defineProperty,hi=(e,t)=>mi(e,`name`,{value:t,configurable:!0}),gi=`Dialog`,[_i,vi]=Ge(gi),[yi,bi]=_i(gi),xi=hi(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=N.useRef(null),c=N.useRef(null),[l,u]=St({prop:r,defaultProp:i??!1,onChange:a,caller:gi}),[d,f]=N.useState(0),[p,m]=N.useState(0);return(0,P.jsx)(yi,{scope:t,triggerRef:s,contentRef:c,contentId:Bt(),titleId:Bt(),descriptionId:Bt(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:N.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Si=`DialogTrigger`,Ci=N.forwardRef(hi(function(e,t){let{__scopeDialog:n,...r}=e,i=bi(Si,n),a=d(t,i.triggerRef);return(0,P.jsx)(f.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Vi(i.open),...r,ref:a,onClick:F(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),wi=`DialogPortal`,[Ti,Ei]=_i(wi,{forceMount:void 0}),Di=hi(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=bi(wi,t);return(0,P.jsx)(Ti,{scope:t,forceMount:n,children:N.Children.map(r,e=>(0,P.jsx)(At,{present:n||a.open,children:(0,P.jsx)(Un,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Oi=`DialogOverlay`,ki=N.forwardRef(hi(function(e,t){let n=Ei(Oi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bi(Oi,e.__scopeDialog);return a.modal?(0,P.jsx)(At,{present:r||a.open,children:(0,P.jsx)(ji,{...i,ref:t})}):null},`DialogOverlay`)),Ai=h(`DialogOverlay.RemoveScroll`),ji=N.forwardRef(hi(function(e,t){let{__scopeDialog:n,...r}=e,i=bi(Oi,n),a=vn(),o=d(t,a);return(0,P.jsx)(ii,{as:Ai,allowPinchZoom:!0,shards:[i.contentRef],children:(0,P.jsx)(f.div,{"data-state":Vi(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Mi=`DialogContent`,Ni=N.forwardRef(hi(function(e,t){let n=Ei(Mi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=bi(Mi,e.__scopeDialog);return(0,P.jsx)(At,{present:r||a.open,children:a.modal?(0,P.jsx)(Pi,{...i,ref:t}):(0,P.jsx)(Fi,{...i,ref:t})})},`DialogContent`)),Pi=N.forwardRef(hi(function(e,t){let n=bi(Mi,e.__scopeDialog),r=N.useRef(null),i=d(t,n.contentRef,r);return N.useEffect(()=>{let e=r.current;if(e)return pi(e)},[]),(0,P.jsx)(Ii,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:F(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Fi=N.forwardRef(hi(function(e,t){let n=bi(Mi,e.__scopeDialog),r=N.useRef(!1),i=N.useRef(!1);return(0,P.jsx)(Ii,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Ii=N.forwardRef(hi(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=bi(Mi,n);return Yn(),(0,P.jsx)(P.Fragment,{children:(0,P.jsx)(kn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,P.jsx)(_n,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Vi(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Li=`DialogTitle`,Ri=N.forwardRef(hi(function(e,t){let{__scopeDialog:n,...r}=e,i=bi(Li,n),{setTitleCount:a}=i;return pt(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,P.jsx)(f.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),zi=`DialogClose`,Bi=N.forwardRef(hi(function(e,t){let{__scopeDialog:n,...r}=e,i=bi(zi,n);return(0,P.jsx)(f.button,{type:`button`,...r,ref:t,onClick:F(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Vi(e){return e?`open`:`closed`}hi(Vi,`getState`);var Hi=Object.defineProperty,Ui=(e,t)=>Hi(e,`name`,{value:t,configurable:!0}),Wi=`Avatar`,[Gi,Ki]=Ge(Wi),qi=[0,()=>void 0],[Ji,Yi]=Gi(Wi),Xi=N.forwardRef(Ui(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=N.useState(`idle`),[o,s]=ra();return(0,P.jsx)(Ji,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,P.jsx)(f.span,{...r,ref:t})})},`Avatar`)),Zi=`AvatarImage`,Qi=N.forwardRef(Ui(function(e,t){let{__scopeAvatar:n,src:r,onLoadingStatusChange:i,...a}=e,o=Yi(Zi,n);o.setImageCount;let s=ta(r,{referrerPolicy:a.referrerPolicy,crossOrigin:a.crossOrigin,loadingStatus:o.imageLoadingStatus,setLoadingStatus:o.setImageLoadingStatus}),c=ln(e=>{i?.(e)}),l=N.useRef(s);return pt(()=>{let e=l.current;l.current=s,s!==e&&c(s)},[s,c]),s===`loaded`?(0,P.jsx)(f.img,{...a,ref:t,src:r}):null},`AvatarImage`)),$i=`AvatarFallback`,ea=N.forwardRef(Ui(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=Yi($i,n),[o,s]=N.useState(r===void 0);return N.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==`loaded`?(0,P.jsx)(f.span,{...i,ref:t}):null},`AvatarFallback`));function ta(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return pt(()=>{if(!e){n(`error`);return}let t=new window.Image,a=Ui(e=>{let t=e.currentTarget;n(na(t))},`handleLoad`),o=Ui(()=>n(`error`),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n(na(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(`idle`)}},[e,i,r,n]),t}Ui(ta,`useImageLoadingStatus`);function na(e){return e.complete?e.naturalWidth>0?`loaded`:`error`:`loading`}Ui(na,`getImageLoadingStatus`);function ra(){return qi}Ui(ra,`useImageCount`);function ia(e){}Ui(ia,`useUpdateImageCount`);var aa=Object.defineProperty,oa=(e,t)=>aa(e,`name`,{value:t,configurable:!0});function sa(e){let[t,n]=N.useState(void 0);return pt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}oa(sa,`useSize`);var ca=[`top`,`right`,`bottom`,`left`],la=Math.min,ua=Math.max,da=Math.round,fa=Math.floor,pa=e=>({x:e,y:e}),ma={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function ha(e,t,n){return ua(e,la(t,n))}function ga(e,t){return typeof e==`function`?e(t):e}function _a(e){return e.split(`-`)[0]}function va(e){return e.split(`-`)[1]}function ya(e){return e===`x`?`y`:`x`}function ba(e){return e===`y`?`height`:`width`}function xa(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Sa(e){return ya(xa(e))}function Ca(e,t,n){n===void 0&&(n=!1);let r=va(e),i=Sa(e),a=ba(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Ma(o)),[o,Ma(o)]}function wa(e){let t=Ma(e);return[Ta(e),t,Ta(t)]}function Ta(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ea=[`left`,`right`],Da=[`right`,`left`],Oa=[`top`,`bottom`],ka=[`bottom`,`top`];function Aa(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Da:Ea:t?Ea:Da;case`left`:case`right`:return t?Oa:ka;default:return[]}}function ja(e,t,n,r){let i=va(e),a=Aa(_a(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ta)))),a}function Ma(e){let t=_a(e);return ma[t]+e.slice(t.length)}function Na(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Pa(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Na(e)}function Fa(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ia(e,t,n){let{reference:r,floating:i}=e,a=xa(t),o=Sa(t),s=ba(o),c=_a(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=va(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function La(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ga(t,e),p=Pa(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Fa(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Fa(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Ra=50,za=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:La},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Ia(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Ra&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Ia(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ba=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ga(e,t)||{};if(l==null)return{};let d=Pa(u),f={x:n,y:r},p=Sa(i),m=ba(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=la(d[_],T),D=la(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=ha(E,k,O),j=!c.arrow&&va(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Va=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ga(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=_a(r),_=xa(o),v=_a(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Ma(o)]:wa(o)),x=p!==`none`;!d&&x&&b.push(...ja(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Ca(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===xa(t)||T.every(e=>xa(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=xa(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Ha(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ua(e){return ca.some(t=>e[t]>=0)}var Wa=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=ga(e,t);switch(i){case`referenceHidden`:{let e=Ha(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ua(e)}}}case`escaped`:{let e=Ha(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ua(e)}}}default:return{}}}}},Ga=new Set([`left`,`top`]);async function Ka(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=_a(n),s=va(n),c=xa(n)===`y`,l=Ga.has(o)?-1:1,u=a&&c?-1:1,d=ga(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var qa=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Ka(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Ja=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ga(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=xa(i),p=ya(f),m=u[p],h=u[f],g=(e,t)=>ha(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Ya=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ga(e,t),u={x:n,y:r},d=xa(i),f=ya(d),p=u[f],m=u[d],h=ga(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ga.has(_a(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Xa=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=ga(e,t),c=await i.detectOverflow(t,s),l=_a(n),u=va(n),d=xa(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=la(p-c[m],g),y=la(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*ua(c.left,c.right):S=p-2*ua(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Za(){return typeof window<`u`}function Qa(e){return to(e)?(e.nodeName||``).toLowerCase():`#document`}function $a(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function eo(e){return((to(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function to(e){return Za()?e instanceof Node||e instanceof $a(e).Node:!1}function no(e){return Za()?e instanceof Element||e instanceof $a(e).Element:!1}function ro(e){return Za()?e instanceof HTMLElement||e instanceof $a(e).HTMLElement:!1}function io(e){return!Za()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof $a(e).ShadowRoot}function ao(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=_o(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function oo(e){return/^(table|td|th)$/.test(Qa(e))}function so(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var co=/transform|translate|scale|rotate|perspective|filter/,lo=/paint|layout|strict|content/,uo=e=>!!e&&e!==`none`,fo;function po(e){let t=no(e)?_o(e):e;return uo(t.transform)||uo(t.translate)||uo(t.scale)||uo(t.rotate)||uo(t.perspective)||!ho()&&(uo(t.backdropFilter)||uo(t.filter))||co.test(t.willChange||``)||lo.test(t.contain||``)}function mo(e){let t=yo(e);for(;ro(t)&&!go(t);){if(po(t))return t;if(so(t))return null;t=yo(t)}return null}function ho(){return fo??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),fo}function go(e){return/^(html|body|#document)$/.test(Qa(e))}function _o(e){return $a(e).getComputedStyle(e)}function vo(e){return no(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function yo(e){if(Qa(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||io(e)&&e.host||eo(e);return io(t)?t.host:t}function bo(e){let t=yo(e);return go(t)?(e.ownerDocument||e).body:ro(t)&&ao(t)?t:bo(t)}function xo(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=bo(e),i=r===e.ownerDocument?.body,a=$a(r);if(i){let e=So(a);return t.concat(a,a.visualViewport||[],ao(r)?r:[],e&&n?xo(e):[])}return t.concat(r,xo(r,[],n))}function So(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Co(e){let t=_o(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ro(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=da(n)!==a||da(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function wo(e){return no(e)?e:e.contextElement}function To(e){let t=wo(e);if(!ro(t))return pa(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Co(t),o=(a?da(n.width):n.width)/r,s=(a?da(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Eo=pa(0);function Do(e){let t=$a(e);return!ho()||!t.visualViewport?Eo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Oo(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===$a(e)}function ko(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=wo(e),o=pa(1);t&&(r?no(r)&&(o=To(r)):o=To(e));let s=Oo(a,n,r)?Do(a):pa(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=$a(a),t=no(r)?$a(r):r,n=e,i=So(n);for(;i&&t!==n;){let e=To(i),t=i.getBoundingClientRect(),r=_o(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=$a(i),i=So(n)}}return Fa({width:u,height:d,x:c,y:l})}function Ao(e,t){let n=vo(e).scrollLeft;return t?t.left+n:ko(eo(e)).left+n}function jo(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ao(e,n),y:n.top+t.scrollTop}}function Mo(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=eo(r),s=t?so(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=pa(1),u=pa(0),d=ro(r);if((d||!a)&&((Qa(r)!==`body`||ao(o))&&(c=vo(r)),d)){let e=ko(r);l=To(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?jo(o,c):pa(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function No(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Po(e){let t=vo(e),n=e.ownerDocument.body,r=ua(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ua(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Ao(e),o=-t.scrollTop;return _o(n).direction===`rtl`&&(a+=ua(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Fo=25;function Io(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=$a(e),a=eo(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ho()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Ao(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Fo&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Lo(e,t){let n=ko(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=To(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ro(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Io(e,n,t);else if(t===`document`)r=Po(eo(e));else if(no(t))r=Lo(t,n);else{let n=Do(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Fa(r)}function zo(e,t){let n=t.get(e);if(n)return n;let r=xo(e,[],!1).filter(e=>no(e)&&Qa(e)!==`body`),i=null,a=_o(e).position===`fixed`,o=a?yo(e):e;for(;no(o)&&!go(o);){let e=_o(o),t=po(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=yo(o)}return t.set(e,r),r}function Bo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?so(t)?[]:zo(t,this._c):[].concat(n),r],o=Ro(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ro(t,a[e],i);s=ua(n.top,s),c=la(n.right,c),l=la(n.bottom,l),u=ua(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Vo(e){let{width:t,height:n}=Co(e);return{width:t,height:n}}function Ho(e,t,n){let r=ro(t),i=eo(t),a=n===`fixed`,o=ko(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=pa(0);if((r||!a)&&((Qa(t)!==`body`||ao(i))&&(s=vo(t)),r)){let e=ko(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Ao(i));let l=i&&!r&&!a?jo(i,s):pa(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Uo(e){return _o(e).position===`static`}function Wo(e,t){if(!ro(e)||_o(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return eo(e)===n&&(n=n.ownerDocument.body),n}function Go(e,t){let n=$a(e);if(so(e))return n;if(!ro(e)){let t=yo(e);for(;t&&!go(t);){if(no(t)&&!Uo(t))return t;t=yo(t)}return n}let r=Wo(e,t);for(;r&&oo(r)&&Uo(r);)r=Wo(r,t);return r&&go(r)&&Uo(r)&&!po(r)?n:r||mo(e)||n}var Ko=async function(e){let t=this.getOffsetParent||Go,n=this.getDimensions,r=await n(e.floating);return{reference:Ho(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function qo(e){return _o(e).direction===`rtl`}var Jo={convertOffsetParentRelativeRectToViewportRelativeRect:Mo,getDocumentElement:eo,getClippingRect:Bo,getOffsetParent:Go,getElementRects:Ko,getClientRects:No,getDimensions:Vo,getScale:To,isElement:no,isRTL:qo};function Yo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Xo(e,t,n){let r=null,i,a=eo(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=fa(d),h=fa(a.clientWidth-(u+f)),g=fa(a.clientHeight-(d+p)),_=fa(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:ua(0,la(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Yo(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=$a(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Zo(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=wo(e),u=i||a?[...l?xo(l):[],...t?xo(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Xo(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?ko(e):null;c&&g();function g(){let t=ko(e);h&&!Yo(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Qo=qa,$o=Ja,es=Va,ts=Xa,ns=Wa,rs=Ba,is=Ya,as=(e,t,n)=>{let r=new Map,i=n??{},a={...Jo,...i.platform,_c:r};return za(e,t,{...i,platform:a})},os=typeof document<`u`?N.useLayoutEffect:function(){};function ss(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,i;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(!ss(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ss(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function cs(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ls(e,t){let n=cs(e);return Math.round(t*n)/n}function us(e){let t=N.useRef(e);return os(()=>{t.current=e}),t}function ds(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=N.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=N.useState(r);ss(f,r)||p(r);let[m,h]=N.useState(null),[g,_]=N.useState(null),v=N.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=N.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=N.useRef(null),C=N.useRef(null),w=N.useRef(u),T=c!=null,E=us(c),D=us(i),O=us(l),k=N.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),as(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!ss(w.current,t)&&(w.current=t,Vn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);os(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=N.useRef(!1);os(()=>(A.current=!0,()=>{A.current=!1}),[]),os(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=N.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=N.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=N.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=ls(M.floating,u.x),r=ls(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...cs(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return N.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:ee}),[u,k,j,M,ee])}var fs=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:rs({element:r.current,padding:i}).fn(n):r?rs({element:r,padding:i}).fn(n):{}}}},ps=(e,t)=>{let n=Qo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ms=(e,t)=>{let n=$o(e);return{name:n.name,fn:n.fn,options:[e,t]}},hs=(e,t)=>({fn:is(e).fn,options:[e,t]}),gs=(e,t)=>{let n=es(e);return{name:n.name,fn:n.fn,options:[e,t]}},_s=(e,t)=>{let n=ts(e);return{name:n.name,fn:n.fn,options:[e,t]}},vs=(e,t)=>{let n=ns(e);return{name:n.name,fn:n.fn,options:[e,t]}},ys=(e,t)=>{let n=fs(e);return{name:n.name,fn:n.fn,options:[e,t]}},bs=Object.defineProperty,xs=N.forwardRef(((e,t)=>bs(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,P.jsx)(f.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,P.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),Ss=Object.defineProperty,Cs=(e,t)=>Ss(e,`name`,{value:t,configurable:!0}),ws=`Popper`,[Ts,Es]=Ge(ws),[Ds,Os]=Ts(ws),ks=Cs(e=>{let{__scopePopper:t,children:n}=e,[r,i]=N.useState(null),[a,o]=N.useState(void 0);return(0,P.jsx)(Ds,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),As=`PopperAnchor`,js=N.forwardRef(Cs(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Os(As,n),o=N.useRef(null),s=a.onAnchorChange,c=N.useCallback(e=>{o.current=e,e&&s(e)},[s]),l=d(t,c),u=N.useRef(null);N.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&s(u.current)});let p=a.placementState&&Vs(a.placementState),m=p?.[0],h=p?.[1];return r?null:(0,P.jsx)(f.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...i,ref:l})},`PopperAnchor`)),Ms=`PopperContent`,[Ns,Ps]=Ts(Ms),Fs=N.forwardRef(Cs(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:p=`partial`,hideWhenDetached:m=!1,updatePositionStrategy:h=`optimized`,onPlaced:g,..._}=e,v=Os(Ms,n),[y,b]=N.useState(null),x=d(t,b),[S,C]=N.useState(null),w=sa(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],A=k.length>0,j={padding:O,boundary:k.filter(zs),altBoundary:A},{refs:M,floatingStyles:ee,placement:te,isPositioned:ne,middlewareData:re}=ds({strategy:`fixed`,placement:D,whileElementsMounted:Cs((...e)=>Zo(...e,{animationFrame:h===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[ps({mainAxis:i+E,alignmentAxis:o}),c&&ms({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?hs():void 0,...j}),c&&gs({...j}),_s({...j,apply:Cs(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&ys({element:S,padding:s}),Bs({arrowWidth:T,arrowHeight:E}),m&&vs({strategy:`referenceHidden`,...j,boundary:A?j.boundary:void 0})]}),ie=v.setPlacementState;pt(()=>(ie(te),()=>{ie(void 0)}),[te,ie]);let[ae,oe]=Vs(te),se=ln(g);pt(()=>{ne&&se?.()},[ne,se]);let ce=re.arrow?.x,le=re.arrow?.y,ue=re.arrow?.centerOffset!==0,[de,fe]=N.useState();return pt(()=>{y&&fe(window.getComputedStyle(y).zIndex)},[y]),(0,P.jsx)(`div`,{ref:M.setFloating,"data-radix-popper-content-wrapper":``,style:{...ee,transform:ne?ee.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:de,"--radix-popper-transform-origin":[re.transformOrigin?.x,re.transformOrigin?.y].join(` `),...re.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,P.jsx)(Ns,{scope:n,placedSide:ae,placedAlign:oe,onArrowChange:C,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,P.jsx)(f.div,{"data-side":ae,"data-align":oe,..._,ref:x,style:{..._.style,animation:ne?_.style?.animation:`none`}})})})},`PopperContent`)),Is=`PopperArrow`,Ls={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Rs=N.forwardRef(Cs(function(e,t){let{__scopePopper:n,...r}=e,i=Ps(Is,n),a=Ls[i.placedSide];return(0,P.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,P.jsx)(xs,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function zs(e){return e!==null}Cs(zs,`isNotNull`);var Bs=Cs(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Vs(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Vs(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Cs(Vs,`getSideAndAlignFromPlacement`);var Hs=ks,Us=js,Ws=Fs,Gs=Rs,Ks=Object.defineProperty,qs=(e,t)=>Ks(e,`name`,{value:t,configurable:!0}),Js=!1;function Ys(){let[e,t]=N.useState(Js);return N.useEffect(()=>{Js||(Js=!0,t(!0))},[]),e}qs(Ys,`useIsHydrated`);var Xs=N.useSyncExternalStore;function Zs(){return()=>{}}qs(Zs,`subscribe`);function Qs(){return Xs(Zs,()=>!0,()=>!1)}qs(Qs,`useIsHydratedModern`);var $s=typeof Xs==`function`?Qs:Ys,ec=Object.defineProperty,tc=(e,t)=>ec(e,`name`,{value:t,configurable:!0}),nc=`rovingFocusGroup.onEntryFocus`,rc={bubbles:!1,cancelable:!0},ic=`RovingFocusGroup`,[ac,oc,sc]=Ye(ic),[cc,lc]=Ge(ic,[sc]),[uc,dc]=cc(ic),fc=N.forwardRef(tc(function(e,t){return(0,P.jsx)(ac.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(ac.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(pc,{...e,ref:t})})})},`RovingFocusGroup`)),pc=N.forwardRef(tc(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...p}=e,m=N.useRef(null),h=d(t,m),g=on(a),[_,v]=St({prop:o,defaultProp:s??null,onChange:c,caller:ic}),[y,b]=N.useState(!1),x=ln(l),S=oc(n),C=N.useRef(!1),[w,T]=N.useState(0);return N.useEffect(()=>{let e=m.current;if(e)return e.addEventListener(nc,x),()=>e.removeEventListener(nc,x)},[x]),(0,P.jsx)(uc,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:N.useCallback(e=>v(e),[v]),onItemShiftTab:N.useCallback(()=>b(!0),[]),onFocusableItemAdd:N.useCallback(()=>T(e=>e+1),[]),onFocusableItemRemove:N.useCallback(()=>T(e=>e-1),[]),children:(0,P.jsx)(f.div,{tabIndex:y||w===0?-1:0,"data-orientation":r,...p,ref:h,style:{outline:`none`,...e.style},onMouseDown:F(e.onMouseDown,()=>{C.current=!0}),onFocus:F(e.onFocus,e=>{let t=!C.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(nc,rc);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);yc([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),u)}}C.current=!1}),onBlur:F(e.onBlur,()=>b(!1))})})},`RovingFocusGroupImpl`)),mc=`RovingFocusGroupItem`,hc=N.forwardRef(tc(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Bt(),l=a||c,u=dc(mc,n),d=u.currentTabStopId===l,p=oc(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=u,_=$s();return pt(()=>{if(_&&r)return m(),()=>h()},[_,r,m,h]),N.useEffect(()=>{if(!_&&r)return m(),()=>h()},[_,r,m,h]),(0,P.jsx)(ac.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,P.jsx)(f.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:F(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:F(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:F(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=vc(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?bc(n,r+1):n.slice(r+1)}setTimeout(()=>yc(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),gc={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function _c(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}tc(_c,`getDirectionAwareKey`);function vc(e,t,n){let r=_c(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return gc[r]}tc(vc,`getFocusIntent`);function yc(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}tc(yc,`focusFirst`);function bc(e,t){return e.map((n,r)=>e[(t+r)%e.length])}tc(bc,`wrapArray`);var xc=fc,Sc=hc,Cc=Object.defineProperty,wc=(e,t)=>Cc(e,`name`,{value:t,configurable:!0}),Tc=[`Enter`,` `],Ec=[`ArrowDown`,`PageUp`,`Home`],Dc=[`ArrowUp`,`PageDown`,`End`],Oc=[...Ec,...Dc],kc={ltr:[...Tc,`ArrowRight`],rtl:[...Tc,`ArrowLeft`]},Ac={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},jc=`Menu`,[Mc,Nc,Pc]=Ye(jc),[Fc,Ic]=Ge(jc,[Pc,Es,lc]),Lc=Es(),Rc=lc(),[zc,Bc]=Fc(jc),[Vc,Hc]=Fc(jc),Uc=wc(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Lc(t),[c,l]=N.useState(null),u=N.useRef(!1),d=ln(a),f=on(i);return N.useEffect(()=>{let e=wc(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=wc(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),N.useEffect(()=>{if(!n)return;let e=wc(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,P.jsx)(Hs,{...s,children:(0,P.jsx)(zc,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,P.jsx)(Vc,{scope:t,onClose:N.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Wc=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,...r}=e,i=Lc(n);return(0,P.jsx)(Us,{...i,...r,ref:t})},`MenuAnchor`)),Gc=`MenuPortal`,[Kc,qc]=Fc(Gc,{forceMount:void 0}),Jc=wc(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Bc(Gc,t);return(0,P.jsx)(Kc,{scope:t,forceMount:n,children:(0,P.jsx)(At,{present:n||a.open,children:(0,P.jsx)(Un,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Yc=`MenuContent`,[Xc,Zc]=Fc(Yc),Qc=N.forwardRef(wc(function(e,t){let n=qc(Yc,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Bc(Yc,e.__scopeMenu),o=Hc(Yc,e.__scopeMenu);return(0,P.jsx)(Mc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(At,{present:r||a.open,children:(0,P.jsx)(Mc.Slot,{scope:e.__scopeMenu,children:o.modal?(0,P.jsx)($c,{...i,ref:t}):(0,P.jsx)(el,{...i,ref:t})})})})},`MenuContent`)),$c=N.forwardRef(wc(function(e,t){let n=Bc(Yc,e.__scopeMenu),r=N.useRef(null),i=d(t,r);return N.useEffect(()=>{let e=r.current;if(e)return pi(e)},[]),(0,P.jsx)(nl,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),el=N.forwardRef(wc(function(e,t){let n=Bc(Yc,e.__scopeMenu);return(0,P.jsx)(nl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),tl=h(`MenuContent.ScrollLock`),nl=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=Bc(Yc,n),v=Hc(Yc,n),y=Lc(n),b=Rc(n),x=Nc(n),[S,C]=N.useState(null),w=N.useRef(null),T=d(t,w,_.onContentChange),E=N.useRef(0),D=N.useRef(``),O=N.useRef(0),k=N.useRef(null),A=N.useRef(`right`),j=N.useRef(0),M=h?ii:N.Fragment,ee=h?{as:tl,allowPinchZoom:!0}:void 0,te=wc(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Pl(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;wc((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);N.useEffect(()=>()=>window.clearTimeout(E.current),[]),Yn();let ne=N.useCallback(e=>A.current===k.current?.side&&Il(e,k.current?.area),[]);return(0,P.jsx)(Xc,{scope:n,searchRef:D,onItemEnter:N.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),onItemLeave:N.useCallback(e=>{ne(e)||(w.current?.focus(),C(null))},[ne]),onTriggerLeave:N.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),pointerGraceTimerRef:O,onPointerGraceIntentChange:N.useCallback(e=>{k.current=e},[]),children:(0,P.jsx)(M,{...ee,children:(0,P.jsx)(kn,{asChild:!0,trapped:i,onMountAutoFocus:F(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,P.jsx)(_n,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,P.jsx)(xc,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:F(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,P.jsx)(Ws,{role:`menu`,"aria-orientation":`vertical`,"data-state":kl(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:F(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&te(e.key));let i=w.current;if(e.target!==i||!Oc.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);Dc.includes(e.key)&&a.reverse(),Ml(a)}),onBlur:F(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:F(e.onPointerMove,Ll(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),rl=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`group`,...r,ref:t})},`MenuGroup`)),il=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{...r,ref:t})},`MenuLabel`)),al=`MenuItem`,ol=`menu.itemSelect`,sl=N.forwardRef(wc(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=N.useRef(null),o=Hc(al,e.__scopeMenu),s=Zc(al,e.__scopeMenu),c=d(t,a),l=N.useRef(!1),u=wc(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(ol,{bubbles:!0,cancelable:!0});e.addEventListener(ol,e=>r?.(e),{once:!0}),v(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,P.jsx)(cl,{...i,ref:c,disabled:n,onClick:F(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:F(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:F(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Tc.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),cl=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Zc(al,n),s=Rc(n),c=N.useRef(null),l=d(t,c),[u,p]=N.useState(!1),[m,h]=N.useState(``);return N.useEffect(()=>{let e=c.current;e&&h((e.textContent??``).trim())},[a.children]),(0,P.jsx)(Mc.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,P.jsx)(Sc,{asChild:!0,...s,focusable:!r,children:(0,P.jsx)(f.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:F(e.onPointerMove,Ll(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,Ll(e=>o.onItemLeave(e))),onFocus:F(e.onFocus,()=>p(!0)),onBlur:F(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),ll=N.forwardRef(wc(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,P.jsx)(gl,{scope:e.__scopeMenu,checked:n,children:(0,P.jsx)(sl,{role:`menuitemcheckbox`,"aria-checked":Al(n)?`mixed`:n,...i,ref:t,"data-state":jl(n),onSelect:F(i.onSelect,()=>r?.(Al(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[ul,dl]=Fc(`MenuRadioGroup`,{value:void 0,onValueChange:wc(()=>{},`onValueChange`)}),fl=N.forwardRef(wc(function(e,t){let{value:n,onValueChange:r,...i}=e,a=ln(r);return(0,P.jsx)(ul,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,P.jsx)(rl,{...i,ref:t})})},`MenuRadioGroup`)),pl=`MenuRadioItem`,ml=N.forwardRef(wc(function(e,t){let{value:n,...r}=e,i=dl(pl,e.__scopeMenu),a=n===i.value;return(0,P.jsx)(gl,{scope:e.__scopeMenu,checked:a,children:(0,P.jsx)(sl,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":jl(a),onSelect:F(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),hl=`MenuItemIndicator`,[gl,_l]=Fc(hl,{checked:!1}),vl=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=_l(hl,n);return(0,P.jsx)(At,{present:r||Al(a.checked)||a.checked===!0,children:(0,P.jsx)(f.span,{...i,ref:t,"data-state":jl(a.checked)})})},`MenuItemIndicator`)),yl=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),bl=N.forwardRef(wc(function(e,t){let{__scopeMenu:n,...r}=e,i=Lc(n);return(0,P.jsx)(Gs,{...i,...r,ref:t})},`MenuArrow`)),xl=`MenuSub`,[Sl,Cl]=Fc(xl),wl=wc(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Bc(xl,t),o=Lc(t),[s,c]=N.useState(null),[l,u]=N.useState(null),d=ln(i);return N.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,P.jsx)(Hs,{...o,children:(0,P.jsx)(zc,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,P.jsx)(Sl,{scope:t,contentId:Bt(),triggerId:Bt(),trigger:s,onTriggerChange:c,children:n})})})},`MenuSub`),Tl=`MenuSubTrigger`,El=N.forwardRef(wc(function(e,t){let n=Bc(Tl,e.__scopeMenu),r=Hc(Tl,e.__scopeMenu),i=Cl(Tl,e.__scopeMenu),a=Zc(Tl,e.__scopeMenu),o=N.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=N.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);N.useEffect(()=>u,[u]),N.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let f=d(t,i.onTriggerChange);return(0,P.jsx)(Wc,{asChild:!0,...l,children:(0,P.jsx)(cl,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":kl(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,Ll(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:F(e.onPointerLeave,Ll(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:F(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&kc[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),Dl=`MenuSubContent`,Ol=N.forwardRef(wc(function(e,t){let n=qc(Yc,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Bc(Yc,e.__scopeMenu),s=Hc(Yc,e.__scopeMenu),c=Cl(Dl,e.__scopeMenu),l=N.useRef(null),u=d(t,l);return(0,P.jsx)(Mc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(At,{present:r||o.open,children:(0,P.jsx)(Mc.Slot,{scope:e.__scopeMenu,children:(0,P.jsx)(nl,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:F(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:F(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Ac[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function kl(e){return e?`open`:`closed`}wc(kl,`getOpenState`);function Al(e){return e===`indeterminate`}wc(Al,`isIndeterminate`);function jl(e){return Al(e)?`indeterminate`:e?`checked`:`unchecked`}wc(jl,`getCheckedState`);function Ml(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}wc(Ml,`focusFirst`);function Nl(e,t){return e.map((n,r)=>e[(t+r)%e.length])}wc(Nl,`wrapArray`);function Pl(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Nl(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}wc(Pl,`getNextMatch`);function Fl(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}wc(Fl,`isPointInPolygon`);function Il(e,t){return t?Fl({x:e.clientX,y:e.clientY},t):!1}wc(Il,`isPointerInGraceArea`);function Ll(e){return t=>t.pointerType===`mouse`?e(t):void 0}wc(Ll,`whenMouse`);var Rl=Uc,zl=Wc,Bl=Jc,Vl=Qc,Hl=rl,Ul=il,Wl=sl,Gl=ll,Kl=fl,ql=ml,Jl=vl,Yl=yl,Xl=bl,Zl=wl,Ql=El,$l=Ol,eu=e({Arrow:()=>zu,CheckboxItem:()=>Pu,Content:()=>Au,DropdownMenu:()=>lu,DropdownMenuArrow:()=>Cu,DropdownMenuCheckboxItem:()=>vu,DropdownMenuContent:()=>mu,DropdownMenuGroup:()=>hu,DropdownMenuItem:()=>_u,DropdownMenuItemIndicator:()=>xu,DropdownMenuLabel:()=>gu,DropdownMenuPortal:()=>fu,DropdownMenuRadioGroup:()=>yu,DropdownMenuRadioItem:()=>bu,DropdownMenuSeparator:()=>Su,DropdownMenuSub:()=>wu,DropdownMenuSubContent:()=>Eu,DropdownMenuSubTrigger:()=>Tu,DropdownMenuTrigger:()=>du,Group:()=>ju,Item:()=>Nu,ItemIndicator:()=>Lu,Label:()=>Mu,Portal:()=>ku,RadioGroup:()=>Fu,RadioItem:()=>Iu,Root:()=>Du,Separator:()=>Ru,Sub:()=>Bu,SubContent:()=>Hu,SubTrigger:()=>Vu,Trigger:()=>Ou,createDropdownMenuScope:()=>au}),tu=Object.defineProperty,nu=(e,t)=>tu(e,`name`,{value:t,configurable:!0}),ru=`DropdownMenu`,[iu,au]=Ge(ru,[Ic]),ou=Ic(),[su,cu]=iu(ru),lu=nu(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=ou(t),l=N.useRef(null),[u,d]=St({prop:i,defaultProp:a??!1,onChange:o,caller:ru});return(0,P.jsx)(su,{scope:t,triggerId:Bt(),triggerRef:l,contentId:Bt(),open:u,onOpenChange:d,onOpenToggle:N.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,P.jsx)(Rl,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),uu=`DropdownMenuTrigger`,du=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=cu(uu,n),o=ou(n),s=d(t,a.triggerRef);return(0,P.jsx)(zl,{asChild:!0,...o,children:(0,P.jsx)(f.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:F(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:F(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),fu=nu(e=>{let{__scopeDropdownMenu:t,...n}=e,r=ou(t);return(0,P.jsx)(Bl,{...r,...n})},`DropdownMenuPortal`),pu=`DropdownMenuContent`,mu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=cu(pu,n),a=ou(n),o=N.useRef(!1);return(0,P.jsx)(Vl,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:F(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),hu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Hl,{...i,...r,ref:t})},`DropdownMenuGroup`)),gu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Ul,{...i,...r,ref:t})},`DropdownMenuLabel`)),_u=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Wl,{...i,...r,ref:t})},`DropdownMenuItem`)),vu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Gl,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),yu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Kl,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),bu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(ql,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),xu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Jl,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),Su=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Yl,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Cu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Xl,{...i,...r,ref:t})},`DropdownMenuArrow`)),wu=nu(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=ou(t),[s,c]=St({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,P.jsx)(Zl,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),Tu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)(Ql,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),Eu=N.forwardRef(nu(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ou(n);return(0,P.jsx)($l,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),Du=lu,Ou=du,ku=fu,Au=mu,ju=hu,Mu=gu,Nu=_u,Pu=vu,Fu=yu,Iu=bu,Lu=xu,Ru=Su,zu=Cu,Bu=wu,Vu=Tu,Hu=Eu,Uu=Object.defineProperty,Wu=(e,t)=>Uu(e,`name`,{value:t,configurable:!0}),[Gu,Ku]=Ge(`Tooltip`,[Es]),qu=Es(),Ju=`TooltipProvider`,Yu=700,Xu=`tooltip.open`,[Zu,Qu]=Gu(Ju),$u=Wu(e=>{let{__scopeTooltip:t,delayDuration:n=Yu,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=N.useRef(!0),s=N.useRef(!1),c=N.useRef(0);return N.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,P.jsx)(Zu,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:N.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:N.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:N.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),ed=`Tooltip`,[td,nd]=Gu(ed),rd=Wu(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Qu(ed,e.__scopeTooltip),l=qu(t),[u,d]=N.useState(null),[f,p]=N.useState(void 0),m=Bt(),h=N.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=N.useRef(!1),[y,b]=St({prop:r,defaultProp:i??!1,onChange:Wu(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Xu))):c.onClose(),a?.(e)},`onChange`),caller:ed}),x=N.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=N.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);N.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,P.jsx)(Hs,{...l,children:(0,P.jsx)(td,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:N.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:N.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),id=`TooltipTrigger`,ad=N.forwardRef(Wu(function(e,t){let{__scopeTooltip:n,...r}=e,i=nd(id,n),a=Qu(id,n),o=qu(n),s=N.useRef(null),c=d(t,s,i.onTriggerChange),l=N.useRef(!1),u=N.useRef(!1),p=N.useCallback(()=>l.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener(`pointerup`,p),[p]),(0,P.jsx)(Us,{asChild:!0,...o,children:(0,P.jsx)(f.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:F(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:F(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:F(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener(`pointerup`,p,{once:!0})}),onFocus:F(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:F(e.onBlur,i.onClose),onClick:F(e.onClick,i.onClose)})})},`TooltipTrigger`)),od=`TooltipPortal`,[sd,cd]=Gu(od,{forceMount:void 0}),ld=Wu(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=nd(od,t);return(0,P.jsx)(sd,{scope:t,forceMount:n,children:(0,P.jsx)(At,{present:n||a.open,children:(0,P.jsx)(Un,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),ud=`TooltipContent`,dd=N.forwardRef(Wu(function(e,t){let n=cd(ud,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=nd(ud,e.__scopeTooltip);return(0,P.jsx)(At,{present:r||o.open,children:o.disableHoverableContent?(0,P.jsx)(md,{side:i,...a,ref:t}):(0,P.jsx)(fd,{side:i,...a,ref:t})})},`TooltipContent`)),fd=N.forwardRef(Wu(function(e,t){let n=nd(ud,e.__scopeTooltip),r=Qu(ud,e.__scopeTooltip),i=N.useRef(null),a=d(t,i),[o,s]=N.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:f}=r,p=N.useCallback(()=>{s(null),f(!1)},[f]),m=N.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=_d(r,gd(r,n.getBoundingClientRect())),a=vd(t.getBoundingClientRect()),o=bd([...i,...a]);s(o),f(!0)},[f]);return N.useEffect(()=>()=>p(),[p]),N.useEffect(()=>{if(c&&u){let e=Wu(e=>m(e,u),`handleTriggerLeave`),t=Wu(e=>m(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,p]),N.useEffect(()=>{if(o){let e=Wu(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!yd(n,o);r?p():i&&(p(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,p]),(0,P.jsx)(md,{...e,ref:a})},`TooltipContentHoverable`)),pd=p(`TooltipContent`),md=N.forwardRef(Wu(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=nd(ud,n),u=qu(n),{onClose:d}=l;N.useEffect(()=>(document.addEventListener(Xu,d),()=>document.removeEventListener(Xu,d)),[d]),N.useEffect(()=>{if(l.trigger){let e=Wu(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return pt(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,P.jsx)(_n,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,P.jsxs)(Ws,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.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:[(0,P.jsx)(pd,{children:r}),i?(0,P.jsx)(Ve,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),hd=N.forwardRef(Wu(function(e,t){let{__scopeTooltip:n,...r}=e,i=qu(n);return(0,P.jsx)(Gs,{...i,...r,ref:t})},`TooltipArrow`));function gd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Wu(gd,`getExitSideFromRect`);function _d(e,t,n=5){let 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})}return r}Wu(_d,`getPaddedExitPoints`);function vd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Wu(vd,`getPointsFromRect`);function yd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Wu(yd,`isPointInPolygon`);function bd(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),xd(t)}Wu(bd,`getHull`);function xd(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Wu(xd,`getHullPresorted`);var Sd=$u,Cd=rd,wd=ad,Td=ld,Ed=dd,Dd=hd,Od=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},kd={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ad=new class{#e=kd;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function jd(e){setTimeout(e,0)}var Md=typeof window>`u`||`Deno`in globalThis;function Nd(){}function Pd(e,t){return typeof e==`function`?e(t):e}function Fd(e){return typeof e==`number`&&e>=0&&e!==1/0}function Id(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ld(e,t){return typeof e==`function`?e(t):e}function Rd(e,t){return typeof e==`function`?e(t):e}function zd(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Vd(o,t.options))return!1}else if(!Ud(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Bd(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Hd(t.options.mutationKey)!==Hd(a))return!1}else if(!Ud(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Vd(e,t){return(t?.queryKeyHashFn||Hd)(e)}function Hd(e){return JSON.stringify(e,(e,t)=>Jd(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Ud(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Ud(e[n],t[n])):!1}var Wd=Object.prototype.hasOwnProperty;function Gd(e,t){if(e===t)return e;let n=qd(e)&&qd(t);if(!n&&!(Jd(e)&&Jd(t)))return t;let r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),a=i.length,o=n?Array(a):{},s=0;for(let c=0;c<a;c++){let a=n?c:i[c],l=e[a],u=t[a];if(l===u){o[a]=l,(n?c<r:Wd.call(e,a))&&s++;continue}if(l===null||u===null||typeof l!=`object`||typeof u!=`object`){o[a]=u;continue}let d=Gd(l,u);o[a]=d,d===l&&s++}return r===a&&s===r?e:o}function Kd(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function qd(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Jd(e){if(!Yd(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Yd(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Yd(e){return Object.prototype.toString.call(e)===`[object Object]`}function Xd(e){return new Promise(t=>{Ad.setTimeout(t,e)})}function Zd(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Gd(e,t)}function Qd(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function $d(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ef=Symbol();function tf(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ef?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function nf(e,t){return typeof e==`function`?e(...t):!!e}var rf=new class extends Od{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!Md&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function af(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var of=jd;function sf(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=of,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var cf=sf(),lf=new class extends Od{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!Md&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function uf(e){return Math.min(1e3*2**e,3e4)}function df(e){return(e??`online`)!==`online`||lf.isOnline()}var ff=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function pf(e){let t=!1,n=0,r,i=af(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ff(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>rf.isFocused()&&(e.networkMode===`always`||lf.isOnline())&&e.canRun(),u=()=>df(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Md?0:3),o=e.retryDelay??uf,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),Xd(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var mf=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Fd(this.gcTime)&&(this.#e=Ad.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Md?1/0:3e5))}clearGcTimeout(){this.#e&&=(Ad.clearTimeout(this.#e),void 0)}},hf=class extends mf{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=_f(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=_f(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=Zd(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(Nd).catch(Nd):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Rd(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ef||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Ld(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Id(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=tf(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=pf({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ff&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ff){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...gf(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:`success`,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),cf.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function gf(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:df(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function _f(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var vf=class extends Od{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=af(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),bf(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return xf(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return xf(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Rd(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Kd(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Sf(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Rd(this.options.enabled,this.#t)!==Rd(t.enabled,this.#t)||Ld(this.options.staleTime,this.#t)!==Ld(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Rd(this.options.enabled,this.#t)!==Rd(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return wf(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`)),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Nd)),t}#g(){this.#b();let e=Ld(this.options.staleTime,this.#t);if(Md||this.#r.isStale||!Fd(e))return;let t=Id(this.#r.dataUpdatedAt,e)+1;this.#d=Ad.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!Md&&Rd(this.options.enabled,this.#t)!==!1&&Fd(this.#p)&&this.#p!==0&&(this.#f=Ad.setInterval(()=>{(this.options.refetchIntervalInBackground||rf.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(Ad.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(Ad.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&bf(e,t),o=i&&Sf(e,n,t,r);(a||o)&&(l={...l,...gf(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Zd(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Zd(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Cf(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Rd(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=e=>{x.status===`error`?e.reject(x.error):x.data!==void 0&&e.resolve(x.data)},r=()=>{let e=this.#o=x.promise=af();t(e)},i=this.#o;switch(i.status){case`pending`:e.queryHash===n.queryHash&&t(i);break;case`fulfilled`:(x.status===`error`||x.data!==i.value)&&r();break;case`rejected`:(x.status!==`error`||x.error!==i.reason)&&r()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Kd(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){cf.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function yf(e,t){return Rd(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||t.retryOnMount!==!1)}function bf(e,t){return yf(e,t)||e.state.data!==void 0&&xf(e,t,t.refetchOnMount)}function xf(e,t,n){if(Rd(t.enabled,e)!==!1&&Ld(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Cf(e,t)}return!1}function Sf(e,t,n,r){return(e!==t||Rd(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Cf(e,n)}function Cf(e,t){return Rd(t.enabled,e)!==!1&&e.isStaleByTime(Ld(t.staleTime,e))}function wf(e,t){return!Kd(e.getCurrentResult(),t)}function Tf(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener(`abort`,()=>{n=!0}),t.signal)})},u=tf(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?$d:Qd;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Df:Ef,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ef(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Ef(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Df(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Of=class extends mf{#e;#t;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||kf(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status===`pending`?this.scheduleGc():this.#t.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#r({type:`continue`})};this.#n=pf({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#r({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#r({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let n=this.state.status===`pending`,r=!this.#n.canStart();try{if(n)t();else{this.#r({type:`pending`,variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#r({type:`pending`,context:t,variables:e,isPaused:r})}let i=await this.#n.start();return await this.#t.config.onSuccess?.(i,e,this.state.context,this),await this.options.onSuccess?.(i,e,this.state.context),await this.#t.config.onSettled?.(i,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(i,null,e,this.state.context),this.#r({type:`success`,data:i}),i}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#r({type:`error`,error:t})}}finally{this.#t.runNext(this)}}#r(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),cf.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:`updated`,action:e})})}};function kf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Af=class extends Od{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Of({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=jf(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=jf(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=jf(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=jf(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){cf.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Bd(t,e))}findAll(e={}){return this.getAll().filter(t=>Bd(e,t))}notify(e){cf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return cf.batch(()=>Promise.all(e.map(e=>e.continue().catch(Nd))))}};function jf(e){return e.options.scope?.id}var Mf=class extends Od{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Kd(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Hd(t.mutationKey)!==Hd(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??kf();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){cf.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context;e?.type===`success`?(this.#r.onSuccess?.(e.data,t,n),this.#r.onSettled?.(e.data,null,t,n)):e?.type===`error`&&(this.#r.onError?.(e.error,t,n),this.#r.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach(e=>{e(this.#t)})})}},Nf=class extends Od{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Vd(r,t),a=this.get(i);return a||(a=new hf({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){cf.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>zd(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>zd(e,t)):t}notify(e){cf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){cf.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){cf.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Pf=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Nf,this.#t=e.mutationCache||new Af,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=rf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=lf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ld(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Pd(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return cf.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;cf.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return cf.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=cf.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Nd).catch(Nd)}invalidateQueries(e,t={}){return cf.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=cf.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Nd)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Nd)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Ld(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Nd).catch(Nd)}fetchInfiniteQuery(e){return e.behavior=Tf(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Nd).catch(Nd)}ensureInfiniteQueryData(e){return e.behavior=Tf(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return lf.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Hd(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Ud(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Hd(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Ud(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Vd(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ef&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Ff=N.createContext(void 0),If=e=>{let t=N.useContext(Ff);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Lf=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(Ff.Provider,{value:e,children:t})),Rf=N.createContext(!1),zf=()=>N.useContext(Rf);Rf.Provider;function Bf(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Vf=N.createContext(Bf()),Hf=()=>N.useContext(Vf),Uf=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Wf=e=>{N.useEffect(()=>{e.clearReset()},[e])},Gf=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||nf(n,[e.error,r])),Kf=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},qf=(e,t)=>e.isLoading&&e.isFetching&&!t,Jf=(e,t)=>e?.suspense&&t.isPending,Yf=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Xf(e,t,n){let r=zf(),i=Hf(),a=If(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Kf(o),Uf(o,i),Wf(i);let s=!a.getQueryCache().get(o.queryHash),[c]=N.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!r&&e.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(e=>{let t=u?c.subscribe(cf.batchCalls(e)):Nd;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(o)},[o,c]),Jf(o,l))throw Yf(o,c,i);if(Gf({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!Md&&qf(l,r)&&(s?Yf(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Nd).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function Zf(e,t){return Xf(e,vf,t)}function Qf(e,t){let n=If(t),[r]=N.useState(()=>new Mf(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(cf.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=N.useCallback((e,t)=>{r.mutate(e,t).catch(Nd)},[r]);if(i.error&&nf(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}Object.freeze({status:`aborted`});function I(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var $f=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ep=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},tp={};function np(e){return e&&Object.assign(tp,e),tp}function rp(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ip(e,t){return typeof t==`bigint`?t.toString():t}function ap(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function op(e){return e==null}function sp(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function cp(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var lp=Symbol(`evaluating`);function up(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==lp)return r===void 0&&(r=lp,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function dp(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function fp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pp(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function mp(e){return JSON.stringify(e)}var hp=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function gp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var _p=ap(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function vp(e){if(gp(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return gp(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function yp(e){return vp(e)?{...e}:Array.isArray(e)?[...e]:e}var bp=new Set([`string`,`number`,`symbol`]);function xp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Sp(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Cp(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var wp={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Tp(e,t){let n=e._zod.def;return Sp(e,pp(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return fp(this,`shape`,e),e},checks:[]}))}function Ep(e,t){let n=e._zod.def;return Sp(e,pp(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return fp(this,`shape`,r),r},checks:[]}))}function Dp(e,t){if(!vp(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return Sp(e,pp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return fp(this,`shape`,n),n},checks:[]}))}function Op(e,t){if(!vp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Sp(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return fp(this,`shape`,n),n},checks:e._zod.def.checks})}function kp(e,t){return Sp(e,pp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return fp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Ap(e,t,n){return Sp(t,pp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return fp(this,`shape`,i),i},checks:[]}))}function jp(e,t,n){return Sp(t,pp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return fp(this,`shape`,i),i},checks:[]}))}function Mp(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Np(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Pp(e){return typeof e==`string`?e:e?.message}function Fp(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Pp(e.inst?._zod.def?.error?.(e))??Pp(t?.error?.(e))??Pp(n.customError?.(e))??Pp(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ip(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Lp(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Rp=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ip,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},zp=I(`$ZodError`,Rp),Bp=I(`$ZodError`,Rp,{Parent:Error});function Vp(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Hp(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var Up=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new $f;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Fp(e,a,np())));throw hp(t,i?.callee),t}return o.value},Wp=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Fp(e,a,np())));throw hp(t,i?.callee),t}return o.value},Gp=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new $f;return a.issues.length?{success:!1,error:new(e??zp)(a.issues.map(e=>Fp(e,i,np())))}:{success:!0,data:a.value}},Kp=Gp(Bp),qp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Fp(e,i,np())))}:{success:!0,data:a.value}},Jp=qp(Bp),Yp=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Up(e)(t,n,i)},Xp=e=>(t,n,r)=>Up(e)(t,n,r),Zp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Wp(e)(t,n,i)},Qp=e=>async(t,n,r)=>Wp(e)(t,n,r),$p=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Gp(e)(t,n,i)},em=e=>(t,n,r)=>Gp(e)(t,n,r),tm=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return qp(e)(t,n,i)},nm=e=>async(t,n,r)=>qp(e)(t,n,r),rm=/^[cC][^\s-]{8,}$/,im=/^[0-9a-z]+$/,am=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,om=/^[0-9a-vA-V]{20}$/,sm=/^[A-Za-z0-9]{27}$/,cm=/^[a-zA-Z0-9_-]{21}$/,lm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,um=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dm=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,fm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,pm=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function mm(){return new RegExp(pm,`u`)}var hm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,gm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_m=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,vm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ym=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bm=/^[A-Za-z0-9_-]*$/,xm=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Sm=/^\+(?:[0-9]){6,14}[0-9]$/,Cm=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,wm=RegExp(`^${Cm}$`);function Tm(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Em(e){return RegExp(`^${Tm(e)}$`)}function Dm(e){let t=Tm({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Cm}T(?:${r})$`)}var Om=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},km=/^-?\d+$/,Am=/^-?\d+(?:\.\d+)?/,jm=/^(?:true|false)$/i,Mm=/^null$/i,Nm=/^[^A-Z]*$/,Pm=/^[^a-z]*$/,Fm=I(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Im={number:`number`,bigint:`bigint`,object:`date`},Lm=I(`$ZodCheckLessThan`,(e,t)=>{Fm.init(e,t);let n=Im[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Rm=I(`$ZodCheckGreaterThan`,(e,t)=>{Fm.init(e,t);let n=Im[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),zm=I(`$ZodCheckMultipleOf`,(e,t)=>{Fm.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):cp(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Bm=I(`$ZodCheckNumberFormat`,(e,t)=>{Fm.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=wp[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=km)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Vm=I(`$ZodCheckMaxLength`,(e,t)=>{var n;Fm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!op(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Ip(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Hm=I(`$ZodCheckMinLength`,(e,t)=>{var n;Fm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!op(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Ip(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Um=I(`$ZodCheckLengthEquals`,(e,t)=>{var n;Fm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!op(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Ip(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Wm=I(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Fm.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Gm=I(`$ZodCheckRegex`,(e,t)=>{Wm.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Km=I(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Nm,Wm.init(e,t)}),qm=I(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Pm,Wm.init(e,t)}),Jm=I(`$ZodCheckIncludes`,(e,t)=>{Fm.init(e,t);let n=xp(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ym=I(`$ZodCheckStartsWith`,(e,t)=>{Fm.init(e,t);let n=RegExp(`^${xp(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Xm=I(`$ZodCheckEndsWith`,(e,t)=>{Fm.init(e,t);let n=RegExp(`.*${xp(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Zm=I(`$ZodCheckOverwrite`,(e,t)=>{Fm.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Qm=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
41
+ `},ni=0,ri=[];function ii(e){var t=N.useRef([]),n=N.useRef([0,0]),r=N.useRef(),i=N.useState(ni++)[0],a=N.useState(Er)[0],o=N.useRef(e);N.useEffect(function(){o.current=e},[e]),N.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=nr([e.lockRef.current],(e.shards||[]).map($r),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=N.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Zr(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Wr(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Wr(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Xr(h,t,e,h===`h`?s:c,!0)},[]),c=N.useCallback(function(e){var n=e;if(ri.length&&ri[ri.length-1]===a){var r=`deltaY`in n?Qr(n):Zr(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&ei(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map($r).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=N.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ai(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=N.useCallback(function(e){n.current=Zr(e),r.current=void 0},[]),d=N.useCallback(function(t){l(t.type,Qr(t),t.target,s(t,e.lockRef.current))},[]),f=N.useCallback(function(t){l(t.type,Zr(t),t.target,s(t,e.lockRef.current))},[]);N.useEffect(function(){return ri.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,zr),document.addEventListener(`touchmove`,c,zr),document.addEventListener(`touchstart`,u,zr),function(){ri=ri.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,zr),document.removeEventListener(`touchmove`,c,zr),document.removeEventListener(`touchstart`,u,zr)}},[]);var p=e.removeScrollBar,m=e.inert;return N.createElement(N.Fragment,null,m?N.createElement(a,{styles:ti(i)}):null,p?N.createElement(Ir,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ai(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var oi=gr(_r,ii),si=N.forwardRef(function(e,t){return N.createElement(yr,er({},e,{ref:t,sideCar:oi}))});si.classNames=yr.classNames;var ci=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},li=new WeakMap,ui=new WeakMap,di={},fi=0,pi=function(e){return e&&(e.host||pi(e.parentNode))},mi=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=pi(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},hi=function(e,t,n,r){var i=mi(t,Array.isArray(e)?e:[e]);di[n]||(di[n]=new WeakMap);var a=di[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(li.get(e)||0)+1,l=(a.get(e)||0)+1;li.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ui.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),fi++,function(){o.forEach(function(e){var t=li.get(e)-1,i=a.get(e)-1;li.set(e,t),a.set(e,i),t||(ui.has(e)||e.removeAttribute(r),ui.delete(e)),i||e.removeAttribute(n)}),fi--,fi||(li=new WeakMap,li=new WeakMap,ui=new WeakMap,di={})}},gi=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||ci(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),hi(r,i,n,`aria-hidden`)):function(){return null}},_i=Object.defineProperty,vi=(e,t)=>_i(e,`name`,{value:t,configurable:!0}),yi=`Dialog`,[bi,xi]=Je(yi),[Si,Ci]=bi(yi),wi=vi(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=N.useRef(null),c=N.useRef(null),[l,u]=Tt({prop:r,defaultProp:i??!1,onChange:a,caller:yi}),[d,f]=N.useState(0),[p,m]=N.useState(0);return(0,P.jsx)(Si,{scope:t,triggerRef:s,contentRef:c,contentId:Ut(),titleId:Ut(),descriptionId:Ut(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:N.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Ti=`DialogTrigger`,Ei=N.forwardRef(vi(function(e,t){let{__scopeDialog:n,...r}=e,i=Ci(Ti,n),a=d(t,i.triggerRef);return(0,P.jsx)(f.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Wi(i.open),...r,ref:a,onClick:F(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),Di=`DialogPortal`,[Oi,ki]=bi(Di,{forceMount:void 0}),Ai=vi(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Ci(Di,t);return(0,P.jsx)(Oi,{scope:t,forceMount:n,children:N.Children.map(r,e=>(0,P.jsx)(Nt,{present:n||a.open,children:(0,P.jsx)(Kn,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),ji=`DialogOverlay`,Mi=N.forwardRef(vi(function(e,t){let n=ki(ji,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ci(ji,e.__scopeDialog);return a.modal?(0,P.jsx)(Nt,{present:r||a.open,children:(0,P.jsx)(Pi,{...i,ref:t})}):null},`DialogOverlay`)),Ni=h(`DialogOverlay.RemoveScroll`),Pi=N.forwardRef(vi(function(e,t){let{__scopeDialog:n,...r}=e,i=Ci(ji,n),a=xn(),o=d(t,a);return(0,P.jsx)(si,{as:Ni,allowPinchZoom:!0,shards:[i.contentRef],children:(0,P.jsx)(f.div,{"data-state":Wi(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Fi=`DialogContent`,Ii=N.forwardRef(vi(function(e,t){let n=ki(Fi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ci(Fi,e.__scopeDialog);return(0,P.jsx)(Nt,{present:r||a.open,children:a.modal?(0,P.jsx)(Li,{...i,ref:t}):(0,P.jsx)(Ri,{...i,ref:t})})},`DialogContent`)),Li=N.forwardRef(vi(function(e,t){let n=Ci(Fi,e.__scopeDialog),r=N.useRef(null),i=d(t,n.contentRef,r);return N.useEffect(()=>{let e=r.current;if(e)return gi(e)},[]),(0,P.jsx)(zi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:F(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Ri=N.forwardRef(vi(function(e,t){let n=Ci(Fi,e.__scopeDialog),r=N.useRef(!1),i=N.useRef(!1);return(0,P.jsx)(zi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),zi=N.forwardRef(vi(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Ci(Fi,n);return Qn(),(0,P.jsx)(P.Fragment,{children:(0,P.jsx)(Mn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,P.jsx)(bn,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Wi(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Bi=`DialogTitle`,Vi=N.forwardRef(vi(function(e,t){let{__scopeDialog:n,...r}=e,i=Ci(Bi,n),{setTitleCount:a}=i;return gt(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,P.jsx)(f.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Hi=`DialogClose`,Ui=N.forwardRef(vi(function(e,t){let{__scopeDialog:n,...r}=e,i=Ci(Hi,n);return(0,P.jsx)(f.button,{type:`button`,...r,ref:t,onClick:F(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Wi(e){return e?`open`:`closed`}vi(Wi,`getState`);var Gi=Object.defineProperty,Ki=(e,t)=>Gi(e,`name`,{value:t,configurable:!0}),qi=`Avatar`,[Ji,Yi]=Je(qi),Xi=[0,()=>void 0],[Zi,Qi]=Ji(qi),$i=N.forwardRef(Ki(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=N.useState(`idle`),[o,s]=oa();return(0,P.jsx)(Zi,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,P.jsx)(f.span,{...r,ref:t})})},`Avatar`)),ea=`AvatarImage`,ta=N.forwardRef(Ki(function(e,t){let{__scopeAvatar:n,src:r,onLoadingStatusChange:i,...a}=e,o=Qi(ea,n);o.setImageCount;let s=ia(r,{referrerPolicy:a.referrerPolicy,crossOrigin:a.crossOrigin,loadingStatus:o.imageLoadingStatus,setLoadingStatus:o.setImageLoadingStatus}),c=fn(e=>{i?.(e)}),l=N.useRef(s);return gt(()=>{let e=l.current;l.current=s,s!==e&&c(s)},[s,c]),s===`loaded`?(0,P.jsx)(f.img,{...a,ref:t,src:r}):null},`AvatarImage`)),na=`AvatarFallback`,ra=N.forwardRef(Ki(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=Qi(na,n),[o,s]=N.useState(r===void 0);return N.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==`loaded`?(0,P.jsx)(f.span,{...i,ref:t}):null},`AvatarFallback`));function ia(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return gt(()=>{if(!e){n(`error`);return}let t=new window.Image,a=Ki(e=>{let t=e.currentTarget;n(aa(t))},`handleLoad`),o=Ki(()=>n(`error`),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n(aa(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(`idle`)}},[e,i,r,n]),t}Ki(ia,`useImageLoadingStatus`);function aa(e){return e.complete?e.naturalWidth>0?`loaded`:`error`:`loading`}Ki(aa,`getImageLoadingStatus`);function oa(){return Xi}Ki(oa,`useImageCount`);function sa(e){}Ki(sa,`useUpdateImageCount`);var ca=Object.defineProperty,la=(e,t)=>ca(e,`name`,{value:t,configurable:!0});function ua(e){let[t,n]=N.useState(void 0);return gt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}la(ua,`useSize`);var da=[`top`,`right`,`bottom`,`left`],fa=Math.min,pa=Math.max,ma=Math.round,ha=Math.floor,ga=e=>({x:e,y:e}),_a={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function va(e,t,n){return pa(e,fa(t,n))}function ya(e,t){return typeof e==`function`?e(t):e}function ba(e){return e.split(`-`)[0]}function xa(e){return e.split(`-`)[1]}function Sa(e){return e===`x`?`y`:`x`}function Ca(e){return e===`y`?`height`:`width`}function wa(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Ta(e){return Sa(wa(e))}function Ea(e,t,n){n===void 0&&(n=!1);let r=xa(e),i=Ta(e),a=Ca(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Fa(o)),[o,Fa(o)]}function Da(e){let t=Fa(e);return[Oa(e),t,Oa(t)]}function Oa(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ka=[`left`,`right`],Aa=[`right`,`left`],ja=[`top`,`bottom`],Ma=[`bottom`,`top`];function Na(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Aa:ka:t?ka:Aa;case`left`:case`right`:return t?ja:Ma;default:return[]}}function Pa(e,t,n,r){let i=xa(e),a=Na(ba(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Oa)))),a}function Fa(e){let t=ba(e);return _a[t]+e.slice(t.length)}function Ia(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function La(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ia(e)}function Ra(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function za(e,t,n){let{reference:r,floating:i}=e,a=wa(t),o=Ta(t),s=Ca(o),c=ba(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=xa(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Ba(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ya(t,e),p=La(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Ra(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Ra(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Va=50,Ha=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ba},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=za(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Va&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=za(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ua=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ya(e,t)||{};if(l==null)return{};let d=La(u),f={x:n,y:r},p=Ta(i),m=Ca(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=fa(d[_],T),D=fa(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=va(E,k,O),j=!c.arrow&&xa(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Wa=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ya(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=ba(r),_=wa(o),v=ba(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Fa(o)]:Da(o)),x=p!==`none`;!d&&x&&b.push(...Pa(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Ea(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===wa(t)||T.every(e=>wa(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=wa(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Ga(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ka(e){return da.some(t=>e[t]>=0)}var qa=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=ya(e,t);switch(i){case`referenceHidden`:{let e=Ga(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ka(e)}}}case`escaped`:{let e=Ga(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ka(e)}}}default:return{}}}}},Ja=new Set([`left`,`top`]);async function Ya(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ba(n),s=xa(n),c=wa(n)===`y`,l=Ja.has(o)?-1:1,u=a&&c?-1:1,d=ya(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Xa=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Ya(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Za=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ya(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=wa(i),p=Sa(f),m=u[p],h=u[f],g=(e,t)=>va(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Qa=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ya(e,t),u={x:n,y:r},d=wa(i),f=Sa(d),p=u[f],m=u[d],h=ya(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ja.has(ba(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},$a=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=ya(e,t),c=await i.detectOverflow(t,s),l=ba(n),u=xa(n),d=wa(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=fa(p-c[m],g),y=fa(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*pa(c.left,c.right):S=p-2*pa(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function eo(){return typeof window<`u`}function to(e){return io(e)?(e.nodeName||``).toLowerCase():`#document`}function no(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ro(e){return((io(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function io(e){return eo()?e instanceof Node||e instanceof no(e).Node:!1}function ao(e){return eo()?e instanceof Element||e instanceof no(e).Element:!1}function oo(e){return eo()?e instanceof HTMLElement||e instanceof no(e).HTMLElement:!1}function so(e){return!eo()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof no(e).ShadowRoot}function co(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=bo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function lo(e){return/^(table|td|th)$/.test(to(e))}function uo(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var fo=/transform|translate|scale|rotate|perspective|filter/,po=/paint|layout|strict|content/,mo=e=>!!e&&e!==`none`,ho;function go(e){let t=ao(e)?bo(e):e;return mo(t.transform)||mo(t.translate)||mo(t.scale)||mo(t.rotate)||mo(t.perspective)||!vo()&&(mo(t.backdropFilter)||mo(t.filter))||fo.test(t.willChange||``)||po.test(t.contain||``)}function _o(e){let t=So(e);for(;oo(t)&&!yo(t);){if(go(t))return t;if(uo(t))return null;t=So(t)}return null}function vo(){return ho??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ho}function yo(e){return/^(html|body|#document)$/.test(to(e))}function bo(e){return no(e).getComputedStyle(e)}function xo(e){return ao(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function So(e){if(to(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||so(e)&&e.host||ro(e);return so(t)?t.host:t}function Co(e){let t=So(e);return yo(t)?(e.ownerDocument||e).body:oo(t)&&co(t)?t:Co(t)}function wo(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Co(e),i=r===e.ownerDocument?.body,a=no(r);if(i){let e=To(a);return t.concat(a,a.visualViewport||[],co(r)?r:[],e&&n?wo(e):[])}return t.concat(r,wo(r,[],n))}function To(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Eo(e){let t=bo(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=oo(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ma(n)!==a||ma(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Do(e){return ao(e)?e:e.contextElement}function Oo(e){let t=Do(e);if(!oo(t))return ga(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Eo(t),o=(a?ma(n.width):n.width)/r,s=(a?ma(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ko=ga(0);function Ao(e){let t=no(e);return!vo()||!t.visualViewport?ko:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jo(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===no(e)}function Mo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Do(e),o=ga(1);t&&(r?ao(r)&&(o=Oo(r)):o=Oo(e));let s=jo(a,n,r)?Ao(a):ga(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=no(a),t=ao(r)?no(r):r,n=e,i=To(n);for(;i&&t!==n;){let e=Oo(i),t=i.getBoundingClientRect(),r=bo(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=no(i),i=To(n)}}return Ra({width:u,height:d,x:c,y:l})}function No(e,t){let n=xo(e).scrollLeft;return t?t.left+n:Mo(ro(e)).left+n}function Po(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-No(e,n),y:n.top+t.scrollTop}}function Fo(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ro(r),s=t?uo(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=ga(1),u=ga(0),d=oo(r);if((d||!a)&&((to(r)!==`body`||co(o))&&(c=xo(r)),d)){let e=Mo(r);l=Oo(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Po(o,c):ga(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Io(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Lo(e){let t=xo(e),n=e.ownerDocument.body,r=pa(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=pa(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+No(e),o=-t.scrollTop;return bo(n).direction===`rtl`&&(a+=pa(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Ro=25;function zo(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=no(e),a=ro(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!vo()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(No(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Ro&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Bo(e,t){let n=Mo(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Oo(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Vo(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=zo(e,n,t);else if(t===`document`)r=Lo(ro(e));else if(ao(t))r=Bo(t,n);else{let n=Ao(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ra(r)}function Ho(e,t){let n=t.get(e);if(n)return n;let r=wo(e,[],!1).filter(e=>ao(e)&&to(e)!==`body`),i=null,a=bo(e).position===`fixed`,o=a?So(e):e;for(;ao(o)&&!yo(o);){let e=bo(o),t=go(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=So(o)}return t.set(e,r),r}function Uo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?uo(t)?[]:Ho(t,this._c):[].concat(n),r],o=Vo(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Vo(t,a[e],i);s=pa(n.top,s),c=fa(n.right,c),l=fa(n.bottom,l),u=pa(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Wo(e){let{width:t,height:n}=Eo(e);return{width:t,height:n}}function Go(e,t,n){let r=oo(t),i=ro(t),a=n===`fixed`,o=Mo(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=ga(0);if((r||!a)&&((to(t)!==`body`||co(i))&&(s=xo(t)),r)){let e=Mo(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=No(i));let l=i&&!r&&!a?Po(i,s):ga(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Ko(e){return bo(e).position===`static`}function qo(e,t){if(!oo(e)||bo(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ro(e)===n&&(n=n.ownerDocument.body),n}function Jo(e,t){let n=no(e);if(uo(e))return n;if(!oo(e)){let t=So(e);for(;t&&!yo(t);){if(ao(t)&&!Ko(t))return t;t=So(t)}return n}let r=qo(e,t);for(;r&&lo(r)&&Ko(r);)r=qo(r,t);return r&&yo(r)&&Ko(r)&&!go(r)?n:r||_o(e)||n}var Yo=async function(e){let t=this.getOffsetParent||Jo,n=this.getDimensions,r=await n(e.floating);return{reference:Go(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xo(e){return bo(e).direction===`rtl`}var Zo={convertOffsetParentRelativeRectToViewportRelativeRect:Fo,getDocumentElement:ro,getClippingRect:Uo,getOffsetParent:Jo,getElementRects:Yo,getClientRects:Io,getDimensions:Wo,getScale:Oo,isElement:ao,isRTL:Xo};function Qo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $o(e,t,n){let r=null,i,a=ro(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=ha(d),h=ha(a.clientWidth-(u+f)),g=ha(a.clientHeight-(d+p)),_=ha(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:pa(0,fa(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Qo(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=no(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function es(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Do(e),u=i||a?[...l?wo(l):[],...t?wo(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?$o(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Mo(e):null;c&&g();function g(){let t=Mo(e);h&&!Qo(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ts=Xa,ns=Za,rs=Wa,is=$a,as=qa,os=Ua,ss=Qa,cs=(e,t,n)=>{let r=new Map,i=n??{},a={...Zo,...i.platform,_c:r};return Ha(e,t,{...i,platform:a})},ls=typeof document<`u`?N.useLayoutEffect:function(){};function us(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,i;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(!us(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!us(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ds(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fs(e,t){let n=ds(e);return Math.round(t*n)/n}function ps(e){let t=N.useRef(e);return ls(()=>{t.current=e}),t}function ms(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=N.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=N.useState(r);us(f,r)||p(r);let[m,h]=N.useState(null),[g,_]=N.useState(null),v=N.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=N.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=N.useRef(null),C=N.useRef(null),w=N.useRef(u),T=c!=null,E=ps(c),D=ps(i),O=ps(l),k=N.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),cs(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!us(w.current,t)&&(w.current=t,Wn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);ls(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=N.useRef(!1);ls(()=>(A.current=!0,()=>{A.current=!1}),[]),ls(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=N.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=N.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=N.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=fs(M.floating,u.x),r=fs(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ds(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return N.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:ee}),[u,k,j,M,ee])}var hs=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:os({element:r.current,padding:i}).fn(n):r?os({element:r,padding:i}).fn(n):{}}}},gs=(e,t)=>{let n=ts(e);return{name:n.name,fn:n.fn,options:[e,t]}},_s=(e,t)=>{let n=ns(e);return{name:n.name,fn:n.fn,options:[e,t]}},vs=(e,t)=>({fn:ss(e).fn,options:[e,t]}),ys=(e,t)=>{let n=rs(e);return{name:n.name,fn:n.fn,options:[e,t]}},bs=(e,t)=>{let n=is(e);return{name:n.name,fn:n.fn,options:[e,t]}},xs=(e,t)=>{let n=as(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ss=(e,t)=>{let n=hs(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cs=Object.defineProperty,ws=N.forwardRef(((e,t)=>Cs(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,P.jsx)(f.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,P.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),Ts=Object.defineProperty,Es=(e,t)=>Ts(e,`name`,{value:t,configurable:!0}),Ds=`Popper`,[Os,ks]=Je(Ds),[As,js]=Os(Ds),Ms=Es(e=>{let{__scopePopper:t,children:n}=e,[r,i]=N.useState(null),[a,o]=N.useState(void 0);return(0,P.jsx)(As,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Ns=`PopperAnchor`,Ps=N.forwardRef(Es(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=js(Ns,n),o=N.useRef(null),s=a.onAnchorChange,c=N.useCallback(e=>{o.current=e,e&&s(e)},[s]),l=d(t,c),u=N.useRef(null);N.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&s(u.current)});let p=a.placementState&&Ws(a.placementState),m=p?.[0],h=p?.[1];return r?null:(0,P.jsx)(f.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...i,ref:l})},`PopperAnchor`)),Fs=`PopperContent`,[Is,Ls]=Os(Fs),Rs=N.forwardRef(Es(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:p=`partial`,hideWhenDetached:m=!1,updatePositionStrategy:h=`optimized`,onPlaced:g,..._}=e,v=js(Fs,n),[y,b]=N.useState(null),x=d(t,b),[S,C]=N.useState(null),w=ua(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],A=k.length>0,j={padding:O,boundary:k.filter(Hs),altBoundary:A},{refs:M,floatingStyles:ee,placement:te,isPositioned:ne,middlewareData:re}=ms({strategy:`fixed`,placement:D,whileElementsMounted:Es((...e)=>es(...e,{animationFrame:h===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[gs({mainAxis:i+E,alignmentAxis:o}),c&&_s({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?vs():void 0,...j}),c&&ys({...j}),bs({...j,apply:Es(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&Ss({element:S,padding:s}),Us({arrowWidth:T,arrowHeight:E}),m&&xs({strategy:`referenceHidden`,...j,boundary:A?j.boundary:void 0})]}),ie=v.setPlacementState;gt(()=>(ie(te),()=>{ie(void 0)}),[te,ie]);let[ae,oe]=Ws(te),se=fn(g);gt(()=>{ne&&se?.()},[ne,se]);let ce=re.arrow?.x,le=re.arrow?.y,ue=re.arrow?.centerOffset!==0,[de,fe]=N.useState();return gt(()=>{y&&fe(window.getComputedStyle(y).zIndex)},[y]),(0,P.jsx)(`div`,{ref:M.setFloating,"data-radix-popper-content-wrapper":``,style:{...ee,transform:ne?ee.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:de,"--radix-popper-transform-origin":[re.transformOrigin?.x,re.transformOrigin?.y].join(` `),...re.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,P.jsx)(Is,{scope:n,placedSide:ae,placedAlign:oe,onArrowChange:C,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,P.jsx)(f.div,{"data-side":ae,"data-align":oe,..._,ref:x,style:{..._.style,animation:ne?_.style?.animation:`none`}})})})},`PopperContent`)),zs=`PopperArrow`,Bs={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Vs=N.forwardRef(Es(function(e,t){let{__scopePopper:n,...r}=e,i=Ls(zs,n),a=Bs[i.placedSide];return(0,P.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,P.jsx)(ws,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function Hs(e){return e!==null}Es(Hs,`isNotNull`);var Us=Es(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Ws(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Ws(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Es(Ws,`getSideAndAlignFromPlacement`);var Gs=Ms,Ks=Ps,qs=Rs,Js=Vs,Ys=Object.defineProperty,Xs=(e,t)=>Ys(e,`name`,{value:t,configurable:!0}),Zs=!1;function Qs(){let[e,t]=N.useState(Zs);return N.useEffect(()=>{Zs||(Zs=!0,t(!0))},[]),e}Xs(Qs,`useIsHydrated`);var $s=N.useSyncExternalStore;function ec(){return()=>{}}Xs(ec,`subscribe`);function tc(){return $s(ec,()=>!0,()=>!1)}Xs(tc,`useIsHydratedModern`);var nc=typeof $s==`function`?tc:Qs,rc=Object.defineProperty,ic=(e,t)=>rc(e,`name`,{value:t,configurable:!0}),ac=`rovingFocusGroup.onEntryFocus`,oc={bubbles:!1,cancelable:!0},sc=`RovingFocusGroup`,[cc,lc,uc]=Qe(sc),[dc,fc]=Je(sc,[uc]),[pc,mc]=dc(sc),hc=N.forwardRef(ic(function(e,t){return(0,P.jsx)(cc.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(cc.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(gc,{...e,ref:t})})})},`RovingFocusGroup`)),gc=N.forwardRef(ic(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...p}=e,m=N.useRef(null),h=d(t,m),g=ln(a),[_,v]=Tt({prop:o,defaultProp:s??null,onChange:c,caller:sc}),[y,b]=N.useState(!1),x=fn(l),S=lc(n),C=N.useRef(!1),[w,T]=N.useState(0);return N.useEffect(()=>{let e=m.current;if(e)return e.addEventListener(ac,x),()=>e.removeEventListener(ac,x)},[x]),(0,P.jsx)(pc,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:N.useCallback(e=>v(e),[v]),onItemShiftTab:N.useCallback(()=>b(!0),[]),onFocusableItemAdd:N.useCallback(()=>T(e=>e+1),[]),onFocusableItemRemove:N.useCallback(()=>T(e=>e-1),[]),children:(0,P.jsx)(f.div,{tabIndex:y||w===0?-1:0,"data-orientation":r,...p,ref:h,style:{outline:`none`,...e.style},onMouseDown:F(e.onMouseDown,()=>{C.current=!0}),onFocus:F(e.onFocus,e=>{let t=!C.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(ac,oc);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);Sc([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),u)}}C.current=!1}),onBlur:F(e.onBlur,()=>b(!1))})})},`RovingFocusGroupImpl`)),_c=`RovingFocusGroupItem`,vc=N.forwardRef(ic(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Ut(),l=a||c,u=mc(_c,n),d=u.currentTabStopId===l,p=lc(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=u,_=nc();return gt(()=>{if(_&&r)return m(),()=>h()},[_,r,m,h]),N.useEffect(()=>{if(!_&&r)return m(),()=>h()},[_,r,m,h]),(0,P.jsx)(cc.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,P.jsx)(f.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:F(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:F(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:F(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=xc(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Cc(n,r+1):n.slice(r+1)}setTimeout(()=>Sc(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),yc={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function bc(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}ic(bc,`getDirectionAwareKey`);function xc(e,t,n){let r=bc(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return yc[r]}ic(xc,`getFocusIntent`);function Sc(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}ic(Sc,`focusFirst`);function Cc(e,t){return e.map((n,r)=>e[(t+r)%e.length])}ic(Cc,`wrapArray`);var wc=hc,Tc=vc,Ec=Object.defineProperty,Dc=(e,t)=>Ec(e,`name`,{value:t,configurable:!0}),Oc=[`Enter`,` `],kc=[`ArrowDown`,`PageUp`,`Home`],Ac=[`ArrowUp`,`PageDown`,`End`],jc=[...kc,...Ac],Mc={ltr:[...Oc,`ArrowRight`],rtl:[...Oc,`ArrowLeft`]},Nc={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Pc=`Menu`,[Fc,Ic,Lc]=Qe(Pc),[Rc,zc]=Je(Pc,[Lc,ks,fc]),Bc=ks(),Vc=fc(),[Hc,Uc]=Rc(Pc),[Wc,Gc]=Rc(Pc),Kc=Dc(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Bc(t),[c,l]=N.useState(null),u=N.useRef(!1),d=fn(a),f=ln(i);return N.useEffect(()=>{let e=Dc(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Dc(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),N.useEffect(()=>{if(!n)return;let e=Dc(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,P.jsx)(Gs,{...s,children:(0,P.jsx)(Hc,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,P.jsx)(Wc,{scope:t,onClose:N.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),qc=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,...r}=e,i=Bc(n);return(0,P.jsx)(Ks,{...i,...r,ref:t})},`MenuAnchor`)),Jc=`MenuPortal`,[Yc,Xc]=Rc(Jc,{forceMount:void 0}),Zc=Dc(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Uc(Jc,t);return(0,P.jsx)(Yc,{scope:t,forceMount:n,children:(0,P.jsx)(Nt,{present:n||a.open,children:(0,P.jsx)(Kn,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Qc=`MenuContent`,[$c,el]=Rc(Qc),tl=N.forwardRef(Dc(function(e,t){let n=Xc(Qc,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Uc(Qc,e.__scopeMenu),o=Gc(Qc,e.__scopeMenu);return(0,P.jsx)(Fc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(Nt,{present:r||a.open,children:(0,P.jsx)(Fc.Slot,{scope:e.__scopeMenu,children:o.modal?(0,P.jsx)(nl,{...i,ref:t}):(0,P.jsx)(rl,{...i,ref:t})})})})},`MenuContent`)),nl=N.forwardRef(Dc(function(e,t){let n=Uc(Qc,e.__scopeMenu),r=N.useRef(null),i=d(t,r);return N.useEffect(()=>{let e=r.current;if(e)return gi(e)},[]),(0,P.jsx)(al,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),rl=N.forwardRef(Dc(function(e,t){let n=Uc(Qc,e.__scopeMenu);return(0,P.jsx)(al,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),il=h(`MenuContent.ScrollLock`),al=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=Uc(Qc,n),v=Gc(Qc,n),y=Bc(n),b=Vc(n),x=Ic(n),[S,C]=N.useState(null),w=N.useRef(null),T=d(t,w,_.onContentChange),E=N.useRef(0),D=N.useRef(``),O=N.useRef(0),k=N.useRef(null),A=N.useRef(`right`),j=N.useRef(0),M=h?si:N.Fragment,ee=h?{as:il,allowPinchZoom:!0}:void 0,te=Dc(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Ll(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;Dc((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);N.useEffect(()=>()=>window.clearTimeout(E.current),[]),Qn();let ne=N.useCallback(e=>A.current===k.current?.side&&zl(e,k.current?.area),[]);return(0,P.jsx)($c,{scope:n,searchRef:D,onItemEnter:N.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),onItemLeave:N.useCallback(e=>{ne(e)||(w.current?.focus(),C(null))},[ne]),onTriggerLeave:N.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),pointerGraceTimerRef:O,onPointerGraceIntentChange:N.useCallback(e=>{k.current=e},[]),children:(0,P.jsx)(M,{...ee,children:(0,P.jsx)(Mn,{asChild:!0,trapped:i,onMountAutoFocus:F(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,P.jsx)(bn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,P.jsx)(wc,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:F(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,P.jsx)(qs,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ml(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:F(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&te(e.key));let i=w.current;if(e.target!==i||!jc.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);Ac.includes(e.key)&&a.reverse(),Fl(a)}),onBlur:F(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:F(e.onPointerMove,Bl(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),ol=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`group`,...r,ref:t})},`MenuGroup`)),sl=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{...r,ref:t})},`MenuLabel`)),cl=`MenuItem`,ll=`menu.itemSelect`,ul=N.forwardRef(Dc(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=N.useRef(null),o=Gc(cl,e.__scopeMenu),s=el(cl,e.__scopeMenu),c=d(t,a),l=N.useRef(!1),u=Dc(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(ll,{bubbles:!0,cancelable:!0});e.addEventListener(ll,e=>r?.(e),{once:!0}),v(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,P.jsx)(dl,{...i,ref:c,disabled:n,onClick:F(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:F(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:F(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Oc.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),dl=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=el(cl,n),s=Vc(n),c=N.useRef(null),l=d(t,c),[u,p]=N.useState(!1),[m,h]=N.useState(``);return N.useEffect(()=>{let e=c.current;e&&h((e.textContent??``).trim())},[a.children]),(0,P.jsx)(Fc.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,P.jsx)(Tc,{asChild:!0,...s,focusable:!r,children:(0,P.jsx)(f.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:F(e.onPointerMove,Bl(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,Bl(e=>o.onItemLeave(e))),onFocus:F(e.onFocus,()=>p(!0)),onBlur:F(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),fl=N.forwardRef(Dc(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,P.jsx)(yl,{scope:e.__scopeMenu,checked:n,children:(0,P.jsx)(ul,{role:`menuitemcheckbox`,"aria-checked":Nl(n)?`mixed`:n,...i,ref:t,"data-state":Pl(n),onSelect:F(i.onSelect,()=>r?.(Nl(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[pl,ml]=Rc(`MenuRadioGroup`,{value:void 0,onValueChange:Dc(()=>{},`onValueChange`)}),hl=N.forwardRef(Dc(function(e,t){let{value:n,onValueChange:r,...i}=e,a=fn(r);return(0,P.jsx)(pl,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,P.jsx)(ol,{...i,ref:t})})},`MenuRadioGroup`)),gl=`MenuRadioItem`,_l=N.forwardRef(Dc(function(e,t){let{value:n,...r}=e,i=ml(gl,e.__scopeMenu),a=n===i.value;return(0,P.jsx)(yl,{scope:e.__scopeMenu,checked:a,children:(0,P.jsx)(ul,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Pl(a),onSelect:F(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),vl=`MenuItemIndicator`,[yl,bl]=Rc(vl,{checked:!1}),xl=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=bl(vl,n);return(0,P.jsx)(Nt,{present:r||Nl(a.checked)||a.checked===!0,children:(0,P.jsx)(f.span,{...i,ref:t,"data-state":Pl(a.checked)})})},`MenuItemIndicator`)),Sl=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),Cl=N.forwardRef(Dc(function(e,t){let{__scopeMenu:n,...r}=e,i=Bc(n);return(0,P.jsx)(Js,{...i,...r,ref:t})},`MenuArrow`)),wl=`MenuSub`,[Tl,El]=Rc(wl),Dl=Dc(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Uc(wl,t),o=Bc(t),[s,c]=N.useState(null),[l,u]=N.useState(null),d=fn(i);return N.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,P.jsx)(Gs,{...o,children:(0,P.jsx)(Hc,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,P.jsx)(Tl,{scope:t,contentId:Ut(),triggerId:Ut(),trigger:s,onTriggerChange:c,children:n})})})},`MenuSub`),Ol=`MenuSubTrigger`,kl=N.forwardRef(Dc(function(e,t){let n=Uc(Ol,e.__scopeMenu),r=Gc(Ol,e.__scopeMenu),i=El(Ol,e.__scopeMenu),a=el(Ol,e.__scopeMenu),o=N.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=N.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);N.useEffect(()=>u,[u]),N.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let f=d(t,i.onTriggerChange);return(0,P.jsx)(qc,{asChild:!0,...l,children:(0,P.jsx)(dl,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":Ml(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,Bl(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:F(e.onPointerLeave,Bl(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:F(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&Mc[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),Al=`MenuSubContent`,jl=N.forwardRef(Dc(function(e,t){let n=Xc(Qc,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Uc(Qc,e.__scopeMenu),s=Gc(Qc,e.__scopeMenu),c=El(Al,e.__scopeMenu),l=N.useRef(null),u=d(t,l);return(0,P.jsx)(Fc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(Nt,{present:r||o.open,children:(0,P.jsx)(Fc.Slot,{scope:e.__scopeMenu,children:(0,P.jsx)(al,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:F(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:F(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Nc[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function Ml(e){return e?`open`:`closed`}Dc(Ml,`getOpenState`);function Nl(e){return e===`indeterminate`}Dc(Nl,`isIndeterminate`);function Pl(e){return Nl(e)?`indeterminate`:e?`checked`:`unchecked`}Dc(Pl,`getCheckedState`);function Fl(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Dc(Fl,`focusFirst`);function Il(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Dc(Il,`wrapArray`);function Ll(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Il(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Dc(Ll,`getNextMatch`);function Rl(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Dc(Rl,`isPointInPolygon`);function zl(e,t){return t?Rl({x:e.clientX,y:e.clientY},t):!1}Dc(zl,`isPointerInGraceArea`);function Bl(e){return t=>t.pointerType===`mouse`?e(t):void 0}Dc(Bl,`whenMouse`);var Vl=Kc,Hl=qc,Ul=Zc,Wl=tl,Gl=ol,Kl=sl,ql=ul,Jl=fl,Yl=hl,Xl=_l,Zl=xl,Ql=Sl,$l=Cl,eu=Dl,tu=kl,nu=jl,ru=e({Arrow:()=>Hu,CheckboxItem:()=>Lu,Content:()=>Nu,DropdownMenu:()=>fu,DropdownMenuArrow:()=>Eu,DropdownMenuCheckboxItem:()=>xu,DropdownMenuContent:()=>_u,DropdownMenuGroup:()=>vu,DropdownMenuItem:()=>bu,DropdownMenuItemIndicator:()=>wu,DropdownMenuLabel:()=>yu,DropdownMenuPortal:()=>hu,DropdownMenuRadioGroup:()=>Su,DropdownMenuRadioItem:()=>Cu,DropdownMenuSeparator:()=>Tu,DropdownMenuSub:()=>Du,DropdownMenuSubContent:()=>ku,DropdownMenuSubTrigger:()=>Ou,DropdownMenuTrigger:()=>mu,Group:()=>Pu,Item:()=>Iu,ItemIndicator:()=>Bu,Label:()=>Fu,Portal:()=>Mu,RadioGroup:()=>Ru,RadioItem:()=>zu,Root:()=>Au,Separator:()=>Vu,Sub:()=>Uu,SubContent:()=>Gu,SubTrigger:()=>Wu,Trigger:()=>ju,createDropdownMenuScope:()=>cu}),iu=Object.defineProperty,au=(e,t)=>iu(e,`name`,{value:t,configurable:!0}),ou=`DropdownMenu`,[su,cu]=Je(ou,[zc]),lu=zc(),[uu,du]=su(ou),fu=au(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=lu(t),l=N.useRef(null),[u,d]=Tt({prop:i,defaultProp:a??!1,onChange:o,caller:ou});return(0,P.jsx)(uu,{scope:t,triggerId:Ut(),triggerRef:l,contentId:Ut(),open:u,onOpenChange:d,onOpenToggle:N.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,P.jsx)(Vl,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),pu=`DropdownMenuTrigger`,mu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=du(pu,n),o=lu(n),s=d(t,a.triggerRef);return(0,P.jsx)(Hl,{asChild:!0,...o,children:(0,P.jsx)(f.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:F(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:F(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),hu=au(e=>{let{__scopeDropdownMenu:t,...n}=e,r=lu(t);return(0,P.jsx)(Ul,{...r,...n})},`DropdownMenuPortal`),gu=`DropdownMenuContent`,_u=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=du(gu,n),a=lu(n),o=N.useRef(!1);return(0,P.jsx)(Wl,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:F(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),vu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(Gl,{...i,...r,ref:t})},`DropdownMenuGroup`)),yu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(Kl,{...i,...r,ref:t})},`DropdownMenuLabel`)),bu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(ql,{...i,...r,ref:t})},`DropdownMenuItem`)),xu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(Jl,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),Su=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(Yl,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),Cu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(Xl,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),wu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(Zl,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),Tu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(Ql,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Eu=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)($l,{...i,...r,ref:t})},`DropdownMenuArrow`)),Du=au(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=lu(t),[s,c]=Tt({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,P.jsx)(eu,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),Ou=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(tu,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),ku=N.forwardRef(au(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=lu(n);return(0,P.jsx)(nu,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),Au=fu,ju=mu,Mu=hu,Nu=_u,Pu=vu,Fu=yu,Iu=bu,Lu=xu,Ru=Su,zu=Cu,Bu=wu,Vu=Tu,Hu=Eu,Uu=Du,Wu=Ou,Gu=ku,Ku=Object.defineProperty,qu=(e,t)=>Ku(e,`name`,{value:t,configurable:!0}),[Ju,Yu]=Je(`Tooltip`,[ks]),Xu=ks(),Zu=`TooltipProvider`,Qu=700,$u=`tooltip.open`,[ed,td]=Ju(Zu),nd=qu(e=>{let{__scopeTooltip:t,delayDuration:n=Qu,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=N.useRef(!0),s=N.useRef(!1),c=N.useRef(0);return N.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,P.jsx)(ed,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:N.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:N.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:N.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),rd=`Tooltip`,[id,ad]=Ju(rd),od=qu(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=td(rd,e.__scopeTooltip),l=Xu(t),[u,d]=N.useState(null),[f,p]=N.useState(void 0),m=Ut(),h=N.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=N.useRef(!1),[y,b]=Tt({prop:r,defaultProp:i??!1,onChange:qu(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent($u))):c.onClose(),a?.(e)},`onChange`),caller:rd}),x=N.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=N.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);N.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,P.jsx)(Gs,{...l,children:(0,P.jsx)(id,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:N.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:N.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),sd=`TooltipTrigger`,cd=N.forwardRef(qu(function(e,t){let{__scopeTooltip:n,...r}=e,i=ad(sd,n),a=td(sd,n),o=Xu(n),s=N.useRef(null),c=d(t,s,i.onTriggerChange),l=N.useRef(!1),u=N.useRef(!1),p=N.useCallback(()=>l.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener(`pointerup`,p),[p]),(0,P.jsx)(Ks,{asChild:!0,...o,children:(0,P.jsx)(f.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:F(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:F(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:F(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener(`pointerup`,p,{once:!0})}),onFocus:F(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:F(e.onBlur,i.onClose),onClick:F(e.onClick,i.onClose)})})},`TooltipTrigger`)),ld=`TooltipPortal`,[ud,dd]=Ju(ld,{forceMount:void 0}),fd=qu(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=ad(ld,t);return(0,P.jsx)(ud,{scope:t,forceMount:n,children:(0,P.jsx)(Nt,{present:n||a.open,children:(0,P.jsx)(Kn,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),pd=`TooltipContent`,md=N.forwardRef(qu(function(e,t){let n=dd(pd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=ad(pd,e.__scopeTooltip);return(0,P.jsx)(Nt,{present:r||o.open,children:o.disableHoverableContent?(0,P.jsx)(_d,{side:i,...a,ref:t}):(0,P.jsx)(hd,{side:i,...a,ref:t})})},`TooltipContent`)),hd=N.forwardRef(qu(function(e,t){let n=ad(pd,e.__scopeTooltip),r=td(pd,e.__scopeTooltip),i=N.useRef(null),a=d(t,i),[o,s]=N.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:f}=r,p=N.useCallback(()=>{s(null),f(!1)},[f]),m=N.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=bd(r,yd(r,n.getBoundingClientRect())),a=xd(t.getBoundingClientRect()),o=Cd([...i,...a]);s(o),f(!0)},[f]);return N.useEffect(()=>()=>p(),[p]),N.useEffect(()=>{if(c&&u){let e=qu(e=>m(e,u),`handleTriggerLeave`),t=qu(e=>m(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,p]),N.useEffect(()=>{if(o){let e=qu(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Sd(n,o);r?p():i&&(p(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,p]),(0,P.jsx)(_d,{...e,ref:a})},`TooltipContentHoverable`)),gd=p(`TooltipContent`),_d=N.forwardRef(qu(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=ad(pd,n),u=Xu(n),{onClose:d}=l;N.useEffect(()=>(document.addEventListener($u,d),()=>document.removeEventListener($u,d)),[d]),N.useEffect(()=>{if(l.trigger){let e=qu(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return gt(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,P.jsx)(bn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,P.jsxs)(qs,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.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:[(0,P.jsx)(gd,{children:r}),i?(0,P.jsx)(We,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),vd=N.forwardRef(qu(function(e,t){let{__scopeTooltip:n,...r}=e,i=Xu(n);return(0,P.jsx)(Js,{...i,...r,ref:t})},`TooltipArrow`));function yd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}qu(yd,`getExitSideFromRect`);function bd(e,t,n=5){let 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})}return r}qu(bd,`getPaddedExitPoints`);function xd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}qu(xd,`getPointsFromRect`);function Sd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}qu(Sd,`isPointInPolygon`);function Cd(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),wd(t)}qu(Cd,`getHull`);function wd(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}qu(wd,`getHullPresorted`);var Td=nd,Ed=od,Dd=cd,Od=fd,kd=md,Ad=vd,jd=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Md={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Nd=new class{#e=Md;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Pd(e){setTimeout(e,0)}var Fd=typeof window>`u`||`Deno`in globalThis;function Id(){}function Ld(e,t){return typeof e==`function`?e(t):e}function Rd(e){return typeof e==`number`&&e>=0&&e!==1/0}function zd(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Bd(e,t){return typeof e==`function`?e(t):e}function Vd(e,t){return typeof e==`function`?e(t):e}function Hd(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Wd(o,t.options))return!1}else if(!Kd(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Ud(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Gd(t.options.mutationKey)!==Gd(a))return!1}else if(!Kd(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Wd(e,t){return(t?.queryKeyHashFn||Gd)(e)}function Gd(e){return JSON.stringify(e,(e,t)=>Zd(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Kd(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Kd(e[n],t[n])):!1}var qd=Object.prototype.hasOwnProperty;function Jd(e,t){if(e===t)return e;let n=Xd(e)&&Xd(t);if(!n&&!(Zd(e)&&Zd(t)))return t;let r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),a=i.length,o=n?Array(a):{},s=0;for(let c=0;c<a;c++){let a=n?c:i[c],l=e[a],u=t[a];if(l===u){o[a]=l,(n?c<r:qd.call(e,a))&&s++;continue}if(l===null||u===null||typeof l!=`object`||typeof u!=`object`){o[a]=u;continue}let d=Jd(l,u);o[a]=d,d===l&&s++}return r===a&&s===r?e:o}function Yd(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Xd(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Zd(e){if(!Qd(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Qd(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Qd(e){return Object.prototype.toString.call(e)===`[object Object]`}function $d(e){return new Promise(t=>{Nd.setTimeout(t,e)})}function ef(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Jd(e,t)}function tf(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function nf(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var rf=Symbol();function af(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===rf?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function of(e,t){return typeof e==`function`?e(...t):!!e}var sf=new class extends jd{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!Fd&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function cf(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var lf=Pd;function uf(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=lf,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var df=uf(),ff=new class extends jd{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!Fd&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function pf(e){return Math.min(1e3*2**e,3e4)}function mf(e){return(e??`online`)!==`online`||ff.isOnline()}var hf=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function gf(e){let t=!1,n=0,r,i=cf(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new hf(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>sf.isFocused()&&(e.networkMode===`always`||ff.isOnline())&&e.canRun(),u=()=>mf(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Fd?0:3),o=e.retryDelay??pf,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),$d(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var _f=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Rd(this.gcTime)&&(this.#e=Nd.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Fd?1/0:3e5))}clearGcTimeout(){this.#e&&=(Nd.clearTimeout(this.#e),void 0)}},vf=class extends _f{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=bf(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=bf(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=ef(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(Id).catch(Id):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Vd(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===rf||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Bd(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!zd(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=af(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=gf({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof hf&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof hf){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...yf(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:`success`,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),df.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function yf(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:mf(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function bf(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var xf=class extends jd{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=cf(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Cf(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return wf(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return wf(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Vd(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Yd(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Tf(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Vd(this.options.enabled,this.#t)!==Vd(t.enabled,this.#t)||Bd(this.options.staleTime,this.#t)!==Bd(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Vd(this.options.enabled,this.#t)!==Vd(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Df(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`)),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Id)),t}#g(){this.#b();let e=Bd(this.options.staleTime,this.#t);if(Fd||this.#r.isStale||!Rd(e))return;let t=zd(this.#r.dataUpdatedAt,e)+1;this.#d=Nd.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!Fd&&Vd(this.options.enabled,this.#t)!==!1&&Rd(this.#p)&&this.#p!==0&&(this.#f=Nd.setInterval(()=>{(this.options.refetchIntervalInBackground||sf.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(Nd.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(Nd.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Cf(e,t),o=i&&Tf(e,n,t,r);(a||o)&&(l={...l,...yf(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ef(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ef(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Ef(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Vd(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=e=>{x.status===`error`?e.reject(x.error):x.data!==void 0&&e.resolve(x.data)},r=()=>{let e=this.#o=x.promise=cf();t(e)},i=this.#o;switch(i.status){case`pending`:e.queryHash===n.queryHash&&t(i);break;case`fulfilled`:(x.status===`error`||x.data!==i.value)&&r();break;case`rejected`:(x.status!==`error`||x.error!==i.reason)&&r()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Yd(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){df.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Sf(e,t){return Vd(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||t.retryOnMount!==!1)}function Cf(e,t){return Sf(e,t)||e.state.data!==void 0&&wf(e,t,t.refetchOnMount)}function wf(e,t,n){if(Vd(t.enabled,e)!==!1&&Bd(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ef(e,t)}return!1}function Tf(e,t,n,r){return(e!==t||Vd(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ef(e,n)}function Ef(e,t){return Vd(t.enabled,e)!==!1&&e.isStaleByTime(Bd(t.staleTime,e))}function Df(e,t){return!Yd(e.getCurrentResult(),t)}function Of(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener(`abort`,()=>{n=!0}),t.signal)})},u=af(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?nf:tf;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Af:kf,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:kf(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function kf(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Af(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var jf=class extends _f{#e;#t;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Mf(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status===`pending`?this.scheduleGc():this.#t.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#r({type:`continue`})};this.#n=gf({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#r({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#r({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let n=this.state.status===`pending`,r=!this.#n.canStart();try{if(n)t();else{this.#r({type:`pending`,variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#r({type:`pending`,context:t,variables:e,isPaused:r})}let i=await this.#n.start();return await this.#t.config.onSuccess?.(i,e,this.state.context,this),await this.options.onSuccess?.(i,e,this.state.context),await this.#t.config.onSettled?.(i,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(i,null,e,this.state.context),this.#r({type:`success`,data:i}),i}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#r({type:`error`,error:t})}}finally{this.#t.runNext(this)}}#r(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),df.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:`updated`,action:e})})}};function Mf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Nf=class extends jd{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new jf({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Pf(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Pf(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Pf(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Pf(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){df.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ud(t,e))}findAll(e={}){return this.getAll().filter(t=>Ud(e,t))}notify(e){df.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return df.batch(()=>Promise.all(e.map(e=>e.continue().catch(Id))))}};function Pf(e){return e.options.scope?.id}var Ff=class extends jd{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Yd(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Gd(t.mutationKey)!==Gd(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Mf();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){df.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context;e?.type===`success`?(this.#r.onSuccess?.(e.data,t,n),this.#r.onSettled?.(e.data,null,t,n)):e?.type===`error`&&(this.#r.onError?.(e.error,t,n),this.#r.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach(e=>{e(this.#t)})})}},If=class extends jd{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Wd(r,t),a=this.get(i);return a||(a=new vf({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){df.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Hd(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Hd(e,t)):t}notify(e){df.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){df.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){df.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Lf=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new If,this.#t=e.mutationCache||new Nf,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=sf.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ff.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Bd(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Ld(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return df.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;df.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return df.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=df.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Id).catch(Id)}invalidateQueries(e,t={}){return df.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=df.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Id)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Id)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Bd(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Id).catch(Id)}fetchInfiniteQuery(e){return e.behavior=Of(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Id).catch(Id)}ensureInfiniteQueryData(e){return e.behavior=Of(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ff.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Gd(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Kd(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Gd(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Kd(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Wd(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===rf&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Rf=N.createContext(void 0),zf=e=>{let t=N.useContext(Rf);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Bf=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(Rf.Provider,{value:e,children:t})),Vf=N.createContext(!1),Hf=()=>N.useContext(Vf);Vf.Provider;function Uf(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Wf=N.createContext(Uf()),Gf=()=>N.useContext(Wf),Kf=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},qf=e=>{N.useEffect(()=>{e.clearReset()},[e])},Jf=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||of(n,[e.error,r])),Yf=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Xf=(e,t)=>e.isLoading&&e.isFetching&&!t,Zf=(e,t)=>e?.suspense&&t.isPending,Qf=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function $f(e,t,n){let r=Hf(),i=Gf(),a=zf(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Yf(o),Kf(o,i),qf(i);let s=!a.getQueryCache().get(o.queryHash),[c]=N.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!r&&e.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(e=>{let t=u?c.subscribe(df.batchCalls(e)):Id;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(o)},[o,c]),Zf(o,l))throw Qf(o,c,i);if(Jf({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!Fd&&Xf(l,r)&&(s?Qf(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Id).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function ep(e,t){return $f(e,xf,t)}function tp(e,t){let n=zf(t),[r]=N.useState(()=>new Ff(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(df.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=N.useCallback((e,t)=>{r.mutate(e,t).catch(Id)},[r]);if(i.error&&of(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}Object.freeze({status:`aborted`});function I(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var np=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},rp=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},ip={};function ap(e){return e&&Object.assign(ip,e),ip}function op(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function sp(e,t){return typeof t==`bigint`?t.toString():t}function cp(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function lp(e){return e==null}function up(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function dp(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var fp=Symbol(`evaluating`);function pp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==fp)return r===void 0&&(r=fp,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function mp(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function hp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gp(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function _p(e){return JSON.stringify(e)}var vp=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function yp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var bp=cp(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function xp(e){if(yp(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return yp(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Sp(e){return xp(e)?{...e}:Array.isArray(e)?[...e]:e}var Cp=new Set([`string`,`number`,`symbol`]);function wp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Tp(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ep(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Dp={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Op(e,t){let n=e._zod.def;return Tp(e,gp(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return hp(this,`shape`,e),e},checks:[]}))}function kp(e,t){let n=e._zod.def;return Tp(e,gp(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return hp(this,`shape`,r),r},checks:[]}))}function Ap(e,t){if(!xp(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return Tp(e,gp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return hp(this,`shape`,n),n},checks:[]}))}function jp(e,t){if(!xp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Tp(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return hp(this,`shape`,n),n},checks:e._zod.def.checks})}function Mp(e,t){return Tp(e,gp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return hp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Np(e,t,n){return Tp(t,gp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return hp(this,`shape`,i),i},checks:[]}))}function Pp(e,t,n){return Tp(t,gp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return hp(this,`shape`,i),i},checks:[]}))}function Fp(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ip(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Lp(e){return typeof e==`string`?e:e?.message}function Rp(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Lp(e.inst?._zod.def?.error?.(e))??Lp(t?.error?.(e))??Lp(n.customError?.(e))??Lp(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function zp(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Bp(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Vp=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,sp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Hp=I(`$ZodError`,Vp),Up=I(`$ZodError`,Vp,{Parent:Error});function Wp(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Gp(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var Kp=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new np;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Rp(e,a,ap())));throw vp(t,i?.callee),t}return o.value},qp=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Rp(e,a,ap())));throw vp(t,i?.callee),t}return o.value},Jp=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new np;return a.issues.length?{success:!1,error:new(e??Hp)(a.issues.map(e=>Rp(e,i,ap())))}:{success:!0,data:a.value}},Yp=Jp(Up),Xp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Rp(e,i,ap())))}:{success:!0,data:a.value}},Zp=Xp(Up),Qp=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Kp(e)(t,n,i)},$p=e=>(t,n,r)=>Kp(e)(t,n,r),em=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return qp(e)(t,n,i)},tm=e=>async(t,n,r)=>qp(e)(t,n,r),nm=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Jp(e)(t,n,i)},rm=e=>(t,n,r)=>Jp(e)(t,n,r),im=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Xp(e)(t,n,i)},am=e=>async(t,n,r)=>Xp(e)(t,n,r),om=/^[cC][^\s-]{8,}$/,sm=/^[0-9a-z]+$/,cm=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,lm=/^[0-9a-vA-V]{20}$/,um=/^[A-Za-z0-9]{27}$/,dm=/^[a-zA-Z0-9_-]{21}$/,fm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pm=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mm=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,hm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gm=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function _m(){return new RegExp(gm,`u`)}var vm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ym=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,bm=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Sm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Cm=/^[A-Za-z0-9_-]*$/,wm=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Tm=/^\+(?:[0-9]){6,14}[0-9]$/,Em=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Dm=RegExp(`^${Em}$`);function Om(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function km(e){return RegExp(`^${Om(e)}$`)}function Am(e){let t=Om({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Em}T(?:${r})$`)}var jm=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Mm=/^-?\d+$/,Nm=/^-?\d+(?:\.\d+)?/,Pm=/^(?:true|false)$/i,Fm=/^null$/i,Im=/^[^A-Z]*$/,Lm=/^[^a-z]*$/,Rm=I(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),zm={number:`number`,bigint:`bigint`,object:`date`},Bm=I(`$ZodCheckLessThan`,(e,t)=>{Rm.init(e,t);let n=zm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vm=I(`$ZodCheckGreaterThan`,(e,t)=>{Rm.init(e,t);let n=zm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hm=I(`$ZodCheckMultipleOf`,(e,t)=>{Rm.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):dp(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Um=I(`$ZodCheckNumberFormat`,(e,t)=>{Rm.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Dp[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Mm)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Wm=I(`$ZodCheckMaxLength`,(e,t)=>{var n;Rm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!lp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=zp(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Gm=I(`$ZodCheckMinLength`,(e,t)=>{var n;Rm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!lp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=zp(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Km=I(`$ZodCheckLengthEquals`,(e,t)=>{var n;Rm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!lp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=zp(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),qm=I(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Rm.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Jm=I(`$ZodCheckRegex`,(e,t)=>{qm.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ym=I(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Im,qm.init(e,t)}),Xm=I(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Lm,qm.init(e,t)}),Zm=I(`$ZodCheckIncludes`,(e,t)=>{Rm.init(e,t);let n=wp(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qm=I(`$ZodCheckStartsWith`,(e,t)=>{Rm.init(e,t);let n=RegExp(`^${wp(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$m=I(`$ZodCheckEndsWith`,(e,t)=>{Rm.init(e,t);let n=RegExp(`.*${wp(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),eh=I(`$ZodCheckOverwrite`,(e,t)=>{Rm.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),th=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
42
42
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
43
- `))}},$m={major:4,minor:1,patch:8},eh=I(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$m;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Mp(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new $f;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Mp(e,t))});else{if(e.issues.length===t)continue;r||=Mp(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Mp(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new $f;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new $f;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=Kp(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Jp(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),th=I(`$ZodString`,(e,t)=>{eh.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Om(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),nh=I(`$ZodStringFormat`,(e,t)=>{Wm.init(e,t),th.init(e,t)}),rh=I(`$ZodGUID`,(e,t)=>{t.pattern??=um,nh.init(e,t)}),ih=I(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=dm(e)}else t.pattern??=dm();nh.init(e,t)}),ah=I(`$ZodEmail`,(e,t)=>{t.pattern??=fm,nh.init(e,t)}),oh=I(`$ZodURL`,(e,t)=>{nh.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:xm.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),sh=I(`$ZodEmoji`,(e,t)=>{t.pattern??=mm(),nh.init(e,t)}),ch=I(`$ZodNanoID`,(e,t)=>{t.pattern??=cm,nh.init(e,t)}),lh=I(`$ZodCUID`,(e,t)=>{t.pattern??=rm,nh.init(e,t)}),uh=I(`$ZodCUID2`,(e,t)=>{t.pattern??=im,nh.init(e,t)}),dh=I(`$ZodULID`,(e,t)=>{t.pattern??=am,nh.init(e,t)}),fh=I(`$ZodXID`,(e,t)=>{t.pattern??=om,nh.init(e,t)}),ph=I(`$ZodKSUID`,(e,t)=>{t.pattern??=sm,nh.init(e,t)}),mh=I(`$ZodISODateTime`,(e,t)=>{t.pattern??=Dm(t),nh.init(e,t)}),hh=I(`$ZodISODate`,(e,t)=>{t.pattern??=wm,nh.init(e,t)}),gh=I(`$ZodISOTime`,(e,t)=>{t.pattern??=Em(t),nh.init(e,t)}),_h=I(`$ZodISODuration`,(e,t)=>{t.pattern??=lm,nh.init(e,t)}),vh=I(`$ZodIPv4`,(e,t)=>{t.pattern??=hm,nh.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),yh=I(`$ZodIPv6`,(e,t)=>{t.pattern??=gm,nh.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),bh=I(`$ZodCIDRv4`,(e,t)=>{t.pattern??=_m,nh.init(e,t)}),xh=I(`$ZodCIDRv6`,(e,t)=>{t.pattern??=vm,nh.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Sh(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Ch=I(`$ZodBase64`,(e,t)=>{t.pattern??=ym,nh.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Sh(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function wh(e){if(!bm.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Sh(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Th=I(`$ZodBase64URL`,(e,t)=>{t.pattern??=bm,nh.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{wh(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Eh=I(`$ZodE164`,(e,t)=>{t.pattern??=Sm,nh.init(e,t)});function Dh(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Oh=I(`$ZodJWT`,(e,t)=>{nh.init(e,t),e._zod.check=n=>{Dh(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),kh=I(`$ZodNumber`,(e,t)=>{eh.init(e,t),e._zod.pattern=e._zod.bag.pattern??Am,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ah=I(`$ZodNumber`,(e,t)=>{Bm.init(e,t),kh.init(e,t)}),jh=I(`$ZodBoolean`,(e,t)=>{eh.init(e,t),e._zod.pattern=jm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Mh=I(`$ZodNull`,(e,t)=>{eh.init(e,t),e._zod.pattern=Mm,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Nh=I(`$ZodUnknown`,(e,t)=>{eh.init(e,t),e._zod.parse=e=>e}),Ph=I(`$ZodNever`,(e,t)=>{eh.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Fh(e,t,n){e.issues.length&&t.issues.push(...Np(n,e.issues)),t.value[n]=e.value}var Ih=I(`$ZodArray`,(e,t)=>{eh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Fh(t,n,e))):Fh(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Lh(e,t,n,r){e.issues.length&&t.issues.push(...Np(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Rh(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Cp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function zh(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Lh(e,n,i,t))):Lh(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Bh=I(`$ZodObject`,(e,t)=>{eh.init(e,t);let n=ap(()=>Rh(t));up(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=gp,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Lh(n,t,e,s))):Lh(n,t,e,s)}return i?zh(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Vh=I(`$ZodObjectJIT`,(e,t)=>{Bh.init(e,t);let n=e._zod.parse,r=ap(()=>Rh(t)),i=e=>{let t=new Qm([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=mp(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=mp(e);t.write(`const ${n} = ${i(e)};`),t.write(`
43
+ `))}},nh={major:4,minor:1,patch:8},rh=I(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nh;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Fp(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new np;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Fp(e,t))});else{if(e.issues.length===t)continue;r||=Fp(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Fp(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new np;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new np;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=Yp(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Zp(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),ih=I(`$ZodString`,(e,t)=>{rh.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??jm(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),ah=I(`$ZodStringFormat`,(e,t)=>{qm.init(e,t),ih.init(e,t)}),oh=I(`$ZodGUID`,(e,t)=>{t.pattern??=pm,ah.init(e,t)}),sh=I(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=mm(e)}else t.pattern??=mm();ah.init(e,t)}),ch=I(`$ZodEmail`,(e,t)=>{t.pattern??=hm,ah.init(e,t)}),lh=I(`$ZodURL`,(e,t)=>{ah.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:wm.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),uh=I(`$ZodEmoji`,(e,t)=>{t.pattern??=_m(),ah.init(e,t)}),dh=I(`$ZodNanoID`,(e,t)=>{t.pattern??=dm,ah.init(e,t)}),fh=I(`$ZodCUID`,(e,t)=>{t.pattern??=om,ah.init(e,t)}),ph=I(`$ZodCUID2`,(e,t)=>{t.pattern??=sm,ah.init(e,t)}),mh=I(`$ZodULID`,(e,t)=>{t.pattern??=cm,ah.init(e,t)}),hh=I(`$ZodXID`,(e,t)=>{t.pattern??=lm,ah.init(e,t)}),gh=I(`$ZodKSUID`,(e,t)=>{t.pattern??=um,ah.init(e,t)}),_h=I(`$ZodISODateTime`,(e,t)=>{t.pattern??=Am(t),ah.init(e,t)}),vh=I(`$ZodISODate`,(e,t)=>{t.pattern??=Dm,ah.init(e,t)}),yh=I(`$ZodISOTime`,(e,t)=>{t.pattern??=km(t),ah.init(e,t)}),bh=I(`$ZodISODuration`,(e,t)=>{t.pattern??=fm,ah.init(e,t)}),xh=I(`$ZodIPv4`,(e,t)=>{t.pattern??=vm,ah.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),Sh=I(`$ZodIPv6`,(e,t)=>{t.pattern??=ym,ah.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Ch=I(`$ZodCIDRv4`,(e,t)=>{t.pattern??=bm,ah.init(e,t)}),wh=I(`$ZodCIDRv6`,(e,t)=>{t.pattern??=xm,ah.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Th(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Eh=I(`$ZodBase64`,(e,t)=>{t.pattern??=Sm,ah.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Th(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Dh(e){if(!Cm.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Th(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Oh=I(`$ZodBase64URL`,(e,t)=>{t.pattern??=Cm,ah.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{Dh(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),kh=I(`$ZodE164`,(e,t)=>{t.pattern??=Tm,ah.init(e,t)});function Ah(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var jh=I(`$ZodJWT`,(e,t)=>{ah.init(e,t),e._zod.check=n=>{Ah(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Mh=I(`$ZodNumber`,(e,t)=>{rh.init(e,t),e._zod.pattern=e._zod.bag.pattern??Nm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Nh=I(`$ZodNumber`,(e,t)=>{Um.init(e,t),Mh.init(e,t)}),Ph=I(`$ZodBoolean`,(e,t)=>{rh.init(e,t),e._zod.pattern=Pm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Fh=I(`$ZodNull`,(e,t)=>{rh.init(e,t),e._zod.pattern=Fm,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Ih=I(`$ZodUnknown`,(e,t)=>{rh.init(e,t),e._zod.parse=e=>e}),Lh=I(`$ZodNever`,(e,t)=>{rh.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Rh(e,t,n){e.issues.length&&t.issues.push(...Ip(n,e.issues)),t.value[n]=e.value}var zh=I(`$ZodArray`,(e,t)=>{rh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Rh(t,n,e))):Rh(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Bh(e,t,n,r){e.issues.length&&t.issues.push(...Ip(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Vh(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Ep(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Hh(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Bh(e,n,i,t))):Bh(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Uh=I(`$ZodObject`,(e,t)=>{rh.init(e,t);let n=cp(()=>Vh(t));pp(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=yp,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Bh(n,t,e,s))):Bh(n,t,e,s)}return i?Hh(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Wh=I(`$ZodObjectJIT`,(e,t)=>{Uh.init(e,t);let n=e._zod.parse,r=cp(()=>Vh(t)),i=e=>{let t=new th([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=_p(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=_p(e);t.write(`const ${n} = ${i(e)};`),t.write(`
44
44
  if (${n}.issues.length) {
45
45
  payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
46
46
  ...iss,
@@ -57,40 +57,40 @@ import{i as e,n as t,o as n,r,t as i}from"./react-dom.B--7n7g5.js";import{_ as a
57
57
  newResult[${r}] = ${n}.value;
58
58
  }
59
59
 
60
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=gp,s=!tp.jitless,c=s&&_p.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?zh([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Hh(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Mp(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Fp(e,r,np())))}),t)}var Uh=I(`$ZodUnion`,(e,t)=>{eh.init(e,t),up(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),up(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),up(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),up(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>sp(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Hh(t,i,e,a)):Hh(s,i,e,a)}}),Wh=I(`$ZodIntersection`,(e,t)=>{eh.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Kh(e,t,n)):Kh(e,i,a)}});function Gh(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(vp(e)&&vp(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Gh(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Gh(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Kh(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Mp(e))return e;let r=Gh(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var qh=I(`$ZodRecord`,(e,t)=>{eh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!vp(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Np(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Np(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Fp(e,r,np())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Np(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Np(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Jh=I(`$ZodEnum`,(e,t)=>{eh.init(e,t);let n=rp(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>bp.has(typeof e)).map(e=>typeof e==`string`?xp(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Yh=I(`$ZodLiteral`,(e,t)=>{if(eh.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?xp(e):e?xp(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),Xh=I(`$ZodTransform`,(e,t)=>{eh.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ep(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new $f;return n.value=i,n}});function Zh(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Qh=I(`$ZodOptional`,(e,t)=>{eh.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,up(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),up(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${sp(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Zh(t,e.value)):Zh(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),$h=I(`$ZodNullable`,(e,t)=>{eh.init(e,t),up(e._zod,`optin`,()=>t.innerType._zod.optin),up(e._zod,`optout`,()=>t.innerType._zod.optout),up(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${sp(e.source)}|null)$`):void 0}),up(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),eg=I(`$ZodDefault`,(e,t)=>{eh.init(e,t),e._zod.optin=`optional`,up(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>tg(e,t)):tg(r,t)}});function tg(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ng=I(`$ZodPrefault`,(e,t)=>{eh.init(e,t),e._zod.optin=`optional`,up(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),rg=I(`$ZodNonOptional`,(e,t)=>{eh.init(e,t),up(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ig(t,e)):ig(i,e)}});function ig(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var ag=I(`$ZodCatch`,(e,t)=>{eh.init(e,t),up(e._zod,`optin`,()=>t.innerType._zod.optin),up(e._zod,`optout`,()=>t.innerType._zod.optout),up(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Fp(e,n,np()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Fp(e,n,np()))},input:e.value}),e.issues=[]),e)}}),og=I(`$ZodPipe`,(e,t)=>{eh.init(e,t),up(e._zod,`values`,()=>t.in._zod.values),up(e._zod,`optin`,()=>t.in._zod.optin),up(e._zod,`optout`,()=>t.out._zod.optout),up(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>sg(e,t.in,n)):sg(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>sg(e,t.out,n)):sg(r,t.out,n)}});function sg(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var cg=I(`$ZodReadonly`,(e,t)=>{eh.init(e,t),up(e._zod,`propValues`,()=>t.innerType._zod.propValues),up(e._zod,`values`,()=>t.innerType._zod.values),up(e._zod,`optin`,()=>t.innerType._zod.optin),up(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(lg):lg(r)}});function lg(e){return e.value=Object.freeze(e.value),e}var ug=I(`$ZodLazy`,(e,t)=>{eh.init(e,t),up(e._zod,`innerType`,()=>t.getter()),up(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),up(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),up(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),up(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),dg=I(`$ZodCustom`,(e,t)=>{Fm.init(e,t),eh.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>fg(t,n,r,e));fg(i,n,r,e)}});function fg(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Lp(e))}}var pg=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function mg(){return new pg}var hg=mg();function gg(e,t){return new e({type:`string`,...L(t)})}function _g(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function vg(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function yg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function bg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function xg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Sg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function Cg(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function wg(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function Tg(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Eg(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Dg(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Og(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function kg(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function Ag(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function jg(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function Mg(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function Ng(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function Pg(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function Fg(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function Ig(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function Lg(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function Rg(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function zg(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function Bg(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function Vg(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function Hg(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function Ug(e,t){return new e({type:`number`,checks:[],...L(t)})}function Wg(e,t){return new e({type:`number`,coerce:!0,checks:[],...L(t)})}function Gg(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function Kg(e,t){return new e({type:`boolean`,...L(t)})}function qg(e,t){return new e({type:`null`,...L(t)})}function Jg(e){return new e({type:`unknown`})}function Yg(e,t){return new e({type:`never`,...L(t)})}function Xg(e,t){return new Lm({check:`less_than`,...L(t),value:e,inclusive:!1})}function Zg(e,t){return new Lm({check:`less_than`,...L(t),value:e,inclusive:!0})}function Qg(e,t){return new Rm({check:`greater_than`,...L(t),value:e,inclusive:!1})}function $g(e,t){return new Rm({check:`greater_than`,...L(t),value:e,inclusive:!0})}function e_(e,t){return new zm({check:`multiple_of`,...L(t),value:e})}function t_(e,t){return new Vm({check:`max_length`,...L(t),maximum:e})}function n_(e,t){return new Hm({check:`min_length`,...L(t),minimum:e})}function r_(e,t){return new Um({check:`length_equals`,...L(t),length:e})}function i_(e,t){return new Gm({check:`string_format`,format:`regex`,...L(t),pattern:e})}function a_(e){return new Km({check:`string_format`,format:`lowercase`,...L(e)})}function o_(e){return new qm({check:`string_format`,format:`uppercase`,...L(e)})}function s_(e,t){return new Jm({check:`string_format`,format:`includes`,...L(t),includes:e})}function c_(e,t){return new Ym({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function l_(e,t){return new Xm({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function u_(e){return new Zm({check:`overwrite`,tx:e})}function d_(e){return u_(t=>t.normalize(e))}function f_(){return u_(e=>e.trim())}function p_(){return u_(e=>e.toLowerCase())}function m_(){return u_(e=>e.toUpperCase())}function h_(e,t,n){return new e({type:`array`,element:t,...L(n)})}function g_(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function __(e){let t=v_(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Lp(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Lp(r))}},e(n.value,n)));return t}function v_(e,t){let n=new Fm({check:`custom`,...L(t)});return n._zod.check=e,n}var y_=I(`ZodISODateTime`,(e,t)=>{mh.init(e,t),W_.init(e,t)});function b_(e){return zg(y_,e)}var x_=I(`ZodISODate`,(e,t)=>{hh.init(e,t),W_.init(e,t)});function S_(e){return Bg(x_,e)}var C_=I(`ZodISOTime`,(e,t)=>{gh.init(e,t),W_.init(e,t)});function w_(e){return Vg(C_,e)}var T_=I(`ZodISODuration`,(e,t)=>{_h.init(e,t),W_.init(e,t)});function E_(e){return Hg(T_,e)}var D_=(e,t)=>{zp.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Hp(e,t)},flatten:{value:t=>Vp(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ip,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ip,2)}},isEmpty:{get(){return e.issues.length===0}}})};I(`ZodError`,D_);var O_=I(`ZodError`,D_,{Parent:Error}),k_=Up(O_),A_=Wp(O_),j_=Gp(O_),M_=qp(O_),N_=Yp(O_),P_=Xp(O_),F_=Zp(O_),I_=Qp(O_),L_=$p(O_),R_=em(O_),z_=tm(O_),B_=nm(O_),V_=I(`ZodType`,(e,t)=>(eh.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>Sp(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>k_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>j_(e,t,n),e.parseAsync=async(t,n)=>A_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>M_(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>N_(e,t,n),e.decode=(t,n)=>P_(e,t,n),e.encodeAsync=async(t,n)=>F_(e,t,n),e.decodeAsync=async(t,n)=>I_(e,t,n),e.safeEncode=(t,n)=>L_(e,t,n),e.safeDecode=(t,n)=>R_(e,t,n),e.safeEncodeAsync=async(t,n)=>z_(e,t,n),e.safeDecodeAsync=async(t,n)=>B_(e,t,n),e.refine=(t,n)=>e.check($v(t,n)),e.superRefine=t=>e.check(ey(t)),e.overwrite=t=>e.check(u_(t)),e.optional=()=>Fv(e),e.nullable=()=>Lv(e),e.nullish=()=>Fv(Lv(e)),e.nonoptional=t=>Uv(e,t),e.array=()=>B(e),e.or=t=>wv([e,t]),e.and=t=>Ev(e,t),e.transform=t=>qv(e,Nv(t)),e.default=t=>zv(e,t),e.prefault=t=>Vv(e,t),e.catch=t=>Gv(e,t),e.pipe=t=>qv(e,t),e.readonly=()=>Yv(e),e.describe=t=>{let n=e.clone();return hg.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return hg.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return hg.get(e);let n=e.clone();return hg.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),H_=I(`_ZodString`,(e,t)=>{th.init(e,t),V_.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(i_(...t)),e.includes=(...t)=>e.check(s_(...t)),e.startsWith=(...t)=>e.check(c_(...t)),e.endsWith=(...t)=>e.check(l_(...t)),e.min=(...t)=>e.check(n_(...t)),e.max=(...t)=>e.check(t_(...t)),e.length=(...t)=>e.check(r_(...t)),e.nonempty=(...t)=>e.check(n_(1,...t)),e.lowercase=t=>e.check(a_(t)),e.uppercase=t=>e.check(o_(t)),e.trim=()=>e.check(f_()),e.normalize=(...t)=>e.check(d_(...t)),e.toLowerCase=()=>e.check(p_()),e.toUpperCase=()=>e.check(m_())}),U_=I(`ZodString`,(e,t)=>{th.init(e,t),H_.init(e,t),e.email=t=>e.check(_g(G_,t)),e.url=t=>e.check(Cg(J_,t)),e.jwt=t=>e.check(Rg(lv,t)),e.emoji=t=>e.check(wg(Y_,t)),e.guid=t=>e.check(vg(K_,t)),e.uuid=t=>e.check(yg(q_,t)),e.uuidv4=t=>e.check(bg(q_,t)),e.uuidv6=t=>e.check(xg(q_,t)),e.uuidv7=t=>e.check(Sg(q_,t)),e.nanoid=t=>e.check(Tg(X_,t)),e.guid=t=>e.check(vg(K_,t)),e.cuid=t=>e.check(Eg(Z_,t)),e.cuid2=t=>e.check(Dg(Q_,t)),e.ulid=t=>e.check(Og($_,t)),e.base64=t=>e.check(Fg(ov,t)),e.base64url=t=>e.check(Ig(sv,t)),e.xid=t=>e.check(kg(ev,t)),e.ksuid=t=>e.check(Ag(tv,t)),e.ipv4=t=>e.check(jg(nv,t)),e.ipv6=t=>e.check(Mg(rv,t)),e.cidrv4=t=>e.check(Ng(iv,t)),e.cidrv6=t=>e.check(Pg(av,t)),e.e164=t=>e.check(Lg(cv,t)),e.datetime=t=>e.check(b_(t)),e.date=t=>e.check(S_(t)),e.time=t=>e.check(w_(t)),e.duration=t=>e.check(E_(t))});function R(e){return gg(U_,e)}var W_=I(`ZodStringFormat`,(e,t)=>{nh.init(e,t),H_.init(e,t)}),G_=I(`ZodEmail`,(e,t)=>{ah.init(e,t),W_.init(e,t)}),K_=I(`ZodGUID`,(e,t)=>{rh.init(e,t),W_.init(e,t)}),q_=I(`ZodUUID`,(e,t)=>{ih.init(e,t),W_.init(e,t)}),J_=I(`ZodURL`,(e,t)=>{oh.init(e,t),W_.init(e,t)}),Y_=I(`ZodEmoji`,(e,t)=>{sh.init(e,t),W_.init(e,t)}),X_=I(`ZodNanoID`,(e,t)=>{ch.init(e,t),W_.init(e,t)}),Z_=I(`ZodCUID`,(e,t)=>{lh.init(e,t),W_.init(e,t)}),Q_=I(`ZodCUID2`,(e,t)=>{uh.init(e,t),W_.init(e,t)}),$_=I(`ZodULID`,(e,t)=>{dh.init(e,t),W_.init(e,t)}),ev=I(`ZodXID`,(e,t)=>{fh.init(e,t),W_.init(e,t)}),tv=I(`ZodKSUID`,(e,t)=>{ph.init(e,t),W_.init(e,t)}),nv=I(`ZodIPv4`,(e,t)=>{vh.init(e,t),W_.init(e,t)}),rv=I(`ZodIPv6`,(e,t)=>{yh.init(e,t),W_.init(e,t)}),iv=I(`ZodCIDRv4`,(e,t)=>{bh.init(e,t),W_.init(e,t)}),av=I(`ZodCIDRv6`,(e,t)=>{xh.init(e,t),W_.init(e,t)}),ov=I(`ZodBase64`,(e,t)=>{Ch.init(e,t),W_.init(e,t)}),sv=I(`ZodBase64URL`,(e,t)=>{Th.init(e,t),W_.init(e,t)}),cv=I(`ZodE164`,(e,t)=>{Eh.init(e,t),W_.init(e,t)}),lv=I(`ZodJWT`,(e,t)=>{Oh.init(e,t),W_.init(e,t)}),uv=I(`ZodNumber`,(e,t)=>{kh.init(e,t),V_.init(e,t),e.gt=(t,n)=>e.check(Qg(t,n)),e.gte=(t,n)=>e.check($g(t,n)),e.min=(t,n)=>e.check($g(t,n)),e.lt=(t,n)=>e.check(Xg(t,n)),e.lte=(t,n)=>e.check(Zg(t,n)),e.max=(t,n)=>e.check(Zg(t,n)),e.int=t=>e.check(fv(t)),e.safe=t=>e.check(fv(t)),e.positive=t=>e.check(Qg(0,t)),e.nonnegative=t=>e.check($g(0,t)),e.negative=t=>e.check(Xg(0,t)),e.nonpositive=t=>e.check(Zg(0,t)),e.multipleOf=(t,n)=>e.check(e_(t,n)),e.step=(t,n)=>e.check(e_(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function z(e){return Ug(uv,e)}var dv=I(`ZodNumberFormat`,(e,t)=>{Ah.init(e,t),uv.init(e,t)});function fv(e){return Gg(dv,e)}var pv=I(`ZodBoolean`,(e,t)=>{jh.init(e,t),V_.init(e,t)});function mv(e){return Kg(pv,e)}var hv=I(`ZodNull`,(e,t)=>{Mh.init(e,t),V_.init(e,t)});function gv(e){return qg(hv,e)}var _v=I(`ZodUnknown`,(e,t)=>{Nh.init(e,t),V_.init(e,t)});function vv(){return Jg(_v)}var yv=I(`ZodNever`,(e,t)=>{Ph.init(e,t),V_.init(e,t)});function bv(e){return Yg(yv,e)}var xv=I(`ZodArray`,(e,t)=>{Ih.init(e,t),V_.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(n_(t,n)),e.nonempty=t=>e.check(n_(1,t)),e.max=(t,n)=>e.check(t_(t,n)),e.length=(t,n)=>e.check(r_(t,n)),e.unwrap=()=>e.element});function B(e,t){return h_(xv,e,t)}var Sv=I(`ZodObject`,(e,t)=>{Vh.init(e,t),V_.init(e,t),up(e,`shape`,()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:vv()}),e.loose=()=>e.clone({...e._zod.def,catchall:vv()}),e.strict=()=>e.clone({...e._zod.def,catchall:bv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Dp(e,t),e.safeExtend=t=>Op(e,t),e.merge=t=>kp(e,t),e.pick=t=>Tp(e,t),e.omit=t=>Ep(e,t),e.partial=(...t)=>Ap(Pv,e,t[0]),e.required=(...t)=>jp(Hv,e,t[0])});function V(e,t){return new Sv({type:`object`,get shape(){return fp(this,`shape`,e?dp(e):{}),this.shape},...L(t)})}var Cv=I(`ZodUnion`,(e,t)=>{Uh.init(e,t),V_.init(e,t),e.options=t.options});function wv(e,t){return new Cv({type:`union`,options:e,...L(t)})}var Tv=I(`ZodIntersection`,(e,t)=>{Wh.init(e,t),V_.init(e,t)});function Ev(e,t){return new Tv({type:`intersection`,left:e,right:t})}var Dv=I(`ZodRecord`,(e,t)=>{qh.init(e,t),V_.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ov(e,t,n){return new Dv({type:`record`,keyType:e,valueType:t,...L(n)})}var kv=I(`ZodEnum`,(e,t)=>{Jh.init(e,t),V_.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new kv({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new kv({...t,checks:[],...L(r),entries:i})}});function H(e,t){return new kv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Av=I(`ZodLiteral`,(e,t)=>{Yh.init(e,t),V_.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function jv(e,t){return new Av({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Mv=I(`ZodTransform`,(e,t)=>{Xh.init(e,t),V_.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ep(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Lp(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Lp(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Nv(e){return new Mv({type:`transform`,transform:e})}var Pv=I(`ZodOptional`,(e,t)=>{Qh.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Fv(e){return new Pv({type:`optional`,innerType:e})}var Iv=I(`ZodNullable`,(e,t)=>{$h.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Lv(e){return new Iv({type:`nullable`,innerType:e})}var Rv=I(`ZodDefault`,(e,t)=>{eg.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zv(e,t){return new Rv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():yp(t)}})}var Bv=I(`ZodPrefault`,(e,t)=>{ng.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Vv(e,t){return new Bv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():yp(t)}})}var Hv=I(`ZodNonOptional`,(e,t)=>{rg.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Uv(e,t){return new Hv({type:`nonoptional`,innerType:e,...L(t)})}var Wv=I(`ZodCatch`,(e,t)=>{ag.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Gv(e,t){return new Wv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Kv=I(`ZodPipe`,(e,t)=>{og.init(e,t),V_.init(e,t),e.in=t.in,e.out=t.out});function qv(e,t){return new Kv({type:`pipe`,in:e,out:t})}var Jv=I(`ZodReadonly`,(e,t)=>{cg.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Yv(e){return new Jv({type:`readonly`,innerType:e})}var Xv=I(`ZodLazy`,(e,t)=>{ug.init(e,t),V_.init(e,t),e.unwrap=()=>e._zod.def.getter()});function Zv(e){return new Xv({type:`lazy`,getter:e})}var Qv=I(`ZodCustom`,(e,t)=>{dg.init(e,t),V_.init(e,t)});function $v(e,t={}){return g_(Qv,e,t)}function ey(e){return __(e)}function ty(e){let t=Zv(()=>wv([R(e),z(),mv(),gv(),B(t),Ov(R(),t)]));return t}function ny(e){return Wg(uv,e)}var U=R().uuid(),W=R().datetime({offset:!0}),ry=R().regex(/^[a-f0-9]{64}$/);R().trim().min(1);var iy=H([`owner`,`admin`,`security_manager`,`operator`,`viewer`,`auditor`]),ay=H([`R0`,`R1`,`R2`]),oy=H([`public`,`internal`,`confidential`,`restricted`]);V({cursor:R().min(1).optional(),limit:ny().int().min(1).max(200).default(50)}),V({nextCursor:R().min(1).optional(),hasMore:mv()}),V({idempotencyKey:R().trim().min(8).max(200),expectedVersion:z().int().nonnegative().optional()}),V({type:R().default(`about:blank`),title:R(),status:z().int().min(400).max(599),detail:R().optional(),instance:R().optional(),code:R().regex(/^[a-z0-9_]+$/),requestId:R(),errors:B(V({path:R(),message:R(),code:R().optional()})).optional()});var sy=V({providerId:R().nullable(),modelId:R().nullable(),inputTokens:z().int().nonnegative(),outputTokens:z().int().nonnegative(),reasoningTokens:z().int().nonnegative(),cacheReadTokens:z().int().nonnegative(),cacheWriteTokens:z().int().nonnegative(),estimatedCostUsd:z().nonnegative(),pricingSource:R().nullable(),pricingAsOf:R().nullable()}),cy=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),externalSessionId:R().nullable(),createdBy:U,status:H([`active`,`waiting`,`completed`,`failed`,`cancelled`]),mode:H([`autonomous`,`guided`]),model:R().nullable(),costUsd:z().nonnegative(),usage:sy,sensitive:mv(),createdAt:W,lastActivityAt:W}),ly=V({id:U,sessionId:U,role:H([`user`,`assistant`,`system`,`tool`]),redactedPreview:R(),sensitivePayloadArtifactId:U.nullable(),createdAt:W}),uy=V({id:U,sessionId:U,runId:U.nullable(),stageId:U.nullable(),externalToolCallId:R().nullable(),toolName:R().min(1),status:H([`running`,`completed`,`failed`,`cancelled`]),inputHash:ry,outputArtifactId:U.nullable(),startedAt:W,completedAt:W.nullable()});V({session:cy,messages:B(ly),toolActivities:B(uy)}),V({expectedRunVersion:z().int().nonnegative(),reason:R().trim().min(1).max(1e3)}),new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var dy=H([`informational`,`low`,`medium`,`high`,`critical`]),fy=H([`clean`,`informational`,`actionable`,`critical`]),py=V({fingerprint:ry.optional(),title:R().min(1),severity:H([`info`,`low`,`medium`,`high`,`critical`]),details:R().default(``),targetUrl:R().optional(),cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R().min(1)).default([]),remediation:R().default(``),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]).default(`candidate`),evidenceRefs:B(ry).default([])}),my=V({description:R().min(1),artifactType:R().min(1),data:ty().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional()}),hy=H([`observation`,`artifact`,`control_result`,`manual_confirmation`,`report`]),gy=V({fingerprint:ry,title:R().min(1),description:R().default(``),severity:dy,cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R()).default([]),remediation:R().default(``),targetUrl:R().optional(),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]),evidenceRefs:B(ry).default([]),status:H([`open`]).default(`open`)}).strict(),_y=V({fingerprint:ry,kind:hy,title:R().min(1),summary:R().default(``),artifactType:R(),sha256:ry,timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional(),classification:oy.default(`confidential`)}).strict(),vy=V({satisfied:mv(),missing:B(R())}).strict(),yy=V({id:U,runId:U,projectId:U,workflowKey:R().min(1),workflowVersionId:U,version:z().int().nonnegative(),contentHash:ry,target:R().min(1),scopeOrigins:B(R()).default([]),summary:R().default(``),posture:fy,findings:B(gy).default([]),unverifiedLeads:B(gy).default([]),evidence:B(_y).default([]),negativeControls:B(R()).default([]),classification:oy.default(`confidential`),publicationState:H([`draft`,`blocked`,`published`]).default(`draft`),gate:vy,parentContentHash:ry.nullable().default(null),editorialMarkdownHash:ry.nullable().default(null),publishedAt:W.optional(),createdAt:W}).strict();V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),target:R().min(1),model:R().min(1)}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),description:R().min(1),artifactType:R().min(1),data:ty().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative()}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),workflowKey:R().min(1),status:H([`succeeded`,`blocked`,`inconclusive`,`failed`]),findings:z().int().nonnegative(),evidence:z().int().nonnegative(),findingItems:B(py).default([]),evidenceItems:B(my).default([]),negativeControls:B(R().min(1).max(4e3)).max(500).default([]),toolAttempts:z().int().nonnegative(),toolsExecuted:z().int().nonnegative(),toolsErrored:z().int().nonnegative(),pricingUnknown:mv().optional()}),V({id:U,organizationId:U,name:R().trim().min(1).max(120),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({id:U,organizationId:U,workspaceId:U,name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),archivedAt:W.nullable(),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});var by=V({id:U,kind:H([`domain`,`ip`,`cidr`,`url`,`repository`,`api`,`android`,`ios`,`custom`]),locator:R().trim().min(1).max(2048),displayName:R().trim().min(1).max(240)}),xy=V({id:U,owner:R().trim().min(1),documentArtifactId:U,validFrom:W,validUntil:W,allowedActions:B(R().min(1)).min(1),prohibitedActions:B(R().min(1)),sha256:ry}),Sy=V({requestsPerSecond:z().positive().optional(),concurrency:z().int().positive().optional(),durationSeconds:z().int().positive(),costUsd:z().nonnegative().optional(),modelTokens:z().int().nonnegative().optional()}),Cy=V({projectId:U,name:R().trim().min(1).max(160),targets:B(by).min(1),exclusions:B(R().trim().min(1)),authorization:xy.optional(),allowedRisk:ay,allowedActions:B(R().min(1)),prohibitedActions:B(R().min(1)),limits:Sy,requiredWorkerClass:R().trim().min(1),requiredCapabilities:B(R().trim().min(1)),credentialReferences:B(R().trim().min(1)),dataClassification:oy,retentionPolicyId:U.optional(),notificationChannels:B(R().trim().min(1))}).extend({id:U,organizationId:U,workspaceId:U,revision:z().int().positive(),inputHash:ry,createdAt:W,createdBy:U}),wy=H([`open`,`in_progress`,`accepted_risk`,`false_positive`,`remediated`,`verified`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,title:R().min(1),description:R(),severity:H([`informational`,`low`,`medium`,`high`,`critical`]),status:wy,fingerprint:ry,version:z().int().nonnegative(),firstSeenAt:W,lastSeenAt:W}),V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),stageId:U.nullable(),agentSessionId:U.nullable(),toolCallId:U.nullable(),kind:H([`observation`,`artifact`,`report`,`manual_confirmation`,`control_result`]),title:R().min(1),summary:R(),classification:oy,artifactId:U.nullable(),sha256:ry,createdAt:W});var Ty=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,objectKey:R().min(1),sha256:ry,mimeType:R().min(1),size:z().int().nonnegative(),classification:oy,createdBy:U,createdAt:W}),Ey=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`mobile-application`,`red-team-campaign`,`purple-team-validation`,`nist-csf-2`,`cis-controls-8-1`,`advanced-security-testing`,`remediation-validation`,`network-security-audit`]),Dy=V({key:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),name:R().min(1),description:R().min(1),risk:ay,optional:mv().default(!1),requiredCapabilities:B(R().min(1)),skillRefs:B(R().min(1).max(80)).max(64).default([]),retrySafe:mv(),approvalCheckpoint:mv(),timeoutSeconds:z().int().positive()}),Oy=V({id:U,key:Ey,version:R().regex(/^\d+\.\d+\.\d+$/),name:R().min(1),description:R().min(1),inputSchema:Ov(R(),vv()),requiredCapabilities:B(R().min(1)),requiredIntegrations:B(R().min(1)),stages:B(Dy).min(1),evidenceRequirements:B(R().min(1)).min(1),completionCriteria:B(R().min(1)).min(1),publishedAt:W,contentHash:ry}),ky=V({code:H([`authorization_missing`,`authorization_expired`,`capability_missing`,`worker_missing`,`integration_missing`,`credential_missing`,`scope_invalid`,`approval_required`]),message:R().min(1),stageKey:R().optional(),capability:R().optional()}),Ay=V({ready:mv(),launchState:H([`ready`,`blocked`,`awaiting_approval`]),highestRisk:ay,reasons:B(ky),matchingWorkerIds:B(U),inputHash:ry}),jy=H([`draft`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`cancel_requested`,`succeeded`,`failed`,`cancelled`,`expired`]),My=H([`pending`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`paused`,`succeeded`,`failed`,`cancel_requested`,`cancelled`,`expired`,`skipped`]);V({projectId:U,assessmentProfileId:U,workflowKey:Ey,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Ov(R(),vv()),workerClass:R().min(1),mode:H([`autonomous`,`guided`]).default(`autonomous`)});var Ny=V({id:U,organizationId:U,workspaceId:U,projectId:U,assessmentId:U,assessmentProfileId:U,workflowVersionId:U,workflowKey:Ey,requestedBy:U,state:jy,risk:ay,inputHash:ry,workerClass:R(),mode:H([`autonomous`,`guided`]),attempt:z().int().positive(),retryOfRunId:U.nullable(),agentSessionId:U.nullable(),usage:sy,version:z().int().nonnegative(),createdAt:W,startedAt:W.nullable(),completedAt:W.nullable()}),Py=V({id:U,runId:U,key:R().min(1),position:z().int().nonnegative(),risk:ay,state:My,workerId:U.nullable(),version:z().int().nonnegative(),startedAt:W.nullable(),completedAt:W.nullable()});V({id:z().int().positive(),runId:U,stageId:U.nullable(),type:R().min(1),payload:Ov(R(),vv()),occurredAt:W}),V({after:z().int().nonnegative().default(0)});var Fy=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`network-security-audit`]);V({target:R().trim().min(1).max(2048),workflowKey:Fy,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Ov(R(),vv()).default({})}).extend({mode:H([`autonomous`,`guided`]).default(`autonomous`)}),V({owner:R().trim().min(2).max(200),statement:R().trim().min(20).max(2e3),validUntil:W});var Iy=V({profile:Cy,authorization:xy,artifact:Ty}),Ly=V({projectId:U,target:by,dossierKey:R().min(1),profileId:U,profileName:R().min(1),reusedProfile:mv()}),Ry=V({binding:Ly,readiness:Ay}),zy=V({binding:Ly,run:Ny,stages:B(Py),agentSession:cy}),By=H([`pending`,`approved`,`rejected`,`expired`,`invalidated`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,stageId:U.nullable(),risk:ay,state:By,requestedBy:U,requiredRole:H([`security_manager`,`owner_or_admin`]),decidedBy:U.nullable(),decisionRole:H([`owner`,`admin`,`security_manager`]).nullable(),workflowVersionId:U,inputHash:ry,scopeHash:ry,targetSetHash:ry,workerClass:R().min(1),actionSetHash:ry,expiresAt:W,decidedAt:W.nullable(),reason:R().nullable()}),V({decision:H([`approve`,`reject`]),reason:R().trim().min(1).max(2e3),passwordConfirmation:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,sequence:z().int().positive(),organizationId:U,workspaceId:U,projectId:U.nullable(),actorId:U.nullable(),authSessionId:U.nullable(),action:R().min(1),resourceType:R().min(1),resourceId:R().min(1),requestId:R().min(1),correlationId:R().nullable(),ip:R().nullable(),userAgent:R().nullable(),outcome:H([`succeeded`,`denied`,`failed`]),reason:R().nullable(),beforeHash:ry.nullable(),afterHash:ry.nullable(),previousEventHash:ry.nullable(),eventHash:ry,occurredAt:W}),V({id:U,workspaceId:U,governanceDays:z().int().min(2555),assessmentDaysAfterClosure:z().int().min(1095),rawSessionDays:z().int().min(180),authSessionInvestigationDays:z().int().min(30),version:z().int().nonnegative()}),V({id:U,workspaceId:U,name:R().min(1),reason:R().min(1),resourceType:H([`assessment`,`run`,`agent_session`,`finding`,`artifact`]),resourceId:U,releasedAt:W.nullable(),createdAt:W});var Vy=H([`workspace:admin`,`project:write`,`workflow:configure`,`run:launch`,`run:approve:r1`,`run:approve:r2`,`finding:write`,`session:read`,`session:read_sensitive`,`evidence:read`,`evidence:read_sensitive`,`governance:read`,`governance:write`]);V({user:V({id:U,email:R().email(),displayName:R().min(1),mfaEnrolled:mv(),createdAt:W}),organizationId:U,memberships:B(V({workspaceId:U,workspaceName:R().min(1),role:iy,permissions:B(Vy)})),activeWorkspaceId:U}),V({id:U,userId:U,createdAt:W,lastSeenAt:W,expiresAt:W,ip:R().nullable(),userAgent:R().nullable(),current:mv()}),V({password:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,workspaceId:U,email:R().email(),role:iy,expiresAt:W,acceptedAt:W.nullable(),createdAt:W});var Hy=z().int().nonnegative(),Uy=R().min(1),Wy=H([`info`,`low`,`medium`,`high`,`critical`]),Gy=H([`open`,`unverified`,`confirmed`,`remediating`,`remediated`,`verified`,`false_positive`,`accepted_risk`,`suppressed`]),Ky=H([`cli`,`tui`,`web`,`github`,`system`]),qy=H([`scan`,`hunt`,`verify`,`import`]),Jy=H([`queued`,`running`,`completed`,`failed`,`cancelled`]),Yy=Ov(R(),vv()),Xy=V({id:Uy,workspaceID:Uy,projectID:Uy.nullable(),repositoryID:Uy.nullable(),engagementID:Uy.nullable(),targetID:Uy.nullable(),parentRunID:Uy.nullable(),sessionID:Uy.nullable(),source:Ky,kind:qy,status:Jy,title:R(),requestedBy:R().nullable(),baseRevision:R().nullable(),headRevision:R().nullable(),promptRevision:R().nullable(),promptFingerprint:R().nullable(),configuration:Yy.nullable(),summary:Yy.nullable(),error:Yy.nullable(),idempotencyKey:R().nullable(),createdAt:Hy,startedAt:Hy.nullable(),completedAt:Hy.nullable(),updatedAt:Hy}),Zy=V({runs:B(Xy),nextCursor:R().optional()}),Qy=V({id:Uy,fingerprint:R().min(1),title:R(),description:R().nullable(),severity:Wy,status:Gy,path:R().nullable(),line:z().int().nullable(),category:R().nullable(),firstSeenAt:Hy,lastSeenAt:Hy,updatedAt:Hy}),$y=V({findings:B(Qy),total:z().int().nonnegative()}),eb=V({id:Uy,runID:Uy.nullable(),operationID:Uy.nullable(),kind:R(),verdict:R(),reason:R().nullable(),payload:Yy.nullable(),createdAt:Hy}),tb=V({finding:Qy.extend({cwe:R().nullable(),cve:R().nullable(),cvssScore:z().nullable(),cvssVector:R().nullable(),remediation:R().nullable(),assignee:R().nullable(),resolvedAt:Hy.nullable(),evidence:B(eb)})}),nb=V({id:Uy,runID:Uy,tool:R(),runtime:R(),status:R(),outcome:R(),title:R().nullable(),input:Yy.nullable(),outputPreview:R().nullable(),error:Yy.nullable(),startedAt:Hy,completedAt:Hy.nullable()}),rb=V({run:Xy,operations:B(nb.omit({runID:!0})),findings:B(Qy)}),ib=V({id:Uy,title:R(),kind:R(),source:R(),status:H([`running`,`failed`,`completed`]),runCount:z().int().nonnegative(),operationCount:z().int().nonnegative(),findingCount:z().int().nonnegative(),startedAt:Hy,lastActivityAt:Hy}),ab=V({session:ib,runs:B(Xy),operations:B(nb),findings:B(Qy)}),ob=V({id:Uy,sequence:z().int().positive(),actorID:R().nullable(),action:R().min(1),objectType:R().min(1),objectID:R().min(1),outcome:H([`succeeded`,`denied`,`failed`]),details:Yy.nullable(),createdAt:Hy}),sb=V({id:Uy,workspaceId:Uy,name:R(),slug:R(),archivedAt:Hy.nullable(),createdAt:Hy,updatedAt:Hy}),cb=V({id:Uy,name:R(),role:R(),createdAt:Hy,updatedAt:Hy}),lb=V({id:Uy,name:R(),status:R(),capabilities:B(R()).default([]),lastSeenAt:Hy.nullable()}),ub=V({sessionId:R().nullable().optional(),runs:Ov(R(),z()),findings:V({total:z().int().nonnegative(),bySeverity:Ov(R(),z()),byStatus:Ov(R(),z())}),recentRuns:B(Xy),recentFindings:B(Qy)}),db=V({count:z().int().nonnegative(),limit:z().int().positive(),hasMore:mv()});function fb(e){return V({items:B(e),page:db})}V({workspaceId:U,clientId:U,batchId:U,records:B(V({id:U,kind:H([`agent_session`,`evidence`,`finding`,`governance_event`]),localSequence:z().int().positive(),payload:Ov(R(),vv()),payloadHash:ry,occurredAt:W})).min(1).max(500)}),V({batchId:U,accepted:B(U),rejected:B(V({id:U,code:R(),detail:R()})),centralizedApproval:jv(!1)});var pb=H([`command_execution`,`read_files`,`write_files`,`http_request`,`run_exploit`,`dns_recon`,`state_mutation`,`skill_load`]);V({stageId:R().uuid(),workflowVersionId:R().uuid(),stageKey:R().min(1),requiredCapabilities:B(R().min(1)),allowedToolCategories:B(pb),allowedSkills:B(R().min(1).max(80)).max(64).default([]),retrySafe:mv(),timeoutMs:z().int().positive()});var mb=V({workerClass:H([`network`,`web-api`,`mobile-lab`,`advanced-analysis`,`passive`]),capabilities:B(R().min(1)),tools:Ov(R(),R()),networkLocation:R().nullable(),devices:B(V({id:R(),platform:H([`android`,`ios`]),version:R()})),limits:V({concurrency:z().int().positive(),memoryMb:z().int().positive(),cpuMillis:z().int().positive(),durationSeconds:z().int().positive()})});V({token:R().min(32),name:R().trim().min(1).max(160),publicKey:R().min(32),capabilities:mb}),V({expiresAt:W}),V({token:R().min(32),expiresAt:W}),V({worker:V({id:U,organizationId:U,workspaceId:U,name:R(),publicKey:R(),capabilities:mb,status:H([`enrolling`,`online`,`offline`,`revoked`]),lastHeartbeatAt:W.nullable(),createdAt:W}),accessToken:R().min(32),expiresAt:W}),V({capabilities:mb.optional(),runningJobIds:B(U)}),V({id:U,runId:U,stageId:U,workerId:U,leaseToken:R().min(32),leaseExpiresAt:W,attempt:z().int().positive(),payload:Ov(R(),vv())}),V({leaseToken:R().min(32),events:B(V({idempotencyKey:R().min(8),type:R().min(1),occurredAt:W,payload:Ov(R(),vv())})).min(1).max(500)});var hb=V({leaseToken:R().min(32)});hb.extend({extendSeconds:z().int().min(10).max(300).default(60)}),hb.extend({outcome:H([`succeeded`,`failed`,`cancelled`]),summary:Ov(R(),vv()).default({}),error:R().max(2e4).optional(),retrySafe:mv().default(!1)});var gb=V({items:B(Oy)}),_b=fb(cb),vb=fb(sb),yb=V({items:B(Cy)}),bb=fb(ib),xb=fb(ob),Sb=fb(lb),Cb=V({id:R(),label:R(),prefix:R().optional().default(``),tokenPrefix:R().optional(),role:R().optional().default(`admin`),workspaceId:R().optional().default(`default`),createdAt:R(),expiresAt:R().nullable().optional(),lastUsedAt:R().nullable().optional()}),wb=Cb.extend({token:R()}),Tb=V({items:B(Cb)}),Eb=V({items:B(V({version:z().int().nonnegative(),posture:R(),target:R(),contentHash:R(),classification:R(),publicationState:H([`draft`,`blocked`,`published`]),gate:V({satisfied:mv(),missing:B(R())}),publishedAt:R().nullable(),createdAt:R()}))}),Db=V({ext:R(),mimeType:R(),url:R().nullable(),rendered:mv()}),Ob=V({version:z().int().nonnegative(),contentHash:R(),posture:R(),target:R(),classification:R(),record:yy,renditions:B(Db)}),kb=V({artifacts:B(V({artifactId:R(),mimeType:R(),size:z(),sha256:R()}))}),Ab=V({version:z().int().nonnegative(),contentHash:R(),posture:R()}),jb=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function Mb(e=fetch){async function t(t,n,r){let i=document.querySelector(`meta[name="csrf-token"]`)?.content||sessionStorage.getItem(`kifaru-csrf`)||document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`kifaru_csrf=`))?.slice(12),a=r?.method?.toUpperCase()??`GET`,o=await e(t,{credentials:`same-origin`,...r,headers:{accept:`application/json`,...a!==`GET`&&a!==`HEAD`&&i?{"x-csrf-token":i}:{},...r?.headers}});if(!o.ok&&o.status===401&&typeof window<`u`&&!window.location.pathname.startsWith(`/login`))throw window.location.href=`/login?redirect=${encodeURIComponent(window.location.pathname+window.location.search)}`,new jb(401,`unauthorized`,`Session expired. Redirecting to login.`);let s=await o.json().catch(()=>void 0);if(!o.ok){let e=s;throw new jb(o.status,e?.code??`request_failed`,e?.detail??`Request failed.`)}return n.parse(s)}return{workflows:()=>t(`/api/v1/workflows`,gb),runs:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??20)),n?.sessionId&&r.set(`sessionId`,n.sessionId),t(`/api/v1/runs?${r.toString()}`,Zy)},runDetail:e=>t(`/api/v1/runs/${encodeURIComponent(e)}`,rb),workspaces:()=>t(`/api/v1/workspaces`,_b),projects:()=>t(`/api/v1/projects`,vb),assessmentProfiles:()=>t(`/api/v1/assessment-profiles`,yb),authorizeAssessmentProfile:(e,n)=>t(`/api/v1/assessment-profiles/${encodeURIComponent(e)}/authorization-attestations`,Iy,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(n)}),findings:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e||`runId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??50)),n?.sessionId&&r.set(`sessionId`,n.sessionId),n?.runId&&r.set(`runId`,n.runId),t(`/api/v1/findings?${r.toString()}`,$y)},finding:e=>t(`/api/v1/findings/${encodeURIComponent(e)}`,tb),updateFindingStatus:(e,n,r)=>t(`/api/v1/findings/${encodeURIComponent(e)}/status`,tb,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:n,...r?{note:r}:{}})}),agentSessions:()=>t(`/api/v1/agent/sessions?limit=50`,bb),agentSession:e=>t(`/api/v1/agent/sessions/${encodeURIComponent(e)}`,ab),governanceEvents:()=>t(`/api/v1/governance/audit-events?limit=50`,xb),workers:()=>t(`/api/v1/workers`,Sb),overview:e=>{let n;return typeof e==`string`?n=e:e&&typeof e==`object`&&`sessionId`in e&&typeof e.sessionId==`string`&&(n=e.sessionId),t(n?`/api/v1/overview?sessionId=${encodeURIComponent(n)}`:`/api/v1/overview`,ub)},tokens:()=>t(`/api/v1/tokens`,Tb),mintToken:e=>t(`/api/v1/tokens`,wb,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),revokeToken:e=>t(`/api/v1/tokens/${encodeURIComponent(e)}`,V({ok:mv()}),{method:`DELETE`}),targetAssessmentReadiness:e=>t(`/api/v1/assessments/readiness`,Ry,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startTargetAssessment:e=>t(`/api/v1/assessments`,zy,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),reportVersions:e=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports`,Eb),reportVersion:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}`,Ob),renderReportRenditions:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/renditions`,kb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({})}),publishEditedMarkdown:(e,n,r)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/editor`,Ab,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({markdown:r})})}}var Nb=Mb(),Pb=[{n:1,name:`Collection & Onboarding`,v:`--s1`},{n:2,name:`Storage & Security`,v:`--s2`},{n:3,name:`Use & Processing`,v:`--s3`},{n:4,name:`Sharing & Disclosure`,v:`--s4`},{n:5,name:`Retention`,v:`--s5`},{n:6,name:`Disposal & Erasure`,v:`--s6`}];function Fb(e){return Pb[Math.min(Math.max(e,1),Pb.length)-1]}function Ib(e){return e.name.split(` `)[0]}var Lb=[`Governance`,`Technical`,`People & 3rd-party`,`Assurance`],Rb=[`critical`,`high`,`medium`,`low`,`info`],zb={critical:0,high:1,medium:2,low:3,info:4},Bb={critical:`--crit`,high:`--high`,medium:`--med`,low:`--low`,info:`--info`},Vb={critical:`Critical`,high:`High`,medium:`Medium`,low:`Low`,info:`Info`};function Hb(e){return e===`informational`?`info`:Rb.includes(e)?e:`info`}function Ub(e){return e.length?[...e].sort((e,t)=>zb[e.severity]-zb[t.severity])[0].severity:null}function Wb(e){return[...e].sort((e,t)=>zb[e.severity]-zb[t.severity])}function Gb(e){return e.status!==`remediated`&&e.status!==`verified`}var Kb=/^(?:L|stage )([1-6])\s*·\s*P([0-3])\s*·\s*(.+)$/i;function qb(e,t){let n=(e??``).trim(),r=Kb.exec(n);if(r)return{stage:Number(r[1]),pillar:Number(r[2]),category:r[3],inferred:!1};let i=`${n} ${t??``}`.toLowerCase();return{stage:/sharing|disclos|transfer|cross-border|offshore|sftp|export|feed|webhook|api partner|integration/.test(i)?4:/retention|purge|backup|archive|dr site|snapshot|data lake/.test(i)?5:/eras|disposal|destroy|delete|decommission|shred/.test(i)?6:/consent|intake|onboarding|collection|telematics|form capture|survey/.test(i)?1:/encrypt|at rest|bucket|object store|database exposure|unencrypted|storage|nas|s3/.test(i)?2:3,pillar:/governance|dpia|retention schedule|policy|register|oversight|audit/.test(i)?0:/shared credential|third-party|tpa|vendor|partner|outsourc|staff|insider/.test(i)?2:1,category:n||`Agent finding`,inferred:!0}}function Jb(e){return e.map(e=>{let t=qb(e.category,e.title);return{...e,severity:Hb(e.severity),stage:t.stage,pillar:t.pillar,displayCategory:t.inferred?`${t.category} (stage inferred)`:t.category,inferred:t.inferred}})}function Yb(e){return Ub(e.filter(e=>e.status===`confirmed`||e.status===`verified`))}function Xb({title:e,sub:t,surface:n=!0,children:r}){return(0,P.jsxs)(`section`,{className:n?`bg-card rounded-xl border p-5`:void 0,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-3`,children:[(0,P.jsx)(`h2`,{children:e}),t?(0,P.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:t}):null]}),r]})}function Zb({children:e}){return(0,P.jsx)(`div`,{className:`kpis`,children:e})}function Qb({label:e,value:t,meta:n,hero:r,tone:i}){return(0,P.jsxs)(`div`,{className:r?`kpi hero`:`kpi`,children:[(0,P.jsx)(`div`,{className:`lab`,children:e}),r?(0,P.jsxs)(`div`,{className:`posture-pill val`,style:i?{color:`var(${Bb[i]})`}:void 0,children:[(0,P.jsx)(`span`,{className:`sq`}),t]}):(0,P.jsx)(`div`,{className:`val`,children:t}),n?(0,P.jsx)(`div`,{className:`meta`,children:n}):null]})}function $b({counts:e}){let t=Math.max(...Rb.map(t=>e[t]),1);return(0,P.jsx)(`div`,{children:Rb.map(n=>(0,P.jsxs)(`div`,{className:`sevrow`,children:[(0,P.jsxs)(`span`,{className:`name`,children:[(0,P.jsx)(`span`,{className:`chip`,style:{background:`var(${Bb[n]})`}}),Vb[n]]}),(0,P.jsx)(`div`,{className:`track`,children:(0,P.jsx)(`div`,{className:`fill`,"data-empty":e[n]===0,style:{width:`${e[n]/t*100}%`,background:`var(${Bb[n]})`}})}),(0,P.jsx)(`span`,{className:`n`,children:e[n]})]},n))})}function ex({findings:e}){let t=Pb.map(t=>e.filter(e=>e.stage===t.n).length),n=Math.max(...t,1);return(0,P.jsx)(`div`,{className:`stagebars`,children:Pb.map((e,r)=>{let i=t[r];return(0,P.jsxs)(`div`,{className:`sbar`,children:[(0,P.jsx)(`span`,{className:`cnt`,children:i}),(0,P.jsx)(`div`,{className:`col`,style:{height:`${Math.max(i/n*112,i?10:2)}px`,background:`var(${e.v})`}}),(0,P.jsx)(`span`,{className:`idx`,children:e.n}),(0,P.jsx)(`span`,{className:`lb`,children:Ib(e)})]},e.n)})})}function tx({findings:e,onSelect:t,emptyLabel:n=`No findings.`}){return e.length?(0,P.jsx)(`div`,{className:`flist`,children:e.map(e=>{let n=Fb(e.stage);return(0,P.jsxs)(`button`,{className:`frow`,type:`button`,onClick:t?()=>t(e):void 0,children:[(0,P.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Vb[e.severity]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`ftitle`,children:e.title}),(0,P.jsxs)(`span`,{className:`fmeta`,children:[(0,P.jsxs)(`span`,{className:`stagetag`,children:[(0,P.jsx)(`span`,{className:`d`,style:{background:`var(${n.v})`}}),`Stage `,n.n,` · `,Ib(n)]}),(0,P.jsx)(`span`,{children:e.displayCategory}),e.path?(0,P.jsx)(`span`,{className:`font-mono`,children:e.path}):null]})]}),(0,P.jsx)(`span`,{className:`fright`,children:(0,P.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:e.status.replaceAll(`_`,` `)})})]},e.id)})}):(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n})}function nx({findings:e,selected:t,onSelect:n}){return(0,P.jsx)(`div`,{className:`chain`,children:Pb.map(r=>{let i=e.filter(e=>e.stage===r.n),a=Ub(i);return(0,P.jsxs)(`button`,{className:`stagenode`,type:`button`,"aria-pressed":r.n===t,onClick:()=>n(r.n),children:[(0,P.jsx)(`div`,{className:`top`,style:{background:`var(${r.v})`}}),a?(0,P.jsx)(`span`,{className:`worst`,style:{background:`var(${Bb[a]})`}}):null,(0,P.jsxs)(`div`,{className:`sn`,children:[`STAGE `,r.n]}),(0,P.jsx)(`div`,{className:`st`,children:r.name}),(0,P.jsxs)(`div`,{className:`sc`,style:{color:`var(${r.v})`},children:[i.length,(0,P.jsxs)(`small`,{children:[`finding`,i.length===1?``:`s`]})]})]},r.n)})})}function rx({findings:e,onSelectStage:t}){return(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{className:`matrix`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`rh`}),Pb.map(e=>(0,P.jsxs)(`th`,{children:[(0,P.jsx)(`span`,{className:`flex flex-wrap gap-4 text-xs font-medium`,children:(0,P.jsx)(`i`,{className:`mcap`,style:{background:`var(${e.v})`}})}),(0,P.jsx)(`br`,{}),e.n]},e.n))]})}),(0,P.jsx)(`tbody`,{children:Lb.map((n,r)=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`rh`,children:n}),Pb.map(i=>{let a=e.filter(e=>e.pillar===r&&e.stage===i.n),o=Ub(a);return o?(0,P.jsx)(`td`,{className:`has`,style:{background:`var(${Bb[o]})`,cursor:`pointer`},title:`${a.length} open at ${n} · stage ${i.n}`,onClick:()=>t(i.n),children:a.length},i.n):(0,P.jsx)(`td`,{children:`·`},i.n)})]},n))})]})})}function ix({items:e}){return(0,P.jsx)(`div`,{className:`my-3.5 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:e.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`k`,children:e.k}),(0,P.jsx)(`div`,{className:e.mono?`v mono`:`v`,children:e.v})]},e.k))})}function ax({title:e,children:t}){return(0,P.jsxs)(`div`,{className:`border-[var(--hair)] mt-4 border-t pt-3.5 [&>h3]:text-muted-foreground [&>h3]:mb-2 [&>h3]:text-[11px] [&>h3]:font-semibold [&>h3]:tracking-[0.1em] [&>h3]:uppercase`,children:[(0,P.jsx)(`h3`,{children:e}),t]})}function ox({title:e,detail:t,verdict:n}){return(0,P.jsxs)(`div`,{className:`evi`,children:[(0,P.jsxs)(`svg`,{className:`ei`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,P.jsx)(`path`,{d:`M14 2v6h6`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`et`,children:e}),(0,P.jsx)(`div`,{className:`ed`,children:t})]}),(0,P.jsx)(`span`,{className:`verdict`,children:n})]})}var sx=y(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`,critical:`border-[color-mix(in_srgb,var(--crit)_35%,transparent)] bg-[var(--crit-bg)] text-[var(--crit)]`,high:`border-[color-mix(in_srgb,var(--high)_35%,transparent)] bg-[var(--high-bg)] text-[var(--high)]`,medium:`border-[color-mix(in_srgb,var(--med)_35%,transparent)] bg-[var(--med-bg)] text-[var(--med)]`,low:`border-[color-mix(in_srgb,var(--low)_35%,transparent)] bg-[var(--low-bg)] text-[var(--low)]`,success:`border-[color-mix(in_srgb,var(--good)_35%,transparent)] bg-[var(--good-bg)] text-[var(--good)]`,info:`bg-[var(--info-bg)] text-[var(--info)]`}},defaultVariants:{variant:`default`}}),cx={critical:`critical`,failed:`critical`,blocked:`critical`,R2:`critical`,high:`high`,awaiting_approval:`high`,cancel_requested:`high`,R1:`high`,medium:`medium`,queued:`medium`,low:`low`,running:`low`,R0:`low`,succeeded:`success`,completed:`success`,confirmed:`success`,ok:`success`,verified:`success`,remediated:`success`,info:`info`,informational:`info`};function lx(e){return e?cx[e]??`secondary`:`secondary`}function ux({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?c:`span`;return(0,P.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:a(sx({variant:t}),e),...r})}function dx(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var fx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,px=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mx={};function hx(e,t){return((t||mx).jsx?px:fx).test(e)}var gx=/[ \t\n\f\r]/g;function _x(e){return typeof e==`object`?e.type===`text`&&vx(e.value):vx(e)}function vx(e){return e.replace(gx,``)===``}var yx=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};yx.prototype.normal={},yx.prototype.property={},yx.prototype.space=void 0;function bx(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new yx(n,r,t)}function xx(e){return e.toLowerCase()}var Sx=class{constructor(e,t){this.attribute=t,this.property=e}};Sx.prototype.attribute=``,Sx.prototype.booleanish=!1,Sx.prototype.boolean=!1,Sx.prototype.commaOrSpaceSeparated=!1,Sx.prototype.commaSeparated=!1,Sx.prototype.defined=!1,Sx.prototype.mustUseProperty=!1,Sx.prototype.number=!1,Sx.prototype.overloadedBoolean=!1,Sx.prototype.property=``,Sx.prototype.spaceSeparated=!1,Sx.prototype.space=void 0;var Cx=e({boolean:()=>G,booleanish:()=>Tx,commaOrSpaceSeparated:()=>kx,commaSeparated:()=>Ox,number:()=>K,overloadedBoolean:()=>Ex,spaceSeparated:()=>Dx}),wx=0,G=Ax(),Tx=Ax(),Ex=Ax(),K=Ax(),Dx=Ax(),Ox=Ax(),kx=Ax();function Ax(){return 2**++wx}var jx=Object.keys(Cx),Mx=class extends Sx{constructor(e,t,n,r){let i=-1;if(super(e,t),Nx(this,`space`,r),typeof n==`number`)for(;++i<jx.length;){let e=jx[i];Nx(this,jx[i],(n&Cx[e])===Cx[e])}}};Mx.prototype.defined=!0;function Nx(e,t,n){n&&(e[t]=n)}function Px(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Mx(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[xx(r)]=r,n[xx(a.attribute)]=r}return new yx(t,n,e.space)}var Fx=Px({properties:{ariaActiveDescendant:null,ariaAtomic:Tx,ariaAutoComplete:null,ariaBusy:Tx,ariaChecked:Tx,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:Dx,ariaCurrent:null,ariaDescribedBy:Dx,ariaDetails:null,ariaDisabled:Tx,ariaDropEffect:Dx,ariaErrorMessage:null,ariaExpanded:Tx,ariaFlowTo:Dx,ariaGrabbed:Tx,ariaHasPopup:null,ariaHidden:Tx,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Dx,ariaLevel:K,ariaLive:null,ariaModal:Tx,ariaMultiLine:Tx,ariaMultiSelectable:Tx,ariaOrientation:null,ariaOwns:Dx,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:Tx,ariaReadOnly:Tx,ariaRelevant:null,ariaRequired:Tx,ariaRoleDescription:Dx,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:Tx,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Ix(e,t){return t in e?e[t]:t}function Lx(e,t){return Ix(e,t.toLowerCase())}var Rx=Px({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Ox,acceptCharset:Dx,accessKey:Dx,action:null,allow:null,allowFullScreen:G,allowPaymentRequest:G,allowUserMedia:G,alpha:G,alt:null,as:null,async:G,autoCapitalize:null,autoComplete:Dx,autoFocus:G,autoPlay:G,blocking:Dx,capture:null,charSet:null,checked:G,cite:null,className:Dx,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:Tx,controls:G,controlsList:Dx,coords:K|Ox,crossOrigin:null,data:null,dateTime:null,decoding:null,default:G,defer:G,dir:null,dirName:null,disabled:G,download:Ex,draggable:Tx,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:G,formTarget:null,headers:Dx,height:K,hidden:Ex,high:K,href:null,hrefLang:null,htmlFor:Dx,httpEquiv:Dx,id:null,imageSizes:null,imageSrcSet:null,inert:G,inputMode:null,integrity:null,is:null,isMap:G,itemId:null,itemProp:Dx,itemRef:Dx,itemScope:G,itemType:Dx,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:G,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:G,muted:G,name:null,nonce:null,noModule:G,noValidate:G,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:G,optimum:K,pattern:null,ping:Dx,placeholder:null,playsInline:G,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:G,referrerPolicy:null,rel:Dx,required:G,reversed:G,rows:K,rowSpan:K,sandbox:Dx,scope:null,scoped:G,seamless:G,selected:G,shadowRootClonable:G,shadowRootCustomElementRegistry:G,shadowRootDelegatesFocus:G,shadowRootMode:null,shadowRootSerializable:G,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:Tx,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:G,useMap:null,value:Tx,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Dx,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:G,declare:G,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:G,noHref:G,noShade:G,noWrap:G,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:Tx,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:G,disablePictureInPicture:G,disableRemotePlayback:G,exportParts:Ox,part:Dx,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:Lx}),zx=Px({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:kx,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:Dx,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:G,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ox,g2:Ox,glyphName:Ox,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:kx,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Dx,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:kx,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:kx,rev:kx,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:kx,requiredFeatures:kx,requiredFonts:kx,requiredFormats:kx,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:kx,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:kx,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:kx,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Ix}),Bx=Px({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Vx=Px({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Lx}),Hx=Px({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Ux={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Wx=/[A-Z]/g,Gx=/-[a-z]/g,Kx=/^data[-\w.:]+$/i;function qx(e,t){let n=xx(t),r=t,i=Sx;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Kx.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Gx,Yx);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Gx.test(e)){let n=e.replace(Wx,Jx);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Mx}return new i(r,t)}function Jx(e){return`-`+e.toLowerCase()}function Yx(e){return e.charAt(1).toUpperCase()}var Xx=bx([Fx,Rx,Bx,Vx,Hx],`html`),Zx=bx([Fx,zx,Bx,Vx,Hx],`svg`);function Qx(e){return e.join(` `).trim()}var $x=r(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
61
- `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),eS=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t($x());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),tS=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),nS=r(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(eS()),r=tS();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),rS=aS(`end`),iS=aS(`start`);function aS(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function oS(e){let t=iS(e),n=rS(e);if(t&&n)return{start:t,end:n}}function sS(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?lS(e.position):`start`in e||`end`in e?lS(e):`line`in e||`column`in e?cS(e):``}function cS(e){return uS(e&&e.line)+`:`+uS(e&&e.column)}function lS(e){return cS(e&&e.start)+`-`+cS(e&&e.end)}function uS(e){return e&&typeof e==`number`?e:1}var dS=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=sS(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};dS.prototype.file=``,dS.prototype.name=``,dS.prototype.reason=``,dS.prototype.message=``,dS.prototype.stack=``,dS.prototype.column=void 0,dS.prototype.line=void 0,dS.prototype.ancestors=void 0,dS.prototype.cause=void 0,dS.prototype.fatal=void 0,dS.prototype.place=void 0,dS.prototype.ruleId=void 0,dS.prototype.source=void 0;var fS=n(nS(),1),pS={}.hasOwnProperty,mS=new Map,hS=/[A-Z]/g,gS=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),_S=new Set([`td`,`th`]),vS=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function yS(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=AS(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=kS(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Zx:Xx,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=bS(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function bS(e,t,n){if(t.type===`element`)return xS(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return SS(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return wS(e,t,n);if(t.type===`mdxjsEsm`)return CS(e,t);if(t.type===`root`)return TS(e,t,n);if(t.type===`text`)return ES(e,t)}function xS(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Zx,e.schema=i),e.ancestors.push(t);let a=IS(e,t.tagName,!1),o=jS(e,t),s=NS(e,t);return gS.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!_x(e)})),DS(e,o,a,t),OS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function SS(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}LS(e,t.position)}function CS(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);LS(e,t.position)}function wS(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Zx,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:IS(e,t.name,!0),o=MS(e,t),s=NS(e,t);return DS(e,o,a,t),OS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function TS(e,t,n){let r={};return OS(r,NS(e,t)),e.create(t,e.Fragment,r,n)}function ES(e,t){return t.value}function DS(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function OS(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function kS(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function AS(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=iS(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function jS(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&pS.call(t.properties,i)){let a=PS(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&_S.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function MS(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else LS(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else LS(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function NS(e,t){let n=[],r=-1,i=e.passKeys?new Map:mS;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=bS(e,a,o);s!==void 0&&n.push(s)}return n}function PS(e,t,n){let r=qx(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?dx(n):Qx(n)),r.property===`style`){let t=typeof n==`object`?n:FS(e,String(n));return e.stylePropertyNameCase===`css`&&(t=RS(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Ux[r.property]||r.property:r.attribute,n]}}function FS(e,t){try{return(0,fS.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new dS("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=vS+`#cannot-parse-style-attribute`,r}}function IS(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=hx(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=hx(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return pS.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);LS(e)}function LS(e,t){let n=new dS("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=vS+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function RS(e){let t={},n;for(n in e)pS.call(e,n)&&(t[zS(n)]=e[n]);return t}function zS(e){let t=e.replace(hS,BS);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function BS(e){return`-`+e.toLowerCase()}var VS={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},HS={};function US(e,t){let n=t||HS;return WS(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function WS(e,t,n){if(KS(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return GS(e.children,t,n)}return Array.isArray(e)?GS(e,t,n):``}function GS(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=WS(e[i],t,n);return r.join(``)}function KS(e){return!!(e&&typeof e==`object`)}var qS=document.createElement(`i`);function JS(e){let t=`&`+e+`;`;qS.innerHTML=t;let n=qS.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function YS(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function XS(e,t){return e.length>0?(YS(e,e.length,0,t),e):t}var ZS={}.hasOwnProperty;function QS(e){let t={},n=-1;for(;++n<e.length;)$S(t,e[n]);return t}function $S(e,t){let n;for(n in t){let r=(ZS.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){ZS.call(r,a)||(r[a]=[]);let e=i[a];eC(r[a],Array.isArray(e)?e:e?[e]:[])}}}function eC(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);YS(e,0,0,r)}function tC(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function nC(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var rC=mC(/[A-Za-z]/),iC=mC(/[\dA-Za-z]/),aC=mC(/[#-'*+\--9=?A-Z^-~]/);function oC(e){return e!==null&&(e<32||e===127)}var sC=mC(/\d/),cC=mC(/[\dA-Fa-f]/),lC=mC(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function uC(e){return e!==null&&(e<0||e===32)}function dC(e){return e===-2||e===-1||e===32}var fC=mC(/\p{P}|\p{S}/u),pC=mC(/\s/);function mC(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function hC(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&iC(e.charCodeAt(n+1))&&iC(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function gC(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return dC(r)?(e.enter(n),s(r)):t(r)}function s(r){return dC(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var _C={tokenize:vC};function vC(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),gC(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var yC={tokenize:xC},bC={tokenize:SC};function xC(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return YS(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(bC,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(bC,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;YS(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function SC(e,t,n){return gC(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function CC(e){if(e===null||uC(e)||pC(e))return 1;if(fC(e))return 2}function wC(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var TC={name:`attention`,resolveAll:EC,tokenize:DC};function EC(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};OC(d,-c),OC(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=XS(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=XS(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=XS(l,wC(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=XS(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=XS(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,YS(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function DC(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=CC(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=CC(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function OC(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var kC={name:`autolink`,tokenize:AC};function AC(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return rC(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||iC(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||iC(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||oC(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):aC(t)?(e.consume(t),l):n(t)}function u(e){return iC(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||iC(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var jC={partial:!0,tokenize:MC};function MC(e,t,n){return r;function r(t){return dC(t)?gC(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var NC={continuation:{tokenize:FC},exit:IC,name:`blockQuote`,tokenize:PC};function PC(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return dC(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function FC(e,t,n){let r=this;return i;function i(t){return dC(t)?gC(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(NC,t,n)(r)}}function IC(e){e.exit(`blockQuote`)}var LC={name:`characterEscape`,tokenize:RC};function RC(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return lC(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var zC={name:`characterReference`,tokenize:BC};function BC(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=iC,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=cC,u):(e.enter(`characterReferenceValue`),a=7,o=sC,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===iC&&!JS(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var VC={partial:!0,tokenize:WC},HC={concrete:!0,name:`codeFenced`,tokenize:UC};function UC(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),dC(t)?gC(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(VC,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):dC(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),gC(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&dC(t)?gC(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(VC,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),dC(t)?gC(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),dC(t)?gC(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function WC(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var GC={name:`codeIndented`,tokenize:qC},KC={partial:!0,tokenize:JC};function qC(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),gC(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(KC,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function JC(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):gC(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var YC={name:`codeText`,previous:ZC,resolve:XC,tokenize:QC};function XC(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function ZC(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function QC(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var $C=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&ew(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),ew(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ew(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);ew(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);ew(this.left,t.reverse())}}}};function ew(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function tw(e){let t={},n=-1,r,i,a,o,s,c,l,u=new $C(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,nw(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return YS(e,0,1/0,u.slice(0)),!l}function nw(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var rw={resolve:aw,tokenize:ow},iw={partial:!0,tokenize:sw};function aw(e){return tw(e),e}function ow(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(iw,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function sw(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),gC(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function cw(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||oC(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||uC(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||oC(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function lw(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!dC(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function uw(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),gC(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function dw(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):dC(i)?gC(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var fw={name:`definition`,tokenize:mw},pw={partial:!0,tokenize:hw};function mw(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return lw.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=nC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return uC(t)?dw(e,l)(t):l(t)}function l(t){return cw(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(pw,d,d)(t)}function d(t){return dC(t)?gC(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function hw(e,t,n){return r;function r(t){return uC(t)?dw(e,i)(t):n(t)}function i(t){return uw(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return dC(t)?gC(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var gw={name:`hardBreakEscape`,tokenize:_w};function _w(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var vw={name:`headingAtx`,resolve:yw,tokenize:bw};function yw(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},YS(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function bw(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||uC(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):dC(n)?gC(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||uC(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var xw=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Sw=[`pre`,`script`,`style`,`textarea`],Cw={concrete:!0,name:`htmlFlow`,resolveTo:Ew,tokenize:Dw},ww={partial:!0,tokenize:kw},Tw={partial:!0,tokenize:Ow};function Ew(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Dw(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:re):rC(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):rC(a)?(e.consume(a),i=4,r.interrupt?t:re):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:re):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return rC(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||uC(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Sw.includes(l)?(i=1,r.interrupt?t(s):O(s)):xw.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||iC(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return dC(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||rC(t)?(e.consume(t),b):dC(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||iC(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):dC(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):dC(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||uC(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||dC(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):dC(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),ee):t===62&&i===4?(e.consume(t),ie):t===63&&i===3?(e.consume(t),re):t===93&&i===5?(e.consume(t),ne):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(ww,ae,k)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Tw,A,ae)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),re):O(t)}function ee(t){return t===47?(e.consume(t),o=``,te):O(t)}function te(t){if(t===62){let n=o.toLowerCase();return Sw.includes(n)?(e.consume(t),ie):O(t)}return rC(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),te):O(t)}function ne(t){return t===93?(e.consume(t),re):O(t)}function re(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),re):O(t)}function ie(t){return t===null||q(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),ie)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function Ow(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function kw(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(jC,t,n)}}var Aw={name:`htmlText`,tokenize:jw};function jw(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):rC(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):rC(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,ee(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,ee(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):q(t)?(o=v,ee(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,ee(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return rC(t)?(e.consume(t),S):n(t)}function S(t){return t===45||iC(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,ee(t)):dC(t)?(e.consume(t),C):M(t)}function w(t){return t===45||iC(t)?(e.consume(t),w):t===47||t===62||uC(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||rC(t)?(e.consume(t),E):q(t)?(o=T,ee(t)):dC(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||iC(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,ee(t)):dC(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):q(t)?(o=O,ee(t)):dC(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):q(t)?(o=k,ee(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||uC(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||uC(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ee(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return dC(t)?gC(e,ne,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ne(t)}function ne(t){return e.enter(`htmlTextData`),o(t)}}var Mw={name:`labelEnd`,resolveAll:Iw,resolveTo:Lw,tokenize:Rw},Nw={tokenize:zw},Pw={tokenize:Bw},Fw={tokenize:Vw};function Iw(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&YS(e,0,e.length,n),e}function Lw(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=XS(s,e.slice(a+1,a+r+3)),s=XS(s,[[`enter`,u,t]]),s=XS(s,wC(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=XS(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=XS(s,e.slice(o+1)),s=XS(s,[[`exit`,c,t]]),YS(e,a,e.length,s),e}function Rw(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(nC(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Nw,u,o?u:d)(t):t===91?e.attempt(Pw,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Fw,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function zw(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return uC(t)?dw(e,a)(t):a(t)}function a(t){return t===41?u(t):cw(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return uC(t)?dw(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?uw(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return uC(t)?dw(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Bw(e,t,n){let r=this;return i;function i(t){return lw.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(nC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Vw(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Hw={name:`labelStartImage`,resolveAll:Mw.resolveAll,tokenize:Uw};function Uw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Ww={name:`labelStartLink`,resolveAll:Mw.resolveAll,tokenize:Gw};function Gw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Kw={name:`lineEnding`,tokenize:qw};function qw(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),gC(e,t,`linePrefix`)}}var Jw={name:`thematicBreak`,tokenize:Yw};function Yw(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),dC(t)?gC(e,s,`whitespace`)(t):s(t))}}var Xw={continuation:{tokenize:eT},exit:nT,name:`list`,tokenize:$w},Zw={partial:!0,tokenize:rT},Qw={partial:!0,tokenize:tT};function $w(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:sC(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Jw,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return sC(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(jC,r.interrupt?n:u,e.attempt(Zw,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return dC(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function eT(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(jC,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,gC(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!dC(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Qw,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,gC(e,e.attempt(Xw,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function tT(e,t,n){let r=this;return gC(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function nT(e){e.exit(this.containerState.type)}function rT(e,t,n){let r=this;return gC(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!dC(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var iT={name:`setextUnderline`,resolveTo:aT,tokenize:oT};function aT(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function oT(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),dC(t)?gC(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var sT={tokenize:cT};function cT(e){let t=this,n=e.attempt(jC,r,e.attempt(this.parser.constructs.flowInitial,i,gC(e,e.attempt(this.parser.constructs.flow,i,e.attempt(rw,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var lT={resolveAll:pT()},uT=fT(`string`),dT=fT(`text`);function fT(e){return{resolveAll:pT(e===`text`?mT:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function pT(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function mT(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var hT=e({attentionMarkers:()=>CT,contentInitial:()=>_T,disable:()=>wT,document:()=>gT,flow:()=>yT,flowInitial:()=>vT,insideSpan:()=>ST,string:()=>bT,text:()=>xT}),gT={42:Xw,43:Xw,45:Xw,48:Xw,49:Xw,50:Xw,51:Xw,52:Xw,53:Xw,54:Xw,55:Xw,56:Xw,57:Xw,62:NC},_T={91:fw},vT={[-2]:GC,[-1]:GC,32:GC},yT={35:vw,42:Jw,45:[iT,Jw],60:Cw,61:iT,95:Jw,96:HC,126:HC},bT={38:zC,92:LC},xT={[-5]:Kw,[-4]:Kw,[-3]:Kw,33:Hw,38:zC,42:TC,60:[kC,Aw],91:Ww,92:[gw,LC],93:Mw,95:TC,96:YC},ST={null:[TC,lT]},CT={null:[42,95]},wT={null:[]};function TT(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=XS(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=wC(a,l.events,l),l.events):[]}function f(e,t){return DT(p(e),t)}function p(e){return ET(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&YS(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function ET(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function DT(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
60
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=yp,s=!ip.jitless,c=s&&bp.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Hh([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Gh(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Fp(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Rp(e,r,ap())))}),t)}var Kh=I(`$ZodUnion`,(e,t)=>{rh.init(e,t),pp(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),pp(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),pp(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),pp(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>up(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Gh(t,i,e,a)):Gh(s,i,e,a)}}),qh=I(`$ZodIntersection`,(e,t)=>{rh.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Yh(e,t,n)):Yh(e,i,a)}});function Jh(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(xp(e)&&xp(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Jh(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Jh(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yh(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Fp(e))return e;let r=Jh(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var Xh=I(`$ZodRecord`,(e,t)=>{rh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!xp(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Ip(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Ip(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Rp(e,r,ap())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Ip(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Ip(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Zh=I(`$ZodEnum`,(e,t)=>{rh.init(e,t);let n=op(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Cp.has(typeof e)).map(e=>typeof e==`string`?wp(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Qh=I(`$ZodLiteral`,(e,t)=>{if(rh.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?wp(e):e?wp(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),$h=I(`$ZodTransform`,(e,t)=>{rh.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rp(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new np;return n.value=i,n}});function eg(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var tg=I(`$ZodOptional`,(e,t)=>{rh.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,pp(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),pp(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${up(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>eg(t,e.value)):eg(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ng=I(`$ZodNullable`,(e,t)=>{rh.init(e,t),pp(e._zod,`optin`,()=>t.innerType._zod.optin),pp(e._zod,`optout`,()=>t.innerType._zod.optout),pp(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${up(e.source)}|null)$`):void 0}),pp(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),rg=I(`$ZodDefault`,(e,t)=>{rh.init(e,t),e._zod.optin=`optional`,pp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ig(e,t)):ig(r,t)}});function ig(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ag=I(`$ZodPrefault`,(e,t)=>{rh.init(e,t),e._zod.optin=`optional`,pp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),og=I(`$ZodNonOptional`,(e,t)=>{rh.init(e,t),pp(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>sg(t,e)):sg(i,e)}});function sg(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var cg=I(`$ZodCatch`,(e,t)=>{rh.init(e,t),pp(e._zod,`optin`,()=>t.innerType._zod.optin),pp(e._zod,`optout`,()=>t.innerType._zod.optout),pp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Rp(e,n,ap()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Rp(e,n,ap()))},input:e.value}),e.issues=[]),e)}}),lg=I(`$ZodPipe`,(e,t)=>{rh.init(e,t),pp(e._zod,`values`,()=>t.in._zod.values),pp(e._zod,`optin`,()=>t.in._zod.optin),pp(e._zod,`optout`,()=>t.out._zod.optout),pp(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ug(e,t.in,n)):ug(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ug(e,t.out,n)):ug(r,t.out,n)}});function ug(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var dg=I(`$ZodReadonly`,(e,t)=>{rh.init(e,t),pp(e._zod,`propValues`,()=>t.innerType._zod.propValues),pp(e._zod,`values`,()=>t.innerType._zod.values),pp(e._zod,`optin`,()=>t.innerType._zod.optin),pp(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(fg):fg(r)}});function fg(e){return e.value=Object.freeze(e.value),e}var pg=I(`$ZodLazy`,(e,t)=>{rh.init(e,t),pp(e._zod,`innerType`,()=>t.getter()),pp(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),pp(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),pp(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),pp(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),mg=I(`$ZodCustom`,(e,t)=>{Rm.init(e,t),rh.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>hg(t,n,r,e));hg(i,n,r,e)}});function hg(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Bp(e))}}var gg=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function _g(){return new gg}var vg=_g();function yg(e,t){return new e({type:`string`,...L(t)})}function bg(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function xg(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function Sg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function Cg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function wg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Tg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function Eg(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function Dg(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function Og(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function kg(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Ag(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function jg(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Mg(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function Ng(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function Pg(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function Fg(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function Ig(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function Lg(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function Rg(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function zg(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function Bg(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function Vg(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function Hg(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function Ug(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function Wg(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function Gg(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function Kg(e,t){return new e({type:`number`,checks:[],...L(t)})}function qg(e,t){return new e({type:`number`,coerce:!0,checks:[],...L(t)})}function Jg(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function Yg(e,t){return new e({type:`boolean`,...L(t)})}function Xg(e,t){return new e({type:`null`,...L(t)})}function Zg(e){return new e({type:`unknown`})}function Qg(e,t){return new e({type:`never`,...L(t)})}function $g(e,t){return new Bm({check:`less_than`,...L(t),value:e,inclusive:!1})}function e_(e,t){return new Bm({check:`less_than`,...L(t),value:e,inclusive:!0})}function t_(e,t){return new Vm({check:`greater_than`,...L(t),value:e,inclusive:!1})}function n_(e,t){return new Vm({check:`greater_than`,...L(t),value:e,inclusive:!0})}function r_(e,t){return new Hm({check:`multiple_of`,...L(t),value:e})}function i_(e,t){return new Wm({check:`max_length`,...L(t),maximum:e})}function a_(e,t){return new Gm({check:`min_length`,...L(t),minimum:e})}function o_(e,t){return new Km({check:`length_equals`,...L(t),length:e})}function s_(e,t){return new Jm({check:`string_format`,format:`regex`,...L(t),pattern:e})}function c_(e){return new Ym({check:`string_format`,format:`lowercase`,...L(e)})}function l_(e){return new Xm({check:`string_format`,format:`uppercase`,...L(e)})}function u_(e,t){return new Zm({check:`string_format`,format:`includes`,...L(t),includes:e})}function d_(e,t){return new Qm({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function f_(e,t){return new $m({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function p_(e){return new eh({check:`overwrite`,tx:e})}function m_(e){return p_(t=>t.normalize(e))}function h_(){return p_(e=>e.trim())}function g_(){return p_(e=>e.toLowerCase())}function __(){return p_(e=>e.toUpperCase())}function v_(e,t,n){return new e({type:`array`,element:t,...L(n)})}function y_(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function b_(e){let t=x_(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Bp(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Bp(r))}},e(n.value,n)));return t}function x_(e,t){let n=new Rm({check:`custom`,...L(t)});return n._zod.check=e,n}var S_=I(`ZodISODateTime`,(e,t)=>{_h.init(e,t),q_.init(e,t)});function C_(e){return Hg(S_,e)}var w_=I(`ZodISODate`,(e,t)=>{vh.init(e,t),q_.init(e,t)});function T_(e){return Ug(w_,e)}var E_=I(`ZodISOTime`,(e,t)=>{yh.init(e,t),q_.init(e,t)});function D_(e){return Wg(E_,e)}var O_=I(`ZodISODuration`,(e,t)=>{bh.init(e,t),q_.init(e,t)});function k_(e){return Gg(O_,e)}var A_=(e,t)=>{Hp.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Gp(e,t)},flatten:{value:t=>Wp(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,sp,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,sp,2)}},isEmpty:{get(){return e.issues.length===0}}})};I(`ZodError`,A_);var j_=I(`ZodError`,A_,{Parent:Error}),M_=Kp(j_),N_=qp(j_),P_=Jp(j_),F_=Xp(j_),I_=Qp(j_),L_=$p(j_),R_=em(j_),z_=tm(j_),B_=nm(j_),V_=rm(j_),H_=im(j_),U_=am(j_),W_=I(`ZodType`,(e,t)=>(rh.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>Tp(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>M_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>P_(e,t,n),e.parseAsync=async(t,n)=>N_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>F_(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>I_(e,t,n),e.decode=(t,n)=>L_(e,t,n),e.encodeAsync=async(t,n)=>R_(e,t,n),e.decodeAsync=async(t,n)=>z_(e,t,n),e.safeEncode=(t,n)=>B_(e,t,n),e.safeDecode=(t,n)=>V_(e,t,n),e.safeEncodeAsync=async(t,n)=>H_(e,t,n),e.safeDecodeAsync=async(t,n)=>U_(e,t,n),e.refine=(t,n)=>e.check(ny(t,n)),e.superRefine=t=>e.check(ry(t)),e.overwrite=t=>e.check(p_(t)),e.optional=()=>Rv(e),e.nullable=()=>Bv(e),e.nullish=()=>Rv(Bv(e)),e.nonoptional=t=>Kv(e,t),e.array=()=>B(e),e.or=t=>Dv([e,t]),e.and=t=>kv(e,t),e.transform=t=>Xv(e,Iv(t)),e.default=t=>Hv(e,t),e.prefault=t=>Wv(e,t),e.catch=t=>Jv(e,t),e.pipe=t=>Xv(e,t),e.readonly=()=>Qv(e),e.describe=t=>{let n=e.clone();return vg.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return vg.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return vg.get(e);let n=e.clone();return vg.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),G_=I(`_ZodString`,(e,t)=>{ih.init(e,t),W_.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(s_(...t)),e.includes=(...t)=>e.check(u_(...t)),e.startsWith=(...t)=>e.check(d_(...t)),e.endsWith=(...t)=>e.check(f_(...t)),e.min=(...t)=>e.check(a_(...t)),e.max=(...t)=>e.check(i_(...t)),e.length=(...t)=>e.check(o_(...t)),e.nonempty=(...t)=>e.check(a_(1,...t)),e.lowercase=t=>e.check(c_(t)),e.uppercase=t=>e.check(l_(t)),e.trim=()=>e.check(h_()),e.normalize=(...t)=>e.check(m_(...t)),e.toLowerCase=()=>e.check(g_()),e.toUpperCase=()=>e.check(__())}),K_=I(`ZodString`,(e,t)=>{ih.init(e,t),G_.init(e,t),e.email=t=>e.check(bg(J_,t)),e.url=t=>e.check(Eg(Z_,t)),e.jwt=t=>e.check(Vg(fv,t)),e.emoji=t=>e.check(Dg(Q_,t)),e.guid=t=>e.check(xg(Y_,t)),e.uuid=t=>e.check(Sg(X_,t)),e.uuidv4=t=>e.check(Cg(X_,t)),e.uuidv6=t=>e.check(wg(X_,t)),e.uuidv7=t=>e.check(Tg(X_,t)),e.nanoid=t=>e.check(Og($_,t)),e.guid=t=>e.check(xg(Y_,t)),e.cuid=t=>e.check(kg(ev,t)),e.cuid2=t=>e.check(Ag(tv,t)),e.ulid=t=>e.check(jg(nv,t)),e.base64=t=>e.check(Rg(lv,t)),e.base64url=t=>e.check(zg(uv,t)),e.xid=t=>e.check(Mg(rv,t)),e.ksuid=t=>e.check(Ng(iv,t)),e.ipv4=t=>e.check(Pg(av,t)),e.ipv6=t=>e.check(Fg(ov,t)),e.cidrv4=t=>e.check(Ig(sv,t)),e.cidrv6=t=>e.check(Lg(cv,t)),e.e164=t=>e.check(Bg(dv,t)),e.datetime=t=>e.check(C_(t)),e.date=t=>e.check(T_(t)),e.time=t=>e.check(D_(t)),e.duration=t=>e.check(k_(t))});function R(e){return yg(K_,e)}var q_=I(`ZodStringFormat`,(e,t)=>{ah.init(e,t),G_.init(e,t)}),J_=I(`ZodEmail`,(e,t)=>{ch.init(e,t),q_.init(e,t)}),Y_=I(`ZodGUID`,(e,t)=>{oh.init(e,t),q_.init(e,t)}),X_=I(`ZodUUID`,(e,t)=>{sh.init(e,t),q_.init(e,t)}),Z_=I(`ZodURL`,(e,t)=>{lh.init(e,t),q_.init(e,t)}),Q_=I(`ZodEmoji`,(e,t)=>{uh.init(e,t),q_.init(e,t)}),$_=I(`ZodNanoID`,(e,t)=>{dh.init(e,t),q_.init(e,t)}),ev=I(`ZodCUID`,(e,t)=>{fh.init(e,t),q_.init(e,t)}),tv=I(`ZodCUID2`,(e,t)=>{ph.init(e,t),q_.init(e,t)}),nv=I(`ZodULID`,(e,t)=>{mh.init(e,t),q_.init(e,t)}),rv=I(`ZodXID`,(e,t)=>{hh.init(e,t),q_.init(e,t)}),iv=I(`ZodKSUID`,(e,t)=>{gh.init(e,t),q_.init(e,t)}),av=I(`ZodIPv4`,(e,t)=>{xh.init(e,t),q_.init(e,t)}),ov=I(`ZodIPv6`,(e,t)=>{Sh.init(e,t),q_.init(e,t)}),sv=I(`ZodCIDRv4`,(e,t)=>{Ch.init(e,t),q_.init(e,t)}),cv=I(`ZodCIDRv6`,(e,t)=>{wh.init(e,t),q_.init(e,t)}),lv=I(`ZodBase64`,(e,t)=>{Eh.init(e,t),q_.init(e,t)}),uv=I(`ZodBase64URL`,(e,t)=>{Oh.init(e,t),q_.init(e,t)}),dv=I(`ZodE164`,(e,t)=>{kh.init(e,t),q_.init(e,t)}),fv=I(`ZodJWT`,(e,t)=>{jh.init(e,t),q_.init(e,t)}),pv=I(`ZodNumber`,(e,t)=>{Mh.init(e,t),W_.init(e,t),e.gt=(t,n)=>e.check(t_(t,n)),e.gte=(t,n)=>e.check(n_(t,n)),e.min=(t,n)=>e.check(n_(t,n)),e.lt=(t,n)=>e.check($g(t,n)),e.lte=(t,n)=>e.check(e_(t,n)),e.max=(t,n)=>e.check(e_(t,n)),e.int=t=>e.check(hv(t)),e.safe=t=>e.check(hv(t)),e.positive=t=>e.check(t_(0,t)),e.nonnegative=t=>e.check(n_(0,t)),e.negative=t=>e.check($g(0,t)),e.nonpositive=t=>e.check(e_(0,t)),e.multipleOf=(t,n)=>e.check(r_(t,n)),e.step=(t,n)=>e.check(r_(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function z(e){return Kg(pv,e)}var mv=I(`ZodNumberFormat`,(e,t)=>{Nh.init(e,t),pv.init(e,t)});function hv(e){return Jg(mv,e)}var gv=I(`ZodBoolean`,(e,t)=>{Ph.init(e,t),W_.init(e,t)});function _v(e){return Yg(gv,e)}var vv=I(`ZodNull`,(e,t)=>{Fh.init(e,t),W_.init(e,t)});function yv(e){return Xg(vv,e)}var bv=I(`ZodUnknown`,(e,t)=>{Ih.init(e,t),W_.init(e,t)});function xv(){return Zg(bv)}var Sv=I(`ZodNever`,(e,t)=>{Lh.init(e,t),W_.init(e,t)});function Cv(e){return Qg(Sv,e)}var wv=I(`ZodArray`,(e,t)=>{zh.init(e,t),W_.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(a_(t,n)),e.nonempty=t=>e.check(a_(1,t)),e.max=(t,n)=>e.check(i_(t,n)),e.length=(t,n)=>e.check(o_(t,n)),e.unwrap=()=>e.element});function B(e,t){return v_(wv,e,t)}var Tv=I(`ZodObject`,(e,t)=>{Wh.init(e,t),W_.init(e,t),pp(e,`shape`,()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:xv()}),e.loose=()=>e.clone({...e._zod.def,catchall:xv()}),e.strict=()=>e.clone({...e._zod.def,catchall:Cv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Ap(e,t),e.safeExtend=t=>jp(e,t),e.merge=t=>Mp(e,t),e.pick=t=>Op(e,t),e.omit=t=>kp(e,t),e.partial=(...t)=>Np(Lv,e,t[0]),e.required=(...t)=>Pp(Gv,e,t[0])});function V(e,t){return new Tv({type:`object`,get shape(){return hp(this,`shape`,e?mp(e):{}),this.shape},...L(t)})}var Ev=I(`ZodUnion`,(e,t)=>{Kh.init(e,t),W_.init(e,t),e.options=t.options});function Dv(e,t){return new Ev({type:`union`,options:e,...L(t)})}var Ov=I(`ZodIntersection`,(e,t)=>{qh.init(e,t),W_.init(e,t)});function kv(e,t){return new Ov({type:`intersection`,left:e,right:t})}var Av=I(`ZodRecord`,(e,t)=>{Xh.init(e,t),W_.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function jv(e,t,n){return new Av({type:`record`,keyType:e,valueType:t,...L(n)})}var Mv=I(`ZodEnum`,(e,t)=>{Zh.init(e,t),W_.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Mv({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Mv({...t,checks:[],...L(r),entries:i})}});function H(e,t){return new Mv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Nv=I(`ZodLiteral`,(e,t)=>{Qh.init(e,t),W_.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Pv(e,t){return new Nv({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Fv=I(`ZodTransform`,(e,t)=>{$h.init(e,t),W_.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new rp(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Bp(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Bp(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Iv(e){return new Fv({type:`transform`,transform:e})}var Lv=I(`ZodOptional`,(e,t)=>{tg.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Rv(e){return new Lv({type:`optional`,innerType:e})}var zv=I(`ZodNullable`,(e,t)=>{ng.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Bv(e){return new zv({type:`nullable`,innerType:e})}var Vv=I(`ZodDefault`,(e,t)=>{rg.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Hv(e,t){return new Vv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sp(t)}})}var Uv=I(`ZodPrefault`,(e,t)=>{ag.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Wv(e,t){return new Uv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Sp(t)}})}var Gv=I(`ZodNonOptional`,(e,t)=>{og.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Kv(e,t){return new Gv({type:`nonoptional`,innerType:e,...L(t)})}var qv=I(`ZodCatch`,(e,t)=>{cg.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Jv(e,t){return new qv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Yv=I(`ZodPipe`,(e,t)=>{lg.init(e,t),W_.init(e,t),e.in=t.in,e.out=t.out});function Xv(e,t){return new Yv({type:`pipe`,in:e,out:t})}var Zv=I(`ZodReadonly`,(e,t)=>{dg.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Qv(e){return new Zv({type:`readonly`,innerType:e})}var $v=I(`ZodLazy`,(e,t)=>{pg.init(e,t),W_.init(e,t),e.unwrap=()=>e._zod.def.getter()});function ey(e){return new $v({type:`lazy`,getter:e})}var ty=I(`ZodCustom`,(e,t)=>{mg.init(e,t),W_.init(e,t)});function ny(e,t={}){return y_(ty,e,t)}function ry(e){return b_(e)}function iy(e){let t=ey(()=>Dv([R(e),z(),_v(),yv(),B(t),jv(R(),t)]));return t}function ay(e){return qg(pv,e)}var U=R().uuid(),W=R().datetime({offset:!0}),oy=R().regex(/^[a-f0-9]{64}$/);R().trim().min(1);var sy=H([`owner`,`admin`,`security_manager`,`operator`,`viewer`,`auditor`]),cy=H([`R0`,`R1`,`R2`]),ly=H([`public`,`internal`,`confidential`,`restricted`]);V({cursor:R().min(1).optional(),limit:ay().int().min(1).max(200).default(50)}),V({nextCursor:R().min(1).optional(),hasMore:_v()}),V({idempotencyKey:R().trim().min(8).max(200),expectedVersion:z().int().nonnegative().optional()}),V({type:R().default(`about:blank`),title:R(),status:z().int().min(400).max(599),detail:R().optional(),instance:R().optional(),code:R().regex(/^[a-z0-9_]+$/),requestId:R(),errors:B(V({path:R(),message:R(),code:R().optional()})).optional()});var uy=V({providerId:R().nullable(),modelId:R().nullable(),inputTokens:z().int().nonnegative(),outputTokens:z().int().nonnegative(),reasoningTokens:z().int().nonnegative(),cacheReadTokens:z().int().nonnegative(),cacheWriteTokens:z().int().nonnegative(),estimatedCostUsd:z().nonnegative(),pricingSource:R().nullable(),pricingAsOf:R().nullable()}),dy=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),externalSessionId:R().nullable(),createdBy:U,status:H([`active`,`waiting`,`completed`,`failed`,`cancelled`]),mode:H([`autonomous`,`guided`]),model:R().nullable(),costUsd:z().nonnegative(),usage:uy,sensitive:_v(),createdAt:W,lastActivityAt:W}),fy=V({id:U,sessionId:U,role:H([`user`,`assistant`,`system`,`tool`]),redactedPreview:R(),sensitivePayloadArtifactId:U.nullable(),createdAt:W}),py=V({id:U,sessionId:U,runId:U.nullable(),stageId:U.nullable(),externalToolCallId:R().nullable(),toolName:R().min(1),status:H([`running`,`completed`,`failed`,`cancelled`]),inputHash:oy,outputArtifactId:U.nullable(),startedAt:W,completedAt:W.nullable()});V({session:dy,messages:B(fy),toolActivities:B(py)}),V({expectedRunVersion:z().int().nonnegative(),reason:R().trim().min(1).max(1e3)}),new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var my=H([`informational`,`low`,`medium`,`high`,`critical`]),hy=H([`clean`,`informational`,`actionable`,`critical`]),gy=V({fingerprint:oy.optional(),title:R().min(1),severity:H([`info`,`low`,`medium`,`high`,`critical`]),details:R().default(``),targetUrl:R().optional(),cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R().min(1)).default([]),remediation:R().default(``),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]).default(`candidate`),evidenceRefs:B(oy).default([])}),_y=V({description:R().min(1),artifactType:R().min(1),data:iy().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional()}),vy=H([`observation`,`artifact`,`control_result`,`manual_confirmation`,`report`]),yy=V({fingerprint:oy,title:R().min(1),description:R().default(``),severity:my,cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R()).default([]),remediation:R().default(``),targetUrl:R().optional(),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]),evidenceRefs:B(oy).default([]),status:H([`open`]).default(`open`)}).strict(),by=V({fingerprint:oy,kind:vy,title:R().min(1),summary:R().default(``),artifactType:R(),sha256:oy,timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional(),classification:ly.default(`confidential`)}).strict(),xy=V({satisfied:_v(),missing:B(R())}).strict(),Sy=V({id:U,runId:U,projectId:U,workflowKey:R().min(1),workflowVersionId:U,version:z().int().nonnegative(),contentHash:oy,target:R().min(1),scopeOrigins:B(R()).default([]),summary:R().default(``),posture:hy,findings:B(yy).default([]),unverifiedLeads:B(yy).default([]),evidence:B(by).default([]),negativeControls:B(R()).default([]),classification:ly.default(`confidential`),publicationState:H([`draft`,`blocked`,`published`]).default(`draft`),gate:xy,parentContentHash:oy.nullable().default(null),editorialMarkdownHash:oy.nullable().default(null),publishedAt:W.optional(),createdAt:W}).strict();V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),target:R().min(1),model:R().min(1)}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),description:R().min(1),artifactType:R().min(1),data:iy().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative()}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),workflowKey:R().min(1),status:H([`succeeded`,`blocked`,`inconclusive`,`failed`]),findings:z().int().nonnegative(),evidence:z().int().nonnegative(),findingItems:B(gy).default([]),evidenceItems:B(_y).default([]),negativeControls:B(R().min(1).max(4e3)).max(500).default([]),toolAttempts:z().int().nonnegative(),toolsExecuted:z().int().nonnegative(),toolsErrored:z().int().nonnegative(),pricingUnknown:_v().optional()}),V({id:U,organizationId:U,name:R().trim().min(1).max(120),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({id:U,organizationId:U,workspaceId:U,name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),archivedAt:W.nullable(),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});var Cy=V({id:U,kind:H([`domain`,`ip`,`cidr`,`url`,`repository`,`api`,`android`,`ios`,`custom`]),locator:R().trim().min(1).max(2048),displayName:R().trim().min(1).max(240)}),wy=V({id:U,owner:R().trim().min(1),documentArtifactId:U,validFrom:W,validUntil:W,allowedActions:B(R().min(1)).min(1),prohibitedActions:B(R().min(1)),sha256:oy}),Ty=V({requestsPerSecond:z().positive().optional(),concurrency:z().int().positive().optional(),durationSeconds:z().int().positive(),costUsd:z().nonnegative().optional(),modelTokens:z().int().nonnegative().optional()}),Ey=V({projectId:U,name:R().trim().min(1).max(160),targets:B(Cy).min(1),exclusions:B(R().trim().min(1)),authorization:wy.optional(),allowedRisk:cy,allowedActions:B(R().min(1)),prohibitedActions:B(R().min(1)),limits:Ty,requiredWorkerClass:R().trim().min(1),requiredCapabilities:B(R().trim().min(1)),credentialReferences:B(R().trim().min(1)),dataClassification:ly,retentionPolicyId:U.optional(),notificationChannels:B(R().trim().min(1))}).extend({id:U,organizationId:U,workspaceId:U,revision:z().int().positive(),inputHash:oy,createdAt:W,createdBy:U}),Dy=H([`open`,`in_progress`,`accepted_risk`,`false_positive`,`remediated`,`verified`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,title:R().min(1),description:R(),severity:H([`informational`,`low`,`medium`,`high`,`critical`]),status:Dy,fingerprint:oy,version:z().int().nonnegative(),firstSeenAt:W,lastSeenAt:W}),V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),stageId:U.nullable(),agentSessionId:U.nullable(),toolCallId:U.nullable(),kind:H([`observation`,`artifact`,`report`,`manual_confirmation`,`control_result`]),title:R().min(1),summary:R(),classification:ly,artifactId:U.nullable(),sha256:oy,createdAt:W});var Oy=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,objectKey:R().min(1),sha256:oy,mimeType:R().min(1),size:z().int().nonnegative(),classification:ly,createdBy:U,createdAt:W}),ky=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`mobile-application`,`red-team-campaign`,`purple-team-validation`,`nist-csf-2`,`cis-controls-8-1`,`advanced-security-testing`,`remediation-validation`,`network-security-audit`]),Ay=V({key:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),name:R().min(1),description:R().min(1),risk:cy,optional:_v().default(!1),requiredCapabilities:B(R().min(1)),skillRefs:B(R().min(1).max(80)).max(64).default([]),retrySafe:_v(),approvalCheckpoint:_v(),timeoutSeconds:z().int().positive()}),jy=V({id:U,key:ky,version:R().regex(/^\d+\.\d+\.\d+$/),name:R().min(1),description:R().min(1),inputSchema:jv(R(),xv()),requiredCapabilities:B(R().min(1)),requiredIntegrations:B(R().min(1)),stages:B(Ay).min(1),evidenceRequirements:B(R().min(1)).min(1),completionCriteria:B(R().min(1)).min(1),publishedAt:W,contentHash:oy}),My=V({code:H([`authorization_missing`,`authorization_expired`,`capability_missing`,`worker_missing`,`integration_missing`,`credential_missing`,`scope_invalid`,`approval_required`]),message:R().min(1),stageKey:R().optional(),capability:R().optional()}),Ny=V({ready:_v(),launchState:H([`ready`,`blocked`,`awaiting_approval`]),highestRisk:cy,reasons:B(My),matchingWorkerIds:B(U),inputHash:oy}),Py=H([`draft`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`cancel_requested`,`succeeded`,`failed`,`cancelled`,`expired`]),Fy=H([`pending`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`paused`,`succeeded`,`failed`,`cancel_requested`,`cancelled`,`expired`,`skipped`]);V({projectId:U,assessmentProfileId:U,workflowKey:ky,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:jv(R(),xv()),workerClass:R().min(1),mode:H([`autonomous`,`guided`]).default(`autonomous`)});var Iy=V({id:U,organizationId:U,workspaceId:U,projectId:U,assessmentId:U,assessmentProfileId:U,workflowVersionId:U,workflowKey:ky,requestedBy:U,state:Py,risk:cy,inputHash:oy,workerClass:R(),mode:H([`autonomous`,`guided`]),attempt:z().int().positive(),retryOfRunId:U.nullable(),agentSessionId:U.nullable(),usage:uy,version:z().int().nonnegative(),createdAt:W,startedAt:W.nullable(),completedAt:W.nullable()}),Ly=V({id:U,runId:U,key:R().min(1),position:z().int().nonnegative(),risk:cy,state:Fy,workerId:U.nullable(),version:z().int().nonnegative(),startedAt:W.nullable(),completedAt:W.nullable()});V({id:z().int().positive(),runId:U,stageId:U.nullable(),type:R().min(1),payload:jv(R(),xv()),occurredAt:W}),V({after:z().int().nonnegative().default(0)});var Ry=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`network-security-audit`]);V({target:R().trim().min(1).max(2048),workflowKey:Ry,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:jv(R(),xv()).default({})}).extend({mode:H([`autonomous`,`guided`]).default(`autonomous`)}),V({owner:R().trim().min(2).max(200),statement:R().trim().min(20).max(2e3),validUntil:W});var zy=V({profile:Ey,authorization:wy,artifact:Oy}),By=V({projectId:U,target:Cy,dossierKey:R().min(1),profileId:U,profileName:R().min(1),reusedProfile:_v()}),Vy=V({binding:By,readiness:Ny}),Hy=V({binding:By,run:Iy,stages:B(Ly),agentSession:dy}),Uy=H([`pending`,`approved`,`rejected`,`expired`,`invalidated`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,stageId:U.nullable(),risk:cy,state:Uy,requestedBy:U,requiredRole:H([`security_manager`,`owner_or_admin`]),decidedBy:U.nullable(),decisionRole:H([`owner`,`admin`,`security_manager`]).nullable(),workflowVersionId:U,inputHash:oy,scopeHash:oy,targetSetHash:oy,workerClass:R().min(1),actionSetHash:oy,expiresAt:W,decidedAt:W.nullable(),reason:R().nullable()}),V({decision:H([`approve`,`reject`]),reason:R().trim().min(1).max(2e3),passwordConfirmation:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,sequence:z().int().positive(),organizationId:U,workspaceId:U,projectId:U.nullable(),actorId:U.nullable(),authSessionId:U.nullable(),action:R().min(1),resourceType:R().min(1),resourceId:R().min(1),requestId:R().min(1),correlationId:R().nullable(),ip:R().nullable(),userAgent:R().nullable(),outcome:H([`succeeded`,`denied`,`failed`]),reason:R().nullable(),beforeHash:oy.nullable(),afterHash:oy.nullable(),previousEventHash:oy.nullable(),eventHash:oy,occurredAt:W}),V({id:U,workspaceId:U,governanceDays:z().int().min(2555),assessmentDaysAfterClosure:z().int().min(1095),rawSessionDays:z().int().min(180),authSessionInvestigationDays:z().int().min(30),version:z().int().nonnegative()}),V({id:U,workspaceId:U,name:R().min(1),reason:R().min(1),resourceType:H([`assessment`,`run`,`agent_session`,`finding`,`artifact`]),resourceId:U,releasedAt:W.nullable(),createdAt:W});var Wy=H([`workspace:admin`,`project:write`,`workflow:configure`,`run:launch`,`run:approve:r1`,`run:approve:r2`,`finding:write`,`session:read`,`session:read_sensitive`,`evidence:read`,`evidence:read_sensitive`,`governance:read`,`governance:write`]);V({user:V({id:U,email:R().email(),displayName:R().min(1),mfaEnrolled:_v(),createdAt:W}),organizationId:U,memberships:B(V({workspaceId:U,workspaceName:R().min(1),role:sy,permissions:B(Wy)})),activeWorkspaceId:U}),V({id:U,userId:U,createdAt:W,lastSeenAt:W,expiresAt:W,ip:R().nullable(),userAgent:R().nullable(),current:_v()}),V({password:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,workspaceId:U,email:R().email(),role:sy,expiresAt:W,acceptedAt:W.nullable(),createdAt:W});var Gy=z().int().nonnegative(),Ky=R().min(1),qy=H([`info`,`low`,`medium`,`high`,`critical`]),Jy=H([`open`,`unverified`,`confirmed`,`remediating`,`remediated`,`verified`,`false_positive`,`accepted_risk`,`suppressed`]),Yy=H([`cli`,`tui`,`web`,`github`,`system`]),Xy=H([`scan`,`hunt`,`verify`,`import`]),Zy=H([`queued`,`running`,`completed`,`failed`,`cancelled`]),Qy=jv(R(),xv()),$y=V({id:Ky,workspaceID:Ky,projectID:Ky.nullable(),repositoryID:Ky.nullable(),engagementID:Ky.nullable(),targetID:Ky.nullable(),parentRunID:Ky.nullable(),sessionID:Ky.nullable(),source:Yy,kind:Xy,status:Zy,title:R(),requestedBy:R().nullable(),baseRevision:R().nullable(),headRevision:R().nullable(),promptRevision:R().nullable(),promptFingerprint:R().nullable(),configuration:Qy.nullable(),summary:Qy.nullable(),error:Qy.nullable(),idempotencyKey:R().nullable(),createdAt:Gy,startedAt:Gy.nullable(),completedAt:Gy.nullable(),updatedAt:Gy}),eb=V({runs:B($y),nextCursor:R().optional()}),tb=V({id:Ky,fingerprint:R().min(1),title:R(),description:R().nullable(),severity:qy,status:Jy,path:R().nullable(),line:z().int().nullable(),category:R().nullable(),firstSeenAt:Gy,lastSeenAt:Gy,updatedAt:Gy}),nb=V({findings:B(tb),total:z().int().nonnegative()}),rb=V({id:Ky,runID:Ky.nullable(),operationID:Ky.nullable(),kind:R(),verdict:R(),reason:R().nullable(),payload:Qy.nullable(),createdAt:Gy}),ib=V({finding:tb.extend({cwe:R().nullable(),cve:R().nullable(),cvssScore:z().nullable(),cvssVector:R().nullable(),remediation:R().nullable(),assignee:R().nullable(),resolvedAt:Gy.nullable(),evidence:B(rb)})}),ab=V({id:Ky,runID:Ky,tool:R(),runtime:R(),status:R(),outcome:R(),title:R().nullable(),input:Qy.nullable(),outputPreview:R().nullable(),error:Qy.nullable(),startedAt:Gy,completedAt:Gy.nullable()}),ob=V({run:$y,operations:B(ab.omit({runID:!0})),findings:B(tb)}),sb=V({id:Ky,title:R(),kind:R(),source:R(),status:H([`running`,`failed`,`completed`]),runCount:z().int().nonnegative(),operationCount:z().int().nonnegative(),findingCount:z().int().nonnegative(),startedAt:Gy,lastActivityAt:Gy}),cb=V({session:sb,runs:B($y),operations:B(ab),findings:B(tb)}),lb=V({id:Ky,sequence:z().int().positive(),actorID:R().nullable(),action:R().min(1),objectType:R().min(1),objectID:R().min(1),outcome:H([`succeeded`,`denied`,`failed`]),details:Qy.nullable(),createdAt:Gy}),ub=V({id:Ky,workspaceId:Ky,name:R(),slug:R(),archivedAt:Gy.nullable(),createdAt:Gy,updatedAt:Gy}),db=V({id:Ky,name:R(),role:R(),createdAt:Gy,updatedAt:Gy}),fb=V({id:Ky,name:R(),status:R(),capabilities:B(R()).default([]),lastSeenAt:Gy.nullable()}),pb=V({sessionId:R().nullable().optional(),runs:jv(R(),z()),findings:V({total:z().int().nonnegative(),bySeverity:jv(R(),z()),byStatus:jv(R(),z())}),recentRuns:B($y),recentFindings:B(tb)}),mb=V({count:z().int().nonnegative(),limit:z().int().positive(),hasMore:_v()});function hb(e){return V({items:B(e),page:mb})}V({workspaceId:U,clientId:U,batchId:U,records:B(V({id:U,kind:H([`agent_session`,`evidence`,`finding`,`governance_event`]),localSequence:z().int().positive(),payload:jv(R(),xv()),payloadHash:oy,occurredAt:W})).min(1).max(500)}),V({batchId:U,accepted:B(U),rejected:B(V({id:U,code:R(),detail:R()})),centralizedApproval:Pv(!1)});var gb=H([`command_execution`,`read_files`,`write_files`,`http_request`,`run_exploit`,`dns_recon`,`state_mutation`,`skill_load`]);V({stageId:R().uuid(),workflowVersionId:R().uuid(),stageKey:R().min(1),requiredCapabilities:B(R().min(1)),allowedToolCategories:B(gb),allowedSkills:B(R().min(1).max(80)).max(64).default([]),retrySafe:_v(),timeoutMs:z().int().positive()});var _b=V({workerClass:H([`network`,`web-api`,`mobile-lab`,`advanced-analysis`,`passive`]),capabilities:B(R().min(1)),tools:jv(R(),R()),networkLocation:R().nullable(),devices:B(V({id:R(),platform:H([`android`,`ios`]),version:R()})),limits:V({concurrency:z().int().positive(),memoryMb:z().int().positive(),cpuMillis:z().int().positive(),durationSeconds:z().int().positive()})});V({token:R().min(32),name:R().trim().min(1).max(160),publicKey:R().min(32),capabilities:_b}),V({expiresAt:W}),V({token:R().min(32),expiresAt:W}),V({worker:V({id:U,organizationId:U,workspaceId:U,name:R(),publicKey:R(),capabilities:_b,status:H([`enrolling`,`online`,`offline`,`revoked`]),lastHeartbeatAt:W.nullable(),createdAt:W}),accessToken:R().min(32),expiresAt:W}),V({capabilities:_b.optional(),runningJobIds:B(U)}),V({id:U,runId:U,stageId:U,workerId:U,leaseToken:R().min(32),leaseExpiresAt:W,attempt:z().int().positive(),payload:jv(R(),xv())}),V({leaseToken:R().min(32),events:B(V({idempotencyKey:R().min(8),type:R().min(1),occurredAt:W,payload:jv(R(),xv())})).min(1).max(500)});var vb=V({leaseToken:R().min(32)});vb.extend({extendSeconds:z().int().min(10).max(300).default(60)}),vb.extend({outcome:H([`succeeded`,`failed`,`cancelled`]),summary:jv(R(),xv()).default({}),error:R().max(2e4).optional(),retrySafe:_v().default(!1)});var yb=V({items:B(jy)}),bb=hb(db),xb=hb(ub),Sb=V({items:B(Ey)}),Cb=hb(sb),wb=hb(lb),Tb=hb(fb),Eb=V({id:R(),label:R(),prefix:R().optional().default(``),tokenPrefix:R().optional(),role:R().optional().default(`admin`),workspaceId:R().optional().default(`default`),createdAt:R(),expiresAt:R().nullable().optional(),lastUsedAt:R().nullable().optional()}),Db=Eb.extend({token:R()}),Ob=V({items:B(Eb)}),kb=V({items:B(V({version:z().int().nonnegative(),posture:R(),target:R(),contentHash:R(),classification:R(),publicationState:H([`draft`,`blocked`,`published`]),gate:V({satisfied:_v(),missing:B(R())}),publishedAt:R().nullable(),createdAt:R()}))}),Ab=V({ext:R(),mimeType:R(),url:R().nullable(),rendered:_v()}),jb=V({version:z().int().nonnegative(),contentHash:R(),posture:R(),target:R(),classification:R(),record:Sy,renditions:B(Ab)}),Mb=V({artifacts:B(V({artifactId:R(),mimeType:R(),size:z(),sha256:R()}))}),Nb=V({version:z().int().nonnegative(),contentHash:R(),posture:R()}),Pb=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function Fb(e=fetch){async function t(t,n,r){let i=document.querySelector(`meta[name="csrf-token"]`)?.content||sessionStorage.getItem(`kifaru-csrf`)||document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`kifaru_csrf=`))?.slice(12),a=r?.method?.toUpperCase()??`GET`,o=await e(t,{credentials:`same-origin`,...r,headers:{accept:`application/json`,...a!==`GET`&&a!==`HEAD`&&i?{"x-csrf-token":i}:{},...r?.headers}});if(!o.ok&&o.status===401&&typeof window<`u`&&!window.location.pathname.startsWith(`/login`))throw window.location.href=`/login?redirect=${encodeURIComponent(window.location.pathname+window.location.search)}`,new Pb(401,`unauthorized`,`Session expired. Redirecting to login.`);let s=await o.json().catch(()=>void 0);if(!o.ok){let e=s;throw new Pb(o.status,e?.code??`request_failed`,e?.detail??`Request failed.`)}return n.parse(s)}return{workflows:()=>t(`/api/v1/workflows`,yb),runs:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??20)),n?.sessionId&&r.set(`sessionId`,n.sessionId),t(`/api/v1/runs?${r.toString()}`,eb)},runDetail:e=>t(`/api/v1/runs/${encodeURIComponent(e)}`,ob),workspaces:()=>t(`/api/v1/workspaces`,bb),projects:()=>t(`/api/v1/projects`,xb),assessmentProfiles:()=>t(`/api/v1/assessment-profiles`,Sb),authorizeAssessmentProfile:(e,n)=>t(`/api/v1/assessment-profiles/${encodeURIComponent(e)}/authorization-attestations`,zy,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(n)}),findings:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e||`runId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??50)),n?.sessionId&&r.set(`sessionId`,n.sessionId),n?.runId&&r.set(`runId`,n.runId),t(`/api/v1/findings?${r.toString()}`,nb)},finding:e=>t(`/api/v1/findings/${encodeURIComponent(e)}`,ib),updateFindingStatus:(e,n,r)=>t(`/api/v1/findings/${encodeURIComponent(e)}/status`,ib,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:n,...r?{note:r}:{}})}),agentSessions:()=>t(`/api/v1/agent/sessions?limit=50`,Cb),agentSession:e=>t(`/api/v1/agent/sessions/${encodeURIComponent(e)}`,cb),governanceEvents:()=>t(`/api/v1/governance/audit-events?limit=50`,wb),workers:()=>t(`/api/v1/workers`,Tb),overview:e=>{let n;return typeof e==`string`?n=e:e&&typeof e==`object`&&`sessionId`in e&&typeof e.sessionId==`string`&&(n=e.sessionId),t(n?`/api/v1/overview?sessionId=${encodeURIComponent(n)}`:`/api/v1/overview`,pb)},tokens:()=>t(`/api/v1/tokens`,Ob),mintToken:e=>t(`/api/v1/tokens`,Db,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),revokeToken:e=>t(`/api/v1/tokens/${encodeURIComponent(e)}`,V({ok:_v()}),{method:`DELETE`}),targetAssessmentReadiness:e=>t(`/api/v1/assessments/readiness`,Vy,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startTargetAssessment:e=>t(`/api/v1/assessments`,Hy,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),reportVersions:e=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports`,kb),reportVersion:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}`,jb),renderReportRenditions:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/renditions`,Mb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({})}),publishEditedMarkdown:(e,n,r)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/editor`,Nb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({markdown:r})})}}var Ib=Fb(),Lb=[{n:1,name:`Collection & Onboarding`,v:`--s1`},{n:2,name:`Storage & Security`,v:`--s2`},{n:3,name:`Use & Processing`,v:`--s3`},{n:4,name:`Sharing & Disclosure`,v:`--s4`},{n:5,name:`Retention`,v:`--s5`},{n:6,name:`Disposal & Erasure`,v:`--s6`}];function Rb(e){return Lb[Math.min(Math.max(e,1),Lb.length)-1]}function zb(e){return e.name.split(` `)[0]}var Bb=[`Governance`,`Technical`,`People & 3rd-party`,`Assurance`],Vb=[`critical`,`high`,`medium`,`low`,`info`],Hb={critical:0,high:1,medium:2,low:3,info:4},Ub={critical:`--crit`,high:`--high`,medium:`--med`,low:`--low`,info:`--info`},Wb={critical:`Critical`,high:`High`,medium:`Medium`,low:`Low`,info:`Info`};function Gb(e){return e===`informational`?`info`:Vb.includes(e)?e:`info`}function Kb(e){return e.length?[...e].sort((e,t)=>Hb[e.severity]-Hb[t.severity])[0].severity:null}function qb(e){return[...e].sort((e,t)=>Hb[e.severity]-Hb[t.severity])}function Jb(e){return e.status!==`remediated`&&e.status!==`verified`}var Yb=/^(?:L|stage )([1-6])\s*·\s*P([0-3])\s*·\s*(.+)$/i;function Xb(e,t){let n=(e??``).trim(),r=Yb.exec(n);if(r)return{stage:Number(r[1]),pillar:Number(r[2]),category:r[3],inferred:!1};let i=`${n} ${t??``}`.toLowerCase();return{stage:/sharing|disclos|transfer|cross-border|offshore|sftp|export|feed|webhook|api partner|integration/.test(i)?4:/retention|purge|backup|archive|dr site|snapshot|data lake/.test(i)?5:/eras|disposal|destroy|delete|decommission|shred/.test(i)?6:/consent|intake|onboarding|collection|telematics|form capture|survey/.test(i)?1:/encrypt|at rest|bucket|object store|database exposure|unencrypted|storage|nas|s3/.test(i)?2:3,pillar:/governance|dpia|retention schedule|policy|register|oversight|audit/.test(i)?0:/shared credential|third-party|tpa|vendor|partner|outsourc|staff|insider/.test(i)?2:1,category:n||`Agent finding`,inferred:!0}}function Zb(e){return e.map(e=>{let t=Xb(e.category,e.title);return{...e,severity:Gb(e.severity),stage:t.stage,pillar:t.pillar,displayCategory:t.inferred?`${t.category} (stage inferred)`:t.category,inferred:t.inferred}})}function Qb(e){return Kb(e.filter(e=>e.status===`confirmed`||e.status===`verified`))}function $b({title:e,sub:t,surface:n=!0,children:r}){return(0,P.jsxs)(`section`,{className:n?`bg-card rounded-xl border p-5`:void 0,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-3`,children:[(0,P.jsx)(`h2`,{children:e}),t?(0,P.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:t}):null]}),r]})}function ex({children:e}){return(0,P.jsx)(`div`,{className:`kpis`,children:e})}function tx({label:e,value:t,meta:n,hero:r,tone:i}){return(0,P.jsxs)(`div`,{className:r?`kpi hero`:`kpi`,children:[(0,P.jsx)(`div`,{className:`lab`,children:e}),r?(0,P.jsxs)(`div`,{className:`posture-pill val`,style:i?{color:`var(${Ub[i]})`}:void 0,children:[(0,P.jsx)(`span`,{className:`sq`}),t]}):(0,P.jsx)(`div`,{className:`val`,children:t}),n?(0,P.jsx)(`div`,{className:`meta`,children:n}):null]})}function nx({counts:e}){let t=Math.max(...Vb.map(t=>e[t]),1);return(0,P.jsx)(`div`,{children:Vb.map(n=>(0,P.jsxs)(`div`,{className:`sevrow`,children:[(0,P.jsxs)(`span`,{className:`name`,children:[(0,P.jsx)(`span`,{className:`chip`,style:{background:`var(${Ub[n]})`}}),Wb[n]]}),(0,P.jsx)(`div`,{className:`track`,children:(0,P.jsx)(`div`,{className:`fill`,"data-empty":e[n]===0,style:{width:`${e[n]/t*100}%`,background:`var(${Ub[n]})`}})}),(0,P.jsx)(`span`,{className:`n`,children:e[n]})]},n))})}function rx({findings:e}){let t=Lb.map(t=>e.filter(e=>e.stage===t.n).length),n=Math.max(...t,1);return(0,P.jsx)(`div`,{className:`stagebars`,children:Lb.map((e,r)=>{let i=t[r];return(0,P.jsxs)(`div`,{className:`sbar`,children:[(0,P.jsx)(`span`,{className:`cnt`,children:i}),(0,P.jsx)(`div`,{className:`col`,style:{height:`${Math.max(i/n*112,i?10:2)}px`,background:`var(${e.v})`}}),(0,P.jsx)(`span`,{className:`idx`,children:e.n}),(0,P.jsx)(`span`,{className:`lb`,children:zb(e)})]},e.n)})})}function ix({findings:e,onSelect:t,emptyLabel:n=`No findings.`}){return e.length?(0,P.jsx)(`div`,{className:`flist`,children:e.map(e=>{let n=Rb(e.stage);return(0,P.jsxs)(`button`,{className:`frow`,type:`button`,onClick:t?()=>t(e):void 0,children:[(0,P.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Wb[e.severity]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`ftitle`,children:e.title}),(0,P.jsxs)(`span`,{className:`fmeta`,children:[(0,P.jsxs)(`span`,{className:`stagetag`,children:[(0,P.jsx)(`span`,{className:`d`,style:{background:`var(${n.v})`}}),`Stage `,n.n,` · `,zb(n)]}),(0,P.jsx)(`span`,{children:e.displayCategory}),e.path?(0,P.jsx)(`span`,{className:`font-mono`,children:e.path}):null]})]}),(0,P.jsx)(`span`,{className:`fright`,children:(0,P.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:e.status.replaceAll(`_`,` `)})})]},e.id)})}):(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n})}function ax({findings:e,selected:t,onSelect:n}){return(0,P.jsx)(`div`,{className:`chain`,children:Lb.map(r=>{let i=e.filter(e=>e.stage===r.n),a=Kb(i);return(0,P.jsxs)(`button`,{className:`stagenode`,type:`button`,"aria-pressed":r.n===t,onClick:()=>n(r.n),children:[(0,P.jsx)(`div`,{className:`top`,style:{background:`var(${r.v})`}}),a?(0,P.jsx)(`span`,{className:`worst`,style:{background:`var(${Ub[a]})`}}):null,(0,P.jsxs)(`div`,{className:`sn`,children:[`STAGE `,r.n]}),(0,P.jsx)(`div`,{className:`st`,children:r.name}),(0,P.jsxs)(`div`,{className:`sc`,style:{color:`var(${r.v})`},children:[i.length,(0,P.jsxs)(`small`,{children:[`finding`,i.length===1?``:`s`]})]})]},r.n)})})}function ox({findings:e,onSelectStage:t}){return(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{className:`matrix`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`rh`}),Lb.map(e=>(0,P.jsxs)(`th`,{children:[(0,P.jsx)(`span`,{className:`flex flex-wrap gap-4 text-xs font-medium`,children:(0,P.jsx)(`i`,{className:`mcap`,style:{background:`var(${e.v})`}})}),(0,P.jsx)(`br`,{}),e.n]},e.n))]})}),(0,P.jsx)(`tbody`,{children:Bb.map((n,r)=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`rh`,children:n}),Lb.map(i=>{let a=e.filter(e=>e.pillar===r&&e.stage===i.n),o=Kb(a);return o?(0,P.jsx)(`td`,{className:`has`,style:{background:`var(${Ub[o]})`,cursor:`pointer`},title:`${a.length} open at ${n} · stage ${i.n}`,onClick:()=>t(i.n),children:a.length},i.n):(0,P.jsx)(`td`,{children:`·`},i.n)})]},n))})]})})}function sx({items:e}){return(0,P.jsx)(`div`,{className:`my-3.5 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:e.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`k`,children:e.k}),(0,P.jsx)(`div`,{className:e.mono?`v mono`:`v`,children:e.v})]},e.k))})}function cx({title:e,children:t}){return(0,P.jsxs)(`div`,{className:`border-[var(--hair)] mt-4 border-t pt-3.5 [&>h3]:text-muted-foreground [&>h3]:mb-2 [&>h3]:text-[11px] [&>h3]:font-semibold [&>h3]:tracking-[0.1em] [&>h3]:uppercase`,children:[(0,P.jsx)(`h3`,{children:e}),t]})}function lx({title:e,detail:t,verdict:n}){return(0,P.jsxs)(`div`,{className:`evi`,children:[(0,P.jsxs)(`svg`,{className:`ei`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,P.jsx)(`path`,{d:`M14 2v6h6`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`et`,children:e}),(0,P.jsx)(`div`,{className:`ed`,children:t})]}),(0,P.jsx)(`span`,{className:`verdict`,children:n})]})}var ux=y(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`,critical:`border-[color-mix(in_srgb,var(--crit)_35%,transparent)] bg-[var(--crit-bg)] text-[var(--crit)]`,high:`border-[color-mix(in_srgb,var(--high)_35%,transparent)] bg-[var(--high-bg)] text-[var(--high)]`,medium:`border-[color-mix(in_srgb,var(--med)_35%,transparent)] bg-[var(--med-bg)] text-[var(--med)]`,low:`border-[color-mix(in_srgb,var(--low)_35%,transparent)] bg-[var(--low-bg)] text-[var(--low)]`,success:`border-[color-mix(in_srgb,var(--good)_35%,transparent)] bg-[var(--good-bg)] text-[var(--good)]`,info:`bg-[var(--info-bg)] text-[var(--info)]`}},defaultVariants:{variant:`default`}}),dx={critical:`critical`,failed:`critical`,blocked:`critical`,R2:`critical`,high:`high`,awaiting_approval:`high`,cancel_requested:`high`,R1:`high`,medium:`medium`,queued:`medium`,low:`low`,running:`low`,R0:`low`,succeeded:`success`,completed:`success`,confirmed:`success`,ok:`success`,verified:`success`,remediated:`success`,info:`info`,informational:`info`};function fx(e){return e?dx[e]??`secondary`:`secondary`}function px({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?c:`span`;return(0,P.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:a(ux({variant:t}),e),...r})}function mx(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var hx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gx=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_x={};function vx(e,t){return((t||_x).jsx?gx:hx).test(e)}var yx=/[ \t\n\f\r]/g;function bx(e){return typeof e==`object`?e.type===`text`&&xx(e.value):xx(e)}function xx(e){return e.replace(yx,``)===``}var Sx=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Sx.prototype.normal={},Sx.prototype.property={},Sx.prototype.space=void 0;function Cx(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Sx(n,r,t)}function wx(e){return e.toLowerCase()}var Tx=class{constructor(e,t){this.attribute=t,this.property=e}};Tx.prototype.attribute=``,Tx.prototype.booleanish=!1,Tx.prototype.boolean=!1,Tx.prototype.commaOrSpaceSeparated=!1,Tx.prototype.commaSeparated=!1,Tx.prototype.defined=!1,Tx.prototype.mustUseProperty=!1,Tx.prototype.number=!1,Tx.prototype.overloadedBoolean=!1,Tx.prototype.property=``,Tx.prototype.spaceSeparated=!1,Tx.prototype.space=void 0;var Ex=e({boolean:()=>G,booleanish:()=>Ox,commaOrSpaceSeparated:()=>Mx,commaSeparated:()=>jx,number:()=>K,overloadedBoolean:()=>kx,spaceSeparated:()=>Ax}),Dx=0,G=Nx(),Ox=Nx(),kx=Nx(),K=Nx(),Ax=Nx(),jx=Nx(),Mx=Nx();function Nx(){return 2**++Dx}var Px=Object.keys(Ex),Fx=class extends Tx{constructor(e,t,n,r){let i=-1;if(super(e,t),Ix(this,`space`,r),typeof n==`number`)for(;++i<Px.length;){let e=Px[i];Ix(this,Px[i],(n&Ex[e])===Ex[e])}}};Fx.prototype.defined=!0;function Ix(e,t,n){n&&(e[t]=n)}function Lx(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Fx(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[wx(r)]=r,n[wx(a.attribute)]=r}return new Sx(t,n,e.space)}var Rx=Lx({properties:{ariaActiveDescendant:null,ariaAtomic:Ox,ariaAutoComplete:null,ariaBusy:Ox,ariaChecked:Ox,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:Ax,ariaCurrent:null,ariaDescribedBy:Ax,ariaDetails:null,ariaDisabled:Ox,ariaDropEffect:Ax,ariaErrorMessage:null,ariaExpanded:Ox,ariaFlowTo:Ax,ariaGrabbed:Ox,ariaHasPopup:null,ariaHidden:Ox,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ax,ariaLevel:K,ariaLive:null,ariaModal:Ox,ariaMultiLine:Ox,ariaMultiSelectable:Ox,ariaOrientation:null,ariaOwns:Ax,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:Ox,ariaReadOnly:Ox,ariaRelevant:null,ariaRequired:Ox,ariaRoleDescription:Ax,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:Ox,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function zx(e,t){return t in e?e[t]:t}function Bx(e,t){return zx(e,t.toLowerCase())}var Vx=Lx({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:jx,acceptCharset:Ax,accessKey:Ax,action:null,allow:null,allowFullScreen:G,allowPaymentRequest:G,allowUserMedia:G,alpha:G,alt:null,as:null,async:G,autoCapitalize:null,autoComplete:Ax,autoFocus:G,autoPlay:G,blocking:Ax,capture:null,charSet:null,checked:G,cite:null,className:Ax,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:Ox,controls:G,controlsList:Ax,coords:K|jx,crossOrigin:null,data:null,dateTime:null,decoding:null,default:G,defer:G,dir:null,dirName:null,disabled:G,download:kx,draggable:Ox,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:G,formTarget:null,headers:Ax,height:K,hidden:kx,high:K,href:null,hrefLang:null,htmlFor:Ax,httpEquiv:Ax,id:null,imageSizes:null,imageSrcSet:null,inert:G,inputMode:null,integrity:null,is:null,isMap:G,itemId:null,itemProp:Ax,itemRef:Ax,itemScope:G,itemType:Ax,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:G,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:G,muted:G,name:null,nonce:null,noModule:G,noValidate:G,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:G,optimum:K,pattern:null,ping:Ax,placeholder:null,playsInline:G,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:G,referrerPolicy:null,rel:Ax,required:G,reversed:G,rows:K,rowSpan:K,sandbox:Ax,scope:null,scoped:G,seamless:G,selected:G,shadowRootClonable:G,shadowRootCustomElementRegistry:G,shadowRootDelegatesFocus:G,shadowRootMode:null,shadowRootSerializable:G,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:Ox,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:G,useMap:null,value:Ox,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ax,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:G,declare:G,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:G,noHref:G,noShade:G,noWrap:G,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:Ox,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:G,disablePictureInPicture:G,disableRemotePlayback:G,exportParts:jx,part:Ax,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:Bx}),Hx=Lx({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Mx,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:Ax,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:G,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:jx,g2:jx,glyphName:jx,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:Mx,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ax,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mx,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mx,rev:Mx,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mx,requiredFeatures:Mx,requiredFonts:Mx,requiredFormats:Mx,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:Mx,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mx,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Mx,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:zx}),Ux=Lx({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Wx=Lx({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Bx}),Gx=Lx({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Kx={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},qx=/[A-Z]/g,Jx=/-[a-z]/g,Yx=/^data[-\w.:]+$/i;function Xx(e,t){let n=wx(t),r=t,i=Tx;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Yx.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Jx,Qx);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Jx.test(e)){let n=e.replace(qx,Zx);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Fx}return new i(r,t)}function Zx(e){return`-`+e.toLowerCase()}function Qx(e){return e.charAt(1).toUpperCase()}var $x=Cx([Rx,Vx,Ux,Wx,Gx],`html`),eS=Cx([Rx,Hx,Ux,Wx,Gx],`svg`);function tS(e){return e.join(` `).trim()}var nS=r(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
61
+ `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),rS=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(nS());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),iS=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),aS=r(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(rS()),r=iS();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),oS=cS(`end`),sS=cS(`start`);function cS(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function lS(e){let t=sS(e),n=oS(e);if(t&&n)return{start:t,end:n}}function uS(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?fS(e.position):`start`in e||`end`in e?fS(e):`line`in e||`column`in e?dS(e):``}function dS(e){return pS(e&&e.line)+`:`+pS(e&&e.column)}function fS(e){return dS(e&&e.start)+`-`+dS(e&&e.end)}function pS(e){return e&&typeof e==`number`?e:1}var mS=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=uS(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};mS.prototype.file=``,mS.prototype.name=``,mS.prototype.reason=``,mS.prototype.message=``,mS.prototype.stack=``,mS.prototype.column=void 0,mS.prototype.line=void 0,mS.prototype.ancestors=void 0,mS.prototype.cause=void 0,mS.prototype.fatal=void 0,mS.prototype.place=void 0,mS.prototype.ruleId=void 0,mS.prototype.source=void 0;var hS=n(aS(),1),gS={}.hasOwnProperty,_S=new Map,vS=/[A-Z]/g,yS=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),bS=new Set([`td`,`th`]),xS=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function SS(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=NS(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=MS(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?eS:$x,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=CS(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function CS(e,t,n){if(t.type===`element`)return wS(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return TS(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return DS(e,t,n);if(t.type===`mdxjsEsm`)return ES(e,t);if(t.type===`root`)return OS(e,t,n);if(t.type===`text`)return kS(e,t)}function wS(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=eS,e.schema=i),e.ancestors.push(t);let a=zS(e,t.tagName,!1),o=PS(e,t),s=IS(e,t);return yS.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!bx(e)})),AS(e,o,a,t),jS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function TS(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}BS(e,t.position)}function ES(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);BS(e,t.position)}function DS(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=eS,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:zS(e,t.name,!0),o=FS(e,t),s=IS(e,t);return AS(e,o,a,t),jS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function OS(e,t,n){let r={};return jS(r,IS(e,t)),e.create(t,e.Fragment,r,n)}function kS(e,t){return t.value}function AS(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function jS(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function MS(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function NS(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=sS(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function PS(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&gS.call(t.properties,i)){let a=LS(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&bS.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function FS(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else BS(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else BS(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function IS(e,t){let n=[],r=-1,i=e.passKeys?new Map:_S;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=CS(e,a,o);s!==void 0&&n.push(s)}return n}function LS(e,t,n){let r=Xx(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?mx(n):tS(n)),r.property===`style`){let t=typeof n==`object`?n:RS(e,String(n));return e.stylePropertyNameCase===`css`&&(t=VS(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Kx[r.property]||r.property:r.attribute,n]}}function RS(e,t){try{return(0,hS.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new mS("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=xS+`#cannot-parse-style-attribute`,r}}function zS(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=vx(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=vx(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return gS.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);BS(e)}function BS(e,t){let n=new mS("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=xS+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function VS(e){let t={},n;for(n in e)gS.call(e,n)&&(t[HS(n)]=e[n]);return t}function HS(e){let t=e.replace(vS,US);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function US(e){return`-`+e.toLowerCase()}var WS={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},GS={};function KS(e,t){let n=t||GS;return qS(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function qS(e,t,n){if(YS(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return JS(e.children,t,n)}return Array.isArray(e)?JS(e,t,n):``}function JS(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=qS(e[i],t,n);return r.join(``)}function YS(e){return!!(e&&typeof e==`object`)}var XS=document.createElement(`i`);function ZS(e){let t=`&`+e+`;`;XS.innerHTML=t;let n=XS.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function QS(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function $S(e,t){return e.length>0?(QS(e,e.length,0,t),e):t}var eC={}.hasOwnProperty;function tC(e){let t={},n=-1;for(;++n<e.length;)nC(t,e[n]);return t}function nC(e,t){let n;for(n in t){let r=(eC.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){eC.call(r,a)||(r[a]=[]);let e=i[a];rC(r[a],Array.isArray(e)?e:e?[e]:[])}}}function rC(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);QS(e,0,0,r)}function iC(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function aC(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var oC=_C(/[A-Za-z]/),sC=_C(/[\dA-Za-z]/),cC=_C(/[#-'*+\--9=?A-Z^-~]/);function lC(e){return e!==null&&(e<32||e===127)}var uC=_C(/\d/),dC=_C(/[\dA-Fa-f]/),fC=_C(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function pC(e){return e!==null&&(e<0||e===32)}function mC(e){return e===-2||e===-1||e===32}var hC=_C(/\p{P}|\p{S}/u),gC=_C(/\s/);function _C(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function vC(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&sC(e.charCodeAt(n+1))&&sC(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function yC(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return mC(r)?(e.enter(n),s(r)):t(r)}function s(r){return mC(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var bC={tokenize:xC};function xC(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),yC(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var SC={tokenize:wC},CC={tokenize:TC};function wC(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return QS(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(CC,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(CC,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;QS(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function TC(e,t,n){return yC(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function EC(e){if(e===null||pC(e)||gC(e))return 1;if(hC(e))return 2}function DC(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var OC={name:`attention`,resolveAll:kC,tokenize:AC};function kC(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};jC(d,-c),jC(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=$S(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=$S(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=$S(l,DC(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=$S(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=$S(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,QS(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function AC(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=EC(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=EC(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function jC(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var MC={name:`autolink`,tokenize:NC};function NC(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return oC(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||sC(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||sC(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||lC(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):cC(t)?(e.consume(t),l):n(t)}function u(e){return sC(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||sC(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var PC={partial:!0,tokenize:FC};function FC(e,t,n){return r;function r(t){return mC(t)?yC(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var IC={continuation:{tokenize:RC},exit:zC,name:`blockQuote`,tokenize:LC};function LC(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return mC(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function RC(e,t,n){let r=this;return i;function i(t){return mC(t)?yC(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(IC,t,n)(r)}}function zC(e){e.exit(`blockQuote`)}var BC={name:`characterEscape`,tokenize:VC};function VC(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return fC(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var HC={name:`characterReference`,tokenize:UC};function UC(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=sC,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=dC,u):(e.enter(`characterReferenceValue`),a=7,o=uC,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===sC&&!ZS(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var WC={partial:!0,tokenize:qC},GC={concrete:!0,name:`codeFenced`,tokenize:KC};function KC(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),mC(t)?yC(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(WC,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):mC(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),yC(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&mC(t)?yC(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(WC,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),mC(t)?yC(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),mC(t)?yC(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function qC(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var JC={name:`codeIndented`,tokenize:XC},YC={partial:!0,tokenize:ZC};function XC(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),yC(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(YC,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function ZC(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):yC(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var QC={name:`codeText`,previous:ew,resolve:$C,tokenize:tw};function $C(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function ew(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function tw(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var nw=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&rw(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),rw(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),rw(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);rw(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);rw(this.left,t.reverse())}}}};function rw(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function iw(e){let t={},n=-1,r,i,a,o,s,c,l,u=new nw(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,aw(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return QS(e,0,1/0,u.slice(0)),!l}function aw(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var ow={resolve:cw,tokenize:lw},sw={partial:!0,tokenize:uw};function cw(e){return iw(e),e}function lw(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(sw,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function uw(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),yC(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function dw(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||lC(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||pC(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||lC(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function fw(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!mC(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function pw(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),yC(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function mw(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):mC(i)?yC(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var hw={name:`definition`,tokenize:_w},gw={partial:!0,tokenize:vw};function _w(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return fw.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=aC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return pC(t)?mw(e,l)(t):l(t)}function l(t){return dw(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(gw,d,d)(t)}function d(t){return mC(t)?yC(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function vw(e,t,n){return r;function r(t){return pC(t)?mw(e,i)(t):n(t)}function i(t){return pw(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return mC(t)?yC(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var yw={name:`hardBreakEscape`,tokenize:bw};function bw(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var xw={name:`headingAtx`,resolve:Sw,tokenize:Cw};function Sw(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},QS(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Cw(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||pC(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):mC(n)?yC(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||pC(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var ww=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Tw=[`pre`,`script`,`style`,`textarea`],Ew={concrete:!0,name:`htmlFlow`,resolveTo:kw,tokenize:Aw},Dw={partial:!0,tokenize:Mw},Ow={partial:!0,tokenize:jw};function kw(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Aw(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:re):oC(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):oC(a)?(e.consume(a),i=4,r.interrupt?t:re):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:re):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return oC(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||pC(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Tw.includes(l)?(i=1,r.interrupt?t(s):O(s)):ww.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||sC(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return mC(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||oC(t)?(e.consume(t),b):mC(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||sC(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):mC(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):mC(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||pC(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||mC(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):mC(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),ee):t===62&&i===4?(e.consume(t),ie):t===63&&i===3?(e.consume(t),re):t===93&&i===5?(e.consume(t),ne):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Dw,ae,k)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Ow,A,ae)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),re):O(t)}function ee(t){return t===47?(e.consume(t),o=``,te):O(t)}function te(t){if(t===62){let n=o.toLowerCase();return Tw.includes(n)?(e.consume(t),ie):O(t)}return oC(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),te):O(t)}function ne(t){return t===93?(e.consume(t),re):O(t)}function re(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),re):O(t)}function ie(t){return t===null||q(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),ie)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function jw(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Mw(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(PC,t,n)}}var Nw={name:`htmlText`,tokenize:Pw};function Pw(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):oC(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):oC(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,ee(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,ee(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):q(t)?(o=v,ee(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,ee(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return oC(t)?(e.consume(t),S):n(t)}function S(t){return t===45||sC(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,ee(t)):mC(t)?(e.consume(t),C):M(t)}function w(t){return t===45||sC(t)?(e.consume(t),w):t===47||t===62||pC(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||oC(t)?(e.consume(t),E):q(t)?(o=T,ee(t)):mC(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||sC(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,ee(t)):mC(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):q(t)?(o=O,ee(t)):mC(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):q(t)?(o=k,ee(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||pC(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||pC(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ee(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return mC(t)?yC(e,ne,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ne(t)}function ne(t){return e.enter(`htmlTextData`),o(t)}}var Fw={name:`labelEnd`,resolveAll:zw,resolveTo:Bw,tokenize:Vw},Iw={tokenize:Hw},Lw={tokenize:Uw},Rw={tokenize:Ww};function zw(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&QS(e,0,e.length,n),e}function Bw(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=$S(s,e.slice(a+1,a+r+3)),s=$S(s,[[`enter`,u,t]]),s=$S(s,DC(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=$S(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=$S(s,e.slice(o+1)),s=$S(s,[[`exit`,c,t]]),QS(e,a,e.length,s),e}function Vw(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(aC(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Iw,u,o?u:d)(t):t===91?e.attempt(Lw,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Rw,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Hw(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return pC(t)?mw(e,a)(t):a(t)}function a(t){return t===41?u(t):dw(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return pC(t)?mw(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?pw(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return pC(t)?mw(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Uw(e,t,n){let r=this;return i;function i(t){return fw.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(aC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Ww(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Gw={name:`labelStartImage`,resolveAll:Fw.resolveAll,tokenize:Kw};function Kw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var qw={name:`labelStartLink`,resolveAll:Fw.resolveAll,tokenize:Jw};function Jw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Yw={name:`lineEnding`,tokenize:Xw};function Xw(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),yC(e,t,`linePrefix`)}}var Zw={name:`thematicBreak`,tokenize:Qw};function Qw(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),mC(t)?yC(e,s,`whitespace`)(t):s(t))}}var $w={continuation:{tokenize:rT},exit:aT,name:`list`,tokenize:nT},eT={partial:!0,tokenize:oT},tT={partial:!0,tokenize:iT};function nT(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:uC(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Zw,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return uC(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(PC,r.interrupt?n:u,e.attempt(eT,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return mC(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function rT(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(PC,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,yC(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!mC(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tT,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,yC(e,e.attempt($w,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function iT(e,t,n){let r=this;return yC(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function aT(e){e.exit(this.containerState.type)}function oT(e,t,n){let r=this;return yC(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!mC(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var sT={name:`setextUnderline`,resolveTo:cT,tokenize:lT};function cT(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function lT(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),mC(t)?yC(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var uT={tokenize:dT};function dT(e){let t=this,n=e.attempt(PC,r,e.attempt(this.parser.constructs.flowInitial,i,yC(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ow,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var fT={resolveAll:gT()},pT=hT(`string`),mT=hT(`text`);function hT(e){return{resolveAll:gT(e===`text`?_T:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function gT(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function _T(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var vT=e({attentionMarkers:()=>ET,contentInitial:()=>bT,disable:()=>DT,document:()=>yT,flow:()=>ST,flowInitial:()=>xT,insideSpan:()=>TT,string:()=>CT,text:()=>wT}),yT={42:$w,43:$w,45:$w,48:$w,49:$w,50:$w,51:$w,52:$w,53:$w,54:$w,55:$w,56:$w,57:$w,62:IC},bT={91:hw},xT={[-2]:JC,[-1]:JC,32:JC},ST={35:xw,42:Zw,45:[sT,Zw],60:Ew,61:sT,95:Zw,96:GC,126:GC},CT={38:HC,92:BC},wT={[-5]:Yw,[-4]:Yw,[-3]:Yw,33:Gw,38:HC,42:OC,60:[MC,Nw],91:qw,92:[yw,BC],93:Fw,95:OC,96:QC},TT={null:[OC,fT]},ET={null:[42,95]},DT={null:[]};function OT(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=$S(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=DC(a,l.events,l),l.events):[]}function f(e,t){return AT(p(e),t)}function p(e){return kT(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&QS(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function kT(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function AT(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
62
62
  `;break;case-3:o=`\r
63
- `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function OT(e){let t={constructs:QS([hT,...(e||{}).extensions||[]]),content:n(_C),defined:[],document:n(yC),flow:n(sT),lazy:{},string:n(uT),text:n(dT)};return t;function n(e){return n;function n(n){return TT(t,e,n)}}}function kT(e){for(;!tw(e););return e}var AT=/[\0\t\n\r]/g;function jT(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(AT.lastIndex=u,c=AT.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var MT=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function NT(e){return e.replace(MT,PT)}function PT(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return tC(n.slice(t?2:1),t?16:10)}return JS(n)||e}var FT={}.hasOwnProperty;function IT(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),LT(n)(kT(OT(n).document().write(jT()(e,t,!0))))}function LT(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(Se),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ve),blockQuote:a(pe),characterEscape:T,characterReference:T,codeFenced:a(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(me,o),codeText:a(he,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(_e),hardBreakEscape:a(ye),hardBreakTrailing:a(ye),htmlFlow:a(be,o),htmlFlowData:T,htmlText:a(be,o),htmlTextData:T,image:a(xe),label:o,link:a(Se),listItem:a(we),listItemValue:f,listOrdered:a(Ce,d),listUnordered:a(Ce),paragraph:a(Te),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(Ee),thematicBreak:a(Oe)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:fe,autolinkProtocol:de,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:le,characterReference:ue,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(ee),label:ne,labelText:te,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:re,resourceTitleString:ie,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};zT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];FT.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||VT).call(a,void 0,e[0])}for(r.position={start:RT(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:RT(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:RT(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||VT).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+sS({start:e.start,end:e.end})+`): it’s not open`);n.position.end=RT(e.end)}function u(){return US(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=nC(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=De(),n.position={start:RT(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=RT(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=RT(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=NT(t),n.identifier=nC(t).toLowerCase()}function ne(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=nC(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ce(e){this.data.characterReferenceType=e.type}function le(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=tC(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=JS(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=RT(e.end)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function fe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function pe(){return{type:`blockquote`,children:[]}}function me(){return{type:`code`,lang:null,meta:null,value:``}}function he(){return{type:`inlineCode`,value:``}}function ge(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function _e(){return{type:`emphasis`,children:[]}}function ve(){return{type:`heading`,depth:0,children:[]}}function ye(){return{type:`break`}}function be(){return{type:`html`,value:``}}function xe(){return{type:`image`,title:null,url:``,alt:null}}function Se(){return{type:`link`,title:null,url:``,children:[]}}function Ce(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function we(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Te(){return{type:`paragraph`,children:[]}}function Ee(){return{type:`strong`,children:[]}}function De(){return{type:`text`,value:``}}function Oe(){return{type:`thematicBreak`}}}function RT(e){return{line:e.line,column:e.column,offset:e.offset}}function zT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?zT(e,r):BT(e,r)}}function BT(e,t){let n;for(n in t)if(FT.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function VT(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+sS({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+sS({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+sS({start:t.start,end:t.end})+`) is still open`)}function HT(e){let t=this;t.parser=n;function n(n){return IT(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function UT(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function WT(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
64
- `}]}function GT(e,t){let n=t.value?t.value+`
65
- `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function KT(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qT(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JT(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=hC(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function YT(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XT(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ZT(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function QT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZT(e,t);let i={src:hC(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function $T(e,t){let n={src:hC(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function eE(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function tE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZT(e,t);let i={href:hC(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function nE(e,t){let n={href:hC(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function rE(e,t,n){let r=e.all(t),i=n?iE(n):aE(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
63
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function jT(e){let t={constructs:tC([vT,...(e||{}).extensions||[]]),content:n(bC),defined:[],document:n(SC),flow:n(uT),lazy:{},string:n(pT),text:n(mT)};return t;function n(e){return n;function n(n){return OT(t,e,n)}}}function MT(e){for(;!iw(e););return e}var NT=/[\0\t\n\r]/g;function PT(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(NT.lastIndex=u,c=NT.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var FT=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function IT(e){return e.replace(FT,LT)}function LT(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return iC(n.slice(t?2:1),t?16:10)}return ZS(n)||e}var RT={}.hasOwnProperty;function zT(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),BT(n)(MT(jT(n).document().write(PT()(e,t,!0))))}function BT(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(Se),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ve),blockQuote:a(pe),characterEscape:T,characterReference:T,codeFenced:a(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(me,o),codeText:a(he,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(_e),hardBreakEscape:a(ye),hardBreakTrailing:a(ye),htmlFlow:a(be,o),htmlFlowData:T,htmlText:a(be,o),htmlTextData:T,image:a(xe),label:o,link:a(Se),listItem:a(we),listItemValue:f,listOrdered:a(Ce,d),listUnordered:a(Ce),paragraph:a(Te),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(Ee),thematicBreak:a(Oe)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:fe,autolinkProtocol:de,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:le,characterReference:ue,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(ee),label:ne,labelText:te,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:re,resourceTitleString:ie,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};HT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];RT.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||WT).call(a,void 0,e[0])}for(r.position={start:VT(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:VT(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:VT(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||WT).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+uS({start:e.start,end:e.end})+`): it’s not open`);n.position.end=VT(e.end)}function u(){return KS(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=aC(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=De(),n.position={start:VT(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=VT(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=VT(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=IT(t),n.identifier=aC(t).toLowerCase()}function ne(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=aC(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ce(e){this.data.characterReferenceType=e.type}function le(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=iC(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=ZS(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=VT(e.end)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function fe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function pe(){return{type:`blockquote`,children:[]}}function me(){return{type:`code`,lang:null,meta:null,value:``}}function he(){return{type:`inlineCode`,value:``}}function ge(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function _e(){return{type:`emphasis`,children:[]}}function ve(){return{type:`heading`,depth:0,children:[]}}function ye(){return{type:`break`}}function be(){return{type:`html`,value:``}}function xe(){return{type:`image`,title:null,url:``,alt:null}}function Se(){return{type:`link`,title:null,url:``,children:[]}}function Ce(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function we(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Te(){return{type:`paragraph`,children:[]}}function Ee(){return{type:`strong`,children:[]}}function De(){return{type:`text`,value:``}}function Oe(){return{type:`thematicBreak`}}}function VT(e){return{line:e.line,column:e.column,offset:e.offset}}function HT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?HT(e,r):UT(e,r)}}function UT(e,t){let n;for(n in t)if(RT.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function WT(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+uS({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+uS({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+uS({start:t.start,end:t.end})+`) is still open`)}function GT(e){let t=this;t.parser=n;function n(n){return zT(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function KT(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function qT(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
64
+ `}]}function JT(e,t){let n=t.value?t.value+`
65
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function YT(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XT(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZT(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=vC(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function QT(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $T(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function eE(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function tE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return eE(e,t);let i={src:vC(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function nE(e,t){let n={src:vC(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function rE(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function iE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return eE(e,t);let i={href:vC(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function aE(e,t){let n={href:vC(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function oE(e,t,n){let r=e.all(t),i=n?sE(n):cE(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
66
66
  `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
67
- `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function iE(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=aE(n[r])}return t}function aE(e){return e.spread??e.children.length>1}function oE(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function sE(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cE(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function lE(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uE(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=iS(t.children[1]),o=rS(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function dE(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function fE(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var pE=9,mE=32;function hE(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(gE(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(gE(t.slice(i),i>0,!1)),a.join(``)}function gE(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===pE||t===mE;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===pE||t===mE;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function _E(e,t){let n={type:`text`,value:hE(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function vE(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var yE={blockquote:UT,break:WT,code:GT,delete:KT,emphasis:qT,footnoteReference:JT,heading:YT,html:XT,imageReference:QT,image:$T,inlineCode:eE,linkReference:tE,link:nE,listItem:rE,list:oE,paragraph:sE,root:cE,strong:lE,table:uE,tableCell:fE,tableRow:dE,text:_E,thematicBreak:vE,toml:bE,yaml:bE,definition:bE,footnoteDefinition:bE};function bE(){}var{defineProperty:xE}=Object,SE=typeof self==`object`?self:globalThis,CE=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new SE[e](t)},wE=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?xE(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof SE[e]==`function`?CE(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(CE(a,o),i)};return r},TE=e=>wE(new Map,e)(0),EE=``,{toString:DE}={},{keys:OE,is:kE}=Object,AE=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=DE.call(e).slice(8,-1);switch(n){case`Array`:return[1,EE];case`Object`:return[2,EE];case`Date`:return[3,EE];case`RegExp`:return[4,EE];case`Map`:return[5,EE];case`Set`:return[6,EE];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},jE=([e,t])=>e===0&&(t===`function`||t===`symbol`),ME=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=AE(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&kE(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of OE(o))(e||!jE(AE(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?EE:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(jE(AE(n))||jE(AE(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!jE(AE(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},NE=(e,{json:t,lossy:n}={})=>{let r=[];return ME(!(t||n),!!t,new Map,r)(e),r},PE=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?TE(NE(e,t)):structuredClone(e):(e,t)=>TE(NE(e,t));function FE(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function IE(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function LE(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||FE,r=e.options.footnoteBackLabel||IE,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=hC(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...PE(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
67
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function sE(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=cE(n[r])}return t}function cE(e){return e.spread??e.children.length>1}function lE(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function uE(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dE(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function fE(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pE(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=sS(t.children[1]),o=oS(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function mE(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function hE(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var gE=9,_E=32;function vE(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(yE(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(yE(t.slice(i),i>0,!1)),a.join(``)}function yE(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===gE||t===_E;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===gE||t===_E;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function bE(e,t){let n={type:`text`,value:vE(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function xE(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var SE={blockquote:KT,break:qT,code:JT,delete:YT,emphasis:XT,footnoteReference:ZT,heading:QT,html:$T,imageReference:tE,image:nE,inlineCode:rE,linkReference:iE,link:aE,listItem:oE,list:lE,paragraph:uE,root:dE,strong:fE,table:pE,tableCell:hE,tableRow:mE,text:bE,thematicBreak:xE,toml:CE,yaml:CE,definition:CE,footnoteDefinition:CE};function CE(){}var{defineProperty:wE}=Object,TE=typeof self==`object`?self:globalThis,EE=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new TE[e](t)},DE=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?wE(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof TE[e]==`function`?EE(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(EE(a,o),i)};return r},OE=e=>DE(new Map,e)(0),kE=``,{toString:AE}={},{keys:jE,is:ME}=Object,NE=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=AE.call(e).slice(8,-1);switch(n){case`Array`:return[1,kE];case`Object`:return[2,kE];case`Date`:return[3,kE];case`RegExp`:return[4,kE];case`Map`:return[5,kE];case`Set`:return[6,kE];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},PE=([e,t])=>e===0&&(t===`function`||t===`symbol`),FE=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=NE(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&ME(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of jE(o))(e||!PE(NE(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?kE:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(PE(NE(n))||PE(NE(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!PE(NE(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},IE=(e,{json:t,lossy:n}={})=>{let r=[];return FE(!(t||n),!!t,new Map,r)(e),r},LE=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?OE(IE(e,t)):structuredClone(e):(e,t)=>OE(IE(e,t));function RE(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function zE(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function BE(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||RE,r=e.options.footnoteBackLabel||zE,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=vC(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...LE(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
68
68
  `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
69
- `}]}}var RE=(function(e){if(e==null)return UE;if(typeof e==`function`)return HE(e);if(typeof e==`object`)return Array.isArray(e)?zE(e):BE(e);if(typeof e==`string`)return VE(e);throw Error(`Expected function, string, or object as test`)});function zE(e){let t=[],n=-1;for(;++n<e.length;)t[n]=RE(e[n]);return HE(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function BE(e){let t=e;return HE(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function VE(e){return HE(t);function t(t){return t&&t.type===e}}function HE(e){return t;function t(t,n,r){return!!(WE(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function UE(){return!0}function WE(e){return typeof e==`object`&&!!e&&`type`in e}function GE(e){return e}var KE=[];function qE(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=RE(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+GE(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=KE,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=JE(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function JE(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?KE:[e]}function YE(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),qE(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var XE={}.hasOwnProperty,ZE={};function QE(e,t){let n=t||ZE,r=new Map,i=new Map,a={all:s,applyData:eD,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...yE,...n.handlers},one:o,options:n,patch:$E,wrap:nD};return YE(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(XE.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=PE(n);return r.children=a.all(e),r}return PE(e)}return(a.options.unknownHandler||tD)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=rD(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=rD(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function $E(e,t){e.position&&(t.position=oS(e))}function eD(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,PE(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function tD(e,t){let n=t.data||{},r=`value`in t&&!(XE.call(n,`hProperties`)||XE.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function nD(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
69
+ `}]}}var VE=(function(e){if(e==null)return KE;if(typeof e==`function`)return GE(e);if(typeof e==`object`)return Array.isArray(e)?HE(e):UE(e);if(typeof e==`string`)return WE(e);throw Error(`Expected function, string, or object as test`)});function HE(e){let t=[],n=-1;for(;++n<e.length;)t[n]=VE(e[n]);return GE(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function UE(e){let t=e;return GE(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function WE(e){return GE(t);function t(t){return t&&t.type===e}}function GE(e){return t;function t(t,n,r){return!!(qE(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function KE(){return!0}function qE(e){return typeof e==`object`&&!!e&&`type`in e}function JE(e){return e}var YE=[];function XE(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=VE(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+JE(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=YE,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=ZE(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function ZE(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?YE:[e]}function QE(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),XE(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var $E={}.hasOwnProperty,eD={};function tD(e,t){let n=t||eD,r=new Map,i=new Map,a={all:s,applyData:rD,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...SE,...n.handlers},one:o,options:n,patch:nD,wrap:aD};return QE(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if($E.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=LE(n);return r.children=a.all(e),r}return LE(e)}return(a.options.unknownHandler||iD)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=oD(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=oD(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function nD(e,t){e.position&&(t.position=lS(e))}function rD(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,LE(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function iD(e,t){let n=t.data||{},r=`value`in t&&!($E.call(n,`hProperties`)||$E.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function aD(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
70
70
  `});++r<e.length;)r&&n.push({type:`text`,value:`
71
71
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
72
- `}),n}function rD(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function iD(e,t){let n=QE(e,t),r=n.one(e,void 0),i=LE(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
73
- `},i)),a}function aD(e,t){return e&&`run`in e?async function(n,r){let i=iD(n,{file:r,...t});await e.run(i,r)}:function(n,r){return iD(n,{file:r,...e||t})}}function oD(e){if(e)throw e}var sD=r(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function cD(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function lD(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?uD(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function uD(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var dD={basename:fD,dirname:pD,extname:mD,join:hD,sep:`/`};function fD(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);vD(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function pD(e){if(vD(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function mD(e){vD(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function hD(...e){let t=-1,n;for(;++t<e.length;)vD(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:gD(n)}function gD(e){vD(e);let t=e.codePointAt(0)===47,n=_D(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function _D(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function vD(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var yD={cwd:bD};function bD(){return`/`}function xD(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function SD(e){if(typeof e==`string`)e=new URL(e);else if(!xD(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return CD(e)}function CD(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var wD=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],TD=class{constructor(e){let t;t=e?xD(e)?{path:e}:typeof e==`string`||kD(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:yD.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<wD.length;){let e=wD[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)wD.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?dD.basename(this.path):void 0}set basename(e){DD(e,`basename`),ED(e,`basename`),this.path=dD.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?dD.dirname(this.path):void 0}set dirname(e){OD(this.basename,`dirname`),this.path=dD.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?dD.extname(this.path):void 0}set extname(e){if(ED(e,`extname`),OD(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=dD.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){xD(e)&&(e=SD(e)),DD(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?dD.basename(this.path,this.extname):void 0}set stem(e){DD(e,`stem`),ED(e,`stem`),this.path=dD.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new dS(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function ED(e,t){if(e&&e.includes(dD.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+dD.sep+"`")}function DD(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function OD(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function kD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var AD=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),jD=n(sD(),1),MD={}.hasOwnProperty,ND=new class e extends AD{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lD()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,jD.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(ID(`data`,this.frozen),this.namespace[e]=t,this):MD.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ID(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=zD(e),n=this.parser||this.Parser;return PD(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),PD(`process`,this.parser||this.Parser),FD(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=zD(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);VD(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),PD(`processSync`,this.parser||this.Parser),FD(`processSync`,this.compiler||this.Compiler),this.process(e,r),RD(`processSync`,`process`,t),n;function r(e,r){t=!0,oD(e),n=r}}run(e,t,n){LD(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=zD(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),RD(`runSync`,`run`,n),r;function i(e,t){oD(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=zD(t),r=this.compiler||this.Compiler;return FD(`stringify`,r),LD(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(ID(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,jD.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];cD(o)&&cD(r)&&(r=(0,jD.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function PD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function FD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function ID(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function LD(e){if(!cD(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function RD(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function zD(e){return BD(e)?e:new TD(e)}function BD(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function VD(e){return typeof e==`string`||HD(e)}function HD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var UD=[],WD={allowDangerousHtml:!0},GD=/^(https?|ircs?|mailto|xmpp)$/i,KD=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function qD(e){let t=JD(e),n=YD(e);return XD(t.runSync(t.parse(n),n),e)}function JD(e){let t=e.rehypePlugins||UD,n=e.remarkPlugins||UD,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...WD}:WD;return ND().use(HT).use(n).use(aD,r).use(t)}function YD(e){let t=e.children||``,n=new TD;return typeof t==`string`?n.value=t:``+t,n}function XD(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||ZD;for(let e of KD)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return YE(e,l),yS(e,{Fragment:P.Fragment,components:i,ignoreInvalidStyle:!0,jsx:P.jsx,jsxs:P.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in VS)if(Object.hasOwn(VS,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=VS[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function ZD(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||GD.test(e.slice(0,t))?e:``}function QD(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function $D(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function eO(e,t,n){let r=RE((n||{}).ignore||[]),i=tO(t),a=-1;for(;++a<i.length;)qE(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function tO(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([nO(e[0]),rO(e[1])])}return t}function nO(e){return typeof e==`string`?new RegExp($D(e),`g`):e}function rO(e){return typeof e==`function`?e:function(){return e}}var iO=`phrasing`,aO=[`autolink`,`link`,`image`,`label`];function oO(){return{transforms:[mO],enter:{literalAutolink:cO,literalAutolinkEmail:lO,literalAutolinkHttp:lO,literalAutolinkWww:lO},exit:{literalAutolink:pO,literalAutolinkEmail:fO,literalAutolinkHttp:uO,literalAutolinkWww:dO}}}function sO(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:iO,notInConstruct:aO},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:iO,notInConstruct:aO},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:iO,notInConstruct:aO}]}}function cO(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function lO(e){this.config.enter.autolinkProtocol.call(this,e)}function uO(e){this.config.exit.autolinkProtocol.call(this,e)}function dO(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function fO(e){this.config.exit.autolinkEmail.call(this,e)}function pO(e){this.exit(e)}function mO(e){eO(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,hO],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,gO]],{ignore:[`link`,`linkReference`]})}function hO(e,t,n,r,i){let a=``;if(!yO(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!_O(n)))return!1;let o=vO(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function gO(e,t,n,r){return!yO(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function _O(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function vO(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=QD(e,`(`),a=QD(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function yO(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||pC(n)||fC(n))&&(!t||n!==47)}kO.peek=OO;function bO(){this.buffer()}function xO(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function SO(){this.buffer()}function CO(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function wO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nC(this.sliceSerialize(e)).toLowerCase(),n.label=t}function TO(e){this.exit(e)}function EO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nC(this.sliceSerialize(e)).toLowerCase(),n.label=t}function DO(e){this.exit(e)}function OO(){return`[`}function kO(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function AO(){return{enter:{gfmFootnoteCallString:bO,gfmFootnoteCall:xO,gfmFootnoteDefinitionLabelString:SO,gfmFootnoteDefinition:CO},exit:{gfmFootnoteCallString:wO,gfmFootnoteCall:TO,gfmFootnoteDefinitionLabelString:EO,gfmFootnoteDefinition:DO}}}function jO(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:kO},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
74
- `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?NO:MO))),s(),o}}function MO(e,t,n){return t===0?e:NO(e,t,n)}function NO(e,t,n){return(n?``:` `)+e}var PO=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];zO.peek=BO;function FO(){return{canContainEols:[`delete`],enter:{strikethrough:LO},exit:{strikethrough:RO}}}function IO(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:PO}],handlers:{delete:zO}}}function LO(e){this.enter({type:`delete`,children:[]},e)}function RO(e){this.exit(e)}function zO(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function BO(){return`~`}function VO(e){return e.length}function HO(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||VO,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=UO(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=WO(r[d]);else{let e=WO(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
75
- `)}function UO(e){return e==null?``:String(e)}function WO(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function GO(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),KO);return i(),o}function KO(e,t,n){return`>`+(n?``:` `)+e}function qO(e,t){return JO(e,t.inConstruct,!0)&&!JO(e,t.notInConstruct,!1)}function JO(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function YO(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
76
- `&&qO(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
77
- `}function XO(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function ZO(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function QO(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function $O(e,t,n,r){let i=QO(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(ZO(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,ek);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(XO(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
72
+ `}),n}function oD(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function sD(e,t){let n=tD(e,t),r=n.one(e,void 0),i=BE(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
73
+ `},i)),a}function cD(e,t){return e&&`run`in e?async function(n,r){let i=sD(n,{file:r,...t});await e.run(i,r)}:function(n,r){return sD(n,{file:r,...e||t})}}function lD(e){if(e)throw e}var uD=r(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function dD(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function fD(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?pD(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function pD(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var mD={basename:hD,dirname:gD,extname:_D,join:vD,sep:`/`};function hD(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);xD(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function gD(e){if(xD(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function _D(e){xD(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function vD(...e){let t=-1,n;for(;++t<e.length;)xD(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:yD(n)}function yD(e){xD(e);let t=e.codePointAt(0)===47,n=bD(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function bD(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function xD(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var SD={cwd:CD};function CD(){return`/`}function wD(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function TD(e){if(typeof e==`string`)e=new URL(e);else if(!wD(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return ED(e)}function ED(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var DD=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],OD=class{constructor(e){let t;t=e?wD(e)?{path:e}:typeof e==`string`||MD(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:SD.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<DD.length;){let e=DD[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)DD.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?mD.basename(this.path):void 0}set basename(e){AD(e,`basename`),kD(e,`basename`),this.path=mD.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?mD.dirname(this.path):void 0}set dirname(e){jD(this.basename,`dirname`),this.path=mD.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?mD.extname(this.path):void 0}set extname(e){if(kD(e,`extname`),jD(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=mD.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){wD(e)&&(e=TD(e)),AD(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?mD.basename(this.path,this.extname):void 0}set stem(e){AD(e,`stem`),kD(e,`stem`),this.path=mD.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new mS(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function kD(e,t){if(e&&e.includes(mD.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+mD.sep+"`")}function AD(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function jD(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function MD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var ND=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),PD=n(uD(),1),FD={}.hasOwnProperty,ID=new class e extends ND{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=fD()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,PD.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(zD(`data`,this.frozen),this.namespace[e]=t,this):FD.call(this.namespace,e)&&this.namespace[e]||void 0:e?(zD(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=HD(e),n=this.parser||this.Parser;return LD(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),LD(`process`,this.parser||this.Parser),RD(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=HD(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);WD(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),LD(`processSync`,this.parser||this.Parser),RD(`processSync`,this.compiler||this.Compiler),this.process(e,r),VD(`processSync`,`process`,t),n;function r(e,r){t=!0,lD(e),n=r}}run(e,t,n){BD(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=HD(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),VD(`runSync`,`run`,n),r;function i(e,t){lD(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=HD(t),r=this.compiler||this.Compiler;return RD(`stringify`,r),BD(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(zD(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,PD.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];dD(o)&&dD(r)&&(r=(0,PD.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function LD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function RD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function zD(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function BD(e){if(!dD(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function VD(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function HD(e){return UD(e)?e:new OD(e)}function UD(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function WD(e){return typeof e==`string`||GD(e)}function GD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var KD=[],qD={allowDangerousHtml:!0},JD=/^(https?|ircs?|mailto|xmpp)$/i,YD=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function XD(e){let t=ZD(e),n=QD(e);return $D(t.runSync(t.parse(n),n),e)}function ZD(e){let t=e.rehypePlugins||KD,n=e.remarkPlugins||KD,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...qD}:qD;return ID().use(GT).use(n).use(cD,r).use(t)}function QD(e){let t=e.children||``,n=new OD;return typeof t==`string`?n.value=t:``+t,n}function $D(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||eO;for(let e of YD)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return QE(e,l),SS(e,{Fragment:P.Fragment,components:i,ignoreInvalidStyle:!0,jsx:P.jsx,jsxs:P.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in WS)if(Object.hasOwn(WS,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=WS[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function eO(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||JD.test(e.slice(0,t))?e:``}function tO(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function nO(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function rO(e,t,n){let r=VE((n||{}).ignore||[]),i=iO(t),a=-1;for(;++a<i.length;)XE(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function iO(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([aO(e[0]),oO(e[1])])}return t}function aO(e){return typeof e==`string`?new RegExp(nO(e),`g`):e}function oO(e){return typeof e==`function`?e:function(){return e}}var sO=`phrasing`,cO=[`autolink`,`link`,`image`,`label`];function lO(){return{transforms:[_O],enter:{literalAutolink:dO,literalAutolinkEmail:fO,literalAutolinkHttp:fO,literalAutolinkWww:fO},exit:{literalAutolink:gO,literalAutolinkEmail:hO,literalAutolinkHttp:pO,literalAutolinkWww:mO}}}function uO(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:sO,notInConstruct:cO},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:sO,notInConstruct:cO},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:sO,notInConstruct:cO}]}}function dO(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function fO(e){this.config.enter.autolinkProtocol.call(this,e)}function pO(e){this.config.exit.autolinkProtocol.call(this,e)}function mO(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function hO(e){this.config.exit.autolinkEmail.call(this,e)}function gO(e){this.exit(e)}function _O(e){rO(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,vO],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,yO]],{ignore:[`link`,`linkReference`]})}function vO(e,t,n,r,i){let a=``;if(!SO(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!bO(n)))return!1;let o=xO(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function yO(e,t,n,r){return!SO(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function bO(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function xO(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=tO(e,`(`),a=tO(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function SO(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||gC(n)||hC(n))&&(!t||n!==47)}MO.peek=jO;function CO(){this.buffer()}function wO(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function TO(){this.buffer()}function EO(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function DO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=aC(this.sliceSerialize(e)).toLowerCase(),n.label=t}function OO(e){this.exit(e)}function kO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=aC(this.sliceSerialize(e)).toLowerCase(),n.label=t}function AO(e){this.exit(e)}function jO(){return`[`}function MO(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function NO(){return{enter:{gfmFootnoteCallString:CO,gfmFootnoteCall:wO,gfmFootnoteDefinitionLabelString:TO,gfmFootnoteDefinition:EO},exit:{gfmFootnoteCallString:DO,gfmFootnoteCall:OO,gfmFootnoteDefinitionLabelString:kO,gfmFootnoteDefinition:AO}}}function PO(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:MO},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
74
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?IO:FO))),s(),o}}function FO(e,t,n){return t===0?e:IO(e,t,n)}function IO(e,t,n){return(n?``:` `)+e}var LO=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];HO.peek=UO;function RO(){return{canContainEols:[`delete`],enter:{strikethrough:BO},exit:{strikethrough:VO}}}function zO(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:LO}],handlers:{delete:HO}}}function BO(e){this.enter({type:`delete`,children:[]},e)}function VO(e){this.exit(e)}function HO(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function UO(){return`~`}function WO(e){return e.length}function GO(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||WO,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=KO(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=qO(r[d]);else{let e=qO(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
75
+ `)}function KO(e){return e==null?``:String(e)}function qO(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function JO(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),YO);return i(),o}function YO(e,t,n){return`>`+(n?``:` `)+e}function XO(e,t){return ZO(e,t.inConstruct,!0)&&!ZO(e,t.notInConstruct,!1)}function ZO(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function QO(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
76
+ `&&XO(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
77
+ `}function $O(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function ek(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function tk(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function nk(e,t,n,r){let i=tk(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(ek(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,rk);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max($O(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
78
78
  `,encode:["`"],...s.current()})),t()}return u+=s.move(`
79
79
  `),a&&(u+=s.move(a+`
80
- `)),u+=s.move(c),l(),u}function ek(e,t,n){return(n?``:` `)+e}function tk(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function nk(e,t,n,r){let i=tk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
81
- `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function rk(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function ik(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function ak(e,t,n){let r=CC(e),i=CC(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}ok.peek=sk;function ok(e,t,n,r){let i=rk(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=ak(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=ik(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=ak(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+ik(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function sk(e,t,n){return n.options.emphasis||`*`}function ck(e,t){let n=!1;return YE(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&US(e)&&(t.options.setext||n))}function lk(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(ck(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
80
+ `)),u+=s.move(c),l(),u}function rk(e,t,n){return(n?``:` `)+e}function ik(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function ak(e,t,n,r){let i=ik(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
81
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function ok(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function sk(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function ck(e,t,n){let r=EC(e),i=EC(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}lk.peek=uk;function lk(e,t,n,r){let i=ok(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=ck(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=sk(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=ck(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+sk(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function uk(e,t,n){return n.options.emphasis||`*`}function dk(e,t){let n=!1;return QE(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&KS(e)&&(t.options.setext||n))}function fk(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(dk(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
82
82
  `,after:`
83
83
  `});return r(),t(),o+`
84
84
  `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
85
85
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
86
- `,...a.current()});return/^[\t ]/.test(l)&&(l=ik(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}uk.peek=dk;function uk(e){return e.value||``}function dk(){return`<`}fk.peek=pk;function fk(e,t,n,r){let i=tk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function pk(){return`!`}mk.peek=hk;function mk(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function hk(){return`!`}gk.peek=_k;function gk(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function _k(){return"`"}function vk(e,t){let n=US(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}yk.peek=bk;function yk(e,t,n,r){let i=tk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(vk(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function bk(e,t,n){return vk(e,n)?`<`:`[`}xk.peek=Sk;function xk(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Sk(){return`[`}function Ck(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function wk(e){let t=Ck(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Tk(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ek(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Dk(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Tk(n):Ck(n),s=e.ordered?o===`.`?`)`:`.`:wk(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Ek(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Ok(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function kk(e,t,n,r){let i=Ok(n),a=n.bulletCurrent||Ck(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Ak(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var jk=RE([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Mk(e,t,n,r){return(e.children.some(function(e){return jk(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Nk(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Pk.peek=Fk;function Pk(e,t,n,r){let i=Nk(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=ak(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=ik(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=ak(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+ik(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Fk(e,t,n){return n.options.strong||`*`}function Ik(e,t,n,r){return n.safe(e.value,r)}function Lk(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Rk(e,t,n){let r=(Ek(n)+(n.options.ruleSpaces?` `:``)).repeat(Lk(n));return n.options.ruleSpaces?r.slice(0,-1):r}var zk={blockquote:GO,break:YO,code:$O,definition:nk,emphasis:ok,hardBreak:YO,heading:lk,html:uk,image:fk,imageReference:mk,inlineCode:gk,link:yk,linkReference:xk,list:Dk,listItem:kk,paragraph:Ak,root:Mk,strong:Pk,text:Ik,thematicBreak:Rk};function Bk(){return{enter:{table:Vk,tableData:Gk,tableHeader:Gk,tableRow:Uk},exit:{codeText:Kk,table:Hk,tableData:Wk,tableHeader:Wk,tableRow:Wk}}}function Vk(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Hk(e){this.exit(e),this.data.inTable=void 0}function Uk(e){this.enter({type:`tableRow`,children:[]},e)}function Wk(e){this.exit(e)}function Gk(e){this.enter({type:`tableCell`,children:[]},e)}function Kk(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,qk));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function qk(e,t){return t===`|`?t:e}function Jk(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
86
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=sk(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}pk.peek=mk;function pk(e){return e.value||``}function mk(){return`<`}hk.peek=gk;function hk(e,t,n,r){let i=ik(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function gk(){return`!`}_k.peek=vk;function _k(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function vk(){return`!`}yk.peek=bk;function yk(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function bk(){return"`"}function xk(e,t){let n=KS(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}Sk.peek=Ck;function Sk(e,t,n,r){let i=ik(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(xk(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Ck(e,t,n){return xk(e,n)?`<`:`[`}wk.peek=Tk;function wk(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Tk(){return`[`}function Ek(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Dk(e){let t=Ek(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Ok(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function kk(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Ak(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Ok(n):Ek(n),s=e.ordered?o===`.`?`)`:`.`:Dk(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),kk(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function jk(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Mk(e,t,n,r){let i=jk(n),a=n.bulletCurrent||Ek(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Nk(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Pk=VE([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Fk(e,t,n,r){return(e.children.some(function(e){return Pk(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Ik(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Lk.peek=Rk;function Lk(e,t,n,r){let i=Ik(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=ck(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=sk(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=ck(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+sk(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Rk(e,t,n){return n.options.strong||`*`}function zk(e,t,n,r){return n.safe(e.value,r)}function Bk(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Vk(e,t,n){let r=(kk(n)+(n.options.ruleSpaces?` `:``)).repeat(Bk(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Hk={blockquote:JO,break:QO,code:nk,definition:ak,emphasis:lk,hardBreak:QO,heading:fk,html:pk,image:hk,imageReference:_k,inlineCode:yk,link:Sk,linkReference:wk,list:Ak,listItem:Mk,paragraph:Nk,root:Fk,strong:Lk,text:zk,thematicBreak:Vk};function Uk(){return{enter:{table:Wk,tableData:Jk,tableHeader:Jk,tableRow:Kk},exit:{codeText:Yk,table:Gk,tableData:qk,tableHeader:qk,tableRow:qk}}}function Wk(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Gk(e){this.exit(e),this.data.inTable=void 0}function Kk(e){this.enter({type:`tableRow`,children:[]},e)}function qk(e){this.exit(e)}function Jk(e){this.enter({type:`tableCell`,children:[]},e)}function Yk(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Xk));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Xk(e,t){return t===`|`?t:e}function Zk(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
87
87
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
88
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return HO(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=zk.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Yk(){return{exit:{taskListCheckValueChecked:Zk,taskListCheckValueUnchecked:Zk,paragraph:Qk}}}function Xk(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:$k}}}function Zk(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Qk(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function $k(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=zk.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function eA(){return[oO(),AO(),FO(),Bk(),Yk()]}function tA(e){return{extensions:[sO(),jO(e),IO(),Jk(e),Xk()]}}var nA={tokenize:gA,partial:!0},rA={tokenize:_A,partial:!0},iA={tokenize:vA,partial:!0},aA={tokenize:yA,partial:!0},oA={tokenize:bA,partial:!0},sA={name:`wwwAutolink`,tokenize:mA,previous:xA},cA={name:`protocolAutolink`,tokenize:hA,previous:SA},lA={name:`emailAutolink`,tokenize:pA,previous:CA},uA={};function dA(){return{text:uA}}for(var fA=48;fA<123;)uA[fA]=lA,fA++,fA===58?fA=65:fA===91&&(fA=97);uA[43]=lA,uA[45]=lA,uA[46]=lA,uA[95]=lA,uA[72]=[lA,cA],uA[104]=[lA,cA],uA[87]=[lA,sA],uA[119]=[lA,sA];function pA(e,t,n){let r=this,i,a;return o;function o(t){return!wA(t)||!CA.call(r,r.previous)||TA(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return wA(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(oA,u,l)(t):t===45||t===95||iC(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&rC(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function mA(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!xA.call(r,r.previous)||TA(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(nA,e.attempt(rA,e.attempt(iA,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function hA(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&SA.call(r,r.previous)&&!TA(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(rC(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||oC(t)||uC(t)||pC(t)||fC(t)?n(t):e.attempt(rA,e.attempt(iA,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function gA(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function _A(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(aA,c,s)(t):t===null||uC(t)||pC(t)||t!==45&&fC(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function vA(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(aA,t,a)(o):o===null||uC(o)||pC(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function yA(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||uC(o)||pC(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||uC(e)||pC(e)?t(e):r(e)}function a(e){return rC(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):rC(t)?(e.consume(t),o):n(t)}}function bA(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return iC(e)?n(e):t(e)}}function xA(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||uC(e)}function SA(e){return!rC(e)}function CA(e){return!(e===47||wA(e))}function wA(e){return e===43||e===45||e===46||e===95||iC(e)}function TA(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var EA={tokenize:PA,partial:!0};function DA(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:jA,continuation:{tokenize:MA},exit:NA}},text:{91:{name:`gfmFootnoteCall`,tokenize:AA},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:OA,resolveTo:kA}}}}function OA(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=nC(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function kA(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function AA(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||uC(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(nC(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return uC(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function jA(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||uC(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=nC(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return uC(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),gC(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function MA(e,t,n){return e.check(jC,t,e.attempt(EA,t,n))}function NA(e){e.exit(`gfmFootnoteDefinition`)}function PA(e,t,n){let r=this;return gC(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function FA(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&YS(o,o.length,0,wC(s,e.slice(r+1,n),t)),YS(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),YS(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=CC(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=CC(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var IA=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){LA(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function LA(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function RA(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function zA(){return{flow:{null:{name:`table`,tokenize:BA,resolveAll:VA}}}}function BA(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):dC(t)?gC(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||uC(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,dC(t)?gC(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return dC(t)?gC(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return dC(t)?gC(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):dC(n)?gC(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||uC(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function VA(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new IA;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(UA(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=HA(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=HA(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=HA(f,t,o,i,n,d)):(o[0]=o[1],d=HA(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&UA(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=RA(t.events,n))}return e}function HA(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},WA(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=WA(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=WA(t.events,n[2]),a=WA(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},WA(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function UA(e,t,n,r,i){let a=[],o=WA(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function WA(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var GA={name:`tasklistCheck`,tokenize:qA};function KA(){return{text:{91:GA}}}function qA(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return uC(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):dC(r)?e.check({tokenize:JA},t,n)(r):n(r)}}function JA(e,t,n){return gC(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function YA(e){return QS([dA(),DA(),FA(e),zA(),KA()])}var XA={};function ZA(e){let t=this,n=e||XA,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(YA(n)),a.push(eA()),o.push(tA(n))}var QA={a:({children:e,...t})=>(0,P.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer`,className:`text-primary underline underline-offset-2`,children:e}),code:({className:e,children:t,...n})=>/language-/.test(e??``)?(0,P.jsx)(`code`,{...n,className:`block overflow-auto rounded-md border bg-[var(--plane)] p-3 font-mono text-xs whitespace-pre-wrap`,children:t}):(0,P.jsx)(`code`,{...n,className:`rounded-sm bg-[var(--plane)] px-1 py-0.5 font-mono text-[0.85em]`,children:t}),pre:({children:e,...t})=>(0,P.jsx)(`pre`,{...t,className:`my-1 overflow-auto`,children:e}),blockquote:({children:e,...t})=>(0,P.jsx)(`blockquote`,{...t,className:`border-l-2 border-border pl-3 text-muted-foreground`,children:e}),table:({children:e,...t})=>(0,P.jsx)(`div`,{className:`overflow-auto`,children:(0,P.jsx)(`table`,{...t,className:`w-full text-xs`,children:e})})};function $A({children:e,className:t}){return(0,P.jsx)(`div`,{className:a(`md-body grid gap-2 text-sm leading-relaxed [&_h1]:mt-1 [&_h2]:mt-2 [&_h3]:mt-1`,t),children:(0,P.jsx)(qD,{remarkPlugins:[ZA],components:QA,children:e})})}var ej={clean:`success`,informational:`neutral`,actionable:`warning`,critical:`critical`},tj={critical:`critical`,high:`error`,medium:`warning`,low:`neutral`,informational:`neutral`};function nj(){let e=If(),t=Zf({queryKey:[`runs`],queryFn:()=>Nb.runs()}),n=t.data?.runs??[],[r,i]=(0,N.useState)(null),a=Zf({queryKey:[`report-versions`,r],queryFn:()=>Nb.reportVersions(r),enabled:!!r}).data?.items??[],[o,c]=(0,N.useState)(null);(0,N.useEffect)(()=>{n.length>0&&!n.some(e=>e.id===r)&&i(n[0].id)},[n,r]),(0,N.useEffect)(()=>{if(a.length===0){c(null);return}a.some(e=>e.version===o)||c(a[0].version)},[r,a,o]);let l=Zf({queryKey:[`report-version`,r,o],queryFn:()=>Nb.reportVersion(r,o),enabled:!!r&&o!==null}),u=l.data?.record,d=l.data?.renditions.find(e=>e.ext===`md`)?.url??null,f=Zf({queryKey:[`report-md`,r,o],queryFn:async()=>{let e=await fetch(d,{credentials:`same-origin`});if(!e.ok)throw Error(`Rendition fetch failed: ${e.status}`);return e.text()},enabled:d!==null}),[p,m]=(0,N.useState)(!1),[h,_]=(0,N.useState)(null),v=()=>{e.invalidateQueries({queryKey:[`report-versions`,r]}),e.invalidateQueries({queryKey:[`report-version`,r]}),e.invalidateQueries({queryKey:[`report-md`,r]})},y=Qf({mutationFn:()=>Nb.renderReportRenditions(r,o),onSuccess:()=>{m(!1),v()}}),b=Qf({mutationFn:()=>Nb.publishEditedMarkdown(r,o,h),onSuccess:e=>{_(null),m(!1),c(e.version),v()}});return t.isLoading?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading runs…`})}):n.length===0?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`No runs yet. Launch an assessment and its report will appear here on completion.`})}):(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-0`,children:`Generated report`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`The structured record is read-only; edits create new auditable versions.`})]}),(0,P.jsxs)(`div`,{className:`bg-card flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border p-3`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Run`}),(0,P.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:r??``,onChange:e=>{i(e.target.value),c(null)},children:n.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title,` — `,rj(e.status)]},e.id))})]}),a.length>0?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Version`}),a.map(e=>(0,P.jsxs)(s,{variant:e.version===o?`secondary`:`outline`,size:`sm`,className:`aria-pressed:border-primary`,"aria-pressed":e.version===o,onClick:()=>{c(e.version),m(!1)},children:[`v`,e.version,` · `,e.publicationState]},e.version))]}):null]}),a.length===0?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No report has been generated for this run yet. Reports are produced when a run reaches a terminal state.`})}):(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[u?(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(ux,{variant:lx(ej[u.posture]??`neutral`),children:u.posture.toUpperCase()}),(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[`v`,l.data?.version,` · `,u.contentHash.slice(0,12),` · `,u.classification,` ·`,` `,u.publicationState]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsx)(`h2`,{children:u.target}),(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Export`}),l.data?.renditions.filter(e=>e.url).length?l.data.renditions.filter(e=>e.url).map(e=>(0,P.jsx)(s,{variant:`outline`,size:`sm`,asChild:!0,children:(0,P.jsxs)(`a`,{href:e.url,download:!0,children:[(0,P.jsx)(oe,{}),` `,e.ext.toUpperCase()]})},e.ext)):(0,P.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:u.publicationState===`published`?`Use “Ensure renditions” below to generate files.`:`Publish to generate downloadable files.`})]})]}),(0,P.jsxs)(`p`,{className:`text-muted-foreground`,children:[u.workflowKey,` · `,u.findings.length,` finding(s) · `,u.evidence.length,` evidence row(s)`]}),u.gate.satisfied?null:(0,P.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Publication blocked: missing `,u.gate.missing.join(`, `),`.`]}),u.summary?(0,P.jsx)(`p`,{children:u.summary}):null,u.findings.length>0?(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Severity`}),(0,P.jsx)(`th`,{children:`Finding`}),(0,P.jsx)(`th`,{children:`Target`})]})}),(0,P.jsx)(`tbody`,{children:u.findings.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{children:(0,P.jsx)(ux,{variant:lx(tj[e.severity]??`neutral`),children:e.severity})}),(0,P.jsx)(`td`,{children:e.title}),(0,P.jsx)(`td`,{className:`text-muted-foreground`,children:e.targetUrl??`—`})]},e.fingerprint))})]}):(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`No confirmed findings recorded — posture never claims a clean bill by default.`}),u.unverifiedLeads.length>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h3`,{children:`Unverified leads`}),(0,P.jsx)(`ul`,{children:u.unverifiedLeads.map(e=>(0,P.jsxs)(`li`,{children:[e.title,` `,(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.disposition,`)`]})]},e.fingerprint))})]}):null,u.negativeControls.length>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h3`,{children:`Negative controls`}),(0,P.jsx)(`ul`,{children:u.negativeControls.map(e=>(0,P.jsx)(`li`,{children:e},e))})]}):null]}):(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{children:`Select a run and version.`})}),l.data?(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(`h3`,{children:`Markdown rendition`}),(0,P.jsx)(`span`,{className:`flex flex-wrap items-center gap-2.5`,children:l.data.renditions.filter(e=>e.url).map(e=>(0,P.jsx)(s,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,P.jsxs)(`a`,{href:e.url,download:!0,children:[(0,P.jsx)(oe,{}),` `,e.ext]})},e.ext))})]}),(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{margin:`0.5rem 0`},children:[(0,P.jsxs)(s,{variant:`ghost`,onClick:()=>m(e=>!e),disabled:b.isPending,children:[p?(0,P.jsx)(ce,{}):(0,P.jsx)(ye,{}),` `,p?`View`:`Edit`]}),(0,P.jsxs)(s,{variant:`ghost`,onClick:()=>y.mutate(),disabled:y.isPending||u?.publicationState!==`published`,title:`Create any missing immutable report renditions`,children:[(0,P.jsx)(Ce,{}),` Ensure renditions`]})]}),p?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`textarea`,{className:`w-full resize-y rounded-lg border bg-[var(--plane)] p-3 font-mono text-[0.85rem] leading-normal`,value:h??f.data??``,onChange:e=>_(e.target.value),rows:24}),(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{marginTop:`0.5rem`},children:[(0,P.jsxs)(s,{onClick:()=>b.mutate(),disabled:b.isPending||!h?.trim(),children:[(0,P.jsx)(we,{}),` Save as v`,(l.data?.version??0)+1]}),b.isError?(0,P.jsxs)(`span`,{className:`text-destructive text-sm`,children:[`Save failed: `,String(b.error)]}):null]})]}):f.isLoading?(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading markdown…`}):f.isError||d===null?(0,P.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No rendered markdown yet`,d===null?``:` (unavailable)`,` — regenerate to produce it.`]}):(0,P.jsx)(`div`,{className:`max-h-[32rem] overflow-auto rounded-lg border bg-[var(--plane)] p-4`,children:(0,P.jsx)($A,{children:f.data??``})})]}):null]})]})}function rj(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var ij=[`Reported`,`Confirmed`,`Remediating`,`Resolved`],aj={open:0,unverified:0,confirmed:1,remediating:2,remediated:3,verified:3},oj={false_positive:`Dismissed as a false positive`,accepted_risk:`Accepted as residual risk`,suppressed:`Suppressed`};function sj(e){let t={label:`Confirm as risk`,status:`confirmed`,icon:(0,P.jsx)(Ee,{size:14})},n={label:`Dismiss (false positive)`,status:`false_positive`,icon:(0,P.jsx)(ne,{size:14}),variant:`outline`},r={label:`Start remediation`,status:`remediating`,icon:(0,P.jsx)(Ie,{size:14})},i={label:`Mark resolved`,status:`remediated`,icon:(0,P.jsx)(A,{size:14})},a={label:`Verify fix`,status:`verified`,icon:(0,P.jsx)(b,{size:14})},o={label:`Accept risk`,status:`accepted_risk`,icon:(0,P.jsx)(b,{size:14}),variant:`outline`},s={label:`Reopen`,status:`confirmed`,icon:(0,P.jsx)(w,{size:14}),variant:`outline`};switch(e){case`open`:case`unverified`:return[t,n];case`confirmed`:return[r,i,o,n];case`remediating`:return[i,a,o];case`remediated`:return[a,s];case`verified`:return[s];default:return[{...s,label:`Reopen finding`}]}}function cj({findingId:e,onBack:t}){let n=If(),r=Zf({queryKey:[`finding`,e],queryFn:()=>Nb.finding(e)}),i=Qf({mutationFn:t=>Nb.updateFindingStatus(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`finding`,e]}),n.invalidateQueries({queryKey:[`findings`]}),n.invalidateQueries({queryKey:[`overview`]})}});if(r.isLoading)return(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading finding…`})});if(r.isError||!r.data)return(0,P.jsx)(g,{children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsx)(`p`,{className:`text-destructive`,children:`Could not load this finding.`}),t?(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:t,children:[(0,P.jsx)(w,{size:14}),` Back`]}):null]})});let a=r.data.finding,o=Hb(a.severity),c=qb(a.category,a.title),l=Fb(c.stage),u=aj[a.status],d=oj[a.status],f=sj(a.status);return(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`grid gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(ux,{variant:lx(o),children:Vb[o]}),(0,P.jsx)(ux,{variant:lx(a.status),children:uj(a.status)}),a.cvssScore==null?null:(0,P.jsxs)(ux,{variant:`outline`,children:[`CVSS `,a.cvssScore]})]}),(0,P.jsx)(`h1`,{className:`text-xl font-semibold`,children:a.title}),(0,P.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[a.path??`unscoped asset`,a.line==null?``:`:${a.line}`,` · Stage `,c.stage,` `,Ib(l),` · Pillar `,Lb[c.pillar],c.inferred?` (inferred)`:``]})]}),t?(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:t,children:[(0,P.jsx)(w,{size:14}),` Back`]}):null]}),(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolution`}),d?(0,P.jsx)(ux,{variant:`secondary`,children:d}):null]}),d?(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This finding is off the remediation track. Reopen it to return it to the queue.`}):(0,P.jsx)(`ol`,{className:`mt-1 grid grid-cols-4 gap-2`,"aria-label":`Resolution progress`,children:ij.map((e,t)=>(0,P.jsxs)(`li`,{className:`grid gap-1.5`,children:[(0,P.jsx)(`span`,{className:`h-1.5 rounded-full`,style:{background:u!=null&&t<=u?`var(--good)`:`var(--border)`},"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:u===t?`text-xs font-semibold`:`text-muted-foreground text-xs`,children:e})]},e))})]}),(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Verify & triage`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Move this finding through its lifecycle. Changes are audited.`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,P.jsxs)(s,{size:`sm`,variant:e.variant??`default`,disabled:i.isPending,onClick:()=>i.mutate(e.status),children:[e.icon,` `,e.label]},`${e.label}:${e.status}`))}),i.isError?(0,P.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Update failed: `,String(i.error?.message??i.error)]}):null]}),a.description?(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Description`}),(0,P.jsx)($A,{children:a.description})]}):null,a.remediation?(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Remediation`}),(0,P.jsx)($A,{children:a.remediation})]}):null,(0,P.jsxs)(g,{children:[(0,P.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[`Evidence (`,a.evidence.length,`)`]}),a.evidence.length?(0,P.jsx)(`div`,{className:`grid gap-2`,children:a.evidence.map(e=>(0,P.jsx)(ox,{title:`${e.kind}${e.reason?` — ${e.reason}`:``}`,detail:(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[new Date(e.createdAt).toLocaleString(),e.runID?` · run ${e.runID.slice(0,12)}`:``]}),verdict:e.verdict},e.id))}):(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No operation-level evidence linked yet. Source findings stay unverified until evidence confirms them.`})]}),(a.cwe||a.cve||a.cvssVector||a.assignee||a.resolvedAt)&&(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Metadata`}),(0,P.jsxs)(`dl`,{className:`grid gap-1.5 text-sm sm:grid-cols-2`,children:[a.cwe?(0,P.jsx)(lj,{k:`CWE`,v:a.cwe}):null,a.cve?(0,P.jsx)(lj,{k:`CVE`,v:a.cve}):null,a.cvssVector?(0,P.jsx)(lj,{k:`CVSS vector`,v:a.cvssVector,mono:!0}):null,a.assignee?(0,P.jsx)(lj,{k:`Assignee`,v:a.assignee}):null,a.resolvedAt?(0,P.jsx)(lj,{k:`Resolved`,v:new Date(a.resolvedAt).toLocaleString()}):null,(0,P.jsx)(lj,{k:`Fingerprint`,v:a.fingerprint,mono:!0})]})]})]})}function lj({k:e,v:t,mono:n}){return(0,P.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,P.jsx)(`dt`,{className:`text-muted-foreground text-2xs w-28 shrink-0 font-semibold tracking-[0.08em] uppercase`,children:e}),(0,P.jsx)(`dd`,{className:n?`font-mono text-xs break-all`:``,children:t})]})}function uj(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var dj=null;function fj(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=dj;dj=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{dj=n}}function pj(){if(!dj)throw Error(`No resource fiber available`);return dj}function mj(){return dj}var hj=typeof process<`u`&&!1,gj=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),_j=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},vj=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(hj)throw Error(`tap: committed history is shorter than the replay base.`);break}Sj(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;xj(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)yj(e.changelog[t]);_j(e)}}},yj=e=>{Sj(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},bj=(e,t)=>{e.wipCommitCallbacks.push(t)},xj=(e,t)=>{e.rollbackCallbacks.push(t)},Sj=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),xj(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},Cj=Symbol.for(`react.memo_cache_sentinel`),wj=e=>Array(e).fill(Cj),Tj=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,xj(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=wj(t),r[i]=a):hj&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},Ej=e=>Tj(pj(),e),Dj=N.default.__COMPILER_RUNTIME?.c??(e=>(0,N.useMemo)(()=>{let t=wj(e);return t[Cj]=!0,t},[])),Oj=()=>mj()!==null,J=e=>Oj()?Ej(e):Dj(e),kj=(e,...t)=>Object.assign(Object.create(null),e,...t),Aj=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},jj=()=>{throw Error(`Hook order changed between renders`)},Mj=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function Nj(e,t){let n=pj(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?Mj():i.type===`effect`?i:jj();if(i===void 0&&(n.isFirstRender||Aj(),n.cells[r]=a,n.effectCells.push(a)),a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);bj(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var Pj=(e,t)=>{hj&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
88
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return GO(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Hk.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Qk(){return{exit:{taskListCheckValueChecked:eA,taskListCheckValueUnchecked:eA,paragraph:tA}}}function $k(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:nA}}}function eA(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function tA(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function nA(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Hk.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function rA(){return[lO(),NO(),RO(),Uk(),Qk()]}function iA(e){return{extensions:[uO(),PO(e),zO(),Zk(e),$k()]}}var aA={tokenize:yA,partial:!0},oA={tokenize:bA,partial:!0},sA={tokenize:xA,partial:!0},cA={tokenize:SA,partial:!0},lA={tokenize:CA,partial:!0},uA={name:`wwwAutolink`,tokenize:_A,previous:wA},dA={name:`protocolAutolink`,tokenize:vA,previous:TA},fA={name:`emailAutolink`,tokenize:gA,previous:EA},pA={};function mA(){return{text:pA}}for(var hA=48;hA<123;)pA[hA]=fA,hA++,hA===58?hA=65:hA===91&&(hA=97);pA[43]=fA,pA[45]=fA,pA[46]=fA,pA[95]=fA,pA[72]=[fA,dA],pA[104]=[fA,dA],pA[87]=[fA,uA],pA[119]=[fA,uA];function gA(e,t,n){let r=this,i,a;return o;function o(t){return!DA(t)||!EA.call(r,r.previous)||OA(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return DA(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(lA,u,l)(t):t===45||t===95||sC(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&oC(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function _A(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!wA.call(r,r.previous)||OA(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(aA,e.attempt(oA,e.attempt(sA,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function vA(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&TA.call(r,r.previous)&&!OA(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(oC(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||lC(t)||pC(t)||gC(t)||hC(t)?n(t):e.attempt(oA,e.attempt(sA,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function yA(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function bA(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(cA,c,s)(t):t===null||pC(t)||gC(t)||t!==45&&hC(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function xA(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(cA,t,a)(o):o===null||pC(o)||gC(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function SA(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||pC(o)||gC(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||pC(e)||gC(e)?t(e):r(e)}function a(e){return oC(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):oC(t)?(e.consume(t),o):n(t)}}function CA(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return sC(e)?n(e):t(e)}}function wA(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||pC(e)}function TA(e){return!oC(e)}function EA(e){return!(e===47||DA(e))}function DA(e){return e===43||e===45||e===46||e===95||sC(e)}function OA(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var kA={tokenize:LA,partial:!0};function AA(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:PA,continuation:{tokenize:FA},exit:IA}},text:{91:{name:`gfmFootnoteCall`,tokenize:NA},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:jA,resolveTo:MA}}}}function jA(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=aC(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function MA(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function NA(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||pC(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(aC(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return pC(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function PA(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||pC(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=aC(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return pC(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),yC(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function FA(e,t,n){return e.check(PC,t,e.attempt(kA,t,n))}function IA(e){e.exit(`gfmFootnoteDefinition`)}function LA(e,t,n){let r=this;return yC(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function RA(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&QS(o,o.length,0,DC(s,e.slice(r+1,n),t)),QS(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),QS(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=EC(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=EC(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var zA=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){BA(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function BA(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function VA(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function HA(){return{flow:{null:{name:`table`,tokenize:UA,resolveAll:WA}}}}function UA(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):mC(t)?yC(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||pC(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,mC(t)?yC(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return mC(t)?yC(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return mC(t)?yC(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):mC(n)?yC(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||pC(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function WA(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new zA;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(KA(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=GA(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=GA(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=GA(f,t,o,i,n,d)):(o[0]=o[1],d=GA(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&KA(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=VA(t.events,n))}return e}function GA(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},qA(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=qA(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=qA(t.events,n[2]),a=qA(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},qA(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function KA(e,t,n,r,i){let a=[],o=qA(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function qA(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var JA={name:`tasklistCheck`,tokenize:XA};function YA(){return{text:{91:JA}}}function XA(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return pC(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):mC(r)?e.check({tokenize:ZA},t,n)(r):n(r)}}function ZA(e,t,n){return yC(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function QA(e){return tC([mA(),AA(),RA(e),HA(),YA()])}var $A={};function ej(e){let t=this,n=e||$A,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(QA(n)),a.push(rA()),o.push(iA(n))}var tj={a:({children:e,...t})=>(0,P.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer`,className:`text-primary underline underline-offset-2`,children:e}),code:({className:e,children:t,...n})=>/language-/.test(e??``)?(0,P.jsx)(`code`,{...n,className:`block overflow-auto rounded-md border bg-[var(--plane)] p-3 font-mono text-xs whitespace-pre-wrap`,children:t}):(0,P.jsx)(`code`,{...n,className:`rounded-sm bg-[var(--plane)] px-1 py-0.5 font-mono text-[0.85em]`,children:t}),pre:({children:e,...t})=>(0,P.jsx)(`pre`,{...t,className:`my-1 overflow-auto`,children:e}),blockquote:({children:e,...t})=>(0,P.jsx)(`blockquote`,{...t,className:`border-l-2 border-border pl-3 text-muted-foreground`,children:e}),table:({children:e,...t})=>(0,P.jsx)(`div`,{className:`overflow-auto`,children:(0,P.jsx)(`table`,{...t,className:`w-full text-xs`,children:e})})};function nj({children:e,className:t}){return(0,P.jsx)(`div`,{className:a(`md-body grid gap-2 text-sm leading-relaxed [&_h1]:mt-1 [&_h2]:mt-2 [&_h3]:mt-1`,t),children:(0,P.jsx)(XD,{remarkPlugins:[ej],components:tj,children:e})})}var rj={clean:`success`,informational:`neutral`,actionable:`warning`,critical:`critical`},ij={critical:`critical`,high:`error`,medium:`warning`,low:`neutral`,informational:`neutral`};function aj(){let e=zf(),t=ep({queryKey:[`runs`],queryFn:()=>Ib.runs()}),n=t.data?.runs??[],[r,i]=(0,N.useState)(null),a=ep({queryKey:[`report-versions`,r],queryFn:()=>Ib.reportVersions(r),enabled:!!r}).data?.items??[],[o,c]=(0,N.useState)(null);(0,N.useEffect)(()=>{n.length>0&&!n.some(e=>e.id===r)&&i(n[0].id)},[n,r]),(0,N.useEffect)(()=>{if(a.length===0){c(null);return}a.some(e=>e.version===o)||c(a[0].version)},[r,a,o]);let l=ep({queryKey:[`report-version`,r,o],queryFn:()=>Ib.reportVersion(r,o),enabled:!!r&&o!==null}),u=l.data?.record,d=l.data?.renditions.find(e=>e.ext===`md`)?.url??null,f=ep({queryKey:[`report-md`,r,o],queryFn:async()=>{let e=await fetch(d,{credentials:`same-origin`});if(!e.ok)throw Error(`Rendition fetch failed: ${e.status}`);return e.text()},enabled:d!==null}),[p,m]=(0,N.useState)(!1),[h,_]=(0,N.useState)(null),v=()=>{e.invalidateQueries({queryKey:[`report-versions`,r]}),e.invalidateQueries({queryKey:[`report-version`,r]}),e.invalidateQueries({queryKey:[`report-md`,r]})},y=tp({mutationFn:()=>Ib.renderReportRenditions(r,o),onSuccess:()=>{m(!1),v()}}),b=tp({mutationFn:()=>Ib.publishEditedMarkdown(r,o,h),onSuccess:e=>{_(null),m(!1),c(e.version),v()}});return t.isLoading?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading runs…`})}):n.length===0?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`No runs yet. Launch an assessment and its report will appear here on completion.`})}):(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-0`,children:`Generated report`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`The structured record is read-only; edits create new auditable versions.`})]}),(0,P.jsxs)(`div`,{className:`bg-card flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border p-3`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Run`}),(0,P.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:r??``,onChange:e=>{i(e.target.value),c(null)},children:n.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title,` — `,oj(e.status)]},e.id))})]}),a.length>0?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Version`}),a.map(e=>(0,P.jsxs)(s,{variant:e.version===o?`secondary`:`outline`,size:`sm`,className:`aria-pressed:border-primary`,"aria-pressed":e.version===o,onClick:()=>{c(e.version),m(!1)},children:[`v`,e.version,` · `,e.publicationState]},e.version))]}):null]}),a.length===0?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No report has been generated for this run yet. Reports are produced when a run reaches a terminal state.`})}):(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[u?(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(px,{variant:fx(rj[u.posture]??`neutral`),children:u.posture.toUpperCase()}),(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[`v`,l.data?.version,` · `,u.contentHash.slice(0,12),` · `,u.classification,` ·`,` `,u.publicationState]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsx)(`h2`,{children:u.target}),(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Export`}),l.data?.renditions.filter(e=>e.url).length?l.data.renditions.filter(e=>e.url).map(e=>(0,P.jsx)(s,{variant:`outline`,size:`sm`,asChild:!0,children:(0,P.jsxs)(`a`,{href:e.url,download:!0,children:[(0,P.jsx)(se,{}),` `,e.ext.toUpperCase()]})},e.ext)):(0,P.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:u.publicationState===`published`?`Use “Ensure renditions” below to generate files.`:`Publish to generate downloadable files.`})]})]}),(0,P.jsxs)(`p`,{className:`text-muted-foreground`,children:[u.workflowKey,` · `,u.findings.length,` finding(s) · `,u.evidence.length,` evidence row(s)`]}),u.gate.satisfied?null:(0,P.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Publication blocked: missing `,u.gate.missing.join(`, `),`.`]}),u.summary?(0,P.jsx)(`p`,{children:u.summary}):null,u.findings.length>0?(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Severity`}),(0,P.jsx)(`th`,{children:`Finding`}),(0,P.jsx)(`th`,{children:`Target`})]})}),(0,P.jsx)(`tbody`,{children:u.findings.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:fx(ij[e.severity]??`neutral`),children:e.severity})}),(0,P.jsx)(`td`,{children:e.title}),(0,P.jsx)(`td`,{className:`text-muted-foreground`,children:e.targetUrl??`—`})]},e.fingerprint))})]}):(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`No confirmed findings recorded — posture never claims a clean bill by default.`}),u.unverifiedLeads.length>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h3`,{children:`Unverified leads`}),(0,P.jsx)(`ul`,{children:u.unverifiedLeads.map(e=>(0,P.jsxs)(`li`,{children:[e.title,` `,(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.disposition,`)`]})]},e.fingerprint))})]}):null,u.negativeControls.length>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h3`,{children:`Negative controls`}),(0,P.jsx)(`ul`,{children:u.negativeControls.map(e=>(0,P.jsx)(`li`,{children:e},e))})]}):null]}):(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{children:`Select a run and version.`})}),l.data?(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(`h3`,{children:`Markdown rendition`}),(0,P.jsx)(`span`,{className:`flex flex-wrap items-center gap-2.5`,children:l.data.renditions.filter(e=>e.url).map(e=>(0,P.jsx)(s,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,P.jsxs)(`a`,{href:e.url,download:!0,children:[(0,P.jsx)(se,{}),` `,e.ext]})},e.ext))})]}),(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{margin:`0.5rem 0`},children:[(0,P.jsxs)(s,{variant:`ghost`,onClick:()=>m(e=>!e),disabled:b.isPending,children:[p?(0,P.jsx)(le,{}):(0,P.jsx)(be,{}),` `,p?`View`:`Edit`]}),(0,P.jsxs)(s,{variant:`ghost`,onClick:()=>y.mutate(),disabled:y.isPending||u?.publicationState!==`published`,title:`Create any missing immutable report renditions`,children:[(0,P.jsx)(we,{}),` Ensure renditions`]})]}),p?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`textarea`,{className:`w-full resize-y rounded-lg border bg-[var(--plane)] p-3 font-mono text-[0.85rem] leading-normal`,value:h??f.data??``,onChange:e=>_(e.target.value),rows:24}),(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{marginTop:`0.5rem`},children:[(0,P.jsxs)(s,{onClick:()=>b.mutate(),disabled:b.isPending||!h?.trim(),children:[(0,P.jsx)(Te,{}),` Save as v`,(l.data?.version??0)+1]}),b.isError?(0,P.jsxs)(`span`,{className:`text-destructive text-sm`,children:[`Save failed: `,String(b.error)]}):null]})]}):f.isLoading?(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading markdown…`}):f.isError||d===null?(0,P.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No rendered markdown yet`,d===null?``:` (unavailable)`,` — regenerate to produce it.`]}):(0,P.jsx)(`div`,{className:`max-h-[32rem] overflow-auto rounded-lg border bg-[var(--plane)] p-4`,children:(0,P.jsx)(nj,{children:f.data??``})})]}):null]})]})}function oj(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var sj=[`Reported`,`Confirmed`,`Remediating`,`Resolved`],cj={open:0,unverified:0,confirmed:1,remediating:2,remediated:3,verified:3},lj={false_positive:`Dismissed as a false positive`,accepted_risk:`Accepted as residual risk`,suppressed:`Suppressed`};function uj(e){let t={label:`Confirm as risk`,status:`confirmed`,icon:(0,P.jsx)(Oe,{size:14})},n={label:`Dismiss (false positive)`,status:`false_positive`,icon:(0,P.jsx)(ne,{size:14}),variant:`outline`},r={label:`Start remediation`,status:`remediating`,icon:(0,P.jsx)(ze,{size:14})},i={label:`Mark resolved`,status:`remediated`,icon:(0,P.jsx)(A,{size:14})},a={label:`Verify fix`,status:`verified`,icon:(0,P.jsx)(b,{size:14})},o={label:`Accept risk`,status:`accepted_risk`,icon:(0,P.jsx)(b,{size:14}),variant:`outline`},s={label:`Reopen`,status:`confirmed`,icon:(0,P.jsx)(w,{size:14}),variant:`outline`};switch(e){case`open`:case`unverified`:return[t,n];case`confirmed`:return[r,i,o,n];case`remediating`:return[i,a,o];case`remediated`:return[a,s];case`verified`:return[s];default:return[{...s,label:`Reopen finding`}]}}function dj({findingId:e,onBack:t}){let n=zf(),r=ep({queryKey:[`finding`,e],queryFn:()=>Ib.finding(e)}),i=tp({mutationFn:t=>Ib.updateFindingStatus(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`finding`,e]}),n.invalidateQueries({queryKey:[`findings`]}),n.invalidateQueries({queryKey:[`overview`]})}});if(r.isLoading)return(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading finding…`})});if(r.isError||!r.data)return(0,P.jsx)(g,{children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsx)(`p`,{className:`text-destructive`,children:`Could not load this finding.`}),t?(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:t,children:[(0,P.jsx)(w,{size:14}),` Back`]}):null]})});let a=r.data.finding,o=Gb(a.severity),c=Xb(a.category,a.title),l=Rb(c.stage),u=cj[a.status],d=lj[a.status],f=uj(a.status);return(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`grid gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(px,{variant:fx(o),children:Wb[o]}),(0,P.jsx)(px,{variant:fx(a.status),children:pj(a.status)}),a.cvssScore==null?null:(0,P.jsxs)(px,{variant:`outline`,children:[`CVSS `,a.cvssScore]})]}),(0,P.jsx)(`h1`,{className:`text-xl font-semibold`,children:a.title}),(0,P.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[a.path??`unscoped asset`,a.line==null?``:`:${a.line}`,` · Stage `,c.stage,` `,zb(l),` · Pillar `,Bb[c.pillar],c.inferred?` (inferred)`:``]})]}),t?(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:t,children:[(0,P.jsx)(w,{size:14}),` Back`]}):null]}),(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolution`}),d?(0,P.jsx)(px,{variant:`secondary`,children:d}):null]}),d?(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This finding is off the remediation track. Reopen it to return it to the queue.`}):(0,P.jsx)(`ol`,{className:`mt-1 grid grid-cols-4 gap-2`,"aria-label":`Resolution progress`,children:sj.map((e,t)=>(0,P.jsxs)(`li`,{className:`grid gap-1.5`,children:[(0,P.jsx)(`span`,{className:`h-1.5 rounded-full`,style:{background:u!=null&&t<=u?`var(--good)`:`var(--border)`},"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:u===t?`text-xs font-semibold`:`text-muted-foreground text-xs`,children:e})]},e))})]}),(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Verify & triage`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Move this finding through its lifecycle. Changes are audited.`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,P.jsxs)(s,{size:`sm`,variant:e.variant??`default`,disabled:i.isPending,onClick:()=>i.mutate(e.status),children:[e.icon,` `,e.label]},`${e.label}:${e.status}`))}),i.isError?(0,P.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Update failed: `,String(i.error?.message??i.error)]}):null]}),a.description?(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Description`}),(0,P.jsx)(nj,{children:a.description})]}):null,a.remediation?(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Remediation`}),(0,P.jsx)(nj,{children:a.remediation})]}):null,(0,P.jsxs)(g,{children:[(0,P.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[`Evidence (`,a.evidence.length,`)`]}),a.evidence.length?(0,P.jsx)(`div`,{className:`grid gap-2`,children:a.evidence.map(e=>(0,P.jsx)(lx,{title:`${e.kind}${e.reason?` — ${e.reason}`:``}`,detail:(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[new Date(e.createdAt).toLocaleString(),e.runID?` · run ${e.runID.slice(0,12)}`:``]}),verdict:e.verdict},e.id))}):(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No operation-level evidence linked yet. Source findings stay unverified until evidence confirms them.`})]}),(a.cwe||a.cve||a.cvssVector||a.assignee||a.resolvedAt)&&(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Metadata`}),(0,P.jsxs)(`dl`,{className:`grid gap-1.5 text-sm sm:grid-cols-2`,children:[a.cwe?(0,P.jsx)(fj,{k:`CWE`,v:a.cwe}):null,a.cve?(0,P.jsx)(fj,{k:`CVE`,v:a.cve}):null,a.cvssVector?(0,P.jsx)(fj,{k:`CVSS vector`,v:a.cvssVector,mono:!0}):null,a.assignee?(0,P.jsx)(fj,{k:`Assignee`,v:a.assignee}):null,a.resolvedAt?(0,P.jsx)(fj,{k:`Resolved`,v:new Date(a.resolvedAt).toLocaleString()}):null,(0,P.jsx)(fj,{k:`Fingerprint`,v:a.fingerprint,mono:!0})]})]})]})}function fj({k:e,v:t,mono:n}){return(0,P.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,P.jsx)(`dt`,{className:`text-muted-foreground text-2xs w-28 shrink-0 font-semibold tracking-[0.08em] uppercase`,children:e}),(0,P.jsx)(`dd`,{className:n?`font-mono text-xs break-all`:``,children:t})]})}function pj(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var mj=null;function hj(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=mj;mj=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{mj=n}}function gj(){if(!mj)throw Error(`No resource fiber available`);return mj}function _j(){return mj}var vj=typeof process<`u`&&!1,yj=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),bj=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},xj=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(vj)throw Error(`tap: committed history is shorter than the replay base.`);break}Tj(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;wj(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)Sj(e.changelog[t]);bj(e)}}},Sj=e=>{Tj(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},Cj=(e,t)=>{e.wipCommitCallbacks.push(t)},wj=(e,t)=>{e.rollbackCallbacks.push(t)},Tj=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),wj(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},Ej=Symbol.for(`react.memo_cache_sentinel`),Dj=e=>Array(e).fill(Ej),Oj=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,wj(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=Dj(t),r[i]=a):vj&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},kj=e=>Oj(gj(),e),Aj=N.default.__COMPILER_RUNTIME?.c??(e=>(0,N.useMemo)(()=>{let t=Dj(e);return t[Ej]=!0,t},[])),jj=()=>_j()!==null,J=e=>jj()?kj(e):Aj(e),Mj=(e,...t)=>Object.assign(Object.create(null),e,...t),Nj=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},Pj=()=>{throw Error(`Hook order changed between renders`)},Fj=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function Ij(e,t){let n=gj(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?Fj():i.type===`effect`?i:Pj();if(i===void 0&&(n.isFirstRender||Nj(),n.cells[r]=a,n.effectCells.push(a)),a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);Cj(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var Lj=(e,t)=>{vj&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
89
89
 
90
- Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},Fj=(e,t)=>{bj(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},Ij=(e,t)=>{let n=pj(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||Aj();let a=e();return hj&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&jj();let a=i;if(Pj(a.wipDeps,t))return a.isDirty&&Fj(n,a),a.wip;let o=e();return hj&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,xj(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),Fj(n,a),o};function Lj(e){return Ij(()=>({current:e}),[])}var Rj=Symbol(`tap.Context.defaultValue`),zj=e=>e,Bj=new Map,Vj=new Set,Hj=()=>new Map(Bj),Uj=(e,t)=>{let n=Bj;Bj=e;try{return t()}finally{Bj=n}},Wj=(e,t)=>{e[Rj]=t},Gj=e=>typeof e==`object`&&!!e&&Rj in e,Kj=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),qj=e=>Gj(e)||Kj(e),Jj=e=>{if(!Gj(e)){if(Kj(e)){Wj(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},Yj=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);Jj(e);let r=e,i=pj(),a=Lj(void 0),o=a.current===void 0||!Object.is(a.current.value,t);Nj(()=>{a.current={value:t}},[t]);let s=Bj.get(r),c=s!==void 0||Bj.has(r);Bj.set(r,{value:t,source:i});try{return Xj(r,o,n)}finally{c?Bj.set(r,s):Bj.delete(r)}},Xj=(e,t,n)=>{let r=Vj.has(e);t?Vj.add(e):Vj.delete(e);try{return n()}finally{r?Vj.add(e):Vj.delete(e)}},Zj=e=>{Jj(e);let t=e,n=Qj(t,e),r=pj();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},Qj=(e,t)=>Bj.get(e)??{value:zj(t)[Rj],source:null},$j=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},eM=(e,t=e.wipContextDeps)=>{let n=mj();n&&t&&(n.wipContextDeps=$j(n,e,n.wipContextDeps,t))},tM=()=>Vj.size>0,nM=e=>{if(!e.contextDeps||!tM())return!1;for(let t of Vj.keys())if(e.contextDeps.has(t))return!0;return!1},rM=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,yj(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},iM=(e,t,n,r,i)=>{let a=r?r(n):n;hj&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=mj();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else rM(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function aM(e,t,n,r){let i=pj(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:jj();i.isFirstRender||Aj();let s=iM(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,hj&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):hj&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(Sj(i,s),s.workInProgress=t)}return s.isDirty&&bj(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function oM(e,t,n){return aM(e,t,n,!1)}var sM=(e,t)=>typeof t==`function`?t(e):t,cM=e=>e===void 0?void 0:typeof e==`function`?e():e;function lM(e){return aM(sM,e,cM,!0)}var uM=(e,t)=>Ij(()=>e,t);function dM(e){let t=pj(),n=Lj(e);return n.current!==e&&bj(t,()=>{n.current=e}),uM(((...e)=>{if(hj&&mj())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var fM=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,pM=()=>{},mM=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(pM,pM):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},hM=e=>fM(e)?mM(e):Zj(e),gM=!1,_M=(e,t,n=t)=>{let r=pj().isNeverMounted,i=r?n():t();hj&&!gM&&(!r||n===t)&&(Object.is(i,t())||(gM=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=oM(e=>e+1,0),o=Lj(0),s=dM(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return Nj(()=>e(()=>{s()&&a()}),[e]),Nj(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},vM=(e,t)=>{},yM=0,bM=()=>{let e=Lj(null);return e.current??=`:tap${yM++}:`,e.current},xM=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?Nj(r):Nj(r,[...n,e])},SM=N.default;function CM(e){let t=(0,N.useRef)(e);return(0,N.useInsertionEffect)(()=>{t.current=e}),(0,N.useCallback)(((...e)=>t.current(...e)),[])}var wM=SM.useEffectEvent??CM,TM=()=>mj()!==null,EM=N.default,DM=e=>TM()?lM(e):EM.useState(e),OM=(e,t,n)=>TM()?oM(e,t,n):EM.useReducer(e,t,n),Y=e=>TM()?Lj(e):EM.useRef(e),kM=(e,t)=>TM()?Ij(e,t):EM.useMemo(e,t),AM=(e,t)=>TM()?uM(e,t):EM.useCallback(e,t),X=(e,t)=>TM()?Nj(e,t):EM.useEffect(e,t),jM=(e,t)=>TM()?Nj(e,t):EM.useLayoutEffect(e,t),MM=e=>TM()?dM(e):wM(e),NM=(e,t,n)=>TM()?_M(e,t,n):EM.useSyncExternalStore(e,t,n),PM=(e,t)=>TM()?void 0:EM.useDebugValue(e,t),FM=(e,t)=>TM()?Nj(e,t):EM.useInsertionEffect(e,t),IM=()=>TM()?bM():EM.useId(),LM=(e,t,n)=>TM()?xM(e,t,n):EM.useImperativeHandle(e,t,n),Z=e=>EM.forwardRef(e),RM=(e,t)=>EM.memo(e,t),zM=EM.Fragment,BM=(...e)=>EM.createElement(...e),VM=(...e)=>EM.cloneElement(...e),HM=e=>EM.isValidElement(e);EM.Children,EM.Suspense;var UM=e=>{let t=EM.createContext(e);return Wj(t,e),t},WM=e=>TM()&&qj(e)?hM(e):EM.use(e),GM=e=>TM()&&qj(e)?hM(e):EM.useContext(e);function KM(e){return(...t)=>({hook:e,args:t})}function qM(e,t,n){return typeof t==`function`?(...n)=>qM(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var JM=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},YM=50,XM={schedulers:new Set,isScheduled:!1},ZM=null,QM=[],$M=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(ZM&&(ZM.get(this)??0)>=YM)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,XM.schedulers.add(this),nN()}runTask(){ZM?.set(this,(ZM.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},eN=[];new $M(()=>{let e=eN.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}JM(t,`Errors occurred while running scheduled tasks`)});var tN=e=>{if(ZM!==null){QM.push(e);return}e()},nN=()=>{XM.isScheduled||(XM.isScheduled=!0,iN())},rN=()=>{let e=ZM;ZM=new Map;let t=[];try{for(let e of XM.schedulers)if(XM.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(ZM=e,XM.schedulers.clear(),XM.isScheduled=!1,ZM===null)for(;QM.length>0;)try{QM.shift()()}catch(e){t.push(e)}}JM(t,`Errors occurred during flushSync`)},iN=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),rN()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(rN,0)})(),aN=e=>{if(ZM!==null)return hj&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=XM;XM={schedulers:new Set,isScheduled:!0};try{let t=e();return rN(),t}finally{let e=XM.schedulers;if(XM=t,e.size>0){for(let t of e)XM.schedulers.add(t);nN()}}};function oN(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}JM(t,`Errors during commit`)}function sN(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var cN=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!Pj(e.deps,e.setupDeps);function lN(e){let t=[],n=[];for(let t of e.effectCells)cN(t)&&n.push(t);for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){t.push(e)}finally{e.cleanup=void 0}for(let e of n)try{sN(e)}catch(e){t.push(e)}JM(t,`Errors during commit`)}function uN(e){let t=[];for(let n of e.effectCells)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}JM(t,`Errors during cleanup`)}var dN={useState:lM,useReducer:oM,useRef:Lj,useMemo:Ij,useCallback:uM,useEffect:Nj,useLayoutEffect:Nj,useInsertionEffect:Nj,useEffectEvent:dM,useContext:Zj,use:hM,useSyncExternalStore:_M,useDebugValue:vM,useId:bM,useImperativeHandle:xM,useMemoCache:Ej},fN=N.default,pN=fN.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??fN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,mN=pN==null?null:`H`in pN?{get current(){return pN.H},set current(e){pN.H=e}}:`ReactCurrentDispatcher`in pN?{get current(){return pN.ReactCurrentDispatcher.current},set current(e){pN.ReactCurrentDispatcher.current=e}}:null;function hN(e){if(!mN)return e();let t=mN.current;mN.current=dN;try{return e()}finally{mN.current=t}}function gN(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function _N(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function vN(e){e.isMounted&&(e.isMounted=!1,uN(e))}function yN(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,fj(e,()=>{r=hN(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw _N(e),t}return eM(e),r}function bN(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=hj&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,_j(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),oN(t)),n&&(lN(e),uN(e)),lN(e)}var xN=()=>{let e=pj();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},SN=()=>`child`,CN=()=>null,wN=()=>{if(!hj)return CN;let e=Y(0);return DM(()=>e.current++),e.current===2?SN:CN},TN=()=>mj()?xN:wN(),EN=e=>e(),DN=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}JM(t,`Errors occurred while notifying Tap root subscribers`)},ON=(e,t,n)=>{let r=new $M(()=>s.handleUpdate()),i=[],a=gj((e,t)=>{(i.length!==0||e())&&(i.push(t),r.markDirty())}),o=gN(EN,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{vj(a,a.committedVersion);for(let e of i)hj&&o.devStrictMode&&e(),e();return vj(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,tN(()=>DN(s.subscribers)))},finishFlush:(e,t,n)=>{_j(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&bN(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{hj&&o.devStrictMode&&Uj(s.context,()=>yN(o,[s.committedRender])),t=Uj(s.context,()=>yN(o,[s.committedRender]))}catch(e){if(vj(a,a.committedVersion),fM(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},kN=e=>{let[,t]=DM(0),n=TN(),r=Y(null),i=r.current??=ON(e,n(),t),a=Hj(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=Uj(a,()=>yN(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),X(()=>(i.isMounted=!0,()=>{i.isMounted=!1,vN(i.fiber)}),[i]),X(()=>{if(c.processed){i.fiber.isMounted||(bN(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}bN(i.fiber),i.publish(c.value,c.version)}),kM(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},AN=()=>{let e=Y(0),t=e.current,n=pj();return{version:t,markDirty:kM(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},jN=()=>{let[e]=DM(()=>gj((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=OM((t,n)=>(vj(e,t),t+ +!!n()),0),[,r]=DM(0);return vj(e,t),{root:e,version:t,markDirty:void 0}},MN=()=>{let e=TN(),{root:t,version:n,markDirty:r}=mj()?AN():jN();return{version:n,createFiber:AM((n,i,a)=>gN(n,t,a?()=>{a(),r?.()}:r,e()),[])}},NN=(e,t,n)=>{let r=Y(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,X(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&Pj(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function PN(e){let{version:t,createFiber:n}=MN(),r=kM(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=NN(()=>({value:yN(r,e.args)}),[r,t,e.args],nM(r));return X(()=>()=>vN(r),[r]),X(()=>{bN(r)},[r,i]),i.value}var FN=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},IN=(e,t)=>!e.isDirty&&!nM(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&Pj(e.committedDeps,t),LN=e=>{if(!tM())return!1;for(let{fiber:t}of e.values())if(nM(t))return!0;return!1};function RN(e){let[t]=DM(()=>new Map),{version:n,createFiber:r}=MN(),i=LN(t),a=NN(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>FN(t,c));l={fiber:e,next:{value:yN(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>FN(t,c)),n=yN(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(IN(l,s.deps))typeof l.next==`object`&&_N(l.fiber),l.fiber.contextDeps&&eM(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=yN(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return X(()=>()=>{for(let e of t.keys())vN(t.get(e).fiber)},[t]),X(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(vN(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&bN(n.fiber):(r.remount&&(vN(n.fiber),n.fiber=r.remount),bN(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var zN=e=>e(),BN=e=>{let{createFiber:t}=MN(),n=kM(()=>t(zN,void 0),[t]),r=yN(n,[e]);X(()=>()=>{vN(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,bN(n))};return X(a),{value:r,effects:a}},VN=KM(()=>{let e=J(4),[t,n]=DM(HN),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{let r=kj(n.renderers);return r[e]=[...r[e]??[],t],{...n,renderers:r}}),()=>{n(n=>{let r=kj(n.renderers),i=r[e]?.filter(e=>e!==t)??[];return i.length>0?r[e]=i:delete r[e],{...n,renderers:r}})}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function HN(){return{renderers:kj(),fallbacks:[]}}var UN=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},WN=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n=kj();return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools!==void 0&&Object.hasOwn(e.tools,i)?e.tools[i]:void 0;if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=UN(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=UN({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||=kj(),e.tools[i]=UN(a),Object.hasOwn(n,i)||(n[i]=r)}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...e.unstable_composerMetadata,...t.unstable_composerMetadata}),e},{})},GN=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},KN=e=>e,qN=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),JN=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!qN.has(e))return!1}},YN=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},XN=Symbol(`assistant-ui.store.clientId`),ZN=Symbol(`assistant-ui.store.instanceTag`),QN=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===XN?nP(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===XN||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(typeof n!=`symbol`&&n in t())return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},$N=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===XN)return n();let i=JN(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},eP=e=>e?.source!=null,tP=e=>e?.source===null,nP=e=>e[XN]??e,rP=e=>e[ZN]??nP(e),iP=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,aP=e=>{let t=[];for(let n in e)iP(n)||t.push(n);return t},oP=class extends YN{#e;constructor(e){super(),this.#e=e}get(e,t){let n=JN(t,`OptionalAssistantClient`);if(n!==!1)return n;if(iP(t))return;let r=this.#e[t];return eP(r)?r:void 0}ownKeys(){return aP(this.#e)}has(e,t){return!iP(t)&&t in this.#e}},sP=e=>new Proxy({},new oP(e)),cP=()=>()=>{},lP=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,uP=class extends YN{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return cP;if(t===`optional`)return this.#r??=sP(this.#n());let n=JN(t,this.#e);return n===!1?$N(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},dP=((e,t)=>{let n=new Proxy({},new uP(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>lP),fP=()=>new Proxy({},{get(e,t){let n=JN(t,`AssistantClient`);return n===!1?$N(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),pP=UM(dP),mP=()=>{},hP=new WeakMap,gP=e=>hP.get(e)??mP,_P=(e,t)=>{hP.set(e,t)},vP=()=>GM(pP),yP=(e,t)=>Yj(pP,e,t),bP=Symbol(`assistant-ui.transform-scopes`);function xP(e,t){let n=e;if(n[bP])throw Error(`transformScopes is already attached to this resource`);n[bP]=t}function SP(e){return e[bP]}var CP=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},wP=e=>{console.error(`NotificationManager: event listener error`,e)},TP=(e,t,n)=>{try{let r=e(t,n);r!==null&&(typeof r==`object`||typeof r==`function`)&&typeof r.then==`function`&&Promise.resolve(r).catch(wP)}catch(e){wP(e)}},EP=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.get(n)===a&&e.delete(n)}},emit(n,r,i){(e.has(n)||t.size!==0)&&queueMicrotask(()=>{let a=e.get(n);if(a)for(let e of a)TP(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)TP(n,e,i)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},DP=()=>DM(EP)[0],OP=Symbol(`assistant-ui.store.clientIndex`),kP=e=>e[OP],AP=UM([]),jP=()=>WM(AP),MP=(e,t)=>{let n=J(3),r=jP(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],Yj(AP,i,t)},NP=UM(null),PP=Symbol(`aui.scope-effect-unapplied`),FP=(e,t)=>Yj(NP,e,t),IP=()=>{let e=WM(NP);if(!e)throw Error(`AssistantTapContext is not available`);return e},LP=()=>IP().clientRef,RP=(e,t,n)=>{let r=J(8),{clientRef:i}=IP(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&eP(t)?rP(t):void 0},a=PP,o,s=e=>{if(o?.(),o=void 0,a=PP,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],X(a,o)},zP=()=>{let e=J(3),{emit:t}=IP(),n=jP(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],MM(r)},BP=UM(void 0),VP=(e,t)=>{let n=WM(BP);return Yj(BP,e??n,t)},HP=()=>{let e=J(3),[t]=DM(UP),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>()=>queueMicrotask(()=>t.abort()),r=[t],e[0]=t,e[1]=n,e[2]=r),FM(n,r),t.signal};function UP(){return new AbortController}var WP=Symbol(`assistant-ui.store.getValue`),GP=e=>{let t=e[WP];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},KP=new Map;function qP(e){let t=KP.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[WP];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},KP.set(e,t)),t}var JP=class extends YN{boundFns;cachedReceiver;outputRef;tagRef;index;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===WP)return this.outputRef.current;if(t===OP)return this.index;if(t===ZN)return this.tagRef.current;let r=JN(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=qP(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===WP||t===OP||t===ZN||t in this.outputRef.current}},YP=e=>{let t=Y(null),n=Y(null),r=kM(()=>({}),[e.hook,e.key]),i=jP().length,a=kM(()=>new Proxy({},new JP(t,n,i)),[i]),o=MP(a,function(){return PN(e)});return t.current||(t.current=o,n.current=r),X(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},XP=KM(YP),ZP=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},QP=e=>{let t=kM(()=>({}),[]);return t.v!==void 0&&ZP(t.v,e)?t.v:(t.v=e,e)},$P=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&ZP(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},eF=(()=>{try{return!1}catch{return!1}})(),tF=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=SP(e.hook);if(a){a(n,t),i=!0;break}}}return n},nF=e=>e.hook===TF,rF=e=>{if(!nF(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},iF=Symbol.for(`aui.event-receiver-ref`),aF=(e,t)=>{let n=e===dP?fP():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=sP(r),enumerable:!1}),r},oF=({notifications:e,clientRef:t})=>kM(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=CP(n),o=n[iF];if(i!==`*`&&!o&&tP(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`)return r(e);let a=((o??t).current??this)[i];if(!eP(a))return;let s=nP(a);if(s===n[kP(s)])return r(e)});if(i!==`*`){if(o){if(t.parent===dP)return s}else if(tP(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),sF=e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=rF(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=QP(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],QP(o)},cF=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=t?e:XP(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],PN(r)},lF=KM((e,t)=>{let n=vP(),r=nF(t),i=cF(t,r),a=r?i:i.methods,o=sF(t),s=kM(()=>QN({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),uF=e=>{let t=J(2),n;return t[0]===e?n=t[1]:(n=e.map(bF),t[0]=e,t[1]=n),RN(n)},dF=(e,t)=>{let n=QP(t),r=kM(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},fF=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=aF(e,oF({notifications:r,clientRef:n}));return{client:dF(i,[e,...FP({clientRef:n,emit:r.emit},function(){return yP(i,function(){return uF(t)})})])}},pF=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=BN(function(){let i=DP(),{client:a}=VP(n,function(){return fF({parent:e,entries:t,clientRef:r,notifications:i})});return X(()=>e.subscribe(i.notifySubscribers),[e,i]),X(()=>i.notifySubscribers()),a});return FM(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},mF=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=BN(function(){let i=DP(),a=kN(function(){return VP(n,function(){return fF({parent:e,entries:t,clientRef:r,notifications:i})})}),o=NM(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return X(()=>{let t=()=>aN(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return FM(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},hF=(e,t,n,r)=>{let{get:i}=r.args[0],a=NM(e.subscribe,()=>i(e),()=>i(e)),o=sF(r),s=kM(()=>QN({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},gF=(e,t)=>{if(eF){let[e]=DM(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!nF(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=Y({parent:e,current:null}).current,r=aF(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=CP(t);if(i===`*`)return e.on(t,r);let o=t[iF];if(!o&&tP(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[iF]:o??n},r)}}),i=dF(r,[e,...t.map(([t,n])=>hF(e,r,t,n))]);return FM(()=>{n.parent=e,n.current=i},[i,e,n]),i},_F=(e,t)=>{let n=J(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(tF(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(xF),n[3]=i,n[4]=a);let[o]=DM(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},vF=(e,t,n,r)=>{let{entries:i,rooted:a}=_F(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:gF(e,i)}},yF=(e,t,n)=>vF(e,t,pF,n);function Q(e){let t=vP();if(e){let{client:n,effects:r}=vF(t,e,mF,HP());return r&&_P(n,r),n}return t}function bF(e){let[t,n]=e;return qM(t,lF(t,n))}function xF(e){let[,t]=e;return!nF(t)}var SF=e=>{let t;class n extends YN{get(t,n){let r=JN(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!iP(i)&&eP(e[i]))return GP(e[i]())}ownKeys(){return aP(e)}has(t,n){return!iP(n)&&n in e}}class r extends YN{get(r,i){let a=JN(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!iP(o))return GP(e[o]())}ownKeys(){return[...aP(e),`optional`]}has(t,n){return n===`optional`||!iP(n)&&n in e}}return new Proxy({},new r)},CF=new WeakMap,wF=e=>{let t=CF.get(e);return t||(t=SF(e),CF.set(e,t)),t},$=e=>{let t=J(6),n=Q(),r;t[0]===n?r=t[1]:(r=wF(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=NM(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return PM(s),s},TF=e=>{let t=J(3),{get:n}=e,r=Q(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],$(i)},EF=KM(TF),DF=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function OF(e){let t=J(12),n;t[0]===e?n=t[1]:(n=e.map(jF),t[0]=e,t[1]=n);let r=RN(n),i;t[2]===e?i=t[3]:(i=e.reduce(AF,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(kF),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function kF(e){return e.state}function AF(e,t,n){return e[DF(t)]=n,e}function jF(e){return qM(DF(e),XP(e),e.deps)}var MF=(e,t=0)=>t===0?Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight:e.scrollHeight-t-e.scrollTop-e.clientHeight<=1||e.scrollHeight-t<=e.clientHeight,NF=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,PF=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,FF=Symbol(`skip-update`),IF=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}},LF=e=>{IF(e)},RF=(e,t)=>e===void 0||t===void 0?e===t:ZP(e,t),zF=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){IF(this._subscribers)}},BF=class extends zF{_state;constructor(e){super(),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}getServerSnapshot;setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},VF=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){GN(this._subscriptions,e,t);return}IF(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{let e=this._connection;this._connection=void 0,e?.()}}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},HF=class extends VF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===FF)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===FF||RF(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},UF=class extends VF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==FF&&(this._previousState===void 0||!RF(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},WF=class extends VF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();if(r===t)return;t=r;let i=n;n=void 0;try{i?.()}finally{n=r?.subscribe(e),e()}});return()=>LF([()=>r?.(),()=>n?.()])}},GF=class extends VF{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=this.outerSubscribe(()=>{let e=this.config.binding.getState();if(e===n)return;n=e;let i=r;r=void 0;try{i?.()}finally{r=e?.unstable_on(this.config.event,t)}});return()=>LF([()=>i?.(),()=>r?.()])}},KF=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return WN(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}this._providerUnsubscribes.set(t,n),this.notifySubscribers();let r=!1;return()=>{if(r)return;r=!0,this._providers.delete(t);let e=this._providerUnsubscribes.get(t);this._providerUnsubscribes.delete(t);let n=!1,i,a=e=>{try{e()}catch(e){n?console.error(e):(n=!0,i=e)}};if(e&&a(e),a(()=>this.notifySubscribers()),n)throw i}}_subscribers=new Set;notifySubscribers(){IF(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},qF=[],JF={modelName:void 0,toolNames:qF},YF=(e,t)=>e===t||ZP(e,t),XF=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():qF,a=i.length?i:qF;return r===t.modelName&&YF(a,t.toolNames)?t:{modelName:r,toolNames:a}},ZF=KM(()=>{let e=J(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new KF,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>XF(n,JF),e[1]=r):r=e[1];let[i,a]=DM(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>XF(n,e)),n.subscribe(()=>{a(e=>XF(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),X(o,s);let c;e[4]===i?c=e[5]:(c=()=>XF(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),QF=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},$F=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,eI=e=>function(t){return QF(e,t)},tI=e=>{let t=J(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[qM(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=RN(i)[0],[o,s]=DM(rI),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=LP(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,renderText:n?.renderText,standalone:n?.standalone??!1};return s(t=>{let n=kj(t);return n[e]=[...n[e]??[],r],n}),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[],i=kj(t);return n.length>0?(i[e]=n,i):(delete i[e],i)})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?eI(i):void 0);a&&e.push(f(t,a,{standalone:$F(r),renderText:i}))}return()=>{e.forEach(iI)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),X(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(aI,kj());return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),RP(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},nI=KM(tI);xP(tI,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=ZF())});function rI(){return kj()}function iI(e){return e()}function aI(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var oI=e=>NM(e.subscribe,e.getState,e.getServerSnapshot),sI=Symbol.for(`assistant-ui.silent-runtime-action`),cI=e=>typeof e==`object`&&!!e&&sI in e,lI=(e,t)=>{let n=t();return n.catch(t=>{cI(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},uI=KM(e=>{let t=J(9),{runtime:n}=e,r=oI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>lI(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),dI=KM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=uI({runtime:a}),t[3]=a,t[4]=o),PN(o)}),fI=KM(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),pI=KM(e=>{let t=J(63),{threadIdRef:n,messageIdRef:r,runtime:i,isSuggestion:a}=e,o=oI(i),s=zP(),c=Y(!1),l,u;t[0]!==s||t[1]!==r||t[2]!==i||t[3]!==n?(l=()=>{let e=[],t=i.unstable_on(`send`,e=>{let t=c.current;c.current=!1,s(`composer.send`,{threadId:n.current,...r&&{messageId:r.current},chars:e.chars,attachments:e.attachments,...t?{suggestion:!0}:void 0})});e.push(t);let a=i.unstable_on(`attachmentAdd`,e=>{s(`composer.attachmentAdd`,{threadId:n.current,...r&&{messageId:r.current},...e.contentType?{contentType:e.contentType}:void 0})});return e.push(a),e.push(i.unstable_on(`attachmentAddError`,e=>{s(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message,...e.contentType?{contentType:e.contentType}:void 0})})),()=>{for(let t of e)t()}},u=[i,s,n,r],t[0]=s,t[1]=r,t[2]=i,t[3]=n,t[4]=l,t[5]=u):(l=t[4],u=t[5]),X(l,u);let d;if(t[6]!==i||t[7]!==o.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>qM(e.id,dI({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),d=o.attachments.map(e),t[6]=i,t[7]=o.attachments,t[8]=d}else d=t[8];let f=OF(d),p=o.queue,m;if(t[11]!==p||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>qM(e.id,fI({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),m=p.map(e),t[11]=p,t[12]=i,t[13]=m}else m=t[13];let h=OF(m),g=o.type??`thread`,_;t[16]!==f.state||t[17]!==p||t[18]!==o.attachmentAccept||t[19]!==o.canCancel||t[20]!==o.canSend||t[21]!==o.dictation||t[22]!==o.isEditing||t[23]!==o.isEmpty||t[24]!==o.quote||t[25]!==o.role||t[26]!==o.runConfig||t[27]!==o.text||t[28]!==g?(_={text:o.text,role:o.role,attachments:f.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:g,dictation:o.dictation,quote:o.quote,queue:p},t[16]=f.state,t[17]=p,t[18]=o.attachmentAccept,t[19]=o.canCancel,t[20]=o.canSend,t[21]=o.dictation,t[22]=o.isEditing,t[23]=o.isEmpty,t[24]=o.quote,t[25]=o.role,t[26]=o.runConfig,t[27]=o.text,t[28]=g,t[29]=_):_=t[29];let v=_,y;t[30]===v?y=t[31]:(y=()=>v,t[30]=v,t[31]=y);let b;t[32]!==a||t[33]!==i?(b=e=>{let t=i.getState();c.current=t.canSend&&(a?.(t.text)??!1),i.send(e)},t[32]=a,t[33]=i,t[34]=b):b=t[34];let x;t[35]!==s||t[36]!==r||t[37]!==i||t[38]!==n?(x=()=>{!r&&i.getState().canCancel&&s(`composer.cancel`,{threadId:n.current}),i.cancel()},t[35]=s,t[36]=r,t[37]=i,t[38]=n,t[39]=x):x=t[39];let S=i.beginEdit??mI,C;t[40]===f?C=t[41]:(C=e=>`id`in e?f.get({key:e.id}):f.get(e),t[40]=f,t[41]=C);let w;t[42]===h?w=t[43]:(w=e=>`id`in e?h.get({key:e.id}):h.get(e),t[42]=h,t[43]=w);let T;t[44]===i?T=t[45]:(T=()=>i,t[44]=i,t[45]=T);let E;return t[46]!==i.addAttachment||t[47]!==i.clearAttachments||t[48]!==i.reset||t[49]!==i.setQuote||t[50]!==i.setRole||t[51]!==i.setRunConfig||t[52]!==i.setText||t[53]!==i.startDictation||t[54]!==i.stopDictation||t[55]!==S||t[56]!==C||t[57]!==w||t[58]!==T||t[59]!==y||t[60]!==b||t[61]!==x?(E={getState:y,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:b,cancel:x,beginEdit:S,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:C,queueItem:w,__internal_getRuntime:T},t[46]=i.addAttachment,t[47]=i.clearAttachments,t[48]=i.reset,t[49]=i.setQuote,t[50]=i.setRole,t[51]=i.setRunConfig,t[52]=i.setText,t[53]=i.startDictation,t[54]=i.stopDictation,t[55]=S,t[56]=C,t[57]=w,t[58]=T,t[59]=y,t[60]=b,t[61]=x,t[62]=E):E=t[62],E});function mI(){throw Error(`beginEdit is not supported in this runtime`)}var hI=e=>({get current(){return e()}}),gI=KM(e=>{let t=J(13),{runtime:n}=e,r=oI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),_I=KM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=uI({runtime:a}),t[3]=a,t[4]=o),PN(o)}),vI=KM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=gI({runtime:a}),t[3]=a,t[4]=o),PN(o)}),yI=KM(e=>{let t=J(74),{runtime:n,threadIdRef:r,threadId:i}=e,a=oI(n),o=zP(),[s,c]=DM(!1),[l,u]=DM(!1),d;t[0]===n?d=t[1]:(d=hI(()=>n.getState().id),t[0]=n,t[1]=d);let f=d,p=Y(a.status),m;t[2]!==o||t[3]!==n||t[4]!==i?(m=e=>{o(e,{threadId:i,messageId:n.getState().id})},t[2]=o,t[3]=n,t[4]=i,t[5]=m):m=t[5];let h=m,g,_;t[6]!==o||t[7]!==a.id||t[8]!==a.status||t[9]!==i?(g=()=>{let e=a.status,t=p.current;p.current=e,e?.type===`incomplete`&&e.reason===`error`&&(t?.type!==`incomplete`||t.reason!==`error`)&&o(`message.error`,{threadId:i,messageId:a.id,reason:`error`})},_=[a.status,a.id,o,i],t[6]=o,t[7]=a.id,t[8]=a.status,t[9]=i,t[10]=g,t[11]=_):(g=t[10],_=t[11]),X(g,_);let v;t[12]!==f||t[13]!==n.composer||t[14]!==r?(v=pI({runtime:n.composer,threadIdRef:r,messageIdRef:f}),t[12]=f,t[13]=n.composer,t[14]=r,t[15]=v):v=t[15];let y=YP(v),b;if(t[16]!==n||t[17]!==a.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>qM(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,vI({runtime:n,index:t}),[n,t]),t[19]=n,t[20]=e),b=a.content.map(e),t[16]=n,t[17]=a.content,t[18]=b}else b=t[18];let x=OF(b),S;t[21]===a.attachments?S=t[22]:(S=a.attachments??[],t[21]=a.attachments,t[22]=S);let C;if(t[23]!==n||t[24]!==S){let e;t[26]===n?e=t[27]:(e=(e,t)=>qM(e.id,_I({runtime:n,index:t}),[n,t]),t[26]=n,t[27]=e),C=S.map(e),t[23]=n,t[24]=S,t[25]=C}else C=t[25];let w=OF(C),T=a,E;t[28]!==y.state||t[29]!==s||t[30]!==l||t[31]!==x.state||t[32]!==T?(E={...T,parts:x.state,composer:y.state,isCopied:s,isHovering:l},t[28]=y.state,t[29]=s,t[30]=l,t[31]=x.state,t[32]=T,t[33]=E):E=t[33];let D=E,O;t[34]===D?O=t[35]:(O=()=>D,t[34]=D,t[35]=O);let k;t[36]===y.methods?k=t[37]:(k=()=>y.methods,t[36]=y.methods,t[37]=k);let A;t[38]===n?A=t[39]:(A=()=>n.delete(),t[38]=n,t[39]=A);let j,M;t[40]!==h||t[41]!==n?(j=e=>(h(`message.reload`),n.reload(e)),M=()=>(h(`message.speak`),n.speak()),t[40]=h,t[41]=n,t[42]=j,t[43]=M):(j=t[42],M=t[43]);let ee,te;t[44]===n?(ee=t[45],te=t[46]):(ee=()=>n.stopSpeaking(),te=e=>n.submitFeedback(e),t[44]=n,t[45]=ee,t[46]=te);let ne;t[47]!==h||t[48]!==n?(ne=e=>(h(`message.branchSwitched`),n.switchToBranch(e)),t[47]=h,t[48]=n,t[49]=ne):ne=t[49];let re;t[50]===n?re=t[51]:(re=()=>n.unstable_getCopyText(),t[50]=n,t[51]=re);let ie;t[52]===x?ie=t[53]:(ie=e=>`index`in e?x.get({index:e.index}):x.get({key:`toolCallId-${e.toolCallId}`}),t[52]=x,t[53]=ie);let ae;t[54]===w?ae=t[55]:(ae=e=>`id`in e?w.get({key:e.id}):w.get(e),t[54]=w,t[55]=ae);let oe;t[56]===h?oe=t[57]:(oe=e=>{e&&h(`message.copied`),c(e)},t[56]=h,t[57]=oe);let se;t[58]===n?se=t[59]:(se=()=>n,t[58]=n,t[59]=se);let ce;return t[60]!==O||t[61]!==k||t[62]!==A||t[63]!==j||t[64]!==M||t[65]!==ee||t[66]!==te||t[67]!==ne||t[68]!==re||t[69]!==ie||t[70]!==ae||t[71]!==oe||t[72]!==se?(ce={getState:O,composer:k,delete:A,reload:j,speak:M,stopSpeaking:ee,submitFeedback:te,switchToBranch:ne,getCopyText:re,part:ie,attachment:ae,setIsCopied:oe,setIsHovering:u,__internal_getRuntime:se},t[60]=O,t[61]=k,t[62]=A,t[63]=j,t[64]=M,t[65]=ee,t[66]=te,t[67]=ne,t[68]=re,t[69]=ie,t[70]=ae,t[71]=oe,t[72]=se,t[73]=ce):ce=t[73],ce}),bI=e=>{let t=kM(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n?.suggestions[r.length];r.push(t&&ZP(t,e)?t:e)});let i=n&&ZP(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},xI=KM(e=>({getState:()=>e})),SI=e=>{let t=J(9),n=bI(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(wI),t[0]=n.suggestions,t[1]=r);let i=OF(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},CI=KM(e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e.map(TI),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),SI(r)});function wI(e,t){return qM(t,xI(e),[e])}function TI(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var EI=Object.freeze({type:`complete`}),DI=Object.freeze({type:`running`}),OI=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),kI=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return DI;if(n===`complete`)return EI;if(n!==`incomplete`)return;let{reason:r}=t;return OI[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},AI=(e,t,n)=>{if(e.role!==`assistant`)return EI;if(n.type===`tool-call`)return n.result===void 0?e.status:EI;if(e.status.type===`running`){let e=kI(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?EI:r?e.status:EI},jI=e=>`reason`in e?e.reason:void 0,MI=e=>`error`in e?e.error:void 0,NI=32,PI=new WeakMap,FI=e=>PI.get(e)??e.id,II=(e,t,n)=>`status`in e&&e.status?AI(e,t,n):EI,LI=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>NI))for(let[l,u]of e.entries())for(let[e,d]of u.content.entries()){if(d.type!==`tool-call`||d.messages===void 0)continue;let f=d.messages,p=II(u,e,d),m=jI(p),h=MI(p),g=`${c}${l}.${e}`,_=t.get(g),v=_?.part===d&&_.statusType===p.type&&_.statusReason===m&&Object.is(_.statusError,h)&&_.messages===f&&_.task.messageId===u.id&&_.task.parentTaskId===n&&_.task.depth===s?_.task:{id:d.toolCallId,toolName:d.toolName,args:d.args,result:d.result,...d.isError===void 0?void 0:{isError:d.isError},status:p,timing:d.timing,messageId:u.id,parentTaskId:n,depth:s,messages:f};v!==_?.task&&(a=!1,PI.set(v,g)),r.push(v),i.set(g,{task:v,part:d,statusType:p.type,statusReason:m,statusError:h,messages:f}),o(f,v.id,s+1,`${g}.`)}};o(n,null,0,``);let s=a&&r.length===e.length&&r.every((t,n)=>t===e[n])?e:r;return e=s,t=i,s}},RI=KM(({task:e})=>({getState:()=>e})),zI=KM(e=>{let t=J(7),{runtime:n,id:r,threadIdRef:i,threadId:a}=e,o;t[0]!==r||t[1]!==n?(o=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==s||t[4]!==a||t[5]!==i?(c=yI({runtime:s,threadIdRef:i,threadId:a}),t[3]=s,t[4]=a,t[5]=i,t[6]=c):c=t[6],PN(c)}),BI=KM(e=>{let t=J(93),{runtime:n}=e,r=oI(n),i=zP(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return e.push(n.unstable_on(`toolApprovalAnswered`,e=>{let t=n.getState()?.threadId||`unknown`;i(`thread.toolApprovalAnswered`,{threadId:t,...e})})),()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),X(a,o);let s;t[4]===n?s=t[5]:(s=hI(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==i||t[7]!==n?(l=e=>{i(e,{threadId:n.getState().threadId})},t[6]=i,t[7]=n,t[8]=l):l=t[8];let u=l,d;t[9]===n?d=t[10]:(d=e=>n.getState().suggestions.some(t=>t.prompt===e),t[9]=n,t[10]=d);let f=d,p;t[11]!==f||t[12]!==n.composer||t[13]!==c?(p=pI({runtime:n.composer,threadIdRef:c,isSuggestion:f}),t[11]=f,t[12]=n.composer,t[13]=c,t[14]=p):p=t[14];let m=YP(p),h;t[15]===r.suggestions?h=t[16]:(h=CI(r.suggestions),t[15]=r.suggestions,t[16]=h);let g=YP(h),_;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=LI(),t[17]=_):_=t[17];let v=_,y;t[18]===r.messages?y=t[19]:(y=v(r.messages),t[18]=r.messages,t[19]=y);let b=y,x;t[20]===b?x=t[21]:(x=b.map(VI),t[20]=b,t[21]=x);let S=OF(x),C;if(t[22]!==n||t[23]!==r.messages||t[24]!==r.threadId||t[25]!==c){let e;t[27]!==n||t[28]!==r.threadId||t[29]!==c?(e=e=>qM(e.id,zI({runtime:n,id:e.id,threadIdRef:c,threadId:r.threadId}),[n,e.id,c,r.threadId]),t[27]=n,t[28]=r.threadId,t[29]=c,t[30]=e):e=t[30],C=r.messages.map(e),t[22]=n,t[23]=r.messages,t[24]=r.threadId,t[25]=c,t[26]=C}else C=t[26];let w=OF(C),T=w.state.length===0&&!r.isLoading,E;t[31]!==m.state||t[32]!==w.state||t[33]!==r.capabilities||t[34]!==r.extras||t[35]!==r.isDisabled||t[36]!==r.isLoading||t[37]!==r.isRunning||t[38]!==r.speech||t[39]!==r.state||t[40]!==r.suggestions||t[41]!==r.voice||t[42]!==T||t[43]!==b?(E={isEmpty:T,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:m.state,messages:w.state,tasks:b},t[31]=m.state,t[32]=w.state,t[33]=r.capabilities,t[34]=r.extras,t[35]=r.isDisabled,t[36]=r.isLoading,t[37]=r.isRunning,t[38]=r.speech,t[39]=r.state,t[40]=r.suggestions,t[41]=r.voice,t[42]=T,t[43]=b,t[44]=E):E=t[44];let D=E,O;t[45]===D?O=t[46]:(O=()=>D,t[45]=D,t[46]=O);let k;t[47]===m.methods?k=t[48]:(k=()=>m.methods,t[47]=m.methods,t[48]=k);let A;t[49]===g?A=t[50]:(A=()=>g.methods,t[49]=g,t[50]=A);let j;t[51]!==S||t[52]!==b?(j=e=>{if(`id`in e){let t=b.find(t=>t.id===e.id);return S.get({key:t?FI(t):e.id})}return S.get(e)},t[51]=S,t[52]=b,t[53]=j):j=t[53];let M;t[54]!==i||t[55]!==f||t[56]!==n?(M=e=>{let t=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if((t.role??`user`)===`user`){let e=t.content.map(HI).join(``);i(`composer.send`,{threadId:n.getState().threadId,chars:e.length,attachments:t.attachments?.length??0,...f(e)?{suggestion:!0}:void 0})}n.append(e)},t[54]=i,t[55]=f,t[56]=n,t[57]=M):M=t[57];let ee;t[58]!==u||t[59]!==n||t[60]!==r.isRunning?(ee=()=>{r.isRunning&&u(`thread.cancelRun`),n.cancelRun()},t[58]=u,t[59]=n,t[60]=r.isRunning,t[61]=ee):ee=t[61];let te;t[62]!==u||t[63]!==n?(te=()=>{n.connectVoice(),u(`thread.voiceStarted`)},t[62]=u,t[63]=n,t[64]=te):te=t[64];let ne;t[65]===w?ne=t[66]:(ne=e=>`id`in e?w.get({key:e.id}):w.get(e),t[65]=w,t[66]=ne);let re;t[67]===n?re=t[68]:(re=()=>n,t[67]=n,t[68]=re);let ie;return t[69]!==n.deleteMessage||t[70]!==n.disconnectVoice||t[71]!==n.export||t[72]!==n.getModelContext||t[73]!==n.getVoiceVolume||t[74]!==n.import||t[75]!==n.importExternalState||t[76]!==n.muteVoice||t[77]!==n.reset||t[78]!==n.resumeRun||t[79]!==n.startRun||t[80]!==n.stopSpeaking||t[81]!==n.subscribeVoiceVolume||t[82]!==n.unmuteVoice||t[83]!==O||t[84]!==k||t[85]!==A||t[86]!==j||t[87]!==M||t[88]!==ee||t[89]!==te||t[90]!==ne||t[91]!==re?(ie={getState:O,composer:k,suggestions:A,task:j,append:M,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:ee,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:te,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:ne,__internal_getRuntime:re},t[69]=n.deleteMessage,t[70]=n.disconnectVoice,t[71]=n.export,t[72]=n.getModelContext,t[73]=n.getVoiceVolume,t[74]=n.import,t[75]=n.importExternalState,t[76]=n.muteVoice,t[77]=n.reset,t[78]=n.resumeRun,t[79]=n.startRun,t[80]=n.stopSpeaking,t[81]=n.subscribeVoiceVolume,t[82]=n.unmuteVoice,t[83]=O,t[84]=k,t[85]=A,t[86]=j,t[87]=M,t[88]=ee,t[89]=te,t[90]=ne,t[91]=re,t[92]=ie):ie=t[92],ie});function VI(e){return qM(FI(e),RI({task:e}),[e])}function HI(e){return e.type===`text`?e.text:``}var UI=(e,t)=>lI(`thread list ${e}`,t),WI=KM(e=>{let t=J(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=oI(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o,c=zP(),{isMain:l,id:u}=a,d;t[3]!==l||t[4]!==u?(d={isMain:l,threadId:u},t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=Y(d),p,m;t[6]!==c||t[7]!==l||t[8]!==u?(p=()=>{let e=f.current;(e.isMain!==l||e.threadId!==u)&&(f.current={isMain:l,threadId:u},c(l?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:u}))},m=[l,u,c],t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=m):(p=t[9],m=t[10]),X(p,m);let h;t[11]===s?h=t[12]:(h=()=>s,t[11]=s,t[12]=h);let g,_,v,y,b,x,S;t[13]===n?(g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20]):(b=e=>UI(`switch`,()=>n.switchTo(e)),x=e=>UI(`rename`,()=>n.rename(e)),S=e=>UI(`update custom metadata`,()=>n.updateCustom(e)),g=()=>UI(`archive`,()=>n.archive()),_=()=>UI(`unarchive`,()=>n.unarchive()),v=()=>UI(`delete`,()=>n.delete()),y=e=>UI(`generate title`,()=>n.generateTitle(e)),t[13]=n,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S);let C;t[21]===n?C=t[22]:(C=()=>n,t[21]=n,t[22]=C);let w;return t[23]!==n.detach||t[24]!==n.initialize||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==y||t[29]!==C||t[30]!==h||t[31]!==b||t[32]!==x||t[33]!==S?(w={getState:h,switchTo:b,rename:x,updateCustom:S,archive:g,unarchive:_,delete:v,generateTitle:y,initialize:n.initialize,detach:n.detach,__internal_getRuntime:C},t[23]=n.detach,t[24]=n.initialize,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=C,t[30]=h,t[31]=b,t[32]=x,t[33]=S,t[34]=w):w=t[34],w}),GI=e=>{let t=J(4),n=zP(),r=Y(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)},KI=KM(e=>{let t=J(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=WI({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],PN(s)}),qI=KM(e=>{let t=J(48),{runtime:n,__internal_assistantRuntime:r}=e,i=oI(n);GI(i.mainThreadId);let a=zP(),o,s;t[0]!==a||t[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:r}=e;t!==n.getState().mainThreadId&&a(`thread.${r}`,{threadId:t})}),s=[n,a],t[0]=a,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),X(o,s);let c;t[4]===n.main?c=t[5]:(c=BI({runtime:n.main}),t[4]=n.main,t[5]=c);let l=YP(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>qM(e,KI({runtime:n,id:e,mainThreadIsRunning:l.state.isRunning}),[n,e,l.state.isRunning])),t[6]=l.state,t[7]=n,t[8]=i.threadItems,t[9]=u):u=t[9];let d=OF(u),f=i.newThreadId??null,p;t[10]!==l.state||t[11]!==i.archivedThreadIds||t[12]!==i.hasMore||t[13]!==i.isLoading||t[14]!==i.isLoadingMore||t[15]!==i.loadError||t[16]!==i.mainThreadId||t[17]!==i.threadIds||t[18]!==f||t[19]!==d.state?(p={mainThreadId:i.mainThreadId,newThreadId:f,isLoading:i.isLoading,loadError:i.loadError,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:d.state,main:l.state},t[10]=l.state,t[11]=i.archivedThreadIds,t[12]=i.hasMore,t[13]=i.isLoading,t[14]=i.isLoadingMore,t[15]=i.loadError,t[16]=i.mainThreadId,t[17]=i.threadIds,t[18]=f,t[19]=d.state,t[20]=p):p=t[20];let m=p,h;t[21]===m?h=t[22]:(h=()=>m,t[21]=m,t[22]=h);let g;t[23]===l.methods?g=t[24]:(g=()=>l.methods,t[23]=l.methods,t[24]=g);let _;t[25]!==m||t[26]!==d?(_=e=>{if(e===`main`)return d.get({key:m.mainThreadId});if(`id`in e)return d.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?m.archivedThreadIds[t]:m.threadIds[t];return d.get({key:r})},t[25]=m,t[26]=d,t[27]=_):_=t[27];let v,y,b,x,S,C;t[28]===n?(v=t[29],y=t[30],b=t[31],x=t[32],S=t[33],C=t[34]):(v=(e,t)=>UI(`switch`,()=>n.switchToThread(e,t)),y=()=>UI(`create`,()=>n.switchToNewThread()),b=()=>n.getLoadThreadsPromise(),x=()=>n.reload(),S=()=>n.reloadMainThread(),C=()=>n.loadMore(),t[28]=n,t[29]=v,t[30]=y,t[31]=b,t[32]=x,t[33]=S,t[34]=C);let w;t[35]===r?w=t[36]:(w=()=>r,t[35]=r,t[36]=w);let T;return t[37]!==v||t[38]!==y||t[39]!==b||t[40]!==x||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==h||t[45]!==g||t[46]!==_?(T={getState:h,thread:g,item:_,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:b,reload:x,reloadMainThread:S,loadMore:C,__internal_getAssistantRuntime:w},t[37]=v,t[38]=y,t[39]=b,t[40]=x,t[41]=S,t[42]=C,t[43]=w,t[44]=h,t[45]=g,t[46]=_,t[47]=T):T=t[47],T}),JI=(e,t)=>{e.thread??=EF({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=EF({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=EF({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=ZF()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=EF({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},YI=e=>{let t=J(7),n=LP(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),RP(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=qI({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),PN(a)},XI=KM(YI);xP(YI,(e,t)=>{JI(e,t),!e.tools&&t.tools.source===null&&(e.tools=nI({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=VN())});var ZI=e=>{let{children:t,condition:n}=e;return $(n)?t:null};ZI.displayName=`AuiIf`;var QI=KN({}),$I=({effects:e})=>{"use no memo";return jM(e),null},eL=Z(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=vP();if(eF){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==dP)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??dP:a?e.value??dP:o,c=HP(),{client:l,effects:u}=yF(s,n??QI,c);return LM(t,()=>l,[l]),(0,P.jsx)(BP.Provider,{value:c,children:(0,P.jsxs)(pP.Provider,{value:l,children:[(0,P.jsx)($I,{effects:gP(s)}),u&&(0,P.jsx)($I,{effects:u}),r]})})}),tL=e=>{let t=Q(),n=Y(!1),r=n.current?null:e(t);return $(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},nL=Object.freeze({});function rL(e){let t=J(3),{getItemState:n,children:r}=e,i=tL(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],iL(a)}var iL=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return kM(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?nL:t?.props])??e},aL=(e,t)=>{let n=J(11),r=Q(),i=MM(t),a;n[0]===e?a=n[1]:(a=CP(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],X(c,l)},oL=e=>e._core?.RenderComponent,sL=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=oL(e),a=KN({...n,threads:XI(e)});return(0,P.jsxs)(eL,{extends:t,config:a,children:[i&&(0,P.jsx)(i,{}),r]})},cL=RM(e=>{let t=J(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,P.jsx)(sL,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s});function lL(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function uL(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>uL(e,t+1)):lL(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&uL(n,t+1)):!1}var dL=100,fL=(e,t,n)=>{if(e===t)return!0;if(n>dL||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>fL(e,t[r],n+1));if(Array.isArray(t)||!lL(e)||!lL(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&fL(e[r],t[r],n+1))},pL=(e,t)=>!uL(e)||!uL(t)?!1:fL(e,t,0);function mL(e){let t=Y(e);return t.current!==e&&!pL(t.current,e)&&(t.current=e),t.current}function hL(e){let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&pL(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r}var gL=Symbol.for(`aui.tool-response`),_L=`<no result>`,vL=class e{get[gL](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?_L:t,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&gL in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?_L:t})}},yL=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},bL=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o=0,s,c,l=()=>(a=void 0,c??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),c),u=e=>{n||r||(r=!0,console.error(e),l(),i.error(e),s?.reject(e),s=void 0)},d=a=>{a.promise||=a.reader.read().then(({done:c,value:l})=>{a.promise=void 0,!(n||r)&&(c?(e.splice(e.indexOf(a),1),a.reader.releaseLock(),t&&e.length===0&&o===0&&i.close()):i.enqueue(l),s?.resolve(),s=void 0)}).catch(u)},f=new ReadableStream({start(e){i=e},pull(){return s=yL(),e.forEach(e=>{d(e)}),s.promise},async cancel(){n=!0;let e=l();s?.resolve(),s=void 0,await e}}),p=c=>{if(e.length>0&&(a=void 0),!a){let c=[];a=c,o++,Promise.resolve().then(()=>{if(o--,a===c&&(a=void 0),!(n||r)){for(let e of c)i.enqueue(e);t&&e.length===0&&o===0&&i.close(),s?.resolve(),s=void 0}}).catch(u)}a.push(c)};return{readable:f,isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&o===0&&i.close())},addStream:(i,o)=>{let s=o?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);a=void 0;let c={reader:i.getReader(),pipeTask:s};e.push(c),d(c)},enqueue(e){if(!(n||r)){if(t)throw Error(`Cannot add streams after the run callback has settled.`);p(e)}}}},xL=e=>e instanceof TypeError,SL=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!xL(e))throw e;n?.(e)}},CL=e=>{try{e.close()}catch(e){if(!xL(e))throw e}},wL=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),TL=(e,t)=>{let n;return[wL({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},EL=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};if(this._isClosed){if(this._strict)throw TypeError(`Cannot append to a closed TextStreamController`);return SL(this._controller,t,this._warnDroppedAfterClose),this}return SL(this._controller,t),this}_warnDroppedAfterClose=e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))};close(){this._isClosed||(this._isClosed=!0,SL(this._controller,{type:`part-finish`,path:[]}),CL(this._controller))}},DL=(e,t={})=>wL(e,e=>new EL(e,t)),OL=(e={})=>TL(t=>new EL(t,e)),kL=class{_isClosed=!1;_mergeTask;_controller;constructor(e,t={}){this._controller=e;let n=DL({start:e=>{this._argsTextController=e}},t),r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:r=!0,SL(this._controller,e);break;case`part-finish`:r||SL(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),SL(this._controller,{type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;SL(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?_L:t,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,SL(this._controller,{type:`part-finish`,path:[]}),CL(this._controller))}},AL=(e={})=>TL(t=>new kL(t,e)),jL=class{value=-1;up(){return++this.value}},ML=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var NL=class extends TransformStream{constructor(e){let t=new jL,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},PL=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},FL=PL(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),IL=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:bL(),contentCounter:new jL}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new ML(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new NL(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=OL({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=OL({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??FL(),[i,a]=AL({strict:this._state.strict});return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function LL(e,t={}){let n=new IL(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function RL(e={}){let{resolve:t,promise:n}=yL(),r;return[LL(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var zL=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},BL=r(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),VL=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},HL=/[0-9a-fA-F]/;function UL(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!HL.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`+`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var WL=n(BL(),1),GL=Symbol(`aui.parse-partial-json-object.meta`),KL=e=>e?.[GL],qL=e=>{if(e.length===0)return{[GL]:{state:`partial`,partialPath:[]}};try{let t=WL.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[GL]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=UL(e),r=WL.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[GL]={state:`partial`,partialPath:n},r}catch{return}}},JL=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return JL(s,{state:`partial`,partialPath:o},i)},YL=(e,t)=>{let n=KL(e);if(!n)throw Error(`unable to determine object state`);return JL(e,n,t.map(String))},XL=new Set([`__proto__`,`constructor`,`prototype`]);function ZL(e){if(XL.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var QL=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);let r=[],i=e;for(let e=0;e<t.length;e++){if(i??={},typeof i!=`object`)throw Error(`Invalid path: [${t.slice(e).join(`, `)}]`);let n=t[e];if(ZL(n),Array.isArray(i)){let a=Number(n);if(!Number.isInteger(a)||String(a)!==String(n))throw Error(`Expected array index at [${t.slice(e).join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>i.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${i.length}`)),a=i.length}r.push({kind:`array`,state:i,key:a}),i=Object.hasOwn(i,a)?i[a]:void 0}else{let e=i;r.push({kind:`object`,state:e,key:n}),i=Object.hasOwn(e,n)?e[n]:void 0}}let a=n(i);for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.kind===`array`){let e=[...t.state];e[t.key]=a,a=e}else{let e={...t.state};e[t.key]=a,a=e}}return a}},$L=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},eR=(e,t)=>({...e,parts:t,get content(){return this.parts}}),tR=(e,t)=>eR(e,[...e.parts,t]),nR=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),rR=16,iR=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:eR(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},aR=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return tR(e,{type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`tool-call`)return tR(e,{type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}});if(r.type===`source`)return tR(e,{type:`source`,sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`file`)return tR(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return tR(e,{type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}});{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),tR(e,{type:`reasoning`,text:``,status:{type:`running`}})}},oR=(e,t,n)=>iR(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`,status:e.status.type===`running`?{type:`running`,isArgsComplete:!0}:e.status}:e:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),sR=(e,t,n)=>iR(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),cR=(e,t,n)=>iR(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=qL(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),lR=(e,t,n)=>iR(e,t,n,e=>e.type===`tool-call`?{...e,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}:(n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e)),uR=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=dR(t);return{...e,status:n}},dR=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},fR=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),pR=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),mR=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),hR=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:FL(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},gR=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},_R=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),vR=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},yR=(e,t,n=0)=>{let r=n>0?n:vR(t);if(r>0)return e.getTiming(r);let i=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(i+=e.text);return e.getTiming(void 0,i||void 0)},bR=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},xR=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??nR(),a,o,s=new $L,c=new Set,l=(e,t)=>{c.has(e)||c.size>=rR||(c.add(e),console.warn(t))},u,d=t?bR(()=>{u?.enqueue(i)}):()=>{u?.enqueue(i)};super({start(e){u=e},transform(e){s.recordChunk();let t=e.type;switch(t){case`part-start`:i=aR(i,e,l),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=oR(i,e,l);break;case`part-finish`:i=sR(i,e,l);break;case`text-delta`:{let t=cR(i,e,l);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=lR(i,e,l);break;case`message-finish`:o=e.usage?.outputTokens,i=uR(i,e);break;case`annotations`:i=fR(i,e);break;case`data`:i=pR(i,e);break;case`step-start`:i=mR(i,e);break;case`step-finish`:i=hR(i,e);break;case`error`:i=gR(i,e),n?.(e.error);break;case`update-state`:a??=new QL(i.metadata.unstable_state,{strict:r}),i=_R(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:yR(s,i,o)}}),d()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&e.result===void 0)??!1;i=uR(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:yR(s,i,o)}},e.enqueue(i)}}})}};async function*SR(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function CR(e){return e[Symbol.asyncIterator]??=SR,e}var wR=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new xR))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return CR(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function TR(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function ER(e,t){let n=e;for(let e of t){if(n==null||!Object.hasOwn(n,e))return;n=n[e]}return n}var DR=class{resolve;reject;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(YL(e,this.fieldPath)===`complete`){let t=ER(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=ER(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},OR=class{controller;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=ER(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),YL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},kR=class{controller;disposed=!1;fieldPath;lastValue=void 0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=ER(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}YL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},AR=class{controller;disposed=!1;fieldPath;nextIndex=0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=ER(e,this.fieldPath);if(!Array.isArray(t))return;for(;this.nextIndex<t.length&&YL(e,[...this.fieldPath,this.nextIndex])===`complete`;this.nextIndex++)this.controller.enqueue(t[this.nextIndex]);YL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},jR=class{argTextDeltas;handles=new Set;accumulatedText=``;parsedTextLength=-1;args=void 0;finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=this.argTextDeltas.getReader();for(;;){let{value:t,done:n}=await e.read();if(n)break;this.accumulatedText+=t,this.handles.size!==0&&this.parseCurrentArgs()&&this.updateHandles()}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}parseCurrentArgs(){if(this.parsedTextLength===this.accumulatedText.length)return!1;let e=qL(this.accumulatedText);return this.parsedTextLength=this.accumulatedText.length,e===void 0?(this.args??=qL(``),!1):(this.args=e,!0)}updateHandles(){for(let e of this.handles)e.update(this.args),e.isDisposed&&this.handles.delete(e)}activateHandle(e){if(this.parseCurrentArgs(),e.update(this.args),!e.isDisposed){if(this.finished){e.end(this.args);return}this.handles.add(e)}}get(...e){return new Promise((t,n)=>{let r=new DR(t,n,e);this.activateHandle(r)})}streamValues(...e){let t=e,n;return CR(new ReadableStream({start:e=>{n=new OR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return CR(new ReadableStream({start:e=>{n=new kR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return CR(new ReadableStream({start:e=>{n=new AR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},MR=class{promise;constructor(e){this.promise=e}get(){return this.promise}},NR=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new jR(e.readable);let{promise:t,resolve:n}=yL();this.resolve=n,this.response=new MR(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},PR=Symbol.for(`assistant-stream.tool-execution-id`),FR=(e,t,n,r,i)=>{try{let a=t?.(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},IR=e=>e.join(`,`),LR=(e,t)=>{let n={...e};return Object.defineProperty(n,PR,{value:t,enumerable:!0}),n},RR=class extends zL{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({async transform(e,s){let c=a.get(IR(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?LR(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new NR,o=Symbol();a.set(String(n),o),r.set(o,i),t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(IR(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);await n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(IR(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new vL({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent,messages:e.messages})),i.add(t);break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(IR(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(await u.finishArgsText(),i.has(l))break;let d=!1,f=TR(()=>{let e;try{e=WL.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,FR(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&FR(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new vL({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),SL(s,LR({type:`result`,path:e.path,...r},l))},n=>{d&&FR(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new vL({result:String(n),isError:!0});u.setResponse(r),SL(s,LR({type:`result`,path:e.path,...r},l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(IR(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(IR(e.path)))};o?o.then(()=>{c(),SL(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new VL).pipeThrough(s)})}},zR=Symbol.for(`assistant-stream.tool-execution-id`),BR=Symbol(`assistant-stream.tool-aborted`),VR=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,HR=e=>typeof e?.then==`function`,UR=async(e,t,n=!1)=>{let r,i=new Promise(e=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>e(BR))):e(BR)},t.aborted?r():t.addEventListener(`abort`,r,{once:!0})});try{return await Promise.race([e,i])}finally{t.removeEventListener(`abort`,r)}},WR=()=>new vL({result:`Tool execution was cancelled.`,isError:!0});function GR(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return WR();let a=e;if(VR(i.parameters)){let e=i.parameters[`~standard`].validate(n.args),r=HR(e)?await UR(e,t):e;if(r===BR)return WR();r.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(r.issues)}`)}))}if(t.aborted)return WR();let o=await UR((async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[zR]:n.executionId},o=await a(n.args,e),s=vL.toResponse(o);if(i.toModelOutput&&!s.isError&&s.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:s.result});return new vL({result:s.result,artifact:s.artifact,isError:s.isError,messages:s.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return s})(),t,!0);return o===BR?WR():o})(i.execute):void 0}function KR(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[zR]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function qR(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new RR({execute:e=>GR(i(),a(),e,s),streamCall:({reader:e,...t})=>KR(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}var JR=new Set([`http://json-schema.org/draft-07/schema`,`https://json-schema.org/draft-07/schema`]);function YR(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}function XR(e){return typeof e==`object`&&!!e&&`toJSONSchema`in e&&typeof e.toJSONSchema==`function`}function ZR(e){return typeof e==`object`&&!!e&&`toJSON`in e&&typeof e.toJSON==`function`}function QR(e){if(typeof e==`object`&&e){let t=e.$schema;if(typeof t==`string`&&!JR.has(t.replace(/#$/,``)))throw Error(`The schema library was asked for a draft-07 JSON Schema and returned "${t}". Upgrade the library, or pass a plain JSON Schema object instead.`)}return e}function $R(e){if(YR(e)){let t=e[`~standard`].jsonSchema;if(typeof t==`object`&&t&&typeof t.input==`function`)return QR(t.input({target:`draft-07`}))}if(XR(e))return e.toJSONSchema({target:`draft-07`});if(ZR(e))return e.toJSON();if(YR(e)){let{vendor:t}=e[`~standard`],n=t===`zod`?`convert it with z.toJSONSchema(schema)`:`wrap the schema with ${t}'s Standard JSON Schema helper`;throw Error(`Could not convert the "${t}" schema to JSON Schema: it has no "~standard.jsonSchema" converter. Upgrade ${t} to a release that implements Standard JSON Schema, ${n}, or pass a plain JSON Schema object instead.`)}return e}function ez(e){let{required:t,...n}=e;return n.properties&&=Object.fromEntries(Object.entries(n.properties).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?[e,ez(t)]:[e,t])),n}function tz(e){return mL(kM(()=>{try{let t=$R(e);return uL(t)?t:null}catch{return null}},[e]))}var nz=e=>{let t=J(17),n=Q(),r;t[0]===e?r=t[1]:(r=t=>t.unstable_interactables.definitions[e]?.state,t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>t.unstable_interactables.persistence[e],t[2]=e,t[3]=a);let o=$(a),s;t[4]!==n||t[5]!==e?(s=t=>{n.unstable_interactables.setState(e,e=>typeof t==`function`?t(e):t)},t[4]=n,t[5]=e,t[6]=s):s=t[6];let c=s,l;t[7]===n?l=t[8]:(l=()=>n.unstable_interactables.flush(),t[7]=n,t[8]=l);let u=l,d=o?.isPending??!1,f=o?.error,p;t[9]!==u||t[10]!==c||t[11]!==d||t[12]!==f?(p={setState:c,isPending:d,error:f,flush:u},t[9]=u,t[10]=c,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==i||t[15]!==p?(m=[i,p],t[14]=i,t[15]=p,t[16]=m):m=t[16],m};function rz(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function iz(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var az=e=>{if(!lL(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function oz(e,t,n){let r=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(r=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);r=r.filter(t=>{let n=az(t);return n===void 0?!e.has(t):!e.has(n)})}let i=t.update;if(Array.isArray(i)&&i.length>0){let e=new Map;for(let t of i){let n=az(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}r=r.map(t=>{let n=az(t);if(n===void 0||!lL(t))return t;let r=e.get(n);return r?{...t,...r}:t})}if(Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!lL(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;r=[...r,...e]}return r}function sz(e,t,n){if(!lL(e)||!lL(t))return t;let r=lL(n?.arrayBaseline)?n.arrayBaseline:e,i=Object.entries(e);for(let[e,a]of Object.entries(t)){let t=r[e];if(Array.isArray(t)&&lL(a)){let r=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0;i.push([e,oz(t,a,r)])}else i.push([e,a])}return Object.fromEntries(i)}function cz(e,t){if(!lL(e)||!lL(t))return;for(let n of Object.keys(e))if(!Object.hasOwn(t,n))return;let n=[];for(let[r,i]of Object.entries(t))(!Object.hasOwn(e,r)||!pL(e[r],i))&&n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var lz=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},uz=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=lL(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},dz=e=>{let t=lL(e)?e.addedItemIds:void 0;if(!lL(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},fz=new WeakMap;function pz(e,t,n){let r=fz.get(e);r||(r=new Map,fz.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=iz(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=rz(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:sz(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=lz(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&uz(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=dz(r.result);s.push({state:i?sz(e.state,n,{idFactory:i}):sz(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function mz(e,t,n){let r=pz(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function hz(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=mz(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(pL(r.state,n.state))continue;let i=cz(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var gz=(e,t)=>{let n=Q(),r=IM().replace(/[^a-zA-Z0-9]/g,``),i=iz(e),a=$(e=>{let t=e.optional.part;return t?.type===`tool-call`?t:void 0}),o;if(a?.toolName===i){let e=a.result,t=a.args;e?.success!==!1&&(typeof e?.id==`string`?o=e.id:typeof t?.id==`string`&&(o=t.id))}let s=t.id??o??r,c=a?.toolName===e||a?.toolName===i?`thread`:void 0,l=Y(t.stateSchema);l.current=t.stateSchema;let u=tz(t.stateSchema),d=Y(t.initialState);d.current=t.initialState;let f=$(()=>n.unstable_interactables);X(()=>f.register({id:s,name:e,description:t.description,stateSchema:l.current,initialState:d.current,updateRender:t.updateRender,...c?{scope:c}:{}}),[f,s,e,t.description,u,c,t.updateRender]);let p=a?.toolCallId,[m,h]=nz(s),{setState:g}=h,_=$(hL(t=>{if(!c||!p)return;let n=pz(t.thread.messages,s,e);if(!n.some(e=>e.origin===`create`&&e.toolCallId===s))return;let r=n.find(e=>e.toolCallId===p);if(!r)return;let i=n.findLast(e=>e.toolCallId!==void 0)?.toolCallId;return{state:r.state,isLatest:i===p}})),v=kM(()=>_&&{state:_.state,isLatest:_.isLatest,restore:()=>g(_.state)},[_,g]);return[m===void 0?t.initialState:m,{id:s,version:v,...h}]},_z=UM(null),vz=(e,t)=>Yj(_z,e,t),yz=()=>GM(_z),bz={},xz=e=>{let t=QP(e??bz);return e==null?null:t},Sz=Symbol(`innerMessage`),Cz=Symbol(`innerMessages`),wz=[],Tz=(e,t)=>{Sz in e||(e[Sz]=t)},Ez=e=>{let t=`messages`in e?e.messages:e,n=t[Cz]||t[Sz];return n?Array.isArray(n)?n:(t[Cz]=[n],t[Cz]):wz},Dz=`__external_store_fallback_`,Oz=PL(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7);function kz(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var Az=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},jz=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?kz(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId||`tool-${Oz()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:qL(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=Az(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=Az(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>Az(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},Mz=e=>e.type===`tool-call`&&e.result===void 0,Nz=e=>{if(e.type!==`tool-call`||e.result!==void 0)return!1;let t=e.messages?.at(-1);return t?.role===`assistant`&&t.status.type===`running`},Pz=e=>e.type!==`tool-call`||e.result!==void 0?!1:e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,Fz=Symbol(`autoStatus`),Iz=Object.freeze(Object.assign({type:`running`},{[Fz]:!0})),Lz=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[Fz]:!0})),Rz=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[Fz]:!0})),zz=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[Fz]:!0})),Bz=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[Fz]:!0})),Vz=e=>e[Fz]===!0,Hz=(e,t,n,r,i,a,o)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[Fz]:!0}):e&&t?Iz:n?Bz:o&&!a?Iz:r?zz:a?Rz:Lz,Uz=e=>Hz(!1,!1,typeof e!=`string`&&e.some(Pz),typeof e!=`string`&&e.some(Mz)),Wz=(e,t,n)=>Hz(t,n,typeof e!=`string`&&e.some(Pz),typeof e!=`string`&&e.some(Mz),void 0,void 0,typeof e!=`string`&&e.some(Nz)),Gz=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},Kz=(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},qz=500,Jz=({adapterRef:e,snapshot:t,updatePersistenceStatus:n})=>{let r=Y(void 0),i=Y(0),a=Y(new Map),o=Y(0),s=Y([]),c=Y(new Set),l=Y([]),u=Y(()=>{}),d=AM(e=>{if(c.current.size===0)return;let n=new Set(c.current);c.current.clear();let r=++i.current;for(let e of n)a.current.set(e,r);return{adapter:e,payload:t(),dirtyIds:n,seq:r}},[t]),f=AM(e=>{let t=d(e);t&&(o.current===0?u.current(t):l.current.push(t))},[d]),p=AM(async t=>{let i=t??(e.current?d(e.current):void 0);if(!i){if(o.current===0){for(let e of s.current)e();s.current=[]}return}let{adapter:f,payload:p,dirtyIds:m,seq:h}=i;o.current+=1,n(e=>{let t=kj(e);for(let e of m)t[e]={isPending:!0,error:void 0};return t});let g=e=>{let t=[];for(let e of m)a.current.get(e)!==h||c.current.has(e)||(a.current.delete(e),t.push(e));t.length!==0&&n(n=>{let r=!1,i=kj(n);for(let a of t)n[a]!==void 0&&(e===void 0?delete i[a]:i[a]=e,r=!0);return r?i:n})};try{await f.save(p),g(void 0)}catch(e){g({isPending:!1,error:e})}finally{--o.current;let t=l.current.shift()??(e.current&&c.current.size>0?d(e.current):void 0);if(t)r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),u.current(t);else if(o.current===0){for(let e of s.current)e();s.current=[]}}},[e,d,n]);return u.current=e=>{p(e)},{flushIfPending:AM(()=>{r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),e.current&&f(e.current)},[e,f]),schedulePersistence:AM(t=>{e.current&&(c.current.add(t),r.current!==void 0&&clearTimeout(r.current),r.current=setTimeout(()=>{r.current=void 0,o.current===0&&e.current?f(e.current):r.current=setTimeout(()=>{r.current=void 0,e.current&&f(e.current)},qz)},qz))},[e,f]),flush:AM(async()=>{if(r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),!(o.current>0||c.current.size>0||l.current.length>0))return;let t=new Promise(e=>{s.current.push(e)});return e.current&&f(e.current),t},[e,f])}},Yz={type:`string`,description:`The id of the instance to update, as shown in its state snapshot in the conversation.`},Xz={type:`string`,description:`The id of an item currently in this list.`},Zz=e=>{let t=e.properties;return lL(t)&&t.id!==void 0},Qz=e=>({...e,required:[`id`]}),$z=e=>{let{id:t,...n}=lL(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(e=>e!==`id`):e.required;return{...e,properties:n,required:r}},eB=(e,t)=>{if(!lL(e)||e.type!==`array`)return e;let n=e.items;if(Array.isArray(n)||!lL(n))return e;let r=Zz(n),i={add:{type:`array`,items:r?$z(n):n},remove:{type:`array`,items:r?Xz:n},clear:{type:`boolean`}};return r&&(i.update={type:`array`,items:Qz(n)}),{type:`object`,description:`Operations for array field "${t}". To change one item use update with its id; add new items (their ids are assigned for you), remove items by id, or clear to empty. Change only the items you mean to — never resend the whole array to edit one item.`,properties:i,additionalProperties:!1}},tB=e=>{let t=new Set;for(let[n,r]of Object.entries(e))lL(r)&&r.type===`array`&&lL(r.items)&&Zz(r.items)&&t.add(n);return t},nB=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,eB(t,e)]));function rB(e){if(!e||typeof e!=`object`||e.type!==`object`)return{type:`object`,properties:{id:Yz},required:[`id`],additionalProperties:!0};let{id:t,...n}=e.properties??{};return{...e,properties:{id:Yz,...nB(n)},required:[`id`]}}function iB(e,t,n,r=new Map){let i=Object.values(e);if(i.length===0)return;let a=new Map;for(let e of i){let t=a.get(e.name)??[];t.push(e),a.set(e.name,t)}let o={};for(let[i,s]of a){let a=iz(i);if(o[a])continue;let c=s[0],l=t.get(c.id),u=l&&lL(l.properties)?tB(l.properties):new Set,d=t=>{if(typeof t==`string`){let n=e[t];return n?.name===i?n:void 0}return s.length===1?c:void 0};o[a]={type:`frontend`,description:`Update the state of interactable component "${i}". ${c.description} Pass the id of the instance to update — instance ids and current state appear in the conversation as state snapshots. Only include the fields you want to change; omitted fields keep their current values.`,parameters:rB(l),streamCall:async(e,{toolCallId:t})=>{try{for await(let i of e.args.streamValues()){if(!i||typeof i!=`object`)continue;let e=i,a=Object.keys(e);if(a.indexOf(`id`)===a.length-1)continue;let{id:o,...s}=e;if(Object.keys(s).length===0)continue;let c=d(o);if(!c)continue;let l=r.get(t),u=l?.targetId===c.id?l.state:c.state;(!l||l.targetId!==c.id)&&r.set(t,{targetId:c.id,state:c.state}),n(c.id,e=>sz(e,s,{arrayBaseline:u}))}}catch{}},execute:async(e,{toolCallId:t})=>{let{id:a,...o}=e??{},c=d(a);if(!c){let e=s.map(e=>e.id);return{success:!1,error:`Unknown id ${JSON.stringify(a)} for interactable "${i}". Valid ids: ${e.join(`, `)}`}}let l=r.get(t);r.delete(t);let f=kj();n(c.id,e=>sz(e,o,{arrayBaseline:l?.targetId===c.id?l.state:void 0,idFactory:e=>{let t=Oz();return(f[e]??=[]).push(t),t},idKeyedFields:u}));let p={success:!0,id:c.id};return Object.keys(f).length>0&&(p.addedItemIds={...f}),p}}}return{tools:o,unstable_composerMetadata:{interactables:i.map(e=>({id:e.id,name:e.name,state:e.state}))}}}var aB=(e,t,n)=>e.some(e=>e.role===`assistant`&&e.content?.some(e=>{if(!e||typeof e!=`object`)return!1;let r=e;return r.type===`tool-call`&&r.toolCallId===t&&r.toolName===n})),oB=({persistence:e}={})=>{let[t,n]=DM(()=>({definitions:kj(),persistence:kj()})),r=LP(),i=Y(t),a=Y(new Set),o=Y(new Map),s=Y(new Map),c=Y(new Map),l=Y(new Map),u=Y(new Map),d=Y(new Map),f=Y(new Map),p=Y(new Map),m=Y(new Set),h=Y(void 0),g=AM(e=>{let t=e(i.current);i.current=t,n(t)},[]),_=AM(()=>{let e=kj();for(let[t,n]of Object.entries(i.current.definitions))n.scope!==`thread`&&(e[t]={name:n.name,state:n.state});return e},[]),{flushIfPending:v,schedulePersistence:y,flush:b}=Jz({adapterRef:h,snapshot:_,updatePersistenceStatus:AM(e=>{g(t=>{let n=e(t.persistence);return n===t.persistence?t:{...t,persistence:n}})},[g])}),x=AM((e,t)=>{let n=t.shouldStash??(()=>!0),r=t.shouldApply??(()=>!0);for(let[r,i]of Object.entries(e))n(r)&&t.stash.set(r,i.state);g(t=>{let n=!1,i=kj(t.definitions);for(let[t,a]of Object.entries(e)){let e=i[t];e&&r(t,e)&&(i[t]={...e,state:a.state},n=!0)}return n?{...t,definitions:i}:t})},[g]),S=AM(e=>{x(e,{stash:l.current})},[x]),C=AM(e=>{x(e,{stash:p.current,shouldStash:e=>!m.current.has(e),shouldApply:(e,t)=>!m.current.has(e)&&t.scope!==`thread`})},[x]),w=AM(async e=>{if(e.load)try{let t=await e.load();if(!t||h.current!==e)return;C(t)}catch(e){console.warn(`[Interactables] Persistence load failed.`,e)}},[C]),T=AM(e=>{h.current!==e&&v(),h.current=e,e&&w(e)},[v,w]),E=AM(()=>{let e=r.current;if(!e)return;let t=e.threadListItem;if(t.source!=null)return t().getState().id;let n=e.threads;if(n.source!=null)return n().getState().mainThreadId},[r]);X(()=>{if(e)return T(e),()=>{h.current===e&&T(void 0)}},[e,T]);let D=AM((e,t)=>{m.current.add(e),g(n=>{let r=n.definitions[e];return r?{...n,definitions:kj(n.definitions,{[e]:{...r,state:t(r.state)}})}:n}),i.current.definitions[e]?.scope!==`thread`&&y(e)},[y,g]),O=kM(()=>({getModelContext:()=>{let e=i.current.definitions;return iB(e,o.current,D,c.current)??{}},subscribe:e=>(a.current.add(e),()=>{a.current.delete(e)})}),[D]);X(()=>{IF(a.current)},[t]),RP(`modelContext`,()=>r.current.modelContext().register(O),[O]);let k=AM((e,t)=>{let n=r.current?.tools;return!n||n.source==null?!1:(t.unsubscribe=n().setToolUI(iz(e),t.render,{standalone:!0}),!0)},[r]);return RP(`tools`,()=>{for(let[e,t]of f.current)t.unsubscribe?.(),t.unsubscribe=void 0,k(e,t);return()=>{for(let e of f.current.values())e.unsubscribe?.(),e.unsubscribe=void 0}},[k]),{getState:()=>i.current,register:AM(e=>{let t=r.current?.thread,n=t&&t.source!=null?t().getState().messages??[]:[],i=e.scope??(aB(n,e.id,e.name)?`thread`:`app`);d.current.set(e.id,(d.current.get(e.id)??0)+1);let a;if(e.updateRender){let t=f.current.get(e.name),n=t??{count:0,render:e.updateRender,unsubscribe:void 0};n.count++,t||f.current.set(e.name,n),!n.unsubscribe&&k(e.name,n),a=()=>{let t=f.current.get(e.name);t&&--t.count===0&&(f.current.delete(e.name),t.unsubscribe?.(),t.unsubscribe=void 0)}}if(s.current.get(e.id)!==e.stateSchema){s.current.set(e.id,e.stateSchema),o.current.delete(e.id);try{let t=$R(e.stateSchema);o.current.set(e.id,ez(t))}catch(t){console.warn(`[Interactables] Failed to create partial schema for "${e.name}". The update tool will accept arbitrary fields without validation.`,t)}}let c=i===`thread`?E():void 0,m=i===`thread`?c?u.current.get(c)?.get(e.id):void 0:l.current.get(e.id);i===`thread`?c&&u.current.get(c)?.delete(e.id):l.current.delete(e.id);let h=i===`thread`?void 0:p.current.get(e.id),_=i===`thread`?mz(n,e.id,e.name):void 0;return g(t=>({...t,definitions:kj(t.definitions,{[e.id]:{id:e.id,name:e.name,description:e.description,stateSchema:e.stateSchema,initialState:e.initialState,scope:i,state:t.definitions[e.id]?.state??m??_?.state??h??e.initialState}})})),()=>{a?.();let t=(d.current.get(e.id)??1)-1;if(t>0){d.current.set(e.id,t);return}d.current.delete(e.id),v(),g(t=>{let n=t.definitions[e.id];if(n){if(n.scope===`thread`){let t=E();if(t){let r=u.current.get(t);r||(r=new Map,u.current.set(t,r)),r.set(e.id,n.state)}}else l.current.set(e.id,n.state)}s.current.delete(e.id),o.current.delete(e.id);let r=kj(t.definitions),i=kj(t.persistence);return delete r[e.id],delete i[e.id],{...t,definitions:r,persistence:i}})}},[v,r,E,k,g]),setState:D,exportState:_,importState:S,setPersistenceAdapter:T,flush:b}},sB=KM(oB);xP(oB,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=ZF())});var cB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({attachment:EF({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},lB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({attachment:EF({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},uB=e=>{let t=J(6),{runtime:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({threadListItem:WI({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},dB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({message:EF({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:EF({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},fB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({part:EF({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},pB=KM(e=>{let t=J(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:hB,resumeToolCall:gB,respondToToolApproval:_B},t[5]=o,t[6]=s),s}),mB=e=>{let t=J(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=Q(),s;t[0]!==a||t[1]!==n?(s=KN({part:pB({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,P.jsx)(eL,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function hB(){throw Error(`Not supported`)}function gB(){throw Error(`Not supported`)}function _B(){throw Error(`Not supported`)}var vB=e=>{for(let t of e)if(t?.status.type===`running`)return DI;return e.at(-1)?.status??EI},yB=(e,t)=>{let n={running:0,complete:0,incomplete:0,requiresAction:0},r=EI,i=!1;for(let a of t)switch(r=e[a]?.status??EI,r.type){case`running`:n.running++,i=!0;break;case`complete`:n.complete++;break;case`incomplete`:n.incomplete++;break;case`requires-action`:n.requiresAction++}return{status:i?DI:r,counts:n}},bB=KM(e=>{let t=J(11),{parts:n,getMessagePart:r}=e,[i,a]=DM(!0),o;t[0]===n?o=t[1]:(o=vB(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),xB=e=>{let t=J(4),{startIndex:n,endIndex:r,children:i}=e,a=$(SB).slice(n,r+1),o=Q(),s=KN({chainOfThought:bB({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message.part({index:n+t})}})}),c;return t[0]!==i||t[1]!==s||t[2]!==o?(c=(0,P.jsx)(eL,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function SB(e){return e.message.parts}var CB=e=>{let t=J(7),{index:n,archived:r,children:i}=e,a=Q(),o;t[0]!==r||t[1]!==n?(o=KN({threadListItem:EF({source:`threads`,query:{type:`index`,index:n,archived:r},get:e=>e.threads.item({index:n,archived:r})})}),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==a||t[4]!==i||t[5]!==s?(c=(0,P.jsx)(eL,{extends:a,config:s,children:i}),t[3]=a,t[4]=i,t[5]=s,t[6]=c):c=t[6],c},wB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({suggestion:EF({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},TB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({queueItem:EF({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},EB=Symbol.for(`assistant-ui.message-not-sent`),DB=e=>typeof e==`object`&&!!e&&EB in e,OB=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},kB=class extends OB{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},AB=class extends kB{get source(){return`thread-composer`}},jB=class extends kB{get source(){return`edit-composer`}},MB=class extends OB{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},NB=Object.freeze([]),PB=Object.freeze({}),FB=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??NB,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??PB,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??NB,value:e?.text??``}),IB=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??NB,runConfig:e?.runConfig??PB,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??NB,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),LB=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new GF({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},RB=class extends LB{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new UF({path:e.path,getState:()=>FB(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new AB(new HF({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:FF},subscribe:e=>this._core.subscribe(e)}),this._core)}},zB=class extends LB{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new UF({path:e.path,getState:()=>IB(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new jB(new HF({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:FF},subscribe:e=>this._core.subscribe(e)}),this._core)}},BB=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
90
+ Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},Rj=(e,t)=>{Cj(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},zj=(e,t)=>{let n=gj(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||Nj();let a=e();return vj&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&Pj();let a=i;if(Lj(a.wipDeps,t))return a.isDirty&&Rj(n,a),a.wip;let o=e();return vj&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,wj(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),Rj(n,a),o};function Bj(e){return zj(()=>({current:e}),[])}var Vj=Symbol(`tap.Context.defaultValue`),Hj=e=>e,Uj=new Map,Wj=new Set,Gj=()=>new Map(Uj),Kj=(e,t)=>{let n=Uj;Uj=e;try{return t()}finally{Uj=n}},qj=(e,t)=>{e[Vj]=t},Jj=e=>typeof e==`object`&&!!e&&Vj in e,Yj=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),Xj=e=>Jj(e)||Yj(e),Zj=e=>{if(!Jj(e)){if(Yj(e)){qj(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},Qj=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);Zj(e);let r=e,i=gj(),a=Bj(void 0),o=a.current===void 0||!Object.is(a.current.value,t);Ij(()=>{a.current={value:t}},[t]);let s=Uj.get(r),c=s!==void 0||Uj.has(r);Uj.set(r,{value:t,source:i});try{return $j(r,o,n)}finally{c?Uj.set(r,s):Uj.delete(r)}},$j=(e,t,n)=>{let r=Wj.has(e);t?Wj.add(e):Wj.delete(e);try{return n()}finally{r?Wj.add(e):Wj.delete(e)}},eM=e=>{Zj(e);let t=e,n=tM(t,e),r=gj();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},tM=(e,t)=>Uj.get(e)??{value:Hj(t)[Vj],source:null},nM=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},rM=(e,t=e.wipContextDeps)=>{let n=_j();n&&t&&(n.wipContextDeps=nM(n,e,n.wipContextDeps,t))},iM=()=>Wj.size>0,aM=e=>{if(!e.contextDeps||!iM())return!1;for(let t of Wj.keys())if(e.contextDeps.has(t))return!0;return!1},oM=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,Sj(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},sM=(e,t,n,r,i)=>{let a=r?r(n):n;vj&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=_j();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else oM(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function cM(e,t,n,r){let i=gj(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:Pj();i.isFirstRender||Nj();let s=sM(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,vj&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):vj&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(Tj(i,s),s.workInProgress=t)}return s.isDirty&&Cj(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function lM(e,t,n){return cM(e,t,n,!1)}var uM=(e,t)=>typeof t==`function`?t(e):t,dM=e=>e===void 0?void 0:typeof e==`function`?e():e;function fM(e){return cM(uM,e,dM,!0)}var pM=(e,t)=>zj(()=>e,t);function mM(e){let t=gj(),n=Bj(e);return n.current!==e&&Cj(t,()=>{n.current=e}),pM(((...e)=>{if(vj&&_j())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var hM=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,gM=()=>{},_M=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(gM,gM):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},vM=e=>hM(e)?_M(e):eM(e),yM=!1,bM=(e,t,n=t)=>{let r=gj().isNeverMounted,i=r?n():t();vj&&!yM&&(!r||n===t)&&(Object.is(i,t())||(yM=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=lM(e=>e+1,0),o=Bj(0),s=mM(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return Ij(()=>e(()=>{s()&&a()}),[e]),Ij(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},xM=(e,t)=>{},SM=0,CM=()=>{let e=Bj(null);return e.current??=`:tap${SM++}:`,e.current},wM=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?Ij(r):Ij(r,[...n,e])},TM=N.default;function EM(e){let t=(0,N.useRef)(e);return(0,N.useInsertionEffect)(()=>{t.current=e}),(0,N.useCallback)(((...e)=>t.current(...e)),[])}var DM=TM.useEffectEvent??EM,OM=()=>_j()!==null,kM=N.default,AM=e=>OM()?fM(e):kM.useState(e),jM=(e,t,n)=>OM()?lM(e,t,n):kM.useReducer(e,t,n),Y=e=>OM()?Bj(e):kM.useRef(e),MM=(e,t)=>OM()?zj(e,t):kM.useMemo(e,t),NM=(e,t)=>OM()?pM(e,t):kM.useCallback(e,t),X=(e,t)=>OM()?Ij(e,t):kM.useEffect(e,t),PM=(e,t)=>OM()?Ij(e,t):kM.useLayoutEffect(e,t),FM=e=>OM()?mM(e):DM(e),IM=(e,t,n)=>OM()?bM(e,t,n):kM.useSyncExternalStore(e,t,n),LM=(e,t)=>OM()?void 0:kM.useDebugValue(e,t),RM=(e,t)=>OM()?Ij(e,t):kM.useInsertionEffect(e,t),zM=()=>OM()?CM():kM.useId(),BM=(e,t,n)=>OM()?wM(e,t,n):kM.useImperativeHandle(e,t,n),Z=e=>kM.forwardRef(e),VM=(e,t)=>kM.memo(e,t),HM=kM.Fragment,UM=(...e)=>kM.createElement(...e),WM=(...e)=>kM.cloneElement(...e),GM=e=>kM.isValidElement(e);kM.Children,kM.Suspense;var KM=e=>{let t=kM.createContext(e);return qj(t,e),t},qM=e=>OM()&&Xj(e)?vM(e):kM.use(e),JM=e=>OM()&&Xj(e)?vM(e):kM.useContext(e);function YM(e){return(...t)=>({hook:e,args:t})}function XM(e,t,n){return typeof t==`function`?(...n)=>XM(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var ZM=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},QM=50,$M={schedulers:new Set,isScheduled:!1},eN=null,tN=[],nN=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(eN&&(eN.get(this)??0)>=QM)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,$M.schedulers.add(this),aN()}runTask(){eN?.set(this,(eN.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},rN=[];new nN(()=>{let e=rN.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}ZM(t,`Errors occurred while running scheduled tasks`)});var iN=e=>{if(eN!==null){tN.push(e);return}e()},aN=()=>{$M.isScheduled||($M.isScheduled=!0,sN())},oN=()=>{let e=eN;eN=new Map;let t=[];try{for(let e of $M.schedulers)if($M.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(eN=e,$M.schedulers.clear(),$M.isScheduled=!1,eN===null)for(;tN.length>0;)try{tN.shift()()}catch(e){t.push(e)}}ZM(t,`Errors occurred during flushSync`)},sN=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),oN()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(oN,0)})(),cN=e=>{if(eN!==null)return vj&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=$M;$M={schedulers:new Set,isScheduled:!0};try{let t=e();return oN(),t}finally{let e=$M.schedulers;if($M=t,e.size>0){for(let t of e)$M.schedulers.add(t);aN()}}};function lN(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}ZM(t,`Errors during commit`)}function uN(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var dN=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!Lj(e.deps,e.setupDeps);function fN(e){let t=[],n=[];for(let t of e.effectCells)dN(t)&&n.push(t);for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){t.push(e)}finally{e.cleanup=void 0}for(let e of n)try{uN(e)}catch(e){t.push(e)}ZM(t,`Errors during commit`)}function pN(e){let t=[];for(let n of e.effectCells)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}ZM(t,`Errors during cleanup`)}var mN={useState:fM,useReducer:lM,useRef:Bj,useMemo:zj,useCallback:pM,useEffect:Ij,useLayoutEffect:Ij,useInsertionEffect:Ij,useEffectEvent:mM,useContext:eM,use:vM,useSyncExternalStore:bM,useDebugValue:xM,useId:CM,useImperativeHandle:wM,useMemoCache:kj},hN=N.default,gN=hN.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??hN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_N=gN==null?null:`H`in gN?{get current(){return gN.H},set current(e){gN.H=e}}:`ReactCurrentDispatcher`in gN?{get current(){return gN.ReactCurrentDispatcher.current},set current(e){gN.ReactCurrentDispatcher.current=e}}:null;function vN(e){if(!_N)return e();let t=_N.current;_N.current=mN;try{return e()}finally{_N.current=t}}function yN(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function bN(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function xN(e){e.isMounted&&(e.isMounted=!1,pN(e))}function SN(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,hj(e,()=>{r=vN(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw bN(e),t}return rM(e),r}function CN(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=vj&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,bj(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),lN(t)),n&&(fN(e),pN(e)),fN(e)}var wN=()=>{let e=gj();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},TN=()=>`child`,EN=()=>null,DN=()=>{if(!vj)return EN;let e=Y(0);return AM(()=>e.current++),e.current===2?TN:EN},ON=()=>_j()?wN:DN(),kN=e=>e(),AN=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}ZM(t,`Errors occurred while notifying Tap root subscribers`)},jN=(e,t,n)=>{let r=new nN(()=>s.handleUpdate()),i=[],a=yj((e,t)=>{(i.length!==0||e())&&(i.push(t),r.markDirty())}),o=yN(kN,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{xj(a,a.committedVersion);for(let e of i)vj&&o.devStrictMode&&e(),e();return xj(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,iN(()=>AN(s.subscribers)))},finishFlush:(e,t,n)=>{bj(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&CN(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{vj&&o.devStrictMode&&Kj(s.context,()=>SN(o,[s.committedRender])),t=Kj(s.context,()=>SN(o,[s.committedRender]))}catch(e){if(xj(a,a.committedVersion),hM(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},MN=e=>{let[,t]=AM(0),n=ON(),r=Y(null),i=r.current??=jN(e,n(),t),a=Gj(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=Kj(a,()=>SN(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),X(()=>(i.isMounted=!0,()=>{i.isMounted=!1,xN(i.fiber)}),[i]),X(()=>{if(c.processed){i.fiber.isMounted||(CN(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}CN(i.fiber),i.publish(c.value,c.version)}),MM(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},NN=()=>{let e=Y(0),t=e.current,n=gj();return{version:t,markDirty:MM(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},PN=()=>{let[e]=AM(()=>yj((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=jM((t,n)=>(xj(e,t),t+ +!!n()),0),[,r]=AM(0);return xj(e,t),{root:e,version:t,markDirty:void 0}},FN=()=>{let e=ON(),{root:t,version:n,markDirty:r}=_j()?NN():PN();return{version:n,createFiber:NM((n,i,a)=>yN(n,t,a?()=>{a(),r?.()}:r,e()),[])}},IN=(e,t,n)=>{let r=Y(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,X(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&Lj(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function LN(e){let{version:t,createFiber:n}=FN(),r=MM(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=IN(()=>({value:SN(r,e.args)}),[r,t,e.args],aM(r));return X(()=>()=>xN(r),[r]),X(()=>{CN(r)},[r,i]),i.value}var RN=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},zN=(e,t)=>!e.isDirty&&!aM(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&Lj(e.committedDeps,t),BN=e=>{if(!iM())return!1;for(let{fiber:t}of e.values())if(aM(t))return!0;return!1};function VN(e){let[t]=AM(()=>new Map),{version:n,createFiber:r}=FN(),i=BN(t),a=IN(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>RN(t,c));l={fiber:e,next:{value:SN(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>RN(t,c)),n=SN(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(zN(l,s.deps))typeof l.next==`object`&&bN(l.fiber),l.fiber.contextDeps&&rM(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=SN(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return X(()=>()=>{for(let e of t.keys())xN(t.get(e).fiber)},[t]),X(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(xN(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&CN(n.fiber):(r.remount&&(xN(n.fiber),n.fiber=r.remount),CN(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var HN=e=>e(),UN=e=>{let{createFiber:t}=FN(),n=MM(()=>t(HN,void 0),[t]),r=SN(n,[e]);X(()=>()=>{xN(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,CN(n))};return X(a),{value:r,effects:a}},WN=YM(()=>{let e=J(4),[t,n]=AM(GN),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{let r=Mj(n.renderers);return r[e]=[...r[e]??[],t],{...n,renderers:r}}),()=>{n(n=>{let r=Mj(n.renderers),i=r[e]?.filter(e=>e!==t)??[];return i.length>0?r[e]=i:delete r[e],{...n,renderers:r}})}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function GN(){return{renderers:Mj(),fallbacks:[]}}var KN=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},qN=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n=Mj();return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools!==void 0&&Object.hasOwn(e.tools,i)?e.tools[i]:void 0;if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=KN(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=KN({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||=Mj(),e.tools[i]=KN(a),Object.hasOwn(n,i)||(n[i]=r)}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...e.unstable_composerMetadata,...t.unstable_composerMetadata}),e},{})},JN=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},YN=e=>e,XN=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),ZN=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!XN.has(e))return!1}},QN=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},$N=Symbol(`assistant-ui.store.clientId`),eP=Symbol(`assistant-ui.store.instanceTag`),tP=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===$N?aP(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===$N||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(typeof n!=`symbol`&&n in t())return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},nP=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===$N)return n();let i=ZN(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},rP=e=>e?.source!=null,iP=e=>e?.source===null,aP=e=>e[$N]??e,oP=e=>e[eP]??aP(e),sP=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,cP=e=>{let t=[];for(let n in e)sP(n)||t.push(n);return t},lP=class extends QN{#e;constructor(e){super(),this.#e=e}get(e,t){let n=ZN(t,`OptionalAssistantClient`);if(n!==!1)return n;if(sP(t))return;let r=this.#e[t];return rP(r)?r:void 0}ownKeys(){return cP(this.#e)}has(e,t){return!sP(t)&&t in this.#e}},uP=e=>new Proxy({},new lP(e)),dP=()=>()=>{},fP=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,pP=class extends QN{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return dP;if(t===`optional`)return this.#r??=uP(this.#n());let n=ZN(t,this.#e);return n===!1?nP(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},mP=((e,t)=>{let n=new Proxy({},new pP(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>fP),hP=()=>new Proxy({},{get(e,t){let n=ZN(t,`AssistantClient`);return n===!1?nP(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),gP=KM(mP),_P=()=>{},vP=new WeakMap,yP=e=>vP.get(e)??_P,bP=(e,t)=>{vP.set(e,t)},xP=()=>JM(gP),SP=(e,t)=>Qj(gP,e,t),CP=Symbol(`assistant-ui.transform-scopes`);function wP(e,t){let n=e;if(n[CP])throw Error(`transformScopes is already attached to this resource`);n[CP]=t}function TP(e){return e[CP]}var EP=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},DP=e=>{console.error(`NotificationManager: event listener error`,e)},OP=(e,t,n)=>{try{let r=e(t,n);r!==null&&(typeof r==`object`||typeof r==`function`)&&typeof r.then==`function`&&Promise.resolve(r).catch(DP)}catch(e){DP(e)}},kP=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.get(n)===a&&e.delete(n)}},emit(n,r,i){(e.has(n)||t.size!==0)&&queueMicrotask(()=>{let a=e.get(n);if(a)for(let e of a)OP(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)OP(n,e,i)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},AP=()=>AM(kP)[0],jP=Symbol(`assistant-ui.store.clientIndex`),MP=e=>e[jP],NP=KM([]),PP=()=>qM(NP),FP=(e,t)=>{let n=J(3),r=PP(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],Qj(NP,i,t)},IP=KM(null),LP=Symbol(`aui.scope-effect-unapplied`),RP=(e,t)=>Qj(IP,e,t),zP=()=>{let e=qM(IP);if(!e)throw Error(`AssistantTapContext is not available`);return e},BP=()=>zP().clientRef,VP=(e,t,n)=>{let r=J(8),{clientRef:i}=zP(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&rP(t)?oP(t):void 0},a=LP,o,s=e=>{if(o?.(),o=void 0,a=LP,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],X(a,o)},HP=()=>{let e=J(3),{emit:t}=zP(),n=PP(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],FM(r)},UP=KM(void 0),WP=(e,t)=>{let n=qM(UP);return Qj(UP,e??n,t)},GP=()=>{let e=J(3),[t]=AM(KP),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>()=>queueMicrotask(()=>t.abort()),r=[t],e[0]=t,e[1]=n,e[2]=r),RM(n,r),t.signal};function KP(){return new AbortController}var qP=Symbol(`assistant-ui.store.getValue`),JP=e=>{let t=e[qP];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},YP=new Map;function XP(e){let t=YP.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[qP];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},YP.set(e,t)),t}var ZP=class extends QN{boundFns;cachedReceiver;outputRef;tagRef;index;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===qP)return this.outputRef.current;if(t===jP)return this.index;if(t===eP)return this.tagRef.current;let r=ZN(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=XP(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===qP||t===jP||t===eP||t in this.outputRef.current}},QP=e=>{let t=Y(null),n=Y(null),r=MM(()=>({}),[e.hook,e.key]),i=PP().length,a=MM(()=>new Proxy({},new ZP(t,n,i)),[i]),o=FP(a,function(){return LN(e)});return t.current||(t.current=o,n.current=r),X(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},$P=YM(QP),eF=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},tF=e=>{let t=MM(()=>({}),[]);return t.v!==void 0&&eF(t.v,e)?t.v:(t.v=e,e)},nF=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&eF(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},rF=(()=>{try{return!1}catch{return!1}})(),iF=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=TP(e.hook);if(a){a(n,t),i=!0;break}}}return n},aF=e=>e.hook===OF,oF=e=>{if(!aF(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},sF=Symbol.for(`aui.event-receiver-ref`),cF=(e,t)=>{let n=e===mP?hP():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=uP(r),enumerable:!1}),r},lF=({notifications:e,clientRef:t})=>MM(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=EP(n),o=n[sF];if(i!==`*`&&!o&&iP(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`)return r(e);let a=((o??t).current??this)[i];if(!rP(a))return;let s=aP(a);if(s===n[MP(s)])return r(e)});if(i!==`*`){if(o){if(t.parent===mP)return s}else if(iP(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),uF=e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=oF(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=tF(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],tF(o)},dF=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=t?e:$P(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],LN(r)},fF=YM((e,t)=>{let n=xP(),r=aF(t),i=dF(t,r),a=r?i:i.methods,o=uF(t),s=MM(()=>tP({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),pF=e=>{let t=J(2),n;return t[0]===e?n=t[1]:(n=e.map(CF),t[0]=e,t[1]=n),VN(n)},mF=(e,t)=>{let n=tF(t),r=MM(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},hF=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=cF(e,lF({notifications:r,clientRef:n}));return{client:mF(i,[e,...RP({clientRef:n,emit:r.emit},function(){return SP(i,function(){return pF(t)})})])}},gF=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=UN(function(){let i=AP(),{client:a}=WP(n,function(){return hF({parent:e,entries:t,clientRef:r,notifications:i})});return X(()=>e.subscribe(i.notifySubscribers),[e,i]),X(()=>i.notifySubscribers()),a});return RM(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},_F=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=UN(function(){let i=AP(),a=MN(function(){return WP(n,function(){return hF({parent:e,entries:t,clientRef:r,notifications:i})})}),o=IM(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return X(()=>{let t=()=>cN(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return RM(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},vF=(e,t,n,r)=>{let{get:i}=r.args[0],a=IM(e.subscribe,()=>i(e),()=>i(e)),o=uF(r),s=MM(()=>tP({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},yF=(e,t)=>{if(rF){let[e]=AM(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!aF(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=Y({parent:e,current:null}).current,r=cF(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=EP(t);if(i===`*`)return e.on(t,r);let o=t[sF];if(!o&&iP(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[sF]:o??n},r)}}),i=mF(r,[e,...t.map(([t,n])=>vF(e,r,t,n))]);return RM(()=>{n.parent=e,n.current=i},[i,e,n]),i},bF=(e,t)=>{let n=J(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(iF(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(wF),n[3]=i,n[4]=a);let[o]=AM(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},xF=(e,t,n,r)=>{let{entries:i,rooted:a}=bF(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:yF(e,i)}},SF=(e,t,n)=>xF(e,t,gF,n);function Q(e){let t=xP();if(e){let{client:n,effects:r}=xF(t,e,_F,GP());return r&&bP(n,r),n}return t}function CF(e){let[t,n]=e;return XM(t,fF(t,n))}function wF(e){let[,t]=e;return!aF(t)}var TF=e=>{let t;class n extends QN{get(t,n){let r=ZN(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!sP(i)&&rP(e[i]))return JP(e[i]())}ownKeys(){return cP(e)}has(t,n){return!sP(n)&&n in e}}class r extends QN{get(r,i){let a=ZN(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!sP(o))return JP(e[o]())}ownKeys(){return[...cP(e),`optional`]}has(t,n){return n===`optional`||!sP(n)&&n in e}}return new Proxy({},new r)},EF=new WeakMap,DF=e=>{let t=EF.get(e);return t||(t=TF(e),EF.set(e,t)),t},$=e=>{let t=J(6),n=Q(),r;t[0]===n?r=t[1]:(r=DF(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=IM(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return LM(s),s},OF=e=>{let t=J(3),{get:n}=e,r=Q(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],$(i)},kF=YM(OF),AF=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function jF(e){let t=J(12),n;t[0]===e?n=t[1]:(n=e.map(PF),t[0]=e,t[1]=n);let r=VN(n),i;t[2]===e?i=t[3]:(i=e.reduce(NF,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(MF),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function MF(e){return e.state}function NF(e,t,n){return e[AF(t)]=n,e}function PF(e){return XM(AF(e),$P(e),e.deps)}var FF=(e,t=0)=>t===0?Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight:e.scrollHeight-t-e.scrollTop-e.clientHeight<=1||e.scrollHeight-t<=e.clientHeight,IF=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,LF=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,RF=Symbol(`skip-update`),zF=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}},BF=e=>{zF(e)},VF=(e,t)=>e===void 0||t===void 0?e===t:eF(e,t),HF=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){zF(this._subscribers)}},UF=class extends HF{_state;constructor(e){super(),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}getServerSnapshot;setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},WF=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){JN(this._subscriptions,e,t);return}zF(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{let e=this._connection;this._connection=void 0,e?.()}}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},GF=class extends WF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===RF)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===RF||VF(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},KF=class extends WF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==RF&&(this._previousState===void 0||!VF(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},qF=class extends WF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();if(r===t)return;t=r;let i=n;n=void 0;try{i?.()}finally{n=r?.subscribe(e),e()}});return()=>BF([()=>r?.(),()=>n?.()])}},JF=class extends WF{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=this.outerSubscribe(()=>{let e=this.config.binding.getState();if(e===n)return;n=e;let i=r;r=void 0;try{i?.()}finally{r=e?.unstable_on(this.config.event,t)}});return()=>BF([()=>i?.(),()=>r?.()])}},YF=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return qN(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}this._providerUnsubscribes.set(t,n),this.notifySubscribers();let r=!1;return()=>{if(r)return;r=!0,this._providers.delete(t);let e=this._providerUnsubscribes.get(t);this._providerUnsubscribes.delete(t);let n=!1,i,a=e=>{try{e()}catch(e){n?console.error(e):(n=!0,i=e)}};if(e&&a(e),a(()=>this.notifySubscribers()),n)throw i}}_subscribers=new Set;notifySubscribers(){zF(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},XF=[],ZF={modelName:void 0,toolNames:XF},QF=(e,t)=>e===t||eF(e,t),$F=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():XF,a=i.length?i:XF;return r===t.modelName&&QF(a,t.toolNames)?t:{modelName:r,toolNames:a}},eI=YM(()=>{let e=J(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new YF,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>$F(n,ZF),e[1]=r):r=e[1];let[i,a]=AM(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>$F(n,e)),n.subscribe(()=>{a(e=>$F(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),X(o,s);let c;e[4]===i?c=e[5]:(c=()=>$F(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),tI=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},nI=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,rI=e=>function(t){return tI(e,t)},iI=e=>{let t=J(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[XM(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=VN(i)[0],[o,s]=AM(oI),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=BP(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,renderText:n?.renderText,standalone:n?.standalone??!1};return s(t=>{let n=Mj(t);return n[e]=[...n[e]??[],r],n}),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[],i=Mj(t);return n.length>0?(i[e]=n,i):(delete i[e],i)})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?rI(i):void 0);a&&e.push(f(t,a,{standalone:nI(r),renderText:i}))}return()=>{e.forEach(sI)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),X(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(cI,Mj());return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),VP(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},aI=YM(iI);wP(iI,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=eI())});function oI(){return Mj()}function sI(e){return e()}function cI(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var lI=e=>IM(e.subscribe,e.getState,e.getServerSnapshot),uI=Symbol.for(`assistant-ui.silent-runtime-action`),dI=e=>typeof e==`object`&&!!e&&uI in e,fI=(e,t)=>{let n=t();return n.catch(t=>{dI(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},pI=YM(e=>{let t=J(9),{runtime:n}=e,r=lI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>fI(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),mI=YM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=pI({runtime:a}),t[3]=a,t[4]=o),LN(o)}),hI=YM(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),gI=YM(e=>{let t=J(63),{threadIdRef:n,messageIdRef:r,runtime:i,isSuggestion:a}=e,o=lI(i),s=HP(),c=Y(!1),l,u;t[0]!==s||t[1]!==r||t[2]!==i||t[3]!==n?(l=()=>{let e=[],t=i.unstable_on(`send`,e=>{let t=c.current;c.current=!1,s(`composer.send`,{threadId:n.current,...r&&{messageId:r.current},chars:e.chars,attachments:e.attachments,...t?{suggestion:!0}:void 0})});e.push(t);let a=i.unstable_on(`attachmentAdd`,e=>{s(`composer.attachmentAdd`,{threadId:n.current,...r&&{messageId:r.current},...e.contentType?{contentType:e.contentType}:void 0})});return e.push(a),e.push(i.unstable_on(`attachmentAddError`,e=>{s(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message,...e.contentType?{contentType:e.contentType}:void 0})})),()=>{for(let t of e)t()}},u=[i,s,n,r],t[0]=s,t[1]=r,t[2]=i,t[3]=n,t[4]=l,t[5]=u):(l=t[4],u=t[5]),X(l,u);let d;if(t[6]!==i||t[7]!==o.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>XM(e.id,mI({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),d=o.attachments.map(e),t[6]=i,t[7]=o.attachments,t[8]=d}else d=t[8];let f=jF(d),p=o.queue,m;if(t[11]!==p||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>XM(e.id,hI({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),m=p.map(e),t[11]=p,t[12]=i,t[13]=m}else m=t[13];let h=jF(m),g=o.type??`thread`,_;t[16]!==f.state||t[17]!==p||t[18]!==o.attachmentAccept||t[19]!==o.canCancel||t[20]!==o.canSend||t[21]!==o.dictation||t[22]!==o.isEditing||t[23]!==o.isEmpty||t[24]!==o.quote||t[25]!==o.role||t[26]!==o.runConfig||t[27]!==o.text||t[28]!==g?(_={text:o.text,role:o.role,attachments:f.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:g,dictation:o.dictation,quote:o.quote,queue:p},t[16]=f.state,t[17]=p,t[18]=o.attachmentAccept,t[19]=o.canCancel,t[20]=o.canSend,t[21]=o.dictation,t[22]=o.isEditing,t[23]=o.isEmpty,t[24]=o.quote,t[25]=o.role,t[26]=o.runConfig,t[27]=o.text,t[28]=g,t[29]=_):_=t[29];let v=_,y;t[30]===v?y=t[31]:(y=()=>v,t[30]=v,t[31]=y);let b;t[32]!==a||t[33]!==i?(b=e=>{let t=i.getState();c.current=t.canSend&&(a?.(t.text)??!1),i.send(e)},t[32]=a,t[33]=i,t[34]=b):b=t[34];let x;t[35]!==s||t[36]!==r||t[37]!==i||t[38]!==n?(x=()=>{!r&&i.getState().canCancel&&s(`composer.cancel`,{threadId:n.current}),i.cancel()},t[35]=s,t[36]=r,t[37]=i,t[38]=n,t[39]=x):x=t[39];let S=i.beginEdit??_I,C;t[40]===f?C=t[41]:(C=e=>`id`in e?f.get({key:e.id}):f.get(e),t[40]=f,t[41]=C);let w;t[42]===h?w=t[43]:(w=e=>`id`in e?h.get({key:e.id}):h.get(e),t[42]=h,t[43]=w);let T;t[44]===i?T=t[45]:(T=()=>i,t[44]=i,t[45]=T);let E;return t[46]!==i.addAttachment||t[47]!==i.clearAttachments||t[48]!==i.reset||t[49]!==i.setQuote||t[50]!==i.setRole||t[51]!==i.setRunConfig||t[52]!==i.setText||t[53]!==i.startDictation||t[54]!==i.stopDictation||t[55]!==S||t[56]!==C||t[57]!==w||t[58]!==T||t[59]!==y||t[60]!==b||t[61]!==x?(E={getState:y,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:b,cancel:x,beginEdit:S,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:C,queueItem:w,__internal_getRuntime:T},t[46]=i.addAttachment,t[47]=i.clearAttachments,t[48]=i.reset,t[49]=i.setQuote,t[50]=i.setRole,t[51]=i.setRunConfig,t[52]=i.setText,t[53]=i.startDictation,t[54]=i.stopDictation,t[55]=S,t[56]=C,t[57]=w,t[58]=T,t[59]=y,t[60]=b,t[61]=x,t[62]=E):E=t[62],E});function _I(){throw Error(`beginEdit is not supported in this runtime`)}var vI=e=>({get current(){return e()}}),yI=YM(e=>{let t=J(13),{runtime:n}=e,r=lI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),bI=YM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=pI({runtime:a}),t[3]=a,t[4]=o),LN(o)}),xI=YM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=yI({runtime:a}),t[3]=a,t[4]=o),LN(o)}),SI=YM(e=>{let t=J(74),{runtime:n,threadIdRef:r,threadId:i}=e,a=lI(n),o=HP(),[s,c]=AM(!1),[l,u]=AM(!1),d;t[0]===n?d=t[1]:(d=vI(()=>n.getState().id),t[0]=n,t[1]=d);let f=d,p=Y(a.status),m;t[2]!==o||t[3]!==n||t[4]!==i?(m=e=>{o(e,{threadId:i,messageId:n.getState().id})},t[2]=o,t[3]=n,t[4]=i,t[5]=m):m=t[5];let h=m,g,_;t[6]!==o||t[7]!==a.id||t[8]!==a.status||t[9]!==i?(g=()=>{let e=a.status,t=p.current;p.current=e,e?.type===`incomplete`&&e.reason===`error`&&(t?.type!==`incomplete`||t.reason!==`error`)&&o(`message.error`,{threadId:i,messageId:a.id,reason:`error`})},_=[a.status,a.id,o,i],t[6]=o,t[7]=a.id,t[8]=a.status,t[9]=i,t[10]=g,t[11]=_):(g=t[10],_=t[11]),X(g,_);let v;t[12]!==f||t[13]!==n.composer||t[14]!==r?(v=gI({runtime:n.composer,threadIdRef:r,messageIdRef:f}),t[12]=f,t[13]=n.composer,t[14]=r,t[15]=v):v=t[15];let y=QP(v),b;if(t[16]!==n||t[17]!==a.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>XM(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,xI({runtime:n,index:t}),[n,t]),t[19]=n,t[20]=e),b=a.content.map(e),t[16]=n,t[17]=a.content,t[18]=b}else b=t[18];let x=jF(b),S;t[21]===a.attachments?S=t[22]:(S=a.attachments??[],t[21]=a.attachments,t[22]=S);let C;if(t[23]!==n||t[24]!==S){let e;t[26]===n?e=t[27]:(e=(e,t)=>XM(e.id,bI({runtime:n,index:t}),[n,t]),t[26]=n,t[27]=e),C=S.map(e),t[23]=n,t[24]=S,t[25]=C}else C=t[25];let w=jF(C),T=a,E;t[28]!==y.state||t[29]!==s||t[30]!==l||t[31]!==x.state||t[32]!==T?(E={...T,parts:x.state,composer:y.state,isCopied:s,isHovering:l},t[28]=y.state,t[29]=s,t[30]=l,t[31]=x.state,t[32]=T,t[33]=E):E=t[33];let D=E,O;t[34]===D?O=t[35]:(O=()=>D,t[34]=D,t[35]=O);let k;t[36]===y.methods?k=t[37]:(k=()=>y.methods,t[36]=y.methods,t[37]=k);let A;t[38]===n?A=t[39]:(A=()=>n.delete(),t[38]=n,t[39]=A);let j,M;t[40]!==h||t[41]!==n?(j=e=>(h(`message.reload`),n.reload(e)),M=()=>(h(`message.speak`),n.speak()),t[40]=h,t[41]=n,t[42]=j,t[43]=M):(j=t[42],M=t[43]);let ee,te;t[44]===n?(ee=t[45],te=t[46]):(ee=()=>n.stopSpeaking(),te=e=>n.submitFeedback(e),t[44]=n,t[45]=ee,t[46]=te);let ne;t[47]!==h||t[48]!==n?(ne=e=>(h(`message.branchSwitched`),n.switchToBranch(e)),t[47]=h,t[48]=n,t[49]=ne):ne=t[49];let re;t[50]===n?re=t[51]:(re=()=>n.unstable_getCopyText(),t[50]=n,t[51]=re);let ie;t[52]===x?ie=t[53]:(ie=e=>`index`in e?x.get({index:e.index}):x.get({key:`toolCallId-${e.toolCallId}`}),t[52]=x,t[53]=ie);let ae;t[54]===w?ae=t[55]:(ae=e=>`id`in e?w.get({key:e.id}):w.get(e),t[54]=w,t[55]=ae);let oe;t[56]===h?oe=t[57]:(oe=e=>{e&&h(`message.copied`),c(e)},t[56]=h,t[57]=oe);let se;t[58]===n?se=t[59]:(se=()=>n,t[58]=n,t[59]=se);let ce;return t[60]!==O||t[61]!==k||t[62]!==A||t[63]!==j||t[64]!==M||t[65]!==ee||t[66]!==te||t[67]!==ne||t[68]!==re||t[69]!==ie||t[70]!==ae||t[71]!==oe||t[72]!==se?(ce={getState:O,composer:k,delete:A,reload:j,speak:M,stopSpeaking:ee,submitFeedback:te,switchToBranch:ne,getCopyText:re,part:ie,attachment:ae,setIsCopied:oe,setIsHovering:u,__internal_getRuntime:se},t[60]=O,t[61]=k,t[62]=A,t[63]=j,t[64]=M,t[65]=ee,t[66]=te,t[67]=ne,t[68]=re,t[69]=ie,t[70]=ae,t[71]=oe,t[72]=se,t[73]=ce):ce=t[73],ce}),CI=e=>{let t=MM(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n?.suggestions[r.length];r.push(t&&eF(t,e)?t:e)});let i=n&&eF(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},wI=YM(e=>({getState:()=>e})),TI=e=>{let t=J(9),n=CI(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(DI),t[0]=n.suggestions,t[1]=r);let i=jF(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},EI=YM(e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e.map(OI),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),TI(r)});function DI(e,t){return XM(t,wI(e),[e])}function OI(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var kI=Object.freeze({type:`complete`}),AI=Object.freeze({type:`running`}),jI=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),MI=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return AI;if(n===`complete`)return kI;if(n!==`incomplete`)return;let{reason:r}=t;return jI[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},NI=(e,t,n)=>{if(e.role!==`assistant`)return kI;if(n.type===`tool-call`)return n.result===void 0?e.status:kI;if(e.status.type===`running`){let e=MI(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?kI:r?e.status:kI},PI=e=>`reason`in e?e.reason:void 0,FI=e=>`error`in e?e.error:void 0,II=32,LI=new WeakMap,RI=e=>LI.get(e)??e.id,zI=(e,t,n)=>`status`in e&&e.status?NI(e,t,n):kI,BI=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>II))for(let[l,u]of e.entries())for(let[e,d]of u.content.entries()){if(d.type!==`tool-call`||d.messages===void 0)continue;let f=d.messages,p=zI(u,e,d),m=PI(p),h=FI(p),g=`${c}${l}.${e}`,_=t.get(g),v=_?.part===d&&_.statusType===p.type&&_.statusReason===m&&Object.is(_.statusError,h)&&_.messages===f&&_.task.messageId===u.id&&_.task.parentTaskId===n&&_.task.depth===s?_.task:{id:d.toolCallId,toolName:d.toolName,args:d.args,result:d.result,...d.isError===void 0?void 0:{isError:d.isError},status:p,timing:d.timing,messageId:u.id,parentTaskId:n,depth:s,messages:f};v!==_?.task&&(a=!1,LI.set(v,g)),r.push(v),i.set(g,{task:v,part:d,statusType:p.type,statusReason:m,statusError:h,messages:f}),o(f,v.id,s+1,`${g}.`)}};o(n,null,0,``);let s=a&&r.length===e.length&&r.every((t,n)=>t===e[n])?e:r;return e=s,t=i,s}},VI=YM(({task:e})=>({getState:()=>e})),HI=YM(e=>{let t=J(7),{runtime:n,id:r,threadIdRef:i,threadId:a}=e,o;t[0]!==r||t[1]!==n?(o=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==s||t[4]!==a||t[5]!==i?(c=SI({runtime:s,threadIdRef:i,threadId:a}),t[3]=s,t[4]=a,t[5]=i,t[6]=c):c=t[6],LN(c)}),UI=YM(e=>{let t=J(93),{runtime:n}=e,r=lI(n),i=HP(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return e.push(n.unstable_on(`toolApprovalAnswered`,e=>{let t=n.getState()?.threadId||`unknown`;i(`thread.toolApprovalAnswered`,{threadId:t,...e})})),()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),X(a,o);let s;t[4]===n?s=t[5]:(s=vI(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==i||t[7]!==n?(l=e=>{i(e,{threadId:n.getState().threadId})},t[6]=i,t[7]=n,t[8]=l):l=t[8];let u=l,d;t[9]===n?d=t[10]:(d=e=>n.getState().suggestions.some(t=>t.prompt===e),t[9]=n,t[10]=d);let f=d,p;t[11]!==f||t[12]!==n.composer||t[13]!==c?(p=gI({runtime:n.composer,threadIdRef:c,isSuggestion:f}),t[11]=f,t[12]=n.composer,t[13]=c,t[14]=p):p=t[14];let m=QP(p),h;t[15]===r.suggestions?h=t[16]:(h=EI(r.suggestions),t[15]=r.suggestions,t[16]=h);let g=QP(h),_;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=BI(),t[17]=_):_=t[17];let v=_,y;t[18]===r.messages?y=t[19]:(y=v(r.messages),t[18]=r.messages,t[19]=y);let b=y,x;t[20]===b?x=t[21]:(x=b.map(WI),t[20]=b,t[21]=x);let S=jF(x),C;if(t[22]!==n||t[23]!==r.messages||t[24]!==r.threadId||t[25]!==c){let e;t[27]!==n||t[28]!==r.threadId||t[29]!==c?(e=e=>XM(e.id,HI({runtime:n,id:e.id,threadIdRef:c,threadId:r.threadId}),[n,e.id,c,r.threadId]),t[27]=n,t[28]=r.threadId,t[29]=c,t[30]=e):e=t[30],C=r.messages.map(e),t[22]=n,t[23]=r.messages,t[24]=r.threadId,t[25]=c,t[26]=C}else C=t[26];let w=jF(C),T=w.state.length===0&&!r.isLoading,E;t[31]!==m.state||t[32]!==w.state||t[33]!==r.capabilities||t[34]!==r.extras||t[35]!==r.isDisabled||t[36]!==r.isLoading||t[37]!==r.isRunning||t[38]!==r.speech||t[39]!==r.state||t[40]!==r.suggestions||t[41]!==r.voice||t[42]!==T||t[43]!==b?(E={isEmpty:T,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:m.state,messages:w.state,tasks:b},t[31]=m.state,t[32]=w.state,t[33]=r.capabilities,t[34]=r.extras,t[35]=r.isDisabled,t[36]=r.isLoading,t[37]=r.isRunning,t[38]=r.speech,t[39]=r.state,t[40]=r.suggestions,t[41]=r.voice,t[42]=T,t[43]=b,t[44]=E):E=t[44];let D=E,O;t[45]===D?O=t[46]:(O=()=>D,t[45]=D,t[46]=O);let k;t[47]===m.methods?k=t[48]:(k=()=>m.methods,t[47]=m.methods,t[48]=k);let A;t[49]===g?A=t[50]:(A=()=>g.methods,t[49]=g,t[50]=A);let j;t[51]!==S||t[52]!==b?(j=e=>{if(`id`in e){let t=b.find(t=>t.id===e.id);return S.get({key:t?RI(t):e.id})}return S.get(e)},t[51]=S,t[52]=b,t[53]=j):j=t[53];let M;t[54]!==i||t[55]!==f||t[56]!==n?(M=e=>{let t=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if((t.role??`user`)===`user`){let e=t.content.map(GI).join(``);i(`composer.send`,{threadId:n.getState().threadId,chars:e.length,attachments:t.attachments?.length??0,...f(e)?{suggestion:!0}:void 0})}n.append(e)},t[54]=i,t[55]=f,t[56]=n,t[57]=M):M=t[57];let ee;t[58]!==u||t[59]!==n||t[60]!==r.isRunning?(ee=()=>{r.isRunning&&u(`thread.cancelRun`),n.cancelRun()},t[58]=u,t[59]=n,t[60]=r.isRunning,t[61]=ee):ee=t[61];let te;t[62]!==u||t[63]!==n?(te=()=>{n.connectVoice(),u(`thread.voiceStarted`)},t[62]=u,t[63]=n,t[64]=te):te=t[64];let ne;t[65]===w?ne=t[66]:(ne=e=>`id`in e?w.get({key:e.id}):w.get(e),t[65]=w,t[66]=ne);let re;t[67]===n?re=t[68]:(re=()=>n,t[67]=n,t[68]=re);let ie;return t[69]!==n.deleteMessage||t[70]!==n.disconnectVoice||t[71]!==n.export||t[72]!==n.getModelContext||t[73]!==n.getVoiceVolume||t[74]!==n.import||t[75]!==n.importExternalState||t[76]!==n.muteVoice||t[77]!==n.reset||t[78]!==n.resumeRun||t[79]!==n.startRun||t[80]!==n.stopSpeaking||t[81]!==n.subscribeVoiceVolume||t[82]!==n.unmuteVoice||t[83]!==O||t[84]!==k||t[85]!==A||t[86]!==j||t[87]!==M||t[88]!==ee||t[89]!==te||t[90]!==ne||t[91]!==re?(ie={getState:O,composer:k,suggestions:A,task:j,append:M,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:ee,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:te,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:ne,__internal_getRuntime:re},t[69]=n.deleteMessage,t[70]=n.disconnectVoice,t[71]=n.export,t[72]=n.getModelContext,t[73]=n.getVoiceVolume,t[74]=n.import,t[75]=n.importExternalState,t[76]=n.muteVoice,t[77]=n.reset,t[78]=n.resumeRun,t[79]=n.startRun,t[80]=n.stopSpeaking,t[81]=n.subscribeVoiceVolume,t[82]=n.unmuteVoice,t[83]=O,t[84]=k,t[85]=A,t[86]=j,t[87]=M,t[88]=ee,t[89]=te,t[90]=ne,t[91]=re,t[92]=ie):ie=t[92],ie});function WI(e){return XM(RI(e),VI({task:e}),[e])}function GI(e){return e.type===`text`?e.text:``}var KI=(e,t)=>fI(`thread list ${e}`,t),qI=YM(e=>{let t=J(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=lI(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o,c=HP(),{isMain:l,id:u}=a,d;t[3]!==l||t[4]!==u?(d={isMain:l,threadId:u},t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=Y(d),p,m;t[6]!==c||t[7]!==l||t[8]!==u?(p=()=>{let e=f.current;(e.isMain!==l||e.threadId!==u)&&(f.current={isMain:l,threadId:u},c(l?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:u}))},m=[l,u,c],t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=m):(p=t[9],m=t[10]),X(p,m);let h;t[11]===s?h=t[12]:(h=()=>s,t[11]=s,t[12]=h);let g,_,v,y,b,x,S;t[13]===n?(g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20]):(b=e=>KI(`switch`,()=>n.switchTo(e)),x=e=>KI(`rename`,()=>n.rename(e)),S=e=>KI(`update custom metadata`,()=>n.updateCustom(e)),g=()=>KI(`archive`,()=>n.archive()),_=()=>KI(`unarchive`,()=>n.unarchive()),v=()=>KI(`delete`,()=>n.delete()),y=e=>KI(`generate title`,()=>n.generateTitle(e)),t[13]=n,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S);let C;t[21]===n?C=t[22]:(C=()=>n,t[21]=n,t[22]=C);let w;return t[23]!==n.detach||t[24]!==n.initialize||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==y||t[29]!==C||t[30]!==h||t[31]!==b||t[32]!==x||t[33]!==S?(w={getState:h,switchTo:b,rename:x,updateCustom:S,archive:g,unarchive:_,delete:v,generateTitle:y,initialize:n.initialize,detach:n.detach,__internal_getRuntime:C},t[23]=n.detach,t[24]=n.initialize,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=C,t[30]=h,t[31]=b,t[32]=x,t[33]=S,t[34]=w):w=t[34],w}),JI=e=>{let t=J(4),n=HP(),r=Y(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)},YI=YM(e=>{let t=J(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=qI({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],LN(s)}),XI=YM(e=>{let t=J(48),{runtime:n,__internal_assistantRuntime:r}=e,i=lI(n);JI(i.mainThreadId);let a=HP(),o,s;t[0]!==a||t[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:r}=e;t!==n.getState().mainThreadId&&a(`thread.${r}`,{threadId:t})}),s=[n,a],t[0]=a,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),X(o,s);let c;t[4]===n.main?c=t[5]:(c=UI({runtime:n.main}),t[4]=n.main,t[5]=c);let l=QP(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>XM(e,YI({runtime:n,id:e,mainThreadIsRunning:l.state.isRunning}),[n,e,l.state.isRunning])),t[6]=l.state,t[7]=n,t[8]=i.threadItems,t[9]=u):u=t[9];let d=jF(u),f=i.newThreadId??null,p;t[10]!==l.state||t[11]!==i.archivedThreadIds||t[12]!==i.hasMore||t[13]!==i.isLoading||t[14]!==i.isLoadingMore||t[15]!==i.loadError||t[16]!==i.mainThreadId||t[17]!==i.threadIds||t[18]!==f||t[19]!==d.state?(p={mainThreadId:i.mainThreadId,newThreadId:f,isLoading:i.isLoading,loadError:i.loadError,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:d.state,main:l.state},t[10]=l.state,t[11]=i.archivedThreadIds,t[12]=i.hasMore,t[13]=i.isLoading,t[14]=i.isLoadingMore,t[15]=i.loadError,t[16]=i.mainThreadId,t[17]=i.threadIds,t[18]=f,t[19]=d.state,t[20]=p):p=t[20];let m=p,h;t[21]===m?h=t[22]:(h=()=>m,t[21]=m,t[22]=h);let g;t[23]===l.methods?g=t[24]:(g=()=>l.methods,t[23]=l.methods,t[24]=g);let _;t[25]!==m||t[26]!==d?(_=e=>{if(e===`main`)return d.get({key:m.mainThreadId});if(`id`in e)return d.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?m.archivedThreadIds[t]:m.threadIds[t];return d.get({key:r})},t[25]=m,t[26]=d,t[27]=_):_=t[27];let v,y,b,x,S,C;t[28]===n?(v=t[29],y=t[30],b=t[31],x=t[32],S=t[33],C=t[34]):(v=(e,t)=>KI(`switch`,()=>n.switchToThread(e,t)),y=()=>KI(`create`,()=>n.switchToNewThread()),b=()=>n.getLoadThreadsPromise(),x=()=>n.reload(),S=()=>n.reloadMainThread(),C=()=>n.loadMore(),t[28]=n,t[29]=v,t[30]=y,t[31]=b,t[32]=x,t[33]=S,t[34]=C);let w;t[35]===r?w=t[36]:(w=()=>r,t[35]=r,t[36]=w);let T;return t[37]!==v||t[38]!==y||t[39]!==b||t[40]!==x||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==h||t[45]!==g||t[46]!==_?(T={getState:h,thread:g,item:_,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:b,reload:x,reloadMainThread:S,loadMore:C,__internal_getAssistantRuntime:w},t[37]=v,t[38]=y,t[39]=b,t[40]=x,t[41]=S,t[42]=C,t[43]=w,t[44]=h,t[45]=g,t[46]=_,t[47]=T):T=t[47],T}),ZI=(e,t)=>{e.thread??=kF({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=kF({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=kF({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=eI()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=kF({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},QI=e=>{let t=J(7),n=BP(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),VP(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=XI({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),LN(a)},$I=YM(QI);wP(QI,(e,t)=>{ZI(e,t),!e.tools&&t.tools.source===null&&(e.tools=aI({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=WN())});var eL=e=>{let{children:t,condition:n}=e;return $(n)?t:null};eL.displayName=`AuiIf`;var tL=YN({}),nL=({effects:e})=>{"use no memo";return PM(e),null},rL=Z(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=xP();if(rF){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==mP)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??mP:a?e.value??mP:o,c=GP(),{client:l,effects:u}=SF(s,n??tL,c);return BM(t,()=>l,[l]),(0,P.jsx)(UP.Provider,{value:c,children:(0,P.jsxs)(gP.Provider,{value:l,children:[(0,P.jsx)(nL,{effects:yP(s)}),u&&(0,P.jsx)(nL,{effects:u}),r]})})}),iL=e=>{let t=Q(),n=Y(!1),r=n.current?null:e(t);return $(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},aL=Object.freeze({});function oL(e){let t=J(3),{getItemState:n,children:r}=e,i=iL(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],sL(a)}var sL=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return MM(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?aL:t?.props])??e},cL=(e,t)=>{let n=J(11),r=Q(),i=FM(t),a;n[0]===e?a=n[1]:(a=EP(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],X(c,l)},lL=e=>e._core?.RenderComponent,uL=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=lL(e),a=YN({...n,threads:$I(e)});return(0,P.jsxs)(rL,{extends:t,config:a,children:[i&&(0,P.jsx)(i,{}),r]})},dL=VM(e=>{let t=J(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,P.jsx)(uL,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s});function fL(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pL(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>pL(e,t+1)):fL(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&pL(n,t+1)):!1}var mL=100,hL=(e,t,n)=>{if(e===t)return!0;if(n>mL||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>hL(e,t[r],n+1));if(Array.isArray(t)||!fL(e)||!fL(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&hL(e[r],t[r],n+1))},gL=(e,t)=>!pL(e)||!pL(t)?!1:hL(e,t,0);function _L(e){let t=Y(e);return t.current!==e&&!gL(t.current,e)&&(t.current=e),t.current}function vL(e){let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&gL(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r}var yL=Symbol.for(`aui.tool-response`),bL=`<no result>`,xL=class e{get[yL](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?bL:t,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&yL in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?bL:t})}},SL=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},CL=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o=0,s,c,l=()=>(a=void 0,c??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),c),u=e=>{n||r||(r=!0,console.error(e),l(),i.error(e),s?.reject(e),s=void 0)},d=a=>{a.promise||=a.reader.read().then(({done:c,value:l})=>{a.promise=void 0,!(n||r)&&(c?(e.splice(e.indexOf(a),1),a.reader.releaseLock(),t&&e.length===0&&o===0&&i.close()):i.enqueue(l),s?.resolve(),s=void 0)}).catch(u)},f=new ReadableStream({start(e){i=e},pull(){return s=SL(),e.forEach(e=>{d(e)}),s.promise},async cancel(){n=!0;let e=l();s?.resolve(),s=void 0,await e}}),p=c=>{if(e.length>0&&(a=void 0),!a){let c=[];a=c,o++,Promise.resolve().then(()=>{if(o--,a===c&&(a=void 0),!(n||r)){for(let e of c)i.enqueue(e);t&&e.length===0&&o===0&&i.close(),s?.resolve(),s=void 0}}).catch(u)}a.push(c)};return{readable:f,isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&o===0&&i.close())},addStream:(i,o)=>{let s=o?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);a=void 0;let c={reader:i.getReader(),pipeTask:s};e.push(c),d(c)},enqueue(e){if(!(n||r)){if(t)throw Error(`Cannot add streams after the run callback has settled.`);p(e)}}}},wL=e=>e instanceof TypeError,TL=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!wL(e))throw e;n?.(e)}},EL=e=>{try{e.close()}catch(e){if(!wL(e))throw e}},DL=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),OL=(e,t)=>{let n;return[DL({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},kL=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};if(this._isClosed){if(this._strict)throw TypeError(`Cannot append to a closed TextStreamController`);return TL(this._controller,t,this._warnDroppedAfterClose),this}return TL(this._controller,t),this}_warnDroppedAfterClose=e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))};close(){this._isClosed||(this._isClosed=!0,TL(this._controller,{type:`part-finish`,path:[]}),EL(this._controller))}},AL=(e,t={})=>DL(e,e=>new kL(e,t)),jL=(e={})=>OL(t=>new kL(t,e)),ML=class{_isClosed=!1;_mergeTask;_controller;constructor(e,t={}){this._controller=e;let n=AL({start:e=>{this._argsTextController=e}},t),r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:r=!0,TL(this._controller,e);break;case`part-finish`:r||TL(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),TL(this._controller,{type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;TL(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?bL:t,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,TL(this._controller,{type:`part-finish`,path:[]}),EL(this._controller))}},NL=(e={})=>OL(t=>new ML(t,e)),PL=class{value=-1;up(){return++this.value}},FL=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var IL=class extends TransformStream{constructor(e){let t=new PL,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},LL=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},RL=LL(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),zL=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:CL(),contentCounter:new PL}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new FL(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new IL(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=jL({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=jL({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??RL(),[i,a]=NL({strict:this._state.strict});return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function BL(e,t={}){let n=new zL(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function VL(e={}){let{resolve:t,promise:n}=SL(),r;return[BL(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var HL=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},UL=r(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),WL=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},GL=/[0-9a-fA-F]/;function KL(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!GL.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`+`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var qL=n(UL(),1),JL=Symbol(`aui.parse-partial-json-object.meta`),YL=e=>e?.[JL],XL=e=>{if(e.length===0)return{[JL]:{state:`partial`,partialPath:[]}};try{let t=qL.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[JL]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=KL(e),r=qL.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[JL]={state:`partial`,partialPath:n},r}catch{return}}},ZL=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return ZL(s,{state:`partial`,partialPath:o},i)},QL=(e,t)=>{let n=YL(e);if(!n)throw Error(`unable to determine object state`);return ZL(e,n,t.map(String))},$L=new Set([`__proto__`,`constructor`,`prototype`]);function eR(e){if($L.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var tR=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);let r=[],i=e;for(let e=0;e<t.length;e++){if(i??={},typeof i!=`object`)throw Error(`Invalid path: [${t.slice(e).join(`, `)}]`);let n=t[e];if(eR(n),Array.isArray(i)){let a=Number(n);if(!Number.isInteger(a)||String(a)!==String(n))throw Error(`Expected array index at [${t.slice(e).join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>i.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${i.length}`)),a=i.length}r.push({kind:`array`,state:i,key:a}),i=Object.hasOwn(i,a)?i[a]:void 0}else{let e=i;r.push({kind:`object`,state:e,key:n}),i=Object.hasOwn(e,n)?e[n]:void 0}}let a=n(i);for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.kind===`array`){let e=[...t.state];e[t.key]=a,a=e}else{let e={...t.state};e[t.key]=a,a=e}}return a}},nR=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},rR=(e,t)=>({...e,parts:t,get content(){return this.parts}}),iR=(e,t)=>rR(e,[...e.parts,t]),aR=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),oR=16,sR=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:rR(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},cR=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return iR(e,{type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`tool-call`)return iR(e,{type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}});if(r.type===`source`)return iR(e,{type:`source`,sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`file`)return iR(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return iR(e,{type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}});{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),iR(e,{type:`reasoning`,text:``,status:{type:`running`}})}},lR=(e,t,n)=>sR(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`,status:e.status.type===`running`?{type:`running`,isArgsComplete:!0}:e.status}:e:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),uR=(e,t,n)=>sR(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),dR=(e,t,n)=>sR(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=XL(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),fR=(e,t,n)=>sR(e,t,n,e=>e.type===`tool-call`?{...e,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}:(n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e)),pR=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=mR(t);return{...e,status:n}},mR=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},hR=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),gR=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),_R=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),vR=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:RL(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},yR=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},bR=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),xR=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},SR=(e,t,n=0)=>{let r=n>0?n:xR(t);if(r>0)return e.getTiming(r);let i=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(i+=e.text);return e.getTiming(void 0,i||void 0)},CR=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},wR=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??aR(),a,o,s=new nR,c=new Set,l=(e,t)=>{c.has(e)||c.size>=oR||(c.add(e),console.warn(t))},u,d=t?CR(()=>{u?.enqueue(i)}):()=>{u?.enqueue(i)};super({start(e){u=e},transform(e){s.recordChunk();let t=e.type;switch(t){case`part-start`:i=cR(i,e,l),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=lR(i,e,l);break;case`part-finish`:i=uR(i,e,l);break;case`text-delta`:{let t=dR(i,e,l);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=fR(i,e,l);break;case`message-finish`:o=e.usage?.outputTokens,i=pR(i,e);break;case`annotations`:i=hR(i,e);break;case`data`:i=gR(i,e);break;case`step-start`:i=_R(i,e);break;case`step-finish`:i=vR(i,e);break;case`error`:i=yR(i,e),n?.(e.error);break;case`update-state`:a??=new tR(i.metadata.unstable_state,{strict:r}),i=bR(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:SR(s,i,o)}}),d()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&e.result===void 0)??!1;i=pR(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:SR(s,i,o)}},e.enqueue(i)}}})}};async function*TR(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function ER(e){return e[Symbol.asyncIterator]??=TR,e}var DR=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new wR))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return ER(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function OR(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function kR(e,t){let n=e;for(let e of t){if(n==null||!Object.hasOwn(n,e))return;n=n[e]}return n}var AR=class{resolve;reject;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(QL(e,this.fieldPath)===`complete`){let t=kR(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=kR(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},jR=class{controller;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=kR(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),QL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},MR=class{controller;disposed=!1;fieldPath;lastValue=void 0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=kR(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}QL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},NR=class{controller;disposed=!1;fieldPath;nextIndex=0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=kR(e,this.fieldPath);if(!Array.isArray(t))return;for(;this.nextIndex<t.length&&QL(e,[...this.fieldPath,this.nextIndex])===`complete`;this.nextIndex++)this.controller.enqueue(t[this.nextIndex]);QL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},PR=class{argTextDeltas;handles=new Set;accumulatedText=``;parsedTextLength=-1;args=void 0;finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=this.argTextDeltas.getReader();for(;;){let{value:t,done:n}=await e.read();if(n)break;this.accumulatedText+=t,this.handles.size!==0&&this.parseCurrentArgs()&&this.updateHandles()}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}parseCurrentArgs(){if(this.parsedTextLength===this.accumulatedText.length)return!1;let e=XL(this.accumulatedText);return this.parsedTextLength=this.accumulatedText.length,e===void 0?(this.args??=XL(``),!1):(this.args=e,!0)}updateHandles(){for(let e of this.handles)e.update(this.args),e.isDisposed&&this.handles.delete(e)}activateHandle(e){if(this.parseCurrentArgs(),e.update(this.args),!e.isDisposed){if(this.finished){e.end(this.args);return}this.handles.add(e)}}get(...e){return new Promise((t,n)=>{let r=new AR(t,n,e);this.activateHandle(r)})}streamValues(...e){let t=e,n;return ER(new ReadableStream({start:e=>{n=new jR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return ER(new ReadableStream({start:e=>{n=new MR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return ER(new ReadableStream({start:e=>{n=new NR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},FR=class{promise;constructor(e){this.promise=e}get(){return this.promise}},IR=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new PR(e.readable);let{promise:t,resolve:n}=SL();this.resolve=n,this.response=new FR(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},LR=Symbol.for(`assistant-stream.tool-execution-id`),RR=(e,t,n,r,i)=>{try{let a=t?.(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},zR=e=>e.join(`,`),BR=(e,t)=>{let n={...e};return Object.defineProperty(n,LR,{value:t,enumerable:!0}),n},VR=class extends HL{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({async transform(e,s){let c=a.get(zR(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?BR(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new IR,o=Symbol();a.set(String(n),o),r.set(o,i),t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(zR(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);await n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(zR(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new xL({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent,messages:e.messages})),i.add(t);break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(zR(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(await u.finishArgsText(),i.has(l))break;let d=!1,f=OR(()=>{let e;try{e=qL.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,RR(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&RR(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new xL({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),TL(s,BR({type:`result`,path:e.path,...r},l))},n=>{d&&RR(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new xL({result:String(n),isError:!0});u.setResponse(r),TL(s,BR({type:`result`,path:e.path,...r},l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(zR(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(zR(e.path)))};o?o.then(()=>{c(),TL(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new WL).pipeThrough(s)})}},HR=Symbol.for(`assistant-stream.tool-execution-id`),UR=Symbol(`assistant-stream.tool-aborted`),WR=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,GR=e=>typeof e?.then==`function`,KR=async(e,t,n=!1)=>{let r,i=new Promise(e=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>e(UR))):e(UR)},t.aborted?r():t.addEventListener(`abort`,r,{once:!0})});try{return await Promise.race([e,i])}finally{t.removeEventListener(`abort`,r)}},qR=()=>new xL({result:`Tool execution was cancelled.`,isError:!0});function JR(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return qR();let a=e;if(WR(i.parameters)){let e=i.parameters[`~standard`].validate(n.args),r=GR(e)?await KR(e,t):e;if(r===UR)return qR();r.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(r.issues)}`)}))}if(t.aborted)return qR();let o=await KR((async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[HR]:n.executionId},o=await a(n.args,e),s=xL.toResponse(o);if(i.toModelOutput&&!s.isError&&s.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:s.result});return new xL({result:s.result,artifact:s.artifact,isError:s.isError,messages:s.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return s})(),t,!0);return o===UR?qR():o})(i.execute):void 0}function YR(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[HR]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function XR(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new VR({execute:e=>JR(i(),a(),e,s),streamCall:({reader:e,...t})=>YR(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}var ZR=new Set([`http://json-schema.org/draft-07/schema`,`https://json-schema.org/draft-07/schema`]);function QR(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}function $R(e){return typeof e==`object`&&!!e&&`toJSONSchema`in e&&typeof e.toJSONSchema==`function`}function ez(e){return typeof e==`object`&&!!e&&`toJSON`in e&&typeof e.toJSON==`function`}function tz(e){if(typeof e==`object`&&e){let t=e.$schema;if(typeof t==`string`&&!ZR.has(t.replace(/#$/,``)))throw Error(`The schema library was asked for a draft-07 JSON Schema and returned "${t}". Upgrade the library, or pass a plain JSON Schema object instead.`)}return e}function nz(e){if(QR(e)){let t=e[`~standard`].jsonSchema;if(typeof t==`object`&&t&&typeof t.input==`function`)return tz(t.input({target:`draft-07`}))}if($R(e))return e.toJSONSchema({target:`draft-07`});if(ez(e))return e.toJSON();if(QR(e)){let{vendor:t}=e[`~standard`],n=t===`zod`?`convert it with z.toJSONSchema(schema)`:`wrap the schema with ${t}'s Standard JSON Schema helper`;throw Error(`Could not convert the "${t}" schema to JSON Schema: it has no "~standard.jsonSchema" converter. Upgrade ${t} to a release that implements Standard JSON Schema, ${n}, or pass a plain JSON Schema object instead.`)}return e}function rz(e){let{required:t,...n}=e;return n.properties&&=Object.fromEntries(Object.entries(n.properties).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?[e,rz(t)]:[e,t])),n}function iz(e){return _L(MM(()=>{try{let t=nz(e);return pL(t)?t:null}catch{return null}},[e]))}var az=e=>{let t=J(17),n=Q(),r;t[0]===e?r=t[1]:(r=t=>t.unstable_interactables.definitions[e]?.state,t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>t.unstable_interactables.persistence[e],t[2]=e,t[3]=a);let o=$(a),s;t[4]!==n||t[5]!==e?(s=t=>{n.unstable_interactables.setState(e,e=>typeof t==`function`?t(e):t)},t[4]=n,t[5]=e,t[6]=s):s=t[6];let c=s,l;t[7]===n?l=t[8]:(l=()=>n.unstable_interactables.flush(),t[7]=n,t[8]=l);let u=l,d=o?.isPending??!1,f=o?.error,p;t[9]!==u||t[10]!==c||t[11]!==d||t[12]!==f?(p={setState:c,isPending:d,error:f,flush:u},t[9]=u,t[10]=c,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==i||t[15]!==p?(m=[i,p],t[14]=i,t[15]=p,t[16]=m):m=t[16],m};function oz(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function sz(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var cz=e=>{if(!fL(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function lz(e,t,n){let r=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(r=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);r=r.filter(t=>{let n=cz(t);return n===void 0?!e.has(t):!e.has(n)})}let i=t.update;if(Array.isArray(i)&&i.length>0){let e=new Map;for(let t of i){let n=cz(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}r=r.map(t=>{let n=cz(t);if(n===void 0||!fL(t))return t;let r=e.get(n);return r?{...t,...r}:t})}if(Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!fL(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;r=[...r,...e]}return r}function uz(e,t,n){if(!fL(e)||!fL(t))return t;let r=fL(n?.arrayBaseline)?n.arrayBaseline:e,i=Object.entries(e);for(let[e,a]of Object.entries(t)){let t=r[e];if(Array.isArray(t)&&fL(a)){let r=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0;i.push([e,lz(t,a,r)])}else i.push([e,a])}return Object.fromEntries(i)}function dz(e,t){if(!fL(e)||!fL(t))return;for(let n of Object.keys(e))if(!Object.hasOwn(t,n))return;let n=[];for(let[r,i]of Object.entries(t))(!Object.hasOwn(e,r)||!gL(e[r],i))&&n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var fz=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},pz=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=fL(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},mz=e=>{let t=fL(e)?e.addedItemIds:void 0;if(!fL(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},hz=new WeakMap;function gz(e,t,n){let r=hz.get(e);r||(r=new Map,hz.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=sz(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=oz(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:uz(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=fz(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&pz(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=mz(r.result);s.push({state:i?uz(e.state,n,{idFactory:i}):uz(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function _z(e,t,n){let r=gz(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function vz(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=_z(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(gL(r.state,n.state))continue;let i=dz(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var yz=(e,t)=>{let n=Q(),r=zM().replace(/[^a-zA-Z0-9]/g,``),i=sz(e),a=$(e=>{let t=e.optional.part;return t?.type===`tool-call`?t:void 0}),o;if(a?.toolName===i){let e=a.result,t=a.args;e?.success!==!1&&(typeof e?.id==`string`?o=e.id:typeof t?.id==`string`&&(o=t.id))}let s=t.id??o??r,c=a?.toolName===e||a?.toolName===i?`thread`:void 0,l=Y(t.stateSchema);l.current=t.stateSchema;let u=iz(t.stateSchema),d=Y(t.initialState);d.current=t.initialState;let f=$(()=>n.unstable_interactables);X(()=>f.register({id:s,name:e,description:t.description,stateSchema:l.current,initialState:d.current,updateRender:t.updateRender,...c?{scope:c}:{}}),[f,s,e,t.description,u,c,t.updateRender]);let p=a?.toolCallId,[m,h]=az(s),{setState:g}=h,_=$(vL(t=>{if(!c||!p)return;let n=gz(t.thread.messages,s,e);if(!n.some(e=>e.origin===`create`&&e.toolCallId===s))return;let r=n.find(e=>e.toolCallId===p);if(!r)return;let i=n.findLast(e=>e.toolCallId!==void 0)?.toolCallId;return{state:r.state,isLatest:i===p}})),v=MM(()=>_&&{state:_.state,isLatest:_.isLatest,restore:()=>g(_.state)},[_,g]);return[m===void 0?t.initialState:m,{id:s,version:v,...h}]},bz=KM(null),xz=(e,t)=>Qj(bz,e,t),Sz=()=>JM(bz),Cz={},wz=e=>{let t=tF(e??Cz);return e==null?null:t},Tz=Symbol(`innerMessage`),Ez=Symbol(`innerMessages`),Dz=[],Oz=(e,t)=>{Tz in e||(e[Tz]=t)},kz=e=>{let t=`messages`in e?e.messages:e,n=t[Ez]||t[Tz];return n?Array.isArray(n)?n:(t[Ez]=[n],t[Ez]):Dz},Az=`__external_store_fallback_`,jz=LL(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7);function Mz(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var Nz=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},Pz=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?Mz(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId||`tool-${jz()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:XL(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=Nz(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=Nz(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>Nz(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},Fz=e=>e.type===`tool-call`&&e.result===void 0,Iz=e=>{if(e.type!==`tool-call`||e.result!==void 0)return!1;let t=e.messages?.at(-1);return t?.role===`assistant`&&t.status.type===`running`},Lz=e=>e.type!==`tool-call`||e.result!==void 0?!1:e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,Rz=Symbol(`autoStatus`),zz=Object.freeze(Object.assign({type:`running`},{[Rz]:!0})),Bz=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[Rz]:!0})),Vz=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[Rz]:!0})),Hz=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[Rz]:!0})),Uz=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[Rz]:!0})),Wz=e=>e[Rz]===!0,Gz=(e,t,n,r,i,a,o)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[Rz]:!0}):e&&t?zz:n?Uz:o&&!a?zz:r?Hz:a?Vz:Bz,Kz=e=>Gz(!1,!1,typeof e!=`string`&&e.some(Lz),typeof e!=`string`&&e.some(Fz)),qz=(e,t,n)=>Gz(t,n,typeof e!=`string`&&e.some(Lz),typeof e!=`string`&&e.some(Fz),void 0,void 0,typeof e!=`string`&&e.some(Iz)),Jz=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},Yz=(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},Xz=500,Zz=({adapterRef:e,snapshot:t,updatePersistenceStatus:n})=>{let r=Y(void 0),i=Y(0),a=Y(new Map),o=Y(0),s=Y([]),c=Y(new Set),l=Y([]),u=Y(()=>{}),d=NM(e=>{if(c.current.size===0)return;let n=new Set(c.current);c.current.clear();let r=++i.current;for(let e of n)a.current.set(e,r);return{adapter:e,payload:t(),dirtyIds:n,seq:r}},[t]),f=NM(e=>{let t=d(e);t&&(o.current===0?u.current(t):l.current.push(t))},[d]),p=NM(async t=>{let i=t??(e.current?d(e.current):void 0);if(!i){if(o.current===0){for(let e of s.current)e();s.current=[]}return}let{adapter:f,payload:p,dirtyIds:m,seq:h}=i;o.current+=1,n(e=>{let t=Mj(e);for(let e of m)t[e]={isPending:!0,error:void 0};return t});let g=e=>{let t=[];for(let e of m)a.current.get(e)!==h||c.current.has(e)||(a.current.delete(e),t.push(e));t.length!==0&&n(n=>{let r=!1,i=Mj(n);for(let a of t)n[a]!==void 0&&(e===void 0?delete i[a]:i[a]=e,r=!0);return r?i:n})};try{await f.save(p),g(void 0)}catch(e){g({isPending:!1,error:e})}finally{--o.current;let t=l.current.shift()??(e.current&&c.current.size>0?d(e.current):void 0);if(t)r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),u.current(t);else if(o.current===0){for(let e of s.current)e();s.current=[]}}},[e,d,n]);return u.current=e=>{p(e)},{flushIfPending:NM(()=>{r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),e.current&&f(e.current)},[e,f]),schedulePersistence:NM(t=>{e.current&&(c.current.add(t),r.current!==void 0&&clearTimeout(r.current),r.current=setTimeout(()=>{r.current=void 0,o.current===0&&e.current?f(e.current):r.current=setTimeout(()=>{r.current=void 0,e.current&&f(e.current)},Xz)},Xz))},[e,f]),flush:NM(async()=>{if(r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),!(o.current>0||c.current.size>0||l.current.length>0))return;let t=new Promise(e=>{s.current.push(e)});return e.current&&f(e.current),t},[e,f])}},Qz={type:`string`,description:`The id of the instance to update, as shown in its state snapshot in the conversation.`},$z={type:`string`,description:`The id of an item currently in this list.`},eB=e=>{let t=e.properties;return fL(t)&&t.id!==void 0},tB=e=>({...e,required:[`id`]}),nB=e=>{let{id:t,...n}=fL(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(e=>e!==`id`):e.required;return{...e,properties:n,required:r}},rB=(e,t)=>{if(!fL(e)||e.type!==`array`)return e;let n=e.items;if(Array.isArray(n)||!fL(n))return e;let r=eB(n),i={add:{type:`array`,items:r?nB(n):n},remove:{type:`array`,items:r?$z:n},clear:{type:`boolean`}};return r&&(i.update={type:`array`,items:tB(n)}),{type:`object`,description:`Operations for array field "${t}". To change one item use update with its id; add new items (their ids are assigned for you), remove items by id, or clear to empty. Change only the items you mean to — never resend the whole array to edit one item.`,properties:i,additionalProperties:!1}},iB=e=>{let t=new Set;for(let[n,r]of Object.entries(e))fL(r)&&r.type===`array`&&fL(r.items)&&eB(r.items)&&t.add(n);return t},aB=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,rB(t,e)]));function oB(e){if(!e||typeof e!=`object`||e.type!==`object`)return{type:`object`,properties:{id:Qz},required:[`id`],additionalProperties:!0};let{id:t,...n}=e.properties??{};return{...e,properties:{id:Qz,...aB(n)},required:[`id`]}}function sB(e,t,n,r=new Map){let i=Object.values(e);if(i.length===0)return;let a=new Map;for(let e of i){let t=a.get(e.name)??[];t.push(e),a.set(e.name,t)}let o={};for(let[i,s]of a){let a=sz(i);if(o[a])continue;let c=s[0],l=t.get(c.id),u=l&&fL(l.properties)?iB(l.properties):new Set,d=t=>{if(typeof t==`string`){let n=e[t];return n?.name===i?n:void 0}return s.length===1?c:void 0};o[a]={type:`frontend`,description:`Update the state of interactable component "${i}". ${c.description} Pass the id of the instance to update — instance ids and current state appear in the conversation as state snapshots. Only include the fields you want to change; omitted fields keep their current values.`,parameters:oB(l),streamCall:async(e,{toolCallId:t})=>{try{for await(let i of e.args.streamValues()){if(!i||typeof i!=`object`)continue;let e=i,a=Object.keys(e);if(a.indexOf(`id`)===a.length-1)continue;let{id:o,...s}=e;if(Object.keys(s).length===0)continue;let c=d(o);if(!c)continue;let l=r.get(t),u=l?.targetId===c.id?l.state:c.state;(!l||l.targetId!==c.id)&&r.set(t,{targetId:c.id,state:c.state}),n(c.id,e=>uz(e,s,{arrayBaseline:u}))}}catch{}},execute:async(e,{toolCallId:t})=>{let{id:a,...o}=e??{},c=d(a);if(!c){let e=s.map(e=>e.id);return{success:!1,error:`Unknown id ${JSON.stringify(a)} for interactable "${i}". Valid ids: ${e.join(`, `)}`}}let l=r.get(t);r.delete(t);let f=Mj();n(c.id,e=>uz(e,o,{arrayBaseline:l?.targetId===c.id?l.state:void 0,idFactory:e=>{let t=jz();return(f[e]??=[]).push(t),t},idKeyedFields:u}));let p={success:!0,id:c.id};return Object.keys(f).length>0&&(p.addedItemIds={...f}),p}}}return{tools:o,unstable_composerMetadata:{interactables:i.map(e=>({id:e.id,name:e.name,state:e.state}))}}}var cB=(e,t,n)=>e.some(e=>e.role===`assistant`&&e.content?.some(e=>{if(!e||typeof e!=`object`)return!1;let r=e;return r.type===`tool-call`&&r.toolCallId===t&&r.toolName===n})),lB=({persistence:e}={})=>{let[t,n]=AM(()=>({definitions:Mj(),persistence:Mj()})),r=BP(),i=Y(t),a=Y(new Set),o=Y(new Map),s=Y(new Map),c=Y(new Map),l=Y(new Map),u=Y(new Map),d=Y(new Map),f=Y(new Map),p=Y(new Map),m=Y(new Set),h=Y(void 0),g=NM(e=>{let t=e(i.current);i.current=t,n(t)},[]),_=NM(()=>{let e=Mj();for(let[t,n]of Object.entries(i.current.definitions))n.scope!==`thread`&&(e[t]={name:n.name,state:n.state});return e},[]),{flushIfPending:v,schedulePersistence:y,flush:b}=Zz({adapterRef:h,snapshot:_,updatePersistenceStatus:NM(e=>{g(t=>{let n=e(t.persistence);return n===t.persistence?t:{...t,persistence:n}})},[g])}),x=NM((e,t)=>{let n=t.shouldStash??(()=>!0),r=t.shouldApply??(()=>!0);for(let[r,i]of Object.entries(e))n(r)&&t.stash.set(r,i.state);g(t=>{let n=!1,i=Mj(t.definitions);for(let[t,a]of Object.entries(e)){let e=i[t];e&&r(t,e)&&(i[t]={...e,state:a.state},n=!0)}return n?{...t,definitions:i}:t})},[g]),S=NM(e=>{x(e,{stash:l.current})},[x]),C=NM(e=>{x(e,{stash:p.current,shouldStash:e=>!m.current.has(e),shouldApply:(e,t)=>!m.current.has(e)&&t.scope!==`thread`})},[x]),w=NM(async e=>{if(e.load)try{let t=await e.load();if(!t||h.current!==e)return;C(t)}catch(e){console.warn(`[Interactables] Persistence load failed.`,e)}},[C]),T=NM(e=>{h.current!==e&&v(),h.current=e,e&&w(e)},[v,w]),E=NM(()=>{let e=r.current;if(!e)return;let t=e.threadListItem;if(t.source!=null)return t().getState().id;let n=e.threads;if(n.source!=null)return n().getState().mainThreadId},[r]);X(()=>{if(e)return T(e),()=>{h.current===e&&T(void 0)}},[e,T]);let D=NM((e,t)=>{m.current.add(e),g(n=>{let r=n.definitions[e];return r?{...n,definitions:Mj(n.definitions,{[e]:{...r,state:t(r.state)}})}:n}),i.current.definitions[e]?.scope!==`thread`&&y(e)},[y,g]),O=MM(()=>({getModelContext:()=>{let e=i.current.definitions;return sB(e,o.current,D,c.current)??{}},subscribe:e=>(a.current.add(e),()=>{a.current.delete(e)})}),[D]);X(()=>{zF(a.current)},[t]),VP(`modelContext`,()=>r.current.modelContext().register(O),[O]);let k=NM((e,t)=>{let n=r.current?.tools;return!n||n.source==null?!1:(t.unsubscribe=n().setToolUI(sz(e),t.render,{standalone:!0}),!0)},[r]);return VP(`tools`,()=>{for(let[e,t]of f.current)t.unsubscribe?.(),t.unsubscribe=void 0,k(e,t);return()=>{for(let e of f.current.values())e.unsubscribe?.(),e.unsubscribe=void 0}},[k]),{getState:()=>i.current,register:NM(e=>{let t=r.current?.thread,n=t&&t.source!=null?t().getState().messages??[]:[],i=e.scope??(cB(n,e.id,e.name)?`thread`:`app`);d.current.set(e.id,(d.current.get(e.id)??0)+1);let a;if(e.updateRender){let t=f.current.get(e.name),n=t??{count:0,render:e.updateRender,unsubscribe:void 0};n.count++,t||f.current.set(e.name,n),!n.unsubscribe&&k(e.name,n),a=()=>{let t=f.current.get(e.name);t&&--t.count===0&&(f.current.delete(e.name),t.unsubscribe?.(),t.unsubscribe=void 0)}}if(s.current.get(e.id)!==e.stateSchema){s.current.set(e.id,e.stateSchema),o.current.delete(e.id);try{let t=nz(e.stateSchema);o.current.set(e.id,rz(t))}catch(t){console.warn(`[Interactables] Failed to create partial schema for "${e.name}". The update tool will accept arbitrary fields without validation.`,t)}}let c=i===`thread`?E():void 0,m=i===`thread`?c?u.current.get(c)?.get(e.id):void 0:l.current.get(e.id);i===`thread`?c&&u.current.get(c)?.delete(e.id):l.current.delete(e.id);let h=i===`thread`?void 0:p.current.get(e.id),_=i===`thread`?_z(n,e.id,e.name):void 0;return g(t=>({...t,definitions:Mj(t.definitions,{[e.id]:{id:e.id,name:e.name,description:e.description,stateSchema:e.stateSchema,initialState:e.initialState,scope:i,state:t.definitions[e.id]?.state??m??_?.state??h??e.initialState}})})),()=>{a?.();let t=(d.current.get(e.id)??1)-1;if(t>0){d.current.set(e.id,t);return}d.current.delete(e.id),v(),g(t=>{let n=t.definitions[e.id];if(n){if(n.scope===`thread`){let t=E();if(t){let r=u.current.get(t);r||(r=new Map,u.current.set(t,r)),r.set(e.id,n.state)}}else l.current.set(e.id,n.state)}s.current.delete(e.id),o.current.delete(e.id);let r=Mj(t.definitions),i=Mj(t.persistence);return delete r[e.id],delete i[e.id],{...t,definitions:r,persistence:i}})}},[v,r,E,k,g]),setState:D,exportState:_,importState:S,setPersistenceAdapter:T,flush:b}},uB=YM(lB);wP(lB,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=eI())});var dB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({attachment:kF({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},fB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({attachment:kF({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},pB=e=>{let t=J(6),{runtime:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({threadListItem:qI({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},mB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({message:kF({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:kF({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},hB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({part:kF({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},gB=YM(e=>{let t=J(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:vB,resumeToolCall:yB,respondToToolApproval:bB},t[5]=o,t[6]=s),s}),_B=e=>{let t=J(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=Q(),s;t[0]!==a||t[1]!==n?(s=YN({part:gB({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,P.jsx)(rL,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function vB(){throw Error(`Not supported`)}function yB(){throw Error(`Not supported`)}function bB(){throw Error(`Not supported`)}var xB=e=>{for(let t of e)if(t?.status.type===`running`)return AI;return e.at(-1)?.status??kI},SB=(e,t)=>{let n={running:0,complete:0,incomplete:0,requiresAction:0},r=kI,i=!1;for(let a of t)switch(r=e[a]?.status??kI,r.type){case`running`:n.running++,i=!0;break;case`complete`:n.complete++;break;case`incomplete`:n.incomplete++;break;case`requires-action`:n.requiresAction++}return{status:i?AI:r,counts:n}},CB=YM(e=>{let t=J(11),{parts:n,getMessagePart:r}=e,[i,a]=AM(!0),o;t[0]===n?o=t[1]:(o=xB(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),wB=e=>{let t=J(4),{startIndex:n,endIndex:r,children:i}=e,a=$(TB).slice(n,r+1),o=Q(),s=YN({chainOfThought:CB({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message.part({index:n+t})}})}),c;return t[0]!==i||t[1]!==s||t[2]!==o?(c=(0,P.jsx)(rL,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function TB(e){return e.message.parts}var EB=e=>{let t=J(7),{index:n,archived:r,children:i}=e,a=Q(),o;t[0]!==r||t[1]!==n?(o=YN({threadListItem:kF({source:`threads`,query:{type:`index`,index:n,archived:r},get:e=>e.threads.item({index:n,archived:r})})}),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==a||t[4]!==i||t[5]!==s?(c=(0,P.jsx)(rL,{extends:a,config:s,children:i}),t[3]=a,t[4]=i,t[5]=s,t[6]=c):c=t[6],c},DB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({suggestion:kF({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},OB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({queueItem:kF({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},kB=Symbol.for(`assistant-ui.message-not-sent`),AB=e=>typeof e==`object`&&!!e&&kB in e,jB=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},MB=class extends jB{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},NB=class extends MB{get source(){return`thread-composer`}},PB=class extends MB{get source(){return`edit-composer`}},FB=class extends jB{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},IB=Object.freeze([]),LB=Object.freeze({}),RB=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??IB,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??LB,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??IB,value:e?.text??``}),zB=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??IB,runConfig:e?.runConfig??LB,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??IB,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),BB=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new JF({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},VB=class extends BB{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new KF({path:e.path,getState:()=>RB(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new NB(new GF({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:RF},subscribe:e=>this._core.subscribe(e)}),this._core)}},HB=class extends BB{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new KF({path:e.path,getState:()=>zB(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new PB(new GF({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:RF},subscribe:e=>this._core.subscribe(e)}),this._core)}},UB=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
91
91
 
92
- `),VB=`ui://`,HB=e=>!!e?.startsWith(VB),UB=e=>e.display===`text`||e.allowFreeform===!0,WB={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},GB=(e,t)=>{let n=t.text;if(n!==void 0&&!UB(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){let n=e.options?.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(WB,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=WB[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:e.id,approved:r,...i!==void 0&&{optionId:i},...n!==void 0&&{text:n},...t.reason!=null&&{reason:t.reason}}},KB=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=vL.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,isError:a.isError,...a.artifact!==void 0&&{artifact:a.artifact},...a.modelContent!==void 0&&{modelContent:a.modelContent}})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);return this.threadApi.getState().respondToToolApproval(GB(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},qB=(e,t)=>{let n=e.content[t];if(!n)return FF;let r=AI(e,t,n);return Object.freeze({...n,[Sz]:n[Sz],status:r})},JB=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new zB(new WF({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e,comment:t}){let n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:e,...t===void 0?void 0:{comment:t}})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return BB(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new KB(new HF({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>qB(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new KB(new HF({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?FF:qB(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new MB(new HF({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:FF},subscribe:e=>this._core.subscribe(e)}))}},YB=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),XB=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),ZB=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId===void 0?e.at(-1)?.id??null:t.parentId,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},QB=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},$B=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:QB(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),eV=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new HF({path:e.path,getState:()=>$B(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>LF([r,i])}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new RB(new WF({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){let t=this._threadBinding.getState().append(ZB(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!DB(e))throw e})}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(XB(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(YB(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new JB(new HF({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return FF;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[Sz]:e[Sz],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new GF({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},tV=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),nV=class extends zF{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},rV=e=>{let t=J(6),{adapters:n,children:r}=e,i=GM(_z),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,P.jsx)(_z.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},iV=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(e){let t=this._core.getState();return this._threadListBinding.generateTitle(t.id,e)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,(e!==`switchedTo`||a)&&(e===`switchedAway`&&a||GN([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},aV=Promise.resolve(),oV=()=>{},sV=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,loadError:e.loadError,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),cV=(e,t)=>{if(t===void 0)return FF;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:FF},lV=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=eV){this._core=e,this._runtimeFactory=t;let n=new UF({path:{},getState:()=>sV(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new iV(new HF({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>cV(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new WF({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){return this._core.unstable_subscribeThreadEvents?.(e)??oV}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??aV}reloadMainThread(){return this._core.reloadMainThread?.()??aV}loadMore(){return this._core.loadMore?.()??aV}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new HF({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>cV(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new WF({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(e))}getItemByIndex(e){return new iV(new HF({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>cV(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new iV(new HF({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>cV(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new iV(this._createItemStateBinding(e),this._core)}},uV=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new lV(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},dV=new WeakMap,fV=e=>dV.get(e)??0,pV=(e,t)=>fV(e)===t,mV=e=>{dV.set(e,fV(e)+1)},hV=class{_contextProvider=new KF;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},gV=Object.freeze([]),_V=`DEFAULT_THREAD_ID`,vV=Object.freeze([_V]),yV=Object.freeze({id:_V,remoteId:void 0,externalId:void 0,status:`regular`}),bV=Promise.resolve(),xV=Object.freeze(kj({[_V]:yV})),SV=class extends zF{_mainThreadId=_V;_threads=vV;_archivedThreads=gV;_threadData=xV;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return bV}_mainThread;get mainThreadId(){return this._mainThreadId}threadFactory;constructor(e={},t){super(),this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return Object.hasOwn(this._threadData,e)?this._threadData[e]:void 0}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??_V,i=e.threads??gV,a=e.archivedThreads??gV,o=n.threadId??_V,s=n.threads??gV,c=n.archivedThreads??gV;(t||(n.isLoading??!1)!==(e.isLoading??!1)||o!==r||s!==i||c!==a)&&((s!==i||c!==a||o!==r)&&(this._threadData=kj(xV,Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[]))),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??gV),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??gV),(t||o!==r)&&(t||mV(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=kj(this._threadData,{[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}})),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},CV={fromArray:e=>{let t=e.map(e=>jz(e,Oz(),Uz(e.content)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>({...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:jz(e,e.id,Uz(e.content))}})})},wV=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},TV=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},EV=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}selectPathTo(e){for(let t=e;t;t=t.prev)(t.prev??this.root).next=t}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],t.prev=e,wV(t)===this.head?this.selectPathTo(t):i.next===null&&(i.next=t,this.head===i&&(this.head=wV(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new TV(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=wV(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;this.selectPathTo(t),this.head=wV(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t,this.selectPathTo(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[],t=[...this.root.children].reverse();for(;t.length>0;){let n=this.messages.get(t.pop());if(!n)continue;for(let e=n.children.length-1;e>=0;e--)t.push(n.children[e]);if(n.current.metadata?.isOptimistic)continue;let r=n.prev;for(;r&&r.current.metadata?.isOptimistic;)r=r.prev;e.push({message:n.current,parentId:r?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},DV=Object.freeze([]);function*OV(e){for(let t of e)if(t?.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e&&e.type===`tool-call`&&(yield{part:e,messageId:t.id},e.messages?.length&&(yield*OV(e.messages)))}function kV(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=e.name.toLowerCase(),i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&r.endsWith(e)||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function AV(e){let t=Oz();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function jV(e){let t=[];for(let n of e)n.type!==`text`&&t.push(AV(n));return t}var MV=e=>`content`in e&&!(`lastModified`in e),NV=e=>e.status.type===`complete`,PV=class{operations=new Set;start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){return!e.cancelled&&(e.attachmentIds.add(t),!0)}finish(e){this.operations.delete(e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t))}cancelAll(){for(let e of this.operations)e.cancelled=!0;this.operations.clear()}},FV=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},IV=class extends zF{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_isSending=!1;_removedDuringSend=new Set;_sendGeneration=0;_attachmentAddOperations=new PV;_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._rebaseDictation(``),this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!NV(e));await Promise.all(t.map(async t=>e.remove(t)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){if(this._cancelAllAttachmentAdds(),this._isSending)for(let e of this._attachments)this._removedDuringSend.add(e.id);let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;if(this._dictationSession)try{this._dictationSession.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation()}let t=this.getAttachmentAdapter(),n=this.attachments.map(async e=>{if(NV(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)}),r=this.attachments,i=this.text,a=this._quote,o=this.role,s=this.runConfig;this._quote=void 0,this._text=``,this._isSending=!0;let c=++this._sendGeneration;this._notifySubscribers();let l;try{l=await Promise.all(n)}catch(e){throw c===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=a,this._notifySubscribers()),Promise.allSettled(n).then(()=>{c===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),e}if(c!==this._sendGeneration)return;let u=new Set(r.map(e=>e.id));this._attachments=this._attachments.filter(e=>!u.has(e.id)),this._isSending=!1,this._notifySubscribers();let d=l.filter(e=>!this._removedDuringSend.has(e.id));this._removedDuringSend.clear();let f={createdAt:new Date,role:o,content:i?[{type:`text`,text:i}]:[],attachments:d,runConfig:s,metadata:{custom:{...a?{quote:a}:{}}}},p={text:i,quote:a,attachments:d},m;try{m=this.handleSend(f,e)}catch(e){throw this._restoreUnsentDraft(e,c,p),e}m&&m.catch(e=>{this._restoreUnsentDraft(e,c,p)}),this._notifyEventSubscribers(`send`,{chars:i.length,attachments:d.length})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text===e.text&&this._quote===e.quote&&t&&(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,t,n){DB(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return DV}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(MV(e)){let t=this.getAttachmentAdapter();if(t&&!kV({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.contentType),r}let n={id:e.id??Oz(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{...n.contentType?{contentType:n.contentType}:void 0});return}let t=this.getAttachmentAdapter();if(!t){let t=`Attachments are not supported`,n=Error(t);throw this._safeEmitAttachmentAddError(`no-adapter`,t,void 0,n,e.type),n}if(!kV({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.type),r}let n=this._attachmentAddOperations.start(),r=e=>{if(!this._attachmentAddOperations.accept(n,e.id))return!1;let t=this._attachments.findIndex(t=>t.id===e.id);return this._attachments=t===-1?[...this._attachments,e]:[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers(),!0},i;try{await FV(t.add({file:e}),e=>(i=e,r(e)))}catch(t){if(this._attachmentAddOperations.isCancelled(n))return;throw i&&r({...i,status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}}),this._safeEmitAttachmentAddError(`adapter-error`,t instanceof Error?t.message:String(t),i?.id,t instanceof Error?t:void 0,i?.contentType||e.type),t}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(i?.status.type===`incomplete`&&i.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,i.status.message??`Attachment upload did not complete successfully.`,i.id,void 0,i.contentType||e.type):this._notifyEventSubscribers(`attachmentAdd`,{...i?.contentType?{contentType:i.contentType}:e.type?{contentType:e.type}:void 0}))}_safeEmitAttachmentAddError(e,t,n,r,i){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r},...i?{contentType:i}:void 0})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!NV(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!NV(t)?{...t,status:{type:`incomplete`,reason:`error`,message:n}}:t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);let t=this._dictationSession!==void 0;if(this._dictationSession){let e=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(e)}let n=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let r;try{r=e.listen()}catch(e){if(t)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Dictation replacement rollback notification threw`,e)}throw e}this._dictationSession=r;let i=++this._dictationSessionIdCounter;this._activeDictationSessionId=i,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();let a=r.onSpeech(e=>{if(!this._isActiveSession(i,r))return;let t=e.isFinal!==!1,n=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+n+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=n+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(a);let o=r.onSpeechStart(()=>{this._isActiveSession(i,r)&&(this._dictation={status:{type:`running`},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);let s=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:i})});this._dictationUnsubscribes.push(s);let c=setInterval(()=>{this._isActiveSession(i,r)&&r.status.type===`ended`&&this._cleanupDictation({sessionId:i})},100);this._dictationUnsubscribes.push(()=>clearInterval(c))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;this._stopDictationSession(e,()=>this._cleanupDictation({sessionId:t}))}_stopDictationSession(e,t=()=>{}){let n;try{n=e.stop()}catch(e){console.error(`[assistant-ui] Dictation session stop threw`,e),t();return}n.then(t,e=>{console.error(`[assistant-ui] Dictation session stop rejected`,e),t()})}_cleanupDictation(e){if(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;let t=e=>{try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}};try{let n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``;for(let e of n)t(e);e?.notify!==!1&&t(()=>this._notifySubscribers())}finally{this._isCleaningDictation=!1}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&GN(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},LV=e=>e.capabilities?.cancel?QB(e):!1,RV=class extends IV{get canCancel(){return LV(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this.runtime.voice&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??DV,t=this.runtime.getQueueItems?.()??DV,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.runtime.voice!==void 0,r=this.queue;return this.runtime.subscribe(()=>{let i=!1,a=this.canCancel;e!==a&&(e=a,i=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,i=!0);let o=this.runtime.voice!==void 0;n!==o&&(n=o,i=!0),r!==this.queue&&(r=this.queue,i=!0),i&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},zV=class extends IV{get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this.runtime.voice&&!this._isSending}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e;let i=e.voice!==void 0,a=e.subscribe(()=>{let t=e.voice!==void 0;t!==i&&(i=t,this._notifySubscribers())});this.endEditCallback=()=>{a(),t()},this._parentId=n,this._sourceId=r.id,this.setText(BB(r)),this.setRole(r.role);let o;r.role===`user`?(o=[...r.attachments??[],...jV(r.content)],this._nonTextPassthrough=[]):(o=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(o),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},BV=class extends zF{_isInitialized=!1;repository=new EV;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();if(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e){let t=new Set(e.map(e=>e.id));this._cachedMergedMessages=[...e,...this._voiceMessages.filter(e=>!t.has(e.id))],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new RV(this);_contextProvider;constructor(e){super(),this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=hz(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}_isVoiceMessage(e){return e!==null&&this._voiceMessages.some(t=>t.id===e)}_resolveAppendParent(e){return this._isVoiceMessage(e)?this._getBaseMessages().at(-1)?.id??null:e}beginEdit(e){if(this.voice)throw Error(`Cannot edit a message while a voice session is connected`);if(this._isVoiceMessage(e))throw Error(`Voice transcript messages cannot be edited`);if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new zV(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&GN(n,t,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,t,n,r){this._notifyEventSubscribers(`toolApprovalAnswered`,{messageId:e,toolCallId:t,toolName:n,approved:r})}submitFeedback({messageId:e,type:t,comment:n}){let r=this.adapters?.feedback,i=this.getMessageById(e);if(!i)throw Error(`Message not found: ${e}`);let{message:a,parentId:o}=i,s=n?.trim(),c={type:t,...s?{comment:s}:void 0};if(r?.submit({message:a,...c}),a.role===`assistant`){let t={...a,metadata:{...a.metadata,submittedFeedback:c}},n=this._voiceMessages.findIndex(t=>t.id===e);n===-1?this.repository.addOrUpdateMessage(o,t):(this._voiceMessages[n]=t,this._currentAssistantMsg===a&&(this._currentAssistantMsg=t),this._markVoiceMessagesDirty())}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let n=this.getMessageById(e);if(!n)throw Error(`Message not found: ${e}`);let{message:r}=n,i=this._stopSpeaking,a;try{i?.(),a=t.speak(BB(r))}catch(e){if(i&&!this._stopSpeaking)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Speech rollback notification threw`,e)}throw e}let o,s=()=>{this._stopSpeaking=void 0,this.speech=void 0;let e=o;o=void 0,e?.()},c=()=>{if(this._stopSpeaking===c)try{s()}finally{a.cancel()}},l=()=>{this._stopSpeaking===c&&(a.status.type===`ended`?IF([s,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:a.status},this._notifySubscribers()))};this._stopSpeaking=c;try{if(o=a.subscribe(l),this._stopSpeaking!==c){o();return}l()}catch(e){if(this._stopSpeaking===c)try{IF([c,()=>this._notifySubscribers()])}catch(e){console.error(`[assistant-ui] Speech rollback cleanup threw`,e)}throw e}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);IF([this._stopSpeaking,()=>this._notifySubscribers()])}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){if(this.isRunning)return!0;let e=this._getBaseMessages().at(-1);return e?.role===`assistant`&&(e.status.type===`running`||e.status.type===`requires-action`)}connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);if(this._isRunActive())throw Error(`Cannot start a voice session while a run is in progress or paused on a pending tool action`);let t=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice cleanup threw before reconnect`,e)}let n;try{n=e.connect({})}catch(e){throw t&&this._voiceSession===void 0&&this._onVoiceDisconnected(),e}this._voiceSession=n;let r=[];this._voiceUnsubs=r;let i=()=>{if(this._voiceSession===n&&this._voiceUnsubs===r)return!1;try{IF(r.splice(0))}catch(e){console.error(`[assistant-ui] Detached voice setup cleanup threw`,e)}return!0};try{let e=`listening`;if(this.voice={status:n.status,isMuted:n.isMuted,mode:e},this._voiceVolume=0,this._notifySubscribers(),i()||(r.push(n.onStatusChange(t=>{this._voiceSession===n&&(t.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0,this._onVoiceDisconnected()):this.voice={status:t,isMuted:n.isMuted,mode:e},this._notifySubscribers())})),i())||(r.push(n.onModeChange(t=>{e=t,this.voice&&(this.voice={...this.voice,mode:t},this._notifySubscribers())})),i())||(r.push(n.onVolumeChange(e=>{this._voiceVolume=e,GN(this._voiceVolumeSubscribers,void 0,`Voice volume`)})),i()))return;r.push(n.onTranscript(e=>{this._handleVoiceTranscript(e)})),i()||this._onVoiceConnected()}catch(e){if(this._voiceSession===n&&this._voiceUnsubs===r){try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice rollback cleanup threw`,e)}t&&this._voiceSession===void 0&&this._onVoiceDisconnected()}else i();throw e}}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`){if(this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal){let t={id:Oz(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{modality:`voice`,custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]};this._voiceMessages.push(t),this._commitVoiceMessage(t),this._markVoiceMessagesDirty(),this._notifySubscribers()}}else{let t=e.isFinal?{type:`complete`,reason:`stop`}:{type:`running`};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:Oz(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],modality:`voice`,custom:{}},status:t,createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let n=this._voiceMessages.indexOf(this._currentAssistantMsg);if(n===-1)return;let r={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],status:t};this._voiceMessages[n]=r,this._currentAssistantMsg=r}e.isFinal&&(this._commitVoiceMessage(this._currentAssistantMsg),this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(e=!0){let t=this._voiceMessages.at(-1);if(t?.role===`assistant`&&t.status.type===`running`){let n=this._voiceMessages.length-1;this._voiceMessages[n]={...t,status:{type:`complete`,reason:`stop`}},this._commitVoiceMessage(this._voiceMessages[n]),this._currentAssistantMsg=null,this._markVoiceMessagesDirty(),e&&this._notifySubscribers()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;let t=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];let n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;let r=this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0;this._voiceMessages=[],this._markVoiceMessagesDirty();try{IF([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>GN(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this._notifySubscribers()])}finally{e&&n&&this._voiceSession===void 0&&this._onVoiceDisconnected()}}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(CV.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>GN([n],{},`Thread runtime "${e}"`))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&GN([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},VV=Symbol.for(`assistant-stream.tool-execution-id`),HV=e=>{try{return JSON.parse(e),!0}catch{return!1}},UV=e=>{try{return JSON.parse(e)}catch{return}},WV=(e,t)=>{let n=UV(e),r=UV(t);return n===void 0||r===void 0?!1:pL(n,r)},GV=e=>e[VV],KV=class{_getTools;_callbacks;_isClientToolCall;_entries=new Map;_humanInput=new Map;_executing=new Set;_discardedToolCallIds=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t,n){this._getTools=e,this._callbacks=t,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){let[e,t]=RL();this._controller=t;let n=qR(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new VL).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(e){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),e?.discardPending)for(let[e,t]of this._entries)t.controller&&(t.argsComplete||t.hasResult||(this._discardedToolCallIds.add(e),t.skipExecute=!0));if(this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let t=new Set(this._executing);return new Promise(e=>{this._settledResolvers.push({executionIds:t,resolve:e})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=GV(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=GV(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._humanInput.get(e)?.executionId!==t&&this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=GV(e),r=this._entries.get(t);r&&r.executionId===n&&(r?.hasResult||r.skipExecute||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_warnProviderOwnedSkip(e,t){}_shouldCloseArgsStream({argsText:e,hasResult:t,clientOwned:n}){return t?!0:HV(e)?n||!this._isRunning:!1}_startActiveEntry(e,t,n,r){let i={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1,clientOwned:r};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)if(t.controller){if(!t.argsComplete&&!t.hasResult){this._entries.delete(e);continue}this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)WV(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(HV(e.argsText)&&HV(t.argsText)&&WV(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:e.clientOwned})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let{part:n}of OV(e)){let e=this._entries.get(n.toolCallId);if(t){e?.controller||this._entries.set(n.toolCallId,{toolName:n.toolName,argsText:n.argsText,hasResult:n.result!==void 0});continue}let r=e;if(n.result!==void 0&&this._discardedToolCallIds.delete(n.toolCallId),r&&!r.controller){if(r.hasResult||(n.argsText===r.argsText||HV(r.argsText)&&HV(n.argsText)&&WV(r.argsText,n.argsText))&&n.result===void 0)continue;this._entries.delete(n.toolCallId),r=void 0}if(!r){let e=this._isClientToolCall?.(n),t=n.result===void 0&&e===!1;t&&this._warnProviderOwnedSkip(n.toolName,n.toolCallId),r=this._startActiveEntry(n.toolCallId,n.toolName,n.result!==void 0||t||this._discardedToolCallIds.has(n.toolCallId),e===!0)}if(n.approval!==void 0&&(r.skipExecute=!0),this._processArgsText(r,n),n.result!==void 0&&!r.hasResult){let{controller:e}=r;if(!e)continue;r.hasResult=!0,r.argsComplete=!0,e.setResponse(new vL({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent===void 0?{}:{modelContent:n.modelContent}})),e.close()}}}},qV=Object.freeze([]),JV=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},YV=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,XV=class extends BV{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}suggestions=[];extras=void 0;_converter=new Gz;_pendingDeleteEvictions=new Set;_optimistic=null;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;_toolStatuses=new Map;_effectiveIsRunning=!1;_inTrackerUpdate=!1;_pendingRunningRefresh=!1;_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){let e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?`runStart`:`runEnd`,{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){let t=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e;let r=this._getEffectiveIsRunning(e),i=e.unstable_messageRepositoryInstance,a=i!==void 0&&i!==this.repository;a&&(this.repository=i,this._pendingDeleteEvictions.clear()),n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let o=e.suggestions??qV;ZP(this.suggestions,o)||(this.suggestions=o);let s={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};ZP(this._capabilities,s)||(this._capabilities=s);let c;if(e.messageRepository){if(n&&!a&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository&&t===r){this._notifySubscribers();return}let i=e.messageRepository.messages,o=e.messageRepository.headId??i.at(-1)?.message.id??null;if(n&&!a&&n.messageRepository===e.messageRepository)this.repository.resetHead(o),c=this.repository.getMessages();else{let e=new Set(i.map(({message:e})=>e.id));for(let{message:e,parentId:t}of i)this.repository.addOrUpdateMessage(t,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(o),c=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new Gz;else if(!a&&n.isRunning===e.isRunning&&n.messages===e.messages&&t===r){this._notifySubscribers();return}}c=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,i)=>{if(!e.convertMessage)return n;let a=i===(e.messages?.length??0)-1,o=`${Dz}${i}`;if(t&&(t.role!==`assistant`||!Vz(t.status)||t.status===Wz(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return Tz(e,n),e}return t}let s=e.convertMessage(n,i),c=jz(s,o,Wz(s.content,a,r));return Tz(c,n),c}):e.messages;let i=new Set,o=[];for(let e=c.length-1;e>=0;e--){let t=c[e];if(i.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}i.add(t.id),o.push(t)}o.length!==c.length&&(c=o.reverse());for(let e=0;e<c.length;e++){let t=c[e],n=c[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}if(this._pendingDeleteEvictions.size>0){let e=new Set(c.map(e=>e.id));for(let t of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(t),!e.has(t)){try{this.repository.getMessage(t)}catch{continue}this.repository.deleteMessage(t)}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);c.length>0&&this.ensureInitialized(),this._effectiveIsRunning=r,t!==r&&(r?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let l=null;if(YV(r,c)){let e=c.at(-1)?.id??null;this._optimistic?.parentId!==e&&(this._optimistic={id:Oz(),parentId:e}),l=this._optimistic.id,this.repository.addOrUpdateMessage(e,jz({role:`assistant`,content:[],metadata:{isOptimistic:!0}},l,{type:`running`}))}l===null&&(this._optimistic=null),this.repository.resetHead(l??c.at(-1)?.id??null);let u=this.repository.getMessages();if((!this._messages||!Kz(this._messages,u))&&(this._messages=u),this._voiceMessages.length>0){let e=new Set(this._messages.map(e=>e.id)),t=this._voiceMessages.filter(t=>!e.has(t.id));t.length!==this._voiceMessages.length&&(this._voiceMessages=t,this._markVoiceMessagesDirty())}a&&this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new KV(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;JV(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{this._store.setToolStatuses?.(Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}},e=>this._store.unstable_isClientToolCall?.(e)),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(let{part:e,messageId:t}of OV(this._messages))this._toolCallToMessageId.set(e.toolCallId,t);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t={...e,parentId:this._resolveAppendParent(e.parentId)};if(this.voice)throw Error(`Cannot send a text message while a voice session is connected`);if(this._isVoiceMessage(t.sourceId))throw Error(`Voice transcript messages cannot be edited`);let n=t.sourceId!=null||t.parentId!==(this._getBaseMessages().at(-1)?.id??null);t=!n&&this._store.queue&&this._store.queue===this._transformedQueue?t:this.enrichAppendMetadata(t);let r=fV(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!n&&this._store.queue){if(i&&await i,!pV(this,r))return;t.steer??this._getEffectiveIsRunning(this._store)?this._store.queue.steer(t):this._store.queue.enqueue(t);return}if(i?.catch(()=>{}),(t.startRun??t.role===`user`)&&await this._toolInvocations?.abort({discardPending:!0}),pV(this,r)){if(n){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._pendingDeleteEvictions.clear(),await this._store.onEdit(t)}else await this._store.onNew(t)}}_commitVoiceMessage(e){this._store.onVoiceTranscript?.(e)}async deleteMessage(e){if(this._store.onDelete){this.repository.getMessages().some(t=>t.id===e)&&this._pendingDeleteEvictions.add(e);try{await this._store.onDelete(e)}catch(t){throw this._pendingDeleteEvictions.delete(e),t}return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._getEffectiveIsRunning(this._store)&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this._pendingDeleteEvictions.clear(),this.updateMessages(t.filter(t=>t.id!==e)),this._evictDeletedMessage(e)}_evictDeletedMessage(e){if(!e.startsWith(`__external_store_fallback_`)){try{this.repository.getMessage(e)}catch{return}this.repository.deleteMessage(e),this._publishRepositoryMessages()}}_publishRepositoryMessages(){let e=this.repository.getMessages();Kz(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){return this._store?.queue?.items??DV}getSteerQueueItems(){return this._store?.queue?.steerItems??DV}moveQueueItem(e,t){this._store?.queue?.move(e,t)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);this._pendingDeleteEvictions.clear(),await this._toolInvocations?.abort({discardPending:!0}),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.queue?.__internal_notifyCancelled?.()}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);let e=fV(this);this._toolInvocations?.abort({discardPending:!0}),this._store.queue?.__internal_notifyCancelled?.(),JV(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let t=this.repository.getMessages(),n=t[t.length-1],r=this._store.setMessages!==void 0&&n?.role===`user`&&n.id===t.at(-1)?.id&&n.content.every(e=>e.type===`text`)?n:void 0,i;if(r){let e={text:BB(r),attachments:r.attachments,quote:r.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(r.id),i={id:r.id,draft:e})}this._publishRepositoryMessages(),setTimeout(()=>{if(pV(this,e)){if(this.dropEmptyOptimisticHead(),i){let e=this.repository.getMessages();e.at(-1)?.id===i.id?this.repository.deleteMessage(i.id):e.some(e=>e.id===i.id)&&this.composer.retractDraft(i.draft)}this._publishRepositoryMessages(),this.updateMessages(this._messages)}},0)}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);JV(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);let t=this.messages.findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId)),n=t?.content.find(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId);try{return Promise.resolve(this._store.onRespondToToolApproval(e)).then(()=>{t&&n?.type===`tool-call`&&this._notifyToolApprovalAnswered(t.id,n.toolCallId,n.toolName,e.approved)})}catch(e){return Promise.reject(e)}}reset(e){let t=new EV;t.import(CV.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(Ez))}},ZV=e=>e.adapters?.threadList??{},QV=class extends hV{threads;constructor(e){super(),this.threads=new SV(ZV(e),()=>new XV(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(ZV(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},$V=e=>{let t=J(21),{modelContext:n,feedback:r}=yz()??{},i;bb0:{if(!r||e.adapters?.feedback){i=e;break bb0}let n;t[0]!==r||t[1]!==e.adapters?(n={...e.adapters,feedback:r},t[0]=r,t[1]=e.adapters,t[2]=n):n=t[2];let a;t[3]!==e||t[4]!==n?(a={...e,adapters:n},t[3]=e,t[4]=n,t[5]=a):a=t[5],i=a}let a=i,o;t[6]===a?o=t[7]:(o=()=>new QV(a),t[6]=a,t[7]=o);let[s]=DM(o),c;t[8]===s.threads?c=t[9]:(c=()=>()=>{mV(s.threads.getMainThreadRuntimeCore())},t[8]=s.threads,t[9]=c);let l;t[10]===s?l=t[11]:(l=[s],t[10]=s,t[11]=l),X(c,l);let u;t[12]!==a||t[13]!==s?(u=()=>{s.setAdapter(a)},t[12]=a,t[13]=s,t[14]=u):u=t[14],X(u);let d,f;t[15]!==n||t[16]!==s?(d=()=>{if(n)return s.registerModelContextProvider(n)},f=[n,s],t[15]=n,t[16]=s,t[17]=d,t[18]=f):(d=t[17],f=t[18]),X(d,f);let p;return t[19]===s?p=t[20]:(p=new uV(s),t[19]=s,t[20]=p),p},eH=e=>e.status?.type!==`running`,tH=async(e,t)=>{let n=wR.fromAssistantStream(e);for await(let e of n){let n=e.parts.filter(e=>e.type===`text`)[0]?.text;n?.trim()&&await t(n)}},nH=(e,t)=>{let n=()=>void t.generateTitle({automatic:!0}).catch(e=>{cI(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(eH);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},rH=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=AM(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=Y(!1);c.current||s(),X(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=Y(void 0),u=Y(!1),d=Y(void 0),f=Y(!1),p=MM(()=>{if(u.current||i.getState().status!==`new`)return;u.current=!0;let e=i.initialize();l.current=e,e.then(()=>{f.current&&(d.current?.(),d.current=nH(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=MM(()=>(p(),l.current));return X(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),X(()=>{if(!a?.threads?.main)return;u.current=!1,f.current=!0;let e=a.threads.main.unstable_on(`initialize`,p);return()=>{f.current=!1,e(),d.current?.(),d.current=void 0}},[a]),a},iH=KM(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s})=>{let c=kM(()=>new iV(new HF({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:FF},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:l}=yF(i,{threadListItem:WI({runtime:c})});return VP(s,function(){return yP(l,function(){return vz(a,function(){return rH({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:c})})})})}),aH=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],oH=e=>{let t=J(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),jM(r,i),null},sH=class extends zF{runtimeHook;adapterStore=new BF({defaultAdapters:null,threadAdapters:new Map});hostStore=new BF({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);return t?(t.runtime&&mV(t.runtime),t.unsubscribeRunning?.(),t.unsubscribeRunning=void 0,t.destroy.abort(),t.destroy=new AbortController,t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime;r.runtime=t,r.publishedGeneration=n,i!==t&&this._trackRunning(e,r),this._notifySubscribers(),i!==void 0&&i!==t&&IF(this.replacedSubscribers)}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){t.unsubscribeRunning?.();let n=t.runtime;if(!n){t.unsubscribeRunning=void 0,this._setRunning(t,!1);return}this._setRunning(t,QB(n));let r=[n.subscribe(()=>{this._setRunning(t,QB(n))}),...aH.map(t=>n.unstable_on(t,()=>{GN(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>{for(let e of r)e()}}_setRunning(e,t){e.isRunning!==t&&(e.isRunning=t,IF(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&mV(t.runtime),t?.unsubscribeRunning?.(),t?.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState();this.hostStore.setState({...t,hookEpoch:t.hookEpoch+1})}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e})}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r})}__internal_dispose(){for(let e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){let e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t,destroy:n}])=>({id:e,generation:t,destroySignal:n.signal}))})}_threadElements(e,{threads:t,hookEpoch:n},r){let i=this.runtimeHook;return t.map(({id:t,generation:a,destroySignal:o})=>{let s=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return qM(`${t}:${a}:${n}`,iH({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:s,publish:this._publish,destroySignal:o}))})}__internal_useHost(e){let t=oI(this.hostStore),n=oI(this.adapterStore);return RN(this._threadElements(e,t,n))}__internal_RenderThreadRuntimes=({provider:e})=>(oI(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,P.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>{let t=oI(this.hostStore),n=oI(this.adapterStore),r=this._threadElements(e,t,n),{effects:i}=BN(function(){return RN(r)});return jM(i),null};_OuterActiveThreadProvider=RM(({threadId:e,provider:t})=>{let n=kM(()=>new lV(this.parent).getItemById(e),[e]),r=Y(!1);return X(()=>{},[t]),(0,P.jsx)(uB,{runtime:n,children:(0,P.jsx)(t,{children:(0,P.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=yz();return this.pendingThreadAdapters.set(e,n),jM(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,P.jsx)(oH,{detectorRef:t})}};function cH(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var lH=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),uH=class extends zF{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>lH(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=lH(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},dH=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),fH=new class extends nV{get error(){return dH}messages=[];composer=tV(dH,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(dH)}};function pH(e){return e}var mH=`__LOCALID_`,hH=e=>e||void 0,gH=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=kj(t.threadIdMap),a=kj(t.threadData),o=new Set([...n,...r]);for(let t of e){switch(t.status){case`regular`:case`archived`:break;default:{let e=t.status;throw Error(`Unsupported state: ${e}`)}}let e=i[t.remoteId],s=e===void 0?void 0:a[e],c=s?.id??t.remoteId,l=e??pH(c),u=s!==void 0&&s.status!==`new`?s.initializeTask:void 0;o.has(c)?s!==void 0&&s.status!==t.status&&(t.status===`regular`?(r=r.filter(e=>e!==c),n.push(c)):(n=n.filter(e=>e!==c),r.push(c))):(o.add(c),t.status===`regular`?n.push(c):r.push(c)),i[c]=l,i[t.remoteId]=l,a[l]={...s?.localOrigin===!0?{localOrigin:!0}:{},id:c,remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,initializeTask:u??Promise.resolve({remoteId:t.remoteId,externalId:t.externalId})}}return{threadIds:n,archivedThreadIds:r,threadIdMap:i,threadData:a}},_H=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:kj(),threadData:kj()}),vH=e=>{let t;do t=`${mH}${Oz()}`;while(e.threadIdMap[t]);let n=pH(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:kj(e.threadIdMap,{[t]:n}),threadData:kj(e.threadData,{[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},yH=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);(e===void 0||e===`new`)&&(e!==void 0||t.localOrigin===!0)&&(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?2**53-1:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),{...e,threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]}},bH=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),xH=(e,t)=>{let n=Object.hasOwn(e.threadIdMap,t)?e.threadIdMap[t]:void 0;if(n!==void 0)return Object.hasOwn(e.threadData,n)?e.threadData[n]:void 0},SH=(e,t,n,r,i)=>{let a=pH(t),o=Object.hasOwn(e.threadData,a)?e.threadData[a]:void 0;if(!o)return{state:e,removedMappingId:void 0,survivorMappingId:a};let s=Object.hasOwn(e.threadIdMap,n)?e.threadIdMap[n]:void 0,c=s!==void 0&&s!==a&&Object.hasOwn(e.threadData,s)?e.threadData[s]:void 0,l=s!==void 0&&c!==void 0?{mappingId:s,data:c}:void 0,u=i!==void 0&&Object.hasOwn(e.threadIdMap,i)?e.threadIdMap[i]:void 0,d=l!==void 0&&u===l.mappingId?l.mappingId:a,f=l===void 0?void 0:d===a?l.mappingId:a,p=r??l?.data.externalId,m=kj(e.threadData);f!==void 0&&delete m[f];let h={...o,id:d,initializeTask:Promise.resolve({remoteId:n,externalId:p}),remoteId:n,externalId:p};m[d]={...l?.data,...h,title:o.title??l?.data.title,lastMessageAt:(`lastMessageAt`in o?o.lastMessageAt:void 0)??(l&&`lastMessageAt`in l.data?l.data.lastMessageAt:void 0),custom:o.custom??l?.data.custom};let g=kj(e.threadIdMap);if(f!==void 0)for(let[e,t]of Object.entries(g))t===f&&(g[e]=d);g[t]=d,g[n]=d;let _=e=>l===void 0?e:e.filter(e=>e!==l.data.id).map(e=>e===o.id?d:e);return{state:{...e,threadIds:_(e.threadIds),archivedThreadIds:_(e.archivedThreadIds),threadIdMap:g,threadData:m},removedMappingId:f,survivorMappingId:d}},CH=(e,t,n,r)=>{let i=xH(e,t);if(!i)return e;let{id:a,status:o}=i;if(o===n)return e;let s;if(n!==`deleted`){if(i.status===`new`){if(r===void 0)return e;s={...i,initializeTask:r,status:n}}else s={...i,status:n}}let c={...e};switch(o){case`new`:c.newThreadId=void 0;break;case`regular`:c.threadIds=c.threadIds.filter(e=>e!==a);break;case`archived`:c.archivedThreadIds=c.archivedThreadIds.filter(e=>e!==a);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:c.threadIds=[a,...c.threadIds];break;case`archived`:c.archivedThreadIds=[a,...c.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t],r=kj(c.threadData);delete r[n],c.threadData=r;let i=kj(c.threadIdMap);for(let[e,t]of Object.entries(i))t===n&&delete i[e];c.threadIdMap=i;break}default:throw Error(`Unsupported state: ${n}`)}return s!==void 0&&(c.threadData={...c.threadData,[a]:s}),c},wH=(e,t,n)=>CH(e,t,n,void 0),TH=(e,t,n)=>CH(e,t,`regular`,n),EH=class extends Error{[sI]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}};function DH(e,t){let n=e.get(t);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualTitle:void 0,latestExplicit:null,nextOrder:0},e.set(t,n)),n}function OH(e,t,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualTitle===void 0&&e.get(t)===n&&e.delete(t)}function kH(e,t){return!t.superseded&&(e.latestExplicit?.order??0)<=t.order}function AH(e,t){return(e.latestExplicit?.order??0)<t.order}function jH(e,t,n){let r=DH(e,t),i,a=new Promise(e=>{i=e}),o={title:n,order:++r.nextOrder,settled:a,settle:i};r.pendingClaim=o,r.inFlightClaims.add(o);for(let e of r.generations)e.order<o.order&&(e.claim=o);return o}function MH(e,t,n,r){n.settle(r);let i=e.get(t);i!==void 0&&(i.inFlightClaims.delete(n),i.pendingClaim===n&&(i.pendingClaim=null,r&&(i.manualTitle=n.title)),OH(e,t,i))}function NH(e,t,n){let r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,OH(e,t,n),r}function PH(e,t){e.delete(t)}function FH(e,t,n){let r=DH(e,t);if(n&&r.pendingClaim===null&&NH(e,t,r)!==void 0)return null;let i,a=new Promise(e=>{i=e}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,beforeGenerationClaims:n?[]:[...r.inFlightClaims],superseded:!1,persisted:a,settlePersisted:i};if(!n){r.pendingClaim=null,r.manualTitle=void 0,r.latestExplicit=o;for(let e of r.generations)e.automatic&&(e.superseded=!0)}return r.generations.add(o),o}async function IH({states:e,threadId:t,automatic:n,generate:r,rename:i,applyTitle:a}){let o=DH(e,t),s=FH(e,t,n);if(s===null)return;let c,l=s.order,u=async e=>{let t=await e.settled;if(s.claim===e)return t||(s.claim=null,o.pendingClaim===e&&(o.pendingClaim=null)),t},d=()=>n&&NH(e,t,o)!==void 0,f=async()=>{if(c!==void 0)for(;;){let e=s.claim;if(e!==null&&e.order>l&&AH(o,e)){await u(e)===!0&&(c=e.title,l=e.order,await i(e.title));continue}let t=o.latestExplicit;if(t===null||t.order<=l)return;let n=await t.persisted;if(o.latestExplicit===t){if(l=t.order,n===void 0||n===c)return;c=n,await i(n)}}},p=async()=>{if(s.beforeGenerationClaims.length>0&&await Promise.all(s.beforeGenerationClaims.map(e=>e.settled)),s.claim!==null){let e=await u(s.claim);if(e===!0){s.superseded=!0;return}if(e===!1&&d())return}if(!kH(o,s))return;let e=!1,t;for(await r(async n=>{e=!0,t=n,n!==void 0&&(c=n);let r=s.claim;if(r!==null){if(await u(r)!==!1)return;if(d()){s.superseded=!0;return}}kH(o,s)&&await a(t)});;){let n=s.claim;if(n===null)return;let r=await u(n);if(r!==void 0){if(r===!1){if(d())return;e&&kH(o,s)&&await a(t);return}if(!AH(o,n))return;if(await i(n.title),c=n.title,l=n.order,s.claim===n){if(!kH(o,s))return;await a(n.title),s.superseded=!0;return}}}};try{await p(),await f()}finally{s.settlePersisted(c),o.generations.delete(s),OH(e,t,o)}}var LH=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),RH=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),zH=_H(),BH=class extends zF{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_titleStates=new Map;_mainThreadId;_state=new uH(zH);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,P.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=xz(e());return n==null?t:(0,P.jsx)(rV,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?zM:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=bH(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>e===this._loadGeneration?{...t,isLoading:!0,loadError:void 0}:t,then:(r,i)=>{if(e!==this._loadGeneration)return r;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads({...r,loadError:void 0},i.threads,hH(i.nextCursor));let a=gH(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return yH({...r,isLoading:!1,loadError:void 0,cursor:hH(i.nextCursor),threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadIdMap:a.threadIdMap,threadData:a.threadData},r,n)}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1,loadError:n});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads({...this._state.baseValue,loadError:n},[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?{...e,isLoadingMore:!0}:e,then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=gH(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:hH(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new sH(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new BF(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;providerStore;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0}),this._titleStates.clear()),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new EH}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new EH}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,n=t&&Object.hasOwn(e.threadData,t)?e.threadData[t]:void 0;n?.status===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i)for(let t of Object.values(e.threadData))i.has(t.id)||(t.status===`new`||t.remoteId!==void 0)&&r.push(t);this._staleThreadIdsOnReplace=void 0;let a={threadIds:[],archivedThreadIds:[],threadIdMap:kj(),threadData:kj()};for(let e of r){let t=pH(e.id);Object.hasOwn(a.threadData,t)||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=gH(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=pH(e.id),n=Object.hasOwn(l,t)?l[t]:void 0;n!==void 0&&(n.status===`regular`&&!o.includes(n.id)?o.push(n.id):n.status===`archived`&&!s.includes(n.id)&&s.push(n.id))}let u={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(c,e.newThreadId)?void 0:e.newThreadId};if(xH(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=vH(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))d.has(t.id)||this._hookManager.stopThreadRuntime(t.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get loadError(){return this._state.value.loadError}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return xH(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&cH(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||fH}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw LH(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return xH(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new EH;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=pH(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw LH(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n!==this._switchGeneration)return;let o=this.getItemById(i.id);o?.id===i.id&&(o.status===`archived`&&t?.unarchive!==!1&&(await o.initializeTask,n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)||o.status===`archived`&&(await this.unarchive(o.id),n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)))||(this._mainThreadId=o.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?this._startSwitchToNewThread(!1):this._startSwitchToThread(e,void 0,!1)}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=vH(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw LH(e,`initializing it`);if(t.status===`new`)throw RH(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}this._requireAdapterGeneration(n);let r=t.initialize(e),i,{remoteId:a,externalId:o}=await this._state.optimisticUpdate({execute:()=>r,optimistic:t=>TH(t,e,r),then:(t,{remoteId:r,externalId:a})=>{if(n!==this._adapterGeneration)return t;let o=SH(t,e,r,a,e);return i=o.removedMappingId,i===this._mainThreadId&&(this._mainThreadId=o.survivorMappingId),o.state}});return this._requireAdapterGeneration(n),i!==void 0&&this._hookManager.stopThreadRuntime(i),{remoteId:a,externalId:o}};generateTitle=async(e,t)=>{this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw LH(e,`generating its title`);if(i.status===`new`)throw RH(e,i.status,`generate a title`);let{remoteId:a}=await i.initializeTask;this._requireAdapterGeneration(r);let o=this._hookManager.getThreadRuntimeCore(i.id);if(!o)return;let s=o.messages.filter(eH);await IH({states:this._titleStates,threadId:i.id,automatic:t?.automatic===!0,generate:async e=>{let t=await n.generateTitle(a,s);this._requireAdapterGeneration(r),await tH(t,e)},rename:async e=>{this._requireAdapterGeneration(r),await n.rename(a,e)},applyTitle:async e=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:t=>{if(r!==this._adapterGeneration)return t;let n=xH(t,i.id);return n?{...t,threadData:{...t.threadData,[n.id]:{...n,title:e}}}:t}})}})};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw LH(e,`renaming it`);if(i.status===`new`)throw RH(e,i.status,`be renamed`);let a=jH(this._titleStates,i.id,t);try{let o=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=xH(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}});return MH(this._titleStates,i.id,a,!0),o}catch(e){throw MH(this._titleStates,i.id,a,!1),e}}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw LH(e,`updating its custom metadata`);if(i.status===`new`)throw RH(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=xH(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){let e=this._switchTask,n=!e||e===t;n&&(e=this.switchToNewThread()),t=e;try{await e}catch(t){if(n&&this._switchTask===e)throw t}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw LH(e,`archiving it`);if(r.status!==`regular`)throw RH(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>wH(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw LH(e,`unarchiving it`);if(r.status!==`archived`)throw RH(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>wH(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw LH(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw RH(e,r.status,`be deleted`);await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n);let i=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>wH(e,r.id,`deleted`)});return this._hookManager.stopThreadRuntime(r.id),PH(this._titleStates,r.id),i}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw LH(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw RH(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new BF([]);__internal_RenderComponent=()=>{let e=IM();X(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=oI(this.boundIdsStore),n=oI(this.providerStore),r=Q();return(t.length===0||t[0]===e)&&(0,P.jsxs)(rV,{adapters:this._runtimeAdapters,children:[(0,P.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,P.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},VH=class extends hV{threads;constructor(e){super(),this.threads=new BH(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},HH=e=>{let t=J(18),n;t[0]===e?n=t[1]:(n=()=>new VH(e),t[0]=e,t[1]=n);let[r]=DM(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>queueMicrotask(()=>r.threads.__internal_dispose()),t[2]=r.threads,t[3]=i);let a;t[4]===r?a=t[5]:(a=[r],t[4]=r,t[5]=a),FM(i,a);let o;t[6]!==e||t[7]!==r.threads?(o=()=>{r.threads.__internal_setOptions(e),r.threads.__internal_load()},t[6]=e,t[7]=r.threads,t[8]=o):o=t[8];let s;t[9]!==e||t[10]!==r?(s=[r,e],t[9]=e,t[10]=r,t[11]=s):s=t[11],X(o,s);let c;t[12]===r.threads?c=t[13]:(c=()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{r.threads.loadError!==void 0&&r.threads.reload()},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},t[12]=r.threads,t[13]=c);let l;t[14]===r?l=t[15]:(l=[r],t[14]=r,t[15]=l),X(c,l);let u;return t[16]===r?u=t[17]:(u=new uV(r),t[16]=r,t[17]=u),u},UH=e=>{let[t]=DM(()=>new BF(e.runtimeHook));jM(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=Y(e.initialThreadId),r=AM(function(){return oI({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()},[t]),i=MM(t=>e.onThreadIdChange?.(t)),a=kM(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(Q().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return HH(a)},WH=e=>{let t=J(6),{id:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=KN({message:EF({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:EF({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(eL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},GH=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,KH=()=>null,qH=new WeakMap,JH=(e,t)=>{let n=qH.get(e);return n||(n=new Set(e.map(e=>e.id)),qH.set(e,n)),n.has(t)},YH=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message??KH:e.SystemMessage??e.Message??KH;default:throw Error(`Unknown message role: ${t}`)}},XH=e=>{let t=J(6),{components:n}=e,r=$(nU),i=$(rU),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=YH(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,P.jsx)(o,{}),t[4]=o,t[5]=s),s},ZH=RM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(XH,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(dB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&GH(e.components,t.components));ZH.displayName=`ThreadPrimitive.MessageByIndex`;var QH=RM(e=>{let t=J(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>JH(e.thread.messages,n),t[0]=n,t[1]=i),!$(i))return null;let a;t[2]===r?a=t[3]:(a=(0,P.jsx)(XH,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,P.jsx)(WH,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&GH(e.components,t.components));QH.displayName=`ThreadPrimitive.Unstable_MessageById`;var $H=({children:e})=>{let t=$($P(e=>e.thread.messages.map(e=>e.id)));return kM(()=>t.length===0?null:t.map((t,n)=>(0,P.jsx)(dB,{index:n,children:(0,P.jsx)(rL,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},t)),[t,e])},eU=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)($H,{children:()=>(0,P.jsx)(XH,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)($H,{children:r}),t[2]=r,t[3]=i),i};eU.displayName=`ThreadPrimitive.Messages`;var tU=RM(eU,(e,t)=>e.children||t.children?e.children===t.children:GH(e.components,t.components));function nU(e){return e.message.role}function rU(e){return e.message.composer.isEditing}var iU=e=>{let t=e.message.metadata;if(t&&typeof t==`object`)return t.custom?.quote},aU=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},oU=e=>typeof e==`object`&&!!e,sU=e=>e==null?[]:Array.isArray(e)?e:[e],cU=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!oU(e)||!(`component`in e)||typeof e.component!=`string`)return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,P.jsx)(n,{component:i,props:a},s??r);throw new aU(i)}return BM(c,{...a??{},key:s??r},...sU(o).map((e,i)=>cU(e,t,n,`${r}/${i}`)))},lU=e=>{let t=J(11),{spec:n,components:r,Fallback:i}=e,a=n?.root,o;t[0]===a?o=t[1]:(o=sU(a),t[0]=a,t[1]=o);let s=o,c;if(t[2]!==i||t[3]!==r||t[4]!==s){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>cU(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],c=s.map(e),t[2]=i,t[3]=r,t[4]=s,t[5]=c}else c=t[5];let l;return t[9]===c?l=t[10]:(l=(0,P.jsx)(P.Fragment,{children:c}),t[9]=c,t[10]=l),l};lU.displayName=`GenerativeUIRender`;var uU=e=>{let t=J(4),{components:n,spec:r,Fallback:i}=e,a=$(dU),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,P.jsx)(lU,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};uU.displayName=`MessagePrimitive.GenerativeUI`;function dU(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var fU=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},pU=(e,t,n)=>{let r=[];if(t){let t=fU(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=fU(`toolGroup`),n=fU(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},mU=e=>{let t=J(10),n=$($P(RU)),r=$($P(BU)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=pU(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},hU=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},gU=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),_U=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>gU(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},vU={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},yU=e=>{let t=J(41),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?vU.Text:i,m=a===void 0?vU.Reasoning:a,h=o===void 0?vU.Image:o,g=s===void 0?vU.Source:s,_=c===void 0?vU.File:c,v=l===void 0?vU.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let b=y,x=Q(),S=$(VU),C=S.type;if(C===`tool-call`){let e=x.part.addToolResult,n=x.part.resumeToolCall,r=x.part.respondToToolApproval;if(`Override`in b){let i;return t[4]!==e||t[5]!==S||t[6]!==r||t[7]!==n||t[8]!==b.Override?(i=(0,P.jsx)(b.Override,{...S,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=S,t[6]=r,t[7]=n,t[8]=b.Override,t[9]=i):i=t[9],i}let i=b.by_name?.[S.toolName]??b.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==S||t[13]!==r||t[14]!==n?(a=(0,P.jsx)(hU,{...S,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=S,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[16]!==p||t[17]!==S?(e=(0,P.jsx)(p,{...S}),t[16]=p,t[17]=S,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==m||t[20]!==S?(e=(0,P.jsx)(m,{...S}),t[19]=m,t[20]=S,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==g||t[23]!==S?(e=(0,P.jsx)(g,{...S}),t[22]=g,t[23]=S,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==h||t[26]!==S?(e=(0,P.jsx)(h,{...S}),t[25]=h,t[26]=S,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==_||t[29]!==S?(e=(0,P.jsx)(_,{...S}),t[28]=_,t[29]=S,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==v||t[32]!==S?(e=(0,P.jsx)(v,{...S}),t[31]=v,t[32]=S,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[34]!==e||t[35]!==S?(n=(0,P.jsx)(_U,{...S,Fallback:e}),t[34]=e,t[35]=S,t[36]=n):n=t[36],n}case`generative-ui`:{if(!f?.components)return null;let e=S,n;return t[37]!==f.Fallback||t[38]!==f.components||t[39]!==e.spec?(n=(0,P.jsx)(lU,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[37]=f.Fallback,t[38]=f.components,t[39]=e.spec,t[40]=n):n=t[40],n}default:return console.warn(`Unknown message part type: ${C}`),null}},bU=RM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(yU,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(fB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);bU.displayName=`MessagePrimitive.PartByIndex`;var xU=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,P.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,P.jsx)(mB,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},SU=Object.freeze({type:`complete`}),CU=Object.freeze({type:`running`}),wU=RM(e=>{let t=J(6),{components:n}=e,r=$(HU);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,P.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??vU.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(xU,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),TU=RM(e=>{let t=J(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!$(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,P.jsx)(wU,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),EU=RM(e=>{let t=J(4),{Quote:n}=e,r=$(iU);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,P.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function DU(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(HB(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var OU=()=>{let e=J(6),t=Q(),n=$(UU),r=$(WU);if(!r||n.type!==`tool-call`)return null;let i;return e[0]!==r||e[1]!==t.part.addToolResult||e[2]!==t.part.respondToToolApproval||e[3]!==t.part.resumeToolCall||e[4]!==n?(i=(0,P.jsx)(r,{...n,addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval}),e[0]=r,e[1]=t.part.addToolResult,e[2]=t.part.respondToToolApproval,e[3]=t.part.resumeToolCall,e[4]=n,e[5]=i):i=e[5],i},kU=()=>{let e=J(3),t=$(GU),n=$(KU);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,P.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},AU=()=>{let e=J(2),t=$(qU);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(OU,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(kU,{}),e[1]=t):t=e[1],t}return null},jU=Object.freeze({type:`text`,text:``,status:CU}),MU=({children:e})=>{let t=Q(),n=$(e=>e.dataRenderers);return(0,P.jsx)(rL,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=DU(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,P.jsx)(OU,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=gU(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,P.jsx)(kU,{}):null}}return e}})})},NU=e=>{let t=J(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(MU,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(fB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},PU=e=>{let t=J(9),{children:n}=e,r=$(JU),i=$(YU),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:jU}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,P.jsx)(mB,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,P.jsx)(NU,{index:t,children:e=>n(e)??(0,P.jsx)(AU,{})},t),t[7]=n,t[8]=e),o=(0,P.jsx)(P.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},FU=e=>{let t=J(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,P.jsx)(PU,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,P.jsx)(IU,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};FU.displayName=`MessagePrimitive.Parts`;var IU=e=>{let t=J(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=$(XU),{ranges:a,partIds:o}=mU(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,P.jsx)(wU,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,P.jsx)(bU,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,P.jsx)(xB,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,P.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}if(e.type===`toolGroup`){let t=n?.ToolGroup??vU.ToolGroup;return(0,P.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,P.jsx)(bU,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??vU.ReasoningGroup;return(0,P.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,P.jsx)(bU,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,P.jsx)(EU,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,P.jsx)(TU,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,P.jsxs)(P.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function LU(e){return e.type}function RU(e){return e.message.parts.map(LU)}function zU(e){return e.type===`tool-call`?e.toolCallId:void 0}function BU(e){return e.message.parts.map(zU)}function VU(e){return e.part}function HU(e){return e.message.status??SU}function UU(e){return e.part}function WU(e){return e.part.type===`tool-call`?DU(e.tools,e.part):null}function GU(e){return e.part}function KU(e){return e.part.type===`data`?gU(e.dataRenderers,e.part.name,void 0)??null:null}function qU(e){return e.part.type}function JU(e){return e.message.parts.length}function YU(e){return(e.message.status?.type??`complete`)===`running`}function XU(e){return e.message.parts.length}var ZU=Symbol.for(`@assistant-ui/groupBy.memoKey`),QU=e=>{let t=e,n=((e,n)=>{if(e.type===`tool-call`){if((HB(e.mcp?.app?.resourceUri)||(n?.toolUIs?.[e.toolName]?.[0]?.standalone??!1))&&t[`standalone-tool-call`]!==void 0)return t[`standalone-tool-call`];let r=t[`tool-call:${e.toolName}`];return r===void 0?t[`tool-call`]??[]:r}return t[e.type]??[]}),r=Object.keys(e).sort().map(t=>[t,e[t]]);return n[ZU]=`groupPartByType:${JSON.stringify(r)}`,n},$U=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},eW=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},tW=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:eW(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:$U(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:$U(s),idKey:eW(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},nW=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},rW=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},iW=(e,t,n)=>{if(e.type===`part`)return(0,P.jsx)(NU,{index:e.index,children:({part:e})=>n({part:e,children:(0,P.jsx)(rW,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let{status:r,counts:i}=yB(t,e.indices),a={type:e.key,status:r,counts:i,indices:e.indices};return(0,P.jsx)(zM,{children:n({part:a,children:(0,P.jsx)(P.Fragment,{children:e.children.map(e=>iW(e,t,n))})})},e.idKey??e.nodeKey)},aW=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=$($P(e=>e.message.parts)),i=$(e=>e.tools.toolUIs),a=$(e=>t!==`never`&&e.message.status?.type===`running`),o=kM(()=>{let t={toolUIs:i};return tW(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[ZU]??e,i]);return(0,P.jsxs)(P.Fragment,{children:[o.map(e=>iW(e,r,n)),nW(t,r,a)&&n({part:{type:`indicator`},children:(0,P.jsx)(rW,{})})]})};aW.displayName=`MessagePrimitive.GroupedParts`;var oW=RM(e=>{let t=J(5),{children:n}=e,r=$(iU);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,P.jsx)(P.Fragment,{children:i}),t[3]=i,t[4]=a),a});oW.displayName=`MessagePrimitive.Quote`;var sW=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},cW=e=>{let t=J(5),{components:n}=e,r=$(fW);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=sW(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,P.jsx)(o,{}),t[3]=o,t[4]=s),s},lW=RM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(cW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(cB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);lW.displayName=`MessagePrimitive.AttachmentByIndex`;var uW=({children:e})=>{let t=$($P(e=>e.message.role===`user`?(e.message.attachments??[]).map(e=>e.id):[]));return kM(()=>t.map((t,n)=>(0,P.jsx)(cB,{index:n,children:(0,P.jsx)(rL,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},dW=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(uW,{children:e=>{let{attachment:t}=e,r=sW(n,t);return r?(0,P.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(uW,{children:r}),t[2]=r,t[3]=i),i};dW.displayName=`MessagePrimitive.Attachments`;function fW(e){return e.attachment}var pW=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},mW=e=>{let t=J(5),{components:n}=e,r=$(vW);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=pW(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,P.jsx)(a,{}),t[3]=a,t[4]=o),o},hW=RM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(mW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(lB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);hW.displayName=`ComposerPrimitive.AttachmentByIndex`;var gW=({children:e})=>{let t=$($P(e=>e.composer.attachments.map(e=>e.id)));return kM(()=>t.map((t,n)=>(0,P.jsx)(lB,{index:n,children:(0,P.jsx)(rL,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},_W=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(gW,{children:e=>{let{attachment:t}=e,r=pW(n,t);return r?(0,P.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(gW,{children:r}),t[2]=r,t[3]=i),i};_W.displayName=`ComposerPrimitive.Attachments`;function vW(e){return e.attachment}var yW=RM(({children:e})=>{let t=$($P(e=>e.composer.queue.map(e=>e.id)));return kM(()=>t.map((t,n)=>(0,P.jsx)(TB,{index:n,children:(0,P.jsx)(rL,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});yW.displayName=`ComposerPrimitive.Queue`;var bW=RM(e=>{let t=J(6),{index:n,archived:r,components:i}=e,a=r!==void 0&&r,o=i.ThreadListItem,s;t[0]===o?s=t[1]:(s=(0,P.jsx)(o,{}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==n||t[4]!==s?(c=(0,P.jsx)(CB,{index:n,archived:a,children:s}),t[2]=a,t[3]=n,t[4]=s,t[5]=c):c=t[5],c},(e,t)=>e.index===t.index&&e.archived===t.archived&&e.components.ThreadListItem===t.components.ThreadListItem);bW.displayName=`ThreadListPrimitive.ItemByIndex`;var xW=({archived:e,children:t})=>{let n=$($P(t=>e?t.threads.archivedThreadIds:t.threads.threadIds));return kM(()=>n.map((n,r)=>(0,P.jsx)(CB,{index:r,archived:e,children:(0,P.jsx)(rL,{getItemState:t=>t.threads.item({index:r,archived:e}).getState(),children:e=>t({get threadListItem(){return e()}})})},n)),[n,e,t])},SW=e=>{let t=J(8),{archived:n,components:r,children:i}=e,a=n!==void 0&&n;if(r){let e=r.ThreadListItem,n;t[0]===e?n=t[1]:(n=()=>(0,P.jsx)(e,{}),t[0]=e,t[1]=n);let i;return t[2]!==a||t[3]!==n?(i=(0,P.jsx)(xW,{archived:a,children:n}),t[2]=a,t[3]=n,t[4]=i):i=t[4],i}let o;return t[5]!==a||t[6]!==i?(o=(0,P.jsx)(xW,{archived:a,children:i}),t[5]=a,t[6]=i,t[7]=o):o=t[7],o};SW.displayName=`ThreadListPrimitive.Items`;var CW=e=>{let{children:t}=e;return $(wW)?t:null};CW.displayName=`MessagePartPrimitive.InProgress`;function wW(e){return e.part.status.type===`running`}var TW=e=>{let t=J(2),{fallback:n}=e,r=$(EW)||n,i;return t[0]===r?i=t[1]:(i=(0,P.jsx)(P.Fragment,{children:r}),t[0]=r,t[1]=i),i};TW.displayName=`ThreadListItemPrimitive.Title`;function EW(e){return e.threadListItem.title}var DW=e=>{let t=J(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,P.jsx)(r,{}),t[0]=r,t[1]=i),i},OW=RM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(DW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(wB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);OW.displayName=`ThreadPrimitive.SuggestionByIndex`;var kW=({children:e})=>{let t=$(e=>e.suggestions.suggestions.length);return kM(()=>t===0?null:Array.from({length:t},(t,n)=>(0,P.jsx)(wB,{index:n,children:(0,P.jsx)(rL,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},AW=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(kW,{children:()=>(0,P.jsx)(DW,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(kW,{children:r}),t[2]=r,t[3]=i),i};AW.displayName=`ThreadPrimitive.Suggestions`;var jW=RM(AW,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),MW=e=>{let t=J(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],$(n)},NW=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),MW(r)?n:null};NW.displayName=`ComposerPrimitive.If`;var PW=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,FW=e=>!e.composer.canCancel,IW=e=>e.composer.isEditing||e.optional.thread?.voice!==void 0||e.optional.thread?.capabilities.edit===!1,LW=e=>e.thread.isRunning||e.thread.isDisabled||e.thread.voice!==void 0||e.message.role!==`assistant`||!e.thread.capabilities.reload,RW=e=>e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(e=>e.type===`text`&&e.text.length>0),zW=e=>e.message.branchNumber<=1||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,BW=e=>e.message.branchNumber>=e.message.branchCount||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,VW=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,HW=e=>{if(e.message.status?.type!==`incomplete`||e.message.status.reason!==`error`)return;let t=e.message.status.error;return typeof t==`string`?t:typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:t??`An error occurred`},UW=e=>!e.threads.hasMore||e.threads.isLoading||e.threads.isLoadingMore,WW=()=>{let e=J(5),t=Q(),n=$(PW),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},GW=()=>{let e=J(5),t=Q(),n=$(FW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},KW=()=>{let e=J(5),t=Q(),n=$(qW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function qW(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var JW=()=>{let e=J(5),t=Q(),n=$(YW),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function YW(e){return!e.composer.isEditing}var XW=e=>{let t=J(15),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=Q(),s=$(RW),c=$(ZW),l=$(QW),u=$($W),d=Y(void 0),f=Y(0),p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>()=>{f.current+=1,d.current!==void 0&&(clearTimeout(d.current),d.current=void 0,o.message.setIsCopied(!1))},m=[o],t[2]=o,t[3]=p,t[4]=m),X(p,m);let h;t[5]!==o||t[6]!==u||t[7]!==a||t[8]!==i||t[9]!==l?(h=()=>{if(!i)return;let e=l?u:o.message.getCopyText();if(!e)return;let t=f.current,n;try{n=i(e)}catch{return}Promise.resolve(n).then(()=>{t===f.current&&(d.current!==void 0&&clearTimeout(d.current),o.message.setIsCopied(!0),d.current=setTimeout(()=>{d.current=void 0,o.message.setIsCopied(!1)},a))},eG)},t[5]=o,t[6]=u,t[7]=a,t[8]=i,t[9]=l,t[10]=h):h=t[10];let g=h,_=s||!i,v;return t[11]!==g||t[12]!==c||t[13]!==_?(v={copy:g,disabled:_,isCopied:c},t[11]=g,t[12]=c,t[13]=_,t[14]=v):v=t[14],v};function ZW(e){return e.message.isCopied}function QW(e){return e.composer.isEditing}function $W(e){return e.composer.text}function eG(){}var tG=()=>{let e=J(5),t=Q(),n=$(IW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},nG=()=>{let e=J(5),t=Q(),n=$(LW),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},rG=()=>{let e=J(5),t=Q(),n=$(aG),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},iG=()=>{let e=J(5),t=Q(),n=$(oG),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function aG(e){return e.message.metadata.submittedFeedback?.type===`positive`}function oG(e){return e.message.metadata.submittedFeedback?.type===`negative`}var sG=()=>{let e=J(5),t=Q(),n=$(lG),r;e[0]===t?r=e[1]:(r=async()=>{t.message.speak()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function cG(e){return e.type===`text`&&e.text.length>0}function lG(e){return e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(cG)}var uG=()=>{let e=J(5),t=Q(),n=$(dG),r;e[0]===t?r=e[1]:(r=()=>{t.message.stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function dG(e){return e.message.speech==null}var fG=()=>{let e=J(5),t=Q(),n=$(BW),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`next`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={next:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},pG=()=>{let e=J(5),t=Q(),n=$(zW),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`previous`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={previous:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},mG=e=>{let t=J(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=Q(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>VW(e,s),t[0]=s,t[1]=c);let l=$(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let{isRunning:e,capabilities:t}=o.thread.getState();if(e&&!t.queue)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&!e&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(hG).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function hG(e){return e.trim()}var gG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.archive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={archive:r},e[2]=r,e[3]=i),i},_G=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.delete()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={delete:r},e[2]=r,e[3]=i),i},vG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.unarchive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={unarchive:r},e[2]=r,e[3]=i),i},yG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.switchTo()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchTo:r},e[2]=r,e[3]=i),i},bG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threads.switchToNewThread()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchToNewThread:r},e[2]=r,e[3]=i),i},xG=()=>{let e=J(5),t=Q(),n=$(UW),r;e[0]===t?r=e[1]:(r=()=>{t.threads.loadMore()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={loadMore:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},SG=()=>$(HW),CG=e=>{let{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c,...l}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c},otherOptions:l}};function wG(e,t){function n(n){let r=GM(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function TG(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var EG=UM(null),{useThreadViewport:DG,useThreadViewportStore:OG}=TG(wG(EG,`ThreadPrimitive.Viewport`),`useThreadViewport`),kG=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},AG=(e=>e?kG(e):kG),jG=e=>e;function MG(e,t=jG){let n=N.useSyncExternalStore(e.subscribe,N.useCallback(()=>t(e.getState()),[e,t]),N.useCallback(()=>t(e.getInitialState()),[e,t]));return N.useDebugValue(n),n}var NG=e=>{let t=AG(e),n=e=>MG(t,e);return Object.assign(n,t),n},PG=(e=>e?NG(e):NG),FG=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},IG=(e={})=>{let t=new Set,n=FG(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=FG(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=PG(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{GN(t,()=>({behavior:e}),`Thread viewport`)},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},LG=e=>e,RG=e=>{let t=J(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=OG(n),i;t[1]===e?i=t[2]:(i=()=>IG(e),t[1]=e,t[2]=i);let[a]=DM(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(e=>{a.getState().scrollToBottom(e)}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),X(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&LG(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),X(c,l),a},zG=e=>{let t=J(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=RG(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=DM(o),c;return t[4]!==n||t[5]!==s?(c=(0,P.jsx)(EG.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},BG=()=>{let e=J(3),t=Q(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),X(n,r),null},VG=RM(e=>{let t=J(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,P.jsx)(BG,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,P.jsx)(zG,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,P.jsxs)(cL,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),HG=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,UG={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(HG)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},WG=Object.defineProperty,GG=(e,t)=>WG(e,`name`,{value:t,configurable:!0});function KG(e,t=globalThis?.document){let n=ln(e);N.useEffect(()=>{let e=GG(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}GG(KG,`useEscapeKeydown`);var qG=f;qG.dispatchDiscreteCustomEvent=v,qG.Root=f;var JG=Object.defineProperty,YG=(e,t)=>{let n={};for(var r in e)JG(n,r,{get:e[r],enumerable:!0});return t||JG(n,Symbol.toStringTag,{value:`Module`}),n},XG=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function ZG(e,t){return VM(e,void 0,t===void 0?e.props.children:t)}function QG(e,t,n){return(0,P.jsx)(c,{...n,children:ZG(e,t)})}function $G(e){let t=Z((t,n)=>{let r=J(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&HM(o)){let e=s,t;r[5]!==a||r[6]!==o?(t=ZG(o,a),r[5]=a,r[6]=o,r[7]=t):t=r[7];let i;return r[8]!==n||r[9]!==e||r[10]!==t?(i=(0,P.jsx)(c,{...e,asChild:!0,ref:n,children:t}),r[8]=n,r[9]=e,r[10]=t,r[11]=i):i=r[11],i}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,P.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function eK(e){let t=qG[e],n=$G(t);return n.displayName=`Primitive.${e}`,n}var tK=XG.reduce((e,t)=>(e[t]=eK(t),e),{}),nK={Hidden:`hidden`,Floating:`floating`,Normal:`normal`},rK=e=>{let t=J(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return nK.Hidden;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?nK.Floating:nK.Normal:nK.Hidden:nK.Normal},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],$(o)},iK=UM(null),aK=()=>GM(iK),oK=Z((e,t)=>{let n=J(18),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({hideWhenRunning:a,autohide:r,autohideFloat:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let[s,c]=DM(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(sK),()=>{e||(e=!0,c(cK))}},n[5]=l):l=n[5];let u=l,d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={acquireInteractionLock:u},n[6]=d):d=n[6];let f=d,p=s>0,m;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==p?(m={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:p},n[7]=r,n[8]=i,n[9]=a,n[10]=p,n[11]=m):m=n[11];let h=rK(m);if(h===nK.Hidden)return null;let g;n[12]===h?g=n[13]:(g=h===nK.Floating?{"data-floating":`true`}:null,n[12]=h,n[13]=g);let _;return n[14]!==t||n[15]!==o||n[16]!==g?(_=(0,P.jsx)(iK.Provider,{value:f,children:(0,P.jsx)(tK.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});oK.displayName=`ActionBarPrimitive.Root`;function sK(e){return e+1}function cK(e){return Math.max(0,e-1)}var lK=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:dK},t[2]=i,t[3]=a);let{copy:o,disabled:s}=XW(a);return s?null:o},uK=Z((e,t)=>{let n=J(20),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({copiedDuration:r,onClick:a,disabled:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=$(fK),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=lK(c),u;n[7]===s?u=n[8]:(u=s?{"data-copied":`true`}:{},n[7]=s,n[8]=u);let d=i||!l,f;n[9]===l?f=n[10]:(f=()=>{l?.()},n[9]=l,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=F(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==o||n[16]!==u||n[17]!==d||n[18]!==p?(m=(0,P.jsx)(tK.button,{type:`button`,...u,...o,ref:t,disabled:d,onClick:p}),n[14]=t,n[15]=o,n[16]=u,n[17]=d,n[18]=p,n[19]=m):m=n[19],m});uK.displayName=`ActionBarPrimitive.Copy`;function dK(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function fK(e){return e.message.isCopied}var pK=(e,t,n=[])=>{let r=Z((e,r)=>{let i=J(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=tK,l=o.disabled||!s,u=F(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,P.jsx)(c.button,{type:`button`,...o,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},mK=pK(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=nG();return e?null:t}),hK=pK(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=tG();return e?null:t}),gK=pK(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=sG();return e?null:t}),_K=()=>{let{disabled:e,stopSpeaking:t}=uG();return e?null:t},vK=Z((e,t)=>{let n=J(10),r=_K(),i=!r,a;n[0]===r?a=n[1]:(a=()=>{r?.()},n[0]=r,n[1]=a);let o;n[2]!==e.onClick||n[3]!==a?(o=F(e.onClick,a),n[2]=e.onClick,n[3]=a,n[4]=o):o=n[4];let s;return n[5]!==e||n[6]!==t||n[7]!==i||n[8]!==o?(s=(0,P.jsx)(tK.button,{type:`button`,disabled:i,...e,ref:t,onClick:o}),n[5]=e,n[6]=t,n[7]=i,n[8]=o,n[9]=s):s=n[9],s});vK.displayName=`ActionBarPrimitive.StopSpeaking`;var yK=()=>{let{submit:e}=rG();return e},bK=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(xK),s=yK(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=F(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,P.jsx)(tK.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});bK.displayName=`ActionBarPrimitive.FeedbackPositive`;function xK(e){return e.message.metadata.submittedFeedback?.type===`positive`}var SK=()=>{let{submit:e}=iG();return e},CK=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(wK),s=SK(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=F(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,P.jsx)(tK.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});CK.displayName=`ActionBarPrimitive.FeedbackNegative`;function wK(e){return e.message.metadata.submittedFeedback?.type===`negative`}var TK=e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=Q(),o=$(OK),s;return t[2]!==a.message||t[3]!==r||t[4]!==i?(s=async()=>{let e=a.message.getCopyText();if(!e)return;if(i){await i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r??`message-${Date.now()}.md`,o.click(),setTimeout(()=>URL.revokeObjectURL(n),4e4)},t[2]=a.message,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},EK=Z((e,t)=>{let n=J(19),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({filename:i,onExport:o,onClick:a,disabled:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==i||n[7]!==o?(c={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=c):c=n[8];let l=TK(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.().catch(kK)},n[9]=l,n[10]=d);let f;n[11]!==a||n[12]!==d?(f=F(a,d),n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;return n[14]!==t||n[15]!==s||n[16]!==u||n[17]!==f?(p=(0,P.jsx)(tK.button,{type:`button`,...s,ref:t,disabled:u,onClick:f}),n[14]=t,n[15]=s,n[16]=u,n[17]=f,n[18]=p):p=n[18],p});EK.displayName=`ActionBarPrimitive.ExportMarkdown`;function DK(e){return e.type===`text`&&e.text.length>0}function OK(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(DK)}function kK(e){console.error(`[assistant-ui] markdown export failed:`,e)}var AK=YG({Copy:()=>uK,Edit:()=>hK,ExportMarkdown:()=>EK,FeedbackNegative:()=>CK,FeedbackPositive:()=>bK,Reload:()=>mK,Root:()=>oK,Speak:()=>gK,StopSpeaking:()=>vK}),jK=au(),MK=e=>{let t=J(25),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({__scopeActionBarMore:n,open:i,onOpenChange:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=jK(n),s=aK(),c=Y(null),l=i!==void 0,u;t[5]===s?u=t[6]:(u=e=>{if(e){if(c.current)return;c.current=s?.acquireInteractionLock()??null;return}c.current?.(),c.current=null},t[5]=s,t[6]=u);let d=u,f;t[7]!==l||t[8]!==r||t[9]!==d?(f=e=>{l||d(e),r?.(e)},t[7]=l,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p=f,m,h;t[11]!==l||t[12]!==i||t[13]!==d?(m=()=>{l&&d(!!i)},h=[l,i,d],t[11]=l,t[12]=i,t[13]=d,t[14]=m,t[15]=h):(m=t[14],h=t[15]),X(m,h);let g,_;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{c.current?.(),c.current=null},_=[],t[16]=g,t[17]=_):(g=t[16],_=t[17]),X(g,_);let v;t[18]===i?v=t[19]:(v=i===void 0?null:{open:i},t[18]=i,t[19]=v);let y;return t[20]!==p||t[21]!==a||t[22]!==o||t[23]!==v?(y=(0,P.jsx)(Du,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};MK.displayName=`ActionBarMorePrimitive.Root`;var NK=$G(Ou),PK=$G(Au),FK=$G(Nu),IK=$G(Ru),LK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=jK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(NK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});LK.displayName=`ActionBarMorePrimitive.Trigger`;var RK=Z((e,t)=>{let n=J(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({__scopeActionBarMore:r,portalProps:i,sideOffset:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?4:o,c=jK(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,P.jsx)(PK,{...c,...a,ref:t,sideOffset:s}),n[5]=t,n[6]=a,n[7]=c,n[8]=s,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==c||n[12]!==l?(u=(0,P.jsx)(ku,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});RK.displayName=`ActionBarMorePrimitive.Content`;var zK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=jK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(FK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});zK.displayName=`ActionBarMorePrimitive.Item`;var BK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=jK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(IK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});BK.displayName=`ActionBarMorePrimitive.Separator`;var VK=YG({Content:()=>RK,Item:()=>zK,Root:()=>MK,Separator:()=>BK,Trigger:()=>LK}),HK=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(tK.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});HK.displayName=`AttachmentPrimitive.Root`;var UK=Z((e,t)=>{let n=J(4),r=$(WK),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(tK.div,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});UK.displayName=`AttachmentPrimitive.unstable_Thumb`;function WK(e){let t=e.attachment.name,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?`.${t.slice(n+1)}`:e.attachment.type}var GK=()=>{let e=J(2),t=$(KK),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};GK.displayName=`AttachmentPrimitive.Name`;function KK(e){return e.attachment.name}var qK=pK(`AttachmentPrimitive.Remove`,()=>{let e=J(2),t=Q(),n;return e[0]===t.attachment?n=e[1]:(n=()=>{t.attachment.remove()},e[0]=t.attachment,e[1]=n),n}),JK=YG({Name:()=>GK,Remove:()=>qK,Root:()=>HK,unstable_Thumb:()=>UK}),YK=pK(`BranchPickerPrimitive.Next`,()=>{let{disabled:e,next:t}=fG();return e?null:t}),XK=pK(`BranchPickerPrimitive.Previous`,()=>{let{disabled:e,previous:t}=pG();return e?null:t}),ZK=()=>$($K),QK=()=>{let e=J(2),t=ZK(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};QK.displayName=`BranchPickerPrimitive.Count`;function $K(e){return e.message.branchCount}var eq=()=>$(nq),tq=()=>{let e=J(2),t=eq(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};tq.displayName=`BranchPickerPrimitive.Number`;function nq(e){return e.message.branchNumber}var rq=Z((e,t)=>{let n=J(11),r,i;n[0]===e?(r=n[1],i=n[2]):({hideWhenSingleBranch:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e=>!r||e.message.branchCount>=2,n[3]=r,n[4]=a);let o;n[5]!==t||n[6]!==i?(o=(0,P.jsx)(tK.div,{...i,ref:t}),n[5]=t,n[6]=i,n[7]=o):o=n[7];let s;return n[8]!==a||n[9]!==o?(s=(0,P.jsx)(ZI,{condition:a,children:o}),n[8]=a,n[9]=o,n[10]=s):s=n[10],s});rq.displayName=`BranchPickerPrimitive.Root`;var iq=YG({Count:()=>QK,Next:()=>YK,Number:()=>tq,Previous:()=>XK,Root:()=>rq}),aq=UM(null),oq=()=>GM(aq),sq=e=>{let t=J(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=Y(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(cq),o.current=e.map(lq)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,P.jsx)(aq.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function cq(e,t){return t[1]-e[1]}function lq(e){let[t]=e;return t}var uq=UM(null),dq=UM(null),fq=()=>{let e=GM(uq);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},pq=()=>GM(uq),mq=()=>{let e=GM(dq);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},hq=()=>{let e=fq();return NM(e.subscribe,e.getTriggers,e.getTriggers)},gq=new Map,_q=()=>()=>{},vq=()=>gq,yq=()=>{let e=pq();return NM(e?e.subscribe:_q,e?e.getTriggers:vq,e?e.getTriggers:vq)},bq=()=>null,xq=()=>{let e=pq();return NM(e?e.subscribeAria:_q,e?e.getActiveAria:bq,e?e.getActiveAria:bq)};function Sq(){let e=J(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=Y(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var Cq=e=>{let t=J(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=Y(a),{notify:s,subscribe:c}=Sq(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return Tq;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=Y(null),g=Y(null),{notify:_,subscribe:v}=Sq(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,P.jsx)(dq.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,P.jsx)(uq.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},wq=e=>{let t=J(4),{children:n}=e;if(oq()){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(Cq,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,P.jsx)(sq,{children:(0,P.jsx)(Cq,{children:n})}),t[2]=n,t[3]=r),r};wq.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function Tq(){}var Eq=/\s/u;function Dq(e,t,n,r){if(r===null)return null;let{query:i,offset:a,endOffset:o}=r;return a<0||a+t.length>n||!e.startsWith(t,a)||o<a+t.length||o>e.length?null:{query:i,offset:a,endOffset:o}}function Oq(e,t,n,r){if(r)return Dq(e,t,n,r(e,t,n));let i=e.slice(0,n);for(let e=i.length-1;e>=0;e--){let r=i[e];if(Eq.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!Eq.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var kq=KM(e=>{let t=J(8),{text:n,triggerChar:r,matcher:i}=e,[a,o]=DM(n.length),s=Math.min(a,n.length),c;t[0]!==i||t[1]!==s||t[2]!==n||t[3]!==r?(c=Oq(n,r,s,i),t[0]=i,t[1]=s,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=c,u=l?.query??``,d;return t[5]!==u||t[6]!==l?(d={trigger:l,query:u,setCursorPosition:o},t[5]=u,t[6]=l,t[7]=d):d=t[7],d});function Aq(e){return`type`in e}var jq=KM(e=>{let t=J(22),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=DM(0),m;t[0]!==i||t[1]!==r||t[2]!==n?(m={navigableList:n,isSearchMode:r,activeCategoryId:i},t[0]=i,t[1]=r,t[2]=n,t[3]=m):m=t[3];let[h,g]=DM(m);(h.navigableList!==n||h.isSearchMode!==r||h.activeCategoryId!==i)&&(g({navigableList:n,isSearchMode:r,activeCategoryId:i}),p(0));let _;t[4]!==f||t[5]!==n.length?(_=e=>{e<0||e>=n.length||e!==f&&p(e)},t[4]=f,t[5]=n.length,t[6]=_):_=t[6];let v=MM(_),y;t[7]!==i||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==n||t[12]!==s||t[13]!==a||t[14]!==l||t[15]!==c?(y=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(Aq(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[7]=i,t[8]=d,t[9]=u,t[10]=f,t[11]=n,t[12]=s,t[13]=a,t[14]=l,t[15]=c,t[16]=y):y=t[16];let b=MM(y),x=n[f],S=s&&x?`${o}-option-${x.id}`:void 0,C;return t[17]!==b||t[18]!==v||t[19]!==f||t[20]!==S?(C={highlightedIndex:f,highlightedItemId:S,highlightIndex:v,handleKeyDown:b},t[17]=b,t[18]=v,t[19]=f,t[20]=S,t[21]=C):C=t[21],C});function Mq(e,t){return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var Nq=KM(e=>{let t=J(35),{adapter:n,query:r,open:i}=e,[a,o]=DM(null),[s,c]=DM(i);s!==i&&(c(i),i||o(null));let l;bb0:{if(!i||!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],l=e;break bb0}let e;t[1]===n?e=t[2]:(e=n.categories(),t[1]=n,t[2]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],f=e;break bb1}let e;t[4]!==n||t[5]!==d?(e=n.categoryItems(d),t[4]=n,t[5]=d,t[6]=e):e=t[6],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[7]!==n||t[8]!==r?(e=n.search(r),t[7]=n,t[8]=r,t[9]=e):e=t[9],m=e;break bb2}let e;if(t[10]!==n||t[11]!==u||t[12]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))Mq(r,i)&&e.push(r);t[10]=n,t[11]=u,t[12]=r,t[13]=e}else e=t[13];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[14]=e):e=t[14],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[15]!==u||t[16]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[15]=u,t[16]=r,t[17]=e}else e=t[17];_=e}let v=_,y;bb4:{if(g){let e;t[18]===h?e=t[19]:(e=h??[],t[18]=h,t[19]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[20]!==p||t[21]!==r){let n=r.toLowerCase();e=p.filter(e=>Mq(e,n)),t[20]=p,t[21]=r,t[22]=e}else e=t[22];y=e}let b=y,x;bb5:{if(g){let e;t[23]===h?e=t[24]:(e=h??[],t[23]=h,t[24]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[25]=C):C=t[25];let w=MM(C),T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[26]=T):T=t[26];let E=MM(T),D;return t[27]!==d||t[28]!==v||t[29]!==b||t[30]!==E||t[31]!==g||t[32]!==S||t[33]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[27]=d,t[28]=v,t[29]=b,t[30]=E,t[31]=g,t[32]=S,t[33]=w,t[34]=D):D=t[34],D}),Pq=KM(e=>{let t=J(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=Y(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>(s.current=e,()=>{s.current===e&&(s.current=null)}),t[0]=c):c=t[0];let l=MM(c),u;t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==r?(u=e=>{if(!r||!n)return;if(s.current?.(e)){o();return}let t=i.composer.getState().text,c=t.slice(0,r.offset),l=t.slice(r.endOffset),u=()=>{let t=n.formatter.serialize(e);i.composer.setText(c+t+(l.startsWith(` `)?l:` ${l}`)),a(c.length+t.length+1)};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?(i.composer.setText(c+(l.startsWith(` `)?l.slice(1):l)),a(c.length)):u(),n.onExecute(e)),o()},t[1]=i,t[2]=n,t[3]=o,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=MM(u),f;t[7]!==o||t[8]!==a||t[9]!==r?(f=()=>{o(),r&&a(r.offset)},t[7]=o,t[8]=a,t[9]=r,t[10]=f):f=t[10];let p=MM(f),m;return t[11]!==p||t[12]!==l||t[13]!==d?(m={selectItem:d,close:p,registerSelectItemOverride:l},t[11]=p,t[12]=l,t[13]=d,t[14]=m):m=t[14],m}),Fq=KM(e=>{let t=J(47),{adapter:n,text:r,triggerChar:i,matcher:a,behavior:o,aui:s,popoverId:c,isLoading:l}=e,u;t[0]!==a||t[1]!==r||t[2]!==i?(u=kq({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=PN(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=Nq({adapter:n,query:d.query,open:f}),t[4]=n,t[5]=d.query,t[6]=f,t[7]=p):p=t[7];let m=PN(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=MM(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=Pq({behavior:o,trigger:d.trigger,aui:s,triggerChar:i,setCursorPosition:d.setCursorPosition,onSelected:g}),t[10]=s,t[11]=o,t[12]=d.setCursorPosition,t[13]=d.trigger,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v=PN(_),y;t[17]!==d.query||t[18]!==m.activeCategoryId||t[19]!==m.goBack||t[20]!==m.isSearchMode||t[21]!==m.navigableList||t[22]!==m.selectCategory||t[23]!==f||t[24]!==c||t[25]!==v.close||t[26]!==v.selectItem?(y=jq({navigableList:m.navigableList,isSearchMode:m.isSearchMode,activeCategoryId:m.activeCategoryId,query:d.query,popoverId:c,open:f,selectItem:v.selectItem,selectCategory:m.selectCategory,goBack:m.goBack,close:v.close}),t[17]=d.query,t[18]=m.activeCategoryId,t[19]=m.goBack,t[20]=m.isSearchMode,t[21]=m.navigableList,t[22]=m.selectCategory,t[23]=f,t[24]=c,t[25]=v.close,t[26]=v.selectItem,t[27]=y):y=t[27];let b=PN(y),x;return t[28]!==d.query||t[29]!==d.setCursorPosition||t[30]!==l||t[31]!==b.handleKeyDown||t[32]!==b.highlightIndex||t[33]!==b.highlightedIndex||t[34]!==b.highlightedItemId||t[35]!==m.activeCategoryId||t[36]!==m.categories||t[37]!==m.goBack||t[38]!==m.isSearchMode||t[39]!==m.items||t[40]!==m.selectCategory||t[41]!==f||t[42]!==c||t[43]!==v.close||t[44]!==v.registerSelectItemOverride||t[45]!==v.selectItem?(x={open:f,query:d.query,activeCategoryId:m.activeCategoryId,categories:m.categories,items:m.items,highlightedIndex:b.highlightedIndex,isSearchMode:m.isSearchMode,isLoading:l,popoverId:c,highlightedItemId:b.highlightedItemId,selectCategory:m.selectCategory,goBack:m.goBack,selectItem:v.selectItem,close:v.close,highlightIndex:b.highlightIndex,handleKeyDown:b.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:v.registerSelectItemOverride},t[28]=d.query,t[29]=d.setCursorPosition,t[30]=l,t[31]=b.handleKeyDown,t[32]=b.highlightIndex,t[33]=b.highlightedIndex,t[34]=b.highlightedItemId,t[35]=m.activeCategoryId,t[36]=m.categories,t[37]=m.goBack,t[38]=m.isSearchMode,t[39]=m.items,t[40]=m.selectCategory,t[41]=f,t[42]=c,t[43]=v.close,t[44]=v.registerSelectItemOverride,t[45]=v.selectItem,t[46]=x):x=t[46],x}),Iq=UM(null),Lq=()=>{let e=GM(Iq);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},Rq=()=>GM(Iq),zq=UM(null),Bq=()=>{let e=GM(zq);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},Vq=Z((e,t)=>{let n=J(69),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({char:a,matcher:s,adapter:r,isLoading:l,"aria-label":i,children:o,...c}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=l!==void 0&&l,d=Q(),f=$(Hq),p=IM(),m=Y(s),h;n[8]===s?h=n[9]:(h=()=>{m.current=s},n[8]=s,n[9]=h),X(h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>(e,t,n)=>m.current(e,t,n),n[10]=g):g=n[10];let[_]=DM(g),v=s!==void 0,y=Y(null),[b,x]=DM(null),S=Y(0),C;n[11]===a?C=n[12]:(C=e=>(S.current+=1,y.current=e,x(e),()=>{S.current=Math.max(0,S.current-1),y.current===e&&(y.current=null,x(null))}),n[11]=a,n[12]=C);let w=C,T;n[13]===w?T=n[14]:(T={register:w},n[13]=w,n[14]=T);let E=T,D=b??void 0,O;n[15]!==r||n[16]!==d||n[17]!==a||n[18]!==u||n[19]!==s||n[20]!==p||n[21]!==D||n[22]!==f?(O=Fq({adapter:r,text:f,triggerChar:a,matcher:s,behavior:D,aui:d,popoverId:p,isLoading:u}),n[15]=r,n[16]=d,n[17]=a,n[18]=u,n[19]=s,n[20]=p,n[21]=D,n[22]=f,n[23]=O):O=n[23];let k=PN(O),A;n[24]===k?A=n[25]:(A=()=>k,n[24]=k,n[25]=A);let j=MM(A),M=fq(),ee;n[26]!==b||n[27]!==a||n[28]!==j||n[29]!==v||n[30]!==_||n[31]!==M?(ee=()=>M.register({char:a,...v?{matcher:_}:{},...b?{behavior:b}:{},resource:j()}),n[26]=b,n[27]=a,n[28]=j,n[29]=v,n[30]=_,n[31]=M,n[32]=ee):ee=n[32];let te;n[33]!==b||n[34]!==a||n[35]!==v||n[36]!==M?(te=[M,a,v,b],n[33]=b,n[34]=a,n[35]=v,n[36]=M,n[37]=te):te=n[37],X(ee,te);let ne=oq(),re;n[38]!==j||n[39]!==ne?(re=()=>{if(ne)return ne.register(j())},n[38]=j,n[39]=ne,n[40]=re):re=n[40];let ie;n[41]===ne?ie=n[42]:(ie=[ne],n[41]=ne,n[42]=ie),X(re,ie);let ae=b!==null&&k.open,oe=mq(),se,ce;n[43]!==oe||n[44]!==a||n[45]!==ae?(se=()=>{if(ae)return()=>{oe.setActiveAria(a,null)}},ce=[oe,a,ae],n[43]=oe,n[44]=a,n[45]=ae,n[46]=se,n[47]=ce):(se=n[46],ce=n[47]),X(se,ce);let le,ue;n[48]!==oe||n[49]!==a||n[50]!==ae||n[51]!==p||n[52]!==k.highlightedItemId?(le=()=>{ae&&oe.setActiveAria(a,{popoverId:p,highlightedItemId:k.highlightedItemId})},ue=[oe,a,p,ae,k.highlightedItemId],n[48]=oe,n[49]=a,n[50]=ae,n[51]=p,n[52]=k.highlightedItemId,n[53]=le,n[54]=ue):(le=n[53],ue=n[54]),X(le,ue);let de;n[55]!==i||n[56]!==o||n[57]!==t||n[58]!==ae||n[59]!==p||n[60]!==c||n[61]!==k.highlightedItemId?(de=ae?(0,P.jsx)(tK.div,{role:`listbox`,id:p,"aria-label":i??`Suggestions`,"aria-activedescendant":k.highlightedItemId,"data-state":`open`,...c,ref:t,children:o}):o,n[55]=i,n[56]=o,n[57]=t,n[58]=ae,n[59]=p,n[60]=c,n[61]=k.highlightedItemId,n[62]=de):de=n[62];let fe;n[63]!==k||n[64]!==de?(fe=(0,P.jsx)(Iq.Provider,{value:k,children:de}),n[63]=k,n[64]=de,n[65]=fe):fe=n[65];let pe;return n[66]!==E||n[67]!==fe?(pe=(0,P.jsx)(zq.Provider,{value:E,children:fe}),n[66]=E,n[67]=fe,n[68]=pe):pe=n[68],pe});Vq.displayName=`ComposerPrimitive.TriggerPopover`;function Hq(e){return e.composer.text}var Uq=()=>{let e=J(2),{disabled:t,send:n}=WW(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},Wq=pK(`ComposerPrimitive.Send`,Uq),Gq=UM(null),Kq=()=>GM(Gq),qq=`[contenteditable]:not([contenteditable='false'])`,Jq=`textarea:not(:disabled), ${qq}`,Yq=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,qq,`[tabindex]`].join(`, `),Xq=Z((e,t)=>{let n=J(24),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({onSubmit:a,onMouseDown:i,compact:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=Uq(),[c,l]=DM(!1),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={setMultiline:l},n[5]=u):u=n[5];let d=u,f;n[6]===r?f=n[7]:(f=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
93
- `):!1,n[6]=r,n[7]=f);let p=$(f)&&!c,m;n[8]===s?m=n[9]:(m=e=>{e.preventDefault(),s&&s()},n[8]=s,n[9]=m);let h=m,g=Zq,_=r?d:null,v=p?``:void 0,y;n[10]!==h||n[11]!==a?(y=F(a,h),n[10]=h,n[11]=a,n[12]=y):y=n[12];let b;n[13]===i?b=n[14]:(b=F(i,g),n[13]=i,n[14]=b);let x;n[15]!==t||n[16]!==o||n[17]!==v||n[18]!==y||n[19]!==b?(x=(0,P.jsx)(tK.form,{...o,"data-compact":v,ref:t,onSubmit:y,onMouseDown:b}),n[15]=t,n[16]=o,n[17]=v,n[18]=y,n[19]=b,n[20]=x):x=n[20];let S;return n[21]!==_||n[22]!==x?(S=(0,P.jsx)(Gq.Provider,{value:_,children:x}),n[21]=_,n[22]=x,n[23]=S):S=n[23],S});Xq.displayName=`ComposerPrimitive.Root`;function Zq(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(Yq);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(Jq);r&&(e.preventDefault(),r.focus())}var Qq=e=>{let t=J(4),n=ln(e),r=DG($q),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)};function $q(e){return e.onScrollToBottom}var eJ=()=>!1,tJ=()=>{},nJ=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return tJ;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),NM(r,i,eJ)};function rJ(){return $(iJ)}function iJ(e){return e.composer.isEditing?e.composer.text:``}function aJ(e){return!!$(oJ)||!!e}function oJ(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function sJ(){let e=J(4),t=xq();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function cJ(){return cJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cJ.apply(null,arguments)}function lJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var uJ=N.useLayoutEffect,dJ=function(e){var t=N.useRef(e);return uJ(function(){t.current=e}),t},fJ=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},pJ=function(e,t){var n=N.useRef();return N.useCallback(function(r){e.current=r,n.current&&fJ(n.current,null),n.current=t,t&&fJ(t,r)},[t])},mJ={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},hJ=function(e){Object.keys(mJ).forEach(function(t){e.style.setProperty(t,mJ[t],`important`)})},gJ=null,_J=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function vJ(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),gJ||(gJ=document.createElement(`textarea`),gJ.setAttribute(`tabindex`,`-1`),gJ.setAttribute(`aria-hidden`,`true`),hJ(gJ)),gJ.parentNode===null&&document.body.appendChild(gJ);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;gJ.style[t]=o[t]}),hJ(gJ),gJ.value=t;var c=_J(gJ,e);gJ.value=t,c=_J(gJ,e),gJ.value=`x`;var l=gJ.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var yJ=function(){},bJ=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},xJ=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],SJ=!!document.documentElement.currentStyle,CJ=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=bJ(xJ,t),r=n.boxSizing;return r===``?null:(SJ&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function wJ(e,t,n){var r=dJ(n);N.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var TJ=function(e,t){wJ(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},EJ=function(e){wJ(window,`resize`,e)},DJ=function(e){wJ(document.fonts,`loadingdone`,e)},OJ=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],kJ=N.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?yJ:a,s=e.onHeightChange,c=s===void 0?yJ:s,l=lJ(e,OJ),u=l.value!==void 0,d=N.useRef(null),f=pJ(d,t),p=N.useRef(0),m=N.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:CJ(e);if(t){m.current=t;var a=vJ(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return N.useLayoutEffect(h),TJ(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),EJ(h),DJ(h),N.createElement(`textarea`,cJ({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),AJ=`(pointer: coarse) and (not (any-pointer: fine))`,jJ=Z(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:l,submitMode:u,cancelOnEscape:f=!0,unstable_focusOnRunStart:p=!0,unstable_focusOnScrollToBottom:m=!0,unstable_focusOnThreadSwitched:h=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:_=!0,onHeightChange:v,...y},b)=>{let x=Q(),S=oq(),C=Kq(),w=u??(l===!1?`none`:`enter`),T=nJ(g?AJ:null),E=g&&T&&w===`enter`?`none`:w,D=rJ(),O=aJ(r),k=Y(null),A=d(b,k),j=Y(!1);KG(e=>{if(!k.current?.contains(e.target)||e.isComposing)return;if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}if(!f)return;let t=x.composer;t.getState().canCancel&&(t.cancel(),e.preventDefault())});let M=e=>{if(!O&&!e.nativeEvent.isComposing){if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=x.thread.getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&w!==`none`&&x.composer.getState().canSend){e.preventDefault(),x.composer.send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;E===`ctrlEnter`?r=e.ctrlKey||e.metaKey:E===`enter`&&(r=!0),r&&(e.preventDefault(),k.current?.closest(`form`)?.requestSubmit())}}},ee=async e=>{if(!_)return;let t=x.thread.getState().capabilities,n=Array.from(e.clipboardData?.files||[]);t.attachments&&n.length>0&&(e.preventDefault(),await Promise.all(n.map(async e=>{try{await x.composer.addAttachment(e)}catch{}})))},te=(e,t)=>{if(v?.(e,t),!C)return;let n=k.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&C.setMultiline(!0)},ne=e&&!O,re=AM(()=>{let e=k.current;e&&ne&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[ne]);X(()=>re(),[re]),Qq(()=>{x.composer.getState().type===`thread`&&m&&re()}),X(()=>{if(x.composer.getState().type===`thread`&&p)return x.on(`thread.runStart`,re)},[p,re,x]),X(()=>{if(x.composer.getState().type===`thread`&&h)return x.on(`threads.selectionChanged`,re)},[h,re,x]),X(()=>{D===``&&C?.setMultiline(!1)},[D,C]);let ie=sJ(),ae={name:`input`,value:D,...y,...ie,ref:A,disabled:O,onChange:F(i,e=>{if(!x.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;j.current&&!t&&(j.current=!1);let n=t||j.current;if(aN(()=>{x.composer.setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(r)}),onKeyDown:F(a,M),onCompositionStart:F(y.onCompositionStart,()=>{j.current=!0}),onCompositionEnd:F(y.onCompositionEnd,e=>{if(j.current=!1,!x.composer.getState().isEditing)return;let t=e.target;aN(()=>{x.composer.setText(t.value)});let n=t.selectionStart??t.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(n)}),onSelect:F(s,e=>{if(j.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(n)}),onPaste:F(o,ee),...C?{onHeightChange:te}:v===void 0?{}:{onHeightChange:v}};if(n&&HM(n))return QG(n,y.children,ae);let oe=t?c:kJ;return(0,P.jsx)(oe,{...ae})});jJ.displayName=`ComposerPrimitive.Input`;var MJ=pK(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=GW();return e?null:t}),NJ=pK(`ComposerPrimitive.AddAttachment`,e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=JW(),s=Q(),c;return t[2]!==o||t[3]!==s.composer||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer.getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=async t=>{let n=t.target.files;if(!n)return;let r=Array.from(n,async e=>{try{await o(e)}catch{}});document.body.removeChild(e),await Promise.all(r)},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s.composer,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),PJ=Z(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,s]=DM(!1),l=Q(),u=AM(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}s(!0)}},[e,l]),d=AM(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}o||s(!0)}},[e,o,l]),f=AM(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||s(!1)},[e]),p=AM(async t=>{if(e||(s(!1),!t.dataTransfer.types.includes(`Files`)))return;t.preventDefault();let n=Array.from(t.dataTransfer.files);l.thread.getState().capabilities.attachments&&n.length!==0&&await Promise.all(n.map(async e=>{try{await l.composer.addAttachment(e)}catch{}}))},[e,l]),m={...o?{"data-dragging":`true`}:null,...i,onDragEnterCapture:F(i.onDragEnterCapture,u),onDragOverCapture:F(i.onDragOverCapture,d),onDragLeaveCapture:F(i.onDragLeaveCapture,f),onDropCapture:F(i.onDropCapture,p),ref:a};if(n&&HM(n))return QG(n,r,m);let h=t?c:`div`;return(0,P.jsx)(h,{...m,children:r})});PJ.displayName=`ComposerPrimitive.AttachmentDropzone`;var FJ=pK(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=KW();return e?null:t}),IJ=pK(`ComposerPrimitive.StopDictation`,()=>{let e=J(2),t=Q(),n=$(LJ),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function LJ(e){return e.composer.dictation!=null}var RJ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(zJ);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(tK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});RJ.displayName=`ComposerPrimitive.DictationTranscript`;function zJ(e){return e.composer.dictation?.transcript}var BJ=Z((e,t)=>{let n=J(3);if(!$(UJ))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(tK.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});BJ.displayName=`ComposerPrimitive.Quote`;var VJ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(WJ);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(tK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});VJ.displayName=`ComposerPrimitive.QuoteText`;var HJ=Z((e,t)=>{let n=J(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(),o;n[3]===a?o=n[4]:(o=()=>{a.composer.setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=F(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,P.jsx)(tK.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});HJ.displayName=`ComposerPrimitive.QuoteDismiss`;function UJ(e){return e.composer.quote}function WJ(e){return e.composer.quote?.text}var GJ=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=Lq();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,P.jsx)(tK.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});GJ.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var KJ=Z((e,t)=>{let n=J(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=Lq(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let b=y,x=`${p}-option-${r}`,S=v?``:void 0,C;n[16]!==h||n[17]!==i?(C=F(i,h),n[16]=h,n[17]=i,n[18]=C):C=n[18];let w;n[19]!==b||n[20]!==a?(w=F(a,b),n[19]=b,n[20]=a,n[21]=w):w=n[21];let T;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==x||n[26]!==S||n[27]!==C||n[28]!==w?(T=(0,P.jsx)(tK.button,{type:`button`,role:`option`,id:x,"aria-selected":v,"data-highlighted":S,...o,ref:t,onClick:C,onMouseMove:w}),n[22]=t,n[23]=v,n[24]=o,n[25]=x,n[26]=S,n[27]=C,n[28]=w,n[29]=T):T=n[29],T});KJ.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var qJ=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=Lq();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,P.jsx)(tK.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});qJ.displayName=`ComposerPrimitive.TriggerPopoverItems`;var JJ=Z((e,t)=>{let n=J(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=Lq(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,b;n[13]!==l||n[14]!==v?(b=()=>{l(v)},n[13]=l,n[14]=v,n[15]=b):b=n[15];let x=b,S=`${m}-option-${i.id}`,C=y?``:void 0,w;n[16]!==g||n[17]!==a?(w=F(a,g),n[16]=g,n[17]=a,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==o?(T=F(o,x),n[19]=x,n[20]=o,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,P.jsx)(tK.button,{type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C,...s,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=y,n[24]=s,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});JJ.displayName=`ComposerPrimitive.TriggerPopoverItem`;var YJ=Z((e,t)=>{let n=J(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=Lq();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=F(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,P.jsx)(tK.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});YJ.displayName=`ComposerPrimitive.TriggerPopoverBack`;var XJ=e=>{let t=J(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=Bq(),o=Y(r),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{o.current=r},c=[r],t[0]=r,t[1]=s,t[2]=c),FM(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e={kind:`action`,formatter:n??UG,onExecute:e=>o.current(e),...i===void 0?{}:{removeOnExecute:i}};return a(e)},u=[a,n,i],t[3]=n,t[4]=a,t[5]=i,t[6]=l,t[7]=u):(l=t[6],u=t[7]),X(l,u),null};XJ.displayName=`ComposerPrimitive.TriggerPopoverAction`;var ZJ=e=>{let t=J(7),{formatter:n,onInserted:r}=e,{register:i}=Bq(),a=Y(r),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{a.current=r},s=[r],t[0]=r,t[1]=o,t[2]=s),FM(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n??UG,onInserted:e=>a.current?.(e)}),l=[i,n],t[3]=n,t[4]=i,t[5]=c,t[6]=l):(c=t[5],l=t[6]),X(c,l),null};ZJ.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var QJ=Object.assign(Vq,{Directive:ZJ,Action:XJ}),$J=YG({AddAttachment:()=>NJ,AttachmentByIndex:()=>hW,AttachmentDropzone:()=>PJ,Attachments:()=>_W,Cancel:()=>MJ,Dictate:()=>FJ,DictationTranscript:()=>RJ,If:()=>NW,Input:()=>jJ,Queue:()=>yW,Quote:()=>BJ,QuoteDismiss:()=>HJ,QuoteText:()=>VJ,Root:()=>Xq,Send:()=>Wq,StopDictation:()=>IJ,Unstable_TriggerPopover:()=>QJ,Unstable_TriggerPopoverBack:()=>YJ,Unstable_TriggerPopoverCategories:()=>GJ,Unstable_TriggerPopoverCategoryItem:()=>KJ,Unstable_TriggerPopoverItem:()=>JJ,Unstable_TriggerPopoverItems:()=>qJ,Unstable_TriggerPopoverRoot:()=>wq,unstable_useTriggerPopoverRootContext:()=>fq,unstable_useTriggerPopoverRootContextOptional:()=>pq,unstable_useTriggerPopoverScopeContext:()=>Lq,unstable_useTriggerPopoverScopeContextOptional:()=>Rq,unstable_useTriggerPopoverTriggers:()=>hq,unstable_useTriggerPopoverTriggersOptional:()=>yq}),eY=Object.freeze({type:`complete`}),tY=Object.freeze({type:`text`,text:``,status:eY}),nY=()=>$(rY);function rY(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?tY:e.part}var iY=UM(null),aY=e=>({useSmoothStatus:PG(()=>e)}),oY=e=>{let t=J(6),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={optional:!0},t[0]=r):r=t[0];let i=cY(r),a=Q(),o;t[1]===a.part?o=t[2]:(o=()=>aY(a.part.getState().status),t[1]=a.part,t[2]=o);let[s]=DM(o);if(i)return n;let c;return t[3]!==n||t[4]!==s?(c=(0,P.jsx)(iY.Provider,{value:s,children:n}),t[3]=n,t[4]=s,t[5]=c):c=t[5],c},sY=e=>{let t=Z((t,n)=>{let r=J(3),i=t,a;return r[0]!==n||r[1]!==i?(a=(0,P.jsx)(oY,{children:(0,P.jsx)(e,{...i,ref:n})}),r[0]=n,r[1]=i,r[2]=a):a=r[2],a});return t.displayName=e.displayName,t};function cY(e){let t=GM(iY);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:lY,useSmoothStatusStore:uY}=TG(cY,`useSmoothStatus`),dY=250,fY=5,pY=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=dY;maxCharIntervalMs=fY;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},mY=Object.freeze({type:`running`}),hY=(e,t)=>e!==void 0&&e>0?e:t,gY=(e,t=!1)=>{let{text:n}=e,r=nJ(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=hY(i?.drainMs,dY),s=hY(i?.maxCharIntervalMs,fY),c=hY(i?.maxCharsPerFrame,1/0),l=hY(i?.minCommitMs,0),[u,d]=DM(e.status.type===`running`?``:n),f=Q(),p=$(()=>f.part),[m,h]=DM(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=uY({optional:!0}),_=ln(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?mY:e.status;LG(g).setState(n,!0)}});X(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?mY:e.status;LG(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=DM(new pY(u,_));X(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=Y(p);return X(()=>{if(!a){v.stop();return}let t=y.current!==p;if(y.current=p,t||!n.startsWith(v.targetText)){e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=0,v.start()):(v.currentText=n,v.targetText=n,v.stop(),_(n));return}if(v.targetText=n,e.status.type!==`running`){if(v.currentText===``){v.currentText=n,v.stop(),_(n);return}v.start();return}v.start()},[v,a,n,e.status.type,p,_]),X(()=>()=>{v.stop()},[v]),kM(()=>a?{...e,text:u,status:n===u?e.status:mY}:e,[a,u,e,n])},_Y=Object.freeze({type:`complete`}),vY=Object.freeze({type:`image`,image:``,status:_Y}),yY=()=>$(bY);function bY(e){return e.part.type===`image`?e.part:vY}var xY=Z(({smooth:e=!0,component:t=tK.span,render:n,...r},i)=>{let{text:a,status:o}=gY(nY(),e),s={"data-status":o.type,...r,ref:i};return n&&HM(n)?QG(n,a,s):(0,P.jsx)(t,{...s,children:a})});xY.displayName=`MessagePartPrimitive.Text`;var SY=Z((e,t)=>{let n=J(4),{image:r}=yY(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,P.jsx)(tK.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});SY.displayName=`MessagePartPrimitive.Image`;var CY=Z((e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(tK.div,{role:`alert`,...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});CY.displayName=`ErrorPrimitive.Root`;var wY=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=SG();if(a===void 0)return null;let o=r??String(a),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(tK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});wY.displayName=`ErrorPrimitive.Message`;var TY=YG({Message:()=>wY,Root:()=>CY}),EY=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},DY=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},OY=e=>e.dataset.messageId,kY=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},AY=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},jY=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},MY=()=>{let e=J(4),t=Q(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=$(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),EY(i)},NY=()=>{let e=J(2),t=DG(BY),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},PY=()=>{let e=J(2),t=DG(VY),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},FY=(e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],EY(r)},IY=e=>{let t=J(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:DY(i.tallerThan,e),visibleHeight:DY(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],EY(i)},LY=e=>{let t=J(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=MY(),a=d(n,i),o=$(HY),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,P.jsx)(tK.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},RY=e=>{let t=J(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=MY(),o=NY(),s=PY(),c=FY(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let u=IY(l),f=d(n,a,c,u),p=$(UY),m=o?``:void 0,h=s?``:void 0,g;return t[7]!==p||t[8]!==r||t[9]!==f||t[10]!==m||t[11]!==h?(g=(0,P.jsx)(tK.div,{...r,ref:f,"data-message-id":p,"data-aui-top-anchor-user":m,"data-aui-top-anchor-target":h}),t[7]=p,t[8]=r,t[9]=f,t[10]=m,t[11]=h,t[12]=g):g=t[12],g},zY=Z((e,t)=>{let n=J(7),r=OG();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,P.jsx)(RY,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,P.jsx)(LY,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});zY.displayName=`MessagePrimitive.Root`;function BY(e){return e.topAnchorTurn?.anchorId}function VY(e){return e.topAnchorTurn?.targetId}function HY(e){return e.message.id}function UY(e){return e.message.id}var WY={...vU,Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(xY,{}),(0,P.jsx)(CW,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,P.jsx)(SY,{})},GY=e=>{let t=J(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,P.jsx)(FU,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{...n,Text:n.Text??WY.Text,Image:n.Image??WY.Image}:WY,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,P.jsx)(FU,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};GY.displayName=`MessagePrimitive.Parts`;var KY=e=>{let t=J(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],$(n)},qY=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),KY(r)?n:null};qY.displayName=`MessagePrimitive.If`;var JY=e=>{let{children:t}=e;return SG()===void 0?null:t};JY.displayName=`MessagePrimitive.Error`;var YY=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??n,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=typeof e==`string`?e:void 0;n.push({groupKey:t,indices:r})}return n},XY=e=>{let t=J(4),n=$(sX),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},ZY=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},QY=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},$Y={Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(xY,{}),(0,P.jsx)(CW,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,P.jsx)(SY,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},eX=e=>{let t=J(37),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?$Y.Text:i,p=a===void 0?$Y.Reasoning:a,m=o===void 0?$Y.Image:o,h=s===void 0?$Y.Source:s,g=c===void 0?$Y.File:c,_=l===void 0?$Y.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,b=Q(),x=$(cX),S=x.type;if(S===`tool-call`){let e=b.part.addToolResult,n=b.part.resumeToolCall,r=b.part.respondToToolApproval;if(`Override`in y){let i;return t[4]!==e||t[5]!==x||t[6]!==r||t[7]!==n||t[8]!==y.Override?(i=(0,P.jsx)(y.Override,{...x,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=x,t[6]=r,t[7]=n,t[8]=y.Override,t[9]=i):i=t[9],i}let i=y.by_name?.[x.toolName]??y.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==x||t[13]!==r||t[14]!==n?(a=(0,P.jsx)(ZY,{...x,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=x,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(x.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(S){case`text`:{let e;return t[16]!==f||t[17]!==x?(e=(0,P.jsx)(f,{...x}),t[16]=f,t[17]=x,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==p||t[20]!==x?(e=(0,P.jsx)(p,{...x}),t[19]=p,t[20]=x,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==h||t[23]!==x?(e=(0,P.jsx)(h,{...x}),t[22]=h,t[23]=x,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==m||t[26]!==x?(e=(0,P.jsx)(m,{...x}),t[25]=m,t[26]=x,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==g||t[29]!==x?(e=(0,P.jsx)(g,{...x}),t[28]=g,t[29]=x,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==_||t[32]!==x?(e=(0,P.jsx)(_,{...x}),t[31]=_,t[32]=x,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[x.name]??d?.Fallback,n;return t[34]!==e||t[35]!==x?(n=(0,P.jsx)(QY,{...x,Fallback:e}),t[34]=e,t[35]=x,t[36]=n):n=t[36],n}default:return console.warn(`Unknown message part type: ${S}`),null}},tX=RM(e=>{let t=J(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(eX,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(fB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),nX=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,P.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,P.jsx)(mB,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},rX=Object.freeze({type:`complete`}),iX=RM(e=>{let t=J(6),{components:n}=e,r=$(lX);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,P.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??$Y.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(nX,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),aX=e=>{let t=J(9),{groupingFunction:n,components:r}=e,i=$(uX),a=XY(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,P.jsx)(iX,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>{let n=r?.Group??$Y.Group;return(0,P.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,P.jsx)(tX,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`)},t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,P.jsx)(P.Fragment,{children:s}),t[7]=s,t[8]=c),c};aX.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var oX=e=>{let t=J(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,P.jsx)(aX,{...r,components:n,groupingFunction:YY}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};oX.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function sX(e){return e.message.parts}function cX(e){return e.part}function lX(e){return e.message.status??rX}function uX(e){return e.message.parts.length}var dX=YG({AttachmentByIndex:()=>lW,Attachments:()=>dW,Content:()=>GY,Error:()=>JY,GenerativeUI:()=>uU,GroupedParts:()=>aW,If:()=>qY,PartByIndex:()=>bU,Parts:()=>GY,Quote:()=>oW,Root:()=>zY,Unstable_PartsGrouped:()=>aX,Unstable_PartsGroupedByParentId:()=>oX}),fX=e=>{let t=J(2),n=ln(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(pX)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),EY(r)};function pX(e){return e.type!==`attributes`||e.attributeName!==`style`}var mX=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=Y(null),a=$(e=>e.thread.messages.length>0),o=$(e=>e.thread.isRunning),s=Y(!1),c=Y(null),l=OG();e===void 0&&(e=l.getState().turnAnchor!==`top`);let u=Y(0),f=Y(0),p=Y(0),m=Y(0),h=Y(null),g=Y(e),_=Y(e);jM(()=>{let t=_.current;if(_.current=e,t||!e)return;let n=i.current;g.current=n!==null&&MF(n)},[e]);let v=AM(e=>{let t=i.current;t&&(g.current=!0,h.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),y=AM(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),b=AM(e=>{h.current=e,y(),c.current=requestAnimationFrame(()=>{c.current=null,v(e)})},[y,v]);jM(()=>()=>y(),[y]);let x=AM(()=>{let e=l.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[l]),S=()=>{let t=i.current;if(!t)return;let n=l.getState().isAtBottom,r=MF(t);if(!(!r&&u.current<t.scrollTop)){let i=PF({scrollTop:u.current,scrollHeight:f.current},t);r?(NF(t)&&(h.current=null),e&&(g.current=!0)):i&&(y(),h.current=null,g.current=!1),(r||h.current===null)&&r!==n&&LG(l).setState({isAtBottom:r})}u.current=t.scrollTop,f.current=t.scrollHeight},C=fX(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===p.current&&r===m.current)return;p.current=n,m.current=r;let a=h.current;a&&x()?h.current=null:a?v(a):e&&!(o&&x())&&g.current&&v(`instant`),S()}),w=EY(e=>{let t=()=>{h.current=null};return e.addEventListener(`scroll`,S),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,S),e.removeEventListener(`pointerdown`,t)}});return jM(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,h.current===null&&b(`instant`))}},[a,b,n]),Qq(({behavior:e})=>{v(e)}),aL(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&b(`auto`)}),aL(`threads.selectionChanged`,()=>{r&&b(`instant`)}),d(C,w,i)},hX=Z((e,t)=>{let n=J(6),r=Q(),i,a;n[0]===r?(i=n[1],a=n[2]):(i=()=>{let e=e=>{if(e.key===`Escape`&&!(e.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},a=[r],n[0]=r,n[1]=i,n[2]=a),X(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,P.jsx)(tK.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});hX.displayName=`ThreadPrimitive.Root`;var gX=e=>{let{children:t}=e;return $(_X)?t:null};gX.displayName=`ThreadPrimitive.Empty`;function _X(e){return e.thread.isEmpty}var vX=e=>{let t=J(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],$(n)},yX=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),vX(r)?n:null};yX.displayName=`ThreadPrimitive.If`;var bX=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],EY(r)},xX=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},SX=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:xX(e)-xX(t)},CX=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=SX(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},wX=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=CX(t)+n.clientHeight;return Math.max(0,r-e)},TX=({viewport:e,reserve:t,...n})=>wX({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),EX=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},DX=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},OX=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o){a.disconnect(),t&&(AY(t,0),t.remove());return}if(!s&&!c&&!l&&r.topAnchorTurn){a.disconnect(),t?.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!s||!c||!l){a.disconnect(),t&&(AY(t,0),t.remove());return}if(t??=kY(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),AY(t,TX({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=OY(s);if(u!==void 0&&n===u)return;let d=jY(CX({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=DX(r),a=EX(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},kX=e=>{let t=J(4),n=OG(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return OX(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),jM(r,i)},AX=(e,t)=>{if(!e)return!1;let n=t.findIndex(t=>t.id===e.targetId);return n<1?!1:t[n-1]?.id===e.anchorId&&t.slice(n+1).every(e=>e.role===`user`)},jX=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},MX=e=>jX(e)?.anchorId,NX=e=>jX(e)?.targetId,PX=()=>bX(DG(zX),BX),FX=()=>EY(DG(VX)),IX=e=>{let t=J(19),n=OG(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return MX(t.thread)},t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return NX(t.thread)},t[2]=e,t[3]=a);let o=$(a),s=DG(HX),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&AX(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=$(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{s&&!d&&n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),jM(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;(t?.anchorId!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),jM(m,h)},LX=Z((e,t)=>{let n=J(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let u=mX(l),f=PX(),p=FX(),m=OG(),h;n[12]===m?h=n[13]:(h=m.getState(),n[12]=m,n[13]=h);let g=h.turnAnchor===`top`;IX(g),kX(g);let _=d(t,u,f,p),v;return n[14]!==i||n[15]!==_||n[16]!==a?(v=(0,P.jsx)(tK.div,{...a,ref:_,children:i}),n[14]=i,n[15]=_,n[16]=a,n[17]=v):v=n[17],v});LX.displayName=`ThreadPrimitive.ViewportScrollable`;var RX=Z((e,t)=>{let n=J(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,P.jsx)(LX,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,P.jsx)(zG,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});RX.displayName=`ThreadPrimitive.Viewport`;function zX(e){return e.registerViewport}function BX(e){return e.clientHeight}function VX(e){return e.registerViewportElement}function HX(e){return e.topAnchorTurn}var UX=Z((e,t)=>{let n=J(3),r=bX(DG(WX),GX),i=d(t,r),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(tK.div,{...e,ref:i}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});UX.displayName=`ThreadPrimitive.ViewportFooter`;function WX(e){return e.registerContentInset}function GX(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var KX=pK(`ThreadPrimitive.ScrollToBottom`,e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=DG(qX),a=OG(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function qX(e){return e.isAtBottom}var JX=pK(`ThreadPrimitive.Suggestion`,e=>{let t=J(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=mG(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),YX=YG({Empty:()=>gX,If:()=>yX,MessageByIndex:()=>ZH,Messages:()=>tU,Root:()=>hX,ScrollToBottom:()=>KX,Suggestion:()=>JX,SuggestionByIndex:()=>OW,Suggestions:()=>jW,Unstable_MessageById:()=>QH,Viewport:()=>RX,ViewportFooter:()=>UX,ViewportProvider:()=>zG}),XX=Z((e,t)=>{let n=J(4),r=$(ZX),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(tK.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});XX.displayName=`SuggestionPrimitive.Title`;function ZX(e){return e.suggestion.title}var QX=Z((e,t)=>{let n=J(4),r=$($X),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(tK.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});QX.displayName=`SuggestionPrimitive.Description`;function $X(e){return e.suggestion.label}var eZ=pK(`SuggestionPrimitive.Trigger`,e=>{let t=J(4),{send:n,clearComposer:r}=e,i=$(tZ),a;t[0]!==r||t[1]!==i||t[2]!==n?(a={prompt:i,send:n,clearComposer:r},t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3];let{trigger:o,disabled:s}=mG(a);return s?null:o},[`send`,`clearComposer`]);function tZ(e){return e.suggestion.prompt}var nZ=YG({Description:()=>QX,Title:()=>XX,Trigger:()=>eZ}),rZ=Z((e,t)=>{let n=J(15),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(iZ),{switchToNewThread:s}=bG(),c;n[4]===o?c=n[5]:(c=o?{"data-active":`true`,"aria-current":`true`}:null,n[4]=o,n[5]=c);let l;n[6]!==i||n[7]!==s?(l=F(i,s),n[6]=i,n[7]=s,n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==t||n[11]!==a||n[12]!==c||n[13]!==l?(u=(0,P.jsx)(tK.button,{type:`button`,...c,...a,ref:t,disabled:r,onClick:l}),n[9]=r,n[10]=t,n[11]=a,n[12]=c,n[13]=l,n[14]=u):u=n[14],u});rZ.displayName=`ThreadListPrimitive.New`;function iZ(e){return e.threads.newThreadId===e.threads.mainThreadId}var aZ=pK(`ThreadListPrimitive.LoadMore`,()=>{let{loadMore:e,disabled:t}=xG();return t?null:e}),[oZ,sZ]=Ye(`ThreadList`),cZ=oZ,lZ=UM(null),uZ=lZ.Provider,dZ=()=>GM(lZ),fZ=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(cZ.Provider,{scope:void 0,children:(0,P.jsx)(cZ.Slot,{scope:void 0,children:(0,P.jsx)(tK.div,{...e,ref:t})})}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});fZ.displayName=`ThreadListPrimitive.Root`;var pZ=YG({ItemByIndex:()=>bW,Items:()=>SW,LoadMore:()=>aZ,New:()=>rZ,Root:()=>fZ}),mZ=Z((e,t)=>{let n=$(e=>e.threads.mainThreadId===e.threadListItem.id),r=Y(null),i=Y(null),a=kM(()=>({triggerRef:r,moreRef:i}),[]),o=sZ(void 0),s=on(),c=e=>{let t=s===`rtl`?`ArrowLeft`:`ArrowRight`,n=s===`rtl`?`ArrowRight`:`ArrowLeft`,a=r.current,c=i.current;if(a&&e.target===a){if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=o().map(e=>e.ref.current).filter(e=>e!==null),n=t[t.indexOf(a)+(e.key===`ArrowDown`?1:-1)];n&&(n.focus(),e.preventDefault())}else e.key===t&&c&&(c.focus(),e.preventDefault())}else c&&e.target===c&&e.key===n&&(a?.focus(),e.preventDefault())};return(0,P.jsx)(uZ,{value:a,children:(0,P.jsx)(tK.div,{...n?{"data-active":`true`,"aria-current":`true`}:null,...e,onKeyDown:F(e.onKeyDown,c),ref:t})})});mZ.displayName=`ThreadListItemPrimitive.Root`;var hZ=pK(`ThreadListItemPrimitive.Archive`,()=>{let{archive:e}=gG();return e}),gZ=pK(`ThreadListItemPrimitive.Unarchive`,()=>{let{unarchive:e}=vG();return e}),_Z=pK(`ThreadListItemPrimitive.Delete`,()=>{let{delete:e}=_G();return e}),vZ=pK(`ThreadListItemPrimitive.Trigger`,()=>{let{switchTo:e}=yG();return e}),yZ=Z((e,t)=>{let n=J(3),r=dZ(),i=d(t,r?.triggerRef),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(cZ.ItemSlot,{scope:void 0,children:(0,P.jsx)(vZ,{...e,ref:i})}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});yZ.displayName=`ThreadListItemPrimitive.Trigger`;var bZ=YG({Archive:()=>hZ,Delete:()=>_Z,Root:()=>mZ,Title:()=>TW,Trigger:()=>yZ,Unarchive:()=>gZ}),xZ=au(),SZ=UM(()=>{}),CZ=()=>GM(SZ),wZ=UM(!1),TZ=()=>GM(wZ),EZ=e=>{let t=J(26),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({__scopeThreadListItemMore:n,open:o,defaultOpen:r,onOpenChange:a,sharedFocusGroup:c,modal:i,...s}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c!==void 0&&c,u=l?!1:i??!0,d=xZ(n),f=r??!1,p;t[8]===a?p=t[9]:(p=a?{onChange:a}:{},t[8]=a,t[9]=p);let m;t[10]!==o||t[11]!==f||t[12]!==p?(m={prop:o,defaultProp:f,caller:`ThreadListItemMorePrimitive.Root`,...p},t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13];let[h,g]=St(m),_;t[14]!==u||t[15]!==h||t[16]!==s||t[17]!==d||t[18]!==g?(_=(0,P.jsx)(Du,{...d,...s,modal:u,open:h,onOpenChange:g}),t[14]=u,t[15]=h,t[16]=s,t[17]=d,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==g||t[21]!==_?(v=(0,P.jsx)(SZ.Provider,{value:g,children:_}),t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;return t[23]!==l||t[24]!==v?(y=(0,P.jsx)(wZ.Provider,{value:l,children:v}),t[23]=l,t[24]=v,t[25]=y):y=t[25],y};EZ.displayName=`ThreadListItemMorePrimitive.Root`;var DZ=Z((e,t)=>{let n=J(10),{__scopeThreadListItemMore:r,...i}=e,a=xZ(r),o=dZ(),s=CZ(),c=TZ(),l=d(t,o?.moreRef),u=on()===`rtl`?`ArrowLeft`:`ArrowRight`,f=NK,p;n[0]!==u||n[1]!==s||n[2]!==c?(p=e=>{c&&e.key===u&&(e.preventDefault(),s(!0))},n[0]=u,n[1]=s,n[2]=c,n[3]=p):p=n[3];let m=F(i.onKeyDown,p),h;return n[4]!==f||n[5]!==l||n[6]!==i||n[7]!==a||n[8]!==m?(h=(0,P.jsx)(f,{...a,...i,onKeyDown:m,ref:l}),n[4]=f,n[5]=l,n[6]=i,n[7]=a,n[8]=m,n[9]=h):h=n[9],h});DZ.displayName=`ThreadListItemMorePrimitive.Trigger`;var OZ=Z((e,t)=>{let n=J(21),{__scopeThreadListItemMore:r,portalProps:i,sideOffset:a,...o}=e,s=a===void 0?4:a,c=xZ(r),l=CZ(),u=dZ(),d=TZ(),f=on()===`rtl`?`ArrowRight`:`ArrowLeft`,p=eu,m=PK,h;n[0]!==f||n[1]!==u?.moreRef||n[2]!==l||n[3]!==d?(h=e=>{d&&e.key===f&&(e.preventDefault(),l(!1),u?.moreRef.current?.focus())},n[0]=f,n[1]=u?.moreRef,n[2]=l,n[3]=d,n[4]=h):h=n[4];let g=F(o.onKeyDown,h),_;n[5]!==u?.moreRef||n[6]!==d?(_=()=>{d&&u?.moreRef.current?.focus()},n[5]=u?.moreRef,n[6]=d,n[7]=_):_=n[7];let v=F(o.onEscapeKeyDown,_),y;n[8]!==m||n[9]!==t||n[10]!==o||n[11]!==c||n[12]!==s||n[13]!==g||n[14]!==v?(y=(0,P.jsx)(m,{...c,...o,onKeyDown:g,onEscapeKeyDown:v,ref:t,sideOffset:s}),n[8]=m,n[9]=t,n[10]=o,n[11]=c,n[12]=s,n[13]=g,n[14]=v,n[15]=y):y=n[15];let b;return n[16]!==i||n[17]!==c||n[18]!==p.Portal||n[19]!==y?(b=(0,P.jsx)(p.Portal,{...c,...i,children:y}),n[16]=i,n[17]=c,n[18]=p.Portal,n[19]=y,n[20]=b):b=n[20],b});OZ.displayName=`ThreadListItemMorePrimitive.Content`;var kZ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=xZ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(FK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});kZ.displayName=`ThreadListItemMorePrimitive.Item`;var AZ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=xZ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(IK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});AZ.displayName=`ThreadListItemMorePrimitive.Separator`;var jZ=YG({Content:()=>OZ,Item:()=>kZ,Root:()=>EZ,Separator:()=>AZ,Trigger:()=>DZ}),MZ=(e,t)=>{let n=J(5),r=Y(null),i=Y(null),a,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>()=>{i.current?.()},o=[],n[0]=a,n[1]=o):(a=n[0],o=n[1]),X(a,o);let s;return n[2]!==e||n[3]!==t?(s=()=>{i.current?.(),(function(){if(r.current||!e.current)return;let t=e.current;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`scroll`||e===`auto`){r.current=t;break}t=t.parentElement}})();let n=r.current;if(!n)return;let a=n.scrollTop,o=n.style.scrollbarWidth,s=getComputedStyle(n),c=s.direction===`rtl`?`paddingLeft`:`paddingRight`,l=n.style[c],u=n.offsetWidth-n.clientWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.borderRightWidth),d=n.ownerDocument,f=(n===d.documentElement||n===d.body)&&u<=0?(d.defaultView?.innerWidth??0)-d.documentElement.clientWidth:u;n.style.scrollbarWidth=`none`,f>0&&(n.style[c]=`${parseFloat(s[c])+f}px`);let p=()=>{n.style.scrollbarWidth=o,n.style[c]=l},m=()=>n.scrollTop=a;n.addEventListener(`scroll`,m);let h=setTimeout(()=>{n.removeEventListener(`scroll`,m),p(),i.current=null},t);i.current=()=>{clearTimeout(h),n.removeEventListener(`scroll`,m),p()}},n[2]=e,n[3]=t,n[4]=s):s=n[4],s},NZ=()=>{let e=J(3),t=$(PZ),n=$(FZ),r=t!==void 0&&t.completedAt===void 0&&n,[i,a]=DM(IZ),o,s;if(e[0]===r?(o=e[1],s=e[2]):(o=()=>{if(!r)return;a(Date.now());let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},s=[r],e[0]=r,e[1]=o,e[2]=s),X(o,s),t!==void 0){if(t.completedAt!==void 0)return Math.max(0,t.completedAt-t.startedAt);if(r)return Math.max(0,i-t.startedAt)}};function PZ(e){let t=e.optional.part;return t?.type===`tool-call`?t.timing:void 0}function FZ(e){let t=e.optional.part;return t?.type===`tool-call`&&t.status.type===`running`}function IZ(){return Date.now()}var LZ=YG({AssistantRuntimeImpl:()=>uV,BaseAssistantRuntimeCore:()=>hV,CompositeContextProvider:()=>KF,DefaultThreadComposerRuntimeCore:()=>RV,MessageRepository:()=>EV,ThreadRuntimeImpl:()=>eV,getAutoStatus:()=>Hz,splitLocalRuntimeOptions:()=>CG,useComposerInputPluginRegistryOptional:()=>oq,useSmooth:()=>gY,useSmoothStatus:()=>lY,withSmoothContextProvider:()=>sY}),RZ=(e,t)=>`${e}:${t}`,zZ=e=>({id:e,status:`idle`}),BZ=e=>({threadId:e,metadata:zZ(e),messages:[],streamingMessageIndex:void 0,toolExecutions:{},runStatus:`idle`,queue:{steering:[],followUp:[]},contextUsage:void 0,compaction:{active:!1},retry:{active:!1,attempt:0},hostUiRequests:[],readiness:void 0,lastError:void 0,loadState:`pending`,lastSeq:0}),VZ=e=>e?.role===`assistant`,HZ=(e,t)=>e.status===t?e:{...e,status:t},UZ=(e,t,n)=>e.compactionActive===t.active&&e.retryActive===n.active&&e.retryAttempt===n.attempt?e:{...e,compactionActive:t.active,retryActive:n.active,retryAttempt:n.attempt},WZ=(e,t)=>{let n=t.metadata.status===`running`?`running`:t.metadata.status===`failed`?`failed`:`idle`,r=n!==`running`,i=t.seq!==void 0&&t.seq<e.lastSeq,a=t.metadata.compactionActive??(!r&&e.compaction.active),o=t.metadata.retryActive??(!r&&e.retry.active),s=i?e.compaction:a?{...e.compaction,active:!0}:{active:!1},c=i?e.retry:o?{active:!0,attempt:t.metadata.retryAttempt??e.retry.attempt}:{active:!1,attempt:0};return{...e,metadata:UZ(t.metadata,s,c),messages:t.messages,streamingMessageIndex:void 0,toolExecutions:{},runStatus:n,compaction:s,retry:c,queue:{steering:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`steer`).map(e=>e.content),followUp:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`followUp`).map(e=>e.content)},contextUsage:t.metadata.contextUsage??e.contextUsage,hostUiRequests:t.hostUiRequests??[],readiness:t.readiness??e.readiness,lastError:t.lastError,loadState:`loaded`}},GZ=(e,t,n)=>{let r=e.slice();return r[t]=n,r},KZ=(e,t,n)=>({...e,toolExecutions:{...e.toolExecutions,[t]:{toolCallId:t,status:`running`,...e.toolExecutions[t],...n}}}),qZ=(e,t)=>e.hostUiRequests.some(e=>e.id===t)?{...e,hostUiRequests:e.hostUiRequests.filter(e=>e.id!==t)}:e,JZ=(e,t)=>{if(t.type!==`snapshot`&&t.type!==`error`&&t.seq<=e.lastSeq)return e;let n=n=>n===e&&t.seq<=e.lastSeq?n:{...n,lastSeq:Math.max(e.lastSeq,t.seq)};switch(t.type){case`snapshot`:return n(WZ(e,t.snapshot));case`agent_start`:return n({...e,runStatus:`running`,lastError:void 0,metadata:HZ(e.metadata,`running`)});case`agent_end`:{let r=t.willRetry===!0;return n({...e,runStatus:r?`running`:`idle`,streamingMessageIndex:void 0,metadata:HZ(e.metadata,r?`running`:`idle`)})}case`message_start`:{let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:VZ(t.message)?r.length-1:e.streamingMessageIndex})}case`message_update`:{if(e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length)return n({...e,messages:GZ(e.messages,e.streamingMessageIndex,t.message)});let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:r.length-1})}case`message_end`:return e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length?n({...e,messages:GZ(e.messages,e.streamingMessageIndex,t.message),streamingMessageIndex:void 0}):n({...e,streamingMessageIndex:void 0});case`tool_execution_start`:return n(KZ(e,t.toolCallId,{toolName:t.toolName,args:t.args,status:`running`}));case`tool_execution_update`:return n(KZ(e,t.toolCallId,{...t.toolName===void 0?{}:{toolName:t.toolName},partialResult:t.partialResult,status:`running`}));case`tool_execution_end`:return n(KZ(e,t.toolCallId,{partialResult:t.result,status:t.isError?`error`:`complete`}));case`queue_update`:return n({...e,queue:{steering:t.steering,followUp:t.followUp}});case`compaction_start`:{let r={active:!0,reason:t.reason};return n({...e,compaction:r,metadata:UZ(e.metadata,r,e.retry)})}case`compaction_end`:{let t={active:!1};return n({...e,compaction:t,metadata:UZ(e.metadata,t,e.retry)})}case`auto_retry_start`:{let r={active:!0,attempt:t.attempt};return n({...e,retry:r,metadata:UZ(e.metadata,e.compaction,r)})}case`auto_retry_end`:{let t={active:!1,attempt:0};return n({...e,retry:t,metadata:UZ(e.metadata,e.compaction,t)})}case`context_usage`:return n({...e,contextUsage:t.contextUsage});case`session_info_changed`:{let r={...e.metadata};return t.name===void 0?delete r.title:r.title=t.name,n({...e,metadata:r})}case`thinking_level_changed`:return n({...e,metadata:{...e.metadata,config:{...e.metadata.config,thinkingLevel:t.level}}});case`extension_ui_request`:return e.hostUiRequests.some(e=>e.id===t.request.id)?n(e):n({...e,hostUiRequests:[...e.hostUiRequests,t.request]});case`extension_ui_resolved`:return n(qZ(e,t.requestId));case`error`:return n({...e,lastError:t.error,runStatus:`failed`,metadata:HZ(e.metadata,`failed`)});case`agent_settled`:case`entry_appended`:return n(e);default:return n(e)}},YZ=e=>{let t=new Map,n=[];for(let r of e)r.toolCallId!==void 0&&ZZ(r)?t.has(r.toolCallId)?n.push(r):t.set(r.toolCallId,r):n.push(r);return{toolAssociated:t,freeStanding:n}},XZ=(e,t)=>({requestId:e,confirmed:t}),ZZ=e=>{switch(e.kind){case`confirm`:return{id:e.id,prompt:`${e.title}\n${e.message}`};case`select`:return e.options.length===0?void 0:{id:e.id,prompt:e.title,display:`select`,options:e.options.map((e,t)=>({id:String(t),kind:`_${t}`,label:e}))};case`input`:case`editor`:return{id:e.id,prompt:e.title,display:`text`}}},QZ=(e,t)=>{if(e.kind===`confirm`)return XZ(e.id,t.approved);if(!t.approved)return{requestId:e.id,dismissed:!0};let n=e.kind===`select`?e.options.find((e,n)=>String(n)===t.optionId):t.text;if(n===void 0)throw Error(`Pi ${e.kind} request "${e.id}" was not answered with ${e.kind===`select`?`one of its options`:`text`}`);return{requestId:e.id,value:n}},$Z=e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(e.dismissed)return;if(typeof e.value==`string`)return e.value}},eQ=(e,t)=>{let n=$Z(t);return n===void 0?{requestId:e,dismissed:!0}:{requestId:e,value:n}};function tQ(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}function nQ(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var rQ=e=>`pi-msg:${e}`,iQ=e=>`pi-step:${e}`,aQ=(e,t)=>/^data:/i.test(e)?e:`data:${t};base64,${e}`,oQ=e=>new Date(typeof e.timestamp==`number`?e.timestamp:0),sQ=e=>{if(!e)return{};let t=e.filter(e=>e.type===`text`).map(e=>e.text).join(``);return e.every(e=>e.type===`text`)?{result:t}:{result:t,modelContent:e.flatMap(e=>{if(e.type===`text`)return[{type:`text`,text:e.text}];let t=tQ(e.data);return[{type:`file`,data:t?.data??e.data,mediaType:t?.mimeType??e.mimeType}]})}},cQ=e=>{if(e==null)return;let t=e.content;if(Array.isArray(t))return t.filter(e=>typeof e==`object`&&!!e&&(e.type===`text`&&typeof e.text==`string`||e.type===`image`&&typeof e.data==`string`&&typeof e.mimeType==`string`))},lQ=e=>typeof e==`string`?[{type:`text`,text:e}]:e.map(e=>e.type===`image`?{type:`image`,image:aQ(e.data,e.mimeType)}:{type:`text`,text:e.text}),uQ=(e,t)=>({type:`data`,name:e,data:t}),dQ=e=>{let t=new Map;for(let n of e){if(n.role!==`toolResult`)continue;let e=n;t.set(e.toolCallId,{...sQ(cQ({content:e.content})),isError:e.isError,details:e.details})}return t},fQ=(e,t,n,r,i,a)=>{let o=iQ(n);e.lastAssistant=t,e.steps.push({messageId:o,usage:{inputTokens:t.usage?.input??0,outputTokens:t.usage?.output??0}});for(let n of t.content)if(n.type===`text`)e.parts.push({type:`text`,text:n.text,parentId:o});else if(n.type===`thinking`){let t=n.thinking||(n.redacted?`[reasoning redacted]`:``);e.parts.push({type:`reasoning`,text:t,parentId:o})}else if(n.type===`toolCall`){let t=i.get(n.id),s=r.toolExecutions[n.id],c=t??sQ(cQ(s?.partialResult)),l=t?.isError??s?.status===`error`,u=a.get(n.id),d=u&&ZZ(u),f={type:`tool-call`,toolCallId:n.id,toolName:n.name,args:n.arguments??{},argsText:JSON.stringify(n.arguments??{}),parentId:o,...c.result===void 0?{}:{result:c.result},...c.modelContent===void 0?{}:{modelContent:c.modelContent},...l?{isError:!0}:{},...d?{approval:d}:{}};d&&(e.hasPendingHostUi=!0),e.parts.push(f)}},pQ=(e,t,n)=>{let r=e.lastAssistant,i=mQ(e,t,n);return{id:rQ(e.firstIndex),role:`assistant`,createdAt:oQ(r),content:e.parts,...i?{status:i}:{},metadata:{steps:e.steps,custom:{pi:{provider:r.provider,model:r.model,api:r.api,usage:r.usage,stopReason:r.stopReason,...r.errorMessage?{errorMessage:r.errorMessage}:{}}}}}},mQ=(e,t,n)=>{if(e.hasPendingHostUi)return{type:`requires-action`,reason:`interrupt`};let r=e.lastAssistant;return t.runStatus===`running`&&n&&r.stopReason!==`error`&&r.stopReason!==`aborted`?{type:`running`}:r.stopReason===`error`?{type:`incomplete`,reason:`error`,...r.errorMessage?{error:r.errorMessage}:{}}:r.stopReason===`aborted`?{type:`incomplete`,reason:`cancelled`}:r.stopReason===`length`?{type:`incomplete`,reason:`length`}:{type:`complete`,reason:`stop`}},hQ=e=>{let{messages:t}=e,n=dQ(t),r=YZ(e.hostUiRequests).toolAssociated,i=[],a=null,o=t=>{a&&=(i.push(pQ(a,e,t)),null)};return t.forEach((s,c)=>{let l=c===t.length-1;switch(s.role){case`assistant`:a||={firstIndex:c,parts:[],steps:[],lastAssistant:s,hasPendingHostUi:!1},fQ(a,s,c,e,n,r),l&&o(!0);break;case`toolResult`:break;case`user`:o(!1),i.push({id:rQ(c),role:`user`,createdAt:oQ(s),content:lQ(s.content)});break;case`bashExecution`:{o(!1);let e=s;i.push(gQ(c,e,`pi-bash-execution`,{command:e.command,output:e.output,exitCode:e.exitCode,cancelled:e.cancelled,truncated:e.truncated,fullOutputPath:e.fullOutputPath}));break}case`custom`:{o(!1);let e=s;if(!e.display)break;i.push({id:rQ(c),role:`assistant`,createdAt:oQ(e),content:[uQ(`pi-custom-message`,{customType:e.customType,details:e.details}),...lQ(e.content)]});break}case`branchSummary`:{o(!1);let e=s;i.push(gQ(c,e,`pi-branch-summary`,{summary:e.summary,fromId:e.fromId}));break}case`compactionSummary`:{o(!1);let e=s;i.push(gQ(c,e,`pi-compaction-summary`,{summary:e.summary,tokensBefore:e.tokensBefore}));break}default:o(!1),i.push(gQ(c,s,`pi-unsupported-message`,{role:s.role,message:s}))}}),o(!0),i},gQ=(e,t,n,r)=>({id:rQ(e),role:`assistant`,createdAt:oQ(t),content:[uQ(n,r)]}),_Q=(e,t)=>e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():void 0,vQ=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,yQ=(e,t)=>{if(e===t)return!0;let n=_Q(e,t);if(n!==void 0)return n;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!yQ(e[n],t[n]))return!1;return!0}if(vQ(e)||vQ(t)){if(!vQ(e)||!vQ(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!yQ(e[r],t[r]))return!1;return!0}return!1},bQ=(e,t)=>e.id===t.id&&e.role===t.role&&yQ(e.createdAt,t.createdAt)&&yQ(e.content,t.content)&&yQ(e.status,t.status)&&yQ(e.metadata,t.metadata),xQ=(e,t)=>{let n=e.length!==t.length,r=e.map((e,r)=>{let i=t[r];return i&&bQ(e,i)?i:(n=!0,e)});return n?r:t},SQ=(e,t)=>xQ(hQ(e),t),CQ={snapshot:!0,agent_start:!0,agent_end:!0,agent_settled:!0,turn_start:!0,turn_end:!0,message_start:!0,message_update:!0,message_end:!0,tool_execution_start:!0,tool_execution_update:!0,tool_execution_end:!0,queue_update:!0,compaction_start:!0,compaction_end:!0,entry_appended:!0,auto_retry_start:!0,auto_retry_end:!0,session_info_changed:!0,thinking_level_changed:!0,context_usage:!0,extension_ui_request:!0,extension_ui_resolved:!0,error:!0},wQ=e=>Object.prototype.hasOwnProperty.call(CQ,e),TQ=e=>e instanceof Error?e.message:String(e),EQ=e=>{if(typeof globalThis.requestAnimationFrame==`function`){globalThis.requestAnimationFrame(()=>e());return}setTimeout(e,16)},DQ=e=>{for(let t of e)try{t()}catch(e){console.error(`[react-pi] Listener threw an error`,e)}},OQ=new Set([`snapshot`,`agent_start`,`agent_end`,`message_start`,`message_update`,`message_end`,`tool_execution_update`,`tool_execution_end`,`extension_ui_request`,`extension_ui_resolved`]),kQ=new Set([`message_update`,`tool_execution_update`]),AQ=new Set([`snapshot`,`agent_start`,`agent_end`,`queue_update`,`compaction_start`,`compaction_end`,`auto_retry_start`,`auto_retry_end`,`session_info_changed`,`thinking_level_changed`,`context_usage`,`extension_ui_request`,`extension_ui_resolved`,`error`]),jQ=e=>{let t=/^data:([^;,]+)(?:;base64)?,(.*)$/is.exec(e);return t?{type:`image`,mimeType:t[1].toLowerCase(),data:t[2]}:{type:`image`,mimeType:`image/png`,data:e}},MQ=e=>[...e.content,...e.attachments?.flatMap(e=>e.content??[])??[]],NQ=(e,t)=>{let n=MQ(e),r=[],i=[];for(let e of n)e.type===`text`?r.push(e.text):e.type===`image`&&i.push(jQ(e.image));return{content:r.join(`
92
+ `),WB=`ui://`,GB=e=>!!e?.startsWith(WB),KB=e=>e.display===`text`||e.allowFreeform===!0,qB={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},JB=(e,t)=>{let n=t.text;if(n!==void 0&&!KB(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){let n=e.options?.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(qB,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=qB[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:e.id,approved:r,...i!==void 0&&{optionId:i},...n!==void 0&&{text:n},...t.reason!=null&&{reason:t.reason}}},YB=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=xL.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,isError:a.isError,...a.artifact!==void 0&&{artifact:a.artifact},...a.modelContent!==void 0&&{modelContent:a.modelContent}})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);return this.threadApi.getState().respondToToolApproval(JB(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},XB=(e,t)=>{let n=e.content[t];if(!n)return RF;let r=NI(e,t,n);return Object.freeze({...n,[Tz]:n[Tz],status:r})},ZB=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new HB(new qF({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e,comment:t}){let n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:e,...t===void 0?void 0:{comment:t}})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return UB(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new YB(new GF({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>XB(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new YB(new GF({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?RF:XB(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new FB(new GF({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:RF},subscribe:e=>this._core.subscribe(e)}))}},QB=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),$B=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),eV=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId===void 0?e.at(-1)?.id??null:t.parentId,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},tV=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},nV=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:tV(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),rV=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new GF({path:e.path,getState:()=>nV(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>BF([r,i])}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new VB(new qF({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){let t=this._threadBinding.getState().append(eV(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!AB(e))throw e})}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun($B(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(QB(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new ZB(new GF({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return RF;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[Tz]:e[Tz],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new JF({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},iV=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),aV=class extends HF{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},oV=e=>{let t=J(6),{adapters:n,children:r}=e,i=JM(bz),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,P.jsx)(bz.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},sV=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(e){let t=this._core.getState();return this._threadListBinding.generateTitle(t.id,e)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,(e!==`switchedTo`||a)&&(e===`switchedAway`&&a||JN([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},cV=Promise.resolve(),lV=()=>{},uV=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,loadError:e.loadError,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),dV=(e,t)=>{if(t===void 0)return RF;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:RF},fV=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=rV){this._core=e,this._runtimeFactory=t;let n=new KF({path:{},getState:()=>uV(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new sV(new GF({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>dV(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new qF({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){return this._core.unstable_subscribeThreadEvents?.(e)??lV}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??cV}reloadMainThread(){return this._core.reloadMainThread?.()??cV}loadMore(){return this._core.loadMore?.()??cV}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new GF({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>dV(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new qF({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(e))}getItemByIndex(e){return new sV(new GF({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>dV(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new sV(new GF({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>dV(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new sV(this._createItemStateBinding(e),this._core)}},pV=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new fV(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},mV=new WeakMap,hV=e=>mV.get(e)??0,gV=(e,t)=>hV(e)===t,_V=e=>{mV.set(e,hV(e)+1)},vV=class{_contextProvider=new YF;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},yV=Object.freeze([]),bV=`DEFAULT_THREAD_ID`,xV=Object.freeze([bV]),SV=Object.freeze({id:bV,remoteId:void 0,externalId:void 0,status:`regular`}),CV=Promise.resolve(),wV=Object.freeze(Mj({[bV]:SV})),TV=class extends HF{_mainThreadId=bV;_threads=xV;_archivedThreads=yV;_threadData=wV;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return CV}_mainThread;get mainThreadId(){return this._mainThreadId}threadFactory;constructor(e={},t){super(),this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return Object.hasOwn(this._threadData,e)?this._threadData[e]:void 0}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??bV,i=e.threads??yV,a=e.archivedThreads??yV,o=n.threadId??bV,s=n.threads??yV,c=n.archivedThreads??yV;(t||(n.isLoading??!1)!==(e.isLoading??!1)||o!==r||s!==i||c!==a)&&((s!==i||c!==a||o!==r)&&(this._threadData=Mj(wV,Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[]))),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??yV),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??yV),(t||o!==r)&&(t||_V(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=Mj(this._threadData,{[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}})),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},EV={fromArray:e=>{let t=e.map(e=>Pz(e,jz(),Kz(e.content)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>({...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:Pz(e,e.id,Kz(e.content))}})})},DV=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},OV=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},kV=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}selectPathTo(e){for(let t=e;t;t=t.prev)(t.prev??this.root).next=t}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],t.prev=e,DV(t)===this.head?this.selectPathTo(t):i.next===null&&(i.next=t,this.head===i&&(this.head=DV(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new OV(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=DV(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;this.selectPathTo(t),this.head=DV(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t,this.selectPathTo(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[],t=[...this.root.children].reverse();for(;t.length>0;){let n=this.messages.get(t.pop());if(!n)continue;for(let e=n.children.length-1;e>=0;e--)t.push(n.children[e]);if(n.current.metadata?.isOptimistic)continue;let r=n.prev;for(;r&&r.current.metadata?.isOptimistic;)r=r.prev;e.push({message:n.current,parentId:r?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},AV=Object.freeze([]);function*jV(e){for(let t of e)if(t?.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e&&e.type===`tool-call`&&(yield{part:e,messageId:t.id},e.messages?.length&&(yield*jV(e.messages)))}function MV(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=e.name.toLowerCase(),i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&r.endsWith(e)||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function NV(e){let t=jz();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function PV(e){let t=[];for(let n of e)n.type!==`text`&&t.push(NV(n));return t}var FV=e=>`content`in e&&!(`lastModified`in e),IV=e=>e.status.type===`complete`,LV=class{operations=new Set;start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){return!e.cancelled&&(e.attachmentIds.add(t),!0)}finish(e){this.operations.delete(e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t))}cancelAll(){for(let e of this.operations)e.cancelled=!0;this.operations.clear()}},RV=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},zV=class extends HF{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_isSending=!1;_removedDuringSend=new Set;_sendGeneration=0;_attachmentAddOperations=new LV;_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._rebaseDictation(``),this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!IV(e));await Promise.all(t.map(async t=>e.remove(t)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){if(this._cancelAllAttachmentAdds(),this._isSending)for(let e of this._attachments)this._removedDuringSend.add(e.id);let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;if(this._dictationSession)try{this._dictationSession.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation()}let t=this.getAttachmentAdapter(),n=this.attachments.map(async e=>{if(IV(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)}),r=this.attachments,i=this.text,a=this._quote,o=this.role,s=this.runConfig;this._quote=void 0,this._text=``,this._isSending=!0;let c=++this._sendGeneration;this._notifySubscribers();let l;try{l=await Promise.all(n)}catch(e){throw c===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=a,this._notifySubscribers()),Promise.allSettled(n).then(()=>{c===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),e}if(c!==this._sendGeneration)return;let u=new Set(r.map(e=>e.id));this._attachments=this._attachments.filter(e=>!u.has(e.id)),this._isSending=!1,this._notifySubscribers();let d=l.filter(e=>!this._removedDuringSend.has(e.id));this._removedDuringSend.clear();let f={createdAt:new Date,role:o,content:i?[{type:`text`,text:i}]:[],attachments:d,runConfig:s,metadata:{custom:{...a?{quote:a}:{}}}},p={text:i,quote:a,attachments:d},m;try{m=this.handleSend(f,e)}catch(e){throw this._restoreUnsentDraft(e,c,p),e}m&&m.catch(e=>{this._restoreUnsentDraft(e,c,p)}),this._notifyEventSubscribers(`send`,{chars:i.length,attachments:d.length})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text===e.text&&this._quote===e.quote&&t&&(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,t,n){AB(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return AV}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(FV(e)){let t=this.getAttachmentAdapter();if(t&&!MV({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.contentType),r}let n={id:e.id??jz(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{...n.contentType?{contentType:n.contentType}:void 0});return}let t=this.getAttachmentAdapter();if(!t){let t=`Attachments are not supported`,n=Error(t);throw this._safeEmitAttachmentAddError(`no-adapter`,t,void 0,n,e.type),n}if(!MV({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.type),r}let n=this._attachmentAddOperations.start(),r=e=>{if(!this._attachmentAddOperations.accept(n,e.id))return!1;let t=this._attachments.findIndex(t=>t.id===e.id);return this._attachments=t===-1?[...this._attachments,e]:[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers(),!0},i;try{await RV(t.add({file:e}),e=>(i=e,r(e)))}catch(t){if(this._attachmentAddOperations.isCancelled(n))return;throw i&&r({...i,status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}}),this._safeEmitAttachmentAddError(`adapter-error`,t instanceof Error?t.message:String(t),i?.id,t instanceof Error?t:void 0,i?.contentType||e.type),t}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(i?.status.type===`incomplete`&&i.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,i.status.message??`Attachment upload did not complete successfully.`,i.id,void 0,i.contentType||e.type):this._notifyEventSubscribers(`attachmentAdd`,{...i?.contentType?{contentType:i.contentType}:e.type?{contentType:e.type}:void 0}))}_safeEmitAttachmentAddError(e,t,n,r,i){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r},...i?{contentType:i}:void 0})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!IV(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!IV(t)?{...t,status:{type:`incomplete`,reason:`error`,message:n}}:t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);let t=this._dictationSession!==void 0;if(this._dictationSession){let e=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(e)}let n=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let r;try{r=e.listen()}catch(e){if(t)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Dictation replacement rollback notification threw`,e)}throw e}this._dictationSession=r;let i=++this._dictationSessionIdCounter;this._activeDictationSessionId=i,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();let a=r.onSpeech(e=>{if(!this._isActiveSession(i,r))return;let t=e.isFinal!==!1,n=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+n+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=n+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(a);let o=r.onSpeechStart(()=>{this._isActiveSession(i,r)&&(this._dictation={status:{type:`running`},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);let s=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:i})});this._dictationUnsubscribes.push(s);let c=setInterval(()=>{this._isActiveSession(i,r)&&r.status.type===`ended`&&this._cleanupDictation({sessionId:i})},100);this._dictationUnsubscribes.push(()=>clearInterval(c))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;this._stopDictationSession(e,()=>this._cleanupDictation({sessionId:t}))}_stopDictationSession(e,t=()=>{}){let n;try{n=e.stop()}catch(e){console.error(`[assistant-ui] Dictation session stop threw`,e),t();return}n.then(t,e=>{console.error(`[assistant-ui] Dictation session stop rejected`,e),t()})}_cleanupDictation(e){if(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;let t=e=>{try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}};try{let n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``;for(let e of n)t(e);e?.notify!==!1&&t(()=>this._notifySubscribers())}finally{this._isCleaningDictation=!1}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&JN(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},BV=e=>e.capabilities?.cancel?tV(e):!1,VV=class extends zV{get canCancel(){return BV(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this.runtime.voice&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??AV,t=this.runtime.getQueueItems?.()??AV,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.runtime.voice!==void 0,r=this.queue;return this.runtime.subscribe(()=>{let i=!1,a=this.canCancel;e!==a&&(e=a,i=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,i=!0);let o=this.runtime.voice!==void 0;n!==o&&(n=o,i=!0),r!==this.queue&&(r=this.queue,i=!0),i&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},HV=class extends zV{get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this.runtime.voice&&!this._isSending}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e;let i=e.voice!==void 0,a=e.subscribe(()=>{let t=e.voice!==void 0;t!==i&&(i=t,this._notifySubscribers())});this.endEditCallback=()=>{a(),t()},this._parentId=n,this._sourceId=r.id,this.setText(UB(r)),this.setRole(r.role);let o;r.role===`user`?(o=[...r.attachments??[],...PV(r.content)],this._nonTextPassthrough=[]):(o=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(o),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},UV=class extends HF{_isInitialized=!1;repository=new kV;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();if(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e){let t=new Set(e.map(e=>e.id));this._cachedMergedMessages=[...e,...this._voiceMessages.filter(e=>!t.has(e.id))],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new VV(this);_contextProvider;constructor(e){super(),this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=vz(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}_isVoiceMessage(e){return e!==null&&this._voiceMessages.some(t=>t.id===e)}_resolveAppendParent(e){return this._isVoiceMessage(e)?this._getBaseMessages().at(-1)?.id??null:e}beginEdit(e){if(this.voice)throw Error(`Cannot edit a message while a voice session is connected`);if(this._isVoiceMessage(e))throw Error(`Voice transcript messages cannot be edited`);if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new HV(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&JN(n,t,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,t,n,r){this._notifyEventSubscribers(`toolApprovalAnswered`,{messageId:e,toolCallId:t,toolName:n,approved:r})}submitFeedback({messageId:e,type:t,comment:n}){let r=this.adapters?.feedback,i=this.getMessageById(e);if(!i)throw Error(`Message not found: ${e}`);let{message:a,parentId:o}=i,s=n?.trim(),c={type:t,...s?{comment:s}:void 0};if(r?.submit({message:a,...c}),a.role===`assistant`){let t={...a,metadata:{...a.metadata,submittedFeedback:c}},n=this._voiceMessages.findIndex(t=>t.id===e);n===-1?this.repository.addOrUpdateMessage(o,t):(this._voiceMessages[n]=t,this._currentAssistantMsg===a&&(this._currentAssistantMsg=t),this._markVoiceMessagesDirty())}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let n=this.getMessageById(e);if(!n)throw Error(`Message not found: ${e}`);let{message:r}=n,i=this._stopSpeaking,a;try{i?.(),a=t.speak(UB(r))}catch(e){if(i&&!this._stopSpeaking)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Speech rollback notification threw`,e)}throw e}let o,s=()=>{this._stopSpeaking=void 0,this.speech=void 0;let e=o;o=void 0,e?.()},c=()=>{if(this._stopSpeaking===c)try{s()}finally{a.cancel()}},l=()=>{this._stopSpeaking===c&&(a.status.type===`ended`?zF([s,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:a.status},this._notifySubscribers()))};this._stopSpeaking=c;try{if(o=a.subscribe(l),this._stopSpeaking!==c){o();return}l()}catch(e){if(this._stopSpeaking===c)try{zF([c,()=>this._notifySubscribers()])}catch(e){console.error(`[assistant-ui] Speech rollback cleanup threw`,e)}throw e}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);zF([this._stopSpeaking,()=>this._notifySubscribers()])}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){if(this.isRunning)return!0;let e=this._getBaseMessages().at(-1);return e?.role===`assistant`&&(e.status.type===`running`||e.status.type===`requires-action`)}connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);if(this._isRunActive())throw Error(`Cannot start a voice session while a run is in progress or paused on a pending tool action`);let t=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice cleanup threw before reconnect`,e)}let n;try{n=e.connect({})}catch(e){throw t&&this._voiceSession===void 0&&this._onVoiceDisconnected(),e}this._voiceSession=n;let r=[];this._voiceUnsubs=r;let i=()=>{if(this._voiceSession===n&&this._voiceUnsubs===r)return!1;try{zF(r.splice(0))}catch(e){console.error(`[assistant-ui] Detached voice setup cleanup threw`,e)}return!0};try{let e=`listening`;if(this.voice={status:n.status,isMuted:n.isMuted,mode:e},this._voiceVolume=0,this._notifySubscribers(),i()||(r.push(n.onStatusChange(t=>{this._voiceSession===n&&(t.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0,this._onVoiceDisconnected()):this.voice={status:t,isMuted:n.isMuted,mode:e},this._notifySubscribers())})),i())||(r.push(n.onModeChange(t=>{e=t,this.voice&&(this.voice={...this.voice,mode:t},this._notifySubscribers())})),i())||(r.push(n.onVolumeChange(e=>{this._voiceVolume=e,JN(this._voiceVolumeSubscribers,void 0,`Voice volume`)})),i()))return;r.push(n.onTranscript(e=>{this._handleVoiceTranscript(e)})),i()||this._onVoiceConnected()}catch(e){if(this._voiceSession===n&&this._voiceUnsubs===r){try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice rollback cleanup threw`,e)}t&&this._voiceSession===void 0&&this._onVoiceDisconnected()}else i();throw e}}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`){if(this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal){let t={id:jz(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{modality:`voice`,custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]};this._voiceMessages.push(t),this._commitVoiceMessage(t),this._markVoiceMessagesDirty(),this._notifySubscribers()}}else{let t=e.isFinal?{type:`complete`,reason:`stop`}:{type:`running`};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:jz(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],modality:`voice`,custom:{}},status:t,createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let n=this._voiceMessages.indexOf(this._currentAssistantMsg);if(n===-1)return;let r={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],status:t};this._voiceMessages[n]=r,this._currentAssistantMsg=r}e.isFinal&&(this._commitVoiceMessage(this._currentAssistantMsg),this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(e=!0){let t=this._voiceMessages.at(-1);if(t?.role===`assistant`&&t.status.type===`running`){let n=this._voiceMessages.length-1;this._voiceMessages[n]={...t,status:{type:`complete`,reason:`stop`}},this._commitVoiceMessage(this._voiceMessages[n]),this._currentAssistantMsg=null,this._markVoiceMessagesDirty(),e&&this._notifySubscribers()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;let t=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];let n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;let r=this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0;this._voiceMessages=[],this._markVoiceMessagesDirty();try{zF([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>JN(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this._notifySubscribers()])}finally{e&&n&&this._voiceSession===void 0&&this._onVoiceDisconnected()}}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(EV.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>JN([n],{},`Thread runtime "${e}"`))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&JN([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},WV=Symbol.for(`assistant-stream.tool-execution-id`),GV=e=>{try{return JSON.parse(e),!0}catch{return!1}},KV=e=>{try{return JSON.parse(e)}catch{return}},qV=(e,t)=>{let n=KV(e),r=KV(t);return n===void 0||r===void 0?!1:gL(n,r)},JV=e=>e[WV],YV=class{_getTools;_callbacks;_isClientToolCall;_entries=new Map;_humanInput=new Map;_executing=new Set;_discardedToolCallIds=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t,n){this._getTools=e,this._callbacks=t,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){let[e,t]=VL();this._controller=t;let n=XR(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new WL).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(e){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),e?.discardPending)for(let[e,t]of this._entries)t.controller&&(t.argsComplete||t.hasResult||(this._discardedToolCallIds.add(e),t.skipExecute=!0));if(this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let t=new Set(this._executing);return new Promise(e=>{this._settledResolvers.push({executionIds:t,resolve:e})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=JV(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=JV(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._humanInput.get(e)?.executionId!==t&&this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=JV(e),r=this._entries.get(t);r&&r.executionId===n&&(r?.hasResult||r.skipExecute||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_warnProviderOwnedSkip(e,t){}_shouldCloseArgsStream({argsText:e,hasResult:t,clientOwned:n}){return t?!0:GV(e)?n||!this._isRunning:!1}_startActiveEntry(e,t,n,r){let i={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1,clientOwned:r};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)if(t.controller){if(!t.argsComplete&&!t.hasResult){this._entries.delete(e);continue}this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)qV(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(GV(e.argsText)&&GV(t.argsText)&&qV(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:e.clientOwned})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let{part:n}of jV(e)){let e=this._entries.get(n.toolCallId);if(t){e?.controller||this._entries.set(n.toolCallId,{toolName:n.toolName,argsText:n.argsText,hasResult:n.result!==void 0});continue}let r=e;if(n.result!==void 0&&this._discardedToolCallIds.delete(n.toolCallId),r&&!r.controller){if(r.hasResult||(n.argsText===r.argsText||GV(r.argsText)&&GV(n.argsText)&&qV(r.argsText,n.argsText))&&n.result===void 0)continue;this._entries.delete(n.toolCallId),r=void 0}if(!r){let e=this._isClientToolCall?.(n),t=n.result===void 0&&e===!1;t&&this._warnProviderOwnedSkip(n.toolName,n.toolCallId),r=this._startActiveEntry(n.toolCallId,n.toolName,n.result!==void 0||t||this._discardedToolCallIds.has(n.toolCallId),e===!0)}if(n.approval!==void 0&&(r.skipExecute=!0),this._processArgsText(r,n),n.result!==void 0&&!r.hasResult){let{controller:e}=r;if(!e)continue;r.hasResult=!0,r.argsComplete=!0,e.setResponse(new xL({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent===void 0?{}:{modelContent:n.modelContent}})),e.close()}}}},XV=Object.freeze([]),ZV=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},QV=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,$V=class extends UV{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}suggestions=[];extras=void 0;_converter=new Jz;_pendingDeleteEvictions=new Set;_optimistic=null;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;_toolStatuses=new Map;_effectiveIsRunning=!1;_inTrackerUpdate=!1;_pendingRunningRefresh=!1;_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){let e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?`runStart`:`runEnd`,{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){let t=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e;let r=this._getEffectiveIsRunning(e),i=e.unstable_messageRepositoryInstance,a=i!==void 0&&i!==this.repository;a&&(this.repository=i,this._pendingDeleteEvictions.clear()),n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let o=e.suggestions??XV;eF(this.suggestions,o)||(this.suggestions=o);let s={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};eF(this._capabilities,s)||(this._capabilities=s);let c;if(e.messageRepository){if(n&&!a&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository&&t===r){this._notifySubscribers();return}let i=e.messageRepository.messages,o=e.messageRepository.headId??i.at(-1)?.message.id??null;if(n&&!a&&n.messageRepository===e.messageRepository)this.repository.resetHead(o),c=this.repository.getMessages();else{let e=new Set(i.map(({message:e})=>e.id));for(let{message:e,parentId:t}of i)this.repository.addOrUpdateMessage(t,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(o),c=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new Jz;else if(!a&&n.isRunning===e.isRunning&&n.messages===e.messages&&t===r){this._notifySubscribers();return}}c=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,i)=>{if(!e.convertMessage)return n;let a=i===(e.messages?.length??0)-1,o=`${Az}${i}`;if(t&&(t.role!==`assistant`||!Wz(t.status)||t.status===qz(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return Oz(e,n),e}return t}let s=e.convertMessage(n,i),c=Pz(s,o,qz(s.content,a,r));return Oz(c,n),c}):e.messages;let i=new Set,o=[];for(let e=c.length-1;e>=0;e--){let t=c[e];if(i.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}i.add(t.id),o.push(t)}o.length!==c.length&&(c=o.reverse());for(let e=0;e<c.length;e++){let t=c[e],n=c[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}if(this._pendingDeleteEvictions.size>0){let e=new Set(c.map(e=>e.id));for(let t of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(t),!e.has(t)){try{this.repository.getMessage(t)}catch{continue}this.repository.deleteMessage(t)}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);c.length>0&&this.ensureInitialized(),this._effectiveIsRunning=r,t!==r&&(r?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let l=null;if(QV(r,c)){let e=c.at(-1)?.id??null;this._optimistic?.parentId!==e&&(this._optimistic={id:jz(),parentId:e}),l=this._optimistic.id,this.repository.addOrUpdateMessage(e,Pz({role:`assistant`,content:[],metadata:{isOptimistic:!0}},l,{type:`running`}))}l===null&&(this._optimistic=null),this.repository.resetHead(l??c.at(-1)?.id??null);let u=this.repository.getMessages();if((!this._messages||!Yz(this._messages,u))&&(this._messages=u),this._voiceMessages.length>0){let e=new Set(this._messages.map(e=>e.id)),t=this._voiceMessages.filter(t=>!e.has(t.id));t.length!==this._voiceMessages.length&&(this._voiceMessages=t,this._markVoiceMessagesDirty())}a&&this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new YV(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;ZV(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{this._store.setToolStatuses?.(Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}},e=>this._store.unstable_isClientToolCall?.(e)),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(let{part:e,messageId:t}of jV(this._messages))this._toolCallToMessageId.set(e.toolCallId,t);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t={...e,parentId:this._resolveAppendParent(e.parentId)};if(this.voice)throw Error(`Cannot send a text message while a voice session is connected`);if(this._isVoiceMessage(t.sourceId))throw Error(`Voice transcript messages cannot be edited`);let n=t.sourceId!=null||t.parentId!==(this._getBaseMessages().at(-1)?.id??null);t=!n&&this._store.queue&&this._store.queue===this._transformedQueue?t:this.enrichAppendMetadata(t);let r=hV(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!n&&this._store.queue){if(i&&await i,!gV(this,r))return;t.steer??this._getEffectiveIsRunning(this._store)?this._store.queue.steer(t):this._store.queue.enqueue(t);return}if(i?.catch(()=>{}),(t.startRun??t.role===`user`)&&await this._toolInvocations?.abort({discardPending:!0}),gV(this,r)){if(n){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._pendingDeleteEvictions.clear(),await this._store.onEdit(t)}else await this._store.onNew(t)}}_commitVoiceMessage(e){this._store.onVoiceTranscript?.(e)}async deleteMessage(e){if(this._store.onDelete){this.repository.getMessages().some(t=>t.id===e)&&this._pendingDeleteEvictions.add(e);try{await this._store.onDelete(e)}catch(t){throw this._pendingDeleteEvictions.delete(e),t}return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._getEffectiveIsRunning(this._store)&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this._pendingDeleteEvictions.clear(),this.updateMessages(t.filter(t=>t.id!==e)),this._evictDeletedMessage(e)}_evictDeletedMessage(e){if(!e.startsWith(`__external_store_fallback_`)){try{this.repository.getMessage(e)}catch{return}this.repository.deleteMessage(e),this._publishRepositoryMessages()}}_publishRepositoryMessages(){let e=this.repository.getMessages();Yz(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){return this._store?.queue?.items??AV}getSteerQueueItems(){return this._store?.queue?.steerItems??AV}moveQueueItem(e,t){this._store?.queue?.move(e,t)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);this._pendingDeleteEvictions.clear(),await this._toolInvocations?.abort({discardPending:!0}),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.queue?.__internal_notifyCancelled?.()}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);let e=hV(this);this._toolInvocations?.abort({discardPending:!0}),this._store.queue?.__internal_notifyCancelled?.(),ZV(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let t=this.repository.getMessages(),n=t[t.length-1],r=this._store.setMessages!==void 0&&n?.role===`user`&&n.id===t.at(-1)?.id&&n.content.every(e=>e.type===`text`)?n:void 0,i;if(r){let e={text:UB(r),attachments:r.attachments,quote:r.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(r.id),i={id:r.id,draft:e})}this._publishRepositoryMessages(),setTimeout(()=>{if(gV(this,e)){if(this.dropEmptyOptimisticHead(),i){let e=this.repository.getMessages();e.at(-1)?.id===i.id?this.repository.deleteMessage(i.id):e.some(e=>e.id===i.id)&&this.composer.retractDraft(i.draft)}this._publishRepositoryMessages(),this.updateMessages(this._messages)}},0)}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);ZV(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);let t=this.messages.findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId)),n=t?.content.find(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId);try{return Promise.resolve(this._store.onRespondToToolApproval(e)).then(()=>{t&&n?.type===`tool-call`&&this._notifyToolApprovalAnswered(t.id,n.toolCallId,n.toolName,e.approved)})}catch(e){return Promise.reject(e)}}reset(e){let t=new kV;t.import(EV.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(kz))}},eH=e=>e.adapters?.threadList??{},tH=class extends vV{threads;constructor(e){super(),this.threads=new TV(eH(e),()=>new $V(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(eH(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},nH=e=>{let t=J(21),{modelContext:n,feedback:r}=Sz()??{},i;bb0:{if(!r||e.adapters?.feedback){i=e;break bb0}let n;t[0]!==r||t[1]!==e.adapters?(n={...e.adapters,feedback:r},t[0]=r,t[1]=e.adapters,t[2]=n):n=t[2];let a;t[3]!==e||t[4]!==n?(a={...e,adapters:n},t[3]=e,t[4]=n,t[5]=a):a=t[5],i=a}let a=i,o;t[6]===a?o=t[7]:(o=()=>new tH(a),t[6]=a,t[7]=o);let[s]=AM(o),c;t[8]===s.threads?c=t[9]:(c=()=>()=>{_V(s.threads.getMainThreadRuntimeCore())},t[8]=s.threads,t[9]=c);let l;t[10]===s?l=t[11]:(l=[s],t[10]=s,t[11]=l),X(c,l);let u;t[12]!==a||t[13]!==s?(u=()=>{s.setAdapter(a)},t[12]=a,t[13]=s,t[14]=u):u=t[14],X(u);let d,f;t[15]!==n||t[16]!==s?(d=()=>{if(n)return s.registerModelContextProvider(n)},f=[n,s],t[15]=n,t[16]=s,t[17]=d,t[18]=f):(d=t[17],f=t[18]),X(d,f);let p;return t[19]===s?p=t[20]:(p=new pV(s),t[19]=s,t[20]=p),p},rH=e=>e.status?.type!==`running`,iH=async(e,t)=>{let n=DR.fromAssistantStream(e);for await(let e of n){let n=e.parts.filter(e=>e.type===`text`)[0]?.text;n?.trim()&&await t(n)}},aH=(e,t)=>{let n=()=>void t.generateTitle({automatic:!0}).catch(e=>{dI(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(rH);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},oH=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=NM(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=Y(!1);c.current||s(),X(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=Y(void 0),u=Y(!1),d=Y(void 0),f=Y(!1),p=FM(()=>{if(u.current||i.getState().status!==`new`)return;u.current=!0;let e=i.initialize();l.current=e,e.then(()=>{f.current&&(d.current?.(),d.current=aH(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=FM(()=>(p(),l.current));return X(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),X(()=>{if(!a?.threads?.main)return;u.current=!1,f.current=!0;let e=a.threads.main.unstable_on(`initialize`,p);return()=>{f.current=!1,e(),d.current?.(),d.current=void 0}},[a]),a},sH=YM(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s})=>{let c=MM(()=>new sV(new GF({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:RF},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:l}=SF(i,{threadListItem:qI({runtime:c})});return WP(s,function(){return SP(l,function(){return xz(a,function(){return oH({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:c})})})})}),cH=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],lH=e=>{let t=J(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),PM(r,i),null},uH=class extends HF{runtimeHook;adapterStore=new UF({defaultAdapters:null,threadAdapters:new Map});hostStore=new UF({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);return t?(t.runtime&&_V(t.runtime),t.unsubscribeRunning?.(),t.unsubscribeRunning=void 0,t.destroy.abort(),t.destroy=new AbortController,t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime;r.runtime=t,r.publishedGeneration=n,i!==t&&this._trackRunning(e,r),this._notifySubscribers(),i!==void 0&&i!==t&&zF(this.replacedSubscribers)}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){t.unsubscribeRunning?.();let n=t.runtime;if(!n){t.unsubscribeRunning=void 0,this._setRunning(t,!1);return}this._setRunning(t,tV(n));let r=[n.subscribe(()=>{this._setRunning(t,tV(n))}),...cH.map(t=>n.unstable_on(t,()=>{JN(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>{for(let e of r)e()}}_setRunning(e,t){e.isRunning!==t&&(e.isRunning=t,zF(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&_V(t.runtime),t?.unsubscribeRunning?.(),t?.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState();this.hostStore.setState({...t,hookEpoch:t.hookEpoch+1})}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e})}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r})}__internal_dispose(){for(let e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){let e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t,destroy:n}])=>({id:e,generation:t,destroySignal:n.signal}))})}_threadElements(e,{threads:t,hookEpoch:n},r){let i=this.runtimeHook;return t.map(({id:t,generation:a,destroySignal:o})=>{let s=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return XM(`${t}:${a}:${n}`,sH({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:s,publish:this._publish,destroySignal:o}))})}__internal_useHost(e){let t=lI(this.hostStore),n=lI(this.adapterStore);return VN(this._threadElements(e,t,n))}__internal_RenderThreadRuntimes=({provider:e})=>(lI(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,P.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>{let t=lI(this.hostStore),n=lI(this.adapterStore),r=this._threadElements(e,t,n),{effects:i}=UN(function(){return VN(r)});return PM(i),null};_OuterActiveThreadProvider=VM(({threadId:e,provider:t})=>{let n=MM(()=>new fV(this.parent).getItemById(e),[e]),r=Y(!1);return X(()=>{},[t]),(0,P.jsx)(pB,{runtime:n,children:(0,P.jsx)(t,{children:(0,P.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=Sz();return this.pendingThreadAdapters.set(e,n),PM(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,P.jsx)(lH,{detectorRef:t})}};function dH(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var fH=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),pH=class extends HF{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>fH(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=fH(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},mH=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),hH=new class extends aV{get error(){return mH}messages=[];composer=iV(mH,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(mH)}};function gH(e){return e}var _H=`__LOCALID_`,vH=e=>e||void 0,yH=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=Mj(t.threadIdMap),a=Mj(t.threadData),o=new Set([...n,...r]);for(let t of e){switch(t.status){case`regular`:case`archived`:break;default:{let e=t.status;throw Error(`Unsupported state: ${e}`)}}let e=i[t.remoteId],s=e===void 0?void 0:a[e],c=s?.id??t.remoteId,l=e??gH(c),u=s!==void 0&&s.status!==`new`?s.initializeTask:void 0;o.has(c)?s!==void 0&&s.status!==t.status&&(t.status===`regular`?(r=r.filter(e=>e!==c),n.push(c)):(n=n.filter(e=>e!==c),r.push(c))):(o.add(c),t.status===`regular`?n.push(c):r.push(c)),i[c]=l,i[t.remoteId]=l,a[l]={...s?.localOrigin===!0?{localOrigin:!0}:{},id:c,remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,initializeTask:u??Promise.resolve({remoteId:t.remoteId,externalId:t.externalId})}}return{threadIds:n,archivedThreadIds:r,threadIdMap:i,threadData:a}},bH=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:Mj(),threadData:Mj()}),xH=e=>{let t;do t=`${_H}${jz()}`;while(e.threadIdMap[t]);let n=gH(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:Mj(e.threadIdMap,{[t]:n}),threadData:Mj(e.threadData,{[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},SH=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);(e===void 0||e===`new`)&&(e!==void 0||t.localOrigin===!0)&&(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?2**53-1:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),{...e,threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]}},CH=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),wH=(e,t)=>{let n=Object.hasOwn(e.threadIdMap,t)?e.threadIdMap[t]:void 0;if(n!==void 0)return Object.hasOwn(e.threadData,n)?e.threadData[n]:void 0},TH=(e,t,n,r,i)=>{let a=gH(t),o=Object.hasOwn(e.threadData,a)?e.threadData[a]:void 0;if(!o)return{state:e,removedMappingId:void 0,survivorMappingId:a};let s=Object.hasOwn(e.threadIdMap,n)?e.threadIdMap[n]:void 0,c=s!==void 0&&s!==a&&Object.hasOwn(e.threadData,s)?e.threadData[s]:void 0,l=s!==void 0&&c!==void 0?{mappingId:s,data:c}:void 0,u=i!==void 0&&Object.hasOwn(e.threadIdMap,i)?e.threadIdMap[i]:void 0,d=l!==void 0&&u===l.mappingId?l.mappingId:a,f=l===void 0?void 0:d===a?l.mappingId:a,p=r??l?.data.externalId,m=Mj(e.threadData);f!==void 0&&delete m[f];let h={...o,id:d,initializeTask:Promise.resolve({remoteId:n,externalId:p}),remoteId:n,externalId:p};m[d]={...l?.data,...h,title:o.title??l?.data.title,lastMessageAt:(`lastMessageAt`in o?o.lastMessageAt:void 0)??(l&&`lastMessageAt`in l.data?l.data.lastMessageAt:void 0),custom:o.custom??l?.data.custom};let g=Mj(e.threadIdMap);if(f!==void 0)for(let[e,t]of Object.entries(g))t===f&&(g[e]=d);g[t]=d,g[n]=d;let _=e=>l===void 0?e:e.filter(e=>e!==l.data.id).map(e=>e===o.id?d:e);return{state:{...e,threadIds:_(e.threadIds),archivedThreadIds:_(e.archivedThreadIds),threadIdMap:g,threadData:m},removedMappingId:f,survivorMappingId:d}},EH=(e,t,n,r)=>{let i=wH(e,t);if(!i)return e;let{id:a,status:o}=i;if(o===n)return e;let s;if(n!==`deleted`){if(i.status===`new`){if(r===void 0)return e;s={...i,initializeTask:r,status:n}}else s={...i,status:n}}let c={...e};switch(o){case`new`:c.newThreadId=void 0;break;case`regular`:c.threadIds=c.threadIds.filter(e=>e!==a);break;case`archived`:c.archivedThreadIds=c.archivedThreadIds.filter(e=>e!==a);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:c.threadIds=[a,...c.threadIds];break;case`archived`:c.archivedThreadIds=[a,...c.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t],r=Mj(c.threadData);delete r[n],c.threadData=r;let i=Mj(c.threadIdMap);for(let[e,t]of Object.entries(i))t===n&&delete i[e];c.threadIdMap=i;break}default:throw Error(`Unsupported state: ${n}`)}return s!==void 0&&(c.threadData={...c.threadData,[a]:s}),c},DH=(e,t,n)=>EH(e,t,n,void 0),OH=(e,t,n)=>EH(e,t,`regular`,n),kH=class extends Error{[uI]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}};function AH(e,t){let n=e.get(t);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualTitle:void 0,latestExplicit:null,nextOrder:0},e.set(t,n)),n}function jH(e,t,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualTitle===void 0&&e.get(t)===n&&e.delete(t)}function MH(e,t){return!t.superseded&&(e.latestExplicit?.order??0)<=t.order}function NH(e,t){return(e.latestExplicit?.order??0)<t.order}function PH(e,t,n){let r=AH(e,t),i,a=new Promise(e=>{i=e}),o={title:n,order:++r.nextOrder,settled:a,settle:i};r.pendingClaim=o,r.inFlightClaims.add(o);for(let e of r.generations)e.order<o.order&&(e.claim=o);return o}function FH(e,t,n,r){n.settle(r);let i=e.get(t);i!==void 0&&(i.inFlightClaims.delete(n),i.pendingClaim===n&&(i.pendingClaim=null,r&&(i.manualTitle=n.title)),jH(e,t,i))}function IH(e,t,n){let r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,jH(e,t,n),r}function LH(e,t){e.delete(t)}function RH(e,t,n){let r=AH(e,t);if(n&&r.pendingClaim===null&&IH(e,t,r)!==void 0)return null;let i,a=new Promise(e=>{i=e}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,beforeGenerationClaims:n?[]:[...r.inFlightClaims],superseded:!1,persisted:a,settlePersisted:i};if(!n){r.pendingClaim=null,r.manualTitle=void 0,r.latestExplicit=o;for(let e of r.generations)e.automatic&&(e.superseded=!0)}return r.generations.add(o),o}async function zH({states:e,threadId:t,automatic:n,generate:r,rename:i,applyTitle:a}){let o=AH(e,t),s=RH(e,t,n);if(s===null)return;let c,l=s.order,u=async e=>{let t=await e.settled;if(s.claim===e)return t||(s.claim=null,o.pendingClaim===e&&(o.pendingClaim=null)),t},d=()=>n&&IH(e,t,o)!==void 0,f=async()=>{if(c!==void 0)for(;;){let e=s.claim;if(e!==null&&e.order>l&&NH(o,e)){await u(e)===!0&&(c=e.title,l=e.order,await i(e.title));continue}let t=o.latestExplicit;if(t===null||t.order<=l)return;let n=await t.persisted;if(o.latestExplicit===t){if(l=t.order,n===void 0||n===c)return;c=n,await i(n)}}},p=async()=>{if(s.beforeGenerationClaims.length>0&&await Promise.all(s.beforeGenerationClaims.map(e=>e.settled)),s.claim!==null){let e=await u(s.claim);if(e===!0){s.superseded=!0;return}if(e===!1&&d())return}if(!MH(o,s))return;let e=!1,t;for(await r(async n=>{e=!0,t=n,n!==void 0&&(c=n);let r=s.claim;if(r!==null){if(await u(r)!==!1)return;if(d()){s.superseded=!0;return}}MH(o,s)&&await a(t)});;){let n=s.claim;if(n===null)return;let r=await u(n);if(r!==void 0){if(r===!1){if(d())return;e&&MH(o,s)&&await a(t);return}if(!NH(o,n))return;if(await i(n.title),c=n.title,l=n.order,s.claim===n){if(!MH(o,s))return;await a(n.title),s.superseded=!0;return}}}};try{await p(),await f()}finally{s.settlePersisted(c),o.generations.delete(s),jH(e,t,o)}}var BH=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),VH=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),HH=bH(),UH=class extends HF{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_titleStates=new Map;_mainThreadId;_state=new pH(HH);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,P.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=wz(e());return n==null?t:(0,P.jsx)(oV,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?HM:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=CH(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>e===this._loadGeneration?{...t,isLoading:!0,loadError:void 0}:t,then:(r,i)=>{if(e!==this._loadGeneration)return r;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads({...r,loadError:void 0},i.threads,vH(i.nextCursor));let a=yH(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return SH({...r,isLoading:!1,loadError:void 0,cursor:vH(i.nextCursor),threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadIdMap:a.threadIdMap,threadData:a.threadData},r,n)}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1,loadError:n});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads({...this._state.baseValue,loadError:n},[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?{...e,isLoadingMore:!0}:e,then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=yH(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:vH(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new uH(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new UF(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;providerStore;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0}),this._titleStates.clear()),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new kH}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new kH}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,n=t&&Object.hasOwn(e.threadData,t)?e.threadData[t]:void 0;n?.status===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i)for(let t of Object.values(e.threadData))i.has(t.id)||(t.status===`new`||t.remoteId!==void 0)&&r.push(t);this._staleThreadIdsOnReplace=void 0;let a={threadIds:[],archivedThreadIds:[],threadIdMap:Mj(),threadData:Mj()};for(let e of r){let t=gH(e.id);Object.hasOwn(a.threadData,t)||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=yH(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=gH(e.id),n=Object.hasOwn(l,t)?l[t]:void 0;n!==void 0&&(n.status===`regular`&&!o.includes(n.id)?o.push(n.id):n.status===`archived`&&!s.includes(n.id)&&s.push(n.id))}let u={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(c,e.newThreadId)?void 0:e.newThreadId};if(wH(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=xH(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))d.has(t.id)||this._hookManager.stopThreadRuntime(t.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get loadError(){return this._state.value.loadError}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return wH(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&dH(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||hH}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw BH(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return wH(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new kH;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=gH(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw BH(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n!==this._switchGeneration)return;let o=this.getItemById(i.id);o?.id===i.id&&(o.status===`archived`&&t?.unarchive!==!1&&(await o.initializeTask,n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)||o.status===`archived`&&(await this.unarchive(o.id),n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)))||(this._mainThreadId=o.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?this._startSwitchToNewThread(!1):this._startSwitchToThread(e,void 0,!1)}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=xH(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw BH(e,`initializing it`);if(t.status===`new`)throw VH(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}this._requireAdapterGeneration(n);let r=t.initialize(e),i,{remoteId:a,externalId:o}=await this._state.optimisticUpdate({execute:()=>r,optimistic:t=>OH(t,e,r),then:(t,{remoteId:r,externalId:a})=>{if(n!==this._adapterGeneration)return t;let o=TH(t,e,r,a,e);return i=o.removedMappingId,i===this._mainThreadId&&(this._mainThreadId=o.survivorMappingId),o.state}});return this._requireAdapterGeneration(n),i!==void 0&&this._hookManager.stopThreadRuntime(i),{remoteId:a,externalId:o}};generateTitle=async(e,t)=>{this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw BH(e,`generating its title`);if(i.status===`new`)throw VH(e,i.status,`generate a title`);let{remoteId:a}=await i.initializeTask;this._requireAdapterGeneration(r);let o=this._hookManager.getThreadRuntimeCore(i.id);if(!o)return;let s=o.messages.filter(rH);await zH({states:this._titleStates,threadId:i.id,automatic:t?.automatic===!0,generate:async e=>{let t=await n.generateTitle(a,s);this._requireAdapterGeneration(r),await iH(t,e)},rename:async e=>{this._requireAdapterGeneration(r),await n.rename(a,e)},applyTitle:async e=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:t=>{if(r!==this._adapterGeneration)return t;let n=wH(t,i.id);return n?{...t,threadData:{...t.threadData,[n.id]:{...n,title:e}}}:t}})}})};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw BH(e,`renaming it`);if(i.status===`new`)throw VH(e,i.status,`be renamed`);let a=PH(this._titleStates,i.id,t);try{let o=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=wH(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}});return FH(this._titleStates,i.id,a,!0),o}catch(e){throw FH(this._titleStates,i.id,a,!1),e}}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw BH(e,`updating its custom metadata`);if(i.status===`new`)throw VH(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=wH(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){let e=this._switchTask,n=!e||e===t;n&&(e=this.switchToNewThread()),t=e;try{await e}catch(t){if(n&&this._switchTask===e)throw t}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw BH(e,`archiving it`);if(r.status!==`regular`)throw VH(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>DH(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw BH(e,`unarchiving it`);if(r.status!==`archived`)throw VH(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>DH(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw BH(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw VH(e,r.status,`be deleted`);await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n);let i=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>DH(e,r.id,`deleted`)});return this._hookManager.stopThreadRuntime(r.id),LH(this._titleStates,r.id),i}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw BH(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw VH(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new UF([]);__internal_RenderComponent=()=>{let e=zM();X(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=lI(this.boundIdsStore),n=lI(this.providerStore),r=Q();return(t.length===0||t[0]===e)&&(0,P.jsxs)(oV,{adapters:this._runtimeAdapters,children:[(0,P.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,P.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},WH=class extends vV{threads;constructor(e){super(),this.threads=new UH(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},GH=e=>{let t=J(18),n;t[0]===e?n=t[1]:(n=()=>new WH(e),t[0]=e,t[1]=n);let[r]=AM(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>queueMicrotask(()=>r.threads.__internal_dispose()),t[2]=r.threads,t[3]=i);let a;t[4]===r?a=t[5]:(a=[r],t[4]=r,t[5]=a),RM(i,a);let o;t[6]!==e||t[7]!==r.threads?(o=()=>{r.threads.__internal_setOptions(e),r.threads.__internal_load()},t[6]=e,t[7]=r.threads,t[8]=o):o=t[8];let s;t[9]!==e||t[10]!==r?(s=[r,e],t[9]=e,t[10]=r,t[11]=s):s=t[11],X(o,s);let c;t[12]===r.threads?c=t[13]:(c=()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{r.threads.loadError!==void 0&&r.threads.reload()},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},t[12]=r.threads,t[13]=c);let l;t[14]===r?l=t[15]:(l=[r],t[14]=r,t[15]=l),X(c,l);let u;return t[16]===r?u=t[17]:(u=new pV(r),t[16]=r,t[17]=u),u},KH=e=>{let[t]=AM(()=>new UF(e.runtimeHook));PM(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=Y(e.initialThreadId),r=NM(function(){return lI({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()},[t]),i=FM(t=>e.onThreadIdChange?.(t)),a=MM(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(Q().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return GH(a)},qH=e=>{let t=J(6),{id:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=YN({message:kF({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:kF({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(rL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},JH=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,YH=()=>null,XH=new WeakMap,ZH=(e,t)=>{let n=XH.get(e);return n||(n=new Set(e.map(e=>e.id)),XH.set(e,n)),n.has(t)},QH=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message??YH:e.SystemMessage??e.Message??YH;default:throw Error(`Unknown message role: ${t}`)}},$H=e=>{let t=J(6),{components:n}=e,r=$(aU),i=$(oU),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=QH(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,P.jsx)(o,{}),t[4]=o,t[5]=s),s},eU=VM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)($H,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(mB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&JH(e.components,t.components));eU.displayName=`ThreadPrimitive.MessageByIndex`;var tU=VM(e=>{let t=J(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>ZH(e.thread.messages,n),t[0]=n,t[1]=i),!$(i))return null;let a;t[2]===r?a=t[3]:(a=(0,P.jsx)($H,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,P.jsx)(qH,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&JH(e.components,t.components));tU.displayName=`ThreadPrimitive.Unstable_MessageById`;var nU=({children:e})=>{let t=$(nF(e=>e.thread.messages.map(e=>e.id)));return MM(()=>t.length===0?null:t.map((t,n)=>(0,P.jsx)(mB,{index:n,children:(0,P.jsx)(oL,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},t)),[t,e])},rU=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(nU,{children:()=>(0,P.jsx)($H,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(nU,{children:r}),t[2]=r,t[3]=i),i};rU.displayName=`ThreadPrimitive.Messages`;var iU=VM(rU,(e,t)=>e.children||t.children?e.children===t.children:JH(e.components,t.components));function aU(e){return e.message.role}function oU(e){return e.message.composer.isEditing}var sU=e=>{let t=e.message.metadata;if(t&&typeof t==`object`)return t.custom?.quote},cU=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},lU=e=>typeof e==`object`&&!!e,uU=e=>e==null?[]:Array.isArray(e)?e:[e],dU=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!lU(e)||!(`component`in e)||typeof e.component!=`string`)return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,P.jsx)(n,{component:i,props:a},s??r);throw new cU(i)}return UM(c,{...a??{},key:s??r},...uU(o).map((e,i)=>dU(e,t,n,`${r}/${i}`)))},fU=e=>{let t=J(11),{spec:n,components:r,Fallback:i}=e,a=n?.root,o;t[0]===a?o=t[1]:(o=uU(a),t[0]=a,t[1]=o);let s=o,c;if(t[2]!==i||t[3]!==r||t[4]!==s){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>dU(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],c=s.map(e),t[2]=i,t[3]=r,t[4]=s,t[5]=c}else c=t[5];let l;return t[9]===c?l=t[10]:(l=(0,P.jsx)(P.Fragment,{children:c}),t[9]=c,t[10]=l),l};fU.displayName=`GenerativeUIRender`;var pU=e=>{let t=J(4),{components:n,spec:r,Fallback:i}=e,a=$(mU),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,P.jsx)(fU,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};pU.displayName=`MessagePrimitive.GenerativeUI`;function mU(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var hU=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},gU=(e,t,n)=>{let r=[];if(t){let t=hU(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=hU(`toolGroup`),n=hU(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},_U=e=>{let t=J(10),n=$(nF(VU)),r=$(nF(UU)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=gU(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},vU=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},yU=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),bU=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>yU(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},xU={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},SU=e=>{let t=J(41),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?xU.Text:i,m=a===void 0?xU.Reasoning:a,h=o===void 0?xU.Image:o,g=s===void 0?xU.Source:s,_=c===void 0?xU.File:c,v=l===void 0?xU.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let b=y,x=Q(),S=$(WU),C=S.type;if(C===`tool-call`){let e=x.part.addToolResult,n=x.part.resumeToolCall,r=x.part.respondToToolApproval;if(`Override`in b){let i;return t[4]!==e||t[5]!==S||t[6]!==r||t[7]!==n||t[8]!==b.Override?(i=(0,P.jsx)(b.Override,{...S,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=S,t[6]=r,t[7]=n,t[8]=b.Override,t[9]=i):i=t[9],i}let i=b.by_name?.[S.toolName]??b.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==S||t[13]!==r||t[14]!==n?(a=(0,P.jsx)(vU,{...S,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=S,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[16]!==p||t[17]!==S?(e=(0,P.jsx)(p,{...S}),t[16]=p,t[17]=S,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==m||t[20]!==S?(e=(0,P.jsx)(m,{...S}),t[19]=m,t[20]=S,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==g||t[23]!==S?(e=(0,P.jsx)(g,{...S}),t[22]=g,t[23]=S,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==h||t[26]!==S?(e=(0,P.jsx)(h,{...S}),t[25]=h,t[26]=S,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==_||t[29]!==S?(e=(0,P.jsx)(_,{...S}),t[28]=_,t[29]=S,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==v||t[32]!==S?(e=(0,P.jsx)(v,{...S}),t[31]=v,t[32]=S,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[34]!==e||t[35]!==S?(n=(0,P.jsx)(bU,{...S,Fallback:e}),t[34]=e,t[35]=S,t[36]=n):n=t[36],n}case`generative-ui`:{if(!f?.components)return null;let e=S,n;return t[37]!==f.Fallback||t[38]!==f.components||t[39]!==e.spec?(n=(0,P.jsx)(fU,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[37]=f.Fallback,t[38]=f.components,t[39]=e.spec,t[40]=n):n=t[40],n}default:return console.warn(`Unknown message part type: ${C}`),null}},CU=VM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(SU,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(hB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);CU.displayName=`MessagePrimitive.PartByIndex`;var wU=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,P.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,P.jsx)(_B,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},TU=Object.freeze({type:`complete`}),EU=Object.freeze({type:`running`}),DU=VM(e=>{let t=J(6),{components:n}=e,r=$(GU);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,P.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??xU.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(wU,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),OU=VM(e=>{let t=J(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!$(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,P.jsx)(DU,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),kU=VM(e=>{let t=J(4),{Quote:n}=e,r=$(sU);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,P.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function AU(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(GB(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var jU=()=>{let e=J(6),t=Q(),n=$(KU),r=$(qU);if(!r||n.type!==`tool-call`)return null;let i;return e[0]!==r||e[1]!==t.part.addToolResult||e[2]!==t.part.respondToToolApproval||e[3]!==t.part.resumeToolCall||e[4]!==n?(i=(0,P.jsx)(r,{...n,addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval}),e[0]=r,e[1]=t.part.addToolResult,e[2]=t.part.respondToToolApproval,e[3]=t.part.resumeToolCall,e[4]=n,e[5]=i):i=e[5],i},MU=()=>{let e=J(3),t=$(JU),n=$(YU);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,P.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},NU=()=>{let e=J(2),t=$(XU);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(jU,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(MU,{}),e[1]=t):t=e[1],t}return null},PU=Object.freeze({type:`text`,text:``,status:EU}),FU=({children:e})=>{let t=Q(),n=$(e=>e.dataRenderers);return(0,P.jsx)(oL,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=AU(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,P.jsx)(jU,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=yU(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,P.jsx)(MU,{}):null}}return e}})})},IU=e=>{let t=J(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(FU,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(hB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},LU=e=>{let t=J(9),{children:n}=e,r=$(ZU),i=$(QU),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:PU}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,P.jsx)(_B,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,P.jsx)(IU,{index:t,children:e=>n(e)??(0,P.jsx)(NU,{})},t),t[7]=n,t[8]=e),o=(0,P.jsx)(P.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},RU=e=>{let t=J(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,P.jsx)(LU,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,P.jsx)(zU,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};RU.displayName=`MessagePrimitive.Parts`;var zU=e=>{let t=J(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=$($U),{ranges:a,partIds:o}=_U(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,P.jsx)(DU,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,P.jsx)(CU,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,P.jsx)(wB,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,P.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}if(e.type===`toolGroup`){let t=n?.ToolGroup??xU.ToolGroup;return(0,P.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,P.jsx)(CU,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??xU.ReasoningGroup;return(0,P.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,P.jsx)(CU,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,P.jsx)(kU,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,P.jsx)(OU,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,P.jsxs)(P.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function BU(e){return e.type}function VU(e){return e.message.parts.map(BU)}function HU(e){return e.type===`tool-call`?e.toolCallId:void 0}function UU(e){return e.message.parts.map(HU)}function WU(e){return e.part}function GU(e){return e.message.status??TU}function KU(e){return e.part}function qU(e){return e.part.type===`tool-call`?AU(e.tools,e.part):null}function JU(e){return e.part}function YU(e){return e.part.type===`data`?yU(e.dataRenderers,e.part.name,void 0)??null:null}function XU(e){return e.part.type}function ZU(e){return e.message.parts.length}function QU(e){return(e.message.status?.type??`complete`)===`running`}function $U(e){return e.message.parts.length}var eW=Symbol.for(`@assistant-ui/groupBy.memoKey`),tW=e=>{let t=e,n=((e,n)=>{if(e.type===`tool-call`){if((GB(e.mcp?.app?.resourceUri)||(n?.toolUIs?.[e.toolName]?.[0]?.standalone??!1))&&t[`standalone-tool-call`]!==void 0)return t[`standalone-tool-call`];let r=t[`tool-call:${e.toolName}`];return r===void 0?t[`tool-call`]??[]:r}return t[e.type]??[]}),r=Object.keys(e).sort().map(t=>[t,e[t]]);return n[eW]=`groupPartByType:${JSON.stringify(r)}`,n},nW=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},rW=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},iW=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:rW(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:nW(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:nW(s),idKey:rW(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},aW=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},oW=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},sW=(e,t,n)=>{if(e.type===`part`)return(0,P.jsx)(IU,{index:e.index,children:({part:e})=>n({part:e,children:(0,P.jsx)(oW,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let{status:r,counts:i}=SB(t,e.indices),a={type:e.key,status:r,counts:i,indices:e.indices};return(0,P.jsx)(HM,{children:n({part:a,children:(0,P.jsx)(P.Fragment,{children:e.children.map(e=>sW(e,t,n))})})},e.idKey??e.nodeKey)},cW=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=$(nF(e=>e.message.parts)),i=$(e=>e.tools.toolUIs),a=$(e=>t!==`never`&&e.message.status?.type===`running`),o=MM(()=>{let t={toolUIs:i};return iW(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[eW]??e,i]);return(0,P.jsxs)(P.Fragment,{children:[o.map(e=>sW(e,r,n)),aW(t,r,a)&&n({part:{type:`indicator`},children:(0,P.jsx)(oW,{})})]})};cW.displayName=`MessagePrimitive.GroupedParts`;var lW=VM(e=>{let t=J(5),{children:n}=e,r=$(sU);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,P.jsx)(P.Fragment,{children:i}),t[3]=i,t[4]=a),a});lW.displayName=`MessagePrimitive.Quote`;var uW=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},dW=e=>{let t=J(5),{components:n}=e,r=$(hW);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=uW(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,P.jsx)(o,{}),t[3]=o,t[4]=s),s},fW=VM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(dW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(dB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);fW.displayName=`MessagePrimitive.AttachmentByIndex`;var pW=({children:e})=>{let t=$(nF(e=>e.message.role===`user`?(e.message.attachments??[]).map(e=>e.id):[]));return MM(()=>t.map((t,n)=>(0,P.jsx)(dB,{index:n,children:(0,P.jsx)(oL,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},mW=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(pW,{children:e=>{let{attachment:t}=e,r=uW(n,t);return r?(0,P.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(pW,{children:r}),t[2]=r,t[3]=i),i};mW.displayName=`MessagePrimitive.Attachments`;function hW(e){return e.attachment}var gW=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},_W=e=>{let t=J(5),{components:n}=e,r=$(xW);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=gW(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,P.jsx)(a,{}),t[3]=a,t[4]=o),o},vW=VM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(_W,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(fB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);vW.displayName=`ComposerPrimitive.AttachmentByIndex`;var yW=({children:e})=>{let t=$(nF(e=>e.composer.attachments.map(e=>e.id)));return MM(()=>t.map((t,n)=>(0,P.jsx)(fB,{index:n,children:(0,P.jsx)(oL,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},bW=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(yW,{children:e=>{let{attachment:t}=e,r=gW(n,t);return r?(0,P.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(yW,{children:r}),t[2]=r,t[3]=i),i};bW.displayName=`ComposerPrimitive.Attachments`;function xW(e){return e.attachment}var SW=VM(({children:e})=>{let t=$(nF(e=>e.composer.queue.map(e=>e.id)));return MM(()=>t.map((t,n)=>(0,P.jsx)(OB,{index:n,children:(0,P.jsx)(oL,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});SW.displayName=`ComposerPrimitive.Queue`;var CW=VM(e=>{let t=J(6),{index:n,archived:r,components:i}=e,a=r!==void 0&&r,o=i.ThreadListItem,s;t[0]===o?s=t[1]:(s=(0,P.jsx)(o,{}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==n||t[4]!==s?(c=(0,P.jsx)(EB,{index:n,archived:a,children:s}),t[2]=a,t[3]=n,t[4]=s,t[5]=c):c=t[5],c},(e,t)=>e.index===t.index&&e.archived===t.archived&&e.components.ThreadListItem===t.components.ThreadListItem);CW.displayName=`ThreadListPrimitive.ItemByIndex`;var wW=({archived:e,children:t})=>{let n=$(nF(t=>e?t.threads.archivedThreadIds:t.threads.threadIds));return MM(()=>n.map((n,r)=>(0,P.jsx)(EB,{index:r,archived:e,children:(0,P.jsx)(oL,{getItemState:t=>t.threads.item({index:r,archived:e}).getState(),children:e=>t({get threadListItem(){return e()}})})},n)),[n,e,t])},TW=e=>{let t=J(8),{archived:n,components:r,children:i}=e,a=n!==void 0&&n;if(r){let e=r.ThreadListItem,n;t[0]===e?n=t[1]:(n=()=>(0,P.jsx)(e,{}),t[0]=e,t[1]=n);let i;return t[2]!==a||t[3]!==n?(i=(0,P.jsx)(wW,{archived:a,children:n}),t[2]=a,t[3]=n,t[4]=i):i=t[4],i}let o;return t[5]!==a||t[6]!==i?(o=(0,P.jsx)(wW,{archived:a,children:i}),t[5]=a,t[6]=i,t[7]=o):o=t[7],o};TW.displayName=`ThreadListPrimitive.Items`;var EW=e=>{let{children:t}=e;return $(DW)?t:null};EW.displayName=`MessagePartPrimitive.InProgress`;function DW(e){return e.part.status.type===`running`}var OW=e=>{let t=J(2),{fallback:n}=e,r=$(kW)||n,i;return t[0]===r?i=t[1]:(i=(0,P.jsx)(P.Fragment,{children:r}),t[0]=r,t[1]=i),i};OW.displayName=`ThreadListItemPrimitive.Title`;function kW(e){return e.threadListItem.title}var AW=e=>{let t=J(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,P.jsx)(r,{}),t[0]=r,t[1]=i),i},jW=VM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(AW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(DB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);jW.displayName=`ThreadPrimitive.SuggestionByIndex`;var MW=({children:e})=>{let t=$(e=>e.suggestions.suggestions.length);return MM(()=>t===0?null:Array.from({length:t},(t,n)=>(0,P.jsx)(DB,{index:n,children:(0,P.jsx)(oL,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},NW=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(MW,{children:()=>(0,P.jsx)(AW,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(MW,{children:r}),t[2]=r,t[3]=i),i};NW.displayName=`ThreadPrimitive.Suggestions`;var PW=VM(NW,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),FW=e=>{let t=J(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],$(n)},IW=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),FW(r)?n:null};IW.displayName=`ComposerPrimitive.If`;var LW=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,RW=e=>!e.composer.canCancel,zW=e=>e.composer.isEditing||e.optional.thread?.voice!==void 0||e.optional.thread?.capabilities.edit===!1,BW=e=>e.thread.isRunning||e.thread.isDisabled||e.thread.voice!==void 0||e.message.role!==`assistant`||!e.thread.capabilities.reload,VW=e=>e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(e=>e.type===`text`&&e.text.length>0),HW=e=>e.message.branchNumber<=1||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,UW=e=>e.message.branchNumber>=e.message.branchCount||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,WW=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,GW=e=>{if(e.message.status?.type!==`incomplete`||e.message.status.reason!==`error`)return;let t=e.message.status.error;return typeof t==`string`?t:typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:t??`An error occurred`},KW=e=>!e.threads.hasMore||e.threads.isLoading||e.threads.isLoadingMore,qW=()=>{let e=J(5),t=Q(),n=$(LW),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},JW=()=>{let e=J(5),t=Q(),n=$(RW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},YW=()=>{let e=J(5),t=Q(),n=$(XW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function XW(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var ZW=()=>{let e=J(5),t=Q(),n=$(QW),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function QW(e){return!e.composer.isEditing}var $W=e=>{let t=J(15),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=Q(),s=$(VW),c=$(eG),l=$(tG),u=$(nG),d=Y(void 0),f=Y(0),p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>()=>{f.current+=1,d.current!==void 0&&(clearTimeout(d.current),d.current=void 0,o.message.setIsCopied(!1))},m=[o],t[2]=o,t[3]=p,t[4]=m),X(p,m);let h;t[5]!==o||t[6]!==u||t[7]!==a||t[8]!==i||t[9]!==l?(h=()=>{if(!i)return;let e=l?u:o.message.getCopyText();if(!e)return;let t=f.current,n;try{n=i(e)}catch{return}Promise.resolve(n).then(()=>{t===f.current&&(d.current!==void 0&&clearTimeout(d.current),o.message.setIsCopied(!0),d.current=setTimeout(()=>{d.current=void 0,o.message.setIsCopied(!1)},a))},rG)},t[5]=o,t[6]=u,t[7]=a,t[8]=i,t[9]=l,t[10]=h):h=t[10];let g=h,_=s||!i,v;return t[11]!==g||t[12]!==c||t[13]!==_?(v={copy:g,disabled:_,isCopied:c},t[11]=g,t[12]=c,t[13]=_,t[14]=v):v=t[14],v};function eG(e){return e.message.isCopied}function tG(e){return e.composer.isEditing}function nG(e){return e.composer.text}function rG(){}var iG=()=>{let e=J(5),t=Q(),n=$(zW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},aG=()=>{let e=J(5),t=Q(),n=$(BW),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},oG=()=>{let e=J(5),t=Q(),n=$(cG),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},sG=()=>{let e=J(5),t=Q(),n=$(lG),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function cG(e){return e.message.metadata.submittedFeedback?.type===`positive`}function lG(e){return e.message.metadata.submittedFeedback?.type===`negative`}var uG=()=>{let e=J(5),t=Q(),n=$(fG),r;e[0]===t?r=e[1]:(r=async()=>{t.message.speak()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function dG(e){return e.type===`text`&&e.text.length>0}function fG(e){return e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(dG)}var pG=()=>{let e=J(5),t=Q(),n=$(mG),r;e[0]===t?r=e[1]:(r=()=>{t.message.stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function mG(e){return e.message.speech==null}var hG=()=>{let e=J(5),t=Q(),n=$(UW),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`next`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={next:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},gG=()=>{let e=J(5),t=Q(),n=$(HW),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`previous`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={previous:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},_G=e=>{let t=J(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=Q(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>WW(e,s),t[0]=s,t[1]=c);let l=$(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let{isRunning:e,capabilities:t}=o.thread.getState();if(e&&!t.queue)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&!e&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(vG).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function vG(e){return e.trim()}var yG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.archive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={archive:r},e[2]=r,e[3]=i),i},bG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.delete()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={delete:r},e[2]=r,e[3]=i),i},xG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.unarchive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={unarchive:r},e[2]=r,e[3]=i),i},SG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.switchTo()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchTo:r},e[2]=r,e[3]=i),i},CG=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threads.switchToNewThread()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchToNewThread:r},e[2]=r,e[3]=i),i},wG=()=>{let e=J(5),t=Q(),n=$(KW),r;e[0]===t?r=e[1]:(r=()=>{t.threads.loadMore()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={loadMore:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},TG=()=>$(GW),EG=e=>{let{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c,...l}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c},otherOptions:l}};function DG(e,t){function n(n){let r=JM(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function OG(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var kG=KM(null),{useThreadViewport:AG,useThreadViewportStore:jG}=OG(DG(kG,`ThreadPrimitive.Viewport`),`useThreadViewport`),MG=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},NG=(e=>e?MG(e):MG),PG=e=>e;function FG(e,t=PG){let n=N.useSyncExternalStore(e.subscribe,N.useCallback(()=>t(e.getState()),[e,t]),N.useCallback(()=>t(e.getInitialState()),[e,t]));return N.useDebugValue(n),n}var IG=e=>{let t=NG(e),n=e=>FG(t,e);return Object.assign(n,t),n},LG=(e=>e?IG(e):IG),RG=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},zG=(e={})=>{let t=new Set,n=RG(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=RG(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=LG(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{JN(t,()=>({behavior:e}),`Thread viewport`)},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},BG=e=>e,VG=e=>{let t=J(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=jG(n),i;t[1]===e?i=t[2]:(i=()=>zG(e),t[1]=e,t[2]=i);let[a]=AM(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(e=>{a.getState().scrollToBottom(e)}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),X(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&BG(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),X(c,l),a},HG=e=>{let t=J(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=VG(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=AM(o),c;return t[4]!==n||t[5]!==s?(c=(0,P.jsx)(kG.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},UG=()=>{let e=J(3),t=Q(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),X(n,r),null},WG=VM(e=>{let t=J(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,P.jsx)(UG,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,P.jsx)(HG,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,P.jsxs)(dL,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),GG=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,KG={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(GG)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},qG=Object.defineProperty,JG=(e,t)=>qG(e,`name`,{value:t,configurable:!0});function YG(e,t=globalThis?.document){let n=fn(e);N.useEffect(()=>{let e=JG(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}JG(YG,`useEscapeKeydown`);var XG=f;XG.dispatchDiscreteCustomEvent=v,XG.Root=f;var ZG=Object.defineProperty,QG=(e,t)=>{let n={};for(var r in e)ZG(n,r,{get:e[r],enumerable:!0});return t||ZG(n,Symbol.toStringTag,{value:`Module`}),n},$G=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function eK(e,t){return WM(e,void 0,t===void 0?e.props.children:t)}function tK(e,t,n){return(0,P.jsx)(c,{...n,children:eK(e,t)})}function nK(e){let t=Z((t,n)=>{let r=J(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&GM(o)){let e=s,t;r[5]!==a||r[6]!==o?(t=eK(o,a),r[5]=a,r[6]=o,r[7]=t):t=r[7];let i;return r[8]!==n||r[9]!==e||r[10]!==t?(i=(0,P.jsx)(c,{...e,asChild:!0,ref:n,children:t}),r[8]=n,r[9]=e,r[10]=t,r[11]=i):i=r[11],i}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,P.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function rK(e){let t=XG[e],n=nK(t);return n.displayName=`Primitive.${e}`,n}var iK=$G.reduce((e,t)=>(e[t]=rK(t),e),{}),aK={Hidden:`hidden`,Floating:`floating`,Normal:`normal`},oK=e=>{let t=J(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return aK.Hidden;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?aK.Floating:aK.Normal:aK.Hidden:aK.Normal},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],$(o)},sK=KM(null),cK=()=>JM(sK),lK=Z((e,t)=>{let n=J(18),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({hideWhenRunning:a,autohide:r,autohideFloat:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let[s,c]=AM(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(uK),()=>{e||(e=!0,c(dK))}},n[5]=l):l=n[5];let u=l,d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={acquireInteractionLock:u},n[6]=d):d=n[6];let f=d,p=s>0,m;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==p?(m={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:p},n[7]=r,n[8]=i,n[9]=a,n[10]=p,n[11]=m):m=n[11];let h=oK(m);if(h===aK.Hidden)return null;let g;n[12]===h?g=n[13]:(g=h===aK.Floating?{"data-floating":`true`}:null,n[12]=h,n[13]=g);let _;return n[14]!==t||n[15]!==o||n[16]!==g?(_=(0,P.jsx)(sK.Provider,{value:f,children:(0,P.jsx)(iK.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});lK.displayName=`ActionBarPrimitive.Root`;function uK(e){return e+1}function dK(e){return Math.max(0,e-1)}var fK=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:mK},t[2]=i,t[3]=a);let{copy:o,disabled:s}=$W(a);return s?null:o},pK=Z((e,t)=>{let n=J(20),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({copiedDuration:r,onClick:a,disabled:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=$(hK),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=fK(c),u;n[7]===s?u=n[8]:(u=s?{"data-copied":`true`}:{},n[7]=s,n[8]=u);let d=i||!l,f;n[9]===l?f=n[10]:(f=()=>{l?.()},n[9]=l,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=F(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==o||n[16]!==u||n[17]!==d||n[18]!==p?(m=(0,P.jsx)(iK.button,{type:`button`,...u,...o,ref:t,disabled:d,onClick:p}),n[14]=t,n[15]=o,n[16]=u,n[17]=d,n[18]=p,n[19]=m):m=n[19],m});pK.displayName=`ActionBarPrimitive.Copy`;function mK(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function hK(e){return e.message.isCopied}var gK=(e,t,n=[])=>{let r=Z((e,r)=>{let i=J(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=iK,l=o.disabled||!s,u=F(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,P.jsx)(c.button,{type:`button`,...o,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},_K=gK(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=aG();return e?null:t}),vK=gK(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=iG();return e?null:t}),yK=gK(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=uG();return e?null:t}),bK=()=>{let{disabled:e,stopSpeaking:t}=pG();return e?null:t},xK=Z((e,t)=>{let n=J(10),r=bK(),i=!r,a;n[0]===r?a=n[1]:(a=()=>{r?.()},n[0]=r,n[1]=a);let o;n[2]!==e.onClick||n[3]!==a?(o=F(e.onClick,a),n[2]=e.onClick,n[3]=a,n[4]=o):o=n[4];let s;return n[5]!==e||n[6]!==t||n[7]!==i||n[8]!==o?(s=(0,P.jsx)(iK.button,{type:`button`,disabled:i,...e,ref:t,onClick:o}),n[5]=e,n[6]=t,n[7]=i,n[8]=o,n[9]=s):s=n[9],s});xK.displayName=`ActionBarPrimitive.StopSpeaking`;var SK=()=>{let{submit:e}=oG();return e},CK=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(wK),s=SK(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=F(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,P.jsx)(iK.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});CK.displayName=`ActionBarPrimitive.FeedbackPositive`;function wK(e){return e.message.metadata.submittedFeedback?.type===`positive`}var TK=()=>{let{submit:e}=sG();return e},EK=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(DK),s=TK(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=F(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,P.jsx)(iK.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});EK.displayName=`ActionBarPrimitive.FeedbackNegative`;function DK(e){return e.message.metadata.submittedFeedback?.type===`negative`}var OK=e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=Q(),o=$(jK),s;return t[2]!==a.message||t[3]!==r||t[4]!==i?(s=async()=>{let e=a.message.getCopyText();if(!e)return;if(i){await i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r??`message-${Date.now()}.md`,o.click(),setTimeout(()=>URL.revokeObjectURL(n),4e4)},t[2]=a.message,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},kK=Z((e,t)=>{let n=J(19),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({filename:i,onExport:o,onClick:a,disabled:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==i||n[7]!==o?(c={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=c):c=n[8];let l=OK(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.().catch(MK)},n[9]=l,n[10]=d);let f;n[11]!==a||n[12]!==d?(f=F(a,d),n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;return n[14]!==t||n[15]!==s||n[16]!==u||n[17]!==f?(p=(0,P.jsx)(iK.button,{type:`button`,...s,ref:t,disabled:u,onClick:f}),n[14]=t,n[15]=s,n[16]=u,n[17]=f,n[18]=p):p=n[18],p});kK.displayName=`ActionBarPrimitive.ExportMarkdown`;function AK(e){return e.type===`text`&&e.text.length>0}function jK(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(AK)}function MK(e){console.error(`[assistant-ui] markdown export failed:`,e)}var NK=QG({Copy:()=>pK,Edit:()=>vK,ExportMarkdown:()=>kK,FeedbackNegative:()=>EK,FeedbackPositive:()=>CK,Reload:()=>_K,Root:()=>lK,Speak:()=>yK,StopSpeaking:()=>xK}),PK=cu(),FK=e=>{let t=J(25),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({__scopeActionBarMore:n,open:i,onOpenChange:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=PK(n),s=cK(),c=Y(null),l=i!==void 0,u;t[5]===s?u=t[6]:(u=e=>{if(e){if(c.current)return;c.current=s?.acquireInteractionLock()??null;return}c.current?.(),c.current=null},t[5]=s,t[6]=u);let d=u,f;t[7]!==l||t[8]!==r||t[9]!==d?(f=e=>{l||d(e),r?.(e)},t[7]=l,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p=f,m,h;t[11]!==l||t[12]!==i||t[13]!==d?(m=()=>{l&&d(!!i)},h=[l,i,d],t[11]=l,t[12]=i,t[13]=d,t[14]=m,t[15]=h):(m=t[14],h=t[15]),X(m,h);let g,_;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{c.current?.(),c.current=null},_=[],t[16]=g,t[17]=_):(g=t[16],_=t[17]),X(g,_);let v;t[18]===i?v=t[19]:(v=i===void 0?null:{open:i},t[18]=i,t[19]=v);let y;return t[20]!==p||t[21]!==a||t[22]!==o||t[23]!==v?(y=(0,P.jsx)(Au,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};FK.displayName=`ActionBarMorePrimitive.Root`;var IK=nK(ju),LK=nK(Nu),RK=nK(Iu),zK=nK(Vu),BK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=PK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(IK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});BK.displayName=`ActionBarMorePrimitive.Trigger`;var VK=Z((e,t)=>{let n=J(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({__scopeActionBarMore:r,portalProps:i,sideOffset:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?4:o,c=PK(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,P.jsx)(LK,{...c,...a,ref:t,sideOffset:s}),n[5]=t,n[6]=a,n[7]=c,n[8]=s,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==c||n[12]!==l?(u=(0,P.jsx)(Mu,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});VK.displayName=`ActionBarMorePrimitive.Content`;var HK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=PK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(RK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});HK.displayName=`ActionBarMorePrimitive.Item`;var UK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=PK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(zK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});UK.displayName=`ActionBarMorePrimitive.Separator`;var WK=QG({Content:()=>VK,Item:()=>HK,Root:()=>FK,Separator:()=>UK,Trigger:()=>BK}),GK=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(iK.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});GK.displayName=`AttachmentPrimitive.Root`;var KK=Z((e,t)=>{let n=J(4),r=$(qK),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(iK.div,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});KK.displayName=`AttachmentPrimitive.unstable_Thumb`;function qK(e){let t=e.attachment.name,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?`.${t.slice(n+1)}`:e.attachment.type}var JK=()=>{let e=J(2),t=$(YK),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};JK.displayName=`AttachmentPrimitive.Name`;function YK(e){return e.attachment.name}var XK=gK(`AttachmentPrimitive.Remove`,()=>{let e=J(2),t=Q(),n;return e[0]===t.attachment?n=e[1]:(n=()=>{t.attachment.remove()},e[0]=t.attachment,e[1]=n),n}),ZK=QG({Name:()=>JK,Remove:()=>XK,Root:()=>GK,unstable_Thumb:()=>KK}),QK=gK(`BranchPickerPrimitive.Next`,()=>{let{disabled:e,next:t}=hG();return e?null:t}),$K=gK(`BranchPickerPrimitive.Previous`,()=>{let{disabled:e,previous:t}=gG();return e?null:t}),eq=()=>$(nq),tq=()=>{let e=J(2),t=eq(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};tq.displayName=`BranchPickerPrimitive.Count`;function nq(e){return e.message.branchCount}var rq=()=>$(aq),iq=()=>{let e=J(2),t=rq(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};iq.displayName=`BranchPickerPrimitive.Number`;function aq(e){return e.message.branchNumber}var oq=Z((e,t)=>{let n=J(11),r,i;n[0]===e?(r=n[1],i=n[2]):({hideWhenSingleBranch:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e=>!r||e.message.branchCount>=2,n[3]=r,n[4]=a);let o;n[5]!==t||n[6]!==i?(o=(0,P.jsx)(iK.div,{...i,ref:t}),n[5]=t,n[6]=i,n[7]=o):o=n[7];let s;return n[8]!==a||n[9]!==o?(s=(0,P.jsx)(eL,{condition:a,children:o}),n[8]=a,n[9]=o,n[10]=s):s=n[10],s});oq.displayName=`BranchPickerPrimitive.Root`;var sq=QG({Count:()=>tq,Next:()=>QK,Number:()=>iq,Previous:()=>$K,Root:()=>oq}),cq=KM(null),lq=()=>JM(cq),uq=e=>{let t=J(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=Y(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(dq),o.current=e.map(fq)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,P.jsx)(cq.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function dq(e,t){return t[1]-e[1]}function fq(e){let[t]=e;return t}var pq=KM(null),mq=KM(null),hq=()=>{let e=JM(pq);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},gq=()=>JM(pq),_q=()=>{let e=JM(mq);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},vq=()=>{let e=hq();return IM(e.subscribe,e.getTriggers,e.getTriggers)},yq=new Map,bq=()=>()=>{},xq=()=>yq,Sq=()=>{let e=gq();return IM(e?e.subscribe:bq,e?e.getTriggers:xq,e?e.getTriggers:xq)},Cq=()=>null,wq=()=>{let e=gq();return IM(e?e.subscribeAria:bq,e?e.getActiveAria:Cq,e?e.getActiveAria:Cq)};function Tq(){let e=J(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=Y(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var Eq=e=>{let t=J(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=Y(a),{notify:s,subscribe:c}=Tq(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return Oq;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=Y(null),g=Y(null),{notify:_,subscribe:v}=Tq(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,P.jsx)(mq.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,P.jsx)(pq.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},Dq=e=>{let t=J(4),{children:n}=e;if(lq()){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(Eq,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,P.jsx)(uq,{children:(0,P.jsx)(Eq,{children:n})}),t[2]=n,t[3]=r),r};Dq.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function Oq(){}var kq=/\s/u;function Aq(e,t,n,r){if(r===null)return null;let{query:i,offset:a,endOffset:o}=r;return a<0||a+t.length>n||!e.startsWith(t,a)||o<a+t.length||o>e.length?null:{query:i,offset:a,endOffset:o}}function jq(e,t,n,r){if(r)return Aq(e,t,n,r(e,t,n));let i=e.slice(0,n);for(let e=i.length-1;e>=0;e--){let r=i[e];if(kq.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!kq.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var Mq=YM(e=>{let t=J(8),{text:n,triggerChar:r,matcher:i}=e,[a,o]=AM(n.length),s=Math.min(a,n.length),c;t[0]!==i||t[1]!==s||t[2]!==n||t[3]!==r?(c=jq(n,r,s,i),t[0]=i,t[1]=s,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=c,u=l?.query??``,d;return t[5]!==u||t[6]!==l?(d={trigger:l,query:u,setCursorPosition:o},t[5]=u,t[6]=l,t[7]=d):d=t[7],d});function Nq(e){return`type`in e}var Pq=YM(e=>{let t=J(22),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=AM(0),m;t[0]!==i||t[1]!==r||t[2]!==n?(m={navigableList:n,isSearchMode:r,activeCategoryId:i},t[0]=i,t[1]=r,t[2]=n,t[3]=m):m=t[3];let[h,g]=AM(m);(h.navigableList!==n||h.isSearchMode!==r||h.activeCategoryId!==i)&&(g({navigableList:n,isSearchMode:r,activeCategoryId:i}),p(0));let _;t[4]!==f||t[5]!==n.length?(_=e=>{e<0||e>=n.length||e!==f&&p(e)},t[4]=f,t[5]=n.length,t[6]=_):_=t[6];let v=FM(_),y;t[7]!==i||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==n||t[12]!==s||t[13]!==a||t[14]!==l||t[15]!==c?(y=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(Nq(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[7]=i,t[8]=d,t[9]=u,t[10]=f,t[11]=n,t[12]=s,t[13]=a,t[14]=l,t[15]=c,t[16]=y):y=t[16];let b=FM(y),x=n[f],S=s&&x?`${o}-option-${x.id}`:void 0,C;return t[17]!==b||t[18]!==v||t[19]!==f||t[20]!==S?(C={highlightedIndex:f,highlightedItemId:S,highlightIndex:v,handleKeyDown:b},t[17]=b,t[18]=v,t[19]=f,t[20]=S,t[21]=C):C=t[21],C});function Fq(e,t){return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var Iq=YM(e=>{let t=J(35),{adapter:n,query:r,open:i}=e,[a,o]=AM(null),[s,c]=AM(i);s!==i&&(c(i),i||o(null));let l;bb0:{if(!i||!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],l=e;break bb0}let e;t[1]===n?e=t[2]:(e=n.categories(),t[1]=n,t[2]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],f=e;break bb1}let e;t[4]!==n||t[5]!==d?(e=n.categoryItems(d),t[4]=n,t[5]=d,t[6]=e):e=t[6],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[7]!==n||t[8]!==r?(e=n.search(r),t[7]=n,t[8]=r,t[9]=e):e=t[9],m=e;break bb2}let e;if(t[10]!==n||t[11]!==u||t[12]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))Fq(r,i)&&e.push(r);t[10]=n,t[11]=u,t[12]=r,t[13]=e}else e=t[13];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[14]=e):e=t[14],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[15]!==u||t[16]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[15]=u,t[16]=r,t[17]=e}else e=t[17];_=e}let v=_,y;bb4:{if(g){let e;t[18]===h?e=t[19]:(e=h??[],t[18]=h,t[19]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[20]!==p||t[21]!==r){let n=r.toLowerCase();e=p.filter(e=>Fq(e,n)),t[20]=p,t[21]=r,t[22]=e}else e=t[22];y=e}let b=y,x;bb5:{if(g){let e;t[23]===h?e=t[24]:(e=h??[],t[23]=h,t[24]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[25]=C):C=t[25];let w=FM(C),T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[26]=T):T=t[26];let E=FM(T),D;return t[27]!==d||t[28]!==v||t[29]!==b||t[30]!==E||t[31]!==g||t[32]!==S||t[33]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[27]=d,t[28]=v,t[29]=b,t[30]=E,t[31]=g,t[32]=S,t[33]=w,t[34]=D):D=t[34],D}),Lq=YM(e=>{let t=J(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=Y(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>(s.current=e,()=>{s.current===e&&(s.current=null)}),t[0]=c):c=t[0];let l=FM(c),u;t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==r?(u=e=>{if(!r||!n)return;if(s.current?.(e)){o();return}let t=i.composer.getState().text,c=t.slice(0,r.offset),l=t.slice(r.endOffset),u=()=>{let t=n.formatter.serialize(e);i.composer.setText(c+t+(l.startsWith(` `)?l:` ${l}`)),a(c.length+t.length+1)};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?(i.composer.setText(c+(l.startsWith(` `)?l.slice(1):l)),a(c.length)):u(),n.onExecute(e)),o()},t[1]=i,t[2]=n,t[3]=o,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=FM(u),f;t[7]!==o||t[8]!==a||t[9]!==r?(f=()=>{o(),r&&a(r.offset)},t[7]=o,t[8]=a,t[9]=r,t[10]=f):f=t[10];let p=FM(f),m;return t[11]!==p||t[12]!==l||t[13]!==d?(m={selectItem:d,close:p,registerSelectItemOverride:l},t[11]=p,t[12]=l,t[13]=d,t[14]=m):m=t[14],m}),Rq=YM(e=>{let t=J(47),{adapter:n,text:r,triggerChar:i,matcher:a,behavior:o,aui:s,popoverId:c,isLoading:l}=e,u;t[0]!==a||t[1]!==r||t[2]!==i?(u=Mq({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=LN(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=Iq({adapter:n,query:d.query,open:f}),t[4]=n,t[5]=d.query,t[6]=f,t[7]=p):p=t[7];let m=LN(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=FM(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=Lq({behavior:o,trigger:d.trigger,aui:s,triggerChar:i,setCursorPosition:d.setCursorPosition,onSelected:g}),t[10]=s,t[11]=o,t[12]=d.setCursorPosition,t[13]=d.trigger,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v=LN(_),y;t[17]!==d.query||t[18]!==m.activeCategoryId||t[19]!==m.goBack||t[20]!==m.isSearchMode||t[21]!==m.navigableList||t[22]!==m.selectCategory||t[23]!==f||t[24]!==c||t[25]!==v.close||t[26]!==v.selectItem?(y=Pq({navigableList:m.navigableList,isSearchMode:m.isSearchMode,activeCategoryId:m.activeCategoryId,query:d.query,popoverId:c,open:f,selectItem:v.selectItem,selectCategory:m.selectCategory,goBack:m.goBack,close:v.close}),t[17]=d.query,t[18]=m.activeCategoryId,t[19]=m.goBack,t[20]=m.isSearchMode,t[21]=m.navigableList,t[22]=m.selectCategory,t[23]=f,t[24]=c,t[25]=v.close,t[26]=v.selectItem,t[27]=y):y=t[27];let b=LN(y),x;return t[28]!==d.query||t[29]!==d.setCursorPosition||t[30]!==l||t[31]!==b.handleKeyDown||t[32]!==b.highlightIndex||t[33]!==b.highlightedIndex||t[34]!==b.highlightedItemId||t[35]!==m.activeCategoryId||t[36]!==m.categories||t[37]!==m.goBack||t[38]!==m.isSearchMode||t[39]!==m.items||t[40]!==m.selectCategory||t[41]!==f||t[42]!==c||t[43]!==v.close||t[44]!==v.registerSelectItemOverride||t[45]!==v.selectItem?(x={open:f,query:d.query,activeCategoryId:m.activeCategoryId,categories:m.categories,items:m.items,highlightedIndex:b.highlightedIndex,isSearchMode:m.isSearchMode,isLoading:l,popoverId:c,highlightedItemId:b.highlightedItemId,selectCategory:m.selectCategory,goBack:m.goBack,selectItem:v.selectItem,close:v.close,highlightIndex:b.highlightIndex,handleKeyDown:b.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:v.registerSelectItemOverride},t[28]=d.query,t[29]=d.setCursorPosition,t[30]=l,t[31]=b.handleKeyDown,t[32]=b.highlightIndex,t[33]=b.highlightedIndex,t[34]=b.highlightedItemId,t[35]=m.activeCategoryId,t[36]=m.categories,t[37]=m.goBack,t[38]=m.isSearchMode,t[39]=m.items,t[40]=m.selectCategory,t[41]=f,t[42]=c,t[43]=v.close,t[44]=v.registerSelectItemOverride,t[45]=v.selectItem,t[46]=x):x=t[46],x}),zq=KM(null),Bq=()=>{let e=JM(zq);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},Vq=()=>JM(zq),Hq=KM(null),Uq=()=>{let e=JM(Hq);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},Wq=Z((e,t)=>{let n=J(69),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({char:a,matcher:s,adapter:r,isLoading:l,"aria-label":i,children:o,...c}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=l!==void 0&&l,d=Q(),f=$(Gq),p=zM(),m=Y(s),h;n[8]===s?h=n[9]:(h=()=>{m.current=s},n[8]=s,n[9]=h),X(h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>(e,t,n)=>m.current(e,t,n),n[10]=g):g=n[10];let[_]=AM(g),v=s!==void 0,y=Y(null),[b,x]=AM(null),S=Y(0),C;n[11]===a?C=n[12]:(C=e=>(S.current+=1,y.current=e,x(e),()=>{S.current=Math.max(0,S.current-1),y.current===e&&(y.current=null,x(null))}),n[11]=a,n[12]=C);let w=C,T;n[13]===w?T=n[14]:(T={register:w},n[13]=w,n[14]=T);let E=T,D=b??void 0,O;n[15]!==r||n[16]!==d||n[17]!==a||n[18]!==u||n[19]!==s||n[20]!==p||n[21]!==D||n[22]!==f?(O=Rq({adapter:r,text:f,triggerChar:a,matcher:s,behavior:D,aui:d,popoverId:p,isLoading:u}),n[15]=r,n[16]=d,n[17]=a,n[18]=u,n[19]=s,n[20]=p,n[21]=D,n[22]=f,n[23]=O):O=n[23];let k=LN(O),A;n[24]===k?A=n[25]:(A=()=>k,n[24]=k,n[25]=A);let j=FM(A),M=hq(),ee;n[26]!==b||n[27]!==a||n[28]!==j||n[29]!==v||n[30]!==_||n[31]!==M?(ee=()=>M.register({char:a,...v?{matcher:_}:{},...b?{behavior:b}:{},resource:j()}),n[26]=b,n[27]=a,n[28]=j,n[29]=v,n[30]=_,n[31]=M,n[32]=ee):ee=n[32];let te;n[33]!==b||n[34]!==a||n[35]!==v||n[36]!==M?(te=[M,a,v,b],n[33]=b,n[34]=a,n[35]=v,n[36]=M,n[37]=te):te=n[37],X(ee,te);let ne=lq(),re;n[38]!==j||n[39]!==ne?(re=()=>{if(ne)return ne.register(j())},n[38]=j,n[39]=ne,n[40]=re):re=n[40];let ie;n[41]===ne?ie=n[42]:(ie=[ne],n[41]=ne,n[42]=ie),X(re,ie);let ae=b!==null&&k.open,oe=_q(),se,ce;n[43]!==oe||n[44]!==a||n[45]!==ae?(se=()=>{if(ae)return()=>{oe.setActiveAria(a,null)}},ce=[oe,a,ae],n[43]=oe,n[44]=a,n[45]=ae,n[46]=se,n[47]=ce):(se=n[46],ce=n[47]),X(se,ce);let le,ue;n[48]!==oe||n[49]!==a||n[50]!==ae||n[51]!==p||n[52]!==k.highlightedItemId?(le=()=>{ae&&oe.setActiveAria(a,{popoverId:p,highlightedItemId:k.highlightedItemId})},ue=[oe,a,p,ae,k.highlightedItemId],n[48]=oe,n[49]=a,n[50]=ae,n[51]=p,n[52]=k.highlightedItemId,n[53]=le,n[54]=ue):(le=n[53],ue=n[54]),X(le,ue);let de;n[55]!==i||n[56]!==o||n[57]!==t||n[58]!==ae||n[59]!==p||n[60]!==c||n[61]!==k.highlightedItemId?(de=ae?(0,P.jsx)(iK.div,{role:`listbox`,id:p,"aria-label":i??`Suggestions`,"aria-activedescendant":k.highlightedItemId,"data-state":`open`,...c,ref:t,children:o}):o,n[55]=i,n[56]=o,n[57]=t,n[58]=ae,n[59]=p,n[60]=c,n[61]=k.highlightedItemId,n[62]=de):de=n[62];let fe;n[63]!==k||n[64]!==de?(fe=(0,P.jsx)(zq.Provider,{value:k,children:de}),n[63]=k,n[64]=de,n[65]=fe):fe=n[65];let pe;return n[66]!==E||n[67]!==fe?(pe=(0,P.jsx)(Hq.Provider,{value:E,children:fe}),n[66]=E,n[67]=fe,n[68]=pe):pe=n[68],pe});Wq.displayName=`ComposerPrimitive.TriggerPopover`;function Gq(e){return e.composer.text}var Kq=()=>{let e=J(2),{disabled:t,send:n}=qW(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},qq=gK(`ComposerPrimitive.Send`,Kq),Jq=KM(null),Yq=()=>JM(Jq),Xq=`[contenteditable]:not([contenteditable='false'])`,Zq=`textarea:not(:disabled), ${Xq}`,Qq=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,Xq,`[tabindex]`].join(`, `),$q=Z((e,t)=>{let n=J(24),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({onSubmit:a,onMouseDown:i,compact:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=Kq(),[c,l]=AM(!1),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={setMultiline:l},n[5]=u):u=n[5];let d=u,f;n[6]===r?f=n[7]:(f=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
93
+ `):!1,n[6]=r,n[7]=f);let p=$(f)&&!c,m;n[8]===s?m=n[9]:(m=e=>{e.preventDefault(),s&&s()},n[8]=s,n[9]=m);let h=m,g=eJ,_=r?d:null,v=p?``:void 0,y;n[10]!==h||n[11]!==a?(y=F(a,h),n[10]=h,n[11]=a,n[12]=y):y=n[12];let b;n[13]===i?b=n[14]:(b=F(i,g),n[13]=i,n[14]=b);let x;n[15]!==t||n[16]!==o||n[17]!==v||n[18]!==y||n[19]!==b?(x=(0,P.jsx)(iK.form,{...o,"data-compact":v,ref:t,onSubmit:y,onMouseDown:b}),n[15]=t,n[16]=o,n[17]=v,n[18]=y,n[19]=b,n[20]=x):x=n[20];let S;return n[21]!==_||n[22]!==x?(S=(0,P.jsx)(Jq.Provider,{value:_,children:x}),n[21]=_,n[22]=x,n[23]=S):S=n[23],S});$q.displayName=`ComposerPrimitive.Root`;function eJ(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(Qq);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(Zq);r&&(e.preventDefault(),r.focus())}var tJ=e=>{let t=J(4),n=fn(e),r=AG(nJ),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)};function nJ(e){return e.onScrollToBottom}var rJ=()=>!1,iJ=()=>{},aJ=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return iJ;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),IM(r,i,rJ)};function oJ(){return $(sJ)}function sJ(e){return e.composer.isEditing?e.composer.text:``}function cJ(e){return!!$(lJ)||!!e}function lJ(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function uJ(){let e=J(4),t=wq();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function dJ(){return dJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},dJ.apply(null,arguments)}function fJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var pJ=N.useLayoutEffect,mJ=function(e){var t=N.useRef(e);return pJ(function(){t.current=e}),t},hJ=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},gJ=function(e,t){var n=N.useRef();return N.useCallback(function(r){e.current=r,n.current&&hJ(n.current,null),n.current=t,t&&hJ(t,r)},[t])},_J={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},vJ=function(e){Object.keys(_J).forEach(function(t){e.style.setProperty(t,_J[t],`important`)})},yJ=null,bJ=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function xJ(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),yJ||(yJ=document.createElement(`textarea`),yJ.setAttribute(`tabindex`,`-1`),yJ.setAttribute(`aria-hidden`,`true`),vJ(yJ)),yJ.parentNode===null&&document.body.appendChild(yJ);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;yJ.style[t]=o[t]}),vJ(yJ),yJ.value=t;var c=bJ(yJ,e);yJ.value=t,c=bJ(yJ,e),yJ.value=`x`;var l=yJ.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var SJ=function(){},CJ=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},wJ=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],TJ=!!document.documentElement.currentStyle,EJ=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=CJ(wJ,t),r=n.boxSizing;return r===``?null:(TJ&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function DJ(e,t,n){var r=mJ(n);N.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var OJ=function(e,t){DJ(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},kJ=function(e){DJ(window,`resize`,e)},AJ=function(e){DJ(document.fonts,`loadingdone`,e)},jJ=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],MJ=N.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?SJ:a,s=e.onHeightChange,c=s===void 0?SJ:s,l=fJ(e,jJ),u=l.value!==void 0,d=N.useRef(null),f=gJ(d,t),p=N.useRef(0),m=N.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:EJ(e);if(t){m.current=t;var a=xJ(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return N.useLayoutEffect(h),OJ(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),kJ(h),AJ(h),N.createElement(`textarea`,dJ({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),NJ=`(pointer: coarse) and (not (any-pointer: fine))`,PJ=Z(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:l,submitMode:u,cancelOnEscape:f=!0,unstable_focusOnRunStart:p=!0,unstable_focusOnScrollToBottom:m=!0,unstable_focusOnThreadSwitched:h=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:_=!0,onHeightChange:v,...y},b)=>{let x=Q(),S=lq(),C=Yq(),w=u??(l===!1?`none`:`enter`),T=aJ(g?NJ:null),E=g&&T&&w===`enter`?`none`:w,D=oJ(),O=cJ(r),k=Y(null),A=d(b,k),j=Y(!1);YG(e=>{if(!k.current?.contains(e.target)||e.isComposing)return;if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}if(!f)return;let t=x.composer;t.getState().canCancel&&(t.cancel(),e.preventDefault())});let M=e=>{if(!O&&!e.nativeEvent.isComposing){if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=x.thread.getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&w!==`none`&&x.composer.getState().canSend){e.preventDefault(),x.composer.send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;E===`ctrlEnter`?r=e.ctrlKey||e.metaKey:E===`enter`&&(r=!0),r&&(e.preventDefault(),k.current?.closest(`form`)?.requestSubmit())}}},ee=async e=>{if(!_)return;let t=x.thread.getState().capabilities,n=Array.from(e.clipboardData?.files||[]);t.attachments&&n.length>0&&(e.preventDefault(),await Promise.all(n.map(async e=>{try{await x.composer.addAttachment(e)}catch{}})))},te=(e,t)=>{if(v?.(e,t),!C)return;let n=k.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&C.setMultiline(!0)},ne=e&&!O,re=NM(()=>{let e=k.current;e&&ne&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[ne]);X(()=>re(),[re]),tJ(()=>{x.composer.getState().type===`thread`&&m&&re()}),X(()=>{if(x.composer.getState().type===`thread`&&p)return x.on(`thread.runStart`,re)},[p,re,x]),X(()=>{if(x.composer.getState().type===`thread`&&h)return x.on(`threads.selectionChanged`,re)},[h,re,x]),X(()=>{D===``&&C?.setMultiline(!1)},[D,C]);let ie=uJ(),ae={name:`input`,value:D,...y,...ie,ref:A,disabled:O,onChange:F(i,e=>{if(!x.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;j.current&&!t&&(j.current=!1);let n=t||j.current;if(cN(()=>{x.composer.setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(r)}),onKeyDown:F(a,M),onCompositionStart:F(y.onCompositionStart,()=>{j.current=!0}),onCompositionEnd:F(y.onCompositionEnd,e=>{if(j.current=!1,!x.composer.getState().isEditing)return;let t=e.target;cN(()=>{x.composer.setText(t.value)});let n=t.selectionStart??t.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(n)}),onSelect:F(s,e=>{if(j.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(n)}),onPaste:F(o,ee),...C?{onHeightChange:te}:v===void 0?{}:{onHeightChange:v}};if(n&&GM(n))return tK(n,y.children,ae);let oe=t?c:MJ;return(0,P.jsx)(oe,{...ae})});PJ.displayName=`ComposerPrimitive.Input`;var FJ=gK(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=JW();return e?null:t}),IJ=gK(`ComposerPrimitive.AddAttachment`,e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=ZW(),s=Q(),c;return t[2]!==o||t[3]!==s.composer||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer.getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=async t=>{let n=t.target.files;if(!n)return;let r=Array.from(n,async e=>{try{await o(e)}catch{}});document.body.removeChild(e),await Promise.all(r)},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s.composer,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),LJ=Z(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,s]=AM(!1),l=Q(),u=NM(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}s(!0)}},[e,l]),d=NM(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}o||s(!0)}},[e,o,l]),f=NM(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||s(!1)},[e]),p=NM(async t=>{if(e||(s(!1),!t.dataTransfer.types.includes(`Files`)))return;t.preventDefault();let n=Array.from(t.dataTransfer.files);l.thread.getState().capabilities.attachments&&n.length!==0&&await Promise.all(n.map(async e=>{try{await l.composer.addAttachment(e)}catch{}}))},[e,l]),m={...o?{"data-dragging":`true`}:null,...i,onDragEnterCapture:F(i.onDragEnterCapture,u),onDragOverCapture:F(i.onDragOverCapture,d),onDragLeaveCapture:F(i.onDragLeaveCapture,f),onDropCapture:F(i.onDropCapture,p),ref:a};if(n&&GM(n))return tK(n,r,m);let h=t?c:`div`;return(0,P.jsx)(h,{...m,children:r})});LJ.displayName=`ComposerPrimitive.AttachmentDropzone`;var RJ=gK(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=YW();return e?null:t}),zJ=gK(`ComposerPrimitive.StopDictation`,()=>{let e=J(2),t=Q(),n=$(BJ),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function BJ(e){return e.composer.dictation!=null}var VJ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(HJ);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(iK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});VJ.displayName=`ComposerPrimitive.DictationTranscript`;function HJ(e){return e.composer.dictation?.transcript}var UJ=Z((e,t)=>{let n=J(3);if(!$(KJ))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(iK.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});UJ.displayName=`ComposerPrimitive.Quote`;var WJ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(qJ);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(iK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});WJ.displayName=`ComposerPrimitive.QuoteText`;var GJ=Z((e,t)=>{let n=J(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(),o;n[3]===a?o=n[4]:(o=()=>{a.composer.setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=F(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,P.jsx)(iK.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});GJ.displayName=`ComposerPrimitive.QuoteDismiss`;function KJ(e){return e.composer.quote}function qJ(e){return e.composer.quote?.text}var JJ=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=Bq();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,P.jsx)(iK.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});JJ.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var YJ=Z((e,t)=>{let n=J(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=Bq(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let b=y,x=`${p}-option-${r}`,S=v?``:void 0,C;n[16]!==h||n[17]!==i?(C=F(i,h),n[16]=h,n[17]=i,n[18]=C):C=n[18];let w;n[19]!==b||n[20]!==a?(w=F(a,b),n[19]=b,n[20]=a,n[21]=w):w=n[21];let T;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==x||n[26]!==S||n[27]!==C||n[28]!==w?(T=(0,P.jsx)(iK.button,{type:`button`,role:`option`,id:x,"aria-selected":v,"data-highlighted":S,...o,ref:t,onClick:C,onMouseMove:w}),n[22]=t,n[23]=v,n[24]=o,n[25]=x,n[26]=S,n[27]=C,n[28]=w,n[29]=T):T=n[29],T});YJ.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var XJ=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=Bq();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,P.jsx)(iK.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});XJ.displayName=`ComposerPrimitive.TriggerPopoverItems`;var ZJ=Z((e,t)=>{let n=J(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=Bq(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,b;n[13]!==l||n[14]!==v?(b=()=>{l(v)},n[13]=l,n[14]=v,n[15]=b):b=n[15];let x=b,S=`${m}-option-${i.id}`,C=y?``:void 0,w;n[16]!==g||n[17]!==a?(w=F(a,g),n[16]=g,n[17]=a,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==o?(T=F(o,x),n[19]=x,n[20]=o,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,P.jsx)(iK.button,{type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C,...s,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=y,n[24]=s,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});ZJ.displayName=`ComposerPrimitive.TriggerPopoverItem`;var QJ=Z((e,t)=>{let n=J(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=Bq();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=F(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,P.jsx)(iK.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});QJ.displayName=`ComposerPrimitive.TriggerPopoverBack`;var $J=e=>{let t=J(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=Uq(),o=Y(r),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{o.current=r},c=[r],t[0]=r,t[1]=s,t[2]=c),RM(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e={kind:`action`,formatter:n??KG,onExecute:e=>o.current(e),...i===void 0?{}:{removeOnExecute:i}};return a(e)},u=[a,n,i],t[3]=n,t[4]=a,t[5]=i,t[6]=l,t[7]=u):(l=t[6],u=t[7]),X(l,u),null};$J.displayName=`ComposerPrimitive.TriggerPopoverAction`;var eY=e=>{let t=J(7),{formatter:n,onInserted:r}=e,{register:i}=Uq(),a=Y(r),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{a.current=r},s=[r],t[0]=r,t[1]=o,t[2]=s),RM(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n??KG,onInserted:e=>a.current?.(e)}),l=[i,n],t[3]=n,t[4]=i,t[5]=c,t[6]=l):(c=t[5],l=t[6]),X(c,l),null};eY.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var tY=Object.assign(Wq,{Directive:eY,Action:$J}),nY=QG({AddAttachment:()=>IJ,AttachmentByIndex:()=>vW,AttachmentDropzone:()=>LJ,Attachments:()=>bW,Cancel:()=>FJ,Dictate:()=>RJ,DictationTranscript:()=>VJ,If:()=>IW,Input:()=>PJ,Queue:()=>SW,Quote:()=>UJ,QuoteDismiss:()=>GJ,QuoteText:()=>WJ,Root:()=>$q,Send:()=>qq,StopDictation:()=>zJ,Unstable_TriggerPopover:()=>tY,Unstable_TriggerPopoverBack:()=>QJ,Unstable_TriggerPopoverCategories:()=>JJ,Unstable_TriggerPopoverCategoryItem:()=>YJ,Unstable_TriggerPopoverItem:()=>ZJ,Unstable_TriggerPopoverItems:()=>XJ,Unstable_TriggerPopoverRoot:()=>Dq,unstable_useTriggerPopoverRootContext:()=>hq,unstable_useTriggerPopoverRootContextOptional:()=>gq,unstable_useTriggerPopoverScopeContext:()=>Bq,unstable_useTriggerPopoverScopeContextOptional:()=>Vq,unstable_useTriggerPopoverTriggers:()=>vq,unstable_useTriggerPopoverTriggersOptional:()=>Sq}),rY=Object.freeze({type:`complete`}),iY=Object.freeze({type:`text`,text:``,status:rY}),aY=()=>$(oY);function oY(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?iY:e.part}var sY=KM(null),cY=e=>({useSmoothStatus:LG(()=>e)}),lY=e=>{let t=J(6),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={optional:!0},t[0]=r):r=t[0];let i=dY(r),a=Q(),o;t[1]===a.part?o=t[2]:(o=()=>cY(a.part.getState().status),t[1]=a.part,t[2]=o);let[s]=AM(o);if(i)return n;let c;return t[3]!==n||t[4]!==s?(c=(0,P.jsx)(sY.Provider,{value:s,children:n}),t[3]=n,t[4]=s,t[5]=c):c=t[5],c},uY=e=>{let t=Z((t,n)=>{let r=J(3),i=t,a;return r[0]!==n||r[1]!==i?(a=(0,P.jsx)(lY,{children:(0,P.jsx)(e,{...i,ref:n})}),r[0]=n,r[1]=i,r[2]=a):a=r[2],a});return t.displayName=e.displayName,t};function dY(e){let t=JM(sY);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:fY,useSmoothStatusStore:pY}=OG(dY,`useSmoothStatus`),mY=250,hY=5,gY=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=mY;maxCharIntervalMs=hY;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},_Y=Object.freeze({type:`running`}),vY=(e,t)=>e!==void 0&&e>0?e:t,yY=(e,t=!1)=>{let{text:n}=e,r=aJ(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=vY(i?.drainMs,mY),s=vY(i?.maxCharIntervalMs,hY),c=vY(i?.maxCharsPerFrame,1/0),l=vY(i?.minCommitMs,0),[u,d]=AM(e.status.type===`running`?``:n),f=Q(),p=$(()=>f.part),[m,h]=AM(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=pY({optional:!0}),_=fn(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?_Y:e.status;BG(g).setState(n,!0)}});X(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?_Y:e.status;BG(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=AM(new gY(u,_));X(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=Y(p);return X(()=>{if(!a){v.stop();return}let t=y.current!==p;if(y.current=p,t||!n.startsWith(v.targetText)){e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=0,v.start()):(v.currentText=n,v.targetText=n,v.stop(),_(n));return}if(v.targetText=n,e.status.type!==`running`){if(v.currentText===``){v.currentText=n,v.stop(),_(n);return}v.start();return}v.start()},[v,a,n,e.status.type,p,_]),X(()=>()=>{v.stop()},[v]),MM(()=>a?{...e,text:u,status:n===u?e.status:_Y}:e,[a,u,e,n])},bY=Object.freeze({type:`complete`}),xY=Object.freeze({type:`image`,image:``,status:bY}),SY=()=>$(CY);function CY(e){return e.part.type===`image`?e.part:xY}var wY=Z(({smooth:e=!0,component:t=iK.span,render:n,...r},i)=>{let{text:a,status:o}=yY(aY(),e),s={"data-status":o.type,...r,ref:i};return n&&GM(n)?tK(n,a,s):(0,P.jsx)(t,{...s,children:a})});wY.displayName=`MessagePartPrimitive.Text`;var TY=Z((e,t)=>{let n=J(4),{image:r}=SY(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,P.jsx)(iK.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});TY.displayName=`MessagePartPrimitive.Image`;var EY=Z((e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(iK.div,{role:`alert`,...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});EY.displayName=`ErrorPrimitive.Root`;var DY=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=TG();if(a===void 0)return null;let o=r??String(a),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(iK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});DY.displayName=`ErrorPrimitive.Message`;var OY=QG({Message:()=>DY,Root:()=>EY}),kY=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},AY=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},jY=e=>e.dataset.messageId,MY=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},NY=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},PY=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},FY=()=>{let e=J(4),t=Q(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=$(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),kY(i)},IY=()=>{let e=J(2),t=AG(UY),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},LY=()=>{let e=J(2),t=AG(WY),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},RY=(e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],kY(r)},zY=e=>{let t=J(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:AY(i.tallerThan,e),visibleHeight:AY(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],kY(i)},BY=e=>{let t=J(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=FY(),a=d(n,i),o=$(GY),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,P.jsx)(iK.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},VY=e=>{let t=J(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=FY(),o=IY(),s=LY(),c=RY(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let u=zY(l),f=d(n,a,c,u),p=$(KY),m=o?``:void 0,h=s?``:void 0,g;return t[7]!==p||t[8]!==r||t[9]!==f||t[10]!==m||t[11]!==h?(g=(0,P.jsx)(iK.div,{...r,ref:f,"data-message-id":p,"data-aui-top-anchor-user":m,"data-aui-top-anchor-target":h}),t[7]=p,t[8]=r,t[9]=f,t[10]=m,t[11]=h,t[12]=g):g=t[12],g},HY=Z((e,t)=>{let n=J(7),r=jG();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,P.jsx)(VY,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,P.jsx)(BY,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});HY.displayName=`MessagePrimitive.Root`;function UY(e){return e.topAnchorTurn?.anchorId}function WY(e){return e.topAnchorTurn?.targetId}function GY(e){return e.message.id}function KY(e){return e.message.id}var qY={...xU,Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(wY,{}),(0,P.jsx)(EW,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,P.jsx)(TY,{})},JY=e=>{let t=J(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,P.jsx)(RU,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{...n,Text:n.Text??qY.Text,Image:n.Image??qY.Image}:qY,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,P.jsx)(RU,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};JY.displayName=`MessagePrimitive.Parts`;var YY=e=>{let t=J(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],$(n)},XY=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),YY(r)?n:null};XY.displayName=`MessagePrimitive.If`;var ZY=e=>{let{children:t}=e;return TG()===void 0?null:t};ZY.displayName=`MessagePrimitive.Error`;var QY=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??n,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=typeof e==`string`?e:void 0;n.push({groupKey:t,indices:r})}return n},$Y=e=>{let t=J(4),n=$(uX),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},eX=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},tX=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},nX={Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(wY,{}),(0,P.jsx)(EW,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,P.jsx)(TY,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},rX=e=>{let t=J(37),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?nX.Text:i,p=a===void 0?nX.Reasoning:a,m=o===void 0?nX.Image:o,h=s===void 0?nX.Source:s,g=c===void 0?nX.File:c,_=l===void 0?nX.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,b=Q(),x=$(dX),S=x.type;if(S===`tool-call`){let e=b.part.addToolResult,n=b.part.resumeToolCall,r=b.part.respondToToolApproval;if(`Override`in y){let i;return t[4]!==e||t[5]!==x||t[6]!==r||t[7]!==n||t[8]!==y.Override?(i=(0,P.jsx)(y.Override,{...x,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=x,t[6]=r,t[7]=n,t[8]=y.Override,t[9]=i):i=t[9],i}let i=y.by_name?.[x.toolName]??y.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==x||t[13]!==r||t[14]!==n?(a=(0,P.jsx)(eX,{...x,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=x,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(x.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(S){case`text`:{let e;return t[16]!==f||t[17]!==x?(e=(0,P.jsx)(f,{...x}),t[16]=f,t[17]=x,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==p||t[20]!==x?(e=(0,P.jsx)(p,{...x}),t[19]=p,t[20]=x,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==h||t[23]!==x?(e=(0,P.jsx)(h,{...x}),t[22]=h,t[23]=x,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==m||t[26]!==x?(e=(0,P.jsx)(m,{...x}),t[25]=m,t[26]=x,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==g||t[29]!==x?(e=(0,P.jsx)(g,{...x}),t[28]=g,t[29]=x,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==_||t[32]!==x?(e=(0,P.jsx)(_,{...x}),t[31]=_,t[32]=x,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[x.name]??d?.Fallback,n;return t[34]!==e||t[35]!==x?(n=(0,P.jsx)(tX,{...x,Fallback:e}),t[34]=e,t[35]=x,t[36]=n):n=t[36],n}default:return console.warn(`Unknown message part type: ${S}`),null}},iX=VM(e=>{let t=J(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(rX,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(hB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),aX=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,P.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,P.jsx)(_B,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},oX=Object.freeze({type:`complete`}),sX=VM(e=>{let t=J(6),{components:n}=e,r=$(fX);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,P.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??nX.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(aX,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),cX=e=>{let t=J(9),{groupingFunction:n,components:r}=e,i=$(pX),a=$Y(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,P.jsx)(sX,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>{let n=r?.Group??nX.Group;return(0,P.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,P.jsx)(iX,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`)},t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,P.jsx)(P.Fragment,{children:s}),t[7]=s,t[8]=c),c};cX.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var lX=e=>{let t=J(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,P.jsx)(cX,{...r,components:n,groupingFunction:QY}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};lX.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function uX(e){return e.message.parts}function dX(e){return e.part}function fX(e){return e.message.status??oX}function pX(e){return e.message.parts.length}var mX=QG({AttachmentByIndex:()=>fW,Attachments:()=>mW,Content:()=>JY,Error:()=>ZY,GenerativeUI:()=>pU,GroupedParts:()=>cW,If:()=>XY,PartByIndex:()=>CU,Parts:()=>JY,Quote:()=>lW,Root:()=>HY,Unstable_PartsGrouped:()=>cX,Unstable_PartsGroupedByParentId:()=>lX}),hX=e=>{let t=J(2),n=fn(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(gX)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),kY(r)};function gX(e){return e.type!==`attributes`||e.attributeName!==`style`}var _X=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=Y(null),a=$(e=>e.thread.messages.length>0),o=$(e=>e.thread.isRunning),s=Y(!1),c=Y(null),l=jG();e===void 0&&(e=l.getState().turnAnchor!==`top`);let u=Y(0),f=Y(0),p=Y(0),m=Y(0),h=Y(null),g=Y(e),_=Y(e);PM(()=>{let t=_.current;if(_.current=e,t||!e)return;let n=i.current;g.current=n!==null&&FF(n)},[e]);let v=NM(e=>{let t=i.current;t&&(g.current=!0,h.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),y=NM(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),b=NM(e=>{h.current=e,y(),c.current=requestAnimationFrame(()=>{c.current=null,v(e)})},[y,v]);PM(()=>()=>y(),[y]);let x=NM(()=>{let e=l.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[l]),S=()=>{let t=i.current;if(!t)return;let n=l.getState().isAtBottom,r=FF(t);if(!(!r&&u.current<t.scrollTop)){let i=LF({scrollTop:u.current,scrollHeight:f.current},t);r?(IF(t)&&(h.current=null),e&&(g.current=!0)):i&&(y(),h.current=null,g.current=!1),(r||h.current===null)&&r!==n&&BG(l).setState({isAtBottom:r})}u.current=t.scrollTop,f.current=t.scrollHeight},C=hX(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===p.current&&r===m.current)return;p.current=n,m.current=r;let a=h.current;a&&x()?h.current=null:a?v(a):e&&!(o&&x())&&g.current&&v(`instant`),S()}),w=kY(e=>{let t=()=>{h.current=null};return e.addEventListener(`scroll`,S),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,S),e.removeEventListener(`pointerdown`,t)}});return PM(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,h.current===null&&b(`instant`))}},[a,b,n]),tJ(({behavior:e})=>{v(e)}),cL(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&b(`auto`)}),cL(`threads.selectionChanged`,()=>{r&&b(`instant`)}),d(C,w,i)},vX=Z((e,t)=>{let n=J(6),r=Q(),i,a;n[0]===r?(i=n[1],a=n[2]):(i=()=>{let e=e=>{if(e.key===`Escape`&&!(e.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},a=[r],n[0]=r,n[1]=i,n[2]=a),X(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,P.jsx)(iK.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});vX.displayName=`ThreadPrimitive.Root`;var yX=e=>{let{children:t}=e;return $(bX)?t:null};yX.displayName=`ThreadPrimitive.Empty`;function bX(e){return e.thread.isEmpty}var xX=e=>{let t=J(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],$(n)},SX=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),xX(r)?n:null};SX.displayName=`ThreadPrimitive.If`;var CX=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],kY(r)},wX=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},TX=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:wX(e)-wX(t)},EX=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=TX(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},DX=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=EX(t)+n.clientHeight;return Math.max(0,r-e)},OX=({viewport:e,reserve:t,...n})=>DX({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),kX=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},AX=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},jX=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o){a.disconnect(),t&&(NY(t,0),t.remove());return}if(!s&&!c&&!l&&r.topAnchorTurn){a.disconnect(),t?.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!s||!c||!l){a.disconnect(),t&&(NY(t,0),t.remove());return}if(t??=MY(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),NY(t,OX({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=jY(s);if(u!==void 0&&n===u)return;let d=PY(EX({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=AX(r),a=kX(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},MX=e=>{let t=J(4),n=jG(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return jX(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),PM(r,i)},NX=(e,t)=>{if(!e)return!1;let n=t.findIndex(t=>t.id===e.targetId);return n<1?!1:t[n-1]?.id===e.anchorId&&t.slice(n+1).every(e=>e.role===`user`)},PX=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},FX=e=>PX(e)?.anchorId,IX=e=>PX(e)?.targetId,LX=()=>CX(AG(HX),UX),RX=()=>kY(AG(WX)),zX=e=>{let t=J(19),n=jG(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return FX(t.thread)},t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return IX(t.thread)},t[2]=e,t[3]=a);let o=$(a),s=AG(GX),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&NX(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=$(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{s&&!d&&n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),PM(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;(t?.anchorId!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),PM(m,h)},BX=Z((e,t)=>{let n=J(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let u=_X(l),f=LX(),p=RX(),m=jG(),h;n[12]===m?h=n[13]:(h=m.getState(),n[12]=m,n[13]=h);let g=h.turnAnchor===`top`;zX(g),MX(g);let _=d(t,u,f,p),v;return n[14]!==i||n[15]!==_||n[16]!==a?(v=(0,P.jsx)(iK.div,{...a,ref:_,children:i}),n[14]=i,n[15]=_,n[16]=a,n[17]=v):v=n[17],v});BX.displayName=`ThreadPrimitive.ViewportScrollable`;var VX=Z((e,t)=>{let n=J(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,P.jsx)(BX,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,P.jsx)(HG,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});VX.displayName=`ThreadPrimitive.Viewport`;function HX(e){return e.registerViewport}function UX(e){return e.clientHeight}function WX(e){return e.registerViewportElement}function GX(e){return e.topAnchorTurn}var KX=Z((e,t)=>{let n=J(3),r=CX(AG(qX),JX),i=d(t,r),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(iK.div,{...e,ref:i}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});KX.displayName=`ThreadPrimitive.ViewportFooter`;function qX(e){return e.registerContentInset}function JX(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var YX=gK(`ThreadPrimitive.ScrollToBottom`,e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=AG(XX),a=jG(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function XX(e){return e.isAtBottom}var ZX=gK(`ThreadPrimitive.Suggestion`,e=>{let t=J(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=_G(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),QX=QG({Empty:()=>yX,If:()=>SX,MessageByIndex:()=>eU,Messages:()=>iU,Root:()=>vX,ScrollToBottom:()=>YX,Suggestion:()=>ZX,SuggestionByIndex:()=>jW,Suggestions:()=>PW,Unstable_MessageById:()=>tU,Viewport:()=>VX,ViewportFooter:()=>KX,ViewportProvider:()=>HG}),$X=Z((e,t)=>{let n=J(4),r=$(eZ),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(iK.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});$X.displayName=`SuggestionPrimitive.Title`;function eZ(e){return e.suggestion.title}var tZ=Z((e,t)=>{let n=J(4),r=$(nZ),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(iK.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});tZ.displayName=`SuggestionPrimitive.Description`;function nZ(e){return e.suggestion.label}var rZ=gK(`SuggestionPrimitive.Trigger`,e=>{let t=J(4),{send:n,clearComposer:r}=e,i=$(iZ),a;t[0]!==r||t[1]!==i||t[2]!==n?(a={prompt:i,send:n,clearComposer:r},t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3];let{trigger:o,disabled:s}=_G(a);return s?null:o},[`send`,`clearComposer`]);function iZ(e){return e.suggestion.prompt}var aZ=QG({Description:()=>tZ,Title:()=>$X,Trigger:()=>rZ}),oZ=Z((e,t)=>{let n=J(15),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(sZ),{switchToNewThread:s}=CG(),c;n[4]===o?c=n[5]:(c=o?{"data-active":`true`,"aria-current":`true`}:null,n[4]=o,n[5]=c);let l;n[6]!==i||n[7]!==s?(l=F(i,s),n[6]=i,n[7]=s,n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==t||n[11]!==a||n[12]!==c||n[13]!==l?(u=(0,P.jsx)(iK.button,{type:`button`,...c,...a,ref:t,disabled:r,onClick:l}),n[9]=r,n[10]=t,n[11]=a,n[12]=c,n[13]=l,n[14]=u):u=n[14],u});oZ.displayName=`ThreadListPrimitive.New`;function sZ(e){return e.threads.newThreadId===e.threads.mainThreadId}var cZ=gK(`ThreadListPrimitive.LoadMore`,()=>{let{loadMore:e,disabled:t}=wG();return t?null:e}),[lZ,uZ]=Qe(`ThreadList`),dZ=lZ,fZ=KM(null),pZ=fZ.Provider,mZ=()=>JM(fZ),hZ=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(dZ.Provider,{scope:void 0,children:(0,P.jsx)(dZ.Slot,{scope:void 0,children:(0,P.jsx)(iK.div,{...e,ref:t})})}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});hZ.displayName=`ThreadListPrimitive.Root`;var gZ=QG({ItemByIndex:()=>CW,Items:()=>TW,LoadMore:()=>cZ,New:()=>oZ,Root:()=>hZ}),_Z=Z((e,t)=>{let n=$(e=>e.threads.mainThreadId===e.threadListItem.id),r=Y(null),i=Y(null),a=MM(()=>({triggerRef:r,moreRef:i}),[]),o=uZ(void 0),s=ln(),c=e=>{let t=s===`rtl`?`ArrowLeft`:`ArrowRight`,n=s===`rtl`?`ArrowRight`:`ArrowLeft`,a=r.current,c=i.current;if(a&&e.target===a){if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=o().map(e=>e.ref.current).filter(e=>e!==null),n=t[t.indexOf(a)+(e.key===`ArrowDown`?1:-1)];n&&(n.focus(),e.preventDefault())}else e.key===t&&c&&(c.focus(),e.preventDefault())}else c&&e.target===c&&e.key===n&&(a?.focus(),e.preventDefault())};return(0,P.jsx)(pZ,{value:a,children:(0,P.jsx)(iK.div,{...n?{"data-active":`true`,"aria-current":`true`}:null,...e,onKeyDown:F(e.onKeyDown,c),ref:t})})});_Z.displayName=`ThreadListItemPrimitive.Root`;var vZ=gK(`ThreadListItemPrimitive.Archive`,()=>{let{archive:e}=yG();return e}),yZ=gK(`ThreadListItemPrimitive.Unarchive`,()=>{let{unarchive:e}=xG();return e}),bZ=gK(`ThreadListItemPrimitive.Delete`,()=>{let{delete:e}=bG();return e}),xZ=gK(`ThreadListItemPrimitive.Trigger`,()=>{let{switchTo:e}=SG();return e}),SZ=Z((e,t)=>{let n=J(3),r=mZ(),i=d(t,r?.triggerRef),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(dZ.ItemSlot,{scope:void 0,children:(0,P.jsx)(xZ,{...e,ref:i})}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});SZ.displayName=`ThreadListItemPrimitive.Trigger`;var CZ=QG({Archive:()=>vZ,Delete:()=>bZ,Root:()=>_Z,Title:()=>OW,Trigger:()=>SZ,Unarchive:()=>yZ}),wZ=cu(),TZ=KM(()=>{}),EZ=()=>JM(TZ),DZ=KM(!1),OZ=()=>JM(DZ),kZ=e=>{let t=J(26),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({__scopeThreadListItemMore:n,open:o,defaultOpen:r,onOpenChange:a,sharedFocusGroup:c,modal:i,...s}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c!==void 0&&c,u=l?!1:i??!0,d=wZ(n),f=r??!1,p;t[8]===a?p=t[9]:(p=a?{onChange:a}:{},t[8]=a,t[9]=p);let m;t[10]!==o||t[11]!==f||t[12]!==p?(m={prop:o,defaultProp:f,caller:`ThreadListItemMorePrimitive.Root`,...p},t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13];let[h,g]=Tt(m),_;t[14]!==u||t[15]!==h||t[16]!==s||t[17]!==d||t[18]!==g?(_=(0,P.jsx)(Au,{...d,...s,modal:u,open:h,onOpenChange:g}),t[14]=u,t[15]=h,t[16]=s,t[17]=d,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==g||t[21]!==_?(v=(0,P.jsx)(TZ.Provider,{value:g,children:_}),t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;return t[23]!==l||t[24]!==v?(y=(0,P.jsx)(DZ.Provider,{value:l,children:v}),t[23]=l,t[24]=v,t[25]=y):y=t[25],y};kZ.displayName=`ThreadListItemMorePrimitive.Root`;var AZ=Z((e,t)=>{let n=J(10),{__scopeThreadListItemMore:r,...i}=e,a=wZ(r),o=mZ(),s=EZ(),c=OZ(),l=d(t,o?.moreRef),u=ln()===`rtl`?`ArrowLeft`:`ArrowRight`,f=IK,p;n[0]!==u||n[1]!==s||n[2]!==c?(p=e=>{c&&e.key===u&&(e.preventDefault(),s(!0))},n[0]=u,n[1]=s,n[2]=c,n[3]=p):p=n[3];let m=F(i.onKeyDown,p),h;return n[4]!==f||n[5]!==l||n[6]!==i||n[7]!==a||n[8]!==m?(h=(0,P.jsx)(f,{...a,...i,onKeyDown:m,ref:l}),n[4]=f,n[5]=l,n[6]=i,n[7]=a,n[8]=m,n[9]=h):h=n[9],h});AZ.displayName=`ThreadListItemMorePrimitive.Trigger`;var jZ=Z((e,t)=>{let n=J(21),{__scopeThreadListItemMore:r,portalProps:i,sideOffset:a,...o}=e,s=a===void 0?4:a,c=wZ(r),l=EZ(),u=mZ(),d=OZ(),f=ln()===`rtl`?`ArrowRight`:`ArrowLeft`,p=ru,m=LK,h;n[0]!==f||n[1]!==u?.moreRef||n[2]!==l||n[3]!==d?(h=e=>{d&&e.key===f&&(e.preventDefault(),l(!1),u?.moreRef.current?.focus())},n[0]=f,n[1]=u?.moreRef,n[2]=l,n[3]=d,n[4]=h):h=n[4];let g=F(o.onKeyDown,h),_;n[5]!==u?.moreRef||n[6]!==d?(_=()=>{d&&u?.moreRef.current?.focus()},n[5]=u?.moreRef,n[6]=d,n[7]=_):_=n[7];let v=F(o.onEscapeKeyDown,_),y;n[8]!==m||n[9]!==t||n[10]!==o||n[11]!==c||n[12]!==s||n[13]!==g||n[14]!==v?(y=(0,P.jsx)(m,{...c,...o,onKeyDown:g,onEscapeKeyDown:v,ref:t,sideOffset:s}),n[8]=m,n[9]=t,n[10]=o,n[11]=c,n[12]=s,n[13]=g,n[14]=v,n[15]=y):y=n[15];let b;return n[16]!==i||n[17]!==c||n[18]!==p.Portal||n[19]!==y?(b=(0,P.jsx)(p.Portal,{...c,...i,children:y}),n[16]=i,n[17]=c,n[18]=p.Portal,n[19]=y,n[20]=b):b=n[20],b});jZ.displayName=`ThreadListItemMorePrimitive.Content`;var MZ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=wZ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(RK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});MZ.displayName=`ThreadListItemMorePrimitive.Item`;var NZ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=wZ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(zK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});NZ.displayName=`ThreadListItemMorePrimitive.Separator`;var PZ=QG({Content:()=>jZ,Item:()=>MZ,Root:()=>kZ,Separator:()=>NZ,Trigger:()=>AZ}),FZ=(e,t)=>{let n=J(5),r=Y(null),i=Y(null),a,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>()=>{i.current?.()},o=[],n[0]=a,n[1]=o):(a=n[0],o=n[1]),X(a,o);let s;return n[2]!==e||n[3]!==t?(s=()=>{i.current?.(),(function(){if(r.current||!e.current)return;let t=e.current;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`scroll`||e===`auto`){r.current=t;break}t=t.parentElement}})();let n=r.current;if(!n)return;let a=n.scrollTop,o=n.style.scrollbarWidth,s=getComputedStyle(n),c=s.direction===`rtl`?`paddingLeft`:`paddingRight`,l=n.style[c],u=n.offsetWidth-n.clientWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.borderRightWidth),d=n.ownerDocument,f=(n===d.documentElement||n===d.body)&&u<=0?(d.defaultView?.innerWidth??0)-d.documentElement.clientWidth:u;n.style.scrollbarWidth=`none`,f>0&&(n.style[c]=`${parseFloat(s[c])+f}px`);let p=()=>{n.style.scrollbarWidth=o,n.style[c]=l},m=()=>n.scrollTop=a;n.addEventListener(`scroll`,m);let h=setTimeout(()=>{n.removeEventListener(`scroll`,m),p(),i.current=null},t);i.current=()=>{clearTimeout(h),n.removeEventListener(`scroll`,m),p()}},n[2]=e,n[3]=t,n[4]=s):s=n[4],s},IZ=()=>{let e=J(3),t=$(LZ),n=$(RZ),r=t!==void 0&&t.completedAt===void 0&&n,[i,a]=AM(zZ),o,s;if(e[0]===r?(o=e[1],s=e[2]):(o=()=>{if(!r)return;a(Date.now());let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},s=[r],e[0]=r,e[1]=o,e[2]=s),X(o,s),t!==void 0){if(t.completedAt!==void 0)return Math.max(0,t.completedAt-t.startedAt);if(r)return Math.max(0,i-t.startedAt)}};function LZ(e){let t=e.optional.part;return t?.type===`tool-call`?t.timing:void 0}function RZ(e){let t=e.optional.part;return t?.type===`tool-call`&&t.status.type===`running`}function zZ(){return Date.now()}var BZ=QG({AssistantRuntimeImpl:()=>pV,BaseAssistantRuntimeCore:()=>vV,CompositeContextProvider:()=>YF,DefaultThreadComposerRuntimeCore:()=>VV,MessageRepository:()=>kV,ThreadRuntimeImpl:()=>rV,getAutoStatus:()=>Gz,splitLocalRuntimeOptions:()=>EG,useComposerInputPluginRegistryOptional:()=>lq,useSmooth:()=>yY,useSmoothStatus:()=>fY,withSmoothContextProvider:()=>uY}),VZ=(e,t)=>`${e}:${t}`,HZ=e=>({id:e,status:`idle`}),UZ=e=>({threadId:e,metadata:HZ(e),messages:[],streamingMessageIndex:void 0,toolExecutions:{},runStatus:`idle`,queue:{steering:[],followUp:[]},contextUsage:void 0,compaction:{active:!1},retry:{active:!1,attempt:0},hostUiRequests:[],readiness:void 0,lastError:void 0,loadState:`pending`,lastSeq:0}),WZ=e=>e?.role===`assistant`,GZ=(e,t)=>e.status===t?e:{...e,status:t},KZ=(e,t,n)=>e.compactionActive===t.active&&e.retryActive===n.active&&e.retryAttempt===n.attempt?e:{...e,compactionActive:t.active,retryActive:n.active,retryAttempt:n.attempt},qZ=(e,t)=>{let n=t.metadata.status===`running`?`running`:t.metadata.status===`failed`?`failed`:`idle`,r=n!==`running`,i=t.seq!==void 0&&t.seq<e.lastSeq,a=t.metadata.compactionActive??(!r&&e.compaction.active),o=t.metadata.retryActive??(!r&&e.retry.active),s=i?e.compaction:a?{...e.compaction,active:!0}:{active:!1},c=i?e.retry:o?{active:!0,attempt:t.metadata.retryAttempt??e.retry.attempt}:{active:!1,attempt:0};return{...e,metadata:KZ(t.metadata,s,c),messages:t.messages,streamingMessageIndex:void 0,toolExecutions:{},runStatus:n,compaction:s,retry:c,queue:{steering:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`steer`).map(e=>e.content),followUp:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`followUp`).map(e=>e.content)},contextUsage:t.metadata.contextUsage??e.contextUsage,hostUiRequests:t.hostUiRequests??[],readiness:t.readiness??e.readiness,lastError:t.lastError,loadState:`loaded`}},JZ=(e,t,n)=>{let r=e.slice();return r[t]=n,r},YZ=(e,t,n)=>({...e,toolExecutions:{...e.toolExecutions,[t]:{toolCallId:t,status:`running`,...e.toolExecutions[t],...n}}}),XZ=(e,t)=>e.hostUiRequests.some(e=>e.id===t)?{...e,hostUiRequests:e.hostUiRequests.filter(e=>e.id!==t)}:e,ZZ=(e,t)=>{if(t.type!==`snapshot`&&t.type!==`error`&&t.seq<=e.lastSeq)return e;let n=n=>n===e&&t.seq<=e.lastSeq?n:{...n,lastSeq:Math.max(e.lastSeq,t.seq)};switch(t.type){case`snapshot`:return n(qZ(e,t.snapshot));case`agent_start`:return n({...e,runStatus:`running`,lastError:void 0,metadata:GZ(e.metadata,`running`)});case`agent_end`:{let r=t.willRetry===!0;return n({...e,runStatus:r?`running`:`idle`,streamingMessageIndex:void 0,metadata:GZ(e.metadata,r?`running`:`idle`)})}case`message_start`:{let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:WZ(t.message)?r.length-1:e.streamingMessageIndex})}case`message_update`:{if(e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length)return n({...e,messages:JZ(e.messages,e.streamingMessageIndex,t.message)});let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:r.length-1})}case`message_end`:return e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length?n({...e,messages:JZ(e.messages,e.streamingMessageIndex,t.message),streamingMessageIndex:void 0}):n({...e,streamingMessageIndex:void 0});case`tool_execution_start`:return n(YZ(e,t.toolCallId,{toolName:t.toolName,args:t.args,status:`running`}));case`tool_execution_update`:return n(YZ(e,t.toolCallId,{...t.toolName===void 0?{}:{toolName:t.toolName},partialResult:t.partialResult,status:`running`}));case`tool_execution_end`:return n(YZ(e,t.toolCallId,{partialResult:t.result,status:t.isError?`error`:`complete`}));case`queue_update`:return n({...e,queue:{steering:t.steering,followUp:t.followUp}});case`compaction_start`:{let r={active:!0,reason:t.reason};return n({...e,compaction:r,metadata:KZ(e.metadata,r,e.retry)})}case`compaction_end`:{let t={active:!1};return n({...e,compaction:t,metadata:KZ(e.metadata,t,e.retry)})}case`auto_retry_start`:{let r={active:!0,attempt:t.attempt};return n({...e,retry:r,metadata:KZ(e.metadata,e.compaction,r)})}case`auto_retry_end`:{let t={active:!1,attempt:0};return n({...e,retry:t,metadata:KZ(e.metadata,e.compaction,t)})}case`context_usage`:return n({...e,contextUsage:t.contextUsage});case`session_info_changed`:{let r={...e.metadata};return t.name===void 0?delete r.title:r.title=t.name,n({...e,metadata:r})}case`thinking_level_changed`:return n({...e,metadata:{...e.metadata,config:{...e.metadata.config,thinkingLevel:t.level}}});case`extension_ui_request`:return e.hostUiRequests.some(e=>e.id===t.request.id)?n(e):n({...e,hostUiRequests:[...e.hostUiRequests,t.request]});case`extension_ui_resolved`:return n(XZ(e,t.requestId));case`error`:return n({...e,lastError:t.error,runStatus:`failed`,metadata:GZ(e.metadata,`failed`)});case`agent_settled`:case`entry_appended`:return n(e);default:return n(e)}},QZ=e=>{let t=new Map,n=[];for(let r of e)r.toolCallId!==void 0&&eQ(r)?t.has(r.toolCallId)?n.push(r):t.set(r.toolCallId,r):n.push(r);return{toolAssociated:t,freeStanding:n}},$Z=(e,t)=>({requestId:e,confirmed:t}),eQ=e=>{switch(e.kind){case`confirm`:return{id:e.id,prompt:`${e.title}\n${e.message}`};case`select`:return e.options.length===0?void 0:{id:e.id,prompt:e.title,display:`select`,options:e.options.map((e,t)=>({id:String(t),kind:`_${t}`,label:e}))};case`input`:case`editor`:return{id:e.id,prompt:e.title,display:`text`}}},tQ=(e,t)=>{if(e.kind===`confirm`)return $Z(e.id,t.approved);if(!t.approved)return{requestId:e.id,dismissed:!0};let n=e.kind===`select`?e.options.find((e,n)=>String(n)===t.optionId):t.text;if(n===void 0)throw Error(`Pi ${e.kind} request "${e.id}" was not answered with ${e.kind===`select`?`one of its options`:`text`}`);return{requestId:e.id,value:n}},nQ=e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(e.dismissed)return;if(typeof e.value==`string`)return e.value}},rQ=(e,t)=>{let n=nQ(t);return n===void 0?{requestId:e,dismissed:!0}:{requestId:e,value:n}};function iQ(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}function aQ(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var oQ=e=>`pi-msg:${e}`,sQ=e=>`pi-step:${e}`,cQ=(e,t)=>/^data:/i.test(e)?e:`data:${t};base64,${e}`,lQ=e=>new Date(typeof e.timestamp==`number`?e.timestamp:0),uQ=e=>{if(!e)return{};let t=e.filter(e=>e.type===`text`).map(e=>e.text).join(``);return e.every(e=>e.type===`text`)?{result:t}:{result:t,modelContent:e.flatMap(e=>{if(e.type===`text`)return[{type:`text`,text:e.text}];let t=iQ(e.data);return[{type:`file`,data:t?.data??e.data,mediaType:t?.mimeType??e.mimeType}]})}},dQ=e=>{if(e==null)return;let t=e.content;if(Array.isArray(t))return t.filter(e=>typeof e==`object`&&!!e&&(e.type===`text`&&typeof e.text==`string`||e.type===`image`&&typeof e.data==`string`&&typeof e.mimeType==`string`))},fQ=e=>typeof e==`string`?[{type:`text`,text:e}]:e.map(e=>e.type===`image`?{type:`image`,image:cQ(e.data,e.mimeType)}:{type:`text`,text:e.text}),pQ=(e,t)=>({type:`data`,name:e,data:t}),mQ=e=>{let t=new Map;for(let n of e){if(n.role!==`toolResult`)continue;let e=n;t.set(e.toolCallId,{...uQ(dQ({content:e.content})),isError:e.isError,details:e.details})}return t},hQ=(e,t,n,r,i,a)=>{let o=sQ(n);e.lastAssistant=t,e.steps.push({messageId:o,usage:{inputTokens:t.usage?.input??0,outputTokens:t.usage?.output??0}});for(let n of t.content)if(n.type===`text`)e.parts.push({type:`text`,text:n.text,parentId:o});else if(n.type===`thinking`){let t=n.thinking||(n.redacted?`[reasoning redacted]`:``);e.parts.push({type:`reasoning`,text:t,parentId:o})}else if(n.type===`toolCall`){let t=i.get(n.id),s=r.toolExecutions[n.id],c=t??uQ(dQ(s?.partialResult)),l=t?.isError??s?.status===`error`,u=a.get(n.id),d=u&&eQ(u),f={type:`tool-call`,toolCallId:n.id,toolName:n.name,args:n.arguments??{},argsText:JSON.stringify(n.arguments??{}),parentId:o,...c.result===void 0?{}:{result:c.result},...c.modelContent===void 0?{}:{modelContent:c.modelContent},...l?{isError:!0}:{},...d?{approval:d}:{}};d&&(e.hasPendingHostUi=!0),e.parts.push(f)}},gQ=(e,t,n)=>{let r=e.lastAssistant,i=_Q(e,t,n);return{id:oQ(e.firstIndex),role:`assistant`,createdAt:lQ(r),content:e.parts,...i?{status:i}:{},metadata:{steps:e.steps,custom:{pi:{provider:r.provider,model:r.model,api:r.api,usage:r.usage,stopReason:r.stopReason,...r.errorMessage?{errorMessage:r.errorMessage}:{}}}}}},_Q=(e,t,n)=>{if(e.hasPendingHostUi)return{type:`requires-action`,reason:`interrupt`};let r=e.lastAssistant;return t.runStatus===`running`&&n&&r.stopReason!==`error`&&r.stopReason!==`aborted`?{type:`running`}:r.stopReason===`error`?{type:`incomplete`,reason:`error`,...r.errorMessage?{error:r.errorMessage}:{}}:r.stopReason===`aborted`?{type:`incomplete`,reason:`cancelled`}:r.stopReason===`length`?{type:`incomplete`,reason:`length`}:{type:`complete`,reason:`stop`}},vQ=e=>{let{messages:t}=e,n=mQ(t),r=QZ(e.hostUiRequests).toolAssociated,i=[],a=null,o=t=>{a&&=(i.push(gQ(a,e,t)),null)};return t.forEach((s,c)=>{let l=c===t.length-1;switch(s.role){case`assistant`:a||={firstIndex:c,parts:[],steps:[],lastAssistant:s,hasPendingHostUi:!1},hQ(a,s,c,e,n,r),l&&o(!0);break;case`toolResult`:break;case`user`:o(!1),i.push({id:oQ(c),role:`user`,createdAt:lQ(s),content:fQ(s.content)});break;case`bashExecution`:{o(!1);let e=s;i.push(yQ(c,e,`pi-bash-execution`,{command:e.command,output:e.output,exitCode:e.exitCode,cancelled:e.cancelled,truncated:e.truncated,fullOutputPath:e.fullOutputPath}));break}case`custom`:{o(!1);let e=s;if(!e.display)break;i.push({id:oQ(c),role:`assistant`,createdAt:lQ(e),content:[pQ(`pi-custom-message`,{customType:e.customType,details:e.details}),...fQ(e.content)]});break}case`branchSummary`:{o(!1);let e=s;i.push(yQ(c,e,`pi-branch-summary`,{summary:e.summary,fromId:e.fromId}));break}case`compactionSummary`:{o(!1);let e=s;i.push(yQ(c,e,`pi-compaction-summary`,{summary:e.summary,tokensBefore:e.tokensBefore}));break}default:o(!1),i.push(yQ(c,s,`pi-unsupported-message`,{role:s.role,message:s}))}}),o(!0),i},yQ=(e,t,n,r)=>({id:oQ(e),role:`assistant`,createdAt:lQ(t),content:[pQ(n,r)]}),bQ=(e,t)=>e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():void 0,xQ=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,SQ=(e,t)=>{if(e===t)return!0;let n=bQ(e,t);if(n!==void 0)return n;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!SQ(e[n],t[n]))return!1;return!0}if(xQ(e)||xQ(t)){if(!xQ(e)||!xQ(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!SQ(e[r],t[r]))return!1;return!0}return!1},CQ=(e,t)=>e.id===t.id&&e.role===t.role&&SQ(e.createdAt,t.createdAt)&&SQ(e.content,t.content)&&SQ(e.status,t.status)&&SQ(e.metadata,t.metadata),wQ=(e,t)=>{let n=e.length!==t.length,r=e.map((e,r)=>{let i=t[r];return i&&CQ(e,i)?i:(n=!0,e)});return n?r:t},TQ=(e,t)=>wQ(vQ(e),t),EQ={snapshot:!0,agent_start:!0,agent_end:!0,agent_settled:!0,turn_start:!0,turn_end:!0,message_start:!0,message_update:!0,message_end:!0,tool_execution_start:!0,tool_execution_update:!0,tool_execution_end:!0,queue_update:!0,compaction_start:!0,compaction_end:!0,entry_appended:!0,auto_retry_start:!0,auto_retry_end:!0,session_info_changed:!0,thinking_level_changed:!0,context_usage:!0,extension_ui_request:!0,extension_ui_resolved:!0,error:!0},DQ=e=>Object.prototype.hasOwnProperty.call(EQ,e),OQ=e=>e instanceof Error?e.message:String(e),kQ=e=>{if(typeof globalThis.requestAnimationFrame==`function`){globalThis.requestAnimationFrame(()=>e());return}setTimeout(e,16)},AQ=e=>{for(let t of e)try{t()}catch(e){console.error(`[react-pi] Listener threw an error`,e)}},jQ=new Set([`snapshot`,`agent_start`,`agent_end`,`message_start`,`message_update`,`message_end`,`tool_execution_update`,`tool_execution_end`,`extension_ui_request`,`extension_ui_resolved`]),MQ=new Set([`message_update`,`tool_execution_update`]),NQ=new Set([`snapshot`,`agent_start`,`agent_end`,`queue_update`,`compaction_start`,`compaction_end`,`auto_retry_start`,`auto_retry_end`,`session_info_changed`,`thinking_level_changed`,`context_usage`,`extension_ui_request`,`extension_ui_resolved`,`error`]),PQ=e=>{let t=/^data:([^;,]+)(?:;base64)?,(.*)$/is.exec(e);return t?{type:`image`,mimeType:t[1].toLowerCase(),data:t[2]}:{type:`image`,mimeType:`image/png`,data:e}},FQ=e=>[...e.content,...e.attachments?.flatMap(e=>e.content??[])??[]],IQ=(e,t)=>{let n=FQ(e),r=[],i=[];for(let e of n)e.type===`text`?r.push(e.text):e.type===`image`&&i.push(PQ(e.image));return{content:r.join(`
94
94
 
95
- `),...i.length>0?{attachments:i}:{},...t?{streamingBehavior:t}:{}}},PQ=e=>{let t=e.runConfig?.custom?.streamingBehavior;return t===`followUp`||t===`steer`?t:void 0},FQ=e=>({role:`user`,content:e.attachments&&e.attachments.length>0?[{type:`text`,text:e.content},...e.attachments]:e.content,timestamp:Date.now()}),IQ=e=>{if(e.role!==`user`)return null;let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
96
- `):null},LQ=e=>e.runStatus===`running`&&e.metadata.status===`running`?e:{...e,runStatus:`running`,lastError:void 0,metadata:e.metadata.status===`running`?e.metadata:{...e.metadata,status:`running`}},RQ=class{state;stateSnapshot;projectedMessages=[];messageRepository=CV.fromArray([]);version=0;allListeners=new Set;metadataListeners=new Set;messageListeners=new Set;connectionRetainers=0;optimisticUserMessages=[];unsubscribeFromEvents=null;disconnectTimer=null;loadPromise=null;messageFlushScheduled=!1;localSnapshotSeq=0;client;threadId;options;constructor(e,t,n={}){this.client=e,this.threadId=t,this.options=n,this.state=BZ(t),this.stateSnapshot=this.state}getState(){return this.state}getStateSnapshot(){return this.stateSnapshot}getProjectedMessages(){return this.projectedMessages}getMessageRepository(){return this.messageRepository}getVersion(){return this.version}connect(){return this.connectionRetainers+=1,this.ensureEventSubscription({includeSnapshot:this.state.loadState!==`loaded`}),()=>{this.connectionRetainers=Math.max(0,this.connectionRetainers-1),this.maybeDisconnectFromEvents()}}subscribe(e){return this.allListeners.add(e),()=>{this.allListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMetadata(e){return this.metadataListeners.add(e),()=>{this.metadataListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMessages(e){return this.messageListeners.add(e),()=>{this.messageListeners.delete(e),this.maybeDisconnectFromEvents()}}dispose(){this.clearDisconnectTimer(),this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null,this.allListeners.clear(),this.metadataListeners.clear(),this.messageListeners.clear()}ensureEventSubscription(e){this.clearDisconnectTimer(),!this.unsubscribeFromEvents&&(this.unsubscribeFromEvents=this.client.subscribe(this.threadId,e=>{e.threadId===this.threadId&&this.dispatch(e)},e))}hasConsumers(){return this.connectionRetainers>0||this.allListeners.size>0||this.metadataListeners.size>0||this.messageListeners.size>0}maybeDisconnectFromEvents(){this.hasConsumers()||(this.disconnectTimer||=setTimeout(()=>{this.disconnectTimer=null,!this.hasConsumers()&&(this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null)},3e4))}clearDisconnectTimer(){this.disconnectTimer&&=(clearTimeout(this.disconnectTimer),null)}async load(e=!1){if(this.loadPromise&&!e)return this.loadPromise;this.setState({...this.state,loadState:`loading`});let t=this.client.getThread(this.threadId).then(e=>{this.loadPromise===t&&this.applySnapshot(e)}).catch(e=>{throw this.loadPromise===t&&this.setState({...this.state,loadState:`loaded`,lastError:TQ(e)}),e}).finally(()=>{this.loadPromise===t&&(this.loadPromise=null)});return this.loadPromise=t,t}refresh(){return this.load(!0)}refreshInBackground(){this.loadPromise||this.refresh().catch(()=>{})}async sendMessage(e,t){if(e.role!==`user`)throw Error(`Pi only supports sending user messages`);let n=this.state.runStatus===`running`,r=t?.streamingBehavior??PQ(e)??(n?`followUp`:void 0),i=NQ(e,r);if(this.ensureEventSubscription({includeSnapshot:!1}),n)return this.sendQueued(i,r??`followUp`);let a=FQ(i);this.optimisticUserMessages.push({message:a,baseMessageCount:this.state.messages.length}),this.setState(LQ(this.state)),this.recomputeProjectedMessagesAndNotify();try{await this.client.sendMessage(this.threadId,i)}catch(e){let t=this.optimisticUserMessages.findIndex(e=>e.message===a);throw t!==-1&&this.optimisticUserMessages.splice(t,1),this.recomputeProjectedMessagesAndNotify(),this.setState({...this.state,lastError:TQ(e),runStatus:`failed`,metadata:{...this.state.metadata,status:`failed`}}),e}}async sendQueued(e,t){let n=t===`steer`?`steering`:`followUp`,r={...this.state.queue,[n]:[...this.state.queue[n],e.content]};this.setState({...this.state,queue:r});try{await this.client.sendMessage(this.threadId,e)}catch(t){let i=this.state.queue!==r,a=this.state.queue[n],o=i?-1:a.lastIndexOf(e.content);throw this.setState({...this.state,lastError:TQ(t),...o===-1?{}:{queue:{...this.state.queue,[n]:a.filter((e,t)=>t!==o)}}}),t}}async clearQueue(){let e=this.state.queue,t=await this.client.clearQueue(this.threadId);return this.state.queue===e&&(e.steering.length>0||e.followUp.length>0)&&this.setState({...this.state,queue:{steering:[],followUp:[]}}),t}async cancel(){try{await this.client.cancelRun(this.threadId)}catch(e){throw this.setState({...this.state,lastError:TQ(e)}),e}}async setModel(e){try{await this.client.setModel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:TQ(e)}),e}await this.refresh()}async setThinkingLevel(e){try{await this.client.setThinkingLevel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:TQ(e)}),e}await this.refresh()}async respondToToolApproval(e,t){let n=this.state.hostUiRequests.find(t=>t.id===e);await this.respond(n?QZ(n,{approvalId:e,approved:t}):XZ(e,t))}async resumeToolCall(e,t){let n=this.state.hostUiRequests.find(t=>t.toolCallId===e);if(!n)throw Error(`No pending host-UI request for tool call "${e}"`);n.kind===`confirm`?await this.respond(XZ(n.id,t===!0)):await this.respond(eQ(n.id,t))}async respondToHostUiRequest(e){await this.respond(e)}async respond(e){try{await this.client.respondToHostUiRequest(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:TQ(e)}),e}let t=qZ(this.state,e.requestId);t!==this.state&&(this.setState(t),this.recomputeProjectedMessagesAndNotify())}applySnapshot(e){this.dispatch({type:`snapshot`,snapshot:e,threadId:this.threadId,seq:this.localSnapshotSeq})}dispatch(e){let t=JZ(this.state,e),n=t!==this.state;n&&(this.state=t),this.reconcileOptimisticUserMessages(),n&&AQ.has(e.type)&&this.notifyMetadataListeners(),n&&OQ.has(e.type)&&(kQ.has(e.type)?this.scheduleProjectedMessageFlush():this.recomputeProjectedMessagesAndNotify()),(!wQ(e.type)||e.type===`entry_appended`&&e.entry?.type!==`custom`)&&this.refreshInBackground()}setState(e){e!==this.state&&(this.state=e,this.notifyMetadataListeners())}projectedInputMessages(){return[...this.state.messages,...this.optimisticUserMessages.map(e=>e.message)]}reconcileOptimisticUserMessages(){if(this.optimisticUserMessages.length===0)return;let e=[];for(let t of this.optimisticUserMessages){let n=IQ(t.message);this.state.messages.slice(t.baseMessageCount).some(e=>IQ(e)===n)||e.push(t)}e.length!==this.optimisticUserMessages.length&&(this.optimisticUserMessages.length=0,this.optimisticUserMessages.push(...e))}projectMessages(){return SQ({messages:this.projectedInputMessages(),toolExecutions:this.state.toolExecutions,runStatus:this.state.runStatus,hostUiRequests:this.state.hostUiRequests},this.projectedMessages)}recomputeProjectedMessagesAndNotify(){let e=this.projectMessages();if(e===this.projectedMessages){this.state!==this.stateSnapshot&&this.publishState();return}this.projectedMessages=e,this.messageRepository=CV.fromArray(e),this.notifyMessageListeners()}scheduleProjectedMessageFlush(){this.messageFlushScheduled||(this.messageFlushScheduled=!0,(this.options.scheduleNotify??EQ)(()=>{this.messageFlushScheduled=!1,this.recomputeProjectedMessagesAndNotify()}))}bumpVersion(){this.version+=1}publishState(){this.stateSnapshot=this.state,this.bumpVersion(),DQ(this.allListeners)}notifyMetadataListeners(){this.stateSnapshot=this.state,this.bumpVersion(),DQ(this.metadataListeners),DQ(this.allListeners)}notifyMessageListeners(){this.stateSnapshot=this.state,this.bumpVersion(),DQ(this.messageListeners),DQ(this.allListeners)}},zQ=e=>{let t=Symbol(`${e} extras`),n=e=>typeof e==`object`&&!!e&&t in e;return{provide:e=>(Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0}),e),is:n,tryGet:e=>n(e)?e:void 0,assert:t=>{if(!n(t))throw Error(`The current thread is not backed by the ${e} runtime.`);return t}}},BQ=e=>{let{provide:t,is:n,tryGet:r,assert:i}=e,a=e=>i(e.thread.getState().extras);function o(e,...t){let r=t.length>0,a=t[0];return $(t=>{let o=t.thread.extras;return n(o)?e?e(o):o:r?a:i(o)})}return{provide:t,is:n,tryGet:r,get:a,use:o}},VQ=(e=>BQ(zQ(e)))(`usePiRuntime`),HQ=BZ(`__pending__`),UQ=[],WQ=CV.fromArray([]),GQ=e=>{let t=new Map,n=!1;return{client:e,controllers:t,get disposed(){return n},activate(){n=!1},dispose(){n=!0;for(let e of t.values())e.dispose()}}},KQ=(e,t)=>{let n=e.controllers.get(t);if(n)return n;let r=new RQ(e.client,t);return e.controllers.set(t,r),r},qQ={getState:()=>HQ,getProjectedMessages:()=>UQ,getMessageRepository:()=>WQ,getVersion:()=>0,subscribe:()=>()=>{},subscribeMetadata:()=>()=>{},subscribeMessages:()=>()=>{},connect:()=>()=>{},load:async()=>{},refresh:async()=>{},sendMessage:async()=>{},cancel:async()=>{},clearQueue:async()=>({steering:[],followUp:[]}),setModel:async()=>{},setThinkingLevel:async()=>{},respondToToolApproval:async()=>{},resumeToolCall:async()=>{},respondToHostUiRequest:async()=>{},dispose:()=>{}},JQ=(e,t)=>{nQ(`react-pi`,`onError`,e,t)},YQ=(e,t)=>{let{freeStanding:n}=YZ(t.hostUiRequests);return VQ.provide({controller:e,state:t,metadata:t.metadata,status:t.runStatus===`failed`?`failed`:t.runStatus,readiness:t.readiness,contextUsage:t.contextUsage,hostUiRequests:n,allHostUiRequests:t.hostUiRequests,queue:t.queue,compaction:t.compaction,retry:t.retry,lastError:t.lastError,cancel:()=>e.cancel(),refresh:()=>e.refresh(),clearQueue:()=>e.clearQueue(),setModel:t=>e.setModel(t),setThinkingLevel:t=>e.setThinkingLevel(t),respondToHostUiRequest:t=>e.respondToHostUiRequest(t),respondToToolApproval:(t,n)=>e.respondToToolApproval(t,n),resumeToolCall:(t,n)=>e.resumeToolCall(t,n)})},XQ=YQ(qQ,HQ),ZQ=e=>e.getStateSnapshot?.()??e.getState(),QQ=e=>{let t=(0,N.useCallback)(()=>ZQ(e),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribe(t),[e]),t,t)},$Q=e=>{let t=(0,N.useCallback)(()=>e.getMessageRepository(),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribeMessages(t),[e]),t,t)},e$=(e,t)=>{let n=(0,N.useMemo)(()=>{let n;return()=>{let r=ZQ(e);return(!n||n.state!==r)&&(n={state:r,selection:t(r)}),n.selection}},[e,t]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribe(t),[e]),n,n)},t$=e=>e.runStatus===`running`||e.compaction.active||e.retry.active,n$=(e,t)=>{let n=QQ(e),r=$Q(e),{adapters:i,isDisabled:a,isSendDisabled:o,onError:s,suggestions:c,unstable_capabilities:l}=t,u=n.loadState===`loading`,d=t$(n),f=(0,N.useEffectEvent)(e=>{JQ(s,e)});(0,N.useEffect)(()=>{e!==qQ&&e.load().catch(f)},[e]),(0,N.useEffect)(()=>{if(e!==qQ&&d)return e.connect()},[e,d]);let p=(0,N.useMemo)(()=>YQ(e,n),[e,n]),m=(0,N.useMemo)(()=>({items:n.queue.followUp.map((e,t)=>({id:RZ(`followUp`,t),prompt:e,parts:[{type:`text`,text:e}]})),steerItems:n.queue.steering.map((e,t)=>({id:RZ(`steer`,t),prompt:e,parts:[{type:`text`,text:e}]})),enqueue:t=>{e.sendMessage(t).catch(e=>JQ(s,e))},steer:t=>{e.sendMessage(t,{streamingBehavior:`steer`}).catch(e=>JQ(s,e))},move:()=>{},edit:()=>{},remove:()=>{}}),[e,n.queue,s]);return(0,N.useMemo)(()=>({isDisabled:a,isSendDisabled:o,unstable_capabilities:l,suggestions:c,isLoading:u,isRunning:d,messageRepository:r,extras:p,queue:m,...i?{adapters:i}:{},onNew:async t=>{try{await e.sendMessage(t)}catch(e){throw JQ(s,e),e}},onCancel:async()=>{try{try{await e.clearQueue()}finally{await e.cancel()}}catch(e){throw JQ(s,e),e}},onRespondToToolApproval:async t=>{try{let n=e.getState().hostUiRequests.find(e=>e.id===t.approvalId);if(!n)throw Error(`No pending host-UI request "${t.approvalId}"`);await e.respondToHostUiRequest(QZ(n,t))}catch(e){throw JQ(s,e),e}},onResumeToolCall:({toolCallId:t,payload:n})=>{e.resumeToolCall(t,n).catch(e=>JQ(s,e))}}),[e,p,r,m,i,a,u,d,o,s,c,l])},r$=(e,t)=>({id:`pi-new-user:${t}`,role:`user`,createdAt:new Date,content:MQ(e)}),i$=(e,t)=>{let n=Q(),{adapters:r,isDisabled:i,isSendDisabled:a,onError:o,suggestions:s,unstable_capabilities:c}=t,[l,u]=(0,N.useState)([]),d=(0,N.useRef)(0),f=(0,N.useMemo)(()=>CV.fromArray(l),[l]);return(0,N.useMemo)(()=>({isDisabled:i??!1,isSendDisabled:a,unstable_capabilities:c,suggestions:s,isLoading:!1,isRunning:!1,messageRepository:f,extras:XQ,...r?{adapters:r}:{},onNew:async t=>{let r=r$(t,d.current++);u(e=>[...e,r]);let i=()=>{u(e=>e.filter(e=>e!==r))};try{let{remoteId:r,externalId:a}=await n.threadListItem.initialize();if(e.disposed){i();return}await KQ(e,a??r).sendMessage(t),i()}catch(e){throw i(),JQ(o,e),e}}}),[n,f,e,r,i,a,o,s,c])},a$=(e,t)=>{let n=$(e=>e.threadListItem),r=$(e=>e.threads.mainThreadId===e.threadListItem.id),i=n.externalId??n.remoteId,a=i?KQ(e,i):qQ,o=n$(r?a:qQ,t),s=i$(e,t);return $V(i?o:s)},o$=e=>({status:e.archived?`archived`:`regular`,remoteId:e.id,externalId:e.id,...e.title===void 0?{}:{title:e.title},custom:{status:e.status,...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.sessionFile===void 0?{}:{sessionFile:e.sessionFile},...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath}}}),s$=e=>{let{client:t}=e,n=(0,N.useMemo)(()=>GQ(t),[t]);return(0,N.useEffect)(()=>(n.activate(),()=>n.dispose()),[n]),UH({allowNesting:!0,adapter:(0,N.useMemo)(()=>({list:async()=>({threads:(await t.listThreads({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.includeArchived===void 0?{}:{includeArchived:e.includeArchived}})).map(o$)}),rename:async(e,n)=>{await t.renameThread(e,n)},archive:async e=>{await t.archiveThread?.(e)},unarchive:async e=>{await t.unarchiveThread?.(e)},delete:async e=>{await t.deleteThread?.(e)},initialize:async()=>{let n=await t.createThread({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath}});return{remoteId:n.metadata.id,externalId:n.metadata.id}},generateTitle:async()=>new ReadableStream({start(e){e.close()}}),fetch:async e=>o$((await t.getThread(e)).metadata)}),[t,e.workspacePath,e.includeArchived]),...e.initialThreadId===void 0?{}:{initialThreadId:e.initialThreadId},...e.threadId===void 0?{}:{threadId:e.threadId},...e.onThreadIdChange===void 0?{}:{onThreadIdChange:e.onThreadIdChange},runtimeHook:()=>a$(n,e)})},c$=()=>VQ.use(e=>e,XQ),l$=()=>VQ.use(e=>e.metadata,null);function u$(e){return e$(VQ.use(e=>e.controller,qQ),e??(e=>e))}var d$=()=>{let e=VQ.use(e=>e,void 0);return(0,N.useMemo)(()=>({requests:e?.hostUiRequests??[],respond:e?.respondToHostUiRequest??(async()=>{throw Error(`Pi runtime is not ready yet`)})}),[e])};function f$({delayDuration:e=0,...t}){return(0,P.jsx)(Sd,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function p$({...e}){return(0,P.jsx)(Cd,{"data-slot":`tooltip`,...e})}function m$({...e}){return(0,P.jsx)(wd,{"data-slot":`tooltip-trigger`,...e})}function h$({className:e,sideOffset:t=0,children:n,...r}){return(0,P.jsx)(Td,{children:(0,P.jsxs)(Ed,{"data-slot":`tooltip-content`,sideOffset:t,className:a(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,P.jsx)(Dd,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function g$({...e}){return(0,P.jsx)(xi,{"data-slot":`dialog`,...e})}function _$({...e}){return(0,P.jsx)(Ci,{"data-slot":`dialog-trigger`,...e})}function v$({...e}){return(0,P.jsx)(Di,{"data-slot":`dialog-portal`,...e})}function y$({className:e,...t}){return(0,P.jsx)(ki,{"data-slot":`dialog-overlay`,className:a(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function b$({className:e,children:t,showCloseButton:n=!0,...r}){return(0,P.jsxs)(v$,{"data-slot":`dialog-portal`,children:[(0,P.jsx)(y$,{}),(0,P.jsxs)(Ni,{"data-slot":`dialog-content`,className:a(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,P.jsxs)(Bi,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,P.jsx)(Le,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function x$({className:e,...t}){return(0,P.jsx)(Ri,{"data-slot":`dialog-title`,className:a(`text-lg leading-none font-semibold`,e),...t})}function S$({className:e,size:t=`default`,...n}){return(0,P.jsx)(Xi,{"data-slot":`avatar`,"data-size":t,className:a(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function C$({className:e,...t}){return(0,P.jsx)(Qi,{"data-slot":`avatar-image`,className:a(`aspect-square size-full`,e),...t})}function w$({className:e,...t}){return(0,P.jsx)(ea,{"data-slot":`avatar-fallback`,className:a(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var T$=(0,N.forwardRef)(({children:e,tooltip:t,side:n=`bottom`,className:r,...i},o)=>(0,P.jsx)(f$,{delayDuration:0,children:(0,P.jsxs)(p$,{children:[(0,P.jsx)(m$,{asChild:!0,children:(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,...i,className:a(`aui-button-icon size-6 p-1 active:scale-90`,r),ref:o,children:[(0,P.jsx)(l,{children:e}),(0,P.jsx)(`span`,{className:`aui-sr-only sr-only`,children:t})]})}),(0,P.jsx)(h$,{side:n,children:t})]})}));T$.displayName=`TooltipIconButton`;var E$=e=>Symbol.iterator in e,D$=e=>`entries`in e,O$=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},k$=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function A$(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:E$(e)&&E$(t)?D$(e)&&D$(t)?O$(e,t):k$(e,t):O$({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function j$(e){let t=N.useRef(void 0);return n=>{let r=e(n);return A$(t.current,r)?t.current:t.current=r}}var M$=e=>{let[t,n]=(0,N.useState)(void 0);return(0,N.useEffect)(()=>{if(!e){n(void 0);return}let t=URL.createObjectURL(e);return n({file:e,url:t}),()=>{URL.revokeObjectURL(t)}},[e]),t!==void 0&&t.file===e?t.url:void 0},N$=()=>{let{file:e,src:t}=$(j$(e=>{if(e.attachment.type!==`image`)return{};if(e.attachment.file)return{file:e.attachment.file};let t=e.attachment.content?.filter(e=>e.type===`image`)[0]?.image;return t?{src:t}:{}}));return M$(e)??t},P$=({src:e})=>{let[t,n]=(0,N.useState)(!1);return(0,P.jsx)(`img`,{src:e,alt:`Attachment preview`,className:a(`block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none`,t?`aui-attachment-preview-image-loaded opacity-100`:`aui-attachment-preview-image-loading opacity-0`),onLoad:()=>n(!0)})},F$=({children:e})=>{let t=N$();return t?(0,P.jsxs)(g$,{children:[(0,P.jsx)(_$,{className:`aui-attachment-preview-trigger cursor-zoom-in`,asChild:!0,children:(0,N.isValidElement)(e)?e:(0,P.jsx)(`button`,{type:`button`,children:e})}),(0,P.jsxs)(b$,{className:`aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!`,children:[(0,P.jsx)(x$,{className:`aui-sr-only sr-only`,children:`Image Attachment Preview`}),(0,P.jsx)(`div`,{className:`aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm`,children:(0,P.jsx)(P$,{src:t})})]})]}):e},I$=()=>{let e=N$();return(0,P.jsxs)(S$,{className:`aui-attachment-tile-avatar h-full w-full rounded-none`,children:[(0,P.jsx)(C$,{src:e,alt:`Attachment preview`,className:`aui-attachment-tile-image rounded-none object-cover`}),(0,P.jsx)(w$,{children:(0,P.jsx)(le,{className:`aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]`})})]})},L$=()=>{let e=Q().attachment.source!==`message`,t=$(e=>e.attachment.type===`image`),n=$(e=>{let t=e.attachment.type;switch(t){case`image`:return`Image`;case`document`:return`Document`;case`file`:return`File`;default:return t}}),r=$(e=>e.attachment.status.type===`running`?`uploading`:e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?`error`:void 0),i=r===`uploading`,o=r===`error`,s=$(e=>e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?e.attachment.status.message??`Upload failed`:void 0);return(0,P.jsx)(f$,{children:(0,P.jsxs)(p$,{children:[(0,P.jsxs)(JK.Root,{className:a(`aui-attachment-root relative`,e&&`animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none`,t&&!e&&`aui-attachment-root-message only:*:first:size-24`),children:[(0,P.jsx)(F$,{children:(0,P.jsx)(m$,{asChild:!0,children:(0,P.jsxs)(`div`,{className:a(`aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--composer-radius,1rem)-var(--composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10`,o&&`after:ring-destructive/60 dark:after:ring-destructive/60`),role:`button`,tabIndex:0,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},"aria-label":`${n} attachment${o?`, upload failed`:i?`, uploading`:``}`,children:[(0,P.jsx)(I$,{}),i&&(0,P.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,P.jsx)(he,{className:`text-muted-foreground size-4 animate-spin`})}),o&&(0,P.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,P.jsx)(te,{className:`text-destructive size-4`})})]})})}),e&&(0,P.jsx)(R$,{})]}),(0,P.jsxs)(h$,{side:`top`,children:[(0,P.jsx)(JK.Name,{}),s&&(0,P.jsx)(`p`,{className:`aui-attachment-error-message`,children:s})]})]})})},R$=()=>(0,P.jsx)(JK.Remove,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Remove file`,className:`aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none`,side:`top`,children:(0,P.jsx)(Le,{className:`aui-attachment-remove-icon size-3 stroke-[2.5]`})})}),z$=()=>(0,P.jsx)(`div`,{className:`aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2 empty:hidden`,children:(0,P.jsx)(dX.Attachments,{children:()=>(0,P.jsx)(L$,{})})}),B$=()=>(0,P.jsx)(`div`,{className:`aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden`,children:(0,P.jsx)($J.Attachments,{children:()=>(0,P.jsx)(L$,{})})}),V$=()=>(0,P.jsx)($J.AddAttachment,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Add Attachment`,side:`bottom`,variant:`ghost`,size:`icon`,className:`aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none`,"aria-label":`Add Attachment`,children:(0,P.jsx)(Se,{className:`aui-attachment-add-icon size-4`})})}),H$=y(`aui-file-root inline-flex items-center gap-3 rounded-lg transition-colors`,{variants:{variant:{outline:`border-border hover:bg-muted/50 border`,ghost:`hover:bg-muted/50`,muted:`bg-muted/50 hover:bg-muted/70`},size:{sm:`px-2.5 py-1.5 text-xs`,default:`px-3 py-2 text-sm`,lg:`px-4 py-3 text-base`}},defaultVariants:{variant:`outline`,size:`default`}});function U$(e){let t=e.toLowerCase();return t.startsWith(`image/`)?fe:t===`application/pdf`?le:t===`application/json`?O:t.startsWith(`text/`)?le:t.startsWith(`audio/`)?ve:t.startsWith(`video/`)?Fe:ue}function W$(e,t){return t===`url`&&/^data:/i.test(e)?`data-uri`:t||(/^data:/i.test(e)?`data-uri`:/^https?:\/\//i.test(e)?`url`:`base64`)}function G$(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`),n=e.search(/[^A-Za-z\d+/]/);return n!==-1&&n!==e.length-t||e.length%4==1||t>0&&e.length%4!=0?0:Math.floor(e.length*3/4)-t}function K$(e){return G$(/[\t\n\f\r ]/.test(e)?e.replace(/[\t\n\f\r ]/g,``):e)}function q$(e){let t=e.indexOf(`#`),n=t<0?e.length:t,r=e.indexOf(`,`);if(r<0||r>=n)return 0;let i=e.slice(r+1,n);return/;base64$/i.test(e.slice(0,r))?(/[%\t\n\f\r ]/.test(i)&&(i=i.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16))).replace(/[\t\n\f\r ]/g,``)),G$(i)):new TextEncoder().encode(i.replace(/%[\da-f]{2}/gi,`_`)).byteLength}function J$(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Y$({className:e,variant:t,size:n,children:r,...i}){return(0,P.jsx)(`div`,{"data-slot":`file-root`,"data-variant":t,"data-size":n,className:a(H$({variant:t,size:n,className:e})),...i,children:r})}function X$({mimeType:e,className:t,children:n,...r}){let i=e?U$(e):ue;return(0,P.jsx)(`span`,{"data-slot":`file-icon`,className:a(`text-muted-foreground shrink-0`,t),...r,children:n??(0,P.jsx)(i,{className:`size-5`})})}function Z$({className:e,children:t,...n}){return(0,P.jsx)(`span`,{"data-slot":`file-name`,className:a(`min-w-0 flex-1 truncate font-medium`,e),...n,children:t||`Unnamed file`})}function Q$({bytes:e,className:t,...n}){return(0,P.jsx)(`span`,{"data-slot":`file-size`,className:a(`text-muted-foreground shrink-0`,t),...n,children:J$(e)})}function $$({data:e,mimeType:t,filename:n,sourceType:r,className:i,children:o,...s}){if(typeof e!=`string`)return null;let c=W$(e,r);if(c===`id`||c===`url`&&!/^(https?:\/\/|blob:)/i.test(e))return null;let l=c===`base64`?`data:${t};base64,${e}`:e;return(0,P.jsx)(`a`,{"data-slot":`file-download`,href:l,download:n||`download`,...c===`url`&&{target:`_blank`,rel:`noopener noreferrer`},className:a(`text-muted-foreground hover:bg-accent hover:text-accent-foreground shrink-0 rounded-md p-1 transition-colors`,i),"aria-label":o?void 0:`Download ${n||`file`}`,...s,children:o||(0,P.jsx)(oe,{className:`size-4`})})}var e1=(0,N.memo)(({filename:e,data:t,mimeType:n,sourceType:r})=>{let i=W$(t,r);return(0,P.jsxs)(Y$,{children:[(0,P.jsx)(X$,{mimeType:n}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,P.jsx)(Z$,{children:e}),typeof t==`string`&&(i===`base64`||i===`data-uri`)&&(0,P.jsx)(Q$,{bytes:i===`data-uri`?q$(t):K$(t),className:`text-xs`})]}),(0,P.jsx)($$,{data:t,mimeType:n,...e!==void 0&&{filename:e},...r!==void 0&&{sourceType:r}})]})});e1.displayName=`File`,e1.Root=Y$,e1.Icon=X$,e1.Name=Z$,e1.Size=Q$,e1.Download=$$;var t1=()=>{let e=$(e=>e.thread.suggestions),t=(0,N.useRef)(null),n=(0,N.useRef)(null),[r,i]=(0,N.useState)({left:!1,right:!1}),a=(0,N.useCallback)(()=>{let e=t.current;if(!e)return;let r=e.scrollWidth-e.clientWidth,a=Math.abs(e.scrollLeft),[o,s]=(n.current??=getComputedStyle(e).direction===`rtl`)?[r-a,a]:[a,r-a];i(e=>{let t={left:o>1,right:s>1};return e.left===t.left&&e.right===t.right?e:t})},[]);(0,N.useEffect)(()=>{a();let e=t.current;if(!e?.firstElementChild)return;let n=new ResizeObserver(a);return n.observe(e),n.observe(e.firstElementChild),()=>n.disconnect()},[a]);let o=`linear-gradient(to right, ${r.left?`transparent, black 2rem`:`black`}, ${r.right?`black calc(100% - 2rem), transparent`:`black`})`;return(0,P.jsx)(`div`,{ref:t,onScroll:a,className:`aui-thread-followup-suggestions -my-1 w-full [scrollbar-width:none] overflow-x-auto py-1 [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,style:{maskImage:o,WebkitMaskImage:o},children:(0,P.jsx)(`div`,{className:`mx-auto flex min-h-8 w-max items-center gap-2 px-0.5`,children:e.map((e,t)=>(0,P.jsxs)(YX.Suggestion,{className:`aui-thread-followup-suggestion border-foreground/10 hover:bg-foreground/[0.03] hover:border-foreground/25 rounded-md border px-2.5 py-1 text-sm whitespace-nowrap transition-colors ease-in motion-reduce:transition-none`,prompt:e.prompt,send:!0,children:[e.title??e.prompt,e.label&&(0,P.jsx)(`span`,{className:`aui-thread-followup-suggestion-label text-muted-foreground ms-1`,children:e.label})]},t))})})},n1=()=>(0,P.jsx)(ZI,{condition:e=>!e.thread.isEmpty&&!e.thread.isRunning&&e.thread.suggestions.length>0,children:(0,P.jsx)(t1,{})}),r1=e=>{switch(e){case`image/png`:return`png`;case`image/jpeg`:case`image/jpg`:return`jpg`;case`image/webp`:return`webp`;case`image/gif`:return`gif`;case`image/svg+xml`:return`svg`;default:return`png`}},i1=e=>{let t=e.indexOf(`,`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``,i=n.match(/data:([^;]+)/i)?.[1]?.toLowerCase()??`application/octet-stream`;if(!/;base64/i.test(n)){let e=r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURIComponent(e)}catch{return e}});return new Blob([e],{type:i})}let a;try{let e=r.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));a=atob(e)}catch{return null}let o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);return new Blob([o],{type:i})},a1=e=>e.match(/^data:([^;,]+)/i)?.[1]?.toLowerCase(),o1=e=>{if(typeof document>`u`)return;let t=r1(a1(e.image)),n=e.filename??`image.${t}`,r=/^data:/i.test(e.image),i=r?i1(e.image):null;if(r&&!i)return;let a=i?URL.createObjectURL(i):null,o=a??e.image,s=document.createElement(`a`);s.href=o,s.download=n,s.rel=`noopener`,document.body.appendChild(s),s.click(),document.body.removeChild(s),a&&setTimeout(()=>URL.revokeObjectURL(a),4e4)},s1=async e=>{if(typeof navigator>`u`||!navigator.clipboard||typeof ClipboardItem>`u`)throw Error(`Clipboard API is not available in this environment.`);let t=/^data:/i.test(e.image)?i1(e.image):await fetch(e.image).then(e=>e.blob());if(!t)return;let n=a1(e.image)??t.type??`image/png`;await navigator.clipboard.write([new ClipboardItem({[n]:t})])},c1=y(`aui-image-root relative overflow-hidden rounded-lg`,{variants:{variant:{outline:`border-border border`,ghost:``,muted:`bg-muted/50`},size:{sm:`max-w-64`,default:`max-w-96`,lg:`max-w-[512px]`,full:`w-full`}},defaultVariants:{variant:`outline`,size:`default`}});function l1({className:e,variant:t,size:n,children:r,...i}){return(0,P.jsx)(`div`,{"data-slot":`image-root`,"data-variant":t,"data-size":n,className:a(c1({variant:t,size:n,className:e})),...i,children:r})}function u1({className:e,containerClassName:t,onLoad:n,onError:r,alt:i=`Image content`,src:o,...s}){let c=(0,N.useRef)(null),[l,u]=(0,N.useState)(void 0),[d,f]=(0,N.useState)(void 0),p=l===o,m=d===o;return(0,N.useEffect)(()=>{let e=c.current;typeof o==`string`&&e?.complete&&(e.naturalWidth>0?u(o):f(o))},[o]),(0,P.jsxs)(`div`,{"data-slot":`image-preview`,className:a(`relative min-h-32`,t),children:[!p&&!m&&(0,P.jsx)(`div`,{"data-slot":`image-preview-loading`,className:`bg-muted/50 absolute inset-0 flex items-center justify-center`,children:(0,P.jsx)(fe,{className:`text-muted-foreground size-8 animate-pulse`})}),m?(0,P.jsx)(`div`,{"data-slot":`image-preview-error`,className:`bg-muted/50 flex min-h-32 items-center justify-center p-4`,children:(0,P.jsx)(de,{className:`text-muted-foreground size-8`})}):(0,P.jsx)(`img`,{ref:c,src:o,alt:i,className:a(`block h-auto w-full object-contain`,!p&&`invisible`,e),onLoad:e=>{typeof o==`string`&&u(o),n?.(e)},onError:e=>{typeof o==`string`&&f(o),r?.(e)},...s})]})}function d1({className:e,children:t,...n}){return t?(0,P.jsx)(`span`,{"data-slot":`image-filename`,className:a(`text-muted-foreground block truncate px-2 py-1.5 text-xs`,e),...n,children:t}):null}function f1({src:e,alt:t=`Image preview`,children:n}){let[r,i]=(0,N.useState)(!1),a=(0,N.useRef)(null),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useCallback)(()=>i(!0),[]),l=(0,N.useCallback)(()=>{i(!1),a.current?.focus()},[]);return(0,N.useEffect)(()=>{if(!r)return;let e=e=>{if(e.key===`Escape`){l();return}if(e.key!==`Tab`)return;let t=s.current?.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`),n=t?.[0],r=t?.[t.length-1];n&&r&&(e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r,l]),(0,N.useEffect)(()=>{if(!r)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[r]),(0,N.useEffect)(()=>{r&&o.current?.focus()},[r]),(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{ref:a,onClick:c,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},role:`button`,tabIndex:0,className:`aui-image-zoom-trigger cursor-zoom-in`,"aria-label":`Click to zoom image`,children:n}),r&&(0,Vn.createPortal)((0,P.jsxs)(`div`,{ref:s,"data-slot":`image-zoom-overlay`,role:`dialog`,"aria-modal":`true`,className:`aui-image-zoom-overlay fade-in animate-in fixed inset-0 z-50 flex items-center justify-center bg-black/80 duration-200`,onClick:l,"aria-label":`Zoomed image`,children:[(0,P.jsx)(`img`,{"data-slot":`image-zoom-content`,src:e,alt:t,className:`aui-image-zoom-content fade-in zoom-in-95 animate-in max-h-[90vh] max-w-[90vw] cursor-zoom-out object-contain duration-200`,onClick:e=>{e.stopPropagation(),l()}}),(0,P.jsx)(`button`,{ref:o,type:`button`,"aria-label":`Close zoomed image`,onClick:e=>{e.stopPropagation(),l()},className:`text-muted-foreground hover:text-foreground bg-background/80 absolute end-4 top-4 cursor-pointer rounded-md p-2`,children:(0,P.jsx)(Le,{className:`size-5`})})]}),document.body)]})}function p1({className:e}){return(0,P.jsxs)(`div`,{"data-slot":`image-generating`,className:a(`bg-muted/50 flex min-h-32 items-center justify-center p-4`,e),children:[(0,P.jsx)(he,{className:`text-muted-foreground size-8 animate-spin`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Generating image…`})]})}function m1({className:e,reason:t}){return(0,P.jsxs)(`div`,{"data-slot":`image-content-filter-error`,className:a(`bg-muted/50 flex min-h-32 flex-col items-center justify-center gap-2 p-4 text-center`,e),children:[(0,P.jsx)(Ee,{className:`text-muted-foreground size-8`}),(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Image could not be generated`}),t&&(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t})]})}function h1({onRegenerate:e}){let[t,n]=(0,N.useState)(!1);return(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{n(!0);try{await e()}catch{}finally{n(!1)}},disabled:t,"data-slot":`image-regenerate`,"aria-label":`Regenerate image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded disabled:opacity-50`,children:(0,P.jsx)(Ce,{className:a(`size-4`,t&&`animate-spin`)})})}function g1({part:e,onRegenerate:t,className:n}){return(0,P.jsxs)(`div`,{"data-slot":`image-actions`,className:a(`flex items-center gap-1 p-1`,n),children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>o1(e),"data-slot":`image-download`,"aria-label":`Download image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,P.jsx)(oe,{className:`size-4`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{s1(e).catch(()=>{})},"data-slot":`image-copy`,"aria-label":`Copy image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,P.jsx)(ae,{className:`size-4`})}),t&&(0,P.jsx)(h1,{onRegenerate:t})]})}var _1=(0,N.memo)(e=>{let{image:t,filename:n,status:r}=e;return r?.type===`running`?(0,P.jsxs)(l1,{children:[(0,P.jsx)(p1,{}),(0,P.jsx)(d1,{children:n})]}):r?.type===`incomplete`&&r.reason===`content-filter`?(0,P.jsx)(l1,{children:(0,P.jsx)(m1,{reason:`The provider blocked this image.`})}):(0,P.jsxs)(l1,{children:[(0,P.jsx)(f1,{src:t,alt:n||`Image content`,children:(0,P.jsx)(u1,{src:t,alt:n||`Image content`})}),(0,P.jsx)(d1,{children:n})]})});_1.displayName=`Image`,_1.Root=l1,_1.Preview=u1,_1.Filename=d1,_1.Zoom=f1,_1.Actions=g1,_1.Generating=p1,_1.ContentFilterError=m1;var v1=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),y1=(e,t)=>{if(!e||!t)return!1;let n=e=>{let{position:t,data:n,...r}=e||{};return r};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&v1(e.children,t.children)},b1=(e,t)=>y1(e.node,t.node),x1=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,N.memo)(({node:e,...t})=>(0,P.jsx)(n,{...t}),b1)]})),S1=(0,N.createContext)(null),C1=()=>(0,N.useContext)(S1)!==null,w1=(0,N.memo)(({children:e,fallbackPre:t,...n})=>n.node?.children.some(e=>e.type===`element`&&e.tagName===`code`)??!0?(0,P.jsx)(S1.Provider,{value:n,children:e}):(0,P.jsx)(t,{...n,children:e}),(e,t)=>e.fallbackPre===t.fallbackPre&&b1(e,t)),T1=({node:e,...t})=>(0,P.jsx)(`pre`,{...t}),E1=({node:e,...t})=>(0,P.jsx)(`code`,{...t}),D1=({node:e,components:{Pre:t,Code:n},code:r})=>(0,P.jsx)(t,{children:(0,P.jsx)(n,{node:e,children:r})}),O1=()=>null,k1=e=>/language-([^\s]+)/.exec(e??``)?.[1]??``,A1=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,N.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(i,{node:e,language:a,code:o}),(0,P.jsx)(r,{node:e,components:s,language:a,code:o})]})},j1=n(r(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),M1=({className:e,...t})=>({className:n,...r})=>({className:(0,j1.default)(e,n),...t,...r});function N1(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=``;for(let n of e)t+=N1(n);return t}return(0,N.isValidElement)(e)?N1(e.props.children):``}var P1=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=M1((0,N.useContext)(S1)),l=ln(e=>(0,P.jsx)(t,{...c(e)})),u=M1(s),d=ln(e=>(0,P.jsx)(n,{...u(e)})),f=k1(s.className),p=a[f]?.SyntaxHighlighter??r,m=a[f]?.CodeHeader??i;return o!=null&&typeof o!=`string`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(m,{node:e,language:f,code:N1(o)}),(0,P.jsx)(D1,{node:e,components:{Pre:l,Code:d},code:o})]}):(0,P.jsx)(A1,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:p,CodeHeader:m},language:f,code:o??``})},F1=({node:e,components:t,componentsByLanguage:n,...r})=>C1()?(0,P.jsx)(P1,{node:e,components:t,componentsByLanguage:n,...r}):(0,P.jsx)(t.Code,{...r}),I1=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let n=e[r],i=t[r];if(n!==i&&(!n||!i||n.SyntaxHighlighter!==i.SyntaxHighlighter||n.CodeHeader!==i.CodeHeader))return!1}return!0},L1=(0,N.memo)(F1,(e,t)=>e.components===t.components&&I1(e.componentsByLanguage,t.componentsByLanguage)&&b1(e,t)),{useSmooth:R1,useSmoothStatus:z1,withSmoothContextProvider:B1}=LZ,V1=(0,N.memo)(({text:e,overrideVersion:t,...n})=>(0,P.jsx)(qD,{...n,children:e}));V1.displayName=`MarkdownRenderer`;var H1=({text:e,...t})=>{let n=(0,N.useDeferredValue)(e);return(0,P.jsx)(V1,{text:n,...t})},U1=e=>typeof e==`object`&&!!e&&!Array.isArray(e),W1=(e,t,n=1)=>{if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!W1(e[r],t[r],n-1))return!1;return!0}if(U1(e)&&U1(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&W1(e[r],t[r],n-1))}return!1};function G1(e,t){let n=(0,N.useRef)(e);return W1(e,n.current,t)||(n.current=e),n.current}function K1(e){let t=(0,N.useRef)(e),n=(e,t)=>e[t],r=Object.keys(e),i=Object.keys(t.current);return r.length===i.length&&r.every(r=>Object.hasOwn(t.current,r)&&W1(n(e,r),n(t.current,r)))||(t.current=e),t.current}var q1=({components:e,componentsByLanguage:t,smooth:n=!0,defer:r=!1,preprocess:i,...a})=>{let{text:o}=R1(nY(),n),s=(0,N.useMemo)(()=>i?i(o):o,[i,o]),{pre:c=T1,code:l=E1,SyntaxHighlighter:u=D1,CodeHeader:d=O1}=e??{},f=(0,N.useMemo)(()=>({Pre:c,Code:l,SyntaxHighlighter:u,CodeHeader:d}),[c,l,u,d]),p=ln(e=>(0,P.jsx)(L1,{components:f,componentsByLanguage:t,...e})),m=ln(e=>(0,P.jsx)(w1,{fallbackPre:c,...e})),h=K1((0,N.useMemo)(()=>{let{pre:t,code:n,SyntaxHighlighter:r,CodeHeader:i,...a}=e??{};return{...a,pre:m,code:p}},[p,m,e])),g=G1((0,N.useMemo)(()=>({components:f,componentsByLanguage:t}),[f,t]),3),_=r?H1:V1,v=K1(a);return(0,P.jsx)(_,{text:s,components:h,overrideVersion:g,...v})},J1=(0,N.forwardRef)(({className:e,containerProps:t,containerComponent:n=`div`,...r},i)=>{let a=z1();return(0,P.jsx)(n,{"data-status":a.type,...t,className:(0,j1.default)(e,t?.className),ref:i,children:(0,P.jsx)(q1,{...r})})});J1.displayName=`MarkdownTextPrimitive`;var Y1=B1(J1),X1=({copiedDuration:e=3e3}={})=>{let[t,n]=(0,N.useState)(!1),r=(0,N.useRef)(void 0),i=(0,N.useRef)(0);return(0,N.useEffect)(()=>()=>{i.current+=1,r.current!==void 0&&(clearTimeout(r.current),r.current=void 0,n(!1))},[]),{isCopied:t,copyToClipboard:t=>{if(!t||typeof navigator>`u`||!navigator.clipboard)return;let a=i.current;navigator.clipboard.writeText(t).then(()=>{a===i.current&&(r.current!==void 0&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{r.current=void 0,n(!1)},e))},()=>{})}}},Z1=e=>{let t=(0,N.useRef)(e);if(e!==t.current){let n=t.current;e!==void 0&&n!==void 0&&Object.keys(n).length===Object.keys(e).length&&Object.keys(e).every(t=>n[t]===e[t])||(t.current=e)}return t.current},Q1=(0,N.memo)(({components:e})=>{let t=Z1(e),n=(0,N.useMemo)(()=>t?{...$1,...x1(t)}:$1,[t]);return(0,P.jsx)(Y1,{remarkPlugins:[ZA],className:`aui-md`,components:n,defer:!0})}),$1=x1({h1:({className:e,...t})=>(0,P.jsx)(`h1`,{className:a(`aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0`,e),...t}),h2:({className:e,...t})=>(0,P.jsx)(`h2`,{className:a(`aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0`,e),...t}),h3:({className:e,...t})=>(0,P.jsx)(`h3`,{className:a(`aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0`,e),...t}),h4:({className:e,...t})=>(0,P.jsx)(`h4`,{className:a(`aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0`,e),...t}),h5:({className:e,...t})=>(0,P.jsx)(`h5`,{className:a(`aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0`,e),...t}),h6:({className:e,...t})=>(0,P.jsx)(`h6`,{className:a(`aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0`,e),...t}),p:({className:e,...t})=>(0,P.jsx)(`p`,{className:a(`aui-md-p my-3 leading-relaxed first:mt-0 last:mb-0`,e),...t}),a:({className:e,...t})=>(0,P.jsx)(`a`,{className:a(`aui-md-a text-primary hover:text-primary/80 underline underline-offset-2`,e),...t}),blockquote:({className:e,...t})=>(0,P.jsx)(`blockquote`,{className:a(`aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4`,e),...t}),ul:({className:e,...t})=>(0,P.jsx)(`ul`,{className:a(`aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1`,e),...t}),ol:({className:e,...t})=>(0,P.jsx)(`ol`,{className:a(`aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1`,e),...t}),hr:({className:e,...t})=>(0,P.jsx)(`hr`,{className:a(`aui-md-hr border-muted-foreground/20 my-3`,e),...t}),table:({className:e,...t})=>(0,P.jsx)(`div`,{className:`aui-md-table-wrapper my-3 overflow-x-auto`,children:(0,P.jsx)(`table`,{className:a(`aui-md-table w-full border-separate border-spacing-0`,e),...t})}),th:({className:e,...t})=>(0,P.jsx)(`th`,{className:a(`aui-md-th bg-muted px-3 py-1.5 text-start font-medium first:rounded-ss-lg last:rounded-se-lg [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),td:({className:e,...t})=>(0,P.jsx)(`td`,{className:a(`aui-md-td border-muted-foreground/20 border-s border-b px-3 py-1.5 text-start last:border-e [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),tr:({className:e,...t})=>(0,P.jsx)(`tr`,{className:a(`aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-es-lg [&:last-child>td:last-child]:rounded-ee-lg`,e),...t}),li:({className:e,...t})=>(0,P.jsx)(`li`,{className:a(`aui-md-li leading-relaxed`,e),...t}),strong:({className:e,...t})=>(0,P.jsx)(`strong`,{className:a(`aui-md-strong font-semibold`,e),...t}),sup:({className:e,...t})=>(0,P.jsx)(`sup`,{className:a(`aui-md-sup [&>a]:text-xs [&>a]:no-underline`,e),...t}),pre:({className:e,...t})=>(0,P.jsx)(`pre`,{className:a(`aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed`,e),...t}),code:function({className:e,...t}){let n=C1();return(0,P.jsx)(`code`,{className:a(!n&&`aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]`,e),...t})},CodeHeader:({language:e,code:t})=>{let{isCopied:n,copyToClipboard:r}=X1();return(0,P.jsxs)(`div`,{className:`aui-code-header-root border-border/50 bg-muted/50 mt-3 flex items-center justify-between rounded-t-xl border border-b-0 px-3.5 py-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`aui-code-header-language text-muted-foreground font-medium lowercase`,children:e}),(0,P.jsxs)(T$,{tooltip:`Copy`,onClick:()=>{t&&!n&&r(t)},children:[!n&&(0,P.jsx)(ae,{className:`animate-in zoom-in-75 fade-in duration-150`}),n&&(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})]})]})}});function e0({...e}){return(0,P.jsx)(tn,{"data-slot":`collapsible`,...e})}function t0({...e}){return(0,P.jsx)(Xt,{"data-slot":`collapsible-trigger`,...e})}function n0({...e}){return(0,P.jsx)(Qt,{"data-slot":`collapsible-content`,...e})}var r0=(0,N.createContext)(!1),i0=y(`aui-reasoning-root mb-4 w-full`,{variants:{variant:{outline:`rounded-lg border px-3 py-2`,ghost:``,muted:`bg-muted/50 rounded-lg px-3 py-2`}},defaultVariants:{variant:`outline`}});function a0({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,streaming:o,onAnimationStart:s,children:c,...l}){let[u]=(0,N.useState)(i),[d,f]=(0,N.useState)(null),p=n!==void 0,m=p?n:d??(o||u),h=o===!0&&m,g=(0,N.useRef)(o);(0,N.useLayoutEffect)(()=>{g.current!==o&&(g.current=o,!p&&d===null&&!u&&s?.())},[o,p,d,u,s]);let _=(0,N.useCallback)(e=>{s?.(),p||f(e),r?.(e)},[s,p,r]);return(0,P.jsx)(e0,{"data-slot":`reasoning-root`,"data-variant":t,open:m,onOpenChange:_,className:a(`group/reasoning-root`,i0({variant:t,className:e})),style:{"--animation-duration":`200ms`},...l,children:(0,P.jsx)(r0.Provider,{value:h,children:c})})}function o0({side:e=`bottom`,className:t,...n}){return e===`top`?(0,P.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-8`,`bg-[linear-gradient(to_bottom,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_bottom,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n}):(0,P.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8`,`bg-[linear-gradient(to_top,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_top,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n})}function s0({active:e,duration:t,className:n,...r}){let i=t?` (${t}s)`:``;return(0,P.jsxs)(t0,{"data-slot":`reasoning-trigger`,className:a(`aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground flex max-w-[75%] origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,P.jsx)(k,{"data-slot":`reasoning-trigger-icon`,className:`aui-reasoning-trigger-icon size-4 shrink-0`}),(0,P.jsxs)(`span`,{"data-slot":`reasoning-trigger-label`,className:a(`aui-reasoning-trigger-label-wrapper inline-block leading-none tabular-nums`,e&&`shimmer motion-reduce:animate-none`),children:[`Reasoning`,i]}),(0,P.jsx)(j,{"data-slot":`reasoning-trigger-chevron`,className:a(`aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function c0({className:e,children:t,...n}){let r=(0,N.useContext)(r0);return(0,P.jsxs)(n0,{"data-slot":`reasoning-content`,className:a(`aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:[(0,P.jsx)(o0,{side:`top`}),t,r?(0,P.jsx)(o0,{}):null]})}function l0({className:e,children:t,...n}){let r=(0,N.useContext)(r0),i=(0,N.useRef)(null),o=(0,N.useRef)(null);return(0,N.useEffect)(()=>{if(!r)return;let e=i.current,t=o.current;if(!e||!t)return;let n=!0,a=e.scrollTop,s=e.scrollHeight,c=()=>Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight,l=()=>{n&&(e.scrollTop=e.scrollHeight)},u=()=>{c()?n=!0:e.scrollTop<a&&e.scrollHeight===s&&(n=!1),a=e.scrollTop,s=e.scrollHeight};l(),e.addEventListener(`scroll`,u);let d=new ResizeObserver(l);return d.observe(t),()=>{e.removeEventListener(`scroll`,u),d.disconnect()}},[r]),(0,P.jsx)(`div`,{ref:i,"data-slot":`reasoning-text`,className:a(`aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty`,`transform-gpu transition-[transform,opacity] ease-[cubic-bezier(0.32,0.72,0,1)]`,`motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in`,`group-data-closed/collapsible-content:animate-out`,`group-data-open/collapsible-content:fade-in-0`,`group-data-closed/collapsible-content:fade-out-0`,`group-data-open/collapsible-content:slide-in-from-top-4`,`group-data-closed/collapsible-content:slide-out-to-top-4`,`group-data-open/collapsible-content:blur-in-[2px]`,`group-data-closed/collapsible-content:blur-out-[2px]`,`group-data-open/collapsible-content:animation-duration-(--animation-duration)`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration)`,e),...n,children:(0,P.jsx)(`div`,{ref:o,className:`aui-reasoning-text-content space-y-4`,children:t})})}function u0({ref:e,onAnimationStart:t,...n}){let r=(0,N.useRef)(null),i=MZ(r,200),a=(0,N.useCallback)(()=>{i(),t?.()},[i,t]),o=(0,N.useCallback)(t=>{r.current=t,typeof e==`function`?e(t):e&&(e.current=t)},[e]);return(0,P.jsx)(a0,{ref:o,onAnimationStart:a,...n})}var d0=()=>(0,P.jsx)(Q1,{}),f0=({children:e,startIndex:t,endIndex:n})=>{let r=$(e=>{if(e.message.status?.type!==`running`)return!1;for(let r=t;r<=n;r++)if(e.message.parts[r]?.status.type===`running`)return!0;return!1});return(0,P.jsxs)(u0,{streaming:r,children:[(0,P.jsx)(s0,{active:r}),(0,P.jsx)(c0,{"aria-busy":r,children:(0,P.jsx)(l0,{children:e})})]})},p0=(0,N.memo)(d0);p0.displayName=`Reasoning`,p0.Root=u0,p0.Trigger=s0,p0.Content=c0,p0.Text=l0,p0.Fade=o0;var m0=(0,N.memo)(f0);m0.displayName=`ReasoningGroup`;function h0({className:e,...t}){return(0,P.jsx)(`textarea`,{"data-slot":`textarea`,className:a(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var g0=200,_0=`active:scale-[0.98]`;function v0({className:e,open:t,onOpenChange:n,defaultOpen:r=!1,children:i,...o}){let s=(0,N.useRef)(null),[c,l]=(0,N.useState)(r),u=MZ(s,g0),d=t!==void 0,f=d?t:c,p=(0,N.useCallback)(e=>{u(),d||l(e),n?.(e)},[u,d,n]);return(0,P.jsx)(e0,{ref:s,"data-slot":`tool-fallback-root`,open:f,onOpenChange:p,className:a(`aui-tool-fallback-root group/tool-fallback-root w-full`,e),style:{"--animation-duration":`${g0}ms`},...o,children:i})}var y0={running:ge,complete:A,incomplete:ne,"requires-action":te},b0=e=>{if(e<1e3)return`<1s`;let t=e/1e3;return t<10?`${(Math.floor(t*10)/10).toFixed(1)}s`:t<60?`${Math.floor(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60)}s`};function x0({className:e,...t}){let n=NZ();return n===void 0?null:(0,P.jsx)(`span`,{"data-slot":`tool-fallback-duration`,className:a(`aui-tool-fallback-duration text-muted-foreground text-xs tabular-nums`,e),...t,children:b0(n)})}function S0({toolName:e,status:t,className:n,...r}){let i=t?.type??`complete`,o=i===`running`,s=t?.type===`incomplete`&&t.reason===`cancelled`,c=y0[i],l=s?`Cancelled tool`:`Used tool`;return(0,P.jsxs)(t0,{"data-slot":`tool-fallback-trigger`,className:a(`aui-tool-fallback-trigger group/trigger text-muted-foreground hover:text-foreground flex w-fit origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,P.jsx)(c,{"data-slot":`tool-fallback-trigger-icon`,className:a(`aui-tool-fallback-trigger-icon size-4 shrink-0`,s&&`text-muted-foreground`,o&&`animate-spin [animation-duration:0.6s]`)}),(0,P.jsxs)(`span`,{"data-slot":`tool-fallback-trigger-label`,className:a(`aui-tool-fallback-trigger-label-wrapper inline-block text-start leading-none`,s&&`text-muted-foreground line-through`,o&&`shimmer motion-reduce:animate-none`),children:[l,`: `,(0,P.jsx)(`b`,{children:e})]}),(0,P.jsx)(x0,{}),(0,P.jsx)(j,{"data-slot":`tool-fallback-trigger-chevron`,className:a(`aui-tool-fallback-trigger-chevron size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function C0({className:e,children:t,...n}){return(0,P.jsx)(n0,{"data-slot":`tool-fallback-content`,className:a(`aui-tool-fallback-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,P.jsx)(`div`,{className:a(`flex flex-col gap-2 ps-6 pt-1 pb-2 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in group-data-open/collapsible-content:fade-in-0 group-data-open/collapsible-content:blur-in-[2px] group-data-open/collapsible-content:slide-in-from-top-1`,`group-data-closed/collapsible-content:animate-out group-data-closed/collapsible-content:fade-out-0 group-data-closed/collapsible-content:blur-out-[2px] group-data-closed/collapsible-content:slide-out-to-top-1`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration) group-data-open/collapsible-content:animation-duration-(--animation-duration)`),children:t})})}function w0({argsText:e,className:t,...n}){return e?(0,P.jsx)(`div`,{"data-slot":`tool-fallback-args`,className:a(`aui-tool-fallback-args`,t),...n,children:(0,P.jsx)(`pre`,{className:`aui-tool-fallback-args-value bg-muted/50 text-foreground/90 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:e})}):null}var T0=(e,t)=>{if(typeof e==`string`)return e;try{if(e instanceof Error)return String(e);let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return`[Unserializable value]`}};function E0({result:e,className:t,...n}){return e===void 0?null:(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-result`,className:a(`aui-tool-fallback-result`,t),...n,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-result-header text-muted-foreground text-xs font-medium`,children:`Result:`}),(0,P.jsx)(`pre`,{className:`aui-tool-fallback-result-content bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:T0(e,2)})]})}function D0({status:e,className:t,...n}){if(e?.type!==`incomplete`)return null;let r=e.error,i=r==null?null:T0(r);if(!i)return null;let o=e.reason===`cancelled`?`Cancelled reason:`:`Error:`;return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-error`,className:a(`aui-tool-fallback-error`,t),...n,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-error-header text-muted-foreground font-semibold`,children:o}),(0,P.jsx)(`p`,{className:`aui-tool-fallback-error-reason text-muted-foreground whitespace-pre-line`,children:i})]})}var O0=`Approved by user`,k0=`User denied tool execution`,A0={"allow-once":`Allow`,"allow-always":`Always allow`,"reject-once":`Deny`,"reject-always":`Always deny`},j0=e=>Object.hasOwn(A0,e),M0=e=>e===`allow-once`||e===`allow-always`,N0=e=>e.label??(j0(e.kind)?A0[e.kind]:void 0)??e.id,P0=e=>e?.display===`select`||e?.display===`text`,F0=(e,t,n)=>e?.type!==`requires-action`||e.reason!==`interrupt`||t!=null||n!=null;function I0({className:e,addResult:t,resume:n,interrupt:r,approval:i,respondToApproval:o,status:c,...l}){let[u,d]=(0,N.useState)(!1),f=$(e=>e.thread.voice!==void 0),p=u||f,[m,h]=(0,N.useState)(null),[g,_]=(0,N.useState)(``),[v,y]=(0,N.useState)(null);if(i!=null&&(i.approved!==void 0||i.resolution!==void 0)||!F0(c,i,r))return null;let b=o?i?.options:void 0,x=i!=null&&o!=null&&UB(i),S=e=>{d(!0),y(null),(async()=>{try{await e()}catch(e){d(!1),y(e instanceof Error?e.message:String(e))}})()},C=e=>{if(!p){if(i!=null&&i.approved===void 0&&o)S(()=>o({approved:e,...T()}));else if(r)S(()=>n?.({approved:e}));else if(c?.type===`requires-action`&&c.reason===`interrupt`)return;else S(()=>t?.(e?O0:k0))}},w=e=>{p||(h(null),S(()=>o?.(j0(e.kind)?{optionId:e.id,...T()}:{optionId:e.id,approved:!0,...T()})))},T=()=>g.trim()?{text:g}:{},E=()=>{p||S(()=>o?.({text:g}))},D=()=>{p||S(()=>o?.({approved:!1}))},O=e=>{e.confirm?h(e.id):w(e)},k=m==null?void 0:b?.find(e=>e.id===m),A=P0(i),j=A&&o!=null&&i?.dismissible===!0?(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:_0,onClick:D,disabled:p,children:`Dismiss`}):null,M=i?.prompt?(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-foreground whitespace-pre-line`,children:i.prompt}):null,ee=v?(0,P.jsx)(`p`,{role:`alert`,className:`aui-tool-fallback-approval-error text-destructive text-xs whitespace-pre-line`,children:v}):null,te=x?(0,P.jsxs)(`div`,{className:`aui-tool-fallback-approval-answer flex flex-col items-start gap-2`,children:[(0,P.jsx)(h0,{value:g,onChange:e=>_(e.target.value),disabled:p,"aria-label":A?i?.prompt??`Answer`:`Note`,placeholder:A?`Type your answer`:`Add a note to your decision`}),A&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:_0,onClick:E,disabled:p,children:`Send`}),j]})]}):null;if(k){let t=typeof k.confirm==`object`?k.confirm:void 0,n=t?.description??k.description;return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval-confirm`,className:a(`aui-tool-fallback-approval-confirm flex flex-col gap-2 pt-1`,e),...l,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-title font-semibold`,children:t?.title??`${N0(k)}?`}),n&&(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-description text-muted-foreground whitespace-pre-line`,children:n}),k.grants&&k.grants.length>0&&(0,P.jsx)(`ul`,{className:`aui-tool-fallback-approval-confirm-grants flex flex-col gap-1`,children:k.grants.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(`code`,{className:`aui-tool-fallback-approval-confirm-grant bg-muted rounded px-1.5 py-0.5 text-xs`,children:e})},e))}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:_0,onClick:()=>w(k),disabled:p,children:`Confirm`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:_0,onClick:()=>h(null),disabled:p,children:`Back`})]})]})}if(b&&b.length>0){let t=b.filter(e=>M0(e.kind)),n=b.filter(e=>!j0(e.kind)),r=b.filter(e=>j0(e.kind)&&!M0(e.kind));return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[...t,...n,...r].map(e=>(0,P.jsx)(s,{size:`sm`,variant:e===t[0]?`default`:`outline`,className:_0,onClick:()=>O(e),disabled:p,children:N0(e)},e.id)),r.length===0&&!A&&(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:_0,onClick:()=>C(!1),disabled:p,children:`Deny`}),!x&&j]}),te,ee]})}return A?(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,te,!x&&j&&(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:j}),ee]}):(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:_0,onClick:()=>C(!0),disabled:p,children:`Allow`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:_0,onClick:()=>C(!1),disabled:p,children:`Deny`})]}),te,ee]})}var L0=(0,N.memo)(({toolName:e,argsText:t,result:n,status:r,addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l})=>{let u=r?.type===`incomplete`&&r.reason===`cancelled`,d=r?.type===`requires-action`,f=d&&F0(r,c,s),[p,m]=(0,N.useState)(d),[h,g]=(0,N.useState)(d);return d!==h&&(g(d),d&&m(!0)),(0,P.jsxs)(v0,{open:p,onOpenChange:m,children:[(0,P.jsx)(S0,{toolName:e,status:r}),(0,P.jsxs)(C0,{children:[(0,P.jsx)(D0,{status:r}),(0,P.jsx)(w0,{argsText:t,className:a(u&&`opacity-60`)}),f&&(0,P.jsx)(I0,{addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l,status:r}),(0,P.jsx)(E0,{result:n})]})]})});L0.displayName=`ToolFallback`,L0.Root=v0,L0.Trigger=S0,L0.Content=C0,L0.Args=w0,L0.Result=E0,L0.Error=D0,L0.Approval=I0;var R0=200,z0=y(`aui-tool-group-root group/tool-group w-full`,{variants:{variant:{outline:`rounded-lg border py-3`,ghost:``,muted:`border-muted-foreground/30 bg-muted/30 rounded-lg border py-3`}},defaultVariants:{variant:`outline`}});function B0({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,children:o,...s}){let c=(0,N.useRef)(null),[l,u]=(0,N.useState)(i),d=MZ(c,R0),f=n!==void 0,p=f?n:l,m=(0,N.useCallback)(e=>{d(),f||u(e),r?.(e)},[d,f,r]);return(0,P.jsx)(e0,{ref:c,"data-slot":`tool-group-root`,"data-variant":t??`outline`,open:p,onOpenChange:m,className:a(z0({variant:t}),`group/tool-group-root`,e),style:{"--animation-duration":`${R0}ms`},...s,children:o})}function V0({count:e,active:t=!1,className:n,...r}){let i=`${e} tool ${e===1?`call`:`calls`}`;return(0,P.jsxs)(t0,{"data-slot":`tool-group-trigger`,className:a(`aui-tool-group-trigger group/trigger flex origin-left items-center gap-2 text-sm transition-[color,scale] active:scale-[0.98]`,`group-data-[variant=ghost]/tool-group-root:text-muted-foreground group-data-[variant=ghost]/tool-group-root:hover:text-foreground group-data-[variant=ghost]/tool-group-root:py-1.5`,`group-data-[variant=outline]/tool-group-root:w-full group-data-[variant=outline]/tool-group-root:px-4`,`group-data-[variant=muted]/tool-group-root:w-full group-data-[variant=muted]/tool-group-root:px-4`,n),...r,children:[t&&(0,P.jsx)(ge,{"data-slot":`tool-group-trigger-loader`,className:`aui-tool-group-trigger-loader size-3 shrink-0 animate-spin [animation-duration:0.6s]`}),(0,P.jsx)(`span`,{"data-slot":`tool-group-trigger-label`,className:a(`aui-tool-group-trigger-label-wrapper inline-block text-start text-xs leading-none font-medium`,`group-data-[variant=ghost]/tool-group-root:font-normal`,`group-data-[variant=outline]/tool-group-root:grow`,`group-data-[variant=muted]/tool-group-root:grow`,t&&`shimmer motion-reduce:animate-none`),children:i}),(0,P.jsx)(j,{"data-slot":`tool-group-trigger-chevron`,className:a(`aui-tool-group-trigger-chevron size-3 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function H0({className:e,children:t,...n}){return(0,P.jsx)(n0,{"data-slot":`tool-group-content`,className:a(`aui-tool-group-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,P.jsx)(`div`,{className:a(`mt-2 flex flex-col gap-2`,`group-data-[variant=ghost]/tool-group-root:mt-1 group-data-[variant=ghost]/tool-group-root:gap-1`,`group-data-[variant=outline]/tool-group-root:mt-3 group-data-[variant=outline]/tool-group-root:border-t group-data-[variant=outline]/tool-group-root:px-4 group-data-[variant=outline]/tool-group-root:pt-3`,`group-data-[variant=muted]/tool-group-root:mt-3 group-data-[variant=muted]/tool-group-root:border-t group-data-[variant=muted]/tool-group-root:px-4 group-data-[variant=muted]/tool-group-root:pt-3`,`[&>*]:animate-in [&>*]:fade-in-0 [&>*]:blur-in-[2px] [&>*]:slide-in-from-top-1 [&>*]:animation-duration-(--animation-duration) [&>*]:ease-[cubic-bezier(0.32,0.72,0,1)]`,`[&>*]:motion-reduce:animate-none`,`[&>*:nth-child(2)]:[animation-delay:40ms]`,`[&>*:nth-child(3)]:[animation-delay:80ms]`,`[&>*:nth-child(4)]:[animation-delay:120ms]`,`[&>*:nth-child(n+5)]:[animation-delay:160ms]`),children:t})})}var U0=(0,N.memo)(({children:e,startIndex:t,endIndex:n})=>{let r=n-t+1;return(0,P.jsxs)(B0,{children:[(0,P.jsx)(V0,{count:r}),(0,P.jsx)(H0,{children:e})]})});U0.displayName=`ToolGroup`,U0.Root=B0,U0.Trigger=V0,U0.Content=H0;function W0({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`skeleton`,className:a(`animate-pulse rounded-md bg-accent`,e),...t})}var G0=QU({reasoning:[`group-chainOfThought`,`group-reasoning`],"tool-call":[`group-chainOfThought`,`group-tool`],"standalone-tool-call":[]}),K0=[`group-chainOfThought`,`group-task`],q0=(e,t)=>{let n=G0(e,t);return e.type===`tool-call`&&e.messages!==void 0&&n.length>0&&!t?.toolUIs?.[e.toolName]?.length?K0:n},J0={},Y0=(0,N.createContext)(J0),X0=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading),Z0=e=>e.thread.messages.length===0&&e.thread.isLoading&&!e.thread.isDisabled&&!e.threads.isLoading,Q0=()=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-history-skeleton`,role:`status`,className:`animate-in fade-in fill-mode-both flex flex-col gap-y-6 [animation-delay:150ms] [animation-duration:200ms]`,children:[(0,P.jsx)(`span`,{className:`sr-only`,children:`Loading conversation`}),(0,P.jsx)(W0,{className:`ml-auto h-9 w-2/5 rounded-xl motion-reduce:animate-none`}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,P.jsx)(W0,{className:`h-4 w-11/12 motion-reduce:animate-none`}),(0,P.jsx)(W0,{className:`h-4 w-4/5 motion-reduce:animate-none`}),(0,P.jsx)(W0,{className:`h-4 w-3/5 motion-reduce:animate-none`})]}),(0,P.jsx)(W0,{className:`ml-auto h-9 w-1/3 rounded-xl motion-reduce:animate-none`}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,P.jsx)(W0,{className:`h-4 w-10/12 motion-reduce:animate-none`}),(0,P.jsx)(W0,{className:`h-4 w-2/3 motion-reduce:animate-none`})]})]}),$0=({components:e=J0,autoFocus:t=!0})=>{let n=$(X0);return(0,P.jsx)(Y0.Provider,{value:e,children:(0,P.jsx)(e2,{isEmpty:n,autoFocus:t})})},e2=({isEmpty:e,autoFocus:t})=>{let{Welcome:n=s2}=(0,N.useContext)(Y0);return(0,P.jsx)(YX.Root,{className:`aui-root aui-thread-root bg-background @container flex h-full flex-col`,style:{"--thread-max-width":`44rem`,"--composer-bg":`color-mix(in oklab, var(--color-muted) 30%, transparent)`,"--composer-radius":`1rem`,"--composer-padding":`8px`},children:(0,P.jsx)(YX.Viewport,{turnAnchor:`top`,"data-slot":`aui_thread-viewport`,className:`relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth`,children:(0,P.jsxs)(`div`,{className:a(`mx-auto flex w-full max-w-(--thread-max-width) flex-1 flex-col px-4 pt-4`,e&&`justify-center`),children:[(0,P.jsx)(ZI,{condition:X0,children:(0,P.jsx)(n,{})}),(0,P.jsx)(ZI,{condition:Z0,children:(0,P.jsx)(Q0,{})}),(0,P.jsx)(`div`,{"data-slot":`aui_message-group`,className:`mb-14 flex flex-col gap-y-6 empty:hidden`,children:(0,P.jsx)(YX.Messages,{children:()=>(0,P.jsx)(t2,{})})}),(0,P.jsxs)(YX.ViewportFooter,{className:a(`aui-thread-viewport-footer bg-background flex flex-col gap-4 overflow-visible pb-4 md:pb-6`,!e&&`sticky bottom-0 mt-auto rounded-t-(--composer-radius)`),children:[(0,P.jsx)(o2,{}),(0,P.jsx)(n1,{}),(0,P.jsx)(u2,{autoFocus:t}),(0,P.jsx)(ZI,{condition:e=>X0(e)&&e.composer.isEmpty,children:(0,P.jsx)(c2,{})})]})]})})})},t2=()=>{let{AssistantMessage:e=p2}=(0,N.useContext)(Y0),t=$(e=>e.message.role),n=$(e=>e.message.composer.isEditing),r=$(e=>e.message.metadata.modality===`voice`);return n?(0,P.jsx)(y2,{}):r?(0,P.jsx)(i2,{}):t===`user`?(0,P.jsx)(_2,{}):(0,P.jsx)(e,{})},n2=()=>$(e=>{let t=e.thread.messages[e.message.index-1]?.metadata.modality===`voice`,n=e.thread.messages[e.message.index+1]?.metadata.modality===`voice`;return t?n?`middle`:`end`:n?`start`:`single`}),r2=({text:e})=>(0,P.jsx)(`p`,{className:`aui-spoken-message-text m-0`,children:e}),i2=()=>{let e=$(e=>e.message.role),t=n2(),n=$(e=>e.message.role===`assistant`&&e.message.status?.type===`running`),r=t===`start`||t===`single`;return(0,P.jsxs)(dX.Root,{"data-slot":`aui_spoken-message-root`,"data-role":e,"data-voice-run":t,className:a(`aui-spoken-message bg-muted/40 mx-2 px-3 py-1.5 [contain-intrinsic-size:auto_48px] [content-visibility:auto]`,t===`single`&&`rounded-xl py-2`,t===`start`&&`rounded-t-xl pt-2`,t===`middle`&&`-mt-6`,t===`end`&&`-mt-6 rounded-b-xl pb-2`),children:[r&&(0,P.jsxs)(`div`,{"data-slot":`aui_spoken-exchange-header`,className:`text-muted-foreground mb-1.5 flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(xe,{className:`size-3`,"aria-hidden":!0}),(0,P.jsx)(`span`,{children:`Voice conversation`})]}),(0,P.jsxs)(`div`,{"data-slot":`aui_spoken-message-content`,className:`text-foreground flex items-start gap-2 text-sm leading-relaxed`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground mt-1 shrink-0`,"aria-hidden":!0,children:e===`user`?(0,P.jsx)(_e,{className:`size-3.5`}):(0,P.jsx)(D,{className:`size-3.5`})}),(0,P.jsx)(`span`,{className:`sr-only`,children:e===`user`?`You said`:`Assistant said`}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1 wrap-break-word`,children:[(0,P.jsx)(dX.Parts,{components:{Text:r2}}),n&&(0,P.jsx)(`span`,{"data-slot":`aui_spoken-message-indicator`,role:`status`,className:`text-muted-foreground ms-1 animate-pulse font-sans`,"aria-label":`Assistant is speaking`,children:`●`})]}),(0,P.jsx)(a2,{})]})]})},a2=()=>(0,P.jsx)(AK.Root,{hideWhenRunning:!0,autohide:`always`,className:`aui-spoken-action-bar text-muted-foreground flex shrink-0 gap-1`,children:(0,P.jsx)(AK.Copy,{asChild:!0,children:(0,P.jsxs)(T$,{tooltip:`Copy`,className:`size-6`,children:[(0,P.jsx)(ZI,{condition:e=>e.message.isCopied,children:(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(ZI,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(ae,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})})}),o2=()=>(0,P.jsx)(YX.ScrollToBottom,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Scroll to bottom`,variant:`outline`,className:`aui-thread-scroll-to-bottom dark:border-border dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible`,children:(0,P.jsx)(C,{})})}),s2=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-root mb-6 flex flex-col px-2`,children:(0,P.jsx)(`p`,{className:`aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-medium tracking-tight duration-200`,children:`How can I help you today?`})}),c2=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-suggestions flex w-full flex-col`,children:(0,P.jsx)(YX.Suggestions,{children:()=>(0,P.jsx)(l2,{})})}),l2=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-2 animate-in fill-mode-both duration-200`,children:(0,P.jsx)(nZ.Trigger,{send:!0,asChild:!0,children:(0,P.jsxs)(`button`,{type:`button`,className:`aui-thread-welcome-suggestion group hover:bg-foreground/[0.03] focus-visible:ring-ring/50 flex w-full items-baseline gap-2.5 rounded-md px-2 py-2 text-start text-sm transition-colors outline-none focus-visible:ring-1 motion-reduce:transition-none`,children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 group-hover:text-foreground font-mono text-xs transition-colors motion-reduce:transition-none`,children:`>`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,P.jsx)(nZ.Title,{className:`aui-thread-welcome-suggestion-text-1 text-foreground`}),` `,(0,P.jsx)(nZ.Description,{className:`aui-thread-welcome-suggestion-text-2 text-muted-foreground empty:hidden`})]})]})})}),u2=({autoFocus:e})=>(0,P.jsx)($J.Root,{className:`aui-composer-root relative flex w-full flex-col`,children:(0,P.jsx)($J.AttachmentDropzone,{asChild:!0,children:(0,P.jsxs)(`div`,{"data-slot":`aui_composer-shell`,className:`border-foreground/10 focus-within:border-foreground/25 data-[dragging=true]:border-ring flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]`,children:[(0,P.jsx)(B$,{}),(0,P.jsx)($J.Input,{placeholder:`Send a message...`,className:`aui-composer-input caret-primary placeholder:text-muted-foreground/60 max-h-48 min-h-10 w-full resize-none bg-transparent px-2.5 py-1 text-base leading-6 outline-none`,rows:1,autoFocus:e,enterKeyHint:`send`,"aria-label":`Message input`}),(0,P.jsx)(d2,{})]})})}),d2=()=>(0,P.jsxs)(`div`,{className:`aui-composer-action-wrapper relative flex items-center justify-between`,children:[(0,P.jsx)(V$,{}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsxs)(ZI,{condition:e=>e.thread.capabilities.dictation,children:[(0,P.jsx)(ZI,{condition:e=>e.composer.dictation==null,children:(0,P.jsx)($J.Dictate,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Voice input`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-dictate text-muted-foreground hover:text-foreground size-7 rounded-full`,"aria-label":`Start voice input`,children:(0,P.jsx)(_e,{className:`aui-composer-dictate-icon size-4`})})})}),(0,P.jsx)(ZI,{condition:e=>e.composer.dictation!=null,children:(0,P.jsx)($J.StopDictation,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Stop dictation`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-stop-dictation text-destructive size-7 rounded-full`,"aria-label":`Stop voice input`,children:(0,P.jsx)(Oe,{className:`aui-composer-stop-dictation-icon size-3.5 animate-pulse fill-current`})})})})]}),(0,P.jsx)(ZI,{condition:e=>!e.thread.isRunning||e.thread.voice!==void 0,children:(0,P.jsx)($J.Send,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Send message`,side:`bottom`,type:`button`,variant:`default`,size:`icon`,className:`aui-composer-send size-7 rounded-full`,"aria-label":`Send message`,children:(0,P.jsx)(E,{className:`aui-composer-send-icon size-4`})})})}),(0,P.jsx)(ZI,{condition:e=>e.thread.isRunning&&e.thread.voice===void 0,children:(0,P.jsx)($J.Cancel,{asChild:!0,children:(0,P.jsx)(s,{type:`button`,variant:`default`,size:`icon`,className:`aui-composer-cancel size-7 rounded-full`,"aria-label":`Stop generating`,children:(0,P.jsx)(Oe,{className:`aui-composer-cancel-icon size-3.5 fill-current`})})})})]})]}),f2=()=>(0,P.jsx)(dX.Error,{children:(0,P.jsx)(TY.Root,{className:`aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200`,children:(0,P.jsx)(TY.Message,{className:`aui-message-error-message line-clamp-2`})})}),p2=()=>{let{ToolFallback:e=L0,ToolGroup:t,ReasoningGroup:n,TaskGroup:r}=(0,N.useContext)(Y0),i=r?q0:G0;return(0,P.jsxs)(dX.Root,{"data-slot":`aui_assistant-message-root`,"data-role":`assistant`,className:`fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:[(0,P.jsxs)(`div`,{"data-slot":`aui_assistant-message-content`,className:`text-foreground px-2 leading-relaxed wrap-break-word`,children:[(0,P.jsx)(dX.GroupedParts,{groupBy:i,children:({part:i,children:a})=>{switch(i.type){case`group-chainOfThought`:return(0,P.jsx)(`div`,{"data-slot":`aui_chain-of-thought`,children:a});case`group-task`:return r?(0,P.jsx)(r,{group:i}):null;case`group-tool`:return t?(0,P.jsx)(t,{group:i,children:a}):(0,P.jsxs)(B0,{variant:`ghost`,children:[(0,P.jsx)(V0,{count:i.indices.length,active:i.status.type===`running`}),(0,P.jsx)(H0,{children:a})]});case`group-reasoning`:{if(n)return(0,P.jsx)(n,{group:i,children:a});let e=i.status.type===`running`;return(0,P.jsxs)(u0,{streaming:e,children:[(0,P.jsx)(s0,{active:e}),(0,P.jsx)(c0,{"aria-busy":e,children:(0,P.jsx)(l0,{children:a})})]})}case`text`:return(0,P.jsx)(Q1,{});case`reasoning`:return(0,P.jsx)(p0,{...i});case`tool-call`:return i.toolUI??(0,P.jsx)(e,{...i});case`data`:return i.dataRendererUI;case`file`:return(0,P.jsx)(`div`,{"data-slot":`aui_assistant-message-file`,className:`py-1`,children:(0,P.jsx)(e1,{...i})});case`image`:return(0,P.jsx)(`div`,{"data-slot":`aui_assistant-message-image`,className:`py-1`,children:(0,P.jsx)(_1,{...i})});case`indicator`:return(0,P.jsx)(`span`,{"data-slot":`aui_assistant-message-indicator`,className:`animate-pulse font-sans`,"aria-label":`Assistant is working`,children:`●`});default:return null}}}),(0,P.jsx)(f2,{})]}),(0,P.jsxs)(`div`,{"data-slot":`aui_assistant-message-footer`,className:a(`ms-2 flex items-center`,`min-h-7.5 pt-1.5`),children:[(0,P.jsx)(b2,{}),(0,P.jsx)(m2,{})]})]})},m2=()=>(0,P.jsxs)(AK.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-assistant-action-bar-root text-muted-foreground animate-in fade-in col-start-3 row-start-2 -ms-1 flex gap-1 duration-200`,children:[(0,P.jsx)(AK.Copy,{asChild:!0,children:(0,P.jsxs)(T$,{tooltip:`Copy`,children:[(0,P.jsx)(ZI,{condition:e=>e.message.isCopied,children:(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(ZI,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(ae,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})}),(0,P.jsxs)(ZI,{condition:e=>e.thread.capabilities.feedback,children:[(0,P.jsx)(AK.FeedbackPositive,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(Me,{})})}),(0,P.jsx)(AK.FeedbackNegative,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Not helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(je,{})})})]}),(0,P.jsx)(AK.Reload,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Refresh`,children:(0,P.jsx)(Ce,{})})}),(0,P.jsxs)(VK.Root,{children:[(0,P.jsx)(VK.Trigger,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`More`,className:`data-[state=open]:bg-accent`,children:(0,P.jsx)(se,{})})}),(0,P.jsx)(VK.Content,{side:`bottom`,align:`start`,sideOffset:6,className:`aui-action-bar-more-content bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-[8rem] overflow-hidden rounded-xl border p-1.5`,children:(0,P.jsx)(AK.ExportMarkdown,{asChild:!0,children:(0,P.jsxs)(VK.Item,{className:`aui-action-bar-more-item hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(oe,{className:`size-4`}),`Export as Markdown`]})})})]})]}),h2=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-file`,className:`py-1`,children:(0,P.jsx)(e1,{...e})}),g2=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-image`,className:`py-1`,children:(0,P.jsx)(_1,{...e})}),_2=()=>(0,P.jsxs)(dX.Root,{"data-slot":`aui_user-message-root`,className:`fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto] [&:where(>*)]:col-start-2`,"data-role":`user`,children:[(0,P.jsx)(z$,{}),(0,P.jsxs)(`div`,{className:`aui-user-message-content-wrapper relative col-start-2 min-w-0`,children:[(0,P.jsx)(`div`,{className:`aui-user-message-content peer bg-muted text-foreground rounded-(--composer-radius) px-4 py-2 wrap-break-word empty:hidden`,children:(0,P.jsx)(dX.Parts,{components:{File:h2,Image:g2}})}),(0,P.jsx)(`div`,{className:`aui-user-action-bar-wrapper absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-2 peer-empty:hidden rtl:translate-x-full`,children:(0,P.jsx)(v2,{})})]}),(0,P.jsx)(b2,{"data-slot":`aui_user-branch-picker`,className:`col-span-full col-start-1 -me-1 justify-end`})]}),v2=()=>(0,P.jsx)(AK.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-user-action-bar-root flex flex-col items-end`,children:(0,P.jsx)(AK.Edit,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Edit`,className:`aui-user-action-edit`,children:(0,P.jsx)(be,{})})})}),y2=()=>(0,P.jsx)(dX.Root,{"data-slot":`aui_edit-composer-wrapper`,className:`flex flex-col px-2 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:(0,P.jsxs)($J.Root,{className:`aui-edit-composer-root border-foreground/10 focus-within:border-foreground/25 ms-auto flex w-full max-w-[85%] cursor-text flex-col rounded-(--composer-radius) border bg-(--composer-bg) transition-[border-color]`,children:[(0,P.jsx)($J.Input,{className:`aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none`,autoFocus:!0}),(0,P.jsxs)(`div`,{className:`aui-edit-composer-footer mx-2.5 mb-2.5 flex items-center gap-1.5 self-end`,children:[(0,P.jsx)($J.Cancel,{asChild:!0,children:(0,P.jsx)(s,{variant:`ghost`,size:`sm`,className:`h-8 px-3`,children:`Cancel`})}),(0,P.jsx)($J.Send,{asChild:!0,children:(0,P.jsx)(s,{size:`sm`,className:`h-8 px-3`,children:`Update`})})]})]})}),b2=({className:e,...t})=>(0,P.jsxs)(iq.Root,{hideWhenSingleBranch:!0,className:a(`aui-branch-picker-root text-muted-foreground -ms-2 me-2 inline-flex items-center text-xs`,e),...t,children:[(0,P.jsx)(iq.Previous,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Previous`,children:(0,P.jsx)(M,{})})}),(0,P.jsxs)(`span`,{className:`aui-branch-picker-state font-medium`,children:[(0,P.jsx)(iq.Number,{}),` / `,(0,P.jsx)(iq.Count,{})]}),(0,P.jsx)(iq.Next,{asChild:!0,children:(0,P.jsx)(T$,{tooltip:`Next`,children:(0,P.jsx)(ee,{})})})]}),x2=()=>{let[e,t]=(0,N.useState)(``),n=$(e=>e.threads.threadIds.length>0);return(0,P.jsxs)(C2,{children:[(0,P.jsx)(A2,{}),n&&(0,P.jsx)(S2,{value:e,onValueChange:t}),(0,P.jsx)(w2,{searchQuery:n?e:``})]})},S2=(0,N.forwardRef)(({className:e,value:t,onValueChange:n,...r},i)=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-list-search`,className:`relative px-0.5 py-1`,children:[(0,P.jsx)(Te,{"data-slot":`aui_thread-list-search-icon`,className:`text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2`}),(0,P.jsx)(m,{ref:i,type:`search`,value:t,onChange:e=>n(e.target.value),"aria-label":`Search threads`,placeholder:`Search threads`,className:a(`h-8 ps-8 text-sm`,e),...r})]}));S2.displayName=`ThreadListSearch`;var C2=({className:e,...t})=>(0,P.jsx)(pZ.Root,{"data-slot":`aui_thread-list-root`,className:a(`flex flex-col gap-0.5`,e),...t}),w2=({className:e,searchQuery:t=``,...n})=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-list-items`,className:a(`flex flex-col gap-0.5`,e),...n,children:[(0,P.jsx)(ZI,{condition:e=>e.threads.isLoading,children:(0,P.jsx)(j2,{})}),(0,P.jsx)(ZI,{condition:e=>!e.threads.isLoading,children:(0,P.jsx)(O2,{searchQuery:t})})]}),T2=864e5,E2=(e,t)=>!e||e.getTime()>=t?`Today`:e.getTime()>=t-T2?`Yesterday`:`Earlier`,D2=(e=``)=>{let t=$(e=>e.threads.threadIds),n=$(e=>e.threads.threadItems),r=e.trim().toLowerCase();return(0,N.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e])),i=t=>!r||(e.get(t)?.title||`New Chat`).toLowerCase().includes(r),a=t=>e.get(t)?.status===`archived`,o=t.map(t=>e.get(t)?.lastMessageAt),s=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&!a(e)).map(({index:e})=>e),c=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&a(e)).map(({index:e})=>e);if(!s.some(e=>o[e]))return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:null};let l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),d=e=>o[e]?.getTime()??2**53-1,f=[...s].sort((e,t)=>d(t)-d(e)),p=[];for(let e of f){let t=E2(o[e],u),n=p[p.length-1];n?.label===t?n.indices.push(e):p.push({label:t,indices:[e]})}return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:p}},[t,n,r])},O2=({searchQuery:e=``})=>{let{threadIds:t,filteredIndices:n,archivedIndices:r,groups:i}=D2(e);return e.trim()&&n.length===0&&r.length===0?(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-empty`,className:`text-muted-foreground px-2.5 py-4 text-sm`,children:`No threads found`}):i?(0,P.jsxs)(P.Fragment,{children:[i.map(e=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:e.label}),e.indices.map(e=>(0,P.jsx)(pZ.ItemByIndex,{index:e,components:{ThreadListItem:M2}},t[e]))]},e.label)),(0,P.jsx)(k2,{threadIds:t,indices:r})]}):(0,P.jsxs)(P.Fragment,{children:[n.map(e=>(0,P.jsx)(pZ.ItemByIndex,{index:e,components:{ThreadListItem:M2}},t[e])),(0,P.jsx)(k2,{threadIds:t,indices:r})]})},k2=({threadIds:e,indices:t})=>t.length?(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:`Archived`}),t.map(t=>(0,P.jsx)(pZ.ItemByIndex,{index:t,components:{ThreadListItem:M2}},e[t]))]}):null,A2=(0,N.forwardRef)(({className:e,labelClassName:t,children:n,...r},i)=>(0,P.jsx)(pZ.New,{asChild:!0,children:(0,P.jsx)(s,{ref:i,variant:`ghost`,"data-slot":`aui_thread-list-new`,className:a(`hover:bg-muted data-active:bg-muted h-8 justify-start gap-2 rounded-md px-2.5 text-sm font-normal`,e),...r,children:n??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Se,{"data-slot":`aui_thread-list-new-icon`,className:`size-4 shrink-0`}),(0,P.jsx)(`span`,{"data-slot":`aui_thread-list-new-label`,className:a(`whitespace-nowrap`,t),children:`New Thread`})]})})}));A2.displayName=`ThreadListNew`;var j2=()=>(0,P.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:Array.from({length:5},(e,t)=>(0,P.jsx)(`div`,{role:`status`,"aria-label":`Loading threads`,"data-slot":`aui_thread-list-skeleton-wrapper`,className:`flex h-8 items-center px-2.5`,children:(0,P.jsx)(W0,{"data-slot":`aui_thread-list-skeleton`,className:`h-3.5 w-full`})},t))}),M2=()=>{let e=$(e=>e.threadListItem.isRunning),t=$(e=>e.threadListItem.status)===`archived`,[n,r]=(0,N.useState)(!1),i=(0,N.useRef)(null),o=(0,N.useRef)(!1);return(0,N.useEffect)(()=>{!n&&o.current&&(o.current=!1,i.current?.focus())},[n]),(0,P.jsxs)(bZ.Root,{"data-slot":`aui_thread-list-item`,"data-archived":t||void 0,className:a(`group hover:bg-muted focus-visible:bg-muted data-active:bg-muted has-focus-visible:bg-muted has-data-[state=open]:bg-muted relative flex h-8 items-center rounded-md transition-colors focus-visible:outline-none`,t&&`opacity-60`),children:[n?(0,P.jsx)(N2,{onDone:e=>{o.current=e,r(!1)}}):(0,P.jsxs)(bZ.Trigger,{ref:i,"data-slot":`aui_thread-list-item-trigger`,className:`focus-visible:ring-ring/50 flex h-full min-w-0 flex-1 items-center rounded-md px-2.5 text-start text-sm outline-none group-hover:pe-9 group-has-focus-visible:pe-9 group-has-data-[state=open]:pe-9 group-data-active:pe-9 focus-visible:ring-1`,children:[e&&(0,P.jsx)(he,{"aria-hidden":!0,"data-slot":`aui_thread-list-item-running`,className:`text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin`}),(0,P.jsx)(`span`,{"data-slot":`aui_thread-list-item-title`,className:`min-w-0 flex-1 truncate`,children:(0,P.jsx)(bZ.Title,{fallback:`New Chat`})}),e&&(0,P.jsx)(`span`,{className:`sr-only`,children:`Running`})]}),(0,P.jsx)(P2,{archived:t,onRename:()=>r(!0)})]})},N2=({onDone:e})=>{let t=Q(),n=$(e=>e.threadListItem.title)??``,[r,i]=(0,N.useState)(n),a=(0,N.useRef)(null),o=(0,N.useRef)(!1);(0,N.useEffect)(()=>{a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0;let s=r.trim();if(!s||s===n){e(i);return}Promise.resolve().then(()=>t.threadListItem.rename(s)).then(()=>e(i),()=>{o.current=!1,i&&a.current?.focus()})},c=()=>{o.current||(o.current=!0,e(!0))};return(0,P.jsx)(m,{ref:a,autoFocus:!0,"data-slot":`aui_thread-list-item-rename`,"aria-label":`Rename thread`,value:r,className:`h-7 min-w-0 flex-1 ps-2.5 pe-9 text-sm`,onChange:e=>i(e.target.value),onBlur:()=>s(!1),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s(!0)):e.key===`Escape`&&(e.preventDefault(),c())}})},P2=({archived:e,onRename:t})=>(0,P.jsxs)(jZ.Root,{sharedFocusGroup:!0,children:[(0,P.jsx)(jZ.Trigger,{asChild:!0,children:(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,"data-slot":`aui_thread-list-item-more`,className:`data-[state=open]:bg-accent absolute end-1.5 top-1/2 size-6 -translate-y-1/2 p-0 opacity-0 group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 data-[state=open]:opacity-100`,children:[(0,P.jsx)(se,{className:`size-3.5`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`More options`})]})}),(0,P.jsxs)(jZ.Content,{side:`right`,align:`start`,sideOffset:6,"data-slot":`aui_thread-list-item-more-content`,className:`bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-32 overflow-hidden rounded-xl border p-1.5`,children:[(0,P.jsxs)(jZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,onSelect:t,children:[(0,P.jsx)(be,{className:`size-4`}),`Rename`]}),e?(0,P.jsx)(bZ.Unarchive,{asChild:!0,children:(0,P.jsxs)(jZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(x,{className:`size-4`}),`Unarchive`]})}):(0,P.jsx)(bZ.Archive,{asChild:!0,children:(0,P.jsxs)(jZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(S,{className:`size-4`}),`Archive`]})}),(0,P.jsx)(bZ.Delete,{asChild:!0,children:(0,P.jsxs)(jZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive focus:bg-destructive/10 focus:text-destructive flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(Ne,{className:`size-4`}),`Delete`]})})]})]}),F2=`bg-background border border-border/60 dark:bg-popover`;function I2({phase:e,attempt:t,resumedTokens:n,onRetry:r,className:i,...o}){return e===`online`?null:(0,P.jsxs)(`div`,{"data-slot":`connection-state`,className:a(F2,`fade-in slide-in-from-top-1 animate-in flex w-full max-w-sm items-center gap-2.5 rounded-2xl px-3.5 py-2.5 duration-300`,i),...o,children:[e===`dropped`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ie,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Connection lost. The run kept going on the server.`}),(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`text-foreground/70 hover:bg-foreground/[0.06] hover:text-foreground/95 shrink-0 rounded-full px-2.5 py-1 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]`,children:`Reconnect`})]}),e===`reconnecting`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(he,{className:`text-foreground/40 size-3.5 shrink-0 animate-spin motion-reduce:animate-none`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Reconnecting`}),t!==void 0&&(0,P.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`attempt `,t]})]}),e===`resumed`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(A,{className:`size-3.5 shrink-0 text-emerald-500`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Picked the stream back up.`}),n!==void 0&&(0,P.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`+`,n,` tokens`]})]})]})}var L2=[`pending`,`testing`,`confirmed`,`rejected`,`blocked`],R2=H(L2),z2=V({tasks:B(V({id:R(),title:R(),status:R2.default(`pending`),note:R().optional()})),target:R().optional(),phase:R().optional()}),B2={tasks:[]};function V2(e){return typeof e==`string`&&L2.includes(e)}function H2(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[^a-z_-]/g,``);if(t===`pending`||t===`todo`||t===`hypothesis`||t===`planned`||t===`open`)return`pending`;if(t===`testing`||t===`in_progress`||t===`inprogress`||t===`active`||t===`probing`)return`testing`;if(t===`confirmed`||t===`verified`||t===`exploited`||t===`vulnerable`||t===`success`)return`confirmed`;if(t===`rejected`||t===`tested_safe`||t===`testedsafe`||t===`safe`||t===`clean`||t===`not_vulnerable`||t===`notvulnerable`||t===`invalid`)return`rejected`;if(t===`blocked`||t===`justified_blocked`||t===`justifiedblocked`||t===`needs_auth`||t===`needsauth`||t===`untestable`)return`blocked`}var U2=/https?:\/\/[^\s<>")']+/i,W2=/\b(?:[a-z0-9-]+\.)+[a-z]{2,}\b/i;function G2(e){if(!e||typeof e!=`string`)return null;let t=e.match(U2);if(t?.[0]){let e=t[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<512)return e}let n=e.match(W2);if(n?.[0]){let e=n[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<256&&!e.endsWith(`.ts`)&&!e.endsWith(`.js`)&&!e.endsWith(`.json`)&&!e.endsWith(`.md`)&&!e.endsWith(`.html`)&&!e.endsWith(`.txt`))return e}return null}function K2(e){let t=0;for(let n of e){let e=n.id.match(/^T-(\d+)$/i);e&&(t=Math.max(t,Number.parseInt(e[1],10)))}return`T-${t+1}`}function q2(e,t){let n=new Map;for(let t of e)n.set(t.id,{...t});for(let e of t){let t=n.get(e.id);t?n.set(e.id,{id:e.id,title:e.title||t.title,status:e.status||t.status,note:e.note===void 0?t.note:e.note}):n.set(e.id,{...e})}return Array.from(n.values())}var J2=/-\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([A-Za-z0-9_-]+):\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,Y2=/Task\s+([A-Za-z0-9_-]+)\s+(?:added|updated):\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,X2=/<kifaru_dossier\s+target="([^"]+)"(?:\s+phase="([^"]+)")?/i;function Z2(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=e.split(/\r?\n/);for(let e of i){let t=e.trim();if(!t.startsWith(`|`)||!t.endsWith(`|`))continue;let i=t.split(`|`).map(e=>e.trim()),a=i.filter((e,t)=>t>0&&t<i.length-1);if(a.length<2||a.every(e=>/^[-:=|\s]+$/.test(e)))continue;let o=H2(a[1]),s=a[0],c=a[2];if(o||(o=H2(a[0]),o&&(s=a[1],c=a[2])),!o||!s||(s=s.replace(/^[`*_\s]+|[`*_\s]+$/g,``).trim(),!s||s.toLowerCase()===`cell`||s.toLowerCase()===`task`))continue;let l,u=s.match(/^(T-\d+)[:\s—-]+(.*)$/i);u?.[1]&&(l=u[1].toUpperCase(),s=u[2].trim());let d=s.toLowerCase(),f=r.get(d);if(f)f.status=o,c&&(f.note=c.trim());else{let e={id:l||K2(n),title:s,status:o,note:c?c.trim():void 0};n.push(e),r.set(d,e)}}return n}function Q2(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=/^\s*[-*]\s*\[([ xX/!?-])\]\s*(?:([A-Za-z0-9_-]+):)?\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gm,a;for(;(a=i.exec(e))!==null;){let[,e,t,i,o]=a;if(!i)continue;let s=`pending`;e===`x`||e===`X`?s=`confirmed`:e===`/`?s=`testing`:e===`!`?s=`blocked`:(e===`-`||e===`?`)&&(s=`rejected`);let c=i.trim(),l=c.toLowerCase(),u=r.get(l);if(u)u.status=s,o&&(u.note=o.trim());else{let e={id:t?.startsWith(`T-`)?t.toUpperCase():K2(n),title:c,status:s,note:o?o.trim():void 0};n.push(e),r.set(l,e)}}return n}function $2(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);for(let t of e){let e=typeof t==`string`?t:typeof t==`object`&&t&&`note`in t?String(t.note??``):``;if(!e)continue;let i,a,o;if(/^CONFIRMED(\([^)]+\))?:/i.test(e)){i=`confirmed`;let t=e.replace(/^CONFIRMED(\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`.`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():void 0}else if(/BLOCKED/i.test(e)&&(/coverage gap/i.test(e)||/needs auth/i.test(e))){i=`blocked`;let t=e.replace(/^Coverage gap(\s*\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`—`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():t}if(i&&a){let e=a.toLowerCase(),t=r.get(e);if(t)t.status=i,o&&(t.note=o);else{let t={id:K2(n),title:a,status:i,note:o};n.push(t),r.set(e,t)}}}return n}function e4(e){let t=[],n,r;for(let i of e){if(i.role===`user`){let e=``;if(typeof i.content==`string`)e=i.content;else if(Array.isArray(i.content))for(let t of i.content)typeof t==`object`&&t&&`type`in t&&t.type===`text`&&(e+=` ${t.text??``}`);let t=G2(e);t&&(n=t)}if(i.role===`custom`&&i.customType===`kifaru-dossier`){let e=typeof i.content==`string`?i.content:``,a=e.match(/Bound target:\s*([^\n\r]+)/i)||e.match(/Session bound to target\s*([^\n\r.]+)/i);a?.[1]&&(n=a[1].trim());let o=e.match(/Phase:\s*([a-zA-Z0-9_-]+)/i);o?.[1]&&(r=o[1].trim());let s;for(J2.lastIndex=0;(s=J2.exec(e))!==null;){let[,e,n,r,i]=s;n&&r&&V2(e)&&(t=q2(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}if(i.role===`assistant`&&Array.isArray(i.content)){for(let e of i.content)if(typeof e==`object`&&e&&`type`in e){if(e.type===`text`&&typeof e.text==`string`){let i=e.text,a=G2(i);a&&!n&&(n=a);let o=i.match(X2);o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),t=Z2(i,t),t=Q2(i,t)}if(e.type===`tool-call`||e.type===`toolCall`){let i=e,a=i.name??i.toolName,o=i.args??i.arguments;if(a===`kifaru_dossier`&&o&&(typeof o.target==`string`&&o.target.trim()&&(n=o.target.trim()),typeof o.phase==`string`&&o.phase.trim()&&(r=o.phase.trim()),o.action===`task`)){let e=typeof o.taskId==`string`?o.taskId.trim():void 0,n=typeof o.title==`string`?o.title.trim():void 0,r=typeof o.note==`string`?o.note.trim():void 0;e&&(t=q2(t,[{id:e,title:n||e,status:V2(o.status)?o.status:`pending`,note:r}]))}}}}if(i.role===`toolResult`){let e=i;for(let i of e.content??[])if(i.type===`text`&&i.text){let e=i.text.trim();if(e.startsWith(`{`)&&e.endsWith(`}`))try{let i=JSON.parse(e);if(typeof i.target==`string`&&(n=i.target),typeof i.phase==`string`&&(r=i.phase),Array.isArray(i.tasks)){let e=[];for(let t of i.tasks)typeof t.id==`string`&&typeof t.title==`string`&&e.push({id:t.id,title:t.title,status:V2(t.status)?t.status:`pending`,note:typeof t.note==`string`?t.note:void 0});t=q2(t,e)}Array.isArray(i.observations)&&(t=$2(i.observations,t))}catch{}t=Z2(e,t),t=Q2(e,t);let a;for(Y2.lastIndex=0;(a=Y2.exec(e))!==null;){let[,e,n,r,i]=a;e&&r&&V2(n)&&(t=q2(t,[{id:e.trim(),title:r.trim(),status:n,note:i?i.trim():void 0}]))}let o=e.match(X2);for(o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),J2.lastIndex=0;(a=J2.exec(e))!==null;){let[,e,n,r,i]=a;n&&r&&V2(e)&&(t=q2(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}}}return{tasks:t,target:n,phase:r}}var t4={pending:re,testing:he,confirmed:A,rejected:ne,blocked:te},n4={pending:{badge:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,text:`text-muted-foreground`,ring:`border-border`},testing:{badge:`bg-blue-500/10 text-blue-500 border-blue-500/30 hover:bg-blue-500/20`,text:`text-blue-500`,ring:`border-blue-500/40 bg-blue-500/10`},confirmed:{badge:`bg-emerald-500/10 text-emerald-500 border-emerald-500/30 hover:bg-emerald-500/20`,text:`text-emerald-500`,ring:`border-emerald-500/50 bg-emerald-500/20`},rejected:{badge:`bg-rose-500/10 text-rose-500 border-rose-500/30 hover:bg-rose-500/20`,text:`text-rose-500`,ring:`border-rose-500/40 bg-rose-500/10`},blocked:{badge:`bg-amber-500/10 text-amber-500 border-amber-500/30 hover:bg-amber-500/20`,text:`text-amber-500`,ring:`border-amber-500/40 bg-amber-500/10`}};function r4({className:e=``,onClose:t}){let[n,{setState:r}]=gz(`taskBoard`,{description:`A task board panel for the target dossier tracking hunt theses, tests, and findings. Use update_taskBoard with tasks.add/update/remove/clear to manage tasks. Tasks have id (e.g. T-1), title, status (pending|testing|confirmed|rejected|blocked), and optional note.`,stateSchema:z2,initialState:B2}),i=u$(e=>e.messages),[a,o]=(0,N.useState)(``),[c,l]=(0,N.useState)(`all`),[u,d]=(0,N.useState)(!1);(0,N.useEffect)(()=>{if(!i||i.length===0)return;let e=e4(i);(e.tasks.length!==0||e.target||e.phase)&&r(t=>{let n=q2(t?.tasks??[],e.tasks),r=e.target&&e.target!==t?.target,i=e.phase&&e.phase!==t?.phase,a=n.length!==(t?.tasks?.length??0)||n.some((e,n)=>{let r=t?.tasks?.[n];return!r||r.id!==e.id||r.status!==e.status||r.title!==e.title||r.note!==e.note});return!r&&!i&&!a?t:{...t,tasks:n,target:e.target??t?.target,phase:e.phase??t?.phase}})},[i,r]);let f=n?.target;(0,N.useEffect)(()=>{if(!f)return;let e=!1;return fetch(`/api/v1/workbench/dossier?target=${encodeURIComponent(f)}`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&Array.isArray(t.tasks)&&t.tasks.length!==0&&r(e=>{let n=q2(e?.tasks??[],t.tasks??[]),r=t.target&&!e?.target,i=t.phase&&!e?.phase,a=n.length!==(e?.tasks?.length??0)||n.some((t,n)=>{let r=e?.tasks?.[n];return!r||r.id!==t.id||r.status!==t.status||r.title!==t.title});return!r&&!i&&!a?e:{...e,tasks:n,target:e?.target??t.target,phase:e?.phase??t.phase}})}).catch(()=>{}),()=>{e=!0}},[f,r]);let p=n?.tasks??[],h=n?.target,g=n?.phase,_=(0,N.useMemo)(()=>{let e={all:p.length};for(let t of L2)e[t]=0;for(let t of p)e[t.status]=(e[t.status]??0)+1;return e},[p]),v=(0,N.useMemo)(()=>c===`all`?p:p.filter(e=>e.status===c),[p,c]),y=(e,t,n)=>{let r=t||h;r&&fetch(`/api/v1/workbench/dossier`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:r,tasks:e,phase:n||g})}).catch(()=>{})},b=e=>{let t=`pending`;e.status===`pending`?t=`testing`:e.status===`testing`?t=`confirmed`:e.status===`confirmed`?t=`pending`:e.status===`blocked`?t=`testing`:e.status===`rejected`&&(t=`pending`);let n=p.map(n=>n.id===e.id?{...n,status:t}:n);r(e=>({...e,tasks:n})),y(n)},x=(e,t)=>{let n=p.map(n=>n.id===e?{...n,status:t}:n);r(e=>({...e,tasks:n})),y(n)},S=e=>{let t=p.filter(t=>t.id!==e);r(e=>({...e,tasks:t})),y(t)},C=()=>{let e=a.trim();if(!e)return;let t={id:K2(p),title:e,status:`pending`},n=[...p,t];r(e=>({...e,tasks:n})),y(n),o(``),d(!1)};return(0,P.jsxs)(`div`,{className:`flex h-full flex-col bg-card text-card-foreground ${e}`,children:[(0,P.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border px-3.5 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(me,{className:`size-4.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,P.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-foreground truncate`,children:`Task Board`}),p.length>0?(0,P.jsx)(ux,{variant:`secondary`,className:`px-1.5 py-0 text-[11px] font-mono font-medium`,children:p.length}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[h?(0,P.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground bg-muted/60 px-2 py-0.5 rounded-md font-mono truncate max-w-32`,title:`Bound target: ${h}`,children:[(0,P.jsx)(ke,{className:`size-3 text-primary shrink-0`}),(0,P.jsx)(`span`,{className:`truncate`,children:h})]}):null,g?(0,P.jsx)(ux,{variant:`outline`,className:`text-[10px] uppercase font-mono tracking-wider px-1.5 py-0`,children:g}):null,(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground`,onClick:()=>d(e=>!e),title:`Add task`,children:[(0,P.jsx)(Se,{className:`size-4`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Add task`})]}),t?(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground md:hidden`,onClick:t,title:`Close panel`,children:[(0,P.jsx)(ne,{className:`size-4`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close panel`})]}):null]})]}),p.length>0?(0,P.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/60 px-3 py-1.5 text-xs`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>l(`all`),className:`rounded-md px-2 py-0.5 text-xs font-medium transition-colors ${c===`all`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[`All (`,_.all,`)`]}),L2.map(e=>{let t=_[e]??0;return t===0&&c!==e?null:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-xs capitalize font-medium transition-colors ${c===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,P.jsx)(`span`,{children:e}),(0,P.jsxs)(`span`,{className:`font-mono text-[10px] opacity-70`,children:[`(`,t,`)`]})]},e)})]}):null,u?(0,P.jsxs)(`div`,{className:`border-b border-border/80 bg-muted/30 p-2.5 flex items-center gap-2`,children:[(0,P.jsx)(m,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),C()):e.key===`Escape`&&d(!1)},placeholder:`New task thesis (e.g. Test IDOR on /api/user)...`,className:`h-8 text-xs bg-background`}),(0,P.jsx)(s,{size:`sm`,className:`h-8 px-2.5 text-xs shrink-0`,onClick:C,children:`Add`})]}):null,(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-3`,children:p.length===0?(0,P.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center text-center px-4`,children:[(0,P.jsx)(`div`,{className:`flex size-14 items-center justify-center rounded-2xl bg-muted/40 mb-3 border border-border/40`,children:(0,P.jsx)(me,{className:`size-8 text-muted-foreground/50`,"aria-hidden":`true`})}),(0,P.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:h?`No tasks yet for ${h}`:`No tasks yet.`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground max-w-56 leading-relaxed`,children:h?`Analyzing target surface and recording hunt theses...`:`Ask the assistant to add some!`}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,className:`mt-4 h-7 text-xs gap-1.5 text-muted-foreground hover:text-foreground`,onClick:()=>d(!0),children:[(0,P.jsx)(Se,{className:`size-3.5`}),`Add task`]})]}):v.length===0?(0,P.jsxs)(`div`,{className:`flex h-full min-h-36 flex-col items-center justify-center text-center text-muted-foreground text-xs py-8`,children:[(0,P.jsxs)(`p`,{children:[`No tasks with status "`,c,`".`]}),(0,P.jsx)(s,{variant:`link`,size:`sm`,className:`text-xs mt-1`,onClick:()=>l(`all`),children:`Show all tasks`})]}):(0,P.jsx)(`ul`,{className:`flex flex-col gap-2`,children:v.map(e=>{let t=t4[e.status]??re,n=n4[e.status]??n4.pending,r=e.status===`confirmed`;return(0,P.jsx)(`li`,{className:`group relative flex flex-col gap-1.5 rounded-lg border border-border/70 bg-card p-2.5 transition-all hover:border-border hover:shadow-xs`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>b(e),title:`Status: ${e.status}. Click to cycle.`,"aria-label":`Toggle task status for ${e.title}`,className:`mt-0.5 flex size-4.5 shrink-0 items-center justify-center rounded-md border transition-all ${r?`border-emerald-500 bg-emerald-500 text-white dark:text-black`:n.ring}`,children:r?(0,P.jsx)(A,{className:`size-3 stroke-[3]`}):e.status===`testing`?(0,P.jsx)(he,{className:`size-2.5 animate-spin text-blue-500`}):(0,P.jsx)(`span`,{className:`size-1.5 rounded-full bg-transparent group-hover:bg-muted-foreground/30`})}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,P.jsx)(`span`,{className:`font-mono text-[10px] font-semibold text-muted-foreground/80 tracking-wider`,children:e.id}),(0,P.jsxs)(`div`,{className:`relative inline-flex items-center`,children:[(0,P.jsx)(t,{className:`pointer-events-none absolute left-1.5 size-2.5 opacity-70`}),(0,P.jsx)(`select`,{value:e.status,onChange:t=>x(e.id,t.target.value),"aria-label":`Change status for task ${e.id}`,className:`h-4.5 appearance-none rounded border pl-4.5 pr-4 text-[10px] font-medium transition-colors cursor-pointer outline-none ${n.badge}`,children:L2.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}),(0,P.jsx)(j,{className:`pointer-events-none absolute right-1 size-2.5 opacity-60`})]})]}),(0,P.jsx)(`p`,{className:`text-xs leading-snug break-words ${r?`text-muted-foreground line-through`:`text-foreground`}`,children:e.title}),e.note?(0,P.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground/90 bg-muted/40 rounded px-1.5 py-0.5 border border-border/40 font-mono`,children:e.note}):null]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>S(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded-sm`,title:`Delete task`,"aria-label":`Delete task`,children:(0,P.jsx)(Pe,{className:`size-3.5`})})]})},e.id)})})}),p.length>0?(0,P.jsxs)(`footer`,{className:`border-t border-border px-3 py-2 flex items-center justify-between text-[11px] text-muted-foreground bg-muted/20`,children:[(0,P.jsxs)(`span`,{children:[_.confirmed??0,` of `,p.length,` confirmed`]}),(0,P.jsx)(s,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-[11px] text-muted-foreground hover:text-destructive`,onClick:()=>r(e=>({...e,tasks:[]})),children:`Clear all`})]}):null]})}function i4({request:e,respond:t}){let[n,r]=(0,N.useState)(e.kind===`editor`?e.prefill??``:``),i=e=>void t(e);return(0,P.jsxs)(`div`,{className:`bg-card grid gap-2 rounded-md border border-l-[3px] border-l-primary p-3`,role:`group`,"aria-label":`The agent is asking for approval`,children:[(0,P.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,P.jsx)(De,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),e.title]}),e.kind===`confirm`?(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs break-words whitespace-pre-wrap`,children:e.message}):null,e.timeoutMs?(0,P.jsxs)(`p`,{className:`text-muted-foreground text-[0.7rem] tabular-nums`,children:[`Auto-dismisses after `,Math.round(e.timeoutMs/1e3),`s`]}):null,e.kind===`confirm`?(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(s,{size:`sm`,onClick:()=>i({requestId:e.id,confirmed:!0}),children:`Allow`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,confirmed:!1}),children:`Deny`})]}):null,e.kind===`select`?(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.options.map(t=>(0,P.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,value:t}),children:t},t)),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]}):null,e.kind===`input`||e.kind===`editor`?(0,P.jsxs)(`form`,{className:`grid gap-2`,onSubmit:t=>{t.preventDefault(),i({requestId:e.id,value:n})},children:[e.kind===`editor`?(0,P.jsx)(h0,{rows:6,value:n,onChange:e=>r(e.target.value)}):(0,P.jsx)(m,{value:n,placeholder:e.placeholder??``,onChange:e=>r(e.target.value)}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(s,{size:`sm`,type:`submit`,children:`Submit`}),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]})]}):null]})}function a4(){let{requests:e,respond:t}=d$();return e.length===0?null:(0,P.jsx)(`div`,{className:`grid gap-2 border-b px-3 py-2`,children:e.map(e=>(0,P.jsx)(i4,{request:e,respond:t},e.id))})}function o4({className:e,...t}){return(0,P.jsx)(`select`,{"data-slot":`native-select`,className:a(`border-input bg-background text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive h-9 w-full min-w-0 cursor-pointer rounded-md border px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}var s4=6e4,c4=500,l4=1e4,u4=100,d4=new Set([`listThreads`,`getThread`,`getAvailableModels`]),f4=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchTransportError`}},p4=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchRpcError`}};function m4(){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/api/v1/workbench/ws`}function h4(e={}){let t=e.url??m4(),n=new Map,r=new Map,i=null,a=0,o,s=!1,c=!1,l=0;function u(t){e.onStatusChange?.(t)}function d(t){e.onError?.(t instanceof Error?t:Error(String(t)))}function f(e,t){let r=n.get(e);r&&(n.delete(e),clearTimeout(r.timer),r.reject(t))}function p(e,t=!1){return e.phase===`sent`?new f4(`OUTCOME_UNKNOWN`,`Confirmation for ${e.frame.method} was lost. The request may have been accepted. Reconnect and check the thread before retrying.`):new f4(t?`TIMEOUT_NOT_SENT`:`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`)}function m(e){if(i&&i.readyState===WebSocket.OPEN&&n.has(e.frame.id))try{i.send(JSON.stringify(e.frame)),e.phase=`sent`}catch{f(e.frame.id,new f4(`SEND_FAILED`,`The request could not be sent.`))}}function h(e){if(i&&i.readyState===WebSocket.OPEN)try{i.send(JSON.stringify(e))}catch(e){d(e),i.close()}}function g(){if(s||o!==void 0)return;let t=Math.min((e.reconnectBaseMs??c4)*2**a,l4);a+=1,o=setTimeout(()=>{o=void 0,_()},t)}function _(){if(s||i)return;u(`connecting`);let o;try{o=e.createSocket?.(t)??new WebSocket(t)}catch(e){d(e),u(`closed`),g();return}i=o,o.onopen=()=>{if(!(s||i!==o)){a=0;for(let[e,t]of r)h({kind:`subscribe`,threadId:e,includeSnapshot:c||t.includeSnapshot});c=!0;for(let e of n.values())e.phase===`queued`&&m(e);u(`open`)}},o.onmessage=e=>{if(s||i!==o)return;let t;try{t=y4(JSON.parse(String(e.data)))}catch{d(new f4(`INVALID_SERVER_FRAME`,`The workspace sent an invalid response. Reconnecting.`)),o.close();return}if(t.kind===`event`){let e=t.event,n=r.get(e.threadId)?.listeners;for(let t of[...n??[]])try{t(e)}catch(e){d(e)}return}let a=n.get(t.id);if(a){if(t.kind===`rpc_error`){f(t.id,new p4(t.code,t.message));return}if(!b4(a.frame.method,t.result)){f(t.id,new f4(`INVALID_SERVER_FRAME`,`The workspace returned an invalid result.`));return}n.delete(t.id),clearTimeout(a.timer),a.resolve(t.result===null?void 0:t.result)}},o.onerror=()=>{},o.onclose=()=>{if(!(s||i!==o)){i=null;for(let[e,t]of n)f(e,p(t));u(`closed`),g()}}}function v(t,r){if(s)return Promise.reject(new f4(`DISPOSED`,`The workspace connection was closed.`));if(!d4.has(t)&&i?.readyState!==WebSocket.OPEN)return Promise.reject(new f4(`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`));if(n.size>=u4)return Promise.reject(new f4(`TOO_MANY_REQUESTS`,`Too many workspace requests are pending.`));let a=`rpc-${l++}`;return new Promise((i,o)=>{let s=setTimeout(()=>{let e=n.get(a);e&&f(a,p(e,!0))},e.requestTimeoutMs??s4),c={frame:{kind:`rpc`,id:a,method:t,params:r},phase:`queued`,resolve:i,reject:o,timer:s};n.set(a,c),m(c)})}return _(),{dispose(){if(!s){s=!0,o&&clearTimeout(o),o=void 0,r.clear();for(let e of n.keys())f(e,new f4(`DISPOSED`,`The workspace connection was closed.`));i&&(i.onopen=null,i.onmessage=null,i.onclose=null,i.onerror=null,i.close()),i=null}},listThreads:e=>v(`listThreads`,e?[e]:[]),createThread:e=>v(`createThread`,e?[e]:[]),getThread:e=>v(`getThread`,[e]),sendMessage:(e,t)=>v(`sendMessage`,[e,t]),cancelRun:e=>v(`cancelRun`,[e]),clearQueue:e=>v(`clearQueue`,[e]),getAvailableModels:e=>v(`getAvailableModels`,e?[e]:[]),setModel:(e,t)=>v(`setModel`,[e,t]),setThinkingLevel:(e,t)=>v(`setThinkingLevel`,[e,t]),renameThread:(e,t)=>v(`renameThread`,[e,t]),archiveThread:e=>v(`archiveThread`,[e]),unarchiveThread:e=>v(`unarchiveThread`,[e]),deleteThread:e=>v(`deleteThread`,[e]),respondToHostUiRequest:(e,t)=>v(`respondToHostUiRequest`,[e,t]),subscribe(e,t,n){if(s)return()=>{};let a=e=>t(e),o=r.get(e);return o?(o.listeners.add(a),n?.includeSnapshot!==!1&&(o.includeSnapshot=!0,i?.readyState===WebSocket.OPEN&&h({kind:`subscribe`,threadId:e,includeSnapshot:!0}))):(o={listeners:new Set,includeSnapshot:n?.includeSnapshot!==!1},r.set(e,o),o.listeners.add(a),h({kind:`subscribe`,threadId:e,includeSnapshot:o.includeSnapshot})),()=>{let t=r.get(e);t&&t.listeners.delete(a)&&t.listeners.size===0&&(r.delete(e),h({kind:`unsubscribe`,threadId:e}))}}}}function g4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _4(e){return g4(e)&&typeof e.id==`string`&&[`idle`,`running`,`failed`].includes(String(e.status))}function v4(e){return g4(e)&&_4(e.metadata)&&Array.isArray(e.messages)}function y4(e){if(!g4(e))throw Error(`Invalid frame`);if(e.kind===`event`){let t=e.event;if(g4(t)&&typeof t.type==`string`&&typeof t.threadId==`string`&&Number.isSafeInteger(t.seq)&&Number(t.seq)>=0&&(t.type!==`snapshot`||v4(t.snapshot)))return e}else if(typeof e.id==`string`&&(e.kind===`rpc_ok`&&`result`in e||e.kind===`rpc_error`&&typeof e.message==`string`&&typeof e.code==`string`))return e;throw Error(`Invalid frame`)}function b4(e,t){switch(e){case`listThreads`:return Array.isArray(t)&&t.every(_4);case`getThread`:case`createThread`:return v4(t);case`getAvailableModels`:return Array.isArray(t)&&t.every(e=>g4(e)&&typeof e.provider==`string`&&typeof e.modelId==`string`);case`clearQueue`:return g4(t)&&Array.isArray(t.steering)&&t.steering.every(e=>typeof e==`string`)&&Array.isArray(t.followUp)&&t.followUp.every(e=>typeof e==`string`);default:return t===null}}async function x4(){try{let e=await fetch(`/api/v1/workbench/status`,{credentials:`same-origin`});return e.status===401||e.status===403?`unauthenticated`:e.ok?(await e.json()).enabled?`up`:`unconfigured`:`down`}catch{return`down`}}var S4={connecting:`reconnecting`,open:`online`,closed:`dropped`};function C4(){let{compaction:e,retry:t,contextUsage:n,readiness:r}=c$(),i=r&&r.state!==`ready`?r:null;return(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?(0,P.jsx)(ux,{variant:`high`,children:i.message}):null,e.active?(0,P.jsx)(ux,{variant:`secondary`,children:`Compacting context…`}):null,t.active?(0,P.jsxs)(ux,{variant:`high`,children:[`Retrying (attempt `,t.attempt,`)`]}):null,n?.percent==null?null:(0,P.jsxs)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,title:`${n.tokens??`?`} / ${n.contextWindow} tokens`,children:[Math.round(n.percent),`% context`]})]})}var w4=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function T4({client:e}){let t=l$(),n=$(e=>e.threadListItem),r=n?n.externalId??n.remoteId??n.id:null,[i,a]=(0,N.useState)([]),[o,s]=(0,N.useState)(null);(0,N.useEffect)(()=>{let t=!1;return e.getAvailableModels().then(e=>{t||a(e)},()=>{}),()=>{t=!0}},[e]);let c=t?.status===`running`,l=t?.config,u=l?.provider&&l.modelId?`${l.provider}/${l.modelId}`:``,d=l?.thinkingLevel??``,f=async e=>{s(null);try{await e()}catch(e){s(e instanceof Error?e.message:String(e))}};return r?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.length>0?(0,P.jsxs)(o4,{"aria-label":`Model`,title:`Model for this conversation`,value:u,disabled:c,onChange:t=>{let[n,...i]=t.target.value.split(`/`),a=i.join(`/`);n&&a&&f(()=>e.setModel(r,{provider:n,modelId:a}))},className:`h-7 w-auto max-w-44 text-xs`,children:[!u||i.every(e=>`${e.provider}/${e.modelId}`!==u)?(0,P.jsx)(`option`,{value:u,children:u||`Select a model`}):null,i.map(e=>(0,P.jsx)(`option`,{value:`${e.provider}/${e.modelId}`,children:e.name},`${e.provider}/${e.modelId}`))]}):null,(0,P.jsxs)(o4,{"aria-label":`Thinking level`,title:`Thinking level for this conversation`,value:d,disabled:c,onChange:t=>{let n=t.target.value;f(()=>e.setThinkingLevel(r,n))},className:`h-7 w-auto text-xs`,children:[(0,P.jsx)(`option`,{value:``,children:`Thinking…`}),w4.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}),o?(0,P.jsx)(`span`,{className:`text-destructive max-w-64 truncate text-xs`,title:o,children:o}):null]}):null}function E4({status:e,client:t,showTaskBoard:n,onToggleTaskBoard:r}){let i=l$();return(0,P.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(`strong`,{className:`truncate text-sm font-semibold`,children:i?.title??`Live Workspace`}),i?.status===`running`?(0,P.jsx)(ux,{variant:`low`,children:`streaming`}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(C4,{}),(0,P.jsx)(T4,{client:t}),e===`open`?null:(0,P.jsx)(I2,{phase:S4[e]}),(0,P.jsxs)(s,{variant:n?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:r,title:`Toggle Dossier Task Board`,"aria-label":`Toggle Dossier Task Board`,children:[(0,P.jsx)(me,{className:`size-3.5`}),(0,P.jsx)(`span`,{className:`hidden sm:inline`,children:`Tasks`})]})]})]})}function D4(){let[e,t]=(0,N.useState)(`connecting`),[n,r]=(0,N.useState)(!0),i=(0,N.useMemo)(()=>h4({onStatusChange:t}),[]);(0,N.useEffect)(()=>()=>i.dispose(),[i]);let o=s$({client:i,includeArchived:!0}),s=(0,N.useMemo)(()=>KN({unstable_interactables:sB()}),[]);return(0,P.jsx)(VG,{runtime:o,config:s,children:(0,P.jsxs)(`div`,{className:a(`grid h-[var(--workspace-height)] min-h-120 grid-cols-1 gap-4`,n?`xl:grid-cols-[minmax(0,16rem)_minmax(0,1fr)_minmax(0,21rem)] md:grid-cols-[minmax(0,1fr)_minmax(0,20rem)]`:`md:grid-cols-[minmax(0,17rem)_minmax(0,1fr)]`),children:[(0,P.jsx)(g,{className:a(`min-h-0 overflow-hidden p-0`,n?`hidden xl:flex`:`hidden md:flex`),children:(0,P.jsx)(x2,{})}),(0,P.jsxs)(g,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:[(0,P.jsx)(E4,{status:e,client:i,showTaskBoard:n,onToggleTaskBoard:()=>r(e=>!e)}),(0,P.jsx)(a4,{}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,P.jsx)($0,{})})]}),n?(0,P.jsx)(g,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:(0,P.jsx)(r4,{onClose:()=>r(!1)})}):null]})})}function O4({state:e}){return(0,P.jsxs)(g,{className:`mx-auto max-w-lg items-start gap-3 p-6`,children:[(0,P.jsx)(`h2`,{className:`text-base font-semibold`,children:e===`unauthenticated`?`Sign in required`:e===`unconfigured`?`Live workspace not configured`:`Live workspace unreachable`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e===`unauthenticated`?`The live workspace is available to authenticated platform users.`:e===`unconfigured`?`Set WORKBENCH_CWD on the platform server to enable the hosted agent runtime (see docs/infra/workbench-integration.md).`:`The platform server did not answer. Check that it is running.`}),e===`unauthenticated`?(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/login`,children:`Sign in`})}):null]})}function k4({eyebrow:e,title:t,description:n,actions:r,className:i}){return(0,P.jsxs)(`header`,{className:a(`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,i),children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[e?(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-2 text-2xs font-semibold tracking-[0.12em] uppercase`,children:e}):null,(0,P.jsx)(`h1`,{children:t}),n?(0,P.jsx)(`p`,{className:`mt-2 mb-0 max-w-[72ch]`,children:n}):null]}),r?(0,P.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r}):null]})}function A4({sessions:e,value:t,onChange:n,className:r,id:i=`agent-session`}){let o=e[0];return(0,P.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,r),children:[(0,P.jsx)(`label`,{className:`text-muted-foreground shrink-0 text-[13px]`,htmlFor:i,children:`Session`}),(0,P.jsxs)(o4,{"aria-label":`Agent session`,className:`w-auto min-w-0 max-w-[22rem] text-[13px]`,id:i,onChange:e=>n(e.target.value),value:t??`latest`,children:[(0,P.jsx)(`option`,{value:`latest`,children:o?`Latest — ${o.title||`Session`}`:`Latest session`}),(0,P.jsx)(`option`,{value:`all`,children:`All workspace sessions`}),e.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title||`Session`,` · `,e.findingCount??0,` findings · `,e.runCount??0,` runs`]},e.id))]})]})}var j4=new Pf({defaultOptions:{queries:{staleTime:1e4,retry:2,refetchOnWindowFocus:!0}}});function M4({section:e}){return(0,P.jsx)(Lf,{client:j4,children:(0,P.jsx)(P4,{section:e})})}function N4(){let e=Zf({queryKey:[`workbench-status`],queryFn:x4,retry:1,staleTime:15e3});return e.isLoading?(0,P.jsx)(I4,{compact:!0,title:`Connecting to the live workspace…`,detail:`Checking the platform agent runtime.`}):e.data&&e.data!==`up`?(0,P.jsx)(O4,{state:e.data}):(0,P.jsx)(D4,{})}function P4({section:e}){let[t,n]=(0,N.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`session`):null);(0,N.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`session`);e&&n(e);let t=e=>{let t=e;t.detail&&`sessionId`in t.detail&&n(t.detail.sessionId)};return window.addEventListener(`kifaru:sessionchange`,t),()=>window.removeEventListener(`kifaru:sessionchange`,t)},[e]);let r=e=>{let t=e===`latest`?null:e;if(n(t),typeof window<`u`){let e=new URL(window.location.href);t?e.searchParams.set(`session`,t):e.searchParams.delete(`session`),window.history.replaceState({},``,e.toString()),window.dispatchEvent(new CustomEvent(`kifaru:sessionchange`,{detail:{sessionId:t}}))}},[i,a]=(0,N.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`finding`):null),o=e=>{if(a(e),typeof window<`u`){let t=new URL(window.location.href);e?t.searchParams.set(`finding`,e):t.searchParams.delete(`finding`),window.history.replaceState({},``,t.toString())}},c=Zf({queryKey:[`agent-sessions`],queryFn:Nb.agentSessions,enabled:e===`runs`||e===`agent`||e===`findings`||e===`dashboard`||e===`lifecycle`,refetchInterval:2e3}),l=t===`all`?void 0:t||c.data?.items?.[0]?.id,u=Zf({queryKey:[`workflows`],queryFn:Nb.workflows,enabled:e===`workflows`||e===`assessments`}),d=Zf({queryKey:[`overview`,l],queryFn:()=>Nb.overview(l),enabled:e===`dashboard`||e===`assessments`||e===`lifecycle`,refetchInterval:2e3}),f=Zf({queryKey:[`runs`,l],queryFn:()=>Nb.runs({sessionId:l}),enabled:e===`runs`,refetchInterval:2e3}),p=Zf({queryKey:[`projects`],queryFn:Nb.projects,enabled:e===`assessments`}),h=Zf({queryKey:[`assessment-profiles`],queryFn:Nb.assessmentProfiles,enabled:e===`assessments`}),v=Zf({queryKey:[`findings`,l],queryFn:()=>Nb.findings({sessionId:l}),enabled:e===`findings`||e===`dashboard`||e===`lifecycle`||e===`reports`,refetchInterval:6e3}),y=Zf({queryKey:[`agent-session`,t],queryFn:()=>Nb.agentSession(t),enabled:e===`runs`&&!!t,refetchInterval:2e3}),b=Zf({queryKey:[`governance-events`],queryFn:Nb.governanceEvents,enabled:e===`reports`}),x=Zf({queryKey:[`workers`],queryFn:Nb.workers,enabled:e===`administration`}),S=Zf({queryKey:[`tokens`],queryFn:Nb.tokens,enabled:e===`administration`}),[C,w]=(0,N.useState)(``),[E,D]=(0,N.useState)(30),[O,k]=(0,N.useState)(!1),[j,M]=(0,N.useState)(null),[ee,te]=(0,N.useState)(!1),[ne,re]=(0,N.useState)(!1),[ie,oe]=(0,N.useState)(null),[se,ce]=(0,N.useState)(null);async function le(e){e.preventDefault(),k(!0),oe(null);try{let e=await Nb.mintToken({label:C.trim()||`CLI Token`,expiresInDays:E});M(e),w(``),j4.invalidateQueries({queryKey:[`tokens`]})}catch(e){oe(e instanceof Error?e.message:`Failed to mint token`)}finally{k(!1)}}async function ue(e){if(confirm(`Are you sure you want to revoke this token? Any CLI session or automation using it will immediately lose access.`)){ce(e);try{await Nb.revokeToken(e),j4.invalidateQueries({queryKey:[`tokens`]})}catch(e){alert(e instanceof Error?e.message:`Failed to revoke token`)}finally{ce(null)}}}let de=[...e===`workflows`||e===`assessments`?[u]:[],...e===`dashboard`?[d,v]:[],...e===`lifecycle`?[d,v]:[],...e===`runs`?[f,c]:[],...e===`runs`&&t?[y]:[],...e===`assessments`?[d,p,h]:[],...e===`findings`?[v]:[],...e===`reports`?[b,v]:[],...e===`administration`?[x,S]:[]];if(de.some(e=>e.isLoading))return(0,P.jsx)(I4,{title:`Loading workspace`,detail:`Reading durable platform state…`});let fe=de.find(e=>e.isError);if(fe){let e=fe.error,t=e&&typeof e==`object`&&`status`in e&&e.status===401;return(0,P.jsx)(I4,{title:`Platform unavailable`,detail:e instanceof Error?e.message:`The platform could not be reached.`,action:t?(0,P.jsx)(s,{asChild:!0,children:(0,P.jsx)(`a`,{href:`/login`,children:`Sign in`})}):(0,P.jsxs)(s,{onClick:()=>void fe.refetch(),children:[(0,P.jsx)(Ce,{}),` Retry`]})})}let me=Jb(v.data?.findings??[]),he=me.filter(Gb);if(e===`dashboard`){let e=Object.fromEntries(Rb.map(e=>[e,he.filter(t=>t.severity===e).length])),n=d.data?.runs??{},i=Object.values(n).reduce((e,t)=>e+t,0),a=(n.queued??0)+(n.running??0),o=Yb(me),l=me.filter(e=>e.status===`confirmed`||e.status===`verified`);return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(k4,{actions:(0,P.jsx)(A4,{onChange:r,sessions:c.data?.items??[],value:t}),eyebrow:`Continuous assurance`,title:`Environment-wide risk posture`,description:`Posture recomputes on every run rather than at a point in time. Every number below comes from the platform ledger — agent runs, recorded tool calls and ingested findings.`}),(0,P.jsxs)(Zb,{children:[(0,P.jsx)(Qb,{hero:!0,tone:o??void 0,label:`Client posture`,value:o?Vb[o].toUpperCase():`NO CONFIRMED RISK`,meta:o?`Worst confirmed finding across ${l.length} confirmed finding${l.length===1?``:`s`}.`:`No finding has been confirmed yet.`}),(0,P.jsx)(Qb,{label:`Open findings`,value:he.length,meta:`${me.length-he.length} resolved`}),(0,P.jsx)(Qb,{label:`Critical / High`,value:`${e.critical} / ${e.high}`,meta:`${l.length} confirmed overall`}),(0,P.jsx)(Qb,{label:`Assessments`,value:i,meta:`${a} in flight`})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)(Xb,{title:`Open findings by severity`,sub:`${he.length} active`,children:(0,P.jsx)($b,{counts:e})}),(0,P.jsx)(Xb,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,P.jsx)(ex,{findings:he})})]}),(0,P.jsx)(Xb,{title:`Highest-priority open findings`,sub:(0,P.jsx)(`a`,{className:`link-more`,href:`/findings`,children:`View all`}),children:(0,P.jsx)(tx,{findings:Wb(he).slice(0,5),onSelect:e=>{window.location.href=`/findings?finding=${encodeURIComponent(e.id)}`},emptyLabel:`No open findings. Agent runs report findings through the report_finding tool; none have been ingested yet.`})}),(0,P.jsxs)(`section`,{"aria-labelledby":`active-runs`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-1 text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Operations`}),(0,P.jsx)(`h2`,{id:`active-runs`,children:`Active runs`})]}),(0,P.jsxs)(`a`,{className:`link-more`,href:`/runs`,children:[`View all `,(0,P.jsx)(T,{"aria-hidden":`true`})]})]}),d.data?.recentRuns.filter(e=>e.status===`queued`||e.status===`running`).length?(0,P.jsx)(B4,{runs:d.data.recentRuns.filter(e=>e.status===`queued`||e.status===`running`)}):(0,P.jsx)(I4,{compact:!0,title:`No active runs`,detail:`Select a target endpoint to initialize a governed assessment.`,action:(0,P.jsx)(s,{asChild:!0,children:(0,P.jsx)(`a`,{href:`/assessments`,children:`New assessment`})})})]})]})}if(e===`lifecycle`)return(0,P.jsx)(R4,{findings:he});if(e===`workflows`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(F4,{title:`Workflows`,detail:`Standardized assessment procedures, risk classifications, and required worker capabilities.`}),(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:u.data?.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(ux,{variant:lx(H4(e.stages)),children:[`Highest risk `,H4(e.stages)]}),(0,P.jsxs)(`span`,{className:`font-mono`,children:[`v`,e.version]})]}),(0,P.jsx)(`h2`,{children:e.name}),(0,P.jsx)(`p`,{children:e.description}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsxs)(`a`,{href:`/assessments`,children:[`Check readiness `,(0,P.jsx)(T,{})]})})]},e.key))})]});if(e===`runs`){if(t&&y.data){let e=y.data,t=e.operations.filter(e=>e.status!==`completed`).length;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:`Session`}),(0,P.jsx)(`h1`,{children:e.session.title}),(0,P.jsx)(`p`,{children:`Recorded tool calls and findings for this agent session, newest run last.`})]}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/runs`,children:`All runs`})})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,P.jsx)(L4,{label:`Status`,value:W4(e.session.status),detail:`${e.session.runCount} run${e.session.runCount===1?``:`s`} in this session`}),(0,P.jsx)(L4,{label:`Tool calls`,value:String(e.session.operationCount),detail:t?`${t} did not complete`:`All completed`}),(0,P.jsx)(L4,{label:`Findings`,value:String(e.session.findingCount),detail:e.session.findingCount?`Ingested through report_finding`:`None reported in this session`})]}),(0,P.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.65fr)]`,"aria-live":`polite`,children:[(0,P.jsxs)(`section`,{"aria-labelledby":`agent-transcript`,children:[(0,P.jsx)(`h2`,{id:`agent-transcript`,children:`Transcript`}),e.operations.length?(0,P.jsx)(`div`,{className:`grid gap-2.5`,children:e.operations.map(e=>(0,P.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground [&_p.font-mono]:max-h-28 [&_p.font-mono]:overflow-auto [&_p.font-mono]:rounded-sm [&_p.font-mono]:bg-[var(--plane)] [&_p.font-mono]:px-2.5 [&_p.font-mono]:py-2 [&_p.font-mono]:text-xs [&_p.font-mono]:whitespace-pre-wrap`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(`strong`,{children:e.tool}),(0,P.jsx)(ux,{variant:lx(e.status),children:W4(e.outcome)})]}),(0,P.jsxs)(`p`,{children:[e.runtime,` · `,new Date(e.startedAt).toLocaleTimeString(),e.completedAt?` · ${e.completedAt-e.startedAt}ms`:``]}),e.outputPreview?(0,P.jsx)(`p`,{className:`font-mono`,children:e.outputPreview.slice(0,400)}):null]},e.id))}):(0,P.jsx)(I4,{compact:!0,title:`Waiting for agent output`,detail:`Tool calls appear here as the runtime records them.`})]}),(0,P.jsxs)(`section`,{"aria-labelledby":`agent-runs`,children:[(0,P.jsx)(`h2`,{id:`agent-runs`,children:`Runs`}),(0,P.jsx)(`div`,{className:`grid gap-2.5`,children:e.runs.map(e=>(0,P.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(ux,{variant:lx(e.status),children:W4(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,12)})]}),(0,P.jsxs)(`p`,{children:[e.kind,` · `,new Date(e.createdAt).toLocaleString()]})]},e.id))})]})]}),e.findings.length?(0,P.jsxs)(`section`,{"aria-labelledby":`agent-findings`,children:[(0,P.jsx)(`h2`,{id:`agent-findings`,children:`Findings from this session`}),(0,P.jsx)(V4,{findings:e.findings})]}):null]})}return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(F4,{title:`Runs`,detail:`Governed assessment runs and the agent sessions behind them. Open a session to replay its transcript.`}),(0,P.jsxs)(`section`,{"aria-labelledby":`all-runs`,children:[(0,P.jsx)(`h2`,{id:`all-runs`,className:`mb-3`,children:`Runs`}),f.data?.runs.length?(0,P.jsx)(B4,{runs:f.data.runs}):(0,P.jsx)(I4,{compact:!0,title:`No runs yet`,detail:`Initialize an assessment to start the first governed run.`})]}),(0,P.jsxs)(`section`,{"aria-labelledby":`all-sessions`,children:[(0,P.jsx)(`h2`,{id:`all-sessions`,className:`mb-3`,children:`Sessions`}),c.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:c.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(ux,{variant:lx(e.status),children:W4(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.source})]}),(0,P.jsx)(`h2`,{children:e.title}),(0,P.jsxs)(`p`,{children:[e.runCount,` run`,e.runCount===1?``:`s`,` · `,e.operationCount,` tool call`,e.operationCount===1?``:`s`,` · `,e.findingCount,` finding`,e.findingCount===1?``:`s`]}),(0,P.jsxs)(`p`,{children:[`Last active `,new Date(e.lastActivityAt).toLocaleString()]}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/runs?session=${e.id}`,children:`Open session`})})]},e.id))}):(0,P.jsx)(I4,{compact:!0,title:`No agent sessions`,detail:`Sessions appear here once an agent run reaches the platform.`})]})]})}if(e===`assessments`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(F4,{title:`Assessments`,detail:`Target environment configurations, authorization scopes, and historical run associations.`}),(0,P.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,P.jsx)(L4,{label:`Projects`,value:String(p.data?.items.length??0),detail:`Active workspace project boundaries`}),(0,P.jsx)(L4,{label:`Target bindings`,value:String(h.data?.items.length??0),detail:`Bound endpoints and infrastructure`}),(0,P.jsx)(L4,{label:`Recent runs`,value:String(d.data?.recentRuns.length??0),detail:`Assessment runs recorded in this workspace`})]}),h.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:h.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(ux,{variant:lx(e.allowedRisk),children:e.allowedRisk}),(0,P.jsxs)(`span`,{className:`font-mono`,children:[`rev `,e.revision]})]}),(0,P.jsx)(`h2`,{children:e.targets[0]?.displayName??e.targets[0]?.locator??`Bound target`}),(0,P.jsxs)(`p`,{children:[e.requiredWorkerClass,` worker · immutable launch policy`]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))})]},e.id))}):(0,P.jsx)(I4,{compact:!0,title:`No targets yet`,detail:`Configure a new target endpoint from the dashboard to initialize assessment tracking.`})]});if(e===`findings`){if(i)return(0,P.jsx)(`div`,{className:`grid gap-6`,children:(0,P.jsx)(cj,{findingId:i,onBack:()=>o(null)})});let e=Object.fromEntries(Rb.map(e=>[e,he.filter(t=>t.severity===e).length])),n=U4(me);return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(k4,{actions:(0,P.jsx)(A4,{id:`findings-session`,onChange:r,sessions:c.data?.items??[],value:t}),title:`Findings & assets`,description:`Every finding on the assessed estate, grouped by asset and placed on the data lifecycle. Click any finding to read it in full, verify it, and track it to resolution.`}),me.length?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)(Xb,{title:`Open findings by severity`,sub:`${he.length} active`,children:(0,P.jsx)($b,{counts:e})}),(0,P.jsx)(Xb,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,P.jsx)(ex,{findings:he})})]}),(0,P.jsx)(Xb,{title:`Control coverage`,sub:`pillar × lifecycle stage — worst open severity per cell`,children:(0,P.jsx)(rx,{findings:he,onSelectStage:()=>{}})}),n.map(({asset:e,items:t})=>(0,P.jsx)(Xb,{title:e,sub:`${t.length} finding${t.length===1?``:`s`}`,children:(0,P.jsx)(tx,{findings:Wb(t),onSelect:e=>o(e.id)})},e))]}):(0,P.jsx)(I4,{compact:!0,title:`No findings`,detail:`Discovered findings will appear here as agent runs report them. Source findings stay unverified until operation-level evidence confirms them.`})]})}return e===`agent`?(0,P.jsx)(N4,{}):e===`reports`?(0,P.jsxs)(`div`,{className:`grid gap-8`,children:[(0,P.jsx)(k4,{eyebrow:`Kifaru platform`,title:`Reports`,description:`The generated audit report for a run, and the finding-level evidence behind every claim.`}),(0,P.jsx)(nj,{}),(0,P.jsx)(z4,{events:b.data?.items??[],findings:me})]}):e===`administration`?(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(F4,{title:`Administration & Access`,detail:`Personal access tokens, CLI credentials, worker registrations, and operational capabilities.`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.5rem`},children:[(0,P.jsx)(pe,{size:18}),(0,P.jsx)(`h2`,{children:`Personal Access Tokens & CLI Sign-In`})]})}),(0,P.jsx)(`p`,{style:{marginTop:`0.25rem`,marginBottom:`1rem`},children:`Mint tokens to authenticate the Kifaru CLI or automated CI/CD pipelines without passwords.`}),j&&(0,P.jsxs)(`div`,{style:{background:`rgba(16, 185, 129, 0.12)`,border:`1px solid rgba(16, 185, 129, 0.4)`,borderRadius:`0.5rem`,padding:`1rem`,marginBottom:`1.25rem`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`0.5rem`},children:[(0,P.jsxs)(`strong`,{style:{color:`var(--good)`,display:`flex`,alignItems:`center`,gap:`0.4rem`},children:[(0,P.jsx)(A,{size:16}),` Token Minted: `,j.label]}),(0,P.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>M(null),children:`Dismiss`})]}),(0,P.jsx)(`p`,{style:{fontSize:`0.85rem`,color:`var(--ink-2)`,marginBottom:`0.75rem`},children:`Make sure to copy your Personal Access Token now. You will not be able to see it again!`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:`0.75rem`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(_,{className:`text-muted-foreground mb-1 block text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Token Value`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,P.jsx)(m,{type:`text`,readOnly:!0,value:j.token,className:`flex-1 font-mono`}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(j.token),te(!0),setTimeout(()=>te(!1),2e3)},children:[ee?(0,P.jsx)(A,{size:14}):(0,P.jsx)(ae,{size:14}),ee?`Copied`:`Copy Token`]})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,style:{display:`block`,marginBottom:`0.25rem`},children:`CLI Sign-In Command`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,P.jsxs)(`code`,{className:`font-mono`,style:{flex:1,borderRadius:`0.375rem`,padding:`0.45rem 0.65rem`,fontSize:`0.82rem`,color:`var(--accent)`},children:[`kifaru session login --token `,j.token]}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(`kifaru session login --token `+j.token),re(!0),setTimeout(()=>re(!1),2e3)},children:[ne?(0,P.jsx)(A,{size:14}):(0,P.jsx)(ae,{size:14}),ne?`Copied`:`Copy Command`]})]})]})]})]}),(0,P.jsxs)(`form`,{onSubmit:le,style:{display:`flex`,flexWrap:`wrap`,alignItems:`flex-end`,gap:`0.75rem`,background:`var(--surface-2)`,border:`1px solid var(--border)`,borderRadius:`0.5rem`,padding:`0.85rem`,marginBottom:`1.25rem`},children:[(0,P.jsxs)(`div`,{style:{flex:`1 1 220px`},children:[(0,P.jsx)(_,{htmlFor:`mint-label`,className:`mb-1.5 block text-sm`,children:`Token Label`}),(0,P.jsx)(m,{id:`mint-label`,type:`text`,placeholder:`e.g. Workstation CLI, CI Runner`,value:C,onChange:e=>w(e.target.value)})]}),(0,P.jsxs)(`div`,{style:{width:`160px`},children:[(0,P.jsx)(_,{htmlFor:`mint-expiry`,className:`mb-1.5 block text-sm`,children:`Expiration`}),(0,P.jsxs)(o4,{id:`mint-expiry`,value:E,onChange:e=>D(Number(e.target.value)),children:[(0,P.jsx)(`option`,{value:30,children:`30 days`}),(0,P.jsx)(`option`,{value:60,children:`60 days`}),(0,P.jsx)(`option`,{value:90,children:`90 days`}),(0,P.jsx)(`option`,{value:365,children:`1 year`}),(0,P.jsx)(`option`,{value:0,children:`Never expires`})]})]}),(0,P.jsxs)(s,{type:`submit`,disabled:O,size:`sm`,children:[(0,P.jsx)(Se,{size:15}),O?`Minting…`:`Mint Token`]})]}),ie&&(0,P.jsx)(`p`,{className:`text-destructive text-sm`,style:{marginBottom:`1rem`},children:ie}),(0,P.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,P.jsx)(`h3`,{style:{fontSize:`0.95rem`,fontWeight:600,marginBottom:`0.5rem`},children:`Active Tokens`}),S.data?.items.length?(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Label`}),(0,P.jsx)(`th`,{children:`Token Prefix`}),(0,P.jsx)(`th`,{children:`Role`}),(0,P.jsx)(`th`,{children:`Created`}),(0,P.jsx)(`th`,{children:`Expires`}),(0,P.jsx)(`th`,{children:`Action`})]})}),(0,P.jsx)(`tbody`,{children:S.data.items.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{style:{fontWeight:600,color:`var(--ink)`},children:e.label}),(0,P.jsxs)(`td`,{className:`font-mono`,children:[e.prefix,`…`]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(ux,{variant:lx(`confirmed`),children:e.role})}),(0,P.jsx)(`td`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,P.jsx)(`td`,{children:e.expiresAt?new Date(e.expiresAt).toLocaleDateString():`Never`}),(0,P.jsx)(`td`,{children:(0,P.jsxs)(s,{variant:`destructive`,size:`sm`,disabled:se===e.id,onClick:()=>ue(e.id),children:[(0,P.jsx)(Pe,{size:13}),se===e.id?`Revoking…`:`Revoke`]})})]},e.id))})]})}):(0,P.jsx)(`p`,{style:{color:`var(--muted)`,fontSize:`0.85rem`,fontStyle:`italic`},children:`No personal access tokens minted yet. Use the form above to create one.`})]}),(0,P.jsxs)(`div`,{style:{marginTop:`1.25rem`,background:`var(--surface-2)`,border:`1px dashed var(--border)`,borderRadius:`0.5rem`,padding:`0.85rem 1rem`,display:`flex`,alignItems:`center`,gap:`0.75rem`},children:[(0,P.jsx)(Ae,{size:20}),(0,P.jsxs)(`div`,{style:{fontSize:`0.82rem`,color:`var(--muted)`},children:[(0,P.jsx)(`strong`,{style:{color:`var(--ink)`},children:`Interactive Browser Sign-in:`}),` You can also run`,` `,(0,P.jsx)(`code`,{className:`font-mono`,style:{color:`var(--accent)`},children:`kifaru session login`}),` `,`in your terminal to authenticate interactively through your browser.`]})]})]}),(0,P.jsxs)(`div`,{style:{marginTop:`1rem`},children:[(0,P.jsx)(`h2`,{style:{fontSize:`1.15rem`,marginBottom:`0.75rem`},children:`Execution Workers`}),x.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:x.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(ux,{variant:lx(e.status),children:W4(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.status})]}),(0,P.jsx)(`h2`,{children:e.name}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))})]},e.id))}):(0,P.jsx)(I4,{compact:!0,title:`No workers registered`,detail:`Connect an execution worker before launching capability-bound workflows.`})]})]}):(0,P.jsx)(I4,{title:`Not found`,detail:`This view does not exist.`})}function F4({title:e,detail:t}){return(0,P.jsx)(k4,{description:t,title:e})}function I4({title:e,detail:t,action:n,compact:r}){return(0,P.jsxs)(g,{className:`state ${r?`state-compact`:``}`,"aria-live":`polite`,children:[(0,P.jsx)(`div`,{className:`mb-1 grid size-9 place-items-center rounded-full border bg-[var(--accent-soft)] text-primary [&_svg]:size-[18px]`,children:(0,P.jsx)(b,{"aria-hidden":`true`})}),(0,P.jsx)(`h2`,{children:e}),(0,P.jsx)(`p`,{children:t}),n]})}function L4({label:e,value:t,detail:n}){return(0,P.jsxs)(g,{children:[(0,P.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:e}),(0,P.jsx)(`strong`,{className:`my-1 block text-[28px] font-bold tracking-[-0.02em]`,children:t}),(0,P.jsx)(`p`,{children:n})]})}function R4({findings:e}){let[t,n]=(0,N.useState)(4),r=Fb(t),i=Wb(e.filter(e=>e.stage===t)),a=e.filter(e=>e.inferred).length;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(k4,{eyebrow:`A control gap at any stage exposes the whole chain`,title:`Finding → data-lifecycle stage`,description:(0,P.jsxs)(P.Fragment,{children:[`Agents declare a stage by prefixing a finding’s category with`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:`L4·P1·`}),`.`,a?` ${a} of ${e.length} findings did not, so their stage is inferred from wording and marked as such.`:` Every finding here declared its own stage.`]})}),(0,P.jsx)(nx,{findings:e,selected:t,onSelect:n}),(0,P.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)(Xb,{title:`Stage ${r.n} · ${r.name}`,sub:`${i.length} finding${i.length===1?``:`s`}`,children:(0,P.jsx)(tx,{findings:i,emptyLabel:`No open findings at this stage.`})}),(0,P.jsxs)(Xb,{title:`Control pillar × lifecycle stage`,sub:`cell = open findings`,children:[(0,P.jsx)(rx,{findings:e,onSelectStage:n}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-4 text-xs font-medium`,style:{marginTop:12},children:[`critical`,`high`,`medium`,`low`].map(e=>(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`i`,{className:`mcap`,style:{background:`var(${Bb[e]})`}}),`worst: `,Vb[e]]},e))})]})]})]})}function z4({events:e,findings:t}){let n=Wb(t.filter(e=>e.status===`confirmed`||e.status===`unverified`)),[r,i]=(0,N.useState)(null),a=n.find(e=>e.id===r)??n[0]??null,o=Zf({queryKey:[`finding`,a?.id],queryFn:()=>Nb.finding(a.id),enabled:!!a});return(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-0`,children:`Findings & evidence`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every finding carries the evidence chain that produced it; every platform mutation is recorded below.`})]}),(0,P.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[300px_minmax(0,1fr)]`,children:[(0,P.jsxs)(`div`,{className:`bg-card overflow-hidden rounded-xl border [&_.ph]:text-muted-foreground [&_.ph]:border-b [&_.ph]:border-[var(--hair)] [&_.ph]:px-3.5 [&_.ph]:py-3 [&_.ph]:text-xs [&_.ph]:font-semibold`,children:[(0,P.jsx)(`div`,{className:`ph`,children:`Findings with evidence`}),n.length?n.map(e=>(0,P.jsxs)(`button`,{className:`block w-full border-0 border-b border-l-[3px] border-[var(--hair)] border-l-transparent bg-transparent px-3.5 py-2.5 text-left last:border-b-0 aria-pressed:border-l-primary aria-pressed:bg-[var(--accent-soft)] [&_.pt]:text-[13px] [&_.pt]:font-semibold`,type:`button`,"aria-pressed":e.id===a?.id,onClick:()=>i(e.id),children:[(0,P.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Vb[e.severity]}),(0,P.jsx)(`div`,{className:`pt`,children:e.title})]},e.id)):(0,P.jsx)(`div`,{style:{padding:`14px`},children:(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No findings have been ingested yet, so there is no evidence to audit.`})})]}),(0,P.jsx)(`div`,{children:a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`mb-4 flex justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`sevtag sev-${a.severity}`,children:Vb[a.severity]}),(0,P.jsx)(`span`,{className:`font-mono text-muted-foreground text-xs`,style:{marginLeft:8},children:a.id}),(0,P.jsx)(`h2`,{style:{marginTop:9},children:a.title})]}),(0,P.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:a.status.replaceAll(`_`,` `)})]}),(0,P.jsx)(`p`,{children:a.description}),(0,P.jsx)(ix,{items:[{k:`CVSS`,v:o.data?.finding.cvssScore??`—`},{k:`Weakness`,v:o.data?.finding.cwe??`—`,mono:!0},{k:`Category`,v:a.displayCategory},{k:`Lifecycle stage`,v:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] [&_.d]:size-2 [&_.d]:rounded-[2px]`,children:[(0,P.jsx)(`span`,{className:`d`,style:{background:`var(${Fb(a.stage).v})`}}),a.stage,` · `,Ib(Fb(a.stage))]})}]}),(0,P.jsx)(ax,{title:`Evidence chain — provenance`,children:o.data?.finding.evidence.length?o.data.finding.evidence.map(e=>(0,P.jsx)(ox,{title:e.kind,detail:e.reason??`No reason recorded.`,verdict:e.verdict},e.id)):(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No evidence records attached to this finding.`})}),o.data?.finding.remediation?(0,P.jsx)(ax,{title:`Remediation`,children:(0,P.jsx)(`p`,{children:o.data.finding.remediation})}):null]}):(0,P.jsx)(I4,{compact:!0,title:`Nothing to audit yet`,detail:`Evidence appears once an agent reports a finding through report_finding.`})})]}),(0,P.jsx)(Xb,{surface:!1,title:`Governance ledger`,sub:`${e.length} recent event${e.length===1?``:`s`}`,children:e.length?(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`#`}),(0,P.jsx)(`th`,{children:`Action`}),(0,P.jsx)(`th`,{children:`Object`}),(0,P.jsx)(`th`,{children:`Actor`}),(0,P.jsx)(`th`,{children:`Outcome`}),(0,P.jsx)(`th`,{children:`Occurred`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`font-mono`,children:e.sequence}),(0,P.jsx)(`td`,{children:e.action}),(0,P.jsxs)(`td`,{children:[e.objectType,` · `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.objectID.slice(0,16)})]}),(0,P.jsx)(`td`,{className:`font-mono`,children:e.actorID??`—`}),(0,P.jsx)(`td`,{children:(0,P.jsx)(ux,{variant:lx(e.outcome),children:e.outcome})}),(0,P.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()})]},e.id))})]})}):(0,P.jsx)(I4,{compact:!0,title:`No governance events`,detail:`Run creation, state transitions, tool calls and finding ingestion are all recorded here.`})})]})}function B4({runs:e}){return(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Assessment`}),(0,P.jsx)(`th`,{children:`Kind`}),(0,P.jsx)(`th`,{children:`Status`}),(0,P.jsx)(`th`,{children:`Updated`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`span`,{children:e.title}),(0,P.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.id})]}),(0,P.jsx)(`td`,{children:W4(e.kind)}),(0,P.jsx)(`td`,{children:(0,P.jsx)(ux,{variant:lx(e.status),children:W4(e.status)})}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function V4({findings:e}){return(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Finding`}),(0,P.jsx)(`th`,{children:`Severity`}),(0,P.jsx)(`th`,{children:`Status`}),(0,P.jsx)(`th`,{children:`Asset`}),(0,P.jsx)(`th`,{children:`Updated`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`a`,{href:`/findings`,children:e.title}),(0,P.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.description??e.id})]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(ux,{variant:lx(e.severity),children:W4(e.severity)})}),(0,P.jsx)(`td`,{children:(0,P.jsx)(ux,{variant:lx(e.status),children:W4(e.status)})}),(0,P.jsx)(`td`,{children:e.path??`—`}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function H4(e){return e.some(e=>e.risk===`R2`)?`R2`:e.some(e=>e.risk===`R1`)?`R1`:`R0`}function U4(e){let t=new Map;for(let n of e){let e=n.path?.trim()||`Unscoped`,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()].map(([e,t])=>({asset:e,items:t})).sort((e,t)=>t.items.length-e.items.length)}function W4(e){return e.replaceAll(`_`,` `).replaceAll(`-`,` `).replace(/\b\w/g,e=>e.toUpperCase())}export{M4 as PlatformRoute};
95
+ `),...i.length>0?{attachments:i}:{},...t?{streamingBehavior:t}:{}}},LQ=e=>{let t=e.runConfig?.custom?.streamingBehavior;return t===`followUp`||t===`steer`?t:void 0},RQ=e=>({role:`user`,content:e.attachments&&e.attachments.length>0?[{type:`text`,text:e.content},...e.attachments]:e.content,timestamp:Date.now()}),zQ=e=>{if(e.role!==`user`)return null;let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
96
+ `):null},BQ=e=>e.runStatus===`running`&&e.metadata.status===`running`?e:{...e,runStatus:`running`,lastError:void 0,metadata:e.metadata.status===`running`?e.metadata:{...e.metadata,status:`running`}},VQ=class{state;stateSnapshot;projectedMessages=[];messageRepository=EV.fromArray([]);version=0;allListeners=new Set;metadataListeners=new Set;messageListeners=new Set;connectionRetainers=0;optimisticUserMessages=[];unsubscribeFromEvents=null;disconnectTimer=null;loadPromise=null;messageFlushScheduled=!1;localSnapshotSeq=0;client;threadId;options;constructor(e,t,n={}){this.client=e,this.threadId=t,this.options=n,this.state=UZ(t),this.stateSnapshot=this.state}getState(){return this.state}getStateSnapshot(){return this.stateSnapshot}getProjectedMessages(){return this.projectedMessages}getMessageRepository(){return this.messageRepository}getVersion(){return this.version}connect(){return this.connectionRetainers+=1,this.ensureEventSubscription({includeSnapshot:this.state.loadState!==`loaded`}),()=>{this.connectionRetainers=Math.max(0,this.connectionRetainers-1),this.maybeDisconnectFromEvents()}}subscribe(e){return this.allListeners.add(e),()=>{this.allListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMetadata(e){return this.metadataListeners.add(e),()=>{this.metadataListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMessages(e){return this.messageListeners.add(e),()=>{this.messageListeners.delete(e),this.maybeDisconnectFromEvents()}}dispose(){this.clearDisconnectTimer(),this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null,this.allListeners.clear(),this.metadataListeners.clear(),this.messageListeners.clear()}ensureEventSubscription(e){this.clearDisconnectTimer(),!this.unsubscribeFromEvents&&(this.unsubscribeFromEvents=this.client.subscribe(this.threadId,e=>{e.threadId===this.threadId&&this.dispatch(e)},e))}hasConsumers(){return this.connectionRetainers>0||this.allListeners.size>0||this.metadataListeners.size>0||this.messageListeners.size>0}maybeDisconnectFromEvents(){this.hasConsumers()||(this.disconnectTimer||=setTimeout(()=>{this.disconnectTimer=null,!this.hasConsumers()&&(this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null)},3e4))}clearDisconnectTimer(){this.disconnectTimer&&=(clearTimeout(this.disconnectTimer),null)}async load(e=!1){if(this.loadPromise&&!e)return this.loadPromise;this.setState({...this.state,loadState:`loading`});let t=this.client.getThread(this.threadId).then(e=>{this.loadPromise===t&&this.applySnapshot(e)}).catch(e=>{throw this.loadPromise===t&&this.setState({...this.state,loadState:`loaded`,lastError:OQ(e)}),e}).finally(()=>{this.loadPromise===t&&(this.loadPromise=null)});return this.loadPromise=t,t}refresh(){return this.load(!0)}refreshInBackground(){this.loadPromise||this.refresh().catch(()=>{})}async sendMessage(e,t){if(e.role!==`user`)throw Error(`Pi only supports sending user messages`);let n=this.state.runStatus===`running`,r=t?.streamingBehavior??LQ(e)??(n?`followUp`:void 0),i=IQ(e,r);if(this.ensureEventSubscription({includeSnapshot:!1}),n)return this.sendQueued(i,r??`followUp`);let a=RQ(i);this.optimisticUserMessages.push({message:a,baseMessageCount:this.state.messages.length}),this.setState(BQ(this.state)),this.recomputeProjectedMessagesAndNotify();try{await this.client.sendMessage(this.threadId,i)}catch(e){let t=this.optimisticUserMessages.findIndex(e=>e.message===a);throw t!==-1&&this.optimisticUserMessages.splice(t,1),this.recomputeProjectedMessagesAndNotify(),this.setState({...this.state,lastError:OQ(e),runStatus:`failed`,metadata:{...this.state.metadata,status:`failed`}}),e}}async sendQueued(e,t){let n=t===`steer`?`steering`:`followUp`,r={...this.state.queue,[n]:[...this.state.queue[n],e.content]};this.setState({...this.state,queue:r});try{await this.client.sendMessage(this.threadId,e)}catch(t){let i=this.state.queue!==r,a=this.state.queue[n],o=i?-1:a.lastIndexOf(e.content);throw this.setState({...this.state,lastError:OQ(t),...o===-1?{}:{queue:{...this.state.queue,[n]:a.filter((e,t)=>t!==o)}}}),t}}async clearQueue(){let e=this.state.queue,t=await this.client.clearQueue(this.threadId);return this.state.queue===e&&(e.steering.length>0||e.followUp.length>0)&&this.setState({...this.state,queue:{steering:[],followUp:[]}}),t}async cancel(){try{await this.client.cancelRun(this.threadId)}catch(e){throw this.setState({...this.state,lastError:OQ(e)}),e}}async setModel(e){try{await this.client.setModel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:OQ(e)}),e}await this.refresh()}async setThinkingLevel(e){try{await this.client.setThinkingLevel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:OQ(e)}),e}await this.refresh()}async respondToToolApproval(e,t){let n=this.state.hostUiRequests.find(t=>t.id===e);await this.respond(n?tQ(n,{approvalId:e,approved:t}):$Z(e,t))}async resumeToolCall(e,t){let n=this.state.hostUiRequests.find(t=>t.toolCallId===e);if(!n)throw Error(`No pending host-UI request for tool call "${e}"`);n.kind===`confirm`?await this.respond($Z(n.id,t===!0)):await this.respond(rQ(n.id,t))}async respondToHostUiRequest(e){await this.respond(e)}async respond(e){try{await this.client.respondToHostUiRequest(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:OQ(e)}),e}let t=XZ(this.state,e.requestId);t!==this.state&&(this.setState(t),this.recomputeProjectedMessagesAndNotify())}applySnapshot(e){this.dispatch({type:`snapshot`,snapshot:e,threadId:this.threadId,seq:this.localSnapshotSeq})}dispatch(e){let t=ZZ(this.state,e),n=t!==this.state;n&&(this.state=t),this.reconcileOptimisticUserMessages(),n&&NQ.has(e.type)&&this.notifyMetadataListeners(),n&&jQ.has(e.type)&&(MQ.has(e.type)?this.scheduleProjectedMessageFlush():this.recomputeProjectedMessagesAndNotify()),(!DQ(e.type)||e.type===`entry_appended`&&e.entry?.type!==`custom`)&&this.refreshInBackground()}setState(e){e!==this.state&&(this.state=e,this.notifyMetadataListeners())}projectedInputMessages(){return[...this.state.messages,...this.optimisticUserMessages.map(e=>e.message)]}reconcileOptimisticUserMessages(){if(this.optimisticUserMessages.length===0)return;let e=[];for(let t of this.optimisticUserMessages){let n=zQ(t.message);this.state.messages.slice(t.baseMessageCount).some(e=>zQ(e)===n)||e.push(t)}e.length!==this.optimisticUserMessages.length&&(this.optimisticUserMessages.length=0,this.optimisticUserMessages.push(...e))}projectMessages(){return TQ({messages:this.projectedInputMessages(),toolExecutions:this.state.toolExecutions,runStatus:this.state.runStatus,hostUiRequests:this.state.hostUiRequests},this.projectedMessages)}recomputeProjectedMessagesAndNotify(){let e=this.projectMessages();if(e===this.projectedMessages){this.state!==this.stateSnapshot&&this.publishState();return}this.projectedMessages=e,this.messageRepository=EV.fromArray(e),this.notifyMessageListeners()}scheduleProjectedMessageFlush(){this.messageFlushScheduled||(this.messageFlushScheduled=!0,(this.options.scheduleNotify??kQ)(()=>{this.messageFlushScheduled=!1,this.recomputeProjectedMessagesAndNotify()}))}bumpVersion(){this.version+=1}publishState(){this.stateSnapshot=this.state,this.bumpVersion(),AQ(this.allListeners)}notifyMetadataListeners(){this.stateSnapshot=this.state,this.bumpVersion(),AQ(this.metadataListeners),AQ(this.allListeners)}notifyMessageListeners(){this.stateSnapshot=this.state,this.bumpVersion(),AQ(this.messageListeners),AQ(this.allListeners)}},HQ=e=>{let t=Symbol(`${e} extras`),n=e=>typeof e==`object`&&!!e&&t in e;return{provide:e=>(Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0}),e),is:n,tryGet:e=>n(e)?e:void 0,assert:t=>{if(!n(t))throw Error(`The current thread is not backed by the ${e} runtime.`);return t}}},UQ=e=>{let{provide:t,is:n,tryGet:r,assert:i}=e,a=e=>i(e.thread.getState().extras);function o(e,...t){let r=t.length>0,a=t[0];return $(t=>{let o=t.thread.extras;return n(o)?e?e(o):o:r?a:i(o)})}return{provide:t,is:n,tryGet:r,get:a,use:o}},WQ=(e=>UQ(HQ(e)))(`usePiRuntime`),GQ=UZ(`__pending__`),KQ=[],qQ=EV.fromArray([]),JQ=e=>{let t=new Map,n=!1;return{client:e,controllers:t,get disposed(){return n},activate(){n=!1},dispose(){n=!0;for(let e of t.values())e.dispose()}}},YQ=(e,t)=>{let n=e.controllers.get(t);if(n)return n;let r=new VQ(e.client,t);return e.controllers.set(t,r),r},XQ={getState:()=>GQ,getProjectedMessages:()=>KQ,getMessageRepository:()=>qQ,getVersion:()=>0,subscribe:()=>()=>{},subscribeMetadata:()=>()=>{},subscribeMessages:()=>()=>{},connect:()=>()=>{},load:async()=>{},refresh:async()=>{},sendMessage:async()=>{},cancel:async()=>{},clearQueue:async()=>({steering:[],followUp:[]}),setModel:async()=>{},setThinkingLevel:async()=>{},respondToToolApproval:async()=>{},resumeToolCall:async()=>{},respondToHostUiRequest:async()=>{},dispose:()=>{}},ZQ=(e,t)=>{aQ(`react-pi`,`onError`,e,t)},QQ=(e,t)=>{let{freeStanding:n}=QZ(t.hostUiRequests);return WQ.provide({controller:e,state:t,metadata:t.metadata,status:t.runStatus===`failed`?`failed`:t.runStatus,readiness:t.readiness,contextUsage:t.contextUsage,hostUiRequests:n,allHostUiRequests:t.hostUiRequests,queue:t.queue,compaction:t.compaction,retry:t.retry,lastError:t.lastError,cancel:()=>e.cancel(),refresh:()=>e.refresh(),clearQueue:()=>e.clearQueue(),setModel:t=>e.setModel(t),setThinkingLevel:t=>e.setThinkingLevel(t),respondToHostUiRequest:t=>e.respondToHostUiRequest(t),respondToToolApproval:(t,n)=>e.respondToToolApproval(t,n),resumeToolCall:(t,n)=>e.resumeToolCall(t,n)})},$Q=QQ(XQ,GQ),e$=e=>e.getStateSnapshot?.()??e.getState(),t$=e=>{let t=(0,N.useCallback)(()=>e$(e),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribe(t),[e]),t,t)},n$=e=>{let t=(0,N.useCallback)(()=>e.getMessageRepository(),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribeMessages(t),[e]),t,t)},r$=(e,t)=>{let n=(0,N.useMemo)(()=>{let n;return()=>{let r=e$(e);return(!n||n.state!==r)&&(n={state:r,selection:t(r)}),n.selection}},[e,t]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribe(t),[e]),n,n)},i$=e=>e.runStatus===`running`||e.compaction.active||e.retry.active,a$=(e,t)=>{let n=t$(e),r=n$(e),{adapters:i,isDisabled:a,isSendDisabled:o,onError:s,suggestions:c,unstable_capabilities:l}=t,u=n.loadState===`loading`,d=i$(n),f=(0,N.useEffectEvent)(e=>{ZQ(s,e)});(0,N.useEffect)(()=>{e!==XQ&&e.load().catch(f)},[e]),(0,N.useEffect)(()=>{if(e!==XQ&&d)return e.connect()},[e,d]);let p=(0,N.useMemo)(()=>QQ(e,n),[e,n]),m=(0,N.useMemo)(()=>({items:n.queue.followUp.map((e,t)=>({id:VZ(`followUp`,t),prompt:e,parts:[{type:`text`,text:e}]})),steerItems:n.queue.steering.map((e,t)=>({id:VZ(`steer`,t),prompt:e,parts:[{type:`text`,text:e}]})),enqueue:t=>{e.sendMessage(t).catch(e=>ZQ(s,e))},steer:t=>{e.sendMessage(t,{streamingBehavior:`steer`}).catch(e=>ZQ(s,e))},move:()=>{},edit:()=>{},remove:()=>{}}),[e,n.queue,s]);return(0,N.useMemo)(()=>({isDisabled:a,isSendDisabled:o,unstable_capabilities:l,suggestions:c,isLoading:u,isRunning:d,messageRepository:r,extras:p,queue:m,...i?{adapters:i}:{},onNew:async t=>{try{await e.sendMessage(t)}catch(e){throw ZQ(s,e),e}},onCancel:async()=>{try{try{await e.clearQueue()}finally{await e.cancel()}}catch(e){throw ZQ(s,e),e}},onRespondToToolApproval:async t=>{try{let n=e.getState().hostUiRequests.find(e=>e.id===t.approvalId);if(!n)throw Error(`No pending host-UI request "${t.approvalId}"`);await e.respondToHostUiRequest(tQ(n,t))}catch(e){throw ZQ(s,e),e}},onResumeToolCall:({toolCallId:t,payload:n})=>{e.resumeToolCall(t,n).catch(e=>ZQ(s,e))}}),[e,p,r,m,i,a,u,d,o,s,c,l])},o$=(e,t)=>({id:`pi-new-user:${t}`,role:`user`,createdAt:new Date,content:FQ(e)}),s$=(e,t)=>{let n=Q(),{adapters:r,isDisabled:i,isSendDisabled:a,onError:o,suggestions:s,unstable_capabilities:c}=t,[l,u]=(0,N.useState)([]),d=(0,N.useRef)(0),f=(0,N.useMemo)(()=>EV.fromArray(l),[l]);return(0,N.useMemo)(()=>({isDisabled:i??!1,isSendDisabled:a,unstable_capabilities:c,suggestions:s,isLoading:!1,isRunning:!1,messageRepository:f,extras:$Q,...r?{adapters:r}:{},onNew:async t=>{let r=o$(t,d.current++);u(e=>[...e,r]);let i=()=>{u(e=>e.filter(e=>e!==r))};try{let{remoteId:r,externalId:a}=await n.threadListItem.initialize();if(e.disposed){i();return}await YQ(e,a??r).sendMessage(t),i()}catch(e){throw i(),ZQ(o,e),e}}}),[n,f,e,r,i,a,o,s,c])},c$=(e,t)=>{let n=$(e=>e.threadListItem),r=$(e=>e.threads.mainThreadId===e.threadListItem.id),i=n.externalId??n.remoteId,a=i?YQ(e,i):XQ,o=a$(r?a:XQ,t),s=s$(e,t);return nH(i?o:s)},l$=e=>({status:e.archived?`archived`:`regular`,remoteId:e.id,externalId:e.id,...e.title===void 0?{}:{title:e.title},custom:{status:e.status,...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.sessionFile===void 0?{}:{sessionFile:e.sessionFile},...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath}}}),u$=e=>{let{client:t}=e,n=(0,N.useMemo)(()=>JQ(t),[t]);return(0,N.useEffect)(()=>(n.activate(),()=>n.dispose()),[n]),KH({allowNesting:!0,adapter:(0,N.useMemo)(()=>({list:async()=>({threads:(await t.listThreads({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.includeArchived===void 0?{}:{includeArchived:e.includeArchived}})).map(l$)}),rename:async(e,n)=>{await t.renameThread(e,n)},archive:async e=>{await t.archiveThread?.(e)},unarchive:async e=>{await t.unarchiveThread?.(e)},delete:async e=>{await t.deleteThread?.(e)},initialize:async()=>{let n=await t.createThread({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath}});return{remoteId:n.metadata.id,externalId:n.metadata.id}},generateTitle:async()=>new ReadableStream({start(e){e.close()}}),fetch:async e=>l$((await t.getThread(e)).metadata)}),[t,e.workspacePath,e.includeArchived]),...e.initialThreadId===void 0?{}:{initialThreadId:e.initialThreadId},...e.threadId===void 0?{}:{threadId:e.threadId},...e.onThreadIdChange===void 0?{}:{onThreadIdChange:e.onThreadIdChange},runtimeHook:()=>c$(n,e)})},d$=()=>WQ.use(e=>e,$Q),f$=()=>WQ.use(e=>e.metadata,null);function p$(e){return r$(WQ.use(e=>e.controller,XQ),e??(e=>e))}var m$=()=>{let e=WQ.use(e=>e,void 0);return(0,N.useMemo)(()=>({requests:e?.hostUiRequests??[],respond:e?.respondToHostUiRequest??(async()=>{throw Error(`Pi runtime is not ready yet`)})}),[e])};function h$({delayDuration:e=0,...t}){return(0,P.jsx)(Td,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function g$({...e}){return(0,P.jsx)(Ed,{"data-slot":`tooltip`,...e})}function _$({...e}){return(0,P.jsx)(Dd,{"data-slot":`tooltip-trigger`,...e})}function v$({className:e,sideOffset:t=0,children:n,...r}){return(0,P.jsx)(Od,{children:(0,P.jsxs)(kd,{"data-slot":`tooltip-content`,sideOffset:t,className:a(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,P.jsx)(Ad,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function y$({...e}){return(0,P.jsx)(wi,{"data-slot":`dialog`,...e})}function b$({...e}){return(0,P.jsx)(Ei,{"data-slot":`dialog-trigger`,...e})}function x$({...e}){return(0,P.jsx)(Ai,{"data-slot":`dialog-portal`,...e})}function S$({className:e,...t}){return(0,P.jsx)(Mi,{"data-slot":`dialog-overlay`,className:a(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function C$({className:e,children:t,showCloseButton:n=!0,...r}){return(0,P.jsxs)(x$,{"data-slot":`dialog-portal`,children:[(0,P.jsx)(S$,{}),(0,P.jsxs)(Ii,{"data-slot":`dialog-content`,className:a(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,P.jsxs)(Ui,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,P.jsx)(Be,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function w$({className:e,...t}){return(0,P.jsx)(Vi,{"data-slot":`dialog-title`,className:a(`text-lg leading-none font-semibold`,e),...t})}function T$({className:e,size:t=`default`,...n}){return(0,P.jsx)($i,{"data-slot":`avatar`,"data-size":t,className:a(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function E$({className:e,...t}){return(0,P.jsx)(ta,{"data-slot":`avatar-image`,className:a(`aspect-square size-full`,e),...t})}function D$({className:e,...t}){return(0,P.jsx)(ra,{"data-slot":`avatar-fallback`,className:a(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var O$=(0,N.forwardRef)(({children:e,tooltip:t,side:n=`bottom`,className:r,...i},o)=>(0,P.jsx)(h$,{delayDuration:0,children:(0,P.jsxs)(g$,{children:[(0,P.jsx)(_$,{asChild:!0,children:(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,...i,className:a(`aui-button-icon size-6 p-1 active:scale-90`,r),ref:o,children:[(0,P.jsx)(l,{children:e}),(0,P.jsx)(`span`,{className:`aui-sr-only sr-only`,children:t})]})}),(0,P.jsx)(v$,{side:n,children:t})]})}));O$.displayName=`TooltipIconButton`;var k$=e=>Symbol.iterator in e,A$=e=>`entries`in e,j$=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},M$=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function N$(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:k$(e)&&k$(t)?A$(e)&&A$(t)?j$(e,t):M$(e,t):j$({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function P$(e){let t=N.useRef(void 0);return n=>{let r=e(n);return N$(t.current,r)?t.current:t.current=r}}var F$=e=>{let[t,n]=(0,N.useState)(void 0);return(0,N.useEffect)(()=>{if(!e){n(void 0);return}let t=URL.createObjectURL(e);return n({file:e,url:t}),()=>{URL.revokeObjectURL(t)}},[e]),t!==void 0&&t.file===e?t.url:void 0},I$=()=>{let{file:e,src:t}=$(P$(e=>{if(e.attachment.type!==`image`)return{};if(e.attachment.file)return{file:e.attachment.file};let t=e.attachment.content?.filter(e=>e.type===`image`)[0]?.image;return t?{src:t}:{}}));return F$(e)??t},L$=({src:e})=>{let[t,n]=(0,N.useState)(!1);return(0,P.jsx)(`img`,{src:e,alt:`Attachment preview`,className:a(`block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none`,t?`aui-attachment-preview-image-loaded opacity-100`:`aui-attachment-preview-image-loading opacity-0`),onLoad:()=>n(!0)})},R$=({children:e})=>{let t=I$();return t?(0,P.jsxs)(y$,{children:[(0,P.jsx)(b$,{className:`aui-attachment-preview-trigger cursor-zoom-in`,asChild:!0,children:(0,N.isValidElement)(e)?e:(0,P.jsx)(`button`,{type:`button`,children:e})}),(0,P.jsxs)(C$,{className:`aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!`,children:[(0,P.jsx)(w$,{className:`aui-sr-only sr-only`,children:`Image Attachment Preview`}),(0,P.jsx)(`div`,{className:`aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm`,children:(0,P.jsx)(L$,{src:t})})]})]}):e},z$=()=>{let e=I$();return(0,P.jsxs)(T$,{className:`aui-attachment-tile-avatar h-full w-full rounded-none`,children:[(0,P.jsx)(E$,{src:e,alt:`Attachment preview`,className:`aui-attachment-tile-image rounded-none object-cover`}),(0,P.jsx)(D$,{children:(0,P.jsx)(ue,{className:`aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]`})})]})},B$=()=>{let e=Q().attachment.source!==`message`,t=$(e=>e.attachment.type===`image`),n=$(e=>{let t=e.attachment.type;switch(t){case`image`:return`Image`;case`document`:return`Document`;case`file`:return`File`;default:return t}}),r=$(e=>e.attachment.status.type===`running`?`uploading`:e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?`error`:void 0),i=r===`uploading`,o=r===`error`,s=$(e=>e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?e.attachment.status.message??`Upload failed`:void 0);return(0,P.jsx)(h$,{children:(0,P.jsxs)(g$,{children:[(0,P.jsxs)(ZK.Root,{className:a(`aui-attachment-root relative`,e&&`animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none`,t&&!e&&`aui-attachment-root-message only:*:first:size-24`),children:[(0,P.jsx)(R$,{children:(0,P.jsx)(_$,{asChild:!0,children:(0,P.jsxs)(`div`,{className:a(`aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--composer-radius,1rem)-var(--composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10`,o&&`after:ring-destructive/60 dark:after:ring-destructive/60`),role:`button`,tabIndex:0,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},"aria-label":`${n} attachment${o?`, upload failed`:i?`, uploading`:``}`,children:[(0,P.jsx)(z$,{}),i&&(0,P.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,P.jsx)(ge,{className:`text-muted-foreground size-4 animate-spin`})}),o&&(0,P.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,P.jsx)(te,{className:`text-destructive size-4`})})]})})}),e&&(0,P.jsx)(V$,{})]}),(0,P.jsxs)(v$,{side:`top`,children:[(0,P.jsx)(ZK.Name,{}),s&&(0,P.jsx)(`p`,{className:`aui-attachment-error-message`,children:s})]})]})})},V$=()=>(0,P.jsx)(ZK.Remove,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Remove file`,className:`aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none`,side:`top`,children:(0,P.jsx)(Be,{className:`aui-attachment-remove-icon size-3 stroke-[2.5]`})})}),H$=()=>(0,P.jsx)(`div`,{className:`aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2 empty:hidden`,children:(0,P.jsx)(mX.Attachments,{children:()=>(0,P.jsx)(B$,{})})}),U$=()=>(0,P.jsx)(`div`,{className:`aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden`,children:(0,P.jsx)(nY.Attachments,{children:()=>(0,P.jsx)(B$,{})})}),W$=()=>(0,P.jsx)(nY.AddAttachment,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Add Attachment`,side:`bottom`,variant:`ghost`,size:`icon`,className:`aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none`,"aria-label":`Add Attachment`,children:(0,P.jsx)(Ce,{className:`aui-attachment-add-icon size-4`})})}),G$=y(`aui-file-root inline-flex items-center gap-3 rounded-lg transition-colors`,{variants:{variant:{outline:`border-border hover:bg-muted/50 border`,ghost:`hover:bg-muted/50`,muted:`bg-muted/50 hover:bg-muted/70`},size:{sm:`px-2.5 py-1.5 text-xs`,default:`px-3 py-2 text-sm`,lg:`px-4 py-3 text-base`}},defaultVariants:{variant:`outline`,size:`default`}});function K$(e){let t=e.toLowerCase();return t.startsWith(`image/`)?pe:t===`application/pdf`?ue:t===`application/json`?O:t.startsWith(`text/`)?ue:t.startsWith(`audio/`)?ye:t.startsWith(`video/`)?Re:de}function q$(e,t){return t===`url`&&/^data:/i.test(e)?`data-uri`:t||(/^data:/i.test(e)?`data-uri`:/^https?:\/\//i.test(e)?`url`:`base64`)}function J$(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`),n=e.search(/[^A-Za-z\d+/]/);return n!==-1&&n!==e.length-t||e.length%4==1||t>0&&e.length%4!=0?0:Math.floor(e.length*3/4)-t}function Y$(e){return J$(/[\t\n\f\r ]/.test(e)?e.replace(/[\t\n\f\r ]/g,``):e)}function X$(e){let t=e.indexOf(`#`),n=t<0?e.length:t,r=e.indexOf(`,`);if(r<0||r>=n)return 0;let i=e.slice(r+1,n);return/;base64$/i.test(e.slice(0,r))?(/[%\t\n\f\r ]/.test(i)&&(i=i.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16))).replace(/[\t\n\f\r ]/g,``)),J$(i)):new TextEncoder().encode(i.replace(/%[\da-f]{2}/gi,`_`)).byteLength}function Z$(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Q$({className:e,variant:t,size:n,children:r,...i}){return(0,P.jsx)(`div`,{"data-slot":`file-root`,"data-variant":t,"data-size":n,className:a(G$({variant:t,size:n,className:e})),...i,children:r})}function $$({mimeType:e,className:t,children:n,...r}){let i=e?K$(e):de;return(0,P.jsx)(`span`,{"data-slot":`file-icon`,className:a(`text-muted-foreground shrink-0`,t),...r,children:n??(0,P.jsx)(i,{className:`size-5`})})}function e1({className:e,children:t,...n}){return(0,P.jsx)(`span`,{"data-slot":`file-name`,className:a(`min-w-0 flex-1 truncate font-medium`,e),...n,children:t||`Unnamed file`})}function t1({bytes:e,className:t,...n}){return(0,P.jsx)(`span`,{"data-slot":`file-size`,className:a(`text-muted-foreground shrink-0`,t),...n,children:Z$(e)})}function n1({data:e,mimeType:t,filename:n,sourceType:r,className:i,children:o,...s}){if(typeof e!=`string`)return null;let c=q$(e,r);if(c===`id`||c===`url`&&!/^(https?:\/\/|blob:)/i.test(e))return null;let l=c===`base64`?`data:${t};base64,${e}`:e;return(0,P.jsx)(`a`,{"data-slot":`file-download`,href:l,download:n||`download`,...c===`url`&&{target:`_blank`,rel:`noopener noreferrer`},className:a(`text-muted-foreground hover:bg-accent hover:text-accent-foreground shrink-0 rounded-md p-1 transition-colors`,i),"aria-label":o?void 0:`Download ${n||`file`}`,...s,children:o||(0,P.jsx)(se,{className:`size-4`})})}var r1=(0,N.memo)(({filename:e,data:t,mimeType:n,sourceType:r})=>{let i=q$(t,r);return(0,P.jsxs)(Q$,{children:[(0,P.jsx)($$,{mimeType:n}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,P.jsx)(e1,{children:e}),typeof t==`string`&&(i===`base64`||i===`data-uri`)&&(0,P.jsx)(t1,{bytes:i===`data-uri`?X$(t):Y$(t),className:`text-xs`})]}),(0,P.jsx)(n1,{data:t,mimeType:n,...e!==void 0&&{filename:e},...r!==void 0&&{sourceType:r}})]})});r1.displayName=`File`,r1.Root=Q$,r1.Icon=$$,r1.Name=e1,r1.Size=t1,r1.Download=n1;var i1=()=>{let e=$(e=>e.thread.suggestions),t=(0,N.useRef)(null),n=(0,N.useRef)(null),[r,i]=(0,N.useState)({left:!1,right:!1}),a=(0,N.useCallback)(()=>{let e=t.current;if(!e)return;let r=e.scrollWidth-e.clientWidth,a=Math.abs(e.scrollLeft),[o,s]=(n.current??=getComputedStyle(e).direction===`rtl`)?[r-a,a]:[a,r-a];i(e=>{let t={left:o>1,right:s>1};return e.left===t.left&&e.right===t.right?e:t})},[]);(0,N.useEffect)(()=>{a();let e=t.current;if(!e?.firstElementChild)return;let n=new ResizeObserver(a);return n.observe(e),n.observe(e.firstElementChild),()=>n.disconnect()},[a]);let o=`linear-gradient(to right, ${r.left?`transparent, black 2rem`:`black`}, ${r.right?`black calc(100% - 2rem), transparent`:`black`})`;return(0,P.jsx)(`div`,{ref:t,onScroll:a,className:`aui-thread-followup-suggestions -my-1 w-full [scrollbar-width:none] overflow-x-auto py-1 [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,style:{maskImage:o,WebkitMaskImage:o},children:(0,P.jsx)(`div`,{className:`mx-auto flex min-h-8 w-max items-center gap-2 px-0.5`,children:e.map((e,t)=>(0,P.jsxs)(QX.Suggestion,{className:`aui-thread-followup-suggestion border-foreground/10 hover:bg-foreground/[0.03] hover:border-foreground/25 rounded-md border px-2.5 py-1 text-sm whitespace-nowrap transition-colors ease-in motion-reduce:transition-none`,prompt:e.prompt,send:!0,children:[e.title??e.prompt,e.label&&(0,P.jsx)(`span`,{className:`aui-thread-followup-suggestion-label text-muted-foreground ms-1`,children:e.label})]},t))})})},a1=()=>(0,P.jsx)(eL,{condition:e=>!e.thread.isEmpty&&!e.thread.isRunning&&e.thread.suggestions.length>0,children:(0,P.jsx)(i1,{})}),o1=e=>{switch(e){case`image/png`:return`png`;case`image/jpeg`:case`image/jpg`:return`jpg`;case`image/webp`:return`webp`;case`image/gif`:return`gif`;case`image/svg+xml`:return`svg`;default:return`png`}},s1=e=>{let t=e.indexOf(`,`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``,i=n.match(/data:([^;]+)/i)?.[1]?.toLowerCase()??`application/octet-stream`;if(!/;base64/i.test(n)){let e=r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURIComponent(e)}catch{return e}});return new Blob([e],{type:i})}let a;try{let e=r.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));a=atob(e)}catch{return null}let o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);return new Blob([o],{type:i})},c1=e=>e.match(/^data:([^;,]+)/i)?.[1]?.toLowerCase(),l1=e=>{if(typeof document>`u`)return;let t=o1(c1(e.image)),n=e.filename??`image.${t}`,r=/^data:/i.test(e.image),i=r?s1(e.image):null;if(r&&!i)return;let a=i?URL.createObjectURL(i):null,o=a??e.image,s=document.createElement(`a`);s.href=o,s.download=n,s.rel=`noopener`,document.body.appendChild(s),s.click(),document.body.removeChild(s),a&&setTimeout(()=>URL.revokeObjectURL(a),4e4)},u1=async e=>{if(typeof navigator>`u`||!navigator.clipboard||typeof ClipboardItem>`u`)throw Error(`Clipboard API is not available in this environment.`);let t=/^data:/i.test(e.image)?s1(e.image):await fetch(e.image).then(e=>e.blob());if(!t)return;let n=c1(e.image)??t.type??`image/png`;await navigator.clipboard.write([new ClipboardItem({[n]:t})])},d1=y(`aui-image-root relative overflow-hidden rounded-lg`,{variants:{variant:{outline:`border-border border`,ghost:``,muted:`bg-muted/50`},size:{sm:`max-w-64`,default:`max-w-96`,lg:`max-w-[512px]`,full:`w-full`}},defaultVariants:{variant:`outline`,size:`default`}});function f1({className:e,variant:t,size:n,children:r,...i}){return(0,P.jsx)(`div`,{"data-slot":`image-root`,"data-variant":t,"data-size":n,className:a(d1({variant:t,size:n,className:e})),...i,children:r})}function p1({className:e,containerClassName:t,onLoad:n,onError:r,alt:i=`Image content`,src:o,...s}){let c=(0,N.useRef)(null),[l,u]=(0,N.useState)(void 0),[d,f]=(0,N.useState)(void 0),p=l===o,m=d===o;return(0,N.useEffect)(()=>{let e=c.current;typeof o==`string`&&e?.complete&&(e.naturalWidth>0?u(o):f(o))},[o]),(0,P.jsxs)(`div`,{"data-slot":`image-preview`,className:a(`relative min-h-32`,t),children:[!p&&!m&&(0,P.jsx)(`div`,{"data-slot":`image-preview-loading`,className:`bg-muted/50 absolute inset-0 flex items-center justify-center`,children:(0,P.jsx)(pe,{className:`text-muted-foreground size-8 animate-pulse`})}),m?(0,P.jsx)(`div`,{"data-slot":`image-preview-error`,className:`bg-muted/50 flex min-h-32 items-center justify-center p-4`,children:(0,P.jsx)(fe,{className:`text-muted-foreground size-8`})}):(0,P.jsx)(`img`,{ref:c,src:o,alt:i,className:a(`block h-auto w-full object-contain`,!p&&`invisible`,e),onLoad:e=>{typeof o==`string`&&u(o),n?.(e)},onError:e=>{typeof o==`string`&&f(o),r?.(e)},...s})]})}function m1({className:e,children:t,...n}){return t?(0,P.jsx)(`span`,{"data-slot":`image-filename`,className:a(`text-muted-foreground block truncate px-2 py-1.5 text-xs`,e),...n,children:t}):null}function h1({src:e,alt:t=`Image preview`,children:n}){let[r,i]=(0,N.useState)(!1),a=(0,N.useRef)(null),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useCallback)(()=>i(!0),[]),l=(0,N.useCallback)(()=>{i(!1),a.current?.focus()},[]);return(0,N.useEffect)(()=>{if(!r)return;let e=e=>{if(e.key===`Escape`){l();return}if(e.key!==`Tab`)return;let t=s.current?.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`),n=t?.[0],r=t?.[t.length-1];n&&r&&(e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r,l]),(0,N.useEffect)(()=>{if(!r)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[r]),(0,N.useEffect)(()=>{r&&o.current?.focus()},[r]),(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{ref:a,onClick:c,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},role:`button`,tabIndex:0,className:`aui-image-zoom-trigger cursor-zoom-in`,"aria-label":`Click to zoom image`,children:n}),r&&(0,Wn.createPortal)((0,P.jsxs)(`div`,{ref:s,"data-slot":`image-zoom-overlay`,role:`dialog`,"aria-modal":`true`,className:`aui-image-zoom-overlay fade-in animate-in fixed inset-0 z-50 flex items-center justify-center bg-black/80 duration-200`,onClick:l,"aria-label":`Zoomed image`,children:[(0,P.jsx)(`img`,{"data-slot":`image-zoom-content`,src:e,alt:t,className:`aui-image-zoom-content fade-in zoom-in-95 animate-in max-h-[90vh] max-w-[90vw] cursor-zoom-out object-contain duration-200`,onClick:e=>{e.stopPropagation(),l()}}),(0,P.jsx)(`button`,{ref:o,type:`button`,"aria-label":`Close zoomed image`,onClick:e=>{e.stopPropagation(),l()},className:`text-muted-foreground hover:text-foreground bg-background/80 absolute end-4 top-4 cursor-pointer rounded-md p-2`,children:(0,P.jsx)(Be,{className:`size-5`})})]}),document.body)]})}function g1({className:e}){return(0,P.jsxs)(`div`,{"data-slot":`image-generating`,className:a(`bg-muted/50 flex min-h-32 items-center justify-center p-4`,e),children:[(0,P.jsx)(ge,{className:`text-muted-foreground size-8 animate-spin`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Generating image…`})]})}function _1({className:e,reason:t}){return(0,P.jsxs)(`div`,{"data-slot":`image-content-filter-error`,className:a(`bg-muted/50 flex min-h-32 flex-col items-center justify-center gap-2 p-4 text-center`,e),children:[(0,P.jsx)(Oe,{className:`text-muted-foreground size-8`}),(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Image could not be generated`}),t&&(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t})]})}function v1({onRegenerate:e}){let[t,n]=(0,N.useState)(!1);return(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{n(!0);try{await e()}catch{}finally{n(!1)}},disabled:t,"data-slot":`image-regenerate`,"aria-label":`Regenerate image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded disabled:opacity-50`,children:(0,P.jsx)(we,{className:a(`size-4`,t&&`animate-spin`)})})}function y1({part:e,onRegenerate:t,className:n}){return(0,P.jsxs)(`div`,{"data-slot":`image-actions`,className:a(`flex items-center gap-1 p-1`,n),children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>l1(e),"data-slot":`image-download`,"aria-label":`Download image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,P.jsx)(se,{className:`size-4`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{u1(e).catch(()=>{})},"data-slot":`image-copy`,"aria-label":`Copy image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,P.jsx)(ae,{className:`size-4`})}),t&&(0,P.jsx)(v1,{onRegenerate:t})]})}var b1=(0,N.memo)(e=>{let{image:t,filename:n,status:r}=e;return r?.type===`running`?(0,P.jsxs)(f1,{children:[(0,P.jsx)(g1,{}),(0,P.jsx)(m1,{children:n})]}):r?.type===`incomplete`&&r.reason===`content-filter`?(0,P.jsx)(f1,{children:(0,P.jsx)(_1,{reason:`The provider blocked this image.`})}):(0,P.jsxs)(f1,{children:[(0,P.jsx)(h1,{src:t,alt:n||`Image content`,children:(0,P.jsx)(p1,{src:t,alt:n||`Image content`})}),(0,P.jsx)(m1,{children:n})]})});b1.displayName=`Image`,b1.Root=f1,b1.Preview=p1,b1.Filename=m1,b1.Zoom=h1,b1.Actions=y1,b1.Generating=g1,b1.ContentFilterError=_1;var x1=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),S1=(e,t)=>{if(!e||!t)return!1;let n=e=>{let{position:t,data:n,...r}=e||{};return r};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&x1(e.children,t.children)},C1=(e,t)=>S1(e.node,t.node),w1=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,N.memo)(({node:e,...t})=>(0,P.jsx)(n,{...t}),C1)]})),T1=(0,N.createContext)(null),E1=()=>(0,N.useContext)(T1)!==null,D1=(0,N.memo)(({children:e,fallbackPre:t,...n})=>n.node?.children.some(e=>e.type===`element`&&e.tagName===`code`)??!0?(0,P.jsx)(T1.Provider,{value:n,children:e}):(0,P.jsx)(t,{...n,children:e}),(e,t)=>e.fallbackPre===t.fallbackPre&&C1(e,t)),O1=({node:e,...t})=>(0,P.jsx)(`pre`,{...t}),k1=({node:e,...t})=>(0,P.jsx)(`code`,{...t}),A1=({node:e,components:{Pre:t,Code:n},code:r})=>(0,P.jsx)(t,{children:(0,P.jsx)(n,{node:e,children:r})}),j1=()=>null,M1=e=>/language-([^\s]+)/.exec(e??``)?.[1]??``,N1=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,N.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(i,{node:e,language:a,code:o}),(0,P.jsx)(r,{node:e,components:s,language:a,code:o})]})},P1=n(r(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),F1=({className:e,...t})=>({className:n,...r})=>({className:(0,P1.default)(e,n),...t,...r});function I1(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=``;for(let n of e)t+=I1(n);return t}return(0,N.isValidElement)(e)?I1(e.props.children):``}var L1=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=F1((0,N.useContext)(T1)),l=fn(e=>(0,P.jsx)(t,{...c(e)})),u=F1(s),d=fn(e=>(0,P.jsx)(n,{...u(e)})),f=M1(s.className),p=a[f]?.SyntaxHighlighter??r,m=a[f]?.CodeHeader??i;return o!=null&&typeof o!=`string`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(m,{node:e,language:f,code:I1(o)}),(0,P.jsx)(A1,{node:e,components:{Pre:l,Code:d},code:o})]}):(0,P.jsx)(N1,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:p,CodeHeader:m},language:f,code:o??``})},R1=({node:e,components:t,componentsByLanguage:n,...r})=>E1()?(0,P.jsx)(L1,{node:e,components:t,componentsByLanguage:n,...r}):(0,P.jsx)(t.Code,{...r}),z1=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let n=e[r],i=t[r];if(n!==i&&(!n||!i||n.SyntaxHighlighter!==i.SyntaxHighlighter||n.CodeHeader!==i.CodeHeader))return!1}return!0},B1=(0,N.memo)(R1,(e,t)=>e.components===t.components&&z1(e.componentsByLanguage,t.componentsByLanguage)&&C1(e,t)),{useSmooth:V1,useSmoothStatus:H1,withSmoothContextProvider:U1}=BZ,W1=(0,N.memo)(({text:e,overrideVersion:t,...n})=>(0,P.jsx)(XD,{...n,children:e}));W1.displayName=`MarkdownRenderer`;var G1=({text:e,...t})=>{let n=(0,N.useDeferredValue)(e);return(0,P.jsx)(W1,{text:n,...t})},K1=e=>typeof e==`object`&&!!e&&!Array.isArray(e),q1=(e,t,n=1)=>{if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!q1(e[r],t[r],n-1))return!1;return!0}if(K1(e)&&K1(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&q1(e[r],t[r],n-1))}return!1};function J1(e,t){let n=(0,N.useRef)(e);return q1(e,n.current,t)||(n.current=e),n.current}function Y1(e){let t=(0,N.useRef)(e),n=(e,t)=>e[t],r=Object.keys(e),i=Object.keys(t.current);return r.length===i.length&&r.every(r=>Object.hasOwn(t.current,r)&&q1(n(e,r),n(t.current,r)))||(t.current=e),t.current}var X1=({components:e,componentsByLanguage:t,smooth:n=!0,defer:r=!1,preprocess:i,...a})=>{let{text:o}=V1(aY(),n),s=(0,N.useMemo)(()=>i?i(o):o,[i,o]),{pre:c=O1,code:l=k1,SyntaxHighlighter:u=A1,CodeHeader:d=j1}=e??{},f=(0,N.useMemo)(()=>({Pre:c,Code:l,SyntaxHighlighter:u,CodeHeader:d}),[c,l,u,d]),p=fn(e=>(0,P.jsx)(B1,{components:f,componentsByLanguage:t,...e})),m=fn(e=>(0,P.jsx)(D1,{fallbackPre:c,...e})),h=Y1((0,N.useMemo)(()=>{let{pre:t,code:n,SyntaxHighlighter:r,CodeHeader:i,...a}=e??{};return{...a,pre:m,code:p}},[p,m,e])),g=J1((0,N.useMemo)(()=>({components:f,componentsByLanguage:t}),[f,t]),3),_=r?G1:W1,v=Y1(a);return(0,P.jsx)(_,{text:s,components:h,overrideVersion:g,...v})},Z1=(0,N.forwardRef)(({className:e,containerProps:t,containerComponent:n=`div`,...r},i)=>{let a=H1();return(0,P.jsx)(n,{"data-status":a.type,...t,className:(0,P1.default)(e,t?.className),ref:i,children:(0,P.jsx)(X1,{...r})})});Z1.displayName=`MarkdownTextPrimitive`;var Q1=U1(Z1),$1=({copiedDuration:e=3e3}={})=>{let[t,n]=(0,N.useState)(!1),r=(0,N.useRef)(void 0),i=(0,N.useRef)(0);return(0,N.useEffect)(()=>()=>{i.current+=1,r.current!==void 0&&(clearTimeout(r.current),r.current=void 0,n(!1))},[]),{isCopied:t,copyToClipboard:t=>{if(!t||typeof navigator>`u`||!navigator.clipboard)return;let a=i.current;navigator.clipboard.writeText(t).then(()=>{a===i.current&&(r.current!==void 0&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{r.current=void 0,n(!1)},e))},()=>{})}}},e0=e=>{let t=(0,N.useRef)(e);if(e!==t.current){let n=t.current;e!==void 0&&n!==void 0&&Object.keys(n).length===Object.keys(e).length&&Object.keys(e).every(t=>n[t]===e[t])||(t.current=e)}return t.current},t0=(0,N.memo)(({components:e})=>{let t=e0(e),n=(0,N.useMemo)(()=>t?{...n0,...w1(t)}:n0,[t]);return(0,P.jsx)(Q1,{remarkPlugins:[ej],className:`aui-md`,components:n,defer:!0})}),n0=w1({h1:({className:e,...t})=>(0,P.jsx)(`h1`,{className:a(`aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0`,e),...t}),h2:({className:e,...t})=>(0,P.jsx)(`h2`,{className:a(`aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0`,e),...t}),h3:({className:e,...t})=>(0,P.jsx)(`h3`,{className:a(`aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0`,e),...t}),h4:({className:e,...t})=>(0,P.jsx)(`h4`,{className:a(`aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0`,e),...t}),h5:({className:e,...t})=>(0,P.jsx)(`h5`,{className:a(`aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0`,e),...t}),h6:({className:e,...t})=>(0,P.jsx)(`h6`,{className:a(`aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0`,e),...t}),p:({className:e,...t})=>(0,P.jsx)(`p`,{className:a(`aui-md-p my-3 leading-relaxed first:mt-0 last:mb-0`,e),...t}),a:({className:e,...t})=>(0,P.jsx)(`a`,{className:a(`aui-md-a text-primary hover:text-primary/80 underline underline-offset-2`,e),...t}),blockquote:({className:e,...t})=>(0,P.jsx)(`blockquote`,{className:a(`aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4`,e),...t}),ul:({className:e,...t})=>(0,P.jsx)(`ul`,{className:a(`aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1`,e),...t}),ol:({className:e,...t})=>(0,P.jsx)(`ol`,{className:a(`aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1`,e),...t}),hr:({className:e,...t})=>(0,P.jsx)(`hr`,{className:a(`aui-md-hr border-muted-foreground/20 my-3`,e),...t}),table:({className:e,...t})=>(0,P.jsx)(`div`,{className:`aui-md-table-wrapper my-3 overflow-x-auto`,children:(0,P.jsx)(`table`,{className:a(`aui-md-table w-full border-separate border-spacing-0`,e),...t})}),th:({className:e,...t})=>(0,P.jsx)(`th`,{className:a(`aui-md-th bg-muted px-3 py-1.5 text-start font-medium first:rounded-ss-lg last:rounded-se-lg [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),td:({className:e,...t})=>(0,P.jsx)(`td`,{className:a(`aui-md-td border-muted-foreground/20 border-s border-b px-3 py-1.5 text-start last:border-e [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),tr:({className:e,...t})=>(0,P.jsx)(`tr`,{className:a(`aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-es-lg [&:last-child>td:last-child]:rounded-ee-lg`,e),...t}),li:({className:e,...t})=>(0,P.jsx)(`li`,{className:a(`aui-md-li leading-relaxed`,e),...t}),strong:({className:e,...t})=>(0,P.jsx)(`strong`,{className:a(`aui-md-strong font-semibold`,e),...t}),sup:({className:e,...t})=>(0,P.jsx)(`sup`,{className:a(`aui-md-sup [&>a]:text-xs [&>a]:no-underline`,e),...t}),pre:({className:e,...t})=>(0,P.jsx)(`pre`,{className:a(`aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed`,e),...t}),code:function({className:e,...t}){let n=E1();return(0,P.jsx)(`code`,{className:a(!n&&`aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]`,e),...t})},CodeHeader:({language:e,code:t})=>{let{isCopied:n,copyToClipboard:r}=$1();return(0,P.jsxs)(`div`,{className:`aui-code-header-root border-border/50 bg-muted/50 mt-3 flex items-center justify-between rounded-t-xl border border-b-0 px-3.5 py-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`aui-code-header-language text-muted-foreground font-medium lowercase`,children:e}),(0,P.jsxs)(O$,{tooltip:`Copy`,onClick:()=>{t&&!n&&r(t)},children:[!n&&(0,P.jsx)(ae,{className:`animate-in zoom-in-75 fade-in duration-150`}),n&&(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})]})]})}});function r0({...e}){return(0,P.jsx)(an,{"data-slot":`collapsible`,...e})}function i0({...e}){return(0,P.jsx)($t,{"data-slot":`collapsible-trigger`,...e})}function a0({...e}){return(0,P.jsx)(tn,{"data-slot":`collapsible-content`,...e})}var o0=(0,N.createContext)(!1),s0=y(`aui-reasoning-root mb-4 w-full`,{variants:{variant:{outline:`rounded-lg border px-3 py-2`,ghost:``,muted:`bg-muted/50 rounded-lg px-3 py-2`}},defaultVariants:{variant:`outline`}});function c0({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,streaming:o,onAnimationStart:s,children:c,...l}){let[u]=(0,N.useState)(i),[d,f]=(0,N.useState)(null),p=n!==void 0,m=p?n:d??(o||u),h=o===!0&&m,g=(0,N.useRef)(o);(0,N.useLayoutEffect)(()=>{g.current!==o&&(g.current=o,!p&&d===null&&!u&&s?.())},[o,p,d,u,s]);let _=(0,N.useCallback)(e=>{s?.(),p||f(e),r?.(e)},[s,p,r]);return(0,P.jsx)(r0,{"data-slot":`reasoning-root`,"data-variant":t,open:m,onOpenChange:_,className:a(`group/reasoning-root`,s0({variant:t,className:e})),style:{"--animation-duration":`200ms`},...l,children:(0,P.jsx)(o0.Provider,{value:h,children:c})})}function l0({side:e=`bottom`,className:t,...n}){return e===`top`?(0,P.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-8`,`bg-[linear-gradient(to_bottom,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_bottom,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n}):(0,P.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8`,`bg-[linear-gradient(to_top,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_top,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n})}function u0({active:e,duration:t,className:n,...r}){let i=t?` (${t}s)`:``;return(0,P.jsxs)(i0,{"data-slot":`reasoning-trigger`,className:a(`aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground flex max-w-[75%] origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,P.jsx)(k,{"data-slot":`reasoning-trigger-icon`,className:`aui-reasoning-trigger-icon size-4 shrink-0`}),(0,P.jsxs)(`span`,{"data-slot":`reasoning-trigger-label`,className:a(`aui-reasoning-trigger-label-wrapper inline-block leading-none tabular-nums`,e&&`shimmer motion-reduce:animate-none`),children:[`Reasoning`,i]}),(0,P.jsx)(j,{"data-slot":`reasoning-trigger-chevron`,className:a(`aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function d0({className:e,children:t,...n}){let r=(0,N.useContext)(o0);return(0,P.jsxs)(a0,{"data-slot":`reasoning-content`,className:a(`aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:[(0,P.jsx)(l0,{side:`top`}),t,r?(0,P.jsx)(l0,{}):null]})}function f0({className:e,children:t,...n}){let r=(0,N.useContext)(o0),i=(0,N.useRef)(null),o=(0,N.useRef)(null);return(0,N.useEffect)(()=>{if(!r)return;let e=i.current,t=o.current;if(!e||!t)return;let n=!0,a=e.scrollTop,s=e.scrollHeight,c=()=>Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight,l=()=>{n&&(e.scrollTop=e.scrollHeight)},u=()=>{c()?n=!0:e.scrollTop<a&&e.scrollHeight===s&&(n=!1),a=e.scrollTop,s=e.scrollHeight};l(),e.addEventListener(`scroll`,u);let d=new ResizeObserver(l);return d.observe(t),()=>{e.removeEventListener(`scroll`,u),d.disconnect()}},[r]),(0,P.jsx)(`div`,{ref:i,"data-slot":`reasoning-text`,className:a(`aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty`,`transform-gpu transition-[transform,opacity] ease-[cubic-bezier(0.32,0.72,0,1)]`,`motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in`,`group-data-closed/collapsible-content:animate-out`,`group-data-open/collapsible-content:fade-in-0`,`group-data-closed/collapsible-content:fade-out-0`,`group-data-open/collapsible-content:slide-in-from-top-4`,`group-data-closed/collapsible-content:slide-out-to-top-4`,`group-data-open/collapsible-content:blur-in-[2px]`,`group-data-closed/collapsible-content:blur-out-[2px]`,`group-data-open/collapsible-content:animation-duration-(--animation-duration)`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration)`,e),...n,children:(0,P.jsx)(`div`,{ref:o,className:`aui-reasoning-text-content space-y-4`,children:t})})}function p0({ref:e,onAnimationStart:t,...n}){let r=(0,N.useRef)(null),i=FZ(r,200),a=(0,N.useCallback)(()=>{i(),t?.()},[i,t]),o=(0,N.useCallback)(t=>{r.current=t,typeof e==`function`?e(t):e&&(e.current=t)},[e]);return(0,P.jsx)(c0,{ref:o,onAnimationStart:a,...n})}var m0=()=>(0,P.jsx)(t0,{}),h0=({children:e,startIndex:t,endIndex:n})=>{let r=$(e=>{if(e.message.status?.type!==`running`)return!1;for(let r=t;r<=n;r++)if(e.message.parts[r]?.status.type===`running`)return!0;return!1});return(0,P.jsxs)(p0,{streaming:r,children:[(0,P.jsx)(u0,{active:r}),(0,P.jsx)(d0,{"aria-busy":r,children:(0,P.jsx)(f0,{children:e})})]})},g0=(0,N.memo)(m0);g0.displayName=`Reasoning`,g0.Root=p0,g0.Trigger=u0,g0.Content=d0,g0.Text=f0,g0.Fade=l0;var _0=(0,N.memo)(h0);_0.displayName=`ReasoningGroup`;function v0({className:e,...t}){return(0,P.jsx)(`textarea`,{"data-slot":`textarea`,className:a(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var y0=200,b0=`active:scale-[0.98]`;function x0({className:e,open:t,onOpenChange:n,defaultOpen:r=!1,children:i,...o}){let s=(0,N.useRef)(null),[c,l]=(0,N.useState)(r),u=FZ(s,y0),d=t!==void 0,f=d?t:c,p=(0,N.useCallback)(e=>{u(),d||l(e),n?.(e)},[u,d,n]);return(0,P.jsx)(r0,{ref:s,"data-slot":`tool-fallback-root`,open:f,onOpenChange:p,className:a(`aui-tool-fallback-root group/tool-fallback-root w-full`,e),style:{"--animation-duration":`${y0}ms`},...o,children:i})}var S0={running:_e,complete:A,incomplete:ne,"requires-action":te},C0=e=>{if(e<1e3)return`<1s`;let t=e/1e3;return t<10?`${(Math.floor(t*10)/10).toFixed(1)}s`:t<60?`${Math.floor(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60)}s`};function w0({className:e,...t}){let n=IZ();return n===void 0?null:(0,P.jsx)(`span`,{"data-slot":`tool-fallback-duration`,className:a(`aui-tool-fallback-duration text-muted-foreground text-xs tabular-nums`,e),...t,children:C0(n)})}function T0({toolName:e,status:t,className:n,...r}){let i=t?.type??`complete`,o=i===`running`,s=t?.type===`incomplete`&&t.reason===`cancelled`,c=S0[i],l=s?`Cancelled tool`:`Used tool`;return(0,P.jsxs)(i0,{"data-slot":`tool-fallback-trigger`,className:a(`aui-tool-fallback-trigger group/trigger text-muted-foreground hover:text-foreground flex w-fit origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,P.jsx)(c,{"data-slot":`tool-fallback-trigger-icon`,className:a(`aui-tool-fallback-trigger-icon size-4 shrink-0`,s&&`text-muted-foreground`,o&&`animate-spin [animation-duration:0.6s]`)}),(0,P.jsxs)(`span`,{"data-slot":`tool-fallback-trigger-label`,className:a(`aui-tool-fallback-trigger-label-wrapper inline-block text-start leading-none`,s&&`text-muted-foreground line-through`,o&&`shimmer motion-reduce:animate-none`),children:[l,`: `,(0,P.jsx)(`b`,{children:e})]}),(0,P.jsx)(w0,{}),(0,P.jsx)(j,{"data-slot":`tool-fallback-trigger-chevron`,className:a(`aui-tool-fallback-trigger-chevron size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function E0({className:e,children:t,...n}){return(0,P.jsx)(a0,{"data-slot":`tool-fallback-content`,className:a(`aui-tool-fallback-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,P.jsx)(`div`,{className:a(`flex flex-col gap-2 ps-6 pt-1 pb-2 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in group-data-open/collapsible-content:fade-in-0 group-data-open/collapsible-content:blur-in-[2px] group-data-open/collapsible-content:slide-in-from-top-1`,`group-data-closed/collapsible-content:animate-out group-data-closed/collapsible-content:fade-out-0 group-data-closed/collapsible-content:blur-out-[2px] group-data-closed/collapsible-content:slide-out-to-top-1`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration) group-data-open/collapsible-content:animation-duration-(--animation-duration)`),children:t})})}function D0({argsText:e,className:t,...n}){return e?(0,P.jsx)(`div`,{"data-slot":`tool-fallback-args`,className:a(`aui-tool-fallback-args`,t),...n,children:(0,P.jsx)(`pre`,{className:`aui-tool-fallback-args-value bg-muted/50 text-foreground/90 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:e})}):null}var O0=(e,t)=>{if(typeof e==`string`)return e;try{if(e instanceof Error)return String(e);let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return`[Unserializable value]`}};function k0({result:e,className:t,...n}){return e===void 0?null:(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-result`,className:a(`aui-tool-fallback-result`,t),...n,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-result-header text-muted-foreground text-xs font-medium`,children:`Result:`}),(0,P.jsx)(`pre`,{className:`aui-tool-fallback-result-content bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:O0(e,2)})]})}function A0({status:e,className:t,...n}){if(e?.type!==`incomplete`)return null;let r=e.error,i=r==null?null:O0(r);if(!i)return null;let o=e.reason===`cancelled`?`Cancelled reason:`:`Error:`;return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-error`,className:a(`aui-tool-fallback-error`,t),...n,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-error-header text-muted-foreground font-semibold`,children:o}),(0,P.jsx)(`p`,{className:`aui-tool-fallback-error-reason text-muted-foreground whitespace-pre-line`,children:i})]})}var j0=`Approved by user`,M0=`User denied tool execution`,N0={"allow-once":`Allow`,"allow-always":`Always allow`,"reject-once":`Deny`,"reject-always":`Always deny`},P0=e=>Object.hasOwn(N0,e),F0=e=>e===`allow-once`||e===`allow-always`,I0=e=>e.label??(P0(e.kind)?N0[e.kind]:void 0)??e.id,L0=e=>e?.display===`select`||e?.display===`text`,R0=(e,t,n)=>e?.type!==`requires-action`||e.reason!==`interrupt`||t!=null||n!=null;function z0({className:e,addResult:t,resume:n,interrupt:r,approval:i,respondToApproval:o,status:c,...l}){let[u,d]=(0,N.useState)(!1),f=$(e=>e.thread.voice!==void 0),p=u||f,[m,h]=(0,N.useState)(null),[g,_]=(0,N.useState)(``),[v,y]=(0,N.useState)(null);if(i!=null&&(i.approved!==void 0||i.resolution!==void 0)||!R0(c,i,r))return null;let b=o?i?.options:void 0,x=i!=null&&o!=null&&KB(i),S=e=>{d(!0),y(null),(async()=>{try{await e()}catch(e){d(!1),y(e instanceof Error?e.message:String(e))}})()},C=e=>{if(!p){if(i!=null&&i.approved===void 0&&o)S(()=>o({approved:e,...T()}));else if(r)S(()=>n?.({approved:e}));else if(c?.type===`requires-action`&&c.reason===`interrupt`)return;else S(()=>t?.(e?j0:M0))}},w=e=>{p||(h(null),S(()=>o?.(P0(e.kind)?{optionId:e.id,...T()}:{optionId:e.id,approved:!0,...T()})))},T=()=>g.trim()?{text:g}:{},E=()=>{p||S(()=>o?.({text:g}))},D=()=>{p||S(()=>o?.({approved:!1}))},O=e=>{e.confirm?h(e.id):w(e)},k=m==null?void 0:b?.find(e=>e.id===m),A=L0(i),j=A&&o!=null&&i?.dismissible===!0?(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:b0,onClick:D,disabled:p,children:`Dismiss`}):null,M=i?.prompt?(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-foreground whitespace-pre-line`,children:i.prompt}):null,ee=v?(0,P.jsx)(`p`,{role:`alert`,className:`aui-tool-fallback-approval-error text-destructive text-xs whitespace-pre-line`,children:v}):null,te=x?(0,P.jsxs)(`div`,{className:`aui-tool-fallback-approval-answer flex flex-col items-start gap-2`,children:[(0,P.jsx)(v0,{value:g,onChange:e=>_(e.target.value),disabled:p,"aria-label":A?i?.prompt??`Answer`:`Note`,placeholder:A?`Type your answer`:`Add a note to your decision`}),A&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:b0,onClick:E,disabled:p,children:`Send`}),j]})]}):null;if(k){let t=typeof k.confirm==`object`?k.confirm:void 0,n=t?.description??k.description;return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval-confirm`,className:a(`aui-tool-fallback-approval-confirm flex flex-col gap-2 pt-1`,e),...l,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-title font-semibold`,children:t?.title??`${I0(k)}?`}),n&&(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-description text-muted-foreground whitespace-pre-line`,children:n}),k.grants&&k.grants.length>0&&(0,P.jsx)(`ul`,{className:`aui-tool-fallback-approval-confirm-grants flex flex-col gap-1`,children:k.grants.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(`code`,{className:`aui-tool-fallback-approval-confirm-grant bg-muted rounded px-1.5 py-0.5 text-xs`,children:e})},e))}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:b0,onClick:()=>w(k),disabled:p,children:`Confirm`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:b0,onClick:()=>h(null),disabled:p,children:`Back`})]})]})}if(b&&b.length>0){let t=b.filter(e=>F0(e.kind)),n=b.filter(e=>!P0(e.kind)),r=b.filter(e=>P0(e.kind)&&!F0(e.kind));return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[...t,...n,...r].map(e=>(0,P.jsx)(s,{size:`sm`,variant:e===t[0]?`default`:`outline`,className:b0,onClick:()=>O(e),disabled:p,children:I0(e)},e.id)),r.length===0&&!A&&(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:b0,onClick:()=>C(!1),disabled:p,children:`Deny`}),!x&&j]}),te,ee]})}return A?(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,te,!x&&j&&(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:j}),ee]}):(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:b0,onClick:()=>C(!0),disabled:p,children:`Allow`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:b0,onClick:()=>C(!1),disabled:p,children:`Deny`})]}),te,ee]})}var B0=(0,N.memo)(({toolName:e,argsText:t,result:n,status:r,addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l})=>{let u=r?.type===`incomplete`&&r.reason===`cancelled`,d=r?.type===`requires-action`,f=d&&R0(r,c,s),[p,m]=(0,N.useState)(d),[h,g]=(0,N.useState)(d);return d!==h&&(g(d),d&&m(!0)),(0,P.jsxs)(x0,{open:p,onOpenChange:m,children:[(0,P.jsx)(T0,{toolName:e,status:r}),(0,P.jsxs)(E0,{children:[(0,P.jsx)(A0,{status:r}),(0,P.jsx)(D0,{argsText:t,className:a(u&&`opacity-60`)}),f&&(0,P.jsx)(z0,{addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l,status:r}),(0,P.jsx)(k0,{result:n})]})]})});B0.displayName=`ToolFallback`,B0.Root=x0,B0.Trigger=T0,B0.Content=E0,B0.Args=D0,B0.Result=k0,B0.Error=A0,B0.Approval=z0;var V0=200,H0=y(`aui-tool-group-root group/tool-group w-full`,{variants:{variant:{outline:`rounded-lg border py-3`,ghost:``,muted:`border-muted-foreground/30 bg-muted/30 rounded-lg border py-3`}},defaultVariants:{variant:`outline`}});function U0({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,children:o,...s}){let c=(0,N.useRef)(null),[l,u]=(0,N.useState)(i),d=FZ(c,V0),f=n!==void 0,p=f?n:l,m=(0,N.useCallback)(e=>{d(),f||u(e),r?.(e)},[d,f,r]);return(0,P.jsx)(r0,{ref:c,"data-slot":`tool-group-root`,"data-variant":t??`outline`,open:p,onOpenChange:m,className:a(H0({variant:t}),`group/tool-group-root`,e),style:{"--animation-duration":`${V0}ms`},...s,children:o})}function W0({count:e,active:t=!1,className:n,...r}){let i=`${e} tool ${e===1?`call`:`calls`}`;return(0,P.jsxs)(i0,{"data-slot":`tool-group-trigger`,className:a(`aui-tool-group-trigger group/trigger flex origin-left items-center gap-2 text-sm transition-[color,scale] active:scale-[0.98]`,`group-data-[variant=ghost]/tool-group-root:text-muted-foreground group-data-[variant=ghost]/tool-group-root:hover:text-foreground group-data-[variant=ghost]/tool-group-root:py-1.5`,`group-data-[variant=outline]/tool-group-root:w-full group-data-[variant=outline]/tool-group-root:px-4`,`group-data-[variant=muted]/tool-group-root:w-full group-data-[variant=muted]/tool-group-root:px-4`,n),...r,children:[t&&(0,P.jsx)(_e,{"data-slot":`tool-group-trigger-loader`,className:`aui-tool-group-trigger-loader size-3 shrink-0 animate-spin [animation-duration:0.6s]`}),(0,P.jsx)(`span`,{"data-slot":`tool-group-trigger-label`,className:a(`aui-tool-group-trigger-label-wrapper inline-block text-start text-xs leading-none font-medium`,`group-data-[variant=ghost]/tool-group-root:font-normal`,`group-data-[variant=outline]/tool-group-root:grow`,`group-data-[variant=muted]/tool-group-root:grow`,t&&`shimmer motion-reduce:animate-none`),children:i}),(0,P.jsx)(j,{"data-slot":`tool-group-trigger-chevron`,className:a(`aui-tool-group-trigger-chevron size-3 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function G0({className:e,children:t,...n}){return(0,P.jsx)(a0,{"data-slot":`tool-group-content`,className:a(`aui-tool-group-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,P.jsx)(`div`,{className:a(`mt-2 flex flex-col gap-2`,`group-data-[variant=ghost]/tool-group-root:mt-1 group-data-[variant=ghost]/tool-group-root:gap-1`,`group-data-[variant=outline]/tool-group-root:mt-3 group-data-[variant=outline]/tool-group-root:border-t group-data-[variant=outline]/tool-group-root:px-4 group-data-[variant=outline]/tool-group-root:pt-3`,`group-data-[variant=muted]/tool-group-root:mt-3 group-data-[variant=muted]/tool-group-root:border-t group-data-[variant=muted]/tool-group-root:px-4 group-data-[variant=muted]/tool-group-root:pt-3`,`[&>*]:animate-in [&>*]:fade-in-0 [&>*]:blur-in-[2px] [&>*]:slide-in-from-top-1 [&>*]:animation-duration-(--animation-duration) [&>*]:ease-[cubic-bezier(0.32,0.72,0,1)]`,`[&>*]:motion-reduce:animate-none`,`[&>*:nth-child(2)]:[animation-delay:40ms]`,`[&>*:nth-child(3)]:[animation-delay:80ms]`,`[&>*:nth-child(4)]:[animation-delay:120ms]`,`[&>*:nth-child(n+5)]:[animation-delay:160ms]`),children:t})})}var K0=(0,N.memo)(({children:e,startIndex:t,endIndex:n})=>{let r=n-t+1;return(0,P.jsxs)(U0,{children:[(0,P.jsx)(W0,{count:r}),(0,P.jsx)(G0,{children:e})]})});K0.displayName=`ToolGroup`,K0.Root=U0,K0.Trigger=W0,K0.Content=G0;function q0({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`skeleton`,className:a(`animate-pulse rounded-md bg-accent`,e),...t})}var J0=tW({reasoning:[`group-chainOfThought`,`group-reasoning`],"tool-call":[`group-chainOfThought`,`group-tool`],"standalone-tool-call":[]}),Y0=[`group-chainOfThought`,`group-task`],X0=(e,t)=>{let n=J0(e,t);return e.type===`tool-call`&&e.messages!==void 0&&n.length>0&&!t?.toolUIs?.[e.toolName]?.length?Y0:n},Z0={},Q0=(0,N.createContext)(Z0),$0=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading),e2=e=>e.thread.messages.length===0&&e.thread.isLoading&&!e.thread.isDisabled&&!e.threads.isLoading,t2=()=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-history-skeleton`,role:`status`,className:`animate-in fade-in fill-mode-both flex flex-col gap-y-6 [animation-delay:150ms] [animation-duration:200ms]`,children:[(0,P.jsx)(`span`,{className:`sr-only`,children:`Loading conversation`}),(0,P.jsx)(q0,{className:`ml-auto h-9 w-2/5 rounded-xl motion-reduce:animate-none`}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,P.jsx)(q0,{className:`h-4 w-11/12 motion-reduce:animate-none`}),(0,P.jsx)(q0,{className:`h-4 w-4/5 motion-reduce:animate-none`}),(0,P.jsx)(q0,{className:`h-4 w-3/5 motion-reduce:animate-none`})]}),(0,P.jsx)(q0,{className:`ml-auto h-9 w-1/3 rounded-xl motion-reduce:animate-none`}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,P.jsx)(q0,{className:`h-4 w-10/12 motion-reduce:animate-none`}),(0,P.jsx)(q0,{className:`h-4 w-2/3 motion-reduce:animate-none`})]})]}),n2=({components:e=Z0,autoFocus:t=!0})=>{let n=$($0);return(0,P.jsx)(Q0.Provider,{value:e,children:(0,P.jsx)(r2,{isEmpty:n,autoFocus:t})})},r2=({isEmpty:e,autoFocus:t})=>{let{Welcome:n=u2}=(0,N.useContext)(Q0);return(0,P.jsx)(QX.Root,{className:`aui-root aui-thread-root bg-background @container flex h-full flex-col`,style:{"--thread-max-width":`44rem`,"--composer-bg":`color-mix(in oklab, var(--color-muted) 30%, transparent)`,"--composer-radius":`1rem`,"--composer-padding":`8px`},children:(0,P.jsx)(QX.Viewport,{turnAnchor:`top`,"data-slot":`aui_thread-viewport`,className:`relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth`,children:(0,P.jsxs)(`div`,{className:a(`mx-auto flex w-full max-w-(--thread-max-width) flex-1 flex-col px-4 pt-4`,e&&`justify-center`),children:[(0,P.jsx)(eL,{condition:$0,children:(0,P.jsx)(n,{})}),(0,P.jsx)(eL,{condition:e2,children:(0,P.jsx)(t2,{})}),(0,P.jsx)(`div`,{"data-slot":`aui_message-group`,className:`mb-14 flex flex-col gap-y-6 empty:hidden`,children:(0,P.jsx)(QX.Messages,{children:()=>(0,P.jsx)(i2,{})})}),(0,P.jsxs)(QX.ViewportFooter,{className:a(`aui-thread-viewport-footer bg-background flex flex-col gap-4 overflow-visible pb-4 md:pb-6`,!e&&`sticky bottom-0 mt-auto rounded-t-(--composer-radius)`),children:[(0,P.jsx)(l2,{}),(0,P.jsx)(a1,{}),(0,P.jsx)(p2,{autoFocus:t}),(0,P.jsx)(eL,{condition:e=>$0(e)&&e.composer.isEmpty,children:(0,P.jsx)(d2,{})})]})]})})})},i2=()=>{let{AssistantMessage:e=g2}=(0,N.useContext)(Q0),t=$(e=>e.message.role),n=$(e=>e.message.composer.isEditing),r=$(e=>e.message.metadata.modality===`voice`);return n?(0,P.jsx)(S2,{}):r?(0,P.jsx)(s2,{}):t===`user`?(0,P.jsx)(b2,{}):(0,P.jsx)(e,{})},a2=()=>$(e=>{let t=e.thread.messages[e.message.index-1]?.metadata.modality===`voice`,n=e.thread.messages[e.message.index+1]?.metadata.modality===`voice`;return t?n?`middle`:`end`:n?`start`:`single`}),o2=({text:e})=>(0,P.jsx)(`p`,{className:`aui-spoken-message-text m-0`,children:e}),s2=()=>{let e=$(e=>e.message.role),t=a2(),n=$(e=>e.message.role===`assistant`&&e.message.status?.type===`running`),r=t===`start`||t===`single`;return(0,P.jsxs)(mX.Root,{"data-slot":`aui_spoken-message-root`,"data-role":e,"data-voice-run":t,className:a(`aui-spoken-message bg-muted/40 mx-2 px-3 py-1.5 [contain-intrinsic-size:auto_48px] [content-visibility:auto]`,t===`single`&&`rounded-xl py-2`,t===`start`&&`rounded-t-xl pt-2`,t===`middle`&&`-mt-6`,t===`end`&&`-mt-6 rounded-b-xl pb-2`),children:[r&&(0,P.jsxs)(`div`,{"data-slot":`aui_spoken-exchange-header`,className:`text-muted-foreground mb-1.5 flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(Se,{className:`size-3`,"aria-hidden":!0}),(0,P.jsx)(`span`,{children:`Voice conversation`})]}),(0,P.jsxs)(`div`,{"data-slot":`aui_spoken-message-content`,className:`text-foreground flex items-start gap-2 text-sm leading-relaxed`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground mt-1 shrink-0`,"aria-hidden":!0,children:e===`user`?(0,P.jsx)(ve,{className:`size-3.5`}):(0,P.jsx)(D,{className:`size-3.5`})}),(0,P.jsx)(`span`,{className:`sr-only`,children:e===`user`?`You said`:`Assistant said`}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1 wrap-break-word`,children:[(0,P.jsx)(mX.Parts,{components:{Text:o2}}),n&&(0,P.jsx)(`span`,{"data-slot":`aui_spoken-message-indicator`,role:`status`,className:`text-muted-foreground ms-1 animate-pulse font-sans`,"aria-label":`Assistant is speaking`,children:`●`})]}),(0,P.jsx)(c2,{})]})]})},c2=()=>(0,P.jsx)(NK.Root,{hideWhenRunning:!0,autohide:`always`,className:`aui-spoken-action-bar text-muted-foreground flex shrink-0 gap-1`,children:(0,P.jsx)(NK.Copy,{asChild:!0,children:(0,P.jsxs)(O$,{tooltip:`Copy`,className:`size-6`,children:[(0,P.jsx)(eL,{condition:e=>e.message.isCopied,children:(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(eL,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(ae,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})})}),l2=()=>(0,P.jsx)(QX.ScrollToBottom,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Scroll to bottom`,variant:`outline`,className:`aui-thread-scroll-to-bottom dark:border-border dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible`,children:(0,P.jsx)(C,{})})}),u2=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-root mb-6 flex flex-col px-2`,children:(0,P.jsx)(`p`,{className:`aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-medium tracking-tight duration-200`,children:`How can I help you today?`})}),d2=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-suggestions flex w-full flex-col`,children:(0,P.jsx)(QX.Suggestions,{children:()=>(0,P.jsx)(f2,{})})}),f2=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-2 animate-in fill-mode-both duration-200`,children:(0,P.jsx)(aZ.Trigger,{send:!0,asChild:!0,children:(0,P.jsxs)(`button`,{type:`button`,className:`aui-thread-welcome-suggestion group hover:bg-foreground/[0.03] focus-visible:ring-ring/50 flex w-full items-baseline gap-2.5 rounded-md px-2 py-2 text-start text-sm transition-colors outline-none focus-visible:ring-1 motion-reduce:transition-none`,children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 group-hover:text-foreground font-mono text-xs transition-colors motion-reduce:transition-none`,children:`>`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,P.jsx)(aZ.Title,{className:`aui-thread-welcome-suggestion-text-1 text-foreground`}),` `,(0,P.jsx)(aZ.Description,{className:`aui-thread-welcome-suggestion-text-2 text-muted-foreground empty:hidden`})]})]})})}),p2=({autoFocus:e})=>(0,P.jsx)(nY.Root,{className:`aui-composer-root relative flex w-full flex-col`,children:(0,P.jsx)(nY.AttachmentDropzone,{asChild:!0,children:(0,P.jsxs)(`div`,{"data-slot":`aui_composer-shell`,className:`border-foreground/10 focus-within:border-foreground/25 data-[dragging=true]:border-ring flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]`,children:[(0,P.jsx)(U$,{}),(0,P.jsx)(nY.Input,{placeholder:`Send a message...`,className:`aui-composer-input caret-primary placeholder:text-muted-foreground/60 max-h-48 min-h-10 w-full resize-none bg-transparent px-2.5 py-1 text-base leading-6 outline-none`,rows:1,autoFocus:e,enterKeyHint:`send`,"aria-label":`Message input`}),(0,P.jsx)(m2,{})]})})}),m2=()=>(0,P.jsxs)(`div`,{className:`aui-composer-action-wrapper relative flex items-center justify-between`,children:[(0,P.jsx)(W$,{}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsxs)(eL,{condition:e=>e.thread.capabilities.dictation,children:[(0,P.jsx)(eL,{condition:e=>e.composer.dictation==null,children:(0,P.jsx)(nY.Dictate,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Voice input`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-dictate text-muted-foreground hover:text-foreground size-7 rounded-full`,"aria-label":`Start voice input`,children:(0,P.jsx)(ve,{className:`aui-composer-dictate-icon size-4`})})})}),(0,P.jsx)(eL,{condition:e=>e.composer.dictation!=null,children:(0,P.jsx)(nY.StopDictation,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Stop dictation`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-stop-dictation text-destructive size-7 rounded-full`,"aria-label":`Stop voice input`,children:(0,P.jsx)(Ae,{className:`aui-composer-stop-dictation-icon size-3.5 animate-pulse fill-current`})})})})]}),(0,P.jsx)(eL,{condition:e=>!e.thread.isRunning||e.thread.voice!==void 0,children:(0,P.jsx)(nY.Send,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Send message`,side:`bottom`,type:`button`,variant:`default`,size:`icon`,className:`aui-composer-send size-7 rounded-full`,"aria-label":`Send message`,children:(0,P.jsx)(E,{className:`aui-composer-send-icon size-4`})})})}),(0,P.jsx)(eL,{condition:e=>e.thread.isRunning&&e.thread.voice===void 0,children:(0,P.jsx)(nY.Cancel,{asChild:!0,children:(0,P.jsx)(s,{type:`button`,variant:`default`,size:`icon`,className:`aui-composer-cancel size-7 rounded-full`,"aria-label":`Stop generating`,children:(0,P.jsx)(Ae,{className:`aui-composer-cancel-icon size-3.5 fill-current`})})})})]})]}),h2=()=>(0,P.jsx)(mX.Error,{children:(0,P.jsx)(OY.Root,{className:`aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200`,children:(0,P.jsx)(OY.Message,{className:`aui-message-error-message line-clamp-2`})})}),g2=()=>{let{ToolFallback:e=B0,ToolGroup:t,ReasoningGroup:n,TaskGroup:r}=(0,N.useContext)(Q0),i=r?X0:J0;return(0,P.jsxs)(mX.Root,{"data-slot":`aui_assistant-message-root`,"data-role":`assistant`,className:`fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:[(0,P.jsxs)(`div`,{"data-slot":`aui_assistant-message-content`,className:`text-foreground px-2 leading-relaxed wrap-break-word`,children:[(0,P.jsx)(mX.GroupedParts,{groupBy:i,children:({part:i,children:a})=>{switch(i.type){case`group-chainOfThought`:return(0,P.jsx)(`div`,{"data-slot":`aui_chain-of-thought`,children:a});case`group-task`:return r?(0,P.jsx)(r,{group:i}):null;case`group-tool`:return t?(0,P.jsx)(t,{group:i,children:a}):(0,P.jsxs)(U0,{variant:`ghost`,children:[(0,P.jsx)(W0,{count:i.indices.length,active:i.status.type===`running`}),(0,P.jsx)(G0,{children:a})]});case`group-reasoning`:{if(n)return(0,P.jsx)(n,{group:i,children:a});let e=i.status.type===`running`;return(0,P.jsxs)(p0,{streaming:e,children:[(0,P.jsx)(u0,{active:e}),(0,P.jsx)(d0,{"aria-busy":e,children:(0,P.jsx)(f0,{children:a})})]})}case`text`:return(0,P.jsx)(t0,{});case`reasoning`:return(0,P.jsx)(g0,{...i});case`tool-call`:return i.toolUI??(0,P.jsx)(e,{...i});case`data`:return i.dataRendererUI;case`file`:return(0,P.jsx)(`div`,{"data-slot":`aui_assistant-message-file`,className:`py-1`,children:(0,P.jsx)(r1,{...i})});case`image`:return(0,P.jsx)(`div`,{"data-slot":`aui_assistant-message-image`,className:`py-1`,children:(0,P.jsx)(b1,{...i})});case`indicator`:return(0,P.jsx)(`span`,{"data-slot":`aui_assistant-message-indicator`,className:`animate-pulse font-sans`,"aria-label":`Assistant is working`,children:`●`});default:return null}}}),(0,P.jsx)(h2,{})]}),(0,P.jsxs)(`div`,{"data-slot":`aui_assistant-message-footer`,className:a(`ms-2 flex items-center`,`min-h-7.5 pt-1.5`),children:[(0,P.jsx)(C2,{}),(0,P.jsx)(_2,{})]})]})},_2=()=>(0,P.jsxs)(NK.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-assistant-action-bar-root text-muted-foreground animate-in fade-in col-start-3 row-start-2 -ms-1 flex gap-1 duration-200`,children:[(0,P.jsx)(NK.Copy,{asChild:!0,children:(0,P.jsxs)(O$,{tooltip:`Copy`,children:[(0,P.jsx)(eL,{condition:e=>e.message.isCopied,children:(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(eL,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(ae,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})}),(0,P.jsxs)(eL,{condition:e=>e.thread.capabilities.feedback,children:[(0,P.jsx)(NK.FeedbackPositive,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(Pe,{})})}),(0,P.jsx)(NK.FeedbackNegative,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Not helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(Ne,{})})})]}),(0,P.jsx)(NK.Reload,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Refresh`,children:(0,P.jsx)(we,{})})}),(0,P.jsxs)(WK.Root,{children:[(0,P.jsx)(WK.Trigger,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`More`,className:`data-[state=open]:bg-accent`,children:(0,P.jsx)(ce,{})})}),(0,P.jsx)(WK.Content,{side:`bottom`,align:`start`,sideOffset:6,className:`aui-action-bar-more-content bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-[8rem] overflow-hidden rounded-xl border p-1.5`,children:(0,P.jsx)(NK.ExportMarkdown,{asChild:!0,children:(0,P.jsxs)(WK.Item,{className:`aui-action-bar-more-item hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(se,{className:`size-4`}),`Export as Markdown`]})})})]})]}),v2=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-file`,className:`py-1`,children:(0,P.jsx)(r1,{...e})}),y2=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-image`,className:`py-1`,children:(0,P.jsx)(b1,{...e})}),b2=()=>(0,P.jsxs)(mX.Root,{"data-slot":`aui_user-message-root`,className:`fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto] [&:where(>*)]:col-start-2`,"data-role":`user`,children:[(0,P.jsx)(H$,{}),(0,P.jsxs)(`div`,{className:`aui-user-message-content-wrapper relative col-start-2 min-w-0`,children:[(0,P.jsx)(`div`,{className:`aui-user-message-content peer bg-muted text-foreground rounded-(--composer-radius) px-4 py-2 wrap-break-word empty:hidden`,children:(0,P.jsx)(mX.Parts,{components:{File:v2,Image:y2}})}),(0,P.jsx)(`div`,{className:`aui-user-action-bar-wrapper absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-2 peer-empty:hidden rtl:translate-x-full`,children:(0,P.jsx)(x2,{})})]}),(0,P.jsx)(C2,{"data-slot":`aui_user-branch-picker`,className:`col-span-full col-start-1 -me-1 justify-end`})]}),x2=()=>(0,P.jsx)(NK.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-user-action-bar-root flex flex-col items-end`,children:(0,P.jsx)(NK.Edit,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Edit`,className:`aui-user-action-edit`,children:(0,P.jsx)(xe,{})})})}),S2=()=>(0,P.jsx)(mX.Root,{"data-slot":`aui_edit-composer-wrapper`,className:`flex flex-col px-2 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:(0,P.jsxs)(nY.Root,{className:`aui-edit-composer-root border-foreground/10 focus-within:border-foreground/25 ms-auto flex w-full max-w-[85%] cursor-text flex-col rounded-(--composer-radius) border bg-(--composer-bg) transition-[border-color]`,children:[(0,P.jsx)(nY.Input,{className:`aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none`,autoFocus:!0}),(0,P.jsxs)(`div`,{className:`aui-edit-composer-footer mx-2.5 mb-2.5 flex items-center gap-1.5 self-end`,children:[(0,P.jsx)(nY.Cancel,{asChild:!0,children:(0,P.jsx)(s,{variant:`ghost`,size:`sm`,className:`h-8 px-3`,children:`Cancel`})}),(0,P.jsx)(nY.Send,{asChild:!0,children:(0,P.jsx)(s,{size:`sm`,className:`h-8 px-3`,children:`Update`})})]})]})}),C2=({className:e,...t})=>(0,P.jsxs)(sq.Root,{hideWhenSingleBranch:!0,className:a(`aui-branch-picker-root text-muted-foreground -ms-2 me-2 inline-flex items-center text-xs`,e),...t,children:[(0,P.jsx)(sq.Previous,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Previous`,children:(0,P.jsx)(M,{})})}),(0,P.jsxs)(`span`,{className:`aui-branch-picker-state font-medium`,children:[(0,P.jsx)(sq.Number,{}),` / `,(0,P.jsx)(sq.Count,{})]}),(0,P.jsx)(sq.Next,{asChild:!0,children:(0,P.jsx)(O$,{tooltip:`Next`,children:(0,P.jsx)(ee,{})})})]}),w2=()=>{let[e,t]=(0,N.useState)(``),n=$(e=>e.threads.threadIds.length>0);return(0,P.jsxs)(E2,{children:[(0,P.jsx)(N2,{}),n&&(0,P.jsx)(T2,{value:e,onValueChange:t}),(0,P.jsx)(D2,{searchQuery:n?e:``})]})},T2=(0,N.forwardRef)(({className:e,value:t,onValueChange:n,...r},i)=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-list-search`,className:`relative px-0.5 py-1`,children:[(0,P.jsx)(Ee,{"data-slot":`aui_thread-list-search-icon`,className:`text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2`}),(0,P.jsx)(m,{ref:i,type:`search`,value:t,onChange:e=>n(e.target.value),"aria-label":`Search threads`,placeholder:`Search threads`,className:a(`h-8 ps-8 text-sm`,e),...r})]}));T2.displayName=`ThreadListSearch`;var E2=({className:e,...t})=>(0,P.jsx)(gZ.Root,{"data-slot":`aui_thread-list-root`,className:a(`flex flex-col gap-0.5`,e),...t}),D2=({className:e,searchQuery:t=``,...n})=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-list-items`,className:a(`flex flex-col gap-0.5`,e),...n,children:[(0,P.jsx)(eL,{condition:e=>e.threads.isLoading,children:(0,P.jsx)(P2,{})}),(0,P.jsx)(eL,{condition:e=>!e.threads.isLoading,children:(0,P.jsx)(j2,{searchQuery:t})})]}),O2=864e5,k2=(e,t)=>!e||e.getTime()>=t?`Today`:e.getTime()>=t-O2?`Yesterday`:`Earlier`,A2=(e=``)=>{let t=$(e=>e.threads.threadIds),n=$(e=>e.threads.threadItems),r=e.trim().toLowerCase();return(0,N.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e])),i=t=>!r||(e.get(t)?.title||`New Chat`).toLowerCase().includes(r),a=t=>e.get(t)?.status===`archived`,o=t.map(t=>e.get(t)?.lastMessageAt),s=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&!a(e)).map(({index:e})=>e),c=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&a(e)).map(({index:e})=>e);if(!s.some(e=>o[e]))return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:null};let l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),d=e=>o[e]?.getTime()??2**53-1,f=[...s].sort((e,t)=>d(t)-d(e)),p=[];for(let e of f){let t=k2(o[e],u),n=p[p.length-1];n?.label===t?n.indices.push(e):p.push({label:t,indices:[e]})}return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:p}},[t,n,r])},j2=({searchQuery:e=``})=>{let{threadIds:t,filteredIndices:n,archivedIndices:r,groups:i}=A2(e);return e.trim()&&n.length===0&&r.length===0?(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-empty`,className:`text-muted-foreground px-2.5 py-4 text-sm`,children:`No threads found`}):i?(0,P.jsxs)(P.Fragment,{children:[i.map(e=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:e.label}),e.indices.map(e=>(0,P.jsx)(gZ.ItemByIndex,{index:e,components:{ThreadListItem:F2}},t[e]))]},e.label)),(0,P.jsx)(M2,{threadIds:t,indices:r})]}):(0,P.jsxs)(P.Fragment,{children:[n.map(e=>(0,P.jsx)(gZ.ItemByIndex,{index:e,components:{ThreadListItem:F2}},t[e])),(0,P.jsx)(M2,{threadIds:t,indices:r})]})},M2=({threadIds:e,indices:t})=>t.length?(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:`Archived`}),t.map(t=>(0,P.jsx)(gZ.ItemByIndex,{index:t,components:{ThreadListItem:F2}},e[t]))]}):null,N2=(0,N.forwardRef)(({className:e,labelClassName:t,children:n,...r},i)=>(0,P.jsx)(gZ.New,{asChild:!0,children:(0,P.jsx)(s,{ref:i,variant:`ghost`,"data-slot":`aui_thread-list-new`,className:a(`hover:bg-muted data-active:bg-muted h-8 justify-start gap-2 rounded-md px-2.5 text-sm font-normal`,e),...r,children:n??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Ce,{"data-slot":`aui_thread-list-new-icon`,className:`size-4 shrink-0`}),(0,P.jsx)(`span`,{"data-slot":`aui_thread-list-new-label`,className:a(`whitespace-nowrap`,t),children:`New Thread`})]})})}));N2.displayName=`ThreadListNew`;var P2=()=>(0,P.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:Array.from({length:5},(e,t)=>(0,P.jsx)(`div`,{role:`status`,"aria-label":`Loading threads`,"data-slot":`aui_thread-list-skeleton-wrapper`,className:`flex h-8 items-center px-2.5`,children:(0,P.jsx)(q0,{"data-slot":`aui_thread-list-skeleton`,className:`h-3.5 w-full`})},t))}),F2=()=>{let e=$(e=>e.threadListItem.isRunning),t=$(e=>e.threadListItem.status)===`archived`,[n,r]=(0,N.useState)(!1),i=(0,N.useRef)(null),o=(0,N.useRef)(!1);return(0,N.useEffect)(()=>{!n&&o.current&&(o.current=!1,i.current?.focus())},[n]),(0,P.jsxs)(CZ.Root,{"data-slot":`aui_thread-list-item`,"data-archived":t||void 0,className:a(`group hover:bg-muted focus-visible:bg-muted data-active:bg-muted has-focus-visible:bg-muted has-data-[state=open]:bg-muted relative flex h-8 items-center rounded-md transition-colors focus-visible:outline-none`,t&&`opacity-60`),children:[n?(0,P.jsx)(I2,{onDone:e=>{o.current=e,r(!1)}}):(0,P.jsxs)(CZ.Trigger,{ref:i,"data-slot":`aui_thread-list-item-trigger`,className:`focus-visible:ring-ring/50 flex h-full min-w-0 flex-1 items-center rounded-md px-2.5 text-start text-sm outline-none group-hover:pe-9 group-has-focus-visible:pe-9 group-has-data-[state=open]:pe-9 group-data-active:pe-9 focus-visible:ring-1`,children:[e&&(0,P.jsx)(ge,{"aria-hidden":!0,"data-slot":`aui_thread-list-item-running`,className:`text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin`}),(0,P.jsx)(`span`,{"data-slot":`aui_thread-list-item-title`,className:`min-w-0 flex-1 truncate`,children:(0,P.jsx)(CZ.Title,{fallback:`New Chat`})}),e&&(0,P.jsx)(`span`,{className:`sr-only`,children:`Running`})]}),(0,P.jsx)(L2,{archived:t,onRename:()=>r(!0)})]})},I2=({onDone:e})=>{let t=Q(),n=$(e=>e.threadListItem.title)??``,[r,i]=(0,N.useState)(n),a=(0,N.useRef)(null),o=(0,N.useRef)(!1);(0,N.useEffect)(()=>{a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0;let s=r.trim();if(!s||s===n){e(i);return}Promise.resolve().then(()=>t.threadListItem.rename(s)).then(()=>e(i),()=>{o.current=!1,i&&a.current?.focus()})},c=()=>{o.current||(o.current=!0,e(!0))};return(0,P.jsx)(m,{ref:a,autoFocus:!0,"data-slot":`aui_thread-list-item-rename`,"aria-label":`Rename thread`,value:r,className:`h-7 min-w-0 flex-1 ps-2.5 pe-9 text-sm`,onChange:e=>i(e.target.value),onBlur:()=>s(!1),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s(!0)):e.key===`Escape`&&(e.preventDefault(),c())}})},L2=({archived:e,onRename:t})=>(0,P.jsxs)(PZ.Root,{sharedFocusGroup:!0,children:[(0,P.jsx)(PZ.Trigger,{asChild:!0,children:(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,"data-slot":`aui_thread-list-item-more`,className:`data-[state=open]:bg-accent absolute end-1.5 top-1/2 size-6 -translate-y-1/2 p-0 opacity-0 group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 data-[state=open]:opacity-100`,children:[(0,P.jsx)(ce,{className:`size-3.5`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`More options`})]})}),(0,P.jsxs)(PZ.Content,{side:`right`,align:`start`,sideOffset:6,"data-slot":`aui_thread-list-item-more-content`,className:`bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-32 overflow-hidden rounded-xl border p-1.5`,children:[(0,P.jsxs)(PZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,onSelect:t,children:[(0,P.jsx)(xe,{className:`size-4`}),`Rename`]}),e?(0,P.jsx)(CZ.Unarchive,{asChild:!0,children:(0,P.jsxs)(PZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(x,{className:`size-4`}),`Unarchive`]})}):(0,P.jsx)(CZ.Archive,{asChild:!0,children:(0,P.jsxs)(PZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(S,{className:`size-4`}),`Archive`]})}),(0,P.jsx)(CZ.Delete,{asChild:!0,children:(0,P.jsxs)(PZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive focus:bg-destructive/10 focus:text-destructive flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(Fe,{className:`size-4`}),`Delete`]})})]})]}),R2=`bg-background border border-border/60 dark:bg-popover`;function z2({phase:e,attempt:t,resumedTokens:n,onRetry:r,className:i,...o}){return e===`online`?null:(0,P.jsxs)(`div`,{"data-slot":`connection-state`,className:a(R2,`fade-in slide-in-from-top-1 animate-in flex w-full max-w-sm items-center gap-2.5 rounded-2xl px-3.5 py-2.5 duration-300`,i),...o,children:[e===`dropped`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ie,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Connection lost. The run kept going on the server.`}),(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`text-foreground/70 hover:bg-foreground/[0.06] hover:text-foreground/95 shrink-0 rounded-full px-2.5 py-1 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]`,children:`Reconnect`})]}),e===`reconnecting`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(ge,{className:`text-foreground/40 size-3.5 shrink-0 animate-spin motion-reduce:animate-none`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Reconnecting`}),t!==void 0&&(0,P.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`attempt `,t]})]}),e===`resumed`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(A,{className:`size-3.5 shrink-0 text-emerald-500`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Picked the stream back up.`}),n!==void 0&&(0,P.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`+`,n,` tokens`]})]})]})}var B2=[`pending`,`testing`,`confirmed`,`rejected`,`blocked`],V2=H(B2),H2=V({tasks:B(V({id:R(),title:R(),status:V2.default(`pending`),note:R().optional()})),target:R().optional(),phase:R().optional()}),U2={tasks:[]};function W2(e){return typeof e==`string`&&B2.includes(e)}function G2(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[^a-z_-]/g,``);if(t===`pending`||t===`todo`||t===`hypothesis`||t===`planned`||t===`open`)return`pending`;if(t===`testing`||t===`in_progress`||t===`inprogress`||t===`active`||t===`probing`)return`testing`;if(t===`confirmed`||t===`verified`||t===`exploited`||t===`vulnerable`||t===`success`)return`confirmed`;if(t===`rejected`||t===`tested_safe`||t===`testedsafe`||t===`safe`||t===`clean`||t===`not_vulnerable`||t===`notvulnerable`||t===`invalid`)return`rejected`;if(t===`blocked`||t===`justified_blocked`||t===`justifiedblocked`||t===`needs_auth`||t===`needsauth`||t===`untestable`)return`blocked`}var K2=/https?:\/\/[^\s<>")']+/i,q2=/\b(?:[a-z0-9-]+\.)+[a-z]{2,}\b/i;function J2(e){if(!e||typeof e!=`string`)return null;let t=e.match(K2);if(t?.[0]){let e=t[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<512)return e}let n=e.match(q2);if(n?.[0]){let e=n[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<256&&!e.endsWith(`.ts`)&&!e.endsWith(`.js`)&&!e.endsWith(`.json`)&&!e.endsWith(`.md`)&&!e.endsWith(`.html`)&&!e.endsWith(`.txt`))return e}return null}function Y2(e){let t=0;for(let n of e){let e=n.id.match(/^T-(\d+)$/i);e&&(t=Math.max(t,Number.parseInt(e[1],10)))}return`T-${t+1}`}function X2(e,t){let n=new Map;for(let t of e)n.set(t.id,{...t});for(let e of t){let t=n.get(e.id);t?n.set(e.id,{id:e.id,title:e.title||t.title,status:e.status||t.status,note:e.note===void 0?t.note:e.note}):n.set(e.id,{...e})}return Array.from(n.values())}var Z2=/-\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([A-Za-z0-9_-]+):\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,Q2=/Task\s+([A-Za-z0-9_-]+)\s+(?:added|updated):\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,$2=/<kifaru_dossier\s+target="([^"]+)"(?:\s+phase="([^"]+)")?/i;function e4(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=e.split(/\r?\n/);for(let e of i){let t=e.trim();if(!t.startsWith(`|`)||!t.endsWith(`|`))continue;let i=t.split(`|`).map(e=>e.trim()),a=i.filter((e,t)=>t>0&&t<i.length-1);if(a.length<2||a.every(e=>/^[-:=|\s]+$/.test(e)))continue;let o=G2(a[1]),s=a[0],c=a[2];if(o||(o=G2(a[0]),o&&(s=a[1],c=a[2])),!o||!s||(s=s.replace(/^[`*_\s]+|[`*_\s]+$/g,``).trim(),!s||s.toLowerCase()===`cell`||s.toLowerCase()===`task`))continue;let l,u=s.match(/^(T-\d+)[:\s—-]+(.*)$/i);u?.[1]&&(l=u[1].toUpperCase(),s=u[2].trim());let d=s.toLowerCase(),f=r.get(d);if(f)f.status=o,c&&(f.note=c.trim());else{let e={id:l||Y2(n),title:s,status:o,note:c?c.trim():void 0};n.push(e),r.set(d,e)}}return n}function t4(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=/^\s*[-*]\s*\[([ xX/!?-])\]\s*(?:([A-Za-z0-9_-]+):)?\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gm,a;for(;(a=i.exec(e))!==null;){let[,e,t,i,o]=a;if(!i)continue;let s=`pending`;e===`x`||e===`X`?s=`confirmed`:e===`/`?s=`testing`:e===`!`?s=`blocked`:(e===`-`||e===`?`)&&(s=`rejected`);let c=i.trim(),l=c.toLowerCase(),u=r.get(l);if(u)u.status=s,o&&(u.note=o.trim());else{let e={id:t?.startsWith(`T-`)?t.toUpperCase():Y2(n),title:c,status:s,note:o?o.trim():void 0};n.push(e),r.set(l,e)}}return n}function n4(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);for(let t of e){let e=typeof t==`string`?t:typeof t==`object`&&t&&`note`in t?String(t.note??``):``;if(!e)continue;let i,a,o;if(/^CONFIRMED(\([^)]+\))?:/i.test(e)){i=`confirmed`;let t=e.replace(/^CONFIRMED(\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`.`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():void 0}else if(/BLOCKED/i.test(e)&&(/coverage gap/i.test(e)||/needs auth/i.test(e))){i=`blocked`;let t=e.replace(/^Coverage gap(\s*\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`—`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():t}if(i&&a){let e=a.toLowerCase(),t=r.get(e);if(t)t.status=i,o&&(t.note=o);else{let t={id:Y2(n),title:a,status:i,note:o};n.push(t),r.set(e,t)}}}return n}function r4(e){let t=[],n,r;for(let i of e){if(i.role===`user`){let e=``;if(typeof i.content==`string`)e=i.content;else if(Array.isArray(i.content))for(let t of i.content)typeof t==`object`&&t&&`type`in t&&t.type===`text`&&(e+=` ${t.text??``}`);let t=J2(e);t&&(n=t)}if(i.role===`custom`&&i.customType===`kifaru-dossier`){let e=typeof i.content==`string`?i.content:``,a=e.match(/Bound target:\s*([^\n\r]+)/i)||e.match(/Session bound to target\s*([^\n\r.]+)/i);a?.[1]&&(n=a[1].trim());let o=e.match(/Phase:\s*([a-zA-Z0-9_-]+)/i);o?.[1]&&(r=o[1].trim());let s;for(Z2.lastIndex=0;(s=Z2.exec(e))!==null;){let[,e,n,r,i]=s;n&&r&&W2(e)&&(t=X2(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}if(i.role===`assistant`&&Array.isArray(i.content)){for(let e of i.content)if(typeof e==`object`&&e&&`type`in e){if(e.type===`text`&&typeof e.text==`string`){let i=e.text,a=J2(i);a&&!n&&(n=a);let o=i.match($2);o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),t=e4(i,t),t=t4(i,t)}if(e.type===`tool-call`||e.type===`toolCall`){let i=e,a=i.name??i.toolName,o=i.args??i.arguments;if(a===`kifaru_dossier`&&o&&(typeof o.target==`string`&&o.target.trim()&&(n=o.target.trim()),typeof o.phase==`string`&&o.phase.trim()&&(r=o.phase.trim()),o.action===`task`)){let e=typeof o.taskId==`string`?o.taskId.trim():void 0,n=typeof o.title==`string`?o.title.trim():void 0,r=typeof o.note==`string`?o.note.trim():void 0;e&&(t=X2(t,[{id:e,title:n||e,status:W2(o.status)?o.status:`pending`,note:r}]))}}}}if(i.role===`toolResult`){let e=i;for(let i of e.content??[])if(i.type===`text`&&i.text){let e=i.text.trim();if(e.startsWith(`{`)&&e.endsWith(`}`))try{let i=JSON.parse(e);if(typeof i.target==`string`&&(n=i.target),typeof i.phase==`string`&&(r=i.phase),Array.isArray(i.tasks)){let e=[];for(let t of i.tasks)typeof t.id==`string`&&typeof t.title==`string`&&e.push({id:t.id,title:t.title,status:W2(t.status)?t.status:`pending`,note:typeof t.note==`string`?t.note:void 0});t=X2(t,e)}Array.isArray(i.observations)&&(t=n4(i.observations,t))}catch{}t=e4(e,t),t=t4(e,t);let a;for(Q2.lastIndex=0;(a=Q2.exec(e))!==null;){let[,e,n,r,i]=a;e&&r&&W2(n)&&(t=X2(t,[{id:e.trim(),title:r.trim(),status:n,note:i?i.trim():void 0}]))}let o=e.match($2);for(o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),Z2.lastIndex=0;(a=Z2.exec(e))!==null;){let[,e,n,r,i]=a;n&&r&&W2(e)&&(t=X2(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}}}return{tasks:t,target:n,phase:r}}var i4={pending:re,testing:ge,confirmed:A,rejected:ne,blocked:te},a4={pending:{badge:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,text:`text-muted-foreground`,ring:`border-border`},testing:{badge:`bg-blue-500/10 text-blue-500 border-blue-500/30 hover:bg-blue-500/20`,text:`text-blue-500`,ring:`border-blue-500/40 bg-blue-500/10`},confirmed:{badge:`bg-emerald-500/10 text-emerald-500 border-emerald-500/30 hover:bg-emerald-500/20`,text:`text-emerald-500`,ring:`border-emerald-500/50 bg-emerald-500/20`},rejected:{badge:`bg-rose-500/10 text-rose-500 border-rose-500/30 hover:bg-rose-500/20`,text:`text-rose-500`,ring:`border-rose-500/40 bg-rose-500/10`},blocked:{badge:`bg-amber-500/10 text-amber-500 border-amber-500/30 hover:bg-amber-500/20`,text:`text-amber-500`,ring:`border-amber-500/40 bg-amber-500/10`}};function o4({className:e=``,onClose:t}){let[n,{setState:r}]=yz(`taskBoard`,{description:`A task board panel for the target dossier tracking hunt theses, tests, and findings. Use update_taskBoard with tasks.add/update/remove/clear to manage tasks. Tasks have id (e.g. T-1), title, status (pending|testing|confirmed|rejected|blocked), and optional note.`,stateSchema:H2,initialState:U2}),i=p$(e=>e.messages),[a,o]=(0,N.useState)(``),[c,l]=(0,N.useState)(`all`),[u,d]=(0,N.useState)(!1);(0,N.useEffect)(()=>{if(!i||i.length===0)return;let e=r4(i);(e.tasks.length!==0||e.target||e.phase)&&r(t=>{let n=X2(t?.tasks??[],e.tasks),r=e.target&&e.target!==t?.target,i=e.phase&&e.phase!==t?.phase,a=n.length!==(t?.tasks?.length??0)||n.some((e,n)=>{let r=t?.tasks?.[n];return!r||r.id!==e.id||r.status!==e.status||r.title!==e.title||r.note!==e.note});return!r&&!i&&!a?t:{...t,tasks:n,target:e.target??t?.target,phase:e.phase??t?.phase}})},[i,r]);let f=n?.target;(0,N.useEffect)(()=>{if(!f)return;let e=!1;return fetch(`/api/v1/workbench/dossier?target=${encodeURIComponent(f)}`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&Array.isArray(t.tasks)&&t.tasks.length!==0&&r(e=>{let n=X2(e?.tasks??[],t.tasks??[]),r=t.target&&!e?.target,i=t.phase&&!e?.phase,a=n.length!==(e?.tasks?.length??0)||n.some((t,n)=>{let r=e?.tasks?.[n];return!r||r.id!==t.id||r.status!==t.status||r.title!==t.title});return!r&&!i&&!a?e:{...e,tasks:n,target:e?.target??t.target,phase:e?.phase??t.phase}})}).catch(()=>{}),()=>{e=!0}},[f,r]);let p=n?.tasks??[],h=n?.target,g=n?.phase,_=(0,N.useMemo)(()=>{let e={all:p.length};for(let t of B2)e[t]=0;for(let t of p)e[t.status]=(e[t.status]??0)+1;return e},[p]),v=(0,N.useMemo)(()=>c===`all`?p:p.filter(e=>e.status===c),[p,c]),y=(e,t,n)=>{let r=t||h;r&&fetch(`/api/v1/workbench/dossier`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:r,tasks:e,phase:n||g})}).catch(()=>{})},b=e=>{let t=`pending`;e.status===`pending`?t=`testing`:e.status===`testing`?t=`confirmed`:e.status===`confirmed`?t=`pending`:e.status===`blocked`?t=`testing`:e.status===`rejected`&&(t=`pending`);let n=p.map(n=>n.id===e.id?{...n,status:t}:n);r(e=>({...e,tasks:n})),y(n)},x=(e,t)=>{let n=p.map(n=>n.id===e?{...n,status:t}:n);r(e=>({...e,tasks:n})),y(n)},S=e=>{let t=p.filter(t=>t.id!==e);r(e=>({...e,tasks:t})),y(t)},C=()=>{let e=a.trim();if(!e)return;let t={id:Y2(p),title:e,status:`pending`},n=[...p,t];r(e=>({...e,tasks:n})),y(n),o(``),d(!1)};return(0,P.jsxs)(`div`,{className:`flex h-full flex-col bg-card text-card-foreground ${e}`,children:[(0,P.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border px-3.5 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(he,{className:`size-4.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,P.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-foreground truncate`,children:`Task Board`}),p.length>0?(0,P.jsx)(px,{variant:`secondary`,className:`px-1.5 py-0 text-[11px] font-mono font-medium`,children:p.length}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[h?(0,P.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground bg-muted/60 px-2 py-0.5 rounded-md font-mono truncate max-w-32`,title:`Bound target: ${h}`,children:[(0,P.jsx)(je,{className:`size-3 text-primary shrink-0`}),(0,P.jsx)(`span`,{className:`truncate`,children:h})]}):null,g?(0,P.jsx)(px,{variant:`outline`,className:`text-[10px] uppercase font-mono tracking-wider px-1.5 py-0`,children:g}):null,(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground`,onClick:()=>d(e=>!e),title:`Add task`,children:[(0,P.jsx)(Ce,{className:`size-4`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Add task`})]}),t?(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground md:hidden`,onClick:t,title:`Close panel`,children:[(0,P.jsx)(ne,{className:`size-4`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close panel`})]}):null]})]}),p.length>0?(0,P.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/60 px-3 py-1.5 text-xs`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>l(`all`),className:`rounded-md px-2 py-0.5 text-xs font-medium transition-colors ${c===`all`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[`All (`,_.all,`)`]}),B2.map(e=>{let t=_[e]??0;return t===0&&c!==e?null:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-xs capitalize font-medium transition-colors ${c===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,P.jsx)(`span`,{children:e}),(0,P.jsxs)(`span`,{className:`font-mono text-[10px] opacity-70`,children:[`(`,t,`)`]})]},e)})]}):null,u?(0,P.jsxs)(`div`,{className:`border-b border-border/80 bg-muted/30 p-2.5 flex items-center gap-2`,children:[(0,P.jsx)(m,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),C()):e.key===`Escape`&&d(!1)},placeholder:`New task thesis (e.g. Test IDOR on /api/user)...`,className:`h-8 text-xs bg-background`}),(0,P.jsx)(s,{size:`sm`,className:`h-8 px-2.5 text-xs shrink-0`,onClick:C,children:`Add`})]}):null,(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-3`,children:p.length===0?(0,P.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center text-center px-4`,children:[(0,P.jsx)(`div`,{className:`flex size-14 items-center justify-center rounded-2xl bg-muted/40 mb-3 border border-border/40`,children:(0,P.jsx)(he,{className:`size-8 text-muted-foreground/50`,"aria-hidden":`true`})}),(0,P.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:h?`No tasks yet for ${h}`:`No tasks yet.`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground max-w-56 leading-relaxed`,children:h?`Analyzing target surface and recording hunt theses...`:`Ask the assistant to add some!`}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,className:`mt-4 h-7 text-xs gap-1.5 text-muted-foreground hover:text-foreground`,onClick:()=>d(!0),children:[(0,P.jsx)(Ce,{className:`size-3.5`}),`Add task`]})]}):v.length===0?(0,P.jsxs)(`div`,{className:`flex h-full min-h-36 flex-col items-center justify-center text-center text-muted-foreground text-xs py-8`,children:[(0,P.jsxs)(`p`,{children:[`No tasks with status "`,c,`".`]}),(0,P.jsx)(s,{variant:`link`,size:`sm`,className:`text-xs mt-1`,onClick:()=>l(`all`),children:`Show all tasks`})]}):(0,P.jsx)(`ul`,{className:`flex flex-col gap-2`,children:v.map(e=>{let t=i4[e.status]??re,n=a4[e.status]??a4.pending,r=e.status===`confirmed`;return(0,P.jsx)(`li`,{className:`group relative flex flex-col gap-1.5 rounded-lg border border-border/70 bg-card p-2.5 transition-all hover:border-border hover:shadow-xs`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>b(e),title:`Status: ${e.status}. Click to cycle.`,"aria-label":`Toggle task status for ${e.title}`,className:`mt-0.5 flex size-4.5 shrink-0 items-center justify-center rounded-md border transition-all ${r?`border-emerald-500 bg-emerald-500 text-white dark:text-black`:n.ring}`,children:r?(0,P.jsx)(A,{className:`size-3 stroke-[3]`}):e.status===`testing`?(0,P.jsx)(ge,{className:`size-2.5 animate-spin text-blue-500`}):(0,P.jsx)(`span`,{className:`size-1.5 rounded-full bg-transparent group-hover:bg-muted-foreground/30`})}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,P.jsx)(`span`,{className:`font-mono text-[10px] font-semibold text-muted-foreground/80 tracking-wider`,children:e.id}),(0,P.jsxs)(`div`,{className:`relative inline-flex items-center`,children:[(0,P.jsx)(t,{className:`pointer-events-none absolute left-1.5 size-2.5 opacity-70`}),(0,P.jsx)(`select`,{value:e.status,onChange:t=>x(e.id,t.target.value),"aria-label":`Change status for task ${e.id}`,className:`h-4.5 appearance-none rounded border pl-4.5 pr-4 text-[10px] font-medium transition-colors cursor-pointer outline-none ${n.badge}`,children:B2.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}),(0,P.jsx)(j,{className:`pointer-events-none absolute right-1 size-2.5 opacity-60`})]})]}),(0,P.jsx)(`p`,{className:`text-xs leading-snug break-words ${r?`text-muted-foreground line-through`:`text-foreground`}`,children:e.title}),e.note?(0,P.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground/90 bg-muted/40 rounded px-1.5 py-0.5 border border-border/40 font-mono`,children:e.note}):null]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>S(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded-sm`,title:`Delete task`,"aria-label":`Delete task`,children:(0,P.jsx)(Ie,{className:`size-3.5`})})]})},e.id)})})}),p.length>0?(0,P.jsxs)(`footer`,{className:`border-t border-border px-3 py-2 flex items-center justify-between text-[11px] text-muted-foreground bg-muted/20`,children:[(0,P.jsxs)(`span`,{children:[_.confirmed??0,` of `,p.length,` confirmed`]}),(0,P.jsx)(s,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-[11px] text-muted-foreground hover:text-destructive`,onClick:()=>r(e=>({...e,tasks:[]})),children:`Clear all`})]}):null]})}function s4({request:e,respond:t}){let[n,r]=(0,N.useState)(e.kind===`editor`?e.prefill??``:``),i=e=>void t(e);return(0,P.jsxs)(`div`,{className:`bg-card grid gap-2 rounded-md border border-l-[3px] border-l-primary p-3`,role:`group`,"aria-label":`The agent is asking for approval`,children:[(0,P.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,P.jsx)(ke,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),e.title]}),e.kind===`confirm`?(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs break-words whitespace-pre-wrap`,children:e.message}):null,e.timeoutMs?(0,P.jsxs)(`p`,{className:`text-muted-foreground text-[0.7rem] tabular-nums`,children:[`Auto-dismisses after `,Math.round(e.timeoutMs/1e3),`s`]}):null,e.kind===`confirm`?(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(s,{size:`sm`,onClick:()=>i({requestId:e.id,confirmed:!0}),children:`Allow`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,confirmed:!1}),children:`Deny`})]}):null,e.kind===`select`?(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.options.map(t=>(0,P.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,value:t}),children:t},t)),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]}):null,e.kind===`input`||e.kind===`editor`?(0,P.jsxs)(`form`,{className:`grid gap-2`,onSubmit:t=>{t.preventDefault(),i({requestId:e.id,value:n})},children:[e.kind===`editor`?(0,P.jsx)(v0,{rows:6,value:n,onChange:e=>r(e.target.value)}):(0,P.jsx)(m,{value:n,placeholder:e.placeholder??``,onChange:e=>r(e.target.value)}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(s,{size:`sm`,type:`submit`,children:`Submit`}),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]})]}):null]})}function c4(){let{requests:e,respond:t}=m$();return e.length===0?null:(0,P.jsx)(`div`,{className:`grid gap-2 border-b px-3 py-2`,children:e.map(e=>(0,P.jsx)(s4,{request:e,respond:t},e.id))})}function l4({className:e,...t}){return(0,P.jsx)(`select`,{"data-slot":`native-select`,className:a(`border-input bg-background text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive h-9 w-full min-w-0 cursor-pointer rounded-md border px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}var u4=6e4,d4=500,f4=1e4,p4=100,m4=new Set([`listThreads`,`getThread`,`getAvailableModels`]),h4=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchTransportError`}},g4=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchRpcError`}};function _4(){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/api/v1/workbench/ws`}function v4(e={}){let t=e.url??_4(),n=new Map,r=new Map,i=null,a=0,o,s=!1,c=!1,l=0;function u(t){e.onStatusChange?.(t)}function d(t){e.onError?.(t instanceof Error?t:Error(String(t)))}function f(e,t){let r=n.get(e);r&&(n.delete(e),clearTimeout(r.timer),r.reject(t))}function p(e,t=!1){return e.phase===`sent`?new h4(`OUTCOME_UNKNOWN`,`Confirmation for ${e.frame.method} was lost. The request may have been accepted. Reconnect and check the thread before retrying.`):new h4(t?`TIMEOUT_NOT_SENT`:`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`)}function m(e){if(i&&i.readyState===WebSocket.OPEN&&n.has(e.frame.id))try{i.send(JSON.stringify(e.frame)),e.phase=`sent`}catch{f(e.frame.id,new h4(`SEND_FAILED`,`The request could not be sent.`))}}function h(e){if(i&&i.readyState===WebSocket.OPEN)try{i.send(JSON.stringify(e))}catch(e){d(e),i.close()}}function g(){if(s||o!==void 0)return;let t=Math.min((e.reconnectBaseMs??d4)*2**a,f4);a+=1,o=setTimeout(()=>{o=void 0,_()},t)}function _(){if(s||i)return;u(`connecting`);let o;try{o=e.createSocket?.(t)??new WebSocket(t)}catch(e){d(e),u(`closed`),g();return}i=o,o.onopen=()=>{if(!(s||i!==o)){a=0;for(let[e,t]of r)h({kind:`subscribe`,threadId:e,includeSnapshot:c||t.includeSnapshot});c=!0;for(let e of n.values())e.phase===`queued`&&m(e);u(`open`)}},o.onmessage=e=>{if(s||i!==o)return;let t;try{t=S4(JSON.parse(String(e.data)))}catch{d(new h4(`INVALID_SERVER_FRAME`,`The workspace sent an invalid response. Reconnecting.`)),o.close();return}if(t.kind===`event`){let e=t.event,n=r.get(e.threadId)?.listeners;for(let t of[...n??[]])try{t(e)}catch(e){d(e)}return}let a=n.get(t.id);if(a){if(t.kind===`rpc_error`){f(t.id,new g4(t.code,t.message));return}if(!C4(a.frame.method,t.result)){f(t.id,new h4(`INVALID_SERVER_FRAME`,`The workspace returned an invalid result.`));return}n.delete(t.id),clearTimeout(a.timer),a.resolve(t.result===null?void 0:t.result)}},o.onerror=()=>{},o.onclose=()=>{if(!(s||i!==o)){i=null;for(let[e,t]of n)f(e,p(t));u(`closed`),g()}}}function v(t,r){if(s)return Promise.reject(new h4(`DISPOSED`,`The workspace connection was closed.`));if(!m4.has(t)&&i?.readyState!==WebSocket.OPEN)return Promise.reject(new h4(`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`));if(n.size>=p4)return Promise.reject(new h4(`TOO_MANY_REQUESTS`,`Too many workspace requests are pending.`));let a=`rpc-${l++}`;return new Promise((i,o)=>{let s=setTimeout(()=>{let e=n.get(a);e&&f(a,p(e,!0))},e.requestTimeoutMs??u4),c={frame:{kind:`rpc`,id:a,method:t,params:r},phase:`queued`,resolve:i,reject:o,timer:s};n.set(a,c),m(c)})}return _(),{dispose(){if(!s){s=!0,o&&clearTimeout(o),o=void 0,r.clear();for(let e of n.keys())f(e,new h4(`DISPOSED`,`The workspace connection was closed.`));i&&(i.onopen=null,i.onmessage=null,i.onclose=null,i.onerror=null,i.close()),i=null}},listThreads:e=>v(`listThreads`,e?[e]:[]),createThread:e=>v(`createThread`,e?[e]:[]),getThread:e=>v(`getThread`,[e]),sendMessage:(e,t)=>v(`sendMessage`,[e,t]),cancelRun:e=>v(`cancelRun`,[e]),clearQueue:e=>v(`clearQueue`,[e]),getAvailableModels:e=>v(`getAvailableModels`,e?[e]:[]),setModel:(e,t)=>v(`setModel`,[e,t]),setThinkingLevel:(e,t)=>v(`setThinkingLevel`,[e,t]),renameThread:(e,t)=>v(`renameThread`,[e,t]),archiveThread:e=>v(`archiveThread`,[e]),unarchiveThread:e=>v(`unarchiveThread`,[e]),deleteThread:e=>v(`deleteThread`,[e]),respondToHostUiRequest:(e,t)=>v(`respondToHostUiRequest`,[e,t]),subscribe(e,t,n){if(s)return()=>{};let a=e=>t(e),o=r.get(e);return o?(o.listeners.add(a),n?.includeSnapshot!==!1&&(o.includeSnapshot=!0,i?.readyState===WebSocket.OPEN&&h({kind:`subscribe`,threadId:e,includeSnapshot:!0}))):(o={listeners:new Set,includeSnapshot:n?.includeSnapshot!==!1},r.set(e,o),o.listeners.add(a),h({kind:`subscribe`,threadId:e,includeSnapshot:o.includeSnapshot})),()=>{let t=r.get(e);t&&t.listeners.delete(a)&&t.listeners.size===0&&(r.delete(e),h({kind:`unsubscribe`,threadId:e}))}}}}function y4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b4(e){return y4(e)&&typeof e.id==`string`&&[`idle`,`running`,`failed`].includes(String(e.status))}function x4(e){return y4(e)&&b4(e.metadata)&&Array.isArray(e.messages)}function S4(e){if(!y4(e))throw Error(`Invalid frame`);if(e.kind===`event`){let t=e.event;if(y4(t)&&typeof t.type==`string`&&typeof t.threadId==`string`&&Number.isSafeInteger(t.seq)&&Number(t.seq)>=0&&(t.type!==`snapshot`||x4(t.snapshot)))return e}else if(typeof e.id==`string`&&(e.kind===`rpc_ok`&&`result`in e||e.kind===`rpc_error`&&typeof e.message==`string`&&typeof e.code==`string`))return e;throw Error(`Invalid frame`)}function C4(e,t){switch(e){case`listThreads`:return Array.isArray(t)&&t.every(b4);case`getThread`:case`createThread`:return x4(t);case`getAvailableModels`:return Array.isArray(t)&&t.every(e=>y4(e)&&typeof e.provider==`string`&&typeof e.modelId==`string`);case`clearQueue`:return y4(t)&&Array.isArray(t.steering)&&t.steering.every(e=>typeof e==`string`)&&Array.isArray(t.followUp)&&t.followUp.every(e=>typeof e==`string`);default:return t===null}}async function w4(){try{let e=await fetch(`/api/v1/workbench/status`,{credentials:`same-origin`});return e.status===401||e.status===403?`unauthenticated`:e.ok?(await e.json()).enabled?`up`:`unconfigured`:`down`}catch{return`down`}}var T4={connecting:`reconnecting`,open:`online`,closed:`dropped`};function E4(){let{compaction:e,retry:t,contextUsage:n,readiness:r}=d$(),i=r&&r.state!==`ready`?r:null;return(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?(0,P.jsx)(px,{variant:`high`,children:i.message}):null,e.active?(0,P.jsx)(px,{variant:`secondary`,children:`Compacting context…`}):null,t.active?(0,P.jsxs)(px,{variant:`high`,children:[`Retrying (attempt `,t.attempt,`)`]}):null,n?.percent==null?null:(0,P.jsxs)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,title:`${n.tokens??`?`} / ${n.contextWindow} tokens`,children:[Math.round(n.percent),`% context`]})]})}var D4=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function O4({client:e}){let t=f$(),n=$(e=>e.threadListItem),r=n?n.externalId??n.remoteId??n.id:null,[i,a]=(0,N.useState)([]),[o,s]=(0,N.useState)(null);(0,N.useEffect)(()=>{let t=!1;return e.getAvailableModels().then(e=>{t||a(e)},()=>{}),()=>{t=!0}},[e]);let c=t?.status===`running`,l=t?.config,u=l?.provider&&l.modelId?`${l.provider}/${l.modelId}`:``,d=l?.thinkingLevel??``,f=async e=>{s(null);try{await e()}catch(e){s(e instanceof Error?e.message:String(e))}};return r?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.length>0?(0,P.jsxs)(l4,{"aria-label":`Model`,title:`Model for this conversation`,value:u,disabled:c,onChange:t=>{let[n,...i]=t.target.value.split(`/`),a=i.join(`/`);n&&a&&f(()=>e.setModel(r,{provider:n,modelId:a}))},className:`h-7 w-auto max-w-44 text-xs`,children:[!u||i.every(e=>`${e.provider}/${e.modelId}`!==u)?(0,P.jsx)(`option`,{value:u,children:u||`Select a model`}):null,i.map(e=>(0,P.jsx)(`option`,{value:`${e.provider}/${e.modelId}`,children:e.name},`${e.provider}/${e.modelId}`))]}):null,(0,P.jsxs)(l4,{"aria-label":`Thinking level`,title:`Thinking level for this conversation`,value:d,disabled:c,onChange:t=>{let n=t.target.value;f(()=>e.setThinkingLevel(r,n))},className:`h-7 w-auto text-xs`,children:[(0,P.jsx)(`option`,{value:``,children:`Thinking…`}),D4.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}),o?(0,P.jsx)(`span`,{className:`text-destructive max-w-64 truncate text-xs`,title:o,children:o}):null]}):null}function k4({status:e,client:t,showTaskBoard:n,onToggleTaskBoard:r}){let i=f$();return(0,P.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(`strong`,{className:`truncate text-sm font-semibold`,children:i?.title??`Live Workspace`}),i?.status===`running`?(0,P.jsx)(px,{variant:`low`,children:`streaming`}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(E4,{}),(0,P.jsx)(O4,{client:t}),e===`open`?null:(0,P.jsx)(z2,{phase:T4[e]}),(0,P.jsxs)(s,{variant:n?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:r,title:`Toggle Dossier Task Board`,"aria-label":`Toggle Dossier Task Board`,children:[(0,P.jsx)(he,{className:`size-3.5`}),(0,P.jsx)(`span`,{className:`hidden sm:inline`,children:`Tasks`})]})]})]})}function A4(){let[e,t]=(0,N.useState)(`connecting`),[n,r]=(0,N.useState)(!0),i=(0,N.useMemo)(()=>v4({onStatusChange:t}),[]);(0,N.useEffect)(()=>()=>i.dispose(),[i]);let o=u$({client:i,includeArchived:!0}),s=(0,N.useMemo)(()=>YN({unstable_interactables:uB()}),[]);return(0,P.jsx)(WG,{runtime:o,config:s,children:(0,P.jsxs)(`div`,{className:a(`grid h-[var(--workspace-height)] min-h-120 grid-cols-1 gap-4`,n?`xl:grid-cols-[minmax(0,16rem)_minmax(0,1fr)_minmax(0,21rem)] md:grid-cols-[minmax(0,1fr)_minmax(0,20rem)]`:`md:grid-cols-[minmax(0,17rem)_minmax(0,1fr)]`),children:[(0,P.jsx)(g,{className:a(`min-h-0 overflow-hidden p-0`,n?`hidden xl:flex`:`hidden md:flex`),children:(0,P.jsx)(w2,{})}),(0,P.jsxs)(g,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:[(0,P.jsx)(k4,{status:e,client:i,showTaskBoard:n,onToggleTaskBoard:()=>r(e=>!e)}),(0,P.jsx)(c4,{}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,P.jsx)(n2,{})})]}),n?(0,P.jsx)(g,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:(0,P.jsx)(o4,{onClose:()=>r(!1)})}):null]})})}function j4({state:e}){return(0,P.jsxs)(g,{className:`mx-auto max-w-lg items-start gap-3 p-6`,children:[(0,P.jsx)(`h2`,{className:`text-base font-semibold`,children:e===`unauthenticated`?`Sign in required`:e===`unconfigured`?`Live workspace not configured`:`Live workspace unreachable`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e===`unauthenticated`?`The live workspace is available to authenticated platform users.`:e===`unconfigured`?`Set WORKBENCH_CWD on the platform server to enable the hosted agent runtime (see docs/infra/workbench-integration.md).`:`The platform server did not answer. Check that it is running.`}),e===`unauthenticated`?(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/login`,children:`Sign in`})}):null]})}function M4({eyebrow:e,title:t,description:n,actions:r,className:i}){return(0,P.jsxs)(`header`,{className:a(`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,i),children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[e?(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-2 text-2xs font-semibold tracking-[0.12em] uppercase`,children:e}):null,(0,P.jsx)(`h1`,{children:t}),n?(0,P.jsx)(`p`,{className:`mt-2 mb-0 max-w-[72ch]`,children:n}):null]}),r?(0,P.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r}):null]})}function N4({sessions:e,value:t,onChange:n,className:r,id:i=`agent-session`}){let o=e[0];return(0,P.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,r),children:[(0,P.jsx)(`label`,{className:`text-muted-foreground shrink-0 text-[13px]`,htmlFor:i,children:`Session`}),(0,P.jsxs)(l4,{"aria-label":`Agent session`,className:`w-auto min-w-0 max-w-[22rem] text-[13px]`,id:i,onChange:e=>n(e.target.value),value:t??`latest`,children:[(0,P.jsx)(`option`,{value:`latest`,children:o?`Latest — ${o.title||`Session`}`:`Latest session`}),(0,P.jsx)(`option`,{value:`all`,children:`All workspace sessions`}),e.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title||`Session`,` · `,e.findingCount??0,` findings · `,e.runCount??0,` runs`]},e.id))]})]})}var P4=new Lf({defaultOptions:{queries:{staleTime:1e4,retry:2,refetchOnWindowFocus:!0}}});function F4({section:e}){return(0,P.jsx)(Bf,{client:P4,children:(0,P.jsx)(L4,{section:e})})}function I4(){let e=ep({queryKey:[`workbench-status`],queryFn:w4,retry:1,staleTime:15e3});return e.isLoading?(0,P.jsx)(H4,{compact:!0,title:`Connecting to the live workspace…`,detail:`Checking the platform agent runtime.`}):e.data&&e.data!==`up`?(0,P.jsx)(j4,{state:e.data}):(0,P.jsx)(A4,{})}function L4({section:e}){let[t,n]=(0,N.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`session`):null);(0,N.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`session`);e&&n(e);let t=e=>{let t=e;t.detail&&`sessionId`in t.detail&&n(t.detail.sessionId)};return window.addEventListener(`kifaru:sessionchange`,t),()=>window.removeEventListener(`kifaru:sessionchange`,t)},[e]);let r=e=>{let t=e===`latest`?null:e;if(n(t),typeof window<`u`){let e=new URL(window.location.href);t?e.searchParams.set(`session`,t):e.searchParams.delete(`session`),window.history.replaceState({},``,e.toString()),window.dispatchEvent(new CustomEvent(`kifaru:sessionchange`,{detail:{sessionId:t}}))}},[i,a]=(0,N.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`finding`):null),o=e=>{if(a(e),typeof window<`u`){let t=new URL(window.location.href);e?t.searchParams.set(`finding`,e):t.searchParams.delete(`finding`),window.history.replaceState({},``,t.toString())}},c=ep({queryKey:[`agent-sessions`],queryFn:Ib.agentSessions,enabled:e===`runs`||e===`agent`||e===`findings`||e===`dashboard`||e===`lifecycle`,refetchInterval:2e3}),l=t===`all`?void 0:t||c.data?.items?.[0]?.id,u=ep({queryKey:[`workflows`],queryFn:Ib.workflows,enabled:e===`workflows`||e===`assessments`}),d=ep({queryKey:[`overview`,l],queryFn:()=>Ib.overview(l),enabled:e===`dashboard`||e===`assessments`||e===`lifecycle`,refetchInterval:2e3}),f=ep({queryKey:[`runs`,l],queryFn:()=>Ib.runs({sessionId:l}),enabled:e===`runs`,refetchInterval:2e3}),p=ep({queryKey:[`projects`],queryFn:Ib.projects,enabled:e===`assessments`}),h=ep({queryKey:[`assessment-profiles`],queryFn:Ib.assessmentProfiles,enabled:e===`assessments`}),v=ep({queryKey:[`findings`,l],queryFn:()=>Ib.findings({sessionId:l}),enabled:e===`findings`||e===`dashboard`||e===`lifecycle`||e===`reports`,refetchInterval:6e3}),y=ep({queryKey:[`agent-session`,t],queryFn:()=>Ib.agentSession(t),enabled:e===`runs`&&!!t,refetchInterval:2e3}),b=ep({queryKey:[`governance-events`],queryFn:Ib.governanceEvents,enabled:e===`reports`}),x=ep({queryKey:[`workers`],queryFn:Ib.workers,enabled:e===`administration`}),S=ep({queryKey:[`tokens`],queryFn:Ib.tokens,enabled:e===`administration`}),[C,w]=(0,N.useState)(``),[E,D]=(0,N.useState)(30),[O,k]=(0,N.useState)(!1),[j,M]=(0,N.useState)(null),[ee,te]=(0,N.useState)(!1),[ne,re]=(0,N.useState)(!1),[ie,oe]=(0,N.useState)(null),[se,ce]=(0,N.useState)(null);async function le(e){e.preventDefault(),k(!0),oe(null);try{let e=await Ib.mintToken({label:C.trim()||`CLI Token`,expiresInDays:E});M(e),w(``),P4.invalidateQueries({queryKey:[`tokens`]})}catch(e){oe(e instanceof Error?e.message:`Failed to mint token`)}finally{k(!1)}}async function ue(e){if(confirm(`Are you sure you want to revoke this token? Any CLI session or automation using it will immediately lose access.`)){ce(e);try{await Ib.revokeToken(e),P4.invalidateQueries({queryKey:[`tokens`]})}catch(e){alert(e instanceof Error?e.message:`Failed to revoke token`)}finally{ce(null)}}}let de=[...e===`workflows`||e===`assessments`?[u]:[],...e===`dashboard`?[d,v]:[],...e===`lifecycle`?[d,v]:[],...e===`runs`?[f,c]:[],...e===`runs`&&t?[y]:[],...e===`assessments`?[d,p,h]:[],...e===`findings`?[v]:[],...e===`reports`?[b,v]:[],...e===`administration`?[x,S]:[]];if(de.some(e=>e.isLoading))return(0,P.jsx)(H4,{title:`Loading workspace`,detail:`Reading durable platform state…`});let fe=de.find(e=>e.isError);if(fe){let e=fe.error,t=e&&typeof e==`object`&&`status`in e&&e.status===401;return(0,P.jsx)(H4,{title:`Platform unavailable`,detail:e instanceof Error?e.message:`The platform could not be reached.`,action:t?(0,P.jsx)(s,{asChild:!0,children:(0,P.jsx)(`a`,{href:`/login`,children:`Sign in`})}):(0,P.jsxs)(s,{onClick:()=>void fe.refetch(),children:[(0,P.jsx)(we,{}),` Retry`]})})}let pe=Zb(v.data?.findings??[]),he=pe.filter(Jb);if(e===`dashboard`){let e=Object.fromEntries(Vb.map(e=>[e,he.filter(t=>t.severity===e).length])),n=d.data?.runs??{},i=Object.values(n).reduce((e,t)=>e+t,0),a=(n.queued??0)+(n.running??0),o=Qb(pe),l=pe.filter(e=>e.status===`confirmed`||e.status===`verified`);return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(M4,{actions:(0,P.jsx)(N4,{onChange:r,sessions:c.data?.items??[],value:t}),eyebrow:`Continuous assurance`,title:`Environment-wide risk posture`,description:`Posture recomputes on every run rather than at a point in time. Every number below comes from the platform ledger — agent runs, recorded tool calls and ingested findings.`}),(0,P.jsxs)(ex,{children:[(0,P.jsx)(tx,{hero:!0,tone:o??void 0,label:`Client posture`,value:o?Wb[o].toUpperCase():`NO CONFIRMED RISK`,meta:o?`Worst confirmed finding across ${l.length} confirmed finding${l.length===1?``:`s`}.`:`No finding has been confirmed yet.`}),(0,P.jsx)(tx,{label:`Open findings`,value:he.length,meta:`${pe.length-he.length} resolved`}),(0,P.jsx)(tx,{label:`Critical / High`,value:`${e.critical} / ${e.high}`,meta:`${l.length} confirmed overall`}),(0,P.jsx)(tx,{label:`Assessments`,value:i,meta:`${a} in flight`})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)($b,{title:`Open findings by severity`,sub:`${he.length} active`,children:(0,P.jsx)(nx,{counts:e})}),(0,P.jsx)($b,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,P.jsx)(rx,{findings:he})})]}),(0,P.jsx)($b,{title:`Highest-priority open findings`,sub:(0,P.jsx)(`a`,{className:`link-more`,href:`/findings`,children:`View all`}),children:(0,P.jsx)(ix,{findings:qb(he).slice(0,5),onSelect:e=>{window.location.href=`/findings?finding=${encodeURIComponent(e.id)}`},emptyLabel:`No open findings. Agent runs report findings through the report_finding tool; none have been ingested yet.`})}),(0,P.jsxs)(`section`,{"aria-labelledby":`active-runs`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-1 text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Operations`}),(0,P.jsx)(`h2`,{id:`active-runs`,children:`Active runs`})]}),(0,P.jsxs)(`a`,{className:`link-more`,href:`/runs`,children:[`View all `,(0,P.jsx)(T,{"aria-hidden":`true`})]})]}),d.data?.recentRuns.filter(e=>e.status===`queued`||e.status===`running`).length?(0,P.jsx)(K4,{runs:d.data.recentRuns.filter(e=>e.status===`queued`||e.status===`running`)}):(0,P.jsx)(H4,{compact:!0,title:`No active runs`,detail:`Select a target endpoint to initialize a governed assessment.`,action:(0,P.jsx)(s,{asChild:!0,children:(0,P.jsx)(`a`,{href:`/assessments`,children:`New assessment`})})})]})]})}if(e===`lifecycle`)return(0,P.jsx)(W4,{findings:he});if(e===`workflows`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(V4,{title:`Workflows`,detail:`Standardized assessment procedures, risk classifications, and required worker capabilities.`}),(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:u.data?.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(px,{variant:fx(J4(e.stages)),children:[`Highest risk `,J4(e.stages)]}),(0,P.jsxs)(`span`,{className:`font-mono`,children:[`v`,e.version]})]}),(0,P.jsx)(`h2`,{children:e.name}),(0,P.jsx)(`p`,{children:e.description}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsxs)(`a`,{href:`/assessments`,children:[`Check readiness `,(0,P.jsx)(T,{})]})})]},e.key))})]});if(e===`runs`){if(t&&y.data){let e=y.data,t=e.operations.filter(e=>e.status!==`completed`).length;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:`Session`}),(0,P.jsx)(`h1`,{children:e.session.title}),(0,P.jsx)(`p`,{children:`Recorded tool calls and findings for this agent session, newest run last.`})]}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/runs`,children:`All runs`})})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,P.jsx)(U4,{label:`Status`,value:X4(e.session.status),detail:`${e.session.runCount} run${e.session.runCount===1?``:`s`} in this session`}),(0,P.jsx)(U4,{label:`Tool calls`,value:String(e.session.operationCount),detail:t?`${t} did not complete`:`All completed`}),(0,P.jsx)(U4,{label:`Findings`,value:String(e.session.findingCount),detail:e.session.findingCount?`Ingested through report_finding`:`None reported in this session`})]}),(0,P.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.65fr)]`,"aria-live":`polite`,children:[(0,P.jsxs)(`section`,{"aria-labelledby":`agent-transcript`,children:[(0,P.jsx)(`h2`,{id:`agent-transcript`,children:`Transcript`}),e.operations.length?(0,P.jsx)(`div`,{className:`grid gap-2.5`,children:e.operations.map(e=>(0,P.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground [&_p.font-mono]:max-h-28 [&_p.font-mono]:overflow-auto [&_p.font-mono]:rounded-sm [&_p.font-mono]:bg-[var(--plane)] [&_p.font-mono]:px-2.5 [&_p.font-mono]:py-2 [&_p.font-mono]:text-xs [&_p.font-mono]:whitespace-pre-wrap`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(`strong`,{children:e.tool}),(0,P.jsx)(px,{variant:fx(e.status),children:X4(e.outcome)})]}),(0,P.jsxs)(`p`,{children:[e.runtime,` · `,new Date(e.startedAt).toLocaleTimeString(),e.completedAt?` · ${e.completedAt-e.startedAt}ms`:``]}),e.outputPreview?(0,P.jsx)(`p`,{className:`font-mono`,children:e.outputPreview.slice(0,400)}):null]},e.id))}):(0,P.jsx)(H4,{compact:!0,title:`Waiting for agent output`,detail:`Tool calls appear here as the runtime records them.`})]}),(0,P.jsxs)(`section`,{"aria-labelledby":`agent-runs`,children:[(0,P.jsx)(`h2`,{id:`agent-runs`,children:`Runs`}),(0,P.jsx)(`div`,{className:`grid gap-2.5`,children:e.runs.map(e=>(0,P.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(px,{variant:fx(e.status),children:X4(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,12)})]}),(0,P.jsxs)(`p`,{children:[e.kind,` · `,new Date(e.createdAt).toLocaleString()]})]},e.id))})]})]}),e.findings.length?(0,P.jsxs)(`section`,{"aria-labelledby":`agent-findings`,children:[(0,P.jsx)(`h2`,{id:`agent-findings`,children:`Findings from this session`}),(0,P.jsx)(q4,{findings:e.findings})]}):null]})}return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(V4,{title:`Runs`,detail:`Governed assessment runs and the agent sessions behind them. Open a session to replay its transcript.`}),(0,P.jsxs)(`section`,{"aria-labelledby":`all-runs`,children:[(0,P.jsx)(`h2`,{id:`all-runs`,className:`mb-3`,children:`Runs`}),f.data?.runs.length?(0,P.jsx)(K4,{runs:f.data.runs}):(0,P.jsx)(H4,{compact:!0,title:`No runs yet`,detail:`Initialize an assessment to start the first governed run.`})]}),(0,P.jsxs)(`section`,{"aria-labelledby":`all-sessions`,children:[(0,P.jsx)(`h2`,{id:`all-sessions`,className:`mb-3`,children:`Sessions`}),c.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:c.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(px,{variant:fx(e.status),children:X4(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.source})]}),(0,P.jsx)(`h2`,{children:e.title}),(0,P.jsxs)(`p`,{children:[e.runCount,` run`,e.runCount===1?``:`s`,` · `,e.operationCount,` tool call`,e.operationCount===1?``:`s`,` · `,e.findingCount,` finding`,e.findingCount===1?``:`s`]}),(0,P.jsxs)(`p`,{children:[`Last active `,new Date(e.lastActivityAt).toLocaleString()]}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/runs?session=${e.id}`,children:`Open session`})})]},e.id))}):(0,P.jsx)(H4,{compact:!0,title:`No agent sessions`,detail:`Sessions appear here once an agent run reaches the platform.`})]})]})}if(e===`assessments`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(V4,{title:`Assessments`,detail:`Target environment configurations, authorization scopes, and historical run associations.`}),(0,P.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,P.jsx)(U4,{label:`Projects`,value:String(p.data?.items.length??0),detail:`Active workspace project boundaries`}),(0,P.jsx)(U4,{label:`Target bindings`,value:String(h.data?.items.length??0),detail:`Bound endpoints and infrastructure`}),(0,P.jsx)(U4,{label:`Recent runs`,value:String(d.data?.recentRuns.length??0),detail:`Assessment runs recorded in this workspace`})]}),h.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:h.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(px,{variant:fx(e.allowedRisk),children:e.allowedRisk}),(0,P.jsxs)(`span`,{className:`font-mono`,children:[`rev `,e.revision]})]}),(0,P.jsx)(`h2`,{children:e.targets[0]?.displayName??e.targets[0]?.locator??`Bound target`}),(0,P.jsxs)(`p`,{children:[e.requiredWorkerClass,` worker · immutable launch policy`]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))})]},e.id))}):(0,P.jsx)(H4,{compact:!0,title:`No targets yet`,detail:`Configure a new target endpoint from the dashboard to initialize assessment tracking.`})]});if(e===`findings`){if(i)return(0,P.jsx)(`div`,{className:`grid gap-6`,children:(0,P.jsx)(dj,{findingId:i,onBack:()=>o(null)})});let e=Object.fromEntries(Vb.map(e=>[e,he.filter(t=>t.severity===e).length])),n=Y4(pe);return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(M4,{actions:(0,P.jsx)(N4,{id:`findings-session`,onChange:r,sessions:c.data?.items??[],value:t}),title:`Findings & assets`,description:`Every finding on the assessed estate, grouped by asset and placed on the data lifecycle. Click any finding to read it in full, verify it, and track it to resolution.`}),pe.length?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)($b,{title:`Open findings by severity`,sub:`${he.length} active`,children:(0,P.jsx)(nx,{counts:e})}),(0,P.jsx)($b,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,P.jsx)(rx,{findings:he})})]}),(0,P.jsx)($b,{title:`Control coverage`,sub:`pillar × lifecycle stage — worst open severity per cell`,children:(0,P.jsx)(ox,{findings:he,onSelectStage:()=>{}})}),n.map(({asset:e,items:t})=>(0,P.jsx)($b,{title:e,sub:`${t.length} finding${t.length===1?``:`s`}`,children:(0,P.jsx)(ix,{findings:qb(t),onSelect:e=>o(e.id)})},e))]}):(0,P.jsx)(H4,{compact:!0,title:`No findings`,detail:`Discovered findings will appear here as agent runs report them. Source findings stay unverified until operation-level evidence confirms them.`})]})}return e===`agent`?(0,P.jsx)(I4,{}):e===`reports`?(0,P.jsxs)(`div`,{className:`grid gap-8`,children:[(0,P.jsx)(M4,{eyebrow:`Kifaru platform`,title:`Reports`,description:`The generated audit report for a run, and the finding-level evidence behind every claim.`}),(0,P.jsx)(aj,{}),(0,P.jsx)(G4,{events:b.data?.items??[],findings:pe})]}):e===`administration`?(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(V4,{title:`Administration & Access`,detail:`Personal access tokens, CLI credentials, worker registrations, and operational capabilities.`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.5rem`},children:[(0,P.jsx)(me,{size:18}),(0,P.jsx)(`h2`,{children:`Personal Access Tokens & CLI Sign-In`})]})}),(0,P.jsx)(`p`,{style:{marginTop:`0.25rem`,marginBottom:`1rem`},children:`Mint tokens to authenticate the Kifaru CLI or automated CI/CD pipelines without passwords.`}),j&&(0,P.jsxs)(`div`,{style:{background:`rgba(16, 185, 129, 0.12)`,border:`1px solid rgba(16, 185, 129, 0.4)`,borderRadius:`0.5rem`,padding:`1rem`,marginBottom:`1.25rem`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`0.5rem`},children:[(0,P.jsxs)(`strong`,{style:{color:`var(--good)`,display:`flex`,alignItems:`center`,gap:`0.4rem`},children:[(0,P.jsx)(A,{size:16}),` Token Minted: `,j.label]}),(0,P.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>M(null),children:`Dismiss`})]}),(0,P.jsx)(`p`,{style:{fontSize:`0.85rem`,color:`var(--ink-2)`,marginBottom:`0.75rem`},children:`Make sure to copy your Personal Access Token now. You will not be able to see it again!`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:`0.75rem`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(_,{className:`text-muted-foreground mb-1 block text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Token Value`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,P.jsx)(m,{type:`text`,readOnly:!0,value:j.token,className:`flex-1 font-mono`}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(j.token),te(!0),setTimeout(()=>te(!1),2e3)},children:[ee?(0,P.jsx)(A,{size:14}):(0,P.jsx)(ae,{size:14}),ee?`Copied`:`Copy Token`]})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,style:{display:`block`,marginBottom:`0.25rem`},children:`CLI Sign-In Command`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,P.jsxs)(`code`,{className:`font-mono`,style:{flex:1,borderRadius:`0.375rem`,padding:`0.45rem 0.65rem`,fontSize:`0.82rem`,color:`var(--accent)`},children:[`kifaru session login --token `,j.token]}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(`kifaru session login --token `+j.token),re(!0),setTimeout(()=>re(!1),2e3)},children:[ne?(0,P.jsx)(A,{size:14}):(0,P.jsx)(ae,{size:14}),ne?`Copied`:`Copy Command`]})]})]})]})]}),(0,P.jsxs)(`form`,{onSubmit:le,style:{display:`flex`,flexWrap:`wrap`,alignItems:`flex-end`,gap:`0.75rem`,background:`var(--surface-2)`,border:`1px solid var(--border)`,borderRadius:`0.5rem`,padding:`0.85rem`,marginBottom:`1.25rem`},children:[(0,P.jsxs)(`div`,{style:{flex:`1 1 220px`},children:[(0,P.jsx)(_,{htmlFor:`mint-label`,className:`mb-1.5 block text-sm`,children:`Token Label`}),(0,P.jsx)(m,{id:`mint-label`,type:`text`,placeholder:`e.g. Workstation CLI, CI Runner`,value:C,onChange:e=>w(e.target.value)})]}),(0,P.jsxs)(`div`,{style:{width:`160px`},children:[(0,P.jsx)(_,{htmlFor:`mint-expiry`,className:`mb-1.5 block text-sm`,children:`Expiration`}),(0,P.jsxs)(l4,{id:`mint-expiry`,value:E,onChange:e=>D(Number(e.target.value)),children:[(0,P.jsx)(`option`,{value:30,children:`30 days`}),(0,P.jsx)(`option`,{value:60,children:`60 days`}),(0,P.jsx)(`option`,{value:90,children:`90 days`}),(0,P.jsx)(`option`,{value:365,children:`1 year`}),(0,P.jsx)(`option`,{value:0,children:`Never expires`})]})]}),(0,P.jsxs)(s,{type:`submit`,disabled:O,size:`sm`,children:[(0,P.jsx)(Ce,{size:15}),O?`Minting…`:`Mint Token`]})]}),ie&&(0,P.jsx)(`p`,{className:`text-destructive text-sm`,style:{marginBottom:`1rem`},children:ie}),(0,P.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,P.jsx)(`h3`,{style:{fontSize:`0.95rem`,fontWeight:600,marginBottom:`0.5rem`},children:`Active Tokens`}),S.data?.items.length?(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Label`}),(0,P.jsx)(`th`,{children:`Token Prefix`}),(0,P.jsx)(`th`,{children:`Role`}),(0,P.jsx)(`th`,{children:`Created`}),(0,P.jsx)(`th`,{children:`Expires`}),(0,P.jsx)(`th`,{children:`Action`})]})}),(0,P.jsx)(`tbody`,{children:S.data.items.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{style:{fontWeight:600,color:`var(--ink)`},children:e.label}),(0,P.jsxs)(`td`,{className:`font-mono`,children:[e.prefix,`…`]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:fx(`confirmed`),children:e.role})}),(0,P.jsx)(`td`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,P.jsx)(`td`,{children:e.expiresAt?new Date(e.expiresAt).toLocaleDateString():`Never`}),(0,P.jsx)(`td`,{children:(0,P.jsxs)(s,{variant:`destructive`,size:`sm`,disabled:se===e.id,onClick:()=>ue(e.id),children:[(0,P.jsx)(Ie,{size:13}),se===e.id?`Revoking…`:`Revoke`]})})]},e.id))})]})}):(0,P.jsx)(`p`,{style:{color:`var(--muted)`,fontSize:`0.85rem`,fontStyle:`italic`},children:`No personal access tokens minted yet. Use the form above to create one.`})]}),(0,P.jsxs)(`div`,{style:{marginTop:`1.25rem`,background:`var(--surface-2)`,border:`1px dashed var(--border)`,borderRadius:`0.5rem`,padding:`0.85rem 1rem`,display:`flex`,alignItems:`center`,gap:`0.75rem`},children:[(0,P.jsx)(Me,{size:20}),(0,P.jsxs)(`div`,{style:{fontSize:`0.82rem`,color:`var(--muted)`},children:[(0,P.jsx)(`strong`,{style:{color:`var(--ink)`},children:`Interactive Browser Sign-in:`}),` You can also run`,` `,(0,P.jsx)(`code`,{className:`font-mono`,style:{color:`var(--accent)`},children:`kifaru session login`}),` `,`in your terminal to authenticate interactively through your browser.`]})]})]}),(0,P.jsxs)(`div`,{style:{marginTop:`1rem`},children:[(0,P.jsx)(`h2`,{style:{fontSize:`1.15rem`,marginBottom:`0.75rem`},children:`Execution Workers`}),x.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:x.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(px,{variant:fx(e.status),children:X4(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.status})]}),(0,P.jsx)(`h2`,{children:e.name}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))})]},e.id))}):(0,P.jsx)(H4,{compact:!0,title:`No workers registered`,detail:`Connect an execution worker before launching capability-bound workflows.`})]})]}):e===`billing`?(0,P.jsx)(R4,{}):e===`team`?(0,P.jsx)(z4,{}):e===`referrals`?(0,P.jsx)(B4,{}):(0,P.jsx)(H4,{title:`Not found`,detail:`This view does not exist.`})}function R4(){return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(V4,{title:`Billing & Subscription`,detail:`Workspace tier, automated audit scan credits, compute limits, and receipts.`}),(0,P.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,P.jsxs)(g,{className:`p-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsxs)(`span`,{className:`text-2xs font-semibold uppercase tracking-[0.12em] text-muted-foreground flex items-center gap-1.5`,children:[(0,P.jsx)(oe,{className:`size-3.5`}),` Current Plan`]}),(0,P.jsx)(px,{variant:`success`,children:`Active`})]}),(0,P.jsx)(`div`,{className:`text-2xl font-bold mb-1`,children:`Developer Pro`}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground mb-6`,children:`Continuous assurance scans with dedicated runtime concurrency.`}),(0,P.jsxs)(`div`,{className:`space-y-2 border-t pt-4 text-xs text-muted-foreground`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{children:`Parallel agent jobs`}),(0,P.jsx)(`span`,{className:`font-semibold text-foreground`,children:`8 concurrent`})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{children:`Finding retention`}),(0,P.jsx)(`span`,{className:`font-semibold text-foreground`,children:`365 days`})]}),(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`span`,{children:`Next renewal`}),(0,P.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Oct 1, 2026`})]})]})]}),(0,P.jsxs)(g,{className:`p-6 flex flex-col justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`span`,{className:`text-2xs font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Scan Credits`}),(0,P.jsx)(`span`,{className:`text-xs font-mono text-[var(--good)] font-semibold`,children:`Active Balance`})]}),(0,P.jsx)(`div`,{className:`text-2xl font-bold font-mono mb-1`,children:`$240.00`}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`Prepaid compute balance for high-concurrency automated audits.`})]}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:`flex-1`,children:`Add Balance`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,children:`Change Plan`})]})]})]}),(0,P.jsxs)(g,{className:`p-6`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold mb-4`,children:`Recent Invoices`}),(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,P.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,P.jsx)(`thead`,{className:`bg-muted/50 border-b`,children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`p-3`,children:`Invoice`}),(0,P.jsx)(`th`,{className:`p-3`,children:`Date`}),(0,P.jsx)(`th`,{className:`p-3`,children:`Amount`}),(0,P.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,P.jsx)(`th`,{className:`p-3 text-right`,children:`Receipt`})]})}),(0,P.jsxs)(`tbody`,{className:`divide-y`,children:[(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`p-3 font-mono font-medium`,children:`INV-2026-009`}),(0,P.jsx)(`td`,{className:`p-3 text-muted-foreground`,children:`Sep 1, 2026`}),(0,P.jsx)(`td`,{className:`p-3 font-mono`,children:`$120.00`}),(0,P.jsx)(`td`,{className:`p-3`,children:(0,P.jsx)(px,{variant:`success`,children:`Paid`})}),(0,P.jsx)(`td`,{className:`p-3 text-right`,children:(0,P.jsx)(`span`,{className:`text-primary hover:underline cursor-pointer`,children:`PDF`})})]}),(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`p-3 font-mono font-medium`,children:`INV-2026-008`}),(0,P.jsx)(`td`,{className:`p-3 text-muted-foreground`,children:`Aug 1, 2026`}),(0,P.jsx)(`td`,{className:`p-3 font-mono`,children:`$120.00`}),(0,P.jsx)(`td`,{className:`p-3`,children:(0,P.jsx)(px,{variant:`success`,children:`Paid`})}),(0,P.jsx)(`td`,{className:`p-3 text-right`,children:(0,P.jsx)(`span`,{className:`text-primary hover:underline cursor-pointer`,children:`PDF`})})]})]})]})})]})]})}function z4(){return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(V4,{title:`Team & Permissions`,detail:`Collaborate with your security engineering and development teams.`}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,P.jsx)(Le,{size:18}),` Workspace Members`]}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Manage organization access and security verification roles.`})]}),(0,P.jsxs)(s,{size:`sm`,children:[(0,P.jsx)(Ce,{size:14}),` Invite Member`]})]}),(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Member`}),(0,P.jsx)(`th`,{children:`Role`}),(0,P.jsx)(`th`,{children:`Status`}),(0,P.jsx)(`th`,{children:`Last Active`})]})}),(0,P.jsxs)(`tbody`,{children:[(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Daniel Bast`}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`daniel@bastsec.com`})]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:`default`,children:`Owner / Admin`})}),(0,P.jsx)(`td`,{children:(0,P.jsx)(`span`,{className:`text-xs text-[var(--good)] font-medium`,children:`Active`})}),(0,P.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:`Just now`})]}),(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Kifaru Security Bot`}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`bot@kifaru.internal`})]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:`secondary`,children:`Automated Worker`})}),(0,P.jsx)(`td`,{children:(0,P.jsx)(`span`,{className:`text-xs text-[var(--good)] font-medium`,children:`Active`})}),(0,P.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:`Running scans`})]})]})]})})]})}function B4(){let[e,t]=(0,N.useState)(!1),n=`https://kifaru.dev/join?ref=bastsec`;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(V4,{title:`Referrals & Rewards`,detail:`Share Kifaru with other security engineering teams and earn audit credits.`}),(0,P.jsxs)(g,{className:`p-6`,children:[(0,P.jsxs)(`h3`,{className:`text-sm font-semibold mb-2 flex items-center gap-2`,children:[(0,P.jsx)(De,{size:16}),` Your Referral Link`]}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mb-4`,children:`Share this link with your team or community. When an invited team runs their first automated security audit, you both get $100 in platform compute credits.`}),(0,P.jsxs)(`div`,{className:`flex max-w-lg gap-2`,children:[(0,P.jsx)(m,{type:`text`,readOnly:!0,value:n,className:`font-mono text-xs flex-1`}),(0,P.jsxs)(s,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard.writeText(n),t(!0),setTimeout(()=>t(!1),2e3)},children:[e?(0,P.jsx)(A,{size:14}):(0,P.jsx)(ae,{size:14}),e?`Copied`:`Copy Link`]})]})]})]})}function V4({title:e,detail:t}){return(0,P.jsx)(M4,{description:t,title:e})}function H4({title:e,detail:t,action:n,compact:r}){return(0,P.jsxs)(g,{className:`state ${r?`state-compact`:``}`,"aria-live":`polite`,children:[(0,P.jsx)(`div`,{className:`mb-1 grid size-9 place-items-center rounded-full border bg-[var(--accent-soft)] text-primary [&_svg]:size-[18px]`,children:(0,P.jsx)(b,{"aria-hidden":`true`})}),(0,P.jsx)(`h2`,{children:e}),(0,P.jsx)(`p`,{children:t}),n]})}function U4({label:e,value:t,detail:n}){return(0,P.jsxs)(g,{children:[(0,P.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:e}),(0,P.jsx)(`strong`,{className:`my-1 block text-[28px] font-bold tracking-[-0.02em]`,children:t}),(0,P.jsx)(`p`,{children:n})]})}function W4({findings:e}){let[t,n]=(0,N.useState)(4),r=Rb(t),i=qb(e.filter(e=>e.stage===t)),a=e.filter(e=>e.inferred).length;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(M4,{eyebrow:`A control gap at any stage exposes the whole chain`,title:`Finding → data-lifecycle stage`,description:(0,P.jsxs)(P.Fragment,{children:[`Agents declare a stage by prefixing a finding’s category with`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:`L4·P1·`}),`.`,a?` ${a} of ${e.length} findings did not, so their stage is inferred from wording and marked as such.`:` Every finding here declared its own stage.`]})}),(0,P.jsx)(ax,{findings:e,selected:t,onSelect:n}),(0,P.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)($b,{title:`Stage ${r.n} · ${r.name}`,sub:`${i.length} finding${i.length===1?``:`s`}`,children:(0,P.jsx)(ix,{findings:i,emptyLabel:`No open findings at this stage.`})}),(0,P.jsxs)($b,{title:`Control pillar × lifecycle stage`,sub:`cell = open findings`,children:[(0,P.jsx)(ox,{findings:e,onSelectStage:n}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-4 text-xs font-medium`,style:{marginTop:12},children:[`critical`,`high`,`medium`,`low`].map(e=>(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`i`,{className:`mcap`,style:{background:`var(${Ub[e]})`}}),`worst: `,Wb[e]]},e))})]})]})]})}function G4({events:e,findings:t}){let n=qb(t.filter(e=>e.status===`confirmed`||e.status===`unverified`)),[r,i]=(0,N.useState)(null),a=n.find(e=>e.id===r)??n[0]??null,o=ep({queryKey:[`finding`,a?.id],queryFn:()=>Ib.finding(a.id),enabled:!!a});return(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-0`,children:`Findings & evidence`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every finding carries the evidence chain that produced it; every platform mutation is recorded below.`})]}),(0,P.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[300px_minmax(0,1fr)]`,children:[(0,P.jsxs)(`div`,{className:`bg-card overflow-hidden rounded-xl border [&_.ph]:text-muted-foreground [&_.ph]:border-b [&_.ph]:border-[var(--hair)] [&_.ph]:px-3.5 [&_.ph]:py-3 [&_.ph]:text-xs [&_.ph]:font-semibold`,children:[(0,P.jsx)(`div`,{className:`ph`,children:`Findings with evidence`}),n.length?n.map(e=>(0,P.jsxs)(`button`,{className:`block w-full border-0 border-b border-l-[3px] border-[var(--hair)] border-l-transparent bg-transparent px-3.5 py-2.5 text-left last:border-b-0 aria-pressed:border-l-primary aria-pressed:bg-[var(--accent-soft)] [&_.pt]:text-[13px] [&_.pt]:font-semibold`,type:`button`,"aria-pressed":e.id===a?.id,onClick:()=>i(e.id),children:[(0,P.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Wb[e.severity]}),(0,P.jsx)(`div`,{className:`pt`,children:e.title})]},e.id)):(0,P.jsx)(`div`,{style:{padding:`14px`},children:(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No findings have been ingested yet, so there is no evidence to audit.`})})]}),(0,P.jsx)(`div`,{children:a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`mb-4 flex justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`sevtag sev-${a.severity}`,children:Wb[a.severity]}),(0,P.jsx)(`span`,{className:`font-mono text-muted-foreground text-xs`,style:{marginLeft:8},children:a.id}),(0,P.jsx)(`h2`,{style:{marginTop:9},children:a.title})]}),(0,P.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:a.status.replaceAll(`_`,` `)})]}),(0,P.jsx)(`p`,{children:a.description}),(0,P.jsx)(sx,{items:[{k:`CVSS`,v:o.data?.finding.cvssScore??`—`},{k:`Weakness`,v:o.data?.finding.cwe??`—`,mono:!0},{k:`Category`,v:a.displayCategory},{k:`Lifecycle stage`,v:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] [&_.d]:size-2 [&_.d]:rounded-[2px]`,children:[(0,P.jsx)(`span`,{className:`d`,style:{background:`var(${Rb(a.stage).v})`}}),a.stage,` · `,zb(Rb(a.stage))]})}]}),(0,P.jsx)(cx,{title:`Evidence chain — provenance`,children:o.data?.finding.evidence.length?o.data.finding.evidence.map(e=>(0,P.jsx)(lx,{title:e.kind,detail:e.reason??`No reason recorded.`,verdict:e.verdict},e.id)):(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No evidence records attached to this finding.`})}),o.data?.finding.remediation?(0,P.jsx)(cx,{title:`Remediation`,children:(0,P.jsx)(`p`,{children:o.data.finding.remediation})}):null]}):(0,P.jsx)(H4,{compact:!0,title:`Nothing to audit yet`,detail:`Evidence appears once an agent reports a finding through report_finding.`})})]}),(0,P.jsx)($b,{surface:!1,title:`Governance ledger`,sub:`${e.length} recent event${e.length===1?``:`s`}`,children:e.length?(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`#`}),(0,P.jsx)(`th`,{children:`Action`}),(0,P.jsx)(`th`,{children:`Object`}),(0,P.jsx)(`th`,{children:`Actor`}),(0,P.jsx)(`th`,{children:`Outcome`}),(0,P.jsx)(`th`,{children:`Occurred`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`font-mono`,children:e.sequence}),(0,P.jsx)(`td`,{children:e.action}),(0,P.jsxs)(`td`,{children:[e.objectType,` · `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.objectID.slice(0,16)})]}),(0,P.jsx)(`td`,{className:`font-mono`,children:e.actorID??`—`}),(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:fx(e.outcome),children:e.outcome})}),(0,P.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()})]},e.id))})]})}):(0,P.jsx)(H4,{compact:!0,title:`No governance events`,detail:`Run creation, state transitions, tool calls and finding ingestion are all recorded here.`})})]})}function K4({runs:e}){return(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Assessment`}),(0,P.jsx)(`th`,{children:`Kind`}),(0,P.jsx)(`th`,{children:`Status`}),(0,P.jsx)(`th`,{children:`Updated`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`span`,{children:e.title}),(0,P.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.id})]}),(0,P.jsx)(`td`,{children:X4(e.kind)}),(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:fx(e.status),children:X4(e.status)})}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function q4({findings:e}){return(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Finding`}),(0,P.jsx)(`th`,{children:`Severity`}),(0,P.jsx)(`th`,{children:`Status`}),(0,P.jsx)(`th`,{children:`Asset`}),(0,P.jsx)(`th`,{children:`Updated`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`a`,{href:`/findings`,children:e.title}),(0,P.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.description??e.id})]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:fx(e.severity),children:X4(e.severity)})}),(0,P.jsx)(`td`,{children:(0,P.jsx)(px,{variant:fx(e.status),children:X4(e.status)})}),(0,P.jsx)(`td`,{children:e.path??`—`}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function J4(e){return e.some(e=>e.risk===`R2`)?`R2`:e.some(e=>e.risk===`R1`)?`R1`:`R0`}function Y4(e){let t=new Map;for(let n of e){let e=n.path?.trim()||`Unscoped`,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()].map(([e,t])=>({asset:e,items:t})).sort((e,t)=>t.items.length-e.items.length)}function X4(e){return e.replaceAll(`_`,` `).replaceAll(`-`,` `).replace(/\b\w/g,e=>e.toUpperCase())}export{F4 as PlatformRoute};