kifaru 1.0.183 → 1.0.184

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.
@@ -0,0 +1,96 @@
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.BUfd2I7n.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-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),T=o(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),E=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`}]]),D=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`}]]),O=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`}]]),k=o(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),ee=o(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),A=o(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),j=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(`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`}]]),M=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`}]]),ie=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`}]]),ae=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`}]]),oe=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`}]]),se=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`}]]),ce=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`}]]),le=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`}]]),ue=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`}]]),de=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`}]]),fe=o(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),pe=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`}]]),me=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`}]]),he=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`}]]),ge=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`}]]),_e=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`}]]),ve=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`}]]),ye=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),be=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`}]]),xe=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`}]]),Se=o(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ce=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`}]]),we=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`}]]),Te=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Ee=o(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),De=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`}]]),Oe=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`}]]),ke=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`}]]),Ae=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`}]]),je=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`}]]),Me=o(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),N=n(t(),1),P=u(),Ne=Object.defineProperty,Pe=(e,t)=>Ne(e,`name`,{value:t,configurable:!0}),Fe=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`}),Ie=N.forwardRef(Pe(function(e,t){return(0,P.jsx)(f.span,{...e,ref:t,style:{...Fe,...e.style}})},`VisuallyHidden`)),Le=Object.defineProperty,Re=(e,t)=>Le(e,`name`,{value:t,configurable:!0});function ze(e,t){let n=N.createContext(t);n.displayName=e+`Context`;let r=Re(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 Re(i,`useContext`),[r,i]}Re(ze,`createContext`);function Be(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=Re(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 Re(s,`useContext`),[o,s]}Re(r,`createContext`);let i=Re(()=>{let t=n.map(e=>N.createContext(e));return Re(function(n){let r=n?.[e]||t;return N.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Ve(i,...t)]}Re(Be,`createContextScope`);function Ve(...e){let t=e[0];if(e.length===1)return t;let n=Re(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return Re(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}Re(Ve,`composeContextScopes`);var He=Object.defineProperty,Ue=(e,t)=>He(e,`name`,{value:t,configurable:!0});function We(e){let t=e+`CollectionProvider`,[n,r]=Be(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Ue(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 Ue(g,`useCollection`),[{Provider:o,Slot:l,ItemSlot:m},g,r]}Ue(We,`createCollection`);var Ge=new WeakMap,Ke=class e extends Map{static{Ue(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Ge.set(this,!0)}set(e,t){return Ge.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=Ye(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=Je(e,t);return n===-1?void 0:e[n]}Ue(qe,`at`);function Je(e,t){let n=e.length,r=Ye(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Ue(Je,`toSafeIndex`);function Ye(e){return e!==e||e===0?0:Math.trunc(e)}Ue(Ye,`toSafeInteger`);function Xe(e){let t=e+`CollectionProvider`,[n,r]=Be(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ke,setItemMap:Ue(()=>void 0,`setItemMap`)}),o=Ue(({state:e,...t})=>e?(0,P.jsx)(c,{...t,state:e}):(0,P.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=Ue(e=>{let t=_();return(0,P.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=Ue(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=et(()=>{});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);Ze(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($e):(t.set(s,{...e,element:s}),t.toSorted($e)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Ke(e)))}},[s,h,u]),(0,P.jsx)(m,{"data-radix-collection-item":``,ref:l,children:r})});g.displayName=p;function _(){return N.useState(new Ke)}Ue(_,`useInitCollection`);function v(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Ue(v,`useCollection`),[{Provider:o,Slot:f,ItemSlot:g},{createCollectionScope:r,useCollection:v,useInitCollection:_}]}Ue(Xe,`createCollection`);function Ze(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}Ue(Ze,`shallowEqual`);function Qe(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ue(Qe,`isElementPreceding`);function $e(e,t){return!e[1].element||!t[1].element?0:Qe(e[1].element,t[1].element)?-1:1}Ue($e,`sortByDocumentPosition`);function et(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Ue(et,`getChildListObserver`);var tt=Object.defineProperty,nt=(e,t)=>tt(e,`name`,{value:t,configurable:!0}),rt=!!(typeof window<`u`&&window.document&&window.document.createElement);function F(e,t,{checkForDefaultPrevented:n=!0}={}){return nt(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}nt(F,`composeEventHandlers`);function it(e){if(!rt)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}nt(it,`getOwnerWindow`);function at(e){if(!rt)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}nt(at,`getOwnerDocument`);function ot(e,t=!1){let{activeElement:n}=at(e);if(!n?.nodeName)return null;if(st(n)&&n.contentDocument)return ot(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=at(n).getElementById(e);if(t)return t}}return n}nt(ot,`getActiveElement`);function st(e){return e.tagName===`IFRAME`}nt(st,`isFrame`);var ct=globalThis?.document?N.useLayoutEffect:()=>{},lt=Object.defineProperty,ut=(e,t)=>lt(e,`name`,{value:t,configurable:!0}),dt=N.useEffectEvent,ft=N.useInsertionEffect;function pt(e){if(typeof dt==`function`)return dt(e);let t=N.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof ft==`function`?ft(()=>{t.current=e}):ct(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}ut(pt,`useEffectEvent`);var mt=Object.defineProperty,ht=(e,t)=>mt(e,`name`,{value:t,configurable:!0}),gt=N.useInsertionEffect||ct;function _t({prop:e,defaultProp:t,onChange:n=ht(()=>{},`onChange`),caller:r}){let[i,a,o]=vt({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,N.useCallback(t=>{if(s){let n=yt(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}ht(_t,`useControllableState`);function vt({defaultProp:e,onChange:t}){let[n,r]=N.useState(e),i=N.useRef(n),a=N.useRef(t);return gt(()=>{a.current=t},[t]),N.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}ht(vt,`useUncontrolledState`);function yt(e){return typeof e==`function`}ht(yt,`isFunction`);var bt=Symbol(`RADIX:SYNC_STATE`);function xt(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=pt(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=N.useReducer((t,n)=>{if(n.type===bt)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:bt,state:i})},[i,d.state,c]),[h,f]}ht(xt,`useControllableStateReducer`);var St=Object.defineProperty,Ct=(e,t)=>St(e,`name`,{value:t,configurable:!0});function wt(e,t){return N.useReducer((e,n)=>t[e][n]??e,e)}Ct(wt,`useStateMachine`);var Tt=Ct(e=>{let{present:t,children:n}=e,r=Et(t),i=typeof n==`function`?n({present:r.isPresent}):N.Children.only(n),a=Ot(r.ref,At(i));return typeof n==`function`||r.isPresent?N.cloneElement(i,{ref:a}):null},`Presence`);function Et(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]=wt(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??kt(r.current),o.current=void 0):a.current=`none`},[s]),ct(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=kt(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]),ct(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Ct(a=>{let o=kt(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=Ct(e=>{e.target===t&&(a.current=kt(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=kt(t)}else r.current=null;n(e)},[])}}Ct(Et,`usePresence`);function Dt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Ct(Dt,`setRef`);function Ot(...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=Dt(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():Dt(n[e],null)}}},[])}Ct(Ot,`useStableComposedRefs`);function kt(e){return e?.animationName||`none`}Ct(kt,`getAnimationName`);function At(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)}Ct(At,`getElementRef`);var jt=Object.defineProperty,Mt=(e,t)=>jt(e,`name`,{value:t,configurable:!0}),Nt=N.useId||(()=>void 0),Pt=0;function Ft(e){let[t,n]=N.useState(Nt());return ct(()=>{e||n(e=>e??String(Pt++))},[e]),e||(t?`radix-${t}`:``)}Mt(Ft,`useId`);var It=Object.defineProperty,Lt=(e,t)=>It(e,`name`,{value:t,configurable:!0}),Rt=`Collapsible`,[zt,Bt]=Be(Rt),[Vt,Ht]=zt(Rt),Ut=N.forwardRef(Lt(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=_t({prop:r,defaultProp:i??!1,onChange:o,caller:Rt});return(0,P.jsx)(Vt,{scope:n,disabled:a,contentId:Ft(),open:c,onOpenToggle:N.useCallback(()=>l(e=>!e),[l]),children:(0,P.jsx)(f.div,{"data-state":Yt(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),Wt=`CollapsibleTrigger`,Gt=N.forwardRef(Lt(function(e,t){let{__scopeCollapsible:n,...r}=e,i=Ht(Wt,n);return(0,P.jsx)(f.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Yt(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:F(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),Kt=`CollapsibleContent`,qt=N.forwardRef(Lt(function(e,t){let{forceMount:n,...r}=e,i=Ht(Kt,e.__scopeCollapsible);return(0,P.jsx)(Tt,{present:n||i.open,children:({present:e})=>(0,P.jsx)(Jt,{...r,ref:t,present:e})})},`CollapsibleContent`)),Jt=N.forwardRef(Lt(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Ht(Kt,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)},[]),ct(()=>{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":Yt(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 Yt(e){return e?`open`:`closed`}Lt(Yt,`getState`);var Xt=Ut,Zt=Object.defineProperty,Qt=(e,t)=>Zt(e,`name`,{value:t,configurable:!0}),$t=N.createContext(void 0);function en(e){let t=N.useContext($t);return e||t||`ltr`}Qt(en,`useDirection`);var tn=Object.defineProperty,nn=(e,t)=>tn(e,`name`,{value:t,configurable:!0});function rn(e){let t=N.useRef(e);return N.useEffect(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}nn(rn,`useCallbackRef`);var an=Object.defineProperty,on=(e,t)=>an(e,`name`,{value:t,configurable:!0}),sn=`dismissableLayer.update`,cn=`dismissableLayer.pointerDownOutside`,ln=`dismissableLayer.focusOutside`,un,dn=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),fn=N.forwardRef(on(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(dn),[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=hn(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=gn(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=rn(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&&(un=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),_n(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=un))}},[p,h,n,u]),N.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),_n())},[p,u]),N.useEffect(()=>{let e=on(()=>g({}),`handleUpdate`);return document.addEventListener(sn,e),()=>document.removeEventListener(sn,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 pn(){let e=N.useContext(dn),[t,n]=N.useState(null);return N.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}on(pn,`useDismissableLayerSurface`);var mn=on(()=>!0,`IS_TRUE`);function hn(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=mn}=t,s=rn(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()}on(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}on(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)}on(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}on(p,`handleInteractionBubble`);let m=on(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||vn(cn,s,p,{discrete:!0})};if(on(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:on(()=>c.current=!0,`onPointerDownCapture`)}}on(hn,`usePointerDownOutside`);function gn(e,t=globalThis?.document){let n=rn(e),r=N.useRef(!1);return N.useEffect(()=>{let e=on(e=>{e.target&&!r.current&&vn(ln,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:on(()=>r.current=!0,`onFocusCapture`),onBlurCapture:on(()=>r.current=!1,`onBlurCapture`)}}on(gn,`useFocusOutside`);function _n(){let e=new CustomEvent(sn);document.dispatchEvent(e)}on(_n,`dispatchUpdate`);function vn(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)}on(vn,`handleAndDispatchCustomEvent`);var yn=Object.defineProperty,bn=(e,t)=>yn(e,`name`,{value:t,configurable:!0}),xn=`focusScope.autoFocusOnMount`,Sn=`focusScope.autoFocusOnUnmount`,Cn={bubbles:!1,cancelable:!0},wn=N.forwardRef(bn(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=N.useState(null),l=rn(i),u=rn(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:jn(p.current,{select:!0})},t=function(e){if(h.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||jn(p.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&jn(s)};bn(e,`handleFocusIn`),bn(t,`handleFocusOut`),bn(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){Mn.add(h);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(xn,Cn);s.addEventListener(xn,l),s.dispatchEvent(t),t.defaultPrevented||(Tn(Fn(Dn(s)),{select:!0}),document.activeElement===e&&jn(s))}return()=>{s.removeEventListener(xn,l),setTimeout(()=>{let t=new CustomEvent(Sn,Cn);s.addEventListener(Sn,u),s.dispatchEvent(t),t.defaultPrevented||jn(e??document.body,{select:!0}),s.removeEventListener(Sn,u),Mn.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]=En(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&jn(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&jn(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 Tn(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(jn(r,{select:t}),document.activeElement!==n)return}bn(Tn,`focusFirst`);function En(e){let t=Dn(e);return[On(t,e),On(t.reverse(),e)]}bn(En,`getTabbableEdges`);function Dn(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:bn(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}bn(Dn,`getTabbableCandidates`);function On(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):kn(r,{upTo:t})))return r}bn(On,`findVisible`);function kn(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}bn(kn,`isHidden`);function An(e){return e instanceof HTMLInputElement&&`select`in e}bn(An,`isSelectableInput`);function jn(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&An(e)&&t&&e.select()}}bn(jn,`focus`);var Mn=Nn();function Nn(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Pn(e,t),e.unshift(t)},remove(t){e=Pn(e,t),e[0]?.resume()}}}bn(Nn,`createFocusScopesStack`);function Pn(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}bn(Pn,`arrayRemove`);function Fn(e){return e.filter(e=>e.tagName!==`A`)}bn(Fn,`removeLinks`);var In=n(i(),1),Ln=Object.defineProperty,Rn=N.forwardRef(((e,t)=>Ln(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=N.useState(!1);ct(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?In.createPortal((0,P.jsx)(f.div,{...r,ref:t}),o):null},`Portal`)),zn=Object.defineProperty,Bn=(e,t)=>zn(e,`name`,{value:t,configurable:!0}),Vn=0,Hn=null;function Un(e){return Wn(),e.children}Bn(Un,`FocusGuards`);function Wn(){N.useEffect(()=>{Hn||={start:Gn(),end:Gn()};let{start:e,end:t}=Hn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Vn++,()=>{Vn===1&&(Hn?.start.remove(),Hn?.end.remove(),Hn=null),Vn=Math.max(0,Vn-1)}},[])}Bn(Wn,`useFocusGuards`);function Gn(){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}Bn(Gn,`createFocusGuard`);var Kn=function(){return Kn=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},Kn.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 Jn(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 Yn=`right-scroll-bar-position`,Xn=`width-before-scroll-bar`,Zn=`with-scroll-bars-hidden`,Qn=`--removed-body-scroll-bar-size`;function $n(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function er(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 tr=typeof window<`u`?N.useLayoutEffect:N.useEffect,nr=new WeakMap;function rr(e,t){var n=er(t||null,function(t){return e.forEach(function(e){return $n(e,t)})});return tr(function(){var t=nr.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||$n(e,null)}),i.forEach(function(e){r.has(e)||$n(e,a)})}nr.set(n,e)},[e]),n}function ir(e){return e}function ar(e,t){t===void 0&&(t=ir);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 or(e){e===void 0&&(e={});var t=ar(null);return t.options=Kn({async:!0,ssr:!1},e),t}var sr=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,Kn({},n))};sr.isSideCarExport=!0;function cr(e,t){return e.useMedium(t),sr}var lr=or(),ur=function(){},dr=N.forwardRef(function(e,t){var n=N.useRef(null),r=N.useState({onScrollCapture:ur,onWheelCapture:ur,onTouchMoveCapture:ur}),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=rr([n,t]),C=Kn(Kn({},b),i);return N.createElement(N.Fragment,null,u&&N.createElement(x,{sideCar:lr,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),Kn(Kn({},C),{ref:S})):N.createElement(v,Kn({},C,{className:c,ref:S}),s))});dr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},dr.classNames={fullWidth:Xn,zeroRight:Yn};var fr=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function pr(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=fr();return t&&e.setAttribute(`nonce`,t),e}function mr(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function hr(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var gr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=pr())&&(mr(t,n),hr(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},_r=function(){var e=gr();return function(t,n){N.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},vr=function(){var e=_r();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},yr={left:0,top:0,right:0,gap:0},br=function(e){return parseInt(e||``,10)||0},xr=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[br(n),br(r),br(i)]},Sr=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return yr;var t=xr(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])}},Cr=vr(),wr=`data-scroll-locked`,Tr=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
+ .${Zn} {
3
+ overflow: hidden ${r};
4
+ padding-right: ${s}px ${r};
5
+ }
6
+ body[${wr}] {
7
+ overflow: hidden ${r};
8
+ overscroll-behavior: contain;
9
+ ${[t&&`position: relative ${r};`,n===`margin`&&`
10
+ padding-left: ${i}px;
11
+ padding-top: ${a}px;
12
+ padding-right: ${o}px;
13
+ margin-left:0;
14
+ margin-top:0;
15
+ margin-right: ${s}px ${r};
16
+ `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
17
+ }
18
+
19
+ .${Yn} {
20
+ right: ${s}px ${r};
21
+ }
22
+
23
+ .${Xn} {
24
+ margin-right: ${s}px ${r};
25
+ }
26
+
27
+ .${Yn} .${Yn} {
28
+ right: 0 ${r};
29
+ }
30
+
31
+ .${Xn} .${Xn} {
32
+ margin-right: 0 ${r};
33
+ }
34
+
35
+ body[${wr}] {
36
+ ${Qn}: ${s}px;
37
+ }
38
+ `},Er=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Dr=function(){N.useEffect(function(){return document.body.setAttribute(wr,(Er()+1).toString()),function(){var e=Er()-1;e<=0?document.body.removeAttribute(wr):document.body.setAttribute(wr,e.toString())}},[])},Or=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Dr();var a=N.useMemo(function(){return Sr(i)},[i]);return N.createElement(Cr,{styles:Tr(a,!t,i,n?``:`!important`)})},kr=!1;if(typeof window<`u`)try{var Ar=Object.defineProperty({},"passive",{get:function(){return kr=!0,!0}});window.addEventListener(`test`,Ar,Ar),window.removeEventListener(`test`,Ar,Ar)}catch{kr=!1}var jr=kr?{passive:!1}:!1,Mr=function(e){return e.tagName===`TEXTAREA`},Nr=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Mr(e)&&n[t]===`visible`)},Pr=function(e){return Nr(e,`overflowY`)},Fr=function(e){return Nr(e,`overflowX`)},Ir=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),zr(e,r)){var i=Br(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Lr=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Rr=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},zr=function(e,t){return e===`v`?Pr(t):Fr(t)},Br=function(e,t){return e===`v`?Lr(t):Rr(t)},Vr=function(e,t){return e===`h`&&t===`rtl`?-1:1},Hr=function(e,t,n,r,i){var a=Vr(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=Br(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&zr(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},Ur=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Wr=function(e){return[e.deltaX,e.deltaY]},Gr=function(e){return e&&`current`in e?e.current:e},Kr=function(e,t){return e[0]===t[0]&&e[1]===t[1]},qr=function(e){return`
39
+ .block-interactivity-${e} {pointer-events: none;}
40
+ .allow-interactivity-${e} {pointer-events: all;}
41
+ `},Jr=0,Yr=[];function Xr(e){var t=N.useRef([]),n=N.useRef([0,0]),r=N.useRef(),i=N.useState(Jr++)[0],a=N.useState(vr)[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=Jn([e.lockRef.current],(e.shards||[]).map(Gr),!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=Ur(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=Ir(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Ir(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 Hr(h,t,e,h===`h`?s:c,!0)},[]),c=N.useCallback(function(e){var n=e;if(Yr.length&&Yr[Yr.length-1]===a){var r=`deltaY`in n?Wr(n):Ur(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Kr(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Gr).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:Zr(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=Ur(e),r.current=void 0},[]),d=N.useCallback(function(t){l(t.type,Wr(t),t.target,s(t,e.lockRef.current))},[]),f=N.useCallback(function(t){l(t.type,Ur(t),t.target,s(t,e.lockRef.current))},[]);N.useEffect(function(){return Yr.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,jr),document.addEventListener(`touchmove`,c,jr),document.addEventListener(`touchstart`,u,jr),function(){Yr=Yr.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,jr),document.removeEventListener(`touchmove`,c,jr),document.removeEventListener(`touchstart`,u,jr)}},[]);var p=e.removeScrollBar,m=e.inert;return N.createElement(N.Fragment,null,m?N.createElement(a,{styles:qr(i)}):null,p?N.createElement(Or,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Zr(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Qr=cr(lr,Xr),$r=N.forwardRef(function(e,t){return N.createElement(dr,Kn({},e,{ref:t,sideCar:Qr}))});$r.classNames=dr.classNames;var ei=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},ti=new WeakMap,ni=new WeakMap,ri={},ii=0,ai=function(e){return e&&(e.host||ai(e.parentNode))},oi=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ai(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})},si=function(e,t,n,r){var i=oi(t,Array.isArray(e)?e:[e]);ri[n]||(ri[n]=new WeakMap);var a=ri[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=(ti.get(e)||0)+1,l=(a.get(e)||0)+1;ti.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ni.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(),ii++,function(){o.forEach(function(e){var t=ti.get(e)-1,i=a.get(e)-1;ti.set(e,t),a.set(e,i),t||(ni.has(e)||e.removeAttribute(r),ni.delete(e)),i||e.removeAttribute(n)}),ii--,ii||(ti=new WeakMap,ti=new WeakMap,ni=new WeakMap,ri={})}},ci=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||ei(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),si(r,i,n,`aria-hidden`)):function(){return null}},li=Object.defineProperty,ui=(e,t)=>li(e,`name`,{value:t,configurable:!0}),di=`Dialog`,[fi,pi]=Be(di),[mi,hi]=fi(di),gi=ui(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]=_t({prop:r,defaultProp:i??!1,onChange:a,caller:di}),[d,f]=N.useState(0),[p,m]=N.useState(0);return(0,P.jsx)(mi,{scope:t,triggerRef:s,contentRef:c,contentId:Ft(),titleId:Ft(),descriptionId:Ft(),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`),_i=`DialogTrigger`,vi=N.forwardRef(ui(function(e,t){let{__scopeDialog:n,...r}=e,i=hi(_i,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":Ii(i.open),...r,ref:a,onClick:F(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),yi=`DialogPortal`,[bi,xi]=fi(yi,{forceMount:void 0}),Si=ui(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=hi(yi,t);return(0,P.jsx)(bi,{scope:t,forceMount:n,children:N.Children.map(r,e=>(0,P.jsx)(Tt,{present:n||a.open,children:(0,P.jsx)(Rn,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Ci=`DialogOverlay`,wi=N.forwardRef(ui(function(e,t){let n=xi(Ci,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=hi(Ci,e.__scopeDialog);return a.modal?(0,P.jsx)(Tt,{present:r||a.open,children:(0,P.jsx)(Ei,{...i,ref:t})}):null},`DialogOverlay`)),Ti=h(`DialogOverlay.RemoveScroll`),Ei=N.forwardRef(ui(function(e,t){let{__scopeDialog:n,...r}=e,i=hi(Ci,n),a=pn(),o=d(t,a);return(0,P.jsx)($r,{as:Ti,allowPinchZoom:!0,shards:[i.contentRef],children:(0,P.jsx)(f.div,{"data-state":Ii(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Di=`DialogContent`,Oi=N.forwardRef(ui(function(e,t){let n=xi(Di,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=hi(Di,e.__scopeDialog);return(0,P.jsx)(Tt,{present:r||a.open,children:a.modal?(0,P.jsx)(ki,{...i,ref:t}):(0,P.jsx)(Ai,{...i,ref:t})})},`DialogContent`)),ki=N.forwardRef(ui(function(e,t){let n=hi(Di,e.__scopeDialog),r=N.useRef(null),i=d(t,n.contentRef,r);return N.useEffect(()=>{let e=r.current;if(e)return ci(e)},[]),(0,P.jsx)(ji,{...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`)),Ai=N.forwardRef(ui(function(e,t){let n=hi(Di,e.__scopeDialog),r=N.useRef(!1),i=N.useRef(!1);return(0,P.jsx)(ji,{...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`)),ji=N.forwardRef(ui(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=hi(Di,n);return Wn(),(0,P.jsx)(P.Fragment,{children:(0,P.jsx)(wn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,P.jsx)(fn,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Ii(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Mi=`DialogTitle`,Ni=N.forwardRef(ui(function(e,t){let{__scopeDialog:n,...r}=e,i=hi(Mi,n),{setTitleCount:a}=i;return ct(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,P.jsx)(f.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Pi=`DialogClose`,Fi=N.forwardRef(ui(function(e,t){let{__scopeDialog:n,...r}=e,i=hi(Pi,n);return(0,P.jsx)(f.button,{type:`button`,...r,ref:t,onClick:F(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Ii(e){return e?`open`:`closed`}ui(Ii,`getState`);var Li=Object.defineProperty,Ri=(e,t)=>Li(e,`name`,{value:t,configurable:!0}),zi=`Avatar`,[Bi,Vi]=Be(zi),Hi=[0,()=>void 0],[Ui,Wi]=Bi(zi),Gi=N.forwardRef(Ri(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=N.useState(`idle`),[o,s]=Qi();return(0,P.jsx)(Ui,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,P.jsx)(f.span,{...r,ref:t})})},`Avatar`)),Ki=`AvatarImage`,qi=N.forwardRef(Ri(function(e,t){let{__scopeAvatar:n,src:r,onLoadingStatusChange:i,...a}=e,o=Wi(Ki,n);o.setImageCount;let s=Xi(r,{referrerPolicy:a.referrerPolicy,crossOrigin:a.crossOrigin,loadingStatus:o.imageLoadingStatus,setLoadingStatus:o.setImageLoadingStatus}),c=rn(e=>{i?.(e)}),l=N.useRef(s);return ct(()=>{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`)),Ji=`AvatarFallback`,Yi=N.forwardRef(Ri(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=Wi(Ji,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 Xi(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return ct(()=>{if(!e){n(`error`);return}let t=new window.Image,a=Ri(e=>{let t=e.currentTarget;n(Zi(t))},`handleLoad`),o=Ri(()=>n(`error`),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n(Zi(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(`idle`)}},[e,i,r,n]),t}Ri(Xi,`useImageLoadingStatus`);function Zi(e){return e.complete?e.naturalWidth>0?`loaded`:`error`:`loading`}Ri(Zi,`getImageLoadingStatus`);function Qi(){return Hi}Ri(Qi,`useImageCount`);function $i(e){}Ri($i,`useUpdateImageCount`);var ea=Object.defineProperty,ta=(e,t)=>ea(e,`name`,{value:t,configurable:!0});function na(e){let[t,n]=N.useState(void 0);return ct(()=>{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}ta(na,`useSize`);var ra=[`top`,`right`,`bottom`,`left`],ia=Math.min,aa=Math.max,oa=Math.round,sa=Math.floor,ca=e=>({x:e,y:e}),la={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function ua(e,t,n){return aa(e,ia(t,n))}function da(e,t){return typeof e==`function`?e(t):e}function fa(e){return e.split(`-`)[0]}function pa(e){return e.split(`-`)[1]}function ma(e){return e===`x`?`y`:`x`}function ha(e){return e===`y`?`height`:`width`}function ga(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function _a(e){return ma(ga(e))}function va(e,t,n){n===void 0&&(n=!1);let r=pa(e),i=_a(e),a=ha(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Da(o)),[o,Da(o)]}function ya(e){let t=Da(e);return[ba(e),t,ba(t)]}function ba(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var xa=[`left`,`right`],Sa=[`right`,`left`],Ca=[`top`,`bottom`],wa=[`bottom`,`top`];function Ta(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Sa:xa:t?xa:Sa;case`left`:case`right`:return t?Ca:wa;default:return[]}}function Ea(e,t,n,r){let i=pa(e),a=Ta(fa(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ba)))),a}function Da(e){let t=fa(e);return la[t]+e.slice(t.length)}function Oa(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ka(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Oa(e)}function Aa(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 ja(e,t,n){let{reference:r,floating:i}=e,a=ga(t),o=_a(t),s=ha(o),c=fa(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=pa(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Ma(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}=da(t,e),p=ka(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Aa(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=Aa(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 Na=50,Pa=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ma},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ja(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<Na&&(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}=ja(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Fa=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}=da(e,t)||{};if(l==null)return{};let d=ka(u),f={x:n,y:r},p=_a(i),m=ha(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=ia(d[_],T),D=ia(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,ee=ua(E,k,O),A=!c.arrow&&pa(i)!=null&&k!==ee&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,j=A?k<E?k-E:k-O:0;return{[p]:f[p]+j,data:{[p]:ee,centerOffset:k-ee-j,...A&&{alignmentOffset:j}},reset:A}}}),Ia=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}=da(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=fa(r),_=ga(o),v=fa(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Da(o)]:ya(o)),x=p!==`none`;!d&&x&&b.push(...Ea(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=va(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`||_===ga(t)||T.every(e=>ga(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=ga(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 La(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ra(e){return ra.some(t=>e[t]>=0)}var za=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=da(e,t);switch(i){case`referenceHidden`:{let e=La(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ra(e)}}}case`escaped`:{let e=La(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ra(e)}}}default:return{}}}}},Ba=new Set([`left`,`top`]);async function Va(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=fa(n),s=pa(n),c=ga(n)===`y`,l=Ba.has(o)?-1:1,u=a&&c?-1:1,d=da(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 Ha=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 Va(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}}}}},Ua=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}=da(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ga(i),p=ma(f),m=u[p],h=u[f],g=(e,t)=>ua(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}}}}}},Wa=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}=da(e,t),u={x:n,y:r},d=ga(i),f=ma(d),p=u[f],m=u[d],h=da(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=Ba.has(fa(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}}}},Ga=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}=da(e,t),c=await i.detectOverflow(t,s),l=fa(n),u=pa(n),d=ga(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=ia(p-c[m],g),y=ia(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*aa(c.left,c.right):S=p-2*aa(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 Ka(){return typeof window<`u`}function qa(e){return Xa(e)?(e.nodeName||``).toLowerCase():`#document`}function Ja(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ya(e){return((Xa(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Xa(e){return Ka()?e instanceof Node||e instanceof Ja(e).Node:!1}function Za(e){return Ka()?e instanceof Element||e instanceof Ja(e).Element:!1}function Qa(e){return Ka()?e instanceof HTMLElement||e instanceof Ja(e).HTMLElement:!1}function $a(e){return!Ka()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ja(e).ShadowRoot}function eo(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=fo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function to(e){return/^(table|td|th)$/.test(qa(e))}function no(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ro=/transform|translate|scale|rotate|perspective|filter/,io=/paint|layout|strict|content/,ao=e=>!!e&&e!==`none`,oo;function so(e){let t=Za(e)?fo(e):e;return ao(t.transform)||ao(t.translate)||ao(t.scale)||ao(t.rotate)||ao(t.perspective)||!lo()&&(ao(t.backdropFilter)||ao(t.filter))||ro.test(t.willChange||``)||io.test(t.contain||``)}function co(e){let t=mo(e);for(;Qa(t)&&!uo(t);){if(so(t))return t;if(no(t))return null;t=mo(t)}return null}function lo(){return oo??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),oo}function uo(e){return/^(html|body|#document)$/.test(qa(e))}function fo(e){return Ja(e).getComputedStyle(e)}function po(e){return Za(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function mo(e){if(qa(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||$a(e)&&e.host||Ya(e);return $a(t)?t.host:t}function ho(e){let t=mo(e);return uo(t)?(e.ownerDocument||e).body:Qa(t)&&eo(t)?t:ho(t)}function go(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ho(e),i=r===e.ownerDocument?.body,a=Ja(r);if(i){let e=_o(a);return t.concat(a,a.visualViewport||[],eo(r)?r:[],e&&n?go(e):[])}return t.concat(r,go(r,[],n))}function _o(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vo(e){let t=fo(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Qa(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=oa(n)!==a||oa(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function yo(e){return Za(e)?e:e.contextElement}function bo(e){let t=yo(e);if(!Qa(t))return ca(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=vo(t),o=(a?oa(n.width):n.width)/r,s=(a?oa(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var xo=ca(0);function So(e){let t=Ja(e);return!lo()||!t.visualViewport?xo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Co(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ja(e)}function wo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=yo(e),o=ca(1);t&&(r?Za(r)&&(o=bo(r)):o=bo(e));let s=Co(a,n,r)?So(a):ca(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=Ja(a),t=Za(r)?Ja(r):r,n=e,i=_o(n);for(;i&&t!==n;){let e=bo(i),t=i.getBoundingClientRect(),r=fo(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=Ja(i),i=_o(n)}}return Aa({width:u,height:d,x:c,y:l})}function To(e,t){let n=po(e).scrollLeft;return t?t.left+n:wo(Ya(e)).left+n}function Eo(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-To(e,n),y:n.top+t.scrollTop}}function Do(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ya(r),s=t?no(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=ca(1),u=ca(0),d=Qa(r);if((d||!a)&&((qa(r)!==`body`||eo(o))&&(c=po(r)),d)){let e=wo(r);l=bo(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Eo(o,c):ca(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 Oo(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ko(e){let t=po(e),n=e.ownerDocument.body,r=aa(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=aa(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+To(e),o=-t.scrollTop;return fo(n).direction===`rtl`&&(a+=aa(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Ao=25;function jo(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Ja(e),a=Ya(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!lo()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(To(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<=Ao&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Mo(e,t){let n=wo(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=bo(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function No(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=jo(e,n,t);else if(t===`document`)r=ko(Ya(e));else if(Za(t))r=Mo(t,n);else{let n=So(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Aa(r)}function Po(e,t){let n=t.get(e);if(n)return n;let r=go(e,[],!1).filter(e=>Za(e)&&qa(e)!==`body`),i=null,a=fo(e).position===`fixed`,o=a?mo(e):e;for(;Za(o)&&!uo(o);){let e=fo(o),t=so(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=mo(o)}return t.set(e,r),r}function Fo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?no(t)?[]:Po(t,this._c):[].concat(n),r],o=No(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=No(t,a[e],i);s=aa(n.top,s),c=ia(n.right,c),l=ia(n.bottom,l),u=aa(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Io(e){let{width:t,height:n}=vo(e);return{width:t,height:n}}function Lo(e,t,n){let r=Qa(t),i=Ya(t),a=n===`fixed`,o=wo(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=ca(0);if((r||!a)&&((qa(t)!==`body`||eo(i))&&(s=po(t)),r)){let e=wo(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=To(i));let l=i&&!r&&!a?Eo(i,s):ca(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 Ro(e){return fo(e).position===`static`}function zo(e,t){if(!Qa(e)||fo(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ya(e)===n&&(n=n.ownerDocument.body),n}function Bo(e,t){let n=Ja(e);if(no(e))return n;if(!Qa(e)){let t=mo(e);for(;t&&!uo(t);){if(Za(t)&&!Ro(t))return t;t=mo(t)}return n}let r=zo(e,t);for(;r&&to(r)&&Ro(r);)r=zo(r,t);return r&&uo(r)&&Ro(r)&&!so(r)?n:r||co(e)||n}var Vo=async function(e){let t=this.getOffsetParent||Bo,n=this.getDimensions,r=await n(e.floating);return{reference:Lo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ho(e){return fo(e).direction===`rtl`}var Uo={convertOffsetParentRelativeRectToViewportRelativeRect:Do,getDocumentElement:Ya,getClippingRect:Fo,getOffsetParent:Bo,getElementRects:Vo,getClientRects:Oo,getDimensions:Io,getScale:bo,isElement:Za,isRTL:Ho};function Wo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Go(e,t,n){let r=null,i,a=Ya(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=sa(d),h=sa(a.clientWidth-(u+f)),g=sa(a.clientHeight-(d+p)),_=sa(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:aa(0,ia(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Wo(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=Ja(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Ko(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=yo(e),u=i||a?[...l?go(l):[],...t?go(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Go(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?wo(e):null;c&&g();function g(){let t=wo(e);h&&!Wo(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=Ha,Jo=Ua,Yo=Ia,Xo=Ga,Zo=za,Qo=Fa,$o=Wa,es=(e,t,n)=>{let r=new Map,i=n??{},a={...Uo,...i.platform,_c:r};return Pa(e,t,{...i,platform:a})},ts=typeof document<`u`?N.useLayoutEffect:function(){};function ns(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(!ns(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)&&!ns(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function rs(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function is(e,t){let n=rs(e);return Math.round(t*n)/n}function as(e){let t=N.useRef(e);return ts(()=>{t.current=e}),t}function os(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);ns(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=as(c),D=as(i),O=as(l),k=N.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),es(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};ee.current&&!ns(w.current,t)&&(w.current=t,In.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);ts(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let ee=N.useRef(!1);ts(()=>(ee.current=!0,()=>{ee.current=!1}),[]),ts(()=>{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 A=N.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),j=N.useMemo(()=>({reference:b,floating:x}),[b,x]),te=N.useMemo(()=>{let e={position:n,left:0,top:0};if(!j.floating)return e;let t=is(j.floating,u.x),r=is(j.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...rs(j.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,j.floating,u.x,u.y]);return N.useMemo(()=>({...u,update:k,refs:A,elements:j,floatingStyles:te}),[u,k,A,j,te])}var ss=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?{}:Qo({element:r.current,padding:i}).fn(n):r?Qo({element:r,padding:i}).fn(n):{}}}},cs=(e,t)=>{let n=qo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ls=(e,t)=>{let n=Jo(e);return{name:n.name,fn:n.fn,options:[e,t]}},us=(e,t)=>({fn:$o(e).fn,options:[e,t]}),ds=(e,t)=>{let n=Yo(e);return{name:n.name,fn:n.fn,options:[e,t]}},fs=(e,t)=>{let n=Xo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ps=(e,t)=>{let n=Zo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ms=(e,t)=>{let n=ss(e);return{name:n.name,fn:n.fn,options:[e,t]}},hs=Object.defineProperty,gs=N.forwardRef(((e,t)=>hs(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`)),_s=Object.defineProperty,vs=(e,t)=>_s(e,`name`,{value:t,configurable:!0}),ys=`Popper`,[bs,xs]=Be(ys),[Ss,Cs]=bs(ys),ws=vs(e=>{let{__scopePopper:t,children:n}=e,[r,i]=N.useState(null),[a,o]=N.useState(void 0);return(0,P.jsx)(Ss,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Ts=`PopperAnchor`,Es=N.forwardRef(vs(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Cs(Ts,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&&Is(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`)),Ds=`PopperContent`,[Os,ks]=bs(Ds),As=N.forwardRef(vs(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=Cs(Ds,n),[y,b]=N.useState(null),x=d(t,b),[S,C]=N.useState(null),w=na(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],ee=k.length>0,A={padding:O,boundary:k.filter(Ps),altBoundary:ee},{refs:j,floatingStyles:te,placement:ne,isPositioned:re,middlewareData:M}=os({strategy:`fixed`,placement:D,whileElementsMounted:vs((...e)=>Ko(...e,{animationFrame:h===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[cs({mainAxis:i+E,alignmentAxis:o}),c&&ls({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?us():void 0,...A}),c&&ds({...A}),fs({...A,apply:vs(({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&&ms({element:S,padding:s}),Fs({arrowWidth:T,arrowHeight:E}),m&&ps({strategy:`referenceHidden`,...A,boundary:ee?A.boundary:void 0})]}),ie=v.setPlacementState;ct(()=>(ie(ne),()=>{ie(void 0)}),[ne,ie]);let[ae,oe]=Is(ne),se=rn(g);ct(()=>{re&&se?.()},[re,se]);let ce=M.arrow?.x,le=M.arrow?.y,ue=M.arrow?.centerOffset!==0,[de,fe]=N.useState();return ct(()=>{y&&fe(window.getComputedStyle(y).zIndex)},[y]),(0,P.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:re?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:de,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(` `),...M.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,P.jsx)(Os,{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:re?_.style?.animation:`none`}})})})},`PopperContent`)),js=`PopperArrow`,Ms={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Ns=N.forwardRef(vs(function(e,t){let{__scopePopper:n,...r}=e,i=ks(js,n),a=Ms[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)(gs,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function Ps(e){return e!==null}vs(Ps,`isNotNull`);var Fs=vs(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]=Is(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 Is(e){let[t,n=`center`]=e.split(`-`);return[t,n]}vs(Is,`getSideAndAlignFromPlacement`);var Ls=ws,Rs=Es,zs=As,Bs=Ns,Vs=Object.defineProperty,Hs=(e,t)=>Vs(e,`name`,{value:t,configurable:!0}),Us=!1;function Ws(){let[e,t]=N.useState(Us);return N.useEffect(()=>{Us||(Us=!0,t(!0))},[]),e}Hs(Ws,`useIsHydrated`);var Gs=N.useSyncExternalStore;function Ks(){return()=>{}}Hs(Ks,`subscribe`);function qs(){return Gs(Ks,()=>!0,()=>!1)}Hs(qs,`useIsHydratedModern`);var Js=typeof Gs==`function`?qs:Ws,Ys=Object.defineProperty,Xs=(e,t)=>Ys(e,`name`,{value:t,configurable:!0}),Zs=`rovingFocusGroup.onEntryFocus`,Qs={bubbles:!1,cancelable:!0},$s=`RovingFocusGroup`,[ec,tc,nc]=We($s),[rc,ic]=Be($s,[nc]),[ac,oc]=rc($s),sc=N.forwardRef(Xs(function(e,t){return(0,P.jsx)(ec.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(ec.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(cc,{...e,ref:t})})})},`RovingFocusGroup`)),cc=N.forwardRef(Xs(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=en(a),[_,v]=_t({prop:o,defaultProp:s??null,onChange:c,caller:$s}),[y,b]=N.useState(!1),x=rn(l),S=tc(n),C=N.useRef(!1),[w,T]=N.useState(0);return N.useEffect(()=>{let e=m.current;if(e)return e.addEventListener(Zs,x),()=>e.removeEventListener(Zs,x)},[x]),(0,P.jsx)(ac,{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(Zs,Qs);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);mc([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`)),lc=`RovingFocusGroupItem`,uc=N.forwardRef(Xs(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Ft(),l=a||c,u=oc(lc,n),d=u.currentTabStopId===l,p=tc(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=u,_=Js();return ct(()=>{if(_&&r)return m(),()=>h()},[_,r,m,h]),N.useEffect(()=>{if(!_&&r)return m(),()=>h()},[_,r,m,h]),(0,P.jsx)(ec.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=pc(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?hc(n,r+1):n.slice(r+1)}setTimeout(()=>mc(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),dc={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function fc(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}Xs(fc,`getDirectionAwareKey`);function pc(e,t,n){let r=fc(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return dc[r]}Xs(pc,`getFocusIntent`);function mc(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Xs(mc,`focusFirst`);function hc(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Xs(hc,`wrapArray`);var gc=sc,_c=uc,vc=Object.defineProperty,yc=(e,t)=>vc(e,`name`,{value:t,configurable:!0}),bc=[`Enter`,` `],xc=[`ArrowDown`,`PageUp`,`Home`],Sc=[`ArrowUp`,`PageDown`,`End`],Cc=[...xc,...Sc],wc={ltr:[...bc,`ArrowRight`],rtl:[...bc,`ArrowLeft`]},Tc={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Ec=`Menu`,[Dc,Oc,kc]=We(Ec),[Ac,jc]=Be(Ec,[kc,xs,ic]),Mc=xs(),Nc=ic(),[Pc,Fc]=Ac(Ec),[Ic,Lc]=Ac(Ec),Rc=yc(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Mc(t),[c,l]=N.useState(null),u=N.useRef(!1),d=rn(a),f=en(i);return N.useEffect(()=>{let e=yc(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=yc(()=>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=yc(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,P.jsx)(Ls,{...s,children:(0,P.jsx)(Pc,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,P.jsx)(Ic,{scope:t,onClose:N.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),zc=N.forwardRef(yc(function(e,t){let{__scopeMenu:n,...r}=e,i=Mc(n);return(0,P.jsx)(Rs,{...i,...r,ref:t})},`MenuAnchor`)),Bc=`MenuPortal`,[Vc,Hc]=Ac(Bc,{forceMount:void 0}),Uc=yc(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Fc(Bc,t);return(0,P.jsx)(Vc,{scope:t,forceMount:n,children:(0,P.jsx)(Tt,{present:n||a.open,children:(0,P.jsx)(Rn,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Wc=`MenuContent`,[Gc,Kc]=Ac(Wc),qc=N.forwardRef(yc(function(e,t){let n=Hc(Wc,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Fc(Wc,e.__scopeMenu),o=Lc(Wc,e.__scopeMenu);return(0,P.jsx)(Dc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(Tt,{present:r||a.open,children:(0,P.jsx)(Dc.Slot,{scope:e.__scopeMenu,children:o.modal?(0,P.jsx)(Jc,{...i,ref:t}):(0,P.jsx)(Yc,{...i,ref:t})})})})},`MenuContent`)),Jc=N.forwardRef(yc(function(e,t){let n=Fc(Wc,e.__scopeMenu),r=N.useRef(null),i=d(t,r);return N.useEffect(()=>{let e=r.current;if(e)return ci(e)},[]),(0,P.jsx)(Zc,{...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`)),Yc=N.forwardRef(yc(function(e,t){let n=Fc(Wc,e.__scopeMenu);return(0,P.jsx)(Zc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Xc=h(`MenuContent.ScrollLock`),Zc=N.forwardRef(yc(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,_=Fc(Wc,n),v=Lc(Wc,n),y=Mc(n),b=Nc(n),x=Oc(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),ee=N.useRef(`right`),A=N.useRef(0),j=h?$r:N.Fragment,te=h?{as:Xc,allowPinchZoom:!0}:void 0,ne=yc(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=kl(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;yc((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),[]),Wn();let re=N.useCallback(e=>ee.current===k.current?.side&&jl(e,k.current?.area),[]);return(0,P.jsx)(Gc,{scope:n,searchRef:D,onItemEnter:N.useCallback(e=>{re(e)&&e.preventDefault()},[re]),onItemLeave:N.useCallback(e=>{re(e)||(w.current?.focus(),C(null))},[re]),onTriggerLeave:N.useCallback(e=>{re(e)&&e.preventDefault()},[re]),pointerGraceTimerRef:O,onPointerGraceIntentChange:N.useCallback(e=>{k.current=e},[]),children:(0,P.jsx)(j,{...te,children:(0,P.jsx)(wn,{asChild:!0,trapped:i,onMountAutoFocus:F(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,P.jsx)(fn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,P.jsx)(gc,{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)(zs,{role:`menu`,"aria-orientation":`vertical`,"data-state":wl(_.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&&ne(e.key));let i=w.current;if(e.target!==i||!Cc.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);Sc.includes(e.key)&&a.reverse(),Dl(a)}),onBlur:F(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:F(e.onPointerMove,Ml(e=>{let t=e.target,n=A.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>A.current?`right`:`left`;ee.current=t,A.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),Qc=N.forwardRef(yc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`group`,...r,ref:t})},`MenuGroup`)),$c=N.forwardRef(yc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{...r,ref:t})},`MenuLabel`)),el=`MenuItem`,tl=`menu.itemSelect`,nl=N.forwardRef(yc(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=N.useRef(null),o=Lc(el,e.__scopeMenu),s=Kc(el,e.__scopeMenu),c=d(t,a),l=N.useRef(!1),u=yc(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(tl,{bubbles:!0,cancelable:!0});e.addEventListener(tl,e=>r?.(e),{once:!0}),v(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,P.jsx)(rl,{...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!==` `)&&bc.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),rl=N.forwardRef(yc(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Kc(el,n),s=Nc(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)(Dc.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,P.jsx)(_c,{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,Ml(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,Ml(e=>o.onItemLeave(e))),onFocus:F(e.onFocus,()=>p(!0)),onBlur:F(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),il=N.forwardRef(yc(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,P.jsx)(dl,{scope:e.__scopeMenu,checked:n,children:(0,P.jsx)(nl,{role:`menuitemcheckbox`,"aria-checked":Tl(n)?`mixed`:n,...i,ref:t,"data-state":El(n),onSelect:F(i.onSelect,()=>r?.(Tl(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[al,ol]=Ac(`MenuRadioGroup`,{value:void 0,onValueChange:yc(()=>{},`onValueChange`)}),sl=N.forwardRef(yc(function(e,t){let{value:n,onValueChange:r,...i}=e,a=rn(r);return(0,P.jsx)(al,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,P.jsx)(Qc,{...i,ref:t})})},`MenuRadioGroup`)),cl=`MenuRadioItem`,ll=N.forwardRef(yc(function(e,t){let{value:n,...r}=e,i=ol(cl,e.__scopeMenu),a=n===i.value;return(0,P.jsx)(dl,{scope:e.__scopeMenu,checked:a,children:(0,P.jsx)(nl,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":El(a),onSelect:F(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),ul=`MenuItemIndicator`,[dl,fl]=Ac(ul,{checked:!1}),pl=N.forwardRef(yc(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=fl(ul,n);return(0,P.jsx)(Tt,{present:r||Tl(a.checked)||a.checked===!0,children:(0,P.jsx)(f.span,{...i,ref:t,"data-state":El(a.checked)})})},`MenuItemIndicator`)),ml=N.forwardRef(yc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),hl=N.forwardRef(yc(function(e,t){let{__scopeMenu:n,...r}=e,i=Mc(n);return(0,P.jsx)(Bs,{...i,...r,ref:t})},`MenuArrow`)),gl=`MenuSub`,[_l,vl]=Ac(gl),yl=yc(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Fc(gl,t),o=Mc(t),[s,c]=N.useState(null),[l,u]=N.useState(null),d=rn(i);return N.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,P.jsx)(Ls,{...o,children:(0,P.jsx)(Pc,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,P.jsx)(_l,{scope:t,contentId:Ft(),triggerId:Ft(),trigger:s,onTriggerChange:c,children:n})})})},`MenuSub`),bl=`MenuSubTrigger`,xl=N.forwardRef(yc(function(e,t){let n=Fc(bl,e.__scopeMenu),r=Lc(bl,e.__scopeMenu),i=vl(bl,e.__scopeMenu),a=Kc(bl,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)(zc,{asChild:!0,...l,children:(0,P.jsx)(rl,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":wl(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,Ml(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,Ml(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!==` `)&&wc[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),Sl=`MenuSubContent`,Cl=N.forwardRef(yc(function(e,t){let n=Hc(Wc,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Fc(Wc,e.__scopeMenu),s=Lc(Wc,e.__scopeMenu),c=vl(Sl,e.__scopeMenu),l=N.useRef(null),u=d(t,l);return(0,P.jsx)(Dc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(Tt,{present:r||o.open,children:(0,P.jsx)(Dc.Slot,{scope:e.__scopeMenu,children:(0,P.jsx)(Zc,{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=Tc[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function wl(e){return e?`open`:`closed`}yc(wl,`getOpenState`);function Tl(e){return e===`indeterminate`}yc(Tl,`isIndeterminate`);function El(e){return Tl(e)?`indeterminate`:e?`checked`:`unchecked`}yc(El,`getCheckedState`);function Dl(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}yc(Dl,`focusFirst`);function Ol(e,t){return e.map((n,r)=>e[(t+r)%e.length])}yc(Ol,`wrapArray`);function kl(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=Ol(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}yc(kl,`getNextMatch`);function Al(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}yc(Al,`isPointInPolygon`);function jl(e,t){return t?Al({x:e.clientX,y:e.clientY},t):!1}yc(jl,`isPointerInGraceArea`);function Ml(e){return t=>t.pointerType===`mouse`?e(t):void 0}yc(Ml,`whenMouse`);var Nl=Rc,Pl=zc,Fl=Uc,Il=qc,Ll=Qc,Rl=$c,zl=nl,Bl=il,Vl=sl,Hl=ll,Ul=pl,Wl=ml,Gl=hl,Kl=yl,ql=xl,Jl=Cl,Yl=e({Arrow:()=>Pu,CheckboxItem:()=>ku,Content:()=>Tu,DropdownMenu:()=>iu,DropdownMenuArrow:()=>vu,DropdownMenuCheckboxItem:()=>pu,DropdownMenuContent:()=>lu,DropdownMenuGroup:()=>uu,DropdownMenuItem:()=>fu,DropdownMenuItemIndicator:()=>gu,DropdownMenuLabel:()=>du,DropdownMenuPortal:()=>su,DropdownMenuRadioGroup:()=>mu,DropdownMenuRadioItem:()=>hu,DropdownMenuSeparator:()=>_u,DropdownMenuSub:()=>yu,DropdownMenuSubContent:()=>xu,DropdownMenuSubTrigger:()=>bu,DropdownMenuTrigger:()=>ou,Group:()=>Eu,Item:()=>Ou,ItemIndicator:()=>Mu,Label:()=>Du,Portal:()=>wu,RadioGroup:()=>Au,RadioItem:()=>ju,Root:()=>Su,Separator:()=>Nu,Sub:()=>Fu,SubContent:()=>Lu,SubTrigger:()=>Iu,Trigger:()=>Cu,createDropdownMenuScope:()=>eu}),Xl=Object.defineProperty,Zl=(e,t)=>Xl(e,`name`,{value:t,configurable:!0}),Ql=`DropdownMenu`,[$l,eu]=Be(Ql,[jc]),tu=jc(),[nu,ru]=$l(Ql),iu=Zl(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=tu(t),l=N.useRef(null),[u,d]=_t({prop:i,defaultProp:a??!1,onChange:o,caller:Ql});return(0,P.jsx)(nu,{scope:t,triggerId:Ft(),triggerRef:l,contentId:Ft(),open:u,onOpenChange:d,onOpenToggle:N.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,P.jsx)(Nl,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),au=`DropdownMenuTrigger`,ou=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ru(au,n),o=tu(n),s=d(t,a.triggerRef);return(0,P.jsx)(Pl,{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`)),su=Zl(e=>{let{__scopeDropdownMenu:t,...n}=e,r=tu(t);return(0,P.jsx)(Fl,{...r,...n})},`DropdownMenuPortal`),cu=`DropdownMenuContent`,lu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(cu,n),a=tu(n),o=N.useRef(!1);return(0,P.jsx)(Il,{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`)),uu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Ll,{...i,...r,ref:t})},`DropdownMenuGroup`)),du=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Rl,{...i,...r,ref:t})},`DropdownMenuLabel`)),fu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(zl,{...i,...r,ref:t})},`DropdownMenuItem`)),pu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Bl,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),mu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Vl,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),hu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Hl,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),gu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Ul,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),_u=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Wl,{...i,...r,ref:t})},`DropdownMenuSeparator`)),vu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Gl,{...i,...r,ref:t})},`DropdownMenuArrow`)),yu=Zl(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=tu(t),[s,c]=_t({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,P.jsx)(Kl,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),bu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(ql,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),xu=N.forwardRef(Zl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tu(n);return(0,P.jsx)(Jl,{...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`)),Su=iu,Cu=ou,wu=su,Tu=lu,Eu=uu,Du=du,Ou=fu,ku=pu,Au=mu,ju=hu,Mu=gu,Nu=_u,Pu=vu,Fu=yu,Iu=bu,Lu=xu,Ru=Object.defineProperty,zu=(e,t)=>Ru(e,`name`,{value:t,configurable:!0}),[Bu,Vu]=Be(`Tooltip`,[xs]),Hu=xs(),Uu=`TooltipProvider`,Wu=700,Gu=`tooltip.open`,[Ku,qu]=Bu(Uu),Ju=zu(e=>{let{__scopeTooltip:t,delayDuration:n=Wu,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)(Ku,{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`),Yu=`Tooltip`,[Xu,Zu]=Bu(Yu),Qu=zu(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=qu(Yu,e.__scopeTooltip),l=Hu(t),[u,d]=N.useState(null),[f,p]=N.useState(void 0),m=Ft(),h=N.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=N.useRef(!1),[y,b]=_t({prop:r,defaultProp:i??!1,onChange:zu(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Gu))):c.onClose(),a?.(e)},`onChange`),caller:Yu}),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)(Ls,{...l,children:(0,P.jsx)(Xu,{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`),$u=`TooltipTrigger`,ed=N.forwardRef(zu(function(e,t){let{__scopeTooltip:n,...r}=e,i=Zu($u,n),a=qu($u,n),o=Hu(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)(Rs,{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`)),td=`TooltipPortal`,[nd,rd]=Bu(td,{forceMount:void 0}),id=zu(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Zu(td,t);return(0,P.jsx)(nd,{scope:t,forceMount:n,children:(0,P.jsx)(Tt,{present:n||a.open,children:(0,P.jsx)(Rn,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),ad=`TooltipContent`,od=N.forwardRef(zu(function(e,t){let n=rd(ad,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Zu(ad,e.__scopeTooltip);return(0,P.jsx)(Tt,{present:r||o.open,children:o.disableHoverableContent?(0,P.jsx)(ld,{side:i,...a,ref:t}):(0,P.jsx)(sd,{side:i,...a,ref:t})})},`TooltipContent`)),sd=N.forwardRef(zu(function(e,t){let n=Zu(ad,e.__scopeTooltip),r=qu(ad,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=fd(r,dd(r,n.getBoundingClientRect())),a=pd(t.getBoundingClientRect()),o=hd([...i,...a]);s(o),f(!0)},[f]);return N.useEffect(()=>()=>p(),[p]),N.useEffect(()=>{if(c&&u){let e=zu(e=>m(e,u),`handleTriggerLeave`),t=zu(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=zu(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!md(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)(ld,{...e,ref:a})},`TooltipContentHoverable`)),cd=p(`TooltipContent`),ld=N.forwardRef(zu(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=Zu(ad,n),u=Hu(n),{onClose:d}=l;N.useEffect(()=>(document.addEventListener(Gu,d),()=>document.removeEventListener(Gu,d)),[d]),N.useEffect(()=>{if(l.trigger){let e=zu(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 ct(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,P.jsx)(fn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,P.jsxs)(zs,{"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)(cd,{children:r}),i?(0,P.jsx)(Ie,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),ud=N.forwardRef(zu(function(e,t){let{__scopeTooltip:n,...r}=e,i=Hu(n);return(0,P.jsx)(Bs,{...i,...r,ref:t})},`TooltipArrow`));function dd(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`)}}zu(dd,`getExitSideFromRect`);function fd(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}zu(fd,`getPaddedExitPoints`);function pd(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}]}zu(pd,`getPointsFromRect`);function md(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}zu(md,`isPointInPolygon`);function hd(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)),gd(t)}zu(hd,`getHull`);function gd(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)}zu(gd,`getHullPresorted`);var _d=Ju,vd=Qu,yd=ed,bd=id,xd=od,Sd=ud,Cd=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(){}},wd={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Td=new class{#e=wd;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 Ed(e){setTimeout(e,0)}var Dd=typeof window>`u`||`Deno`in globalThis;function Od(){}function kd(e,t){return typeof e==`function`?e(t):e}function Ad(e){return typeof e==`number`&&e>=0&&e!==1/0}function jd(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Md(e,t){return typeof e==`function`?e(t):e}function Nd(e,t){return typeof e==`function`?e(t):e}function Pd(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Id(o,t.options))return!1}else if(!Rd(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 Fd(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Ld(t.options.mutationKey)!==Ld(a))return!1}else if(!Rd(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Id(e,t){return(t?.queryKeyHashFn||Ld)(e)}function Ld(e){return JSON.stringify(e,(e,t)=>Ud(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Rd(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Rd(e[n],t[n])):!1}var zd=Object.prototype.hasOwnProperty;function Bd(e,t){if(e===t)return e;let n=Hd(e)&&Hd(t);if(!n&&!(Ud(e)&&Ud(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:zd.call(e,a))&&s++;continue}if(l===null||u===null||typeof l!=`object`||typeof u!=`object`){o[a]=u;continue}let d=Bd(l,u);o[a]=d,d===l&&s++}return r===a&&s===r?e:o}function Vd(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 Hd(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ud(e){if(!Wd(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Wd(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Wd(e){return Object.prototype.toString.call(e)===`[object Object]`}function Gd(e){return new Promise(t=>{Td.setTimeout(t,e)})}function Kd(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Bd(e,t)}function qd(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Jd(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Yd=Symbol();function Xd(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Yd?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Zd(e,t){return typeof e==`function`?e(...t):!!e}var Qd=new class extends Cd{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!Dd&&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 $d(){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 ef=Ed;function tf(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ef,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 nf=tf(),rf=new class extends Cd{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!Dd&&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 af(e){return Math.min(1e3*2**e,3e4)}function of(e){return(e??`online`)!==`online`||rf.isOnline()}var sf=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function cf(e){let t=!1,n=0,r,i=$d(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new sf(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Qd.isFocused()&&(e.networkMode===`always`||rf.isOnline())&&e.canRun(),u=()=>of(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??(Dd?0:3),o=e.retryDelay??af,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),Gd(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 lf=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ad(this.gcTime)&&(this.#e=Td.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Dd?1/0:3e5))}clearGcTimeout(){this.#e&&=(Td.clearTimeout(this.#e),void 0)}},uf=class extends lf{#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=ff(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=ff(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=Kd(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(Od).catch(Od):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Nd(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Yd||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Md(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:!jd(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=Xd(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=cf({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof sf&&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 sf){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,...df(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),nf.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function df(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:of(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ff(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 pf=class extends Cd{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=$d(),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),hf(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return gf(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return gf(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 Nd(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&&!Vd(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&_f(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Nd(this.options.enabled,this.#t)!==Nd(t.enabled,this.#t)||Md(this.options.staleTime,this.#t)!==Md(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Nd(this.options.enabled,this.#t)!==Nd(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 yf(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(Od)),t}#g(){this.#b();let e=Md(this.options.staleTime,this.#t);if(Dd||this.#r.isStale||!Ad(e))return;let t=jd(this.#r.dataUpdatedAt,e)+1;this.#d=Td.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,!Dd&&Nd(this.options.enabled,this.#t)!==!1&&Ad(this.#p)&&this.#p!==0&&(this.#f=Td.setInterval(()=>{(this.options.refetchIntervalInBackground||Qd.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(Td.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(Td.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&&hf(e,t),o=i&&_f(e,n,t,r);(a||o)&&(l={...l,...df(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=Kd(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=Kd(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:vf(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Nd(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=$d();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),!Vd(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){nf.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function mf(e,t){return Nd(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||t.retryOnMount!==!1)}function hf(e,t){return mf(e,t)||e.state.data!==void 0&&gf(e,t,t.refetchOnMount)}function gf(e,t,n){if(Nd(t.enabled,e)!==!1&&Md(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&vf(e,t)}return!1}function _f(e,t,n,r){return(e!==t||Nd(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&vf(e,n)}function vf(e,t){return Nd(t.enabled,e)!==!1&&e.isStaleByTime(Md(t.staleTime,e))}function yf(e,t){return!Vd(e.getCurrentResult(),t)}function bf(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=Xd(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?Jd:qd;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Sf:xf,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:xf(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 xf(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 Sf(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Cf=class extends lf{#e;#t;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||wf(),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=cf({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),nf.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:`updated`,action:e})})}};function wf(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Tf=class extends Cd{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 Cf({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ef(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=Ef(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=Ef(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=Ef(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){nf.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=>Fd(t,e))}findAll(e={}){return this.getAll().filter(t=>Fd(e,t))}notify(e){nf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return nf.batch(()=>Promise.all(e.map(e=>e.continue().catch(Od))))}};function Ef(e){return e.options.scope?.id}var Df=class extends Cd{#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),Vd(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ld(t.mutationKey)!==Ld(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??wf();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){nf.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)})})}},Of=class extends Cd{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Id(r,t),a=this.get(i);return a||(a=new uf({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(){nf.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=>Pd(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Pd(e,t)):t}notify(e){nf.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){nf.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){nf.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},kf=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Of,this.#t=e.mutationCache||new Tf,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Qd.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=rf.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(Md(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=kd(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return nf.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;nf.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return nf.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=nf.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Od).catch(Od)}invalidateQueries(e,t={}){return nf.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=nf.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(Od)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Od)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Md(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Od).catch(Od)}fetchInfiniteQuery(e){return e.behavior=bf(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Od).catch(Od)}ensureInfiniteQueryData(e){return e.behavior=bf(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return rf.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(Ld(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Rd(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Ld(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Rd(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||=Id(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===Yd&&(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()}},Af=N.createContext(void 0),jf=e=>{let t=N.useContext(Af);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Mf=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(Af.Provider,{value:e,children:t})),Nf=N.createContext(!1),Pf=()=>N.useContext(Nf);Nf.Provider;function Ff(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var If=N.createContext(Ff()),Lf=()=>N.useContext(If),Rf=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},zf=e=>{N.useEffect(()=>{e.clearReset()},[e])},Bf=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Zd(n,[e.error,r])),Vf=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))}},Hf=(e,t)=>e.isLoading&&e.isFetching&&!t,Uf=(e,t)=>e?.suspense&&t.isPending,Wf=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Gf(e,t,n){let r=Pf(),i=Lf(),a=jf(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Vf(o),Rf(o,i),zf(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(nf.batchCalls(e)):Od;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(o)},[o,c]),Uf(o,l))throw Wf(o,c,i);if(Bf({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&&!Dd&&Hf(l,r)&&(s?Wf(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Od).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function Kf(e,t){return Gf(e,pf,t)}function qf(e,t){let n=jf(t),[r]=N.useState(()=>new Df(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(nf.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=N.useCallback((e,t)=>{r.mutate(e,t).catch(Od)},[r]);if(i.error&&Zd(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 Jf=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Yf=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},Xf={};function Zf(e){return e&&Object.assign(Xf,e),Xf}function Qf(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 $f(e,t){return typeof t==`bigint`?t.toString():t}function ep(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function tp(e){return e==null}function np(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function rp(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 ip=Symbol(`evaluating`);function ap(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ip)return r===void 0&&(r=ip,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function op(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function sp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function cp(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function lp(e){return JSON.stringify(e)}var up=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function dp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var fp=ep(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function pp(e){if(dp(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return dp(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function mp(e){return pp(e)?{...e}:Array.isArray(e)?[...e]:e}var hp=new Set([`string`,`number`,`symbol`]);function gp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _p(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 vp(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var yp={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function bp(e,t){let n=e._zod.def;return _p(e,cp(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 sp(this,`shape`,e),e},checks:[]}))}function xp(e,t){let n=e._zod.def;return _p(e,cp(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 sp(this,`shape`,r),r},checks:[]}))}function Sp(e,t){if(!pp(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 _p(e,cp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return sp(this,`shape`,n),n},checks:[]}))}function Cp(e,t){if(!pp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _p(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return sp(this,`shape`,n),n},checks:e._zod.def.checks})}function wp(e,t){return _p(e,cp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return sp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Tp(e,t,n){return _p(t,cp(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 sp(this,`shape`,i),i},checks:[]}))}function Ep(e,t,n){return _p(t,cp(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 sp(this,`shape`,i),i},checks:[]}))}function Dp(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 Op(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function kp(e){return typeof e==`string`?e:e?.message}function Ap(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=kp(e.inst?._zod.def?.error?.(e))??kp(t?.error?.(e))??kp(n.customError?.(e))??kp(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function jp(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Mp(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Np=(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,$f,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pp=I(`$ZodError`,Np),Fp=I(`$ZodError`,Np,{Parent:Error});function Ip(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 Lp(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 Rp=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 Jf;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Ap(e,a,Zf())));throw up(t,i?.callee),t}return o.value},zp=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=>Ap(e,a,Zf())));throw up(t,i?.callee),t}return o.value},Bp=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 Jf;return a.issues.length?{success:!1,error:new(e??Pp)(a.issues.map(e=>Ap(e,i,Zf())))}:{success:!0,data:a.value}},Vp=Bp(Fp),Hp=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=>Ap(e,i,Zf())))}:{success:!0,data:a.value}},Up=Hp(Fp),Wp=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Rp(e)(t,n,i)},Gp=e=>(t,n,r)=>Rp(e)(t,n,r),Kp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return zp(e)(t,n,i)},qp=e=>async(t,n,r)=>zp(e)(t,n,r),Jp=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Bp(e)(t,n,i)},Yp=e=>(t,n,r)=>Bp(e)(t,n,r),Xp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Hp(e)(t,n,i)},Zp=e=>async(t,n,r)=>Hp(e)(t,n,r),Qp=/^[cC][^\s-]{8,}$/,$p=/^[0-9a-z]+$/,em=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,tm=/^[0-9a-vA-V]{20}$/,nm=/^[A-Za-z0-9]{27}$/,rm=/^[a-zA-Z0-9_-]{21}$/,im=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,am=/^([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})$/,om=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)$/,sm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,cm=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function lm(){return new RegExp(cm,`u`)}var um=/^(?:(?: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])$/,dm=/^(([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}|:))$/,fm=/^((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])$/,pm=/^(([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])$/,mm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hm=/^[A-Za-z0-9_-]*$/,gm=/^(?=.{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])?)*\.?$/,_m=/^\+(?:[0-9]){6,14}[0-9]$/,vm=`(?:(?:\\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])))`,ym=RegExp(`^${vm}$`);function bm(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 xm(e){return RegExp(`^${bm(e)}$`)}function Sm(e){let t=bm({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(`^${vm}T(?:${r})$`)}var Cm=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},wm=/^-?\d+$/,Tm=/^-?\d+(?:\.\d+)?/,Em=/^(?:true|false)$/i,Dm=/^null$/i,Om=/^[^A-Z]*$/,km=/^[^a-z]*$/,Am=I(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jm={number:`number`,bigint:`bigint`,object:`date`},Mm=I(`$ZodCheckLessThan`,(e,t)=>{Am.init(e,t);let n=jm[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})}}),Nm=I(`$ZodCheckGreaterThan`,(e,t)=>{Am.init(e,t);let n=jm[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})}}),Pm=I(`$ZodCheckMultipleOf`,(e,t)=>{Am.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):rp(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})}}),Fm=I(`$ZodCheckNumberFormat`,(e,t)=>{Am.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=yp[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=wm)}),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})}}),Im=I(`$ZodCheckMaxLength`,(e,t)=>{var n;Am.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!tp(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=jp(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Lm=I(`$ZodCheckMinLength`,(e,t)=>{var n;Am.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!tp(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=jp(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Rm=I(`$ZodCheckLengthEquals`,(e,t)=>{var n;Am.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!tp(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=jp(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})}}),zm=I(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Am.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=()=>{})}),Bm=I(`$ZodCheckRegex`,(e,t)=>{zm.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})}}),Vm=I(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Om,zm.init(e,t)}),Hm=I(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=km,zm.init(e,t)}),Um=I(`$ZodCheckIncludes`,(e,t)=>{Am.init(e,t);let n=gp(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})}}),Wm=I(`$ZodCheckStartsWith`,(e,t)=>{Am.init(e,t);let n=RegExp(`^${gp(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})}}),Gm=I(`$ZodCheckEndsWith`,(e,t)=>{Am.init(e,t);let n=RegExp(`.*${gp(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})}}),Km=I(`$ZodCheckOverwrite`,(e,t)=>{Am.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(`
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
+ `))}},Jm={major:4,minor:1,patch:8},Ym=I(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jm;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=Dp(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 Jf;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Dp(e,t))});else{if(e.issues.length===t)continue;r||=Dp(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Dp(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Jf;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 Jf;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=Vp(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Up(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Xm=I(`$ZodString`,(e,t)=>{Ym.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Cm(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}}),Zm=I(`$ZodStringFormat`,(e,t)=>{zm.init(e,t),Xm.init(e,t)}),Qm=I(`$ZodGUID`,(e,t)=>{t.pattern??=am,Zm.init(e,t)}),$m=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??=om(e)}else t.pattern??=om();Zm.init(e,t)}),eh=I(`$ZodEmail`,(e,t)=>{t.pattern??=sm,Zm.init(e,t)}),th=I(`$ZodURL`,(e,t)=>{Zm.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:gm.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})}}}),nh=I(`$ZodEmoji`,(e,t)=>{t.pattern??=lm(),Zm.init(e,t)}),rh=I(`$ZodNanoID`,(e,t)=>{t.pattern??=rm,Zm.init(e,t)}),ih=I(`$ZodCUID`,(e,t)=>{t.pattern??=Qp,Zm.init(e,t)}),ah=I(`$ZodCUID2`,(e,t)=>{t.pattern??=$p,Zm.init(e,t)}),oh=I(`$ZodULID`,(e,t)=>{t.pattern??=em,Zm.init(e,t)}),sh=I(`$ZodXID`,(e,t)=>{t.pattern??=tm,Zm.init(e,t)}),ch=I(`$ZodKSUID`,(e,t)=>{t.pattern??=nm,Zm.init(e,t)}),lh=I(`$ZodISODateTime`,(e,t)=>{t.pattern??=Sm(t),Zm.init(e,t)}),uh=I(`$ZodISODate`,(e,t)=>{t.pattern??=ym,Zm.init(e,t)}),dh=I(`$ZodISOTime`,(e,t)=>{t.pattern??=xm(t),Zm.init(e,t)}),fh=I(`$ZodISODuration`,(e,t)=>{t.pattern??=im,Zm.init(e,t)}),ph=I(`$ZodIPv4`,(e,t)=>{t.pattern??=um,Zm.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),mh=I(`$ZodIPv6`,(e,t)=>{t.pattern??=dm,Zm.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})}}}),hh=I(`$ZodCIDRv4`,(e,t)=>{t.pattern??=fm,Zm.init(e,t)}),gh=I(`$ZodCIDRv6`,(e,t)=>{t.pattern??=pm,Zm.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 _h(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var vh=I(`$ZodBase64`,(e,t)=>{t.pattern??=mm,Zm.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{_h(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function yh(e){if(!hm.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return _h(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var bh=I(`$ZodBase64URL`,(e,t)=>{t.pattern??=hm,Zm.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{yh(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),xh=I(`$ZodE164`,(e,t)=>{t.pattern??=_m,Zm.init(e,t)});function Sh(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 Ch=I(`$ZodJWT`,(e,t)=>{Zm.init(e,t),e._zod.check=n=>{Sh(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),wh=I(`$ZodNumber`,(e,t)=>{Ym.init(e,t),e._zod.pattern=e._zod.bag.pattern??Tm,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}}),Th=I(`$ZodNumber`,(e,t)=>{Fm.init(e,t),wh.init(e,t)}),Eh=I(`$ZodBoolean`,(e,t)=>{Ym.init(e,t),e._zod.pattern=Em,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}}),Dh=I(`$ZodNull`,(e,t)=>{Ym.init(e,t),e._zod.pattern=Dm,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}}),Oh=I(`$ZodUnknown`,(e,t)=>{Ym.init(e,t),e._zod.parse=e=>e}),kh=I(`$ZodNever`,(e,t)=>{Ym.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ah(e,t,n){e.issues.length&&t.issues.push(...Op(n,e.issues)),t.value[n]=e.value}var jh=I(`$ZodArray`,(e,t)=>{Ym.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=>Ah(t,n,e))):Ah(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Mh(e,t,n,r){e.issues.length&&t.issues.push(...Op(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Nh(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=vp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ph(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=>Mh(e,n,i,t))):Mh(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 Fh=I(`$ZodObject`,(e,t)=>{Ym.init(e,t);let n=ep(()=>Nh(t));ap(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=dp,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=>Mh(n,t,e,s))):Mh(n,t,e,s)}return i?Ph(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Ih=I(`$ZodObjectJIT`,(e,t)=>{Fh.init(e,t);let n=e._zod.parse,r=ep(()=>Nh(t)),i=e=>{let t=new qm([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=lp(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=lp(e);t.write(`const ${n} = ${i(e)};`),t.write(`
44
+ if (${n}.issues.length) {
45
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
46
+ ...iss,
47
+ path: iss.path ? [${r}, ...iss.path] : [${r}]
48
+ })));
49
+ }
50
+
51
+
52
+ if (${n}.value === undefined) {
53
+ if (${r} in input) {
54
+ newResult[${r}] = undefined;
55
+ }
56
+ } else {
57
+ newResult[${r}] = ${n}.value;
58
+ }
59
+
60
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=dp,s=!Xf.jitless,c=s&&fp.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?Ph([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Lh(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=>!Dp(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=>Ap(e,r,Zf())))}),t)}var Rh=I(`$ZodUnion`,(e,t)=>{Ym.init(e,t),ap(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),ap(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),ap(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),ap(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=>np(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=>Lh(t,i,e,a)):Lh(s,i,e,a)}}),zh=I(`$ZodIntersection`,(e,t)=>{Ym.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])=>Vh(e,t,n)):Vh(e,i,a)}});function Bh(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pp(e)&&pp(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=Bh(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=Bh(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 Vh(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Dp(e))return e;let r=Bh(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var Hh=I(`$ZodRecord`,(e,t)=>{Ym.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!pp(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(...Op(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Op(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=>Ap(e,r,Zf())),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(...Op(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Op(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Uh=I(`$ZodEnum`,(e,t)=>{Ym.init(e,t);let n=Qf(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>hp.has(typeof e)).map(e=>typeof e==`string`?gp(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}}),Wh=I(`$ZodLiteral`,(e,t)=>{if(Ym.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`?gp(e):e?gp(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}}),Gh=I(`$ZodTransform`,(e,t)=>{Ym.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Yf(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 Jf;return n.value=i,n}});function Kh(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var qh=I(`$ZodOptional`,(e,t)=>{Ym.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,ap(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ap(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${np(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=>Kh(t,e.value)):Kh(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Jh=I(`$ZodNullable`,(e,t)=>{Ym.init(e,t),ap(e._zod,`optin`,()=>t.innerType._zod.optin),ap(e._zod,`optout`,()=>t.innerType._zod.optout),ap(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${np(e.source)}|null)$`):void 0}),ap(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)}),Yh=I(`$ZodDefault`,(e,t)=>{Ym.init(e,t),e._zod.optin=`optional`,ap(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=>Xh(e,t)):Xh(r,t)}});function Xh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Zh=I(`$ZodPrefault`,(e,t)=>{Ym.init(e,t),e._zod.optin=`optional`,ap(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))}),Qh=I(`$ZodNonOptional`,(e,t)=>{Ym.init(e,t),ap(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=>$h(t,e)):$h(i,e)}});function $h(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 eg=I(`$ZodCatch`,(e,t)=>{Ym.init(e,t),ap(e._zod,`optin`,()=>t.innerType._zod.optin),ap(e._zod,`optout`,()=>t.innerType._zod.optout),ap(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=>Ap(e,n,Zf()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ap(e,n,Zf()))},input:e.value}),e.issues=[]),e)}}),tg=I(`$ZodPipe`,(e,t)=>{Ym.init(e,t),ap(e._zod,`values`,()=>t.in._zod.values),ap(e._zod,`optin`,()=>t.in._zod.optin),ap(e._zod,`optout`,()=>t.out._zod.optout),ap(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=>ng(e,t.in,n)):ng(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ng(e,t.out,n)):ng(r,t.out,n)}});function ng(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var rg=I(`$ZodReadonly`,(e,t)=>{Ym.init(e,t),ap(e._zod,`propValues`,()=>t.innerType._zod.propValues),ap(e._zod,`values`,()=>t.innerType._zod.values),ap(e._zod,`optin`,()=>t.innerType._zod.optin),ap(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(ig):ig(r)}});function ig(e){return e.value=Object.freeze(e.value),e}var ag=I(`$ZodLazy`,(e,t)=>{Ym.init(e,t),ap(e._zod,`innerType`,()=>t.getter()),ap(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),ap(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),ap(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),ap(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),og=I(`$ZodCustom`,(e,t)=>{Am.init(e,t),Ym.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=>sg(t,n,r,e));sg(i,n,r,e)}});function sg(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(Mp(e))}}var cg=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 lg(){return new cg}var ug=lg();function dg(e,t){return new e({type:`string`,...L(t)})}function fg(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function pg(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function mg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function hg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function gg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function _g(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function vg(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function yg(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function bg(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function xg(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Sg(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Cg(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function wg(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function Tg(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function Eg(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function Dg(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function Og(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function kg(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function Ag(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function jg(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function Mg(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function Ng(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function Pg(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function Fg(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function Ig(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function Lg(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function Rg(e,t){return new e({type:`number`,checks:[],...L(t)})}function zg(e,t){return new e({type:`number`,coerce:!0,checks:[],...L(t)})}function Bg(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function Vg(e,t){return new e({type:`boolean`,...L(t)})}function Hg(e,t){return new e({type:`null`,...L(t)})}function Ug(e){return new e({type:`unknown`})}function Wg(e,t){return new e({type:`never`,...L(t)})}function Gg(e,t){return new Mm({check:`less_than`,...L(t),value:e,inclusive:!1})}function Kg(e,t){return new Mm({check:`less_than`,...L(t),value:e,inclusive:!0})}function qg(e,t){return new Nm({check:`greater_than`,...L(t),value:e,inclusive:!1})}function Jg(e,t){return new Nm({check:`greater_than`,...L(t),value:e,inclusive:!0})}function Yg(e,t){return new Pm({check:`multiple_of`,...L(t),value:e})}function Xg(e,t){return new Im({check:`max_length`,...L(t),maximum:e})}function Zg(e,t){return new Lm({check:`min_length`,...L(t),minimum:e})}function Qg(e,t){return new Rm({check:`length_equals`,...L(t),length:e})}function $g(e,t){return new Bm({check:`string_format`,format:`regex`,...L(t),pattern:e})}function e_(e){return new Vm({check:`string_format`,format:`lowercase`,...L(e)})}function t_(e){return new Hm({check:`string_format`,format:`uppercase`,...L(e)})}function n_(e,t){return new Um({check:`string_format`,format:`includes`,...L(t),includes:e})}function r_(e,t){return new Wm({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function i_(e,t){return new Gm({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function a_(e){return new Km({check:`overwrite`,tx:e})}function o_(e){return a_(t=>t.normalize(e))}function s_(){return a_(e=>e.trim())}function c_(){return a_(e=>e.toLowerCase())}function l_(){return a_(e=>e.toUpperCase())}function u_(e,t,n){return new e({type:`array`,element:t,...L(n)})}function d_(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function f_(e){let t=p_(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Mp(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(Mp(r))}},e(n.value,n)));return t}function p_(e,t){let n=new Am({check:`custom`,...L(t)});return n._zod.check=e,n}var m_=I(`ZodISODateTime`,(e,t)=>{lh.init(e,t),z_.init(e,t)});function h_(e){return Pg(m_,e)}var g_=I(`ZodISODate`,(e,t)=>{uh.init(e,t),z_.init(e,t)});function __(e){return Fg(g_,e)}var v_=I(`ZodISOTime`,(e,t)=>{dh.init(e,t),z_.init(e,t)});function y_(e){return Ig(v_,e)}var b_=I(`ZodISODuration`,(e,t)=>{fh.init(e,t),z_.init(e,t)});function x_(e){return Lg(b_,e)}var S_=(e,t)=>{Pp.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Lp(e,t)},flatten:{value:t=>Ip(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,$f,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,$f,2)}},isEmpty:{get(){return e.issues.length===0}}})};I(`ZodError`,S_);var C_=I(`ZodError`,S_,{Parent:Error}),w_=Rp(C_),T_=zp(C_),E_=Bp(C_),D_=Hp(C_),O_=Wp(C_),k_=Gp(C_),A_=Kp(C_),j_=qp(C_),M_=Jp(C_),N_=Yp(C_),P_=Xp(C_),F_=Zp(C_),I_=I(`ZodType`,(e,t)=>(Ym.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)=>_p(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>w_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>E_(e,t,n),e.parseAsync=async(t,n)=>T_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>D_(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>O_(e,t,n),e.decode=(t,n)=>k_(e,t,n),e.encodeAsync=async(t,n)=>A_(e,t,n),e.decodeAsync=async(t,n)=>j_(e,t,n),e.safeEncode=(t,n)=>M_(e,t,n),e.safeDecode=(t,n)=>N_(e,t,n),e.safeEncodeAsync=async(t,n)=>P_(e,t,n),e.safeDecodeAsync=async(t,n)=>F_(e,t,n),e.refine=(t,n)=>e.check(Jv(t,n)),e.superRefine=t=>e.check(Yv(t)),e.overwrite=t=>e.check(a_(t)),e.optional=()=>Av(e),e.nullable=()=>Mv(e),e.nullish=()=>Av(Mv(e)),e.nonoptional=t=>Rv(e,t),e.array=()=>B(e),e.or=t=>yv([e,t]),e.and=t=>xv(e,t),e.transform=t=>Hv(e,Ov(t)),e.default=t=>Pv(e,t),e.prefault=t=>Iv(e,t),e.catch=t=>Bv(e,t),e.pipe=t=>Hv(e,t),e.readonly=()=>Wv(e),e.describe=t=>{let n=e.clone();return ug.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return ug.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return ug.get(e);let n=e.clone();return ug.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),L_=I(`_ZodString`,(e,t)=>{Xm.init(e,t),I_.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($g(...t)),e.includes=(...t)=>e.check(n_(...t)),e.startsWith=(...t)=>e.check(r_(...t)),e.endsWith=(...t)=>e.check(i_(...t)),e.min=(...t)=>e.check(Zg(...t)),e.max=(...t)=>e.check(Xg(...t)),e.length=(...t)=>e.check(Qg(...t)),e.nonempty=(...t)=>e.check(Zg(1,...t)),e.lowercase=t=>e.check(e_(t)),e.uppercase=t=>e.check(t_(t)),e.trim=()=>e.check(s_()),e.normalize=(...t)=>e.check(o_(...t)),e.toLowerCase=()=>e.check(c_()),e.toUpperCase=()=>e.check(l_())}),R_=I(`ZodString`,(e,t)=>{Xm.init(e,t),L_.init(e,t),e.email=t=>e.check(fg(B_,t)),e.url=t=>e.check(vg(U_,t)),e.jwt=t=>e.check(Ng(iv,t)),e.emoji=t=>e.check(yg(W_,t)),e.guid=t=>e.check(pg(V_,t)),e.uuid=t=>e.check(mg(H_,t)),e.uuidv4=t=>e.check(hg(H_,t)),e.uuidv6=t=>e.check(gg(H_,t)),e.uuidv7=t=>e.check(_g(H_,t)),e.nanoid=t=>e.check(bg(G_,t)),e.guid=t=>e.check(pg(V_,t)),e.cuid=t=>e.check(xg(K_,t)),e.cuid2=t=>e.check(Sg(q_,t)),e.ulid=t=>e.check(Cg(J_,t)),e.base64=t=>e.check(Ag(tv,t)),e.base64url=t=>e.check(jg(nv,t)),e.xid=t=>e.check(wg(Y_,t)),e.ksuid=t=>e.check(Tg(X_,t)),e.ipv4=t=>e.check(Eg(Z_,t)),e.ipv6=t=>e.check(Dg(Q_,t)),e.cidrv4=t=>e.check(Og($_,t)),e.cidrv6=t=>e.check(kg(ev,t)),e.e164=t=>e.check(Mg(rv,t)),e.datetime=t=>e.check(h_(t)),e.date=t=>e.check(__(t)),e.time=t=>e.check(y_(t)),e.duration=t=>e.check(x_(t))});function R(e){return dg(R_,e)}var z_=I(`ZodStringFormat`,(e,t)=>{Zm.init(e,t),L_.init(e,t)}),B_=I(`ZodEmail`,(e,t)=>{eh.init(e,t),z_.init(e,t)}),V_=I(`ZodGUID`,(e,t)=>{Qm.init(e,t),z_.init(e,t)}),H_=I(`ZodUUID`,(e,t)=>{$m.init(e,t),z_.init(e,t)}),U_=I(`ZodURL`,(e,t)=>{th.init(e,t),z_.init(e,t)}),W_=I(`ZodEmoji`,(e,t)=>{nh.init(e,t),z_.init(e,t)}),G_=I(`ZodNanoID`,(e,t)=>{rh.init(e,t),z_.init(e,t)}),K_=I(`ZodCUID`,(e,t)=>{ih.init(e,t),z_.init(e,t)}),q_=I(`ZodCUID2`,(e,t)=>{ah.init(e,t),z_.init(e,t)}),J_=I(`ZodULID`,(e,t)=>{oh.init(e,t),z_.init(e,t)}),Y_=I(`ZodXID`,(e,t)=>{sh.init(e,t),z_.init(e,t)}),X_=I(`ZodKSUID`,(e,t)=>{ch.init(e,t),z_.init(e,t)}),Z_=I(`ZodIPv4`,(e,t)=>{ph.init(e,t),z_.init(e,t)}),Q_=I(`ZodIPv6`,(e,t)=>{mh.init(e,t),z_.init(e,t)}),$_=I(`ZodCIDRv4`,(e,t)=>{hh.init(e,t),z_.init(e,t)}),ev=I(`ZodCIDRv6`,(e,t)=>{gh.init(e,t),z_.init(e,t)}),tv=I(`ZodBase64`,(e,t)=>{vh.init(e,t),z_.init(e,t)}),nv=I(`ZodBase64URL`,(e,t)=>{bh.init(e,t),z_.init(e,t)}),rv=I(`ZodE164`,(e,t)=>{xh.init(e,t),z_.init(e,t)}),iv=I(`ZodJWT`,(e,t)=>{Ch.init(e,t),z_.init(e,t)}),av=I(`ZodNumber`,(e,t)=>{wh.init(e,t),I_.init(e,t),e.gt=(t,n)=>e.check(qg(t,n)),e.gte=(t,n)=>e.check(Jg(t,n)),e.min=(t,n)=>e.check(Jg(t,n)),e.lt=(t,n)=>e.check(Gg(t,n)),e.lte=(t,n)=>e.check(Kg(t,n)),e.max=(t,n)=>e.check(Kg(t,n)),e.int=t=>e.check(sv(t)),e.safe=t=>e.check(sv(t)),e.positive=t=>e.check(qg(0,t)),e.nonnegative=t=>e.check(Jg(0,t)),e.negative=t=>e.check(Gg(0,t)),e.nonpositive=t=>e.check(Kg(0,t)),e.multipleOf=(t,n)=>e.check(Yg(t,n)),e.step=(t,n)=>e.check(Yg(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 Rg(av,e)}var ov=I(`ZodNumberFormat`,(e,t)=>{Th.init(e,t),av.init(e,t)});function sv(e){return Bg(ov,e)}var cv=I(`ZodBoolean`,(e,t)=>{Eh.init(e,t),I_.init(e,t)});function lv(e){return Vg(cv,e)}var uv=I(`ZodNull`,(e,t)=>{Dh.init(e,t),I_.init(e,t)});function dv(e){return Hg(uv,e)}var fv=I(`ZodUnknown`,(e,t)=>{Oh.init(e,t),I_.init(e,t)});function pv(){return Ug(fv)}var mv=I(`ZodNever`,(e,t)=>{kh.init(e,t),I_.init(e,t)});function hv(e){return Wg(mv,e)}var gv=I(`ZodArray`,(e,t)=>{jh.init(e,t),I_.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Zg(t,n)),e.nonempty=t=>e.check(Zg(1,t)),e.max=(t,n)=>e.check(Xg(t,n)),e.length=(t,n)=>e.check(Qg(t,n)),e.unwrap=()=>e.element});function B(e,t){return u_(gv,e,t)}var _v=I(`ZodObject`,(e,t)=>{Ih.init(e,t),I_.init(e,t),ap(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:pv()}),e.loose=()=>e.clone({...e._zod.def,catchall:pv()}),e.strict=()=>e.clone({...e._zod.def,catchall:hv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Sp(e,t),e.safeExtend=t=>Cp(e,t),e.merge=t=>wp(e,t),e.pick=t=>bp(e,t),e.omit=t=>xp(e,t),e.partial=(...t)=>Tp(kv,e,t[0]),e.required=(...t)=>Ep(Lv,e,t[0])});function V(e,t){return new _v({type:`object`,get shape(){return sp(this,`shape`,e?op(e):{}),this.shape},...L(t)})}var vv=I(`ZodUnion`,(e,t)=>{Rh.init(e,t),I_.init(e,t),e.options=t.options});function yv(e,t){return new vv({type:`union`,options:e,...L(t)})}var bv=I(`ZodIntersection`,(e,t)=>{zh.init(e,t),I_.init(e,t)});function xv(e,t){return new bv({type:`intersection`,left:e,right:t})}var Sv=I(`ZodRecord`,(e,t)=>{Hh.init(e,t),I_.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Cv(e,t,n){return new Sv({type:`record`,keyType:e,valueType:t,...L(n)})}var wv=I(`ZodEnum`,(e,t)=>{Uh.init(e,t),I_.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 wv({...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 wv({...t,checks:[],...L(r),entries:i})}});function H(e,t){return new wv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Tv=I(`ZodLiteral`,(e,t)=>{Wh.init(e,t),I_.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 Ev(e,t){return new Tv({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Dv=I(`ZodTransform`,(e,t)=>{Gh.init(e,t),I_.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Yf(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Mp(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(Mp(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Ov(e){return new Dv({type:`transform`,transform:e})}var kv=I(`ZodOptional`,(e,t)=>{qh.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Av(e){return new kv({type:`optional`,innerType:e})}var jv=I(`ZodNullable`,(e,t)=>{Jh.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Mv(e){return new jv({type:`nullable`,innerType:e})}var Nv=I(`ZodDefault`,(e,t)=>{Yh.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Pv(e,t){return new Nv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():mp(t)}})}var Fv=I(`ZodPrefault`,(e,t)=>{Zh.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Iv(e,t){return new Fv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():mp(t)}})}var Lv=I(`ZodNonOptional`,(e,t)=>{Qh.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Rv(e,t){return new Lv({type:`nonoptional`,innerType:e,...L(t)})}var zv=I(`ZodCatch`,(e,t)=>{eg.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Bv(e,t){return new zv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Vv=I(`ZodPipe`,(e,t)=>{tg.init(e,t),I_.init(e,t),e.in=t.in,e.out=t.out});function Hv(e,t){return new Vv({type:`pipe`,in:e,out:t})}var Uv=I(`ZodReadonly`,(e,t)=>{rg.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Wv(e){return new Uv({type:`readonly`,innerType:e})}var Gv=I(`ZodLazy`,(e,t)=>{ag.init(e,t),I_.init(e,t),e.unwrap=()=>e._zod.def.getter()});function Kv(e){return new Gv({type:`lazy`,getter:e})}var qv=I(`ZodCustom`,(e,t)=>{og.init(e,t),I_.init(e,t)});function Jv(e,t={}){return d_(qv,e,t)}function Yv(e){return f_(e)}function Xv(e){let t=Kv(()=>yv([R(e),z(),lv(),dv(),B(t),Cv(R(),t)]));return t}function Zv(e){return zg(av,e)}var U=R().uuid(),W=R().datetime({offset:!0}),Qv=R().regex(/^[a-f0-9]{64}$/);R().trim().min(1);var $v=H([`owner`,`admin`,`security_manager`,`operator`,`viewer`,`auditor`]),ey=H([`R0`,`R1`,`R2`]),ty=H([`public`,`internal`,`confidential`,`restricted`]);V({cursor:R().min(1).optional(),limit:Zv().int().min(1).max(200).default(50)}),V({nextCursor:R().min(1).optional(),hasMore:lv()}),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 ny=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()}),ry=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:ny,sensitive:lv(),createdAt:W,lastActivityAt:W}),iy=V({id:U,sessionId:U,role:H([`user`,`assistant`,`system`,`tool`]),redactedPreview:R(),sensitivePayloadArtifactId:U.nullable(),createdAt:W}),ay=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:Qv,outputArtifactId:U.nullable(),startedAt:W,completedAt:W.nullable()});V({session:ry,messages:B(iy),toolActivities:B(ay)}),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 oy=H([`informational`,`low`,`medium`,`high`,`critical`]),sy=H([`clean`,`informational`,`actionable`,`critical`]),cy=V({fingerprint:Qv.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(Qv).default([])}),ly=V({description:R().min(1),artifactType:R().min(1),data:Xv().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()}),uy=H([`observation`,`artifact`,`control_result`,`manual_confirmation`,`report`]),dy=V({fingerprint:Qv,title:R().min(1),description:R().default(``),severity:oy,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(Qv).default([]),status:H([`open`]).default(`open`)}).strict(),fy=V({fingerprint:Qv,kind:uy,title:R().min(1),summary:R().default(``),artifactType:R(),sha256:Qv,timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional(),classification:ty.default(`confidential`)}).strict(),py=V({satisfied:lv(),missing:B(R())}).strict(),my=V({id:U,runId:U,projectId:U,workflowKey:R().min(1),workflowVersionId:U,version:z().int().nonnegative(),contentHash:Qv,target:R().min(1),scopeOrigins:B(R()).default([]),summary:R().default(``),posture:sy,findings:B(dy).default([]),unverifiedLeads:B(dy).default([]),evidence:B(fy).default([]),negativeControls:B(R()).default([]),classification:ty.default(`confidential`),publicationState:H([`draft`,`blocked`,`published`]).default(`draft`),gate:py,parentContentHash:Qv.nullable().default(null),editorialMarkdownHash:Qv.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:Xv().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(cy).default([]),evidenceItems:B(ly).default([]),negativeControls:B(R().min(1).max(4e3)).max(500).default([]),toolAttempts:z().int().nonnegative(),toolsExecuted:z().int().nonnegative(),toolsErrored:z().int().nonnegative(),pricingUnknown:lv().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 hy=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)}),gy=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:Qv}),_y=V({requestsPerSecond:z().positive().optional(),concurrency:z().int().positive().optional(),durationSeconds:z().int().positive(),costUsd:z().nonnegative().optional(),modelTokens:z().int().nonnegative().optional()}),vy=V({projectId:U,name:R().trim().min(1).max(160),targets:B(hy).min(1),exclusions:B(R().trim().min(1)),authorization:gy.optional(),allowedRisk:ey,allowedActions:B(R().min(1)),prohibitedActions:B(R().min(1)),limits:_y,requiredWorkerClass:R().trim().min(1),requiredCapabilities:B(R().trim().min(1)),credentialReferences:B(R().trim().min(1)),dataClassification:ty,retentionPolicyId:U.optional(),notificationChannels:B(R().trim().min(1))}).extend({id:U,organizationId:U,workspaceId:U,revision:z().int().positive(),inputHash:Qv,createdAt:W,createdBy:U}),yy=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:yy,fingerprint:Qv,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:ty,artifactId:U.nullable(),sha256:Qv,createdAt:W});var by=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,objectKey:R().min(1),sha256:Qv,mimeType:R().min(1),size:z().int().nonnegative(),classification:ty,createdBy:U,createdAt:W}),xy=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`]),Sy=V({key:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),name:R().min(1),description:R().min(1),risk:ey,optional:lv().default(!1),requiredCapabilities:B(R().min(1)),skillRefs:B(R().min(1).max(80)).max(64).default([]),retrySafe:lv(),approvalCheckpoint:lv(),timeoutSeconds:z().int().positive()}),Cy=V({id:U,key:xy,version:R().regex(/^\d+\.\d+\.\d+$/),name:R().min(1),description:R().min(1),inputSchema:Cv(R(),pv()),requiredCapabilities:B(R().min(1)),requiredIntegrations:B(R().min(1)),stages:B(Sy).min(1),evidenceRequirements:B(R().min(1)).min(1),completionCriteria:B(R().min(1)).min(1),publishedAt:W,contentHash:Qv}),wy=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()}),Ty=V({ready:lv(),launchState:H([`ready`,`blocked`,`awaiting_approval`]),highestRisk:ey,reasons:B(wy),matchingWorkerIds:B(U),inputHash:Qv}),Ey=H([`draft`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`cancel_requested`,`succeeded`,`failed`,`cancelled`,`expired`]),Dy=H([`pending`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`paused`,`succeeded`,`failed`,`cancel_requested`,`cancelled`,`expired`,`skipped`]);V({projectId:U,assessmentProfileId:U,workflowKey:xy,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Cv(R(),pv()),workerClass:R().min(1),mode:H([`autonomous`,`guided`]).default(`autonomous`)});var Oy=V({id:U,organizationId:U,workspaceId:U,projectId:U,assessmentId:U,assessmentProfileId:U,workflowVersionId:U,workflowKey:xy,requestedBy:U,state:Ey,risk:ey,inputHash:Qv,workerClass:R(),mode:H([`autonomous`,`guided`]),attempt:z().int().positive(),retryOfRunId:U.nullable(),agentSessionId:U.nullable(),usage:ny,version:z().int().nonnegative(),createdAt:W,startedAt:W.nullable(),completedAt:W.nullable()}),ky=V({id:U,runId:U,key:R().min(1),position:z().int().nonnegative(),risk:ey,state:Dy,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:Cv(R(),pv()),occurredAt:W}),V({after:z().int().nonnegative().default(0)});var Ay=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`network-security-audit`]);V({target:R().trim().min(1).max(2048),workflowKey:Ay,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Cv(R(),pv()).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 jy=V({profile:vy,authorization:gy,artifact:by}),My=V({projectId:U,target:hy,dossierKey:R().min(1),profileId:U,profileName:R().min(1),reusedProfile:lv()}),Ny=V({binding:My,readiness:Ty}),Py=V({binding:My,run:Oy,stages:B(ky),agentSession:ry}),Fy=H([`pending`,`approved`,`rejected`,`expired`,`invalidated`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,stageId:U.nullable(),risk:ey,state:Fy,requestedBy:U,requiredRole:H([`security_manager`,`owner_or_admin`]),decidedBy:U.nullable(),decisionRole:H([`owner`,`admin`,`security_manager`]).nullable(),workflowVersionId:U,inputHash:Qv,scopeHash:Qv,targetSetHash:Qv,workerClass:R().min(1),actionSetHash:Qv,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:Qv.nullable(),afterHash:Qv.nullable(),previousEventHash:Qv.nullable(),eventHash:Qv,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 Iy=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:lv(),createdAt:W}),organizationId:U,memberships:B(V({workspaceId:U,workspaceName:R().min(1),role:$v,permissions:B(Iy)})),activeWorkspaceId:U}),V({id:U,userId:U,createdAt:W,lastSeenAt:W,expiresAt:W,ip:R().nullable(),userAgent:R().nullable(),current:lv()}),V({password:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,workspaceId:U,email:R().email(),role:$v,expiresAt:W,acceptedAt:W.nullable(),createdAt:W});var Ly=z().int().nonnegative(),Ry=R().min(1),zy=H([`info`,`low`,`medium`,`high`,`critical`]),By=H([`open`,`unverified`,`confirmed`,`remediating`,`remediated`,`verified`,`false_positive`,`accepted_risk`,`suppressed`]),Vy=H([`cli`,`tui`,`web`,`github`,`system`]),Hy=H([`scan`,`hunt`,`verify`,`import`]),Uy=H([`queued`,`running`,`completed`,`failed`,`cancelled`]),Wy=Cv(R(),pv()),Gy=V({id:Ry,workspaceID:Ry,projectID:Ry.nullable(),repositoryID:Ry.nullable(),engagementID:Ry.nullable(),targetID:Ry.nullable(),parentRunID:Ry.nullable(),sessionID:Ry.nullable(),source:Vy,kind:Hy,status:Uy,title:R(),requestedBy:R().nullable(),baseRevision:R().nullable(),headRevision:R().nullable(),promptRevision:R().nullable(),promptFingerprint:R().nullable(),configuration:Wy.nullable(),summary:Wy.nullable(),error:Wy.nullable(),idempotencyKey:R().nullable(),createdAt:Ly,startedAt:Ly.nullable(),completedAt:Ly.nullable(),updatedAt:Ly}),Ky=V({runs:B(Gy),nextCursor:R().optional()}),qy=V({id:Ry,fingerprint:R().min(1),title:R(),description:R().nullable(),severity:zy,status:By,path:R().nullable(),line:z().int().nullable(),category:R().nullable(),firstSeenAt:Ly,lastSeenAt:Ly,updatedAt:Ly}),Jy=V({findings:B(qy),total:z().int().nonnegative()}),Yy=V({id:Ry,runID:Ry.nullable(),operationID:Ry.nullable(),kind:R(),verdict:R(),reason:R().nullable(),payload:Wy.nullable(),createdAt:Ly}),Xy=V({finding:qy.extend({cwe:R().nullable(),cve:R().nullable(),cvssScore:z().nullable(),cvssVector:R().nullable(),remediation:R().nullable(),assignee:R().nullable(),resolvedAt:Ly.nullable(),evidence:B(Yy)})}),Zy=V({id:Ry,runID:Ry,tool:R(),runtime:R(),status:R(),outcome:R(),title:R().nullable(),input:Wy.nullable(),outputPreview:R().nullable(),error:Wy.nullable(),startedAt:Ly,completedAt:Ly.nullable()}),Qy=V({run:Gy,operations:B(Zy.omit({runID:!0})),findings:B(qy)}),$y=V({id:Ry,title:R(),kind:R(),source:R(),status:H([`running`,`failed`,`completed`]),runCount:z().int().nonnegative(),operationCount:z().int().nonnegative(),findingCount:z().int().nonnegative(),startedAt:Ly,lastActivityAt:Ly}),eb=V({session:$y,runs:B(Gy),operations:B(Zy),findings:B(qy)}),tb=V({id:Ry,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:Wy.nullable(),createdAt:Ly}),nb=V({id:Ry,workspaceId:Ry,name:R(),slug:R(),archivedAt:Ly.nullable(),createdAt:Ly,updatedAt:Ly}),rb=V({id:Ry,name:R(),role:R(),createdAt:Ly,updatedAt:Ly}),ib=V({id:Ry,name:R(),status:R(),capabilities:B(R()).default([]),lastSeenAt:Ly.nullable()}),ab=V({sessionId:R().nullable().optional(),runs:Cv(R(),z()),findings:V({total:z().int().nonnegative(),bySeverity:Cv(R(),z()),byStatus:Cv(R(),z())}),recentRuns:B(Gy),recentFindings:B(qy)}),ob=V({count:z().int().nonnegative(),limit:z().int().positive(),hasMore:lv()});function sb(e){return V({items:B(e),page:ob})}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:Cv(R(),pv()),payloadHash:Qv,occurredAt:W})).min(1).max(500)}),V({batchId:U,accepted:B(U),rejected:B(V({id:U,code:R(),detail:R()})),centralizedApproval:Ev(!1)});var cb=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(cb),allowedSkills:B(R().min(1).max(80)).max(64).default([]),retrySafe:lv(),timeoutMs:z().int().positive()});var lb=V({workerClass:H([`network`,`web-api`,`mobile-lab`,`advanced-analysis`,`passive`]),capabilities:B(R().min(1)),tools:Cv(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:lb}),V({expiresAt:W}),V({token:R().min(32),expiresAt:W}),V({worker:V({id:U,organizationId:U,workspaceId:U,name:R(),publicKey:R(),capabilities:lb,status:H([`enrolling`,`online`,`offline`,`revoked`]),lastHeartbeatAt:W.nullable(),createdAt:W}),accessToken:R().min(32),expiresAt:W}),V({capabilities:lb.optional(),runningJobIds:B(U)}),V({id:U,runId:U,stageId:U,workerId:U,leaseToken:R().min(32),leaseExpiresAt:W,attempt:z().int().positive(),payload:Cv(R(),pv())}),V({leaseToken:R().min(32),events:B(V({idempotencyKey:R().min(8),type:R().min(1),occurredAt:W,payload:Cv(R(),pv())})).min(1).max(500)});var ub=V({leaseToken:R().min(32)});ub.extend({extendSeconds:z().int().min(10).max(300).default(60)}),ub.extend({outcome:H([`succeeded`,`failed`,`cancelled`]),summary:Cv(R(),pv()).default({}),error:R().max(2e4).optional(),retrySafe:lv().default(!1)});var db=V({items:B(Cy)}),fb=sb(rb),pb=sb(nb),mb=V({items:B(vy)}),hb=sb($y),gb=sb(tb),_b=sb(ib),vb=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()}),yb=vb.extend({token:R()}),bb=V({items:B(vb)}),xb=V({items:B(V({version:z().int().nonnegative(),posture:R(),target:R(),contentHash:R(),classification:R(),publicationState:H([`draft`,`blocked`,`published`]),gate:V({satisfied:lv(),missing:B(R())}),publishedAt:R().nullable(),createdAt:R()}))}),Sb=V({ext:R(),mimeType:R(),url:R().nullable(),rendered:lv()}),Cb=V({version:z().int().nonnegative(),contentHash:R(),posture:R(),target:R(),classification:R(),record:my,renditions:B(Sb)}),wb=V({artifacts:B(V({artifactId:R(),mimeType:R(),size:z(),sha256:R()}))}),Tb=V({version:z().int().nonnegative(),contentHash:R(),posture:R()}),Eb=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function Db(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 Eb(401,`unauthorized`,`Session expired. Redirecting to login.`);let s=await o.json().catch(()=>void 0);if(!o.ok){let e=s;throw new Eb(o.status,e?.code??`request_failed`,e?.detail??`Request failed.`)}return n.parse(s)}return{workflows:()=>t(`/api/v1/workflows`,db),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()}`,Ky)},runDetail:e=>t(`/api/v1/runs/${encodeURIComponent(e)}`,Qy),workspaces:()=>t(`/api/v1/workspaces`,fb),projects:()=>t(`/api/v1/projects`,pb),assessmentProfiles:()=>t(`/api/v1/assessment-profiles`,mb),authorizeAssessmentProfile:(e,n)=>t(`/api/v1/assessment-profiles/${encodeURIComponent(e)}/authorization-attestations`,jy,{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()}`,Jy)},finding:e=>t(`/api/v1/findings/${encodeURIComponent(e)}`,Xy),agentSessions:()=>t(`/api/v1/agent/sessions?limit=50`,hb),agentSession:e=>t(`/api/v1/agent/sessions/${encodeURIComponent(e)}`,eb),governanceEvents:()=>t(`/api/v1/governance/audit-events?limit=50`,gb),workers:()=>t(`/api/v1/workers`,_b),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`,ab)},tokens:()=>t(`/api/v1/tokens`,bb),mintToken:e=>t(`/api/v1/tokens`,yb,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),revokeToken:e=>t(`/api/v1/tokens/${encodeURIComponent(e)}`,V({ok:lv()}),{method:`DELETE`}),targetAssessmentReadiness:e=>t(`/api/v1/assessments/readiness`,Ny,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startTargetAssessment:e=>t(`/api/v1/assessments`,Py,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),reportVersions:e=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports`,xb),reportVersion:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}`,Cb),renderReportRenditions:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/renditions`,wb,{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`,Tb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({markdown:r})})}}var Ob=Db(),kb=[{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 Ab(e){return kb[Math.min(Math.max(e,1),kb.length)-1]}function jb(e){return e.name.split(` `)[0]}var Mb=[`Governance`,`Technical`,`People & 3rd-party`,`Assurance`],Nb=[`critical`,`high`,`medium`,`low`,`info`],Pb={critical:0,high:1,medium:2,low:3,info:4},Fb={critical:`--crit`,high:`--high`,medium:`--med`,low:`--low`,info:`--info`},Ib={critical:`Critical`,high:`High`,medium:`Medium`,low:`Low`,info:`Info`};function Lb(e){return e===`informational`?`info`:Nb.includes(e)?e:`info`}function Rb(e){return e.length?[...e].sort((e,t)=>Pb[e.severity]-Pb[t.severity])[0].severity:null}function zb(e){return[...e].sort((e,t)=>Pb[e.severity]-Pb[t.severity])}function Bb(e){return e.status!==`remediated`&&e.status!==`verified`}var Vb=/^(?:L|stage )([1-6])\s*·\s*P([0-3])\s*·\s*(.+)$/i;function Hb(e,t){let n=(e??``).trim(),r=Vb.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 Ub(e){return e.map(e=>{let t=Hb(e.category,e.title);return{...e,severity:Lb(e.severity),stage:t.stage,pillar:t.pillar,displayCategory:t.inferred?`${t.category} (stage inferred)`:t.category,inferred:t.inferred}})}function Wb(e){return Rb(e.filter(e=>e.status===`confirmed`||e.status===`verified`))}function Gb({title:e,sub:t,surface:n=!0,children:r}){return(0,P.jsxs)(`section`,{className:n?`bg-card rounded-xl border p-5 shadow-xs`: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 Kb({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(${Fb[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 Jb({counts:e}){let t=Math.max(...Nb.map(t=>e[t]),1);return(0,P.jsx)(`div`,{children:Nb.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(${Fb[n]})`}}),Ib[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(${Fb[n]})`}})}),(0,P.jsx)(`span`,{className:`n`,children:e[n]})]},n))})}function Yb({findings:e}){let t=kb.map(t=>e.filter(e=>e.stage===t.n).length),n=Math.max(...t,1);return(0,P.jsx)(`div`,{className:`stagebars`,children:kb.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:jb(e)})]},e.n)})})}function Xb({findings:e,onSelect:t,emptyLabel:n=`No findings.`}){return e.length?(0,P.jsx)(`div`,{className:`flist`,children:e.map(e=>{let n=Ab(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:Ib[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,` · `,jb(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 Zb({findings:e,selected:t,onSelect:n}){return(0,P.jsx)(`div`,{className:`chain`,children:kb.map(r=>{let i=e.filter(e=>e.stage===r.n),a=Rb(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(${Fb[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 Qb({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`}),kb.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:Mb.map((n,r)=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`rh`,children:n}),kb.map(i=>{let a=e.filter(e=>e.pillar===r&&e.stage===i.n),o=Rb(a);return o?(0,P.jsx)(`td`,{className:`has`,style:{background:`var(${Fb[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 $b({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 ex({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 tx({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 nx=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`}}),rx={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 ix(e){return e?rx[e]??`secondary`:`secondary`}function ax({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(nx({variant:t}),e),...r})}var ox={clean:`success`,informational:`neutral`,actionable:`warning`,critical:`critical`},sx={critical:`critical`,high:`error`,medium:`warning`,low:`neutral`,informational:`neutral`};function cx({title:e,detail:t}){return(0,P.jsx)(`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:`Kifaru platform`}),(0,P.jsx)(`h1`,{children:e}),(0,P.jsx)(`p`,{children:t})]})})}function lx(){let e=jf(),t=Kf({queryKey:[`runs`],queryFn:()=>Ob.runs()}),n=t.data?.runs??[],[r,i]=(0,N.useState)(null),a=Kf({queryKey:[`report-versions`,r],queryFn:()=>Ob.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=Kf({queryKey:[`report-version`,r,o],queryFn:()=>Ob.reportVersion(r,o),enabled:!!r&&o!==null}),u=l.data?.record,d=l.data?.renditions.find(e=>e.ext===`md`)?.url??null,f=Kf({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:()=>Ob.renderReportRenditions(r,o),onSuccess:()=>{m(!1),v()}}),b=qf({mutationFn:()=>Ob.publishEditedMarkdown(r,o,h),onSuccess:e=>{_(null),m(!1),c(e.version),v()}});return t.isLoading?(0,P.jsx)(cx,{title:`Reports`,detail:`Loading runs…`}):n.length===0?(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(cx,{title:`Reports`,detail:`Versioned audit reports generated when a run reaches a terminal state.`}),(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{children:`No runs yet. Launch an assessment and its report will appear here on completion.`})})]}):(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(cx,{title:`Reports`,detail:`Versioned audit reports — the structured record is read-only; edits create new auditable versions.`}),(0,P.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[minmax(240px,320px)_minmax(0,1fr)]`,children:[(0,P.jsx)(`div`,{className:`grid gap-4`,children:(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{children:`Run`}),(0,P.jsx)(`select`,{value:r??``,onChange:e=>{i(e.target.value),c(null)},children:n.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title,` — `,ux(e.status)]},e.id))}),(0,P.jsx)(`h3`,{style:{marginTop:`1rem`},children:`Versions`}),a.length===0?(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`No report versions yet for this run.`}):(0,P.jsx)(`ul`,{className:`grid gap-1.5`,children:a.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(s,{variant:e.version===o?`secondary`:`outline`,size:`sm`,className:`h-auto w-full justify-start py-1.5 text-left font-normal aria-pressed:border-primary`,"aria-pressed":e.version===o,onClick:()=>{c(e.version),m(!1)},children:[`v`,e.version,` · `,e.publicationState,` · `,e.posture,` · `,e.contentHash.slice(0,8)]})},e.version))})]})}),(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)(ax,{variant:ix(ox[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.jsx)(`h2`,{children:u.target}),(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)(ax,{variant:ix(sx[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)(ie,{}),` `,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)(oe,{}):(0,P.jsx)(ge,{}),` `,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)(be,{}),` 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)(xe,{}),` 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)(`pre`,{className:`report-markdown`,children:f.data})]}):null]})]})]})}function ux(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var dx=null;function fx(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=dx;dx=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{dx=n}}function px(){if(!dx)throw Error(`No resource fiber available`);return dx}function mx(){return dx}var hx=typeof process<`u`&&!1,gx=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),_x=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},vx=(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(hx)throw Error(`tap: committed history is shorter than the replay base.`);break}Sx(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;xx(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++)yx(e.changelog[t]);_x(e)}}},yx=e=>{Sx(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},bx=(e,t)=>{e.wipCommitCallbacks.push(t)},xx=(e,t)=>{e.rollbackCallbacks.push(t)},Sx=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),xx(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}))},Cx=Symbol.for(`react.memo_cache_sentinel`),wx=e=>Array(e).fill(Cx),Tx=(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,xx(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=wx(t),r[i]=a):hx&&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},Ex=e=>Tx(px(),e),Dx=N.default.__COMPILER_RUNTIME?.c??(e=>(0,N.useMemo)(()=>{let t=wx(e);return t[Cx]=!0,t},[])),Ox=()=>mx()!==null,G=e=>Ox()?Ex(e):Dx(e),kx=(e,...t)=>Object.assign(Object.create(null),e,...t),Ax=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},jx=()=>{throw Error(`Hook order changed between renders`)},Mx=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function Nx(e,t){let n=px(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?Mx():i.type===`effect`?i:jx();if(i===void 0&&(n.isFirstRender||Ax(),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`);bx(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var Px=(e,t)=>{hx&&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.
61
+
62
+ 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},Fx=(e,t)=>{bx(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},Ix=(e,t)=>{let n=px(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||Ax();let a=e();return hx&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&jx();let a=i;if(Px(a.wipDeps,t))return a.isDirty&&Fx(n,a),a.wip;let o=e();return hx&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,xx(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),Fx(n,a),o};function Lx(e){return Ix(()=>({current:e}),[])}var Rx=Symbol(`tap.Context.defaultValue`),zx=e=>e,Bx=new Map,Vx=new Set,Hx=()=>new Map(Bx),Ux=(e,t)=>{let n=Bx;Bx=e;try{return t()}finally{Bx=n}},Wx=(e,t)=>{e[Rx]=t},Gx=e=>typeof e==`object`&&!!e&&Rx in e,Kx=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),qx=e=>Gx(e)||Kx(e),Jx=e=>{if(!Gx(e)){if(Kx(e)){Wx(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},Yx=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);Jx(e);let r=e,i=px(),a=Lx(void 0),o=a.current===void 0||!Object.is(a.current.value,t);Nx(()=>{a.current={value:t}},[t]);let s=Bx.get(r),c=s!==void 0||Bx.has(r);Bx.set(r,{value:t,source:i});try{return Xx(r,o,n)}finally{c?Bx.set(r,s):Bx.delete(r)}},Xx=(e,t,n)=>{let r=Vx.has(e);t?Vx.add(e):Vx.delete(e);try{return n()}finally{r?Vx.add(e):Vx.delete(e)}},Zx=e=>{Jx(e);let t=e,n=Qx(t,e),r=px();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},Qx=(e,t)=>Bx.get(e)??{value:zx(t)[Rx],source:null},$x=(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},eS=(e,t=e.wipContextDeps)=>{let n=mx();n&&t&&(n.wipContextDeps=$x(n,e,n.wipContextDeps,t))},tS=()=>Vx.size>0,nS=e=>{if(!e.contextDeps||!tS())return!1;for(let t of Vx.keys())if(e.contextDeps.has(t))return!0;return!1},rS=(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,yx(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},iS=(e,t,n,r,i)=>{let a=r?r(n):n;hx&&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=mx();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 rS(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 aS(e,t,n,r){let i=px(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:jx();i.isFirstRender||Ax();let s=iS(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,hx&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):hx&&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)||(Sx(i,s),s.workInProgress=t)}return s.isDirty&&bx(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function oS(e,t,n){return aS(e,t,n,!1)}var sS=(e,t)=>typeof t==`function`?t(e):t,cS=e=>e===void 0?void 0:typeof e==`function`?e():e;function lS(e){return aS(sS,e,cS,!0)}var uS=(e,t)=>Ix(()=>e,t);function dS(e){let t=px(),n=Lx(e);return n.current!==e&&bx(t,()=>{n.current=e}),uS(((...e)=>{if(hx&&mx())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var fS=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,pS=()=>{},mS=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(pS,pS):(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}},hS=e=>fS(e)?mS(e):Zx(e),gS=!1,_S=(e,t,n=t)=>{let r=px().isNeverMounted,i=r?n():t();hx&&!gS&&(!r||n===t)&&(Object.is(i,t())||(gS=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=oS(e=>e+1,0),o=Lx(0),s=dS(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return Nx(()=>e(()=>{s()&&a()}),[e]),Nx(()=>{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},vS=(e,t)=>{},yS=0,bS=()=>{let e=Lx(null);return e.current??=`:tap${yS++}:`,e.current},xS=(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?Nx(r):Nx(r,[...n,e])},SS=N.default;function CS(e){let t=(0,N.useRef)(e);return(0,N.useInsertionEffect)(()=>{t.current=e}),(0,N.useCallback)(((...e)=>t.current(...e)),[])}var wS=SS.useEffectEvent??CS,TS=()=>mx()!==null,ES=N.default,DS=e=>TS()?lS(e):ES.useState(e),OS=(e,t,n)=>TS()?oS(e,t,n):ES.useReducer(e,t,n),K=e=>TS()?Lx(e):ES.useRef(e),kS=(e,t)=>TS()?Ix(e,t):ES.useMemo(e,t),AS=(e,t)=>TS()?uS(e,t):ES.useCallback(e,t),q=(e,t)=>TS()?Nx(e,t):ES.useEffect(e,t),jS=(e,t)=>TS()?Nx(e,t):ES.useLayoutEffect(e,t),MS=e=>TS()?dS(e):wS(e),NS=(e,t,n)=>TS()?_S(e,t,n):ES.useSyncExternalStore(e,t,n),PS=(e,t)=>TS()?void 0:ES.useDebugValue(e,t),FS=(e,t)=>TS()?Nx(e,t):ES.useInsertionEffect(e,t),IS=()=>TS()?bS():ES.useId(),LS=(e,t,n)=>TS()?xS(e,t,n):ES.useImperativeHandle(e,t,n),J=e=>ES.forwardRef(e),RS=(e,t)=>ES.memo(e,t),zS=ES.Fragment,BS=(...e)=>ES.createElement(...e),VS=(...e)=>ES.cloneElement(...e),HS=e=>ES.isValidElement(e);ES.Children,ES.Suspense;var US=e=>{let t=ES.createContext(e);return Wx(t,e),t},WS=e=>TS()&&qx(e)?hS(e):ES.use(e),GS=e=>TS()&&qx(e)?hS(e):ES.useContext(e);function KS(e){return(...t)=>({hook:e,args:t})}function qS(e,t,n){return typeof t==`function`?(...n)=>qS(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var JS=(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)}},YS=50,XS={schedulers:new Set,isScheduled:!1},ZS=null,QS=[],$S=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(ZS&&(ZS.get(this)??0)>=YS)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,XS.schedulers.add(this),nC()}runTask(){ZS?.set(this,(ZS.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},eC=[];new $S(()=>{let e=eC.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}JS(t,`Errors occurred while running scheduled tasks`)});var tC=e=>{if(ZS!==null){QS.push(e);return}e()},nC=()=>{XS.isScheduled||(XS.isScheduled=!0,iC())},rC=()=>{let e=ZS;ZS=new Map;let t=[];try{for(let e of XS.schedulers)if(XS.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(ZS=e,XS.schedulers.clear(),XS.isScheduled=!1,ZS===null)for(;QS.length>0;)try{QS.shift()()}catch(e){t.push(e)}}JS(t,`Errors occurred during flushSync`)},iC=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),rC()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(rC,0)})(),aC=e=>{if(ZS!==null)return hx&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=XS;XS={schedulers:new Set,isScheduled:!0};try{let t=e();return rC(),t}finally{let e=XS.schedulers;if(XS=t,e.size>0){for(let t of e)XS.schedulers.add(t);nC()}}};function oC(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}JS(t,`Errors during commit`)}function sC(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 cC=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!Px(e.deps,e.setupDeps);function lC(e){let t=[],n=[];for(let t of e.effectCells)cC(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{sC(e)}catch(e){t.push(e)}JS(t,`Errors during commit`)}function uC(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}JS(t,`Errors during cleanup`)}var dC={useState:lS,useReducer:oS,useRef:Lx,useMemo:Ix,useCallback:uS,useEffect:Nx,useLayoutEffect:Nx,useInsertionEffect:Nx,useEffectEvent:dS,useContext:Zx,use:hS,useSyncExternalStore:_S,useDebugValue:vS,useId:bS,useImperativeHandle:xS,useMemoCache:Ex},fC=N.default,pC=fC.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??fC.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,mC=pC==null?null:`H`in pC?{get current(){return pC.H},set current(e){pC.H=e}}:`ReactCurrentDispatcher`in pC?{get current(){return pC.ReactCurrentDispatcher.current},set current(e){pC.ReactCurrentDispatcher.current=e}}:null;function hC(e){if(!mC)return e();let t=mC.current;mC.current=dC;try{return e()}finally{mC.current=t}}function gC(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 _C(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function vC(e){e.isMounted&&(e.isMounted=!1,uC(e))}function yC(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,fx(e,()=>{r=hC(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw _C(e),t}return eS(e),r}function bC(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=hx&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,_x(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),oC(t)),n&&(lC(e),uC(e)),lC(e)}var xC=()=>{let e=px();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},SC=()=>`child`,CC=()=>null,wC=()=>{if(!hx)return CC;let e=K(0);return DS(()=>e.current++),e.current===2?SC:CC},TC=()=>mx()?xC:wC(),EC=e=>e(),DC=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}JS(t,`Errors occurred while notifying Tap root subscribers`)},OC=(e,t,n)=>{let r=new $S(()=>s.handleUpdate()),i=[],a=gx((e,t)=>{(i.length!==0||e())&&(i.push(t),r.markDirty())}),o=gC(EC,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:()=>{vx(a,a.committedVersion);for(let e of i)hx&&o.devStrictMode&&e(),e();return vx(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,tC(()=>DC(s.subscribers)))},finishFlush:(e,t,n)=>{_x(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&bC(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{hx&&o.devStrictMode&&Ux(s.context,()=>yC(o,[s.committedRender])),t=Ux(s.context,()=>yC(o,[s.committedRender]))}catch(e){if(vx(a,a.committedVersion),fS(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},kC=e=>{let[,t]=DS(0),n=TC(),r=K(null),i=r.current??=OC(e,n(),t),a=Hx(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=Ux(a,()=>yC(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),q(()=>(i.isMounted=!0,()=>{i.isMounted=!1,vC(i.fiber)}),[i]),q(()=>{if(c.processed){i.fiber.isMounted||(bC(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}bC(i.fiber),i.publish(c.value,c.version)}),kS(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},AC=()=>{let e=K(0),t=e.current,n=px();return{version:t,markDirty:kS(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},jC=()=>{let[e]=DS(()=>gx((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=OS((t,n)=>(vx(e,t),t+ +!!n()),0),[,r]=DS(0);return vx(e,t),{root:e,version:t,markDirty:void 0}},MC=()=>{let e=TC(),{root:t,version:n,markDirty:r}=mx()?AC():jC();return{version:n,createFiber:AS((n,i,a)=>gC(n,t,a?()=>{a(),r?.()}:r,e()),[])}},NC=(e,t,n)=>{let r=K(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,q(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&Px(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function PC(e){let{version:t,createFiber:n}=MC(),r=kS(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=NC(()=>({value:yC(r,e.args)}),[r,t,e.args],nS(r));return q(()=>()=>vC(r),[r]),q(()=>{bC(r)},[r,i]),i.value}var FC=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},IC=(e,t)=>!e.isDirty&&!nS(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&Px(e.committedDeps,t),LC=e=>{if(!tS())return!1;for(let{fiber:t}of e.values())if(nS(t))return!0;return!1};function RC(e){let[t]=DS(()=>new Map),{version:n,createFiber:r}=MC(),i=LC(t),a=NC(()=>{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,()=>FC(t,c));l={fiber:e,next:{value:yC(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,()=>FC(t,c)),n=yC(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(IC(l,s.deps))typeof l.next==`object`&&_C(l.fiber),l.fiber.contextDeps&&eS(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=yC(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 q(()=>()=>{for(let e of t.keys())vC(t.get(e).fiber)},[t]),q(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(vC(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&bC(n.fiber):(r.remount&&(vC(n.fiber),n.fiber=r.remount),bC(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var zC=e=>e(),BC=e=>{let{createFiber:t}=MC(),n=kS(()=>t(zC,void 0),[t]),r=yC(n,[e]);q(()=>()=>{vC(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,bC(n))};return q(a),{value:r,effects:a}},VC=KS(()=>{let e=G(4),[t,n]=DS(HC),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{let r=kx(n.renderers);return r[e]=[...r[e]??[],t],{...n,renderers:r}}),()=>{n(n=>{let r=kx(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 HC(){return{renderers:kx(),fallbacks:[]}}var UC=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},WC=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n=kx();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]=UC(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=UC({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||=kx(),e.tools[i]=UC(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},{})},GC=(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)}},KC=e=>e,qC=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),JC=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!qC.has(e))return!1}},YC=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}},XC=Symbol(`assistant-ui.store.clientId`),ZC=Symbol(`assistant-ui.store.instanceTag`),QC=(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===XC?nw(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===XC||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},$C=(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===XC)return n();let i=JC(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},ew=e=>e?.source!=null,tw=e=>e?.source===null,nw=e=>e[XC]??e,rw=e=>e[ZC]??nw(e),iw=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,aw=e=>{let t=[];for(let n in e)iw(n)||t.push(n);return t},ow=class extends YC{#e;constructor(e){super(),this.#e=e}get(e,t){let n=JC(t,`OptionalAssistantClient`);if(n!==!1)return n;if(iw(t))return;let r=this.#e[t];return ew(r)?r:void 0}ownKeys(){return aw(this.#e)}has(e,t){return!iw(t)&&t in this.#e}},sw=e=>new Proxy({},new ow(e)),cw=()=>()=>{},lw=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,uw=class extends YC{#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 cw;if(t===`optional`)return this.#r??=sw(this.#n());let n=JC(t,this.#e);return n===!1?$C(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`}},dw=((e,t)=>{let n=new Proxy({},new uw(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>lw),fw=()=>new Proxy({},{get(e,t){let n=JC(t,`AssistantClient`);return n===!1?$C(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),pw=US(dw),mw=()=>{},hw=new WeakMap,gw=e=>hw.get(e)??mw,_w=(e,t)=>{hw.set(e,t)},vw=()=>GS(pw),yw=(e,t)=>Yx(pw,e,t),bw=Symbol(`assistant-ui.transform-scopes`);function xw(e,t){let n=e;if(n[bw])throw Error(`transformScopes is already attached to this resource`);n[bw]=t}function Sw(e){return e[bw]}var Cw=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},ww=e=>{console.error(`NotificationManager: event listener error`,e)},Tw=(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(ww)}catch(e){ww(e)}},Ew=()=>{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)Tw(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)Tw(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)}}}},Dw=()=>DS(Ew)[0],Ow=Symbol(`assistant-ui.store.clientIndex`),kw=e=>e[Ow],Aw=US([]),jw=()=>WS(Aw),Mw=(e,t)=>{let n=G(3),r=jw(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],Yx(Aw,i,t)},Nw=US(null),Pw=Symbol(`aui.scope-effect-unapplied`),Fw=(e,t)=>Yx(Nw,e,t),Iw=()=>{let e=WS(Nw);if(!e)throw Error(`AssistantTapContext is not available`);return e},Lw=()=>Iw().clientRef,Rw=(e,t,n)=>{let r=G(8),{clientRef:i}=Iw(),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&&ew(t)?rw(t):void 0},a=Pw,o,s=e=>{if(o?.(),o=void 0,a=Pw,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],q(a,o)},zw=()=>{let e=G(3),{emit:t}=Iw(),n=jw(),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],MS(r)},Bw=US(void 0),Vw=(e,t)=>{let n=WS(Bw);return Yx(Bw,e??n,t)},Hw=()=>{let e=G(3),[t]=DS(Uw),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),FS(n,r),t.signal};function Uw(){return new AbortController}var Ww=Symbol(`assistant-ui.store.getValue`),Gw=e=>{let t=e[Ww];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?.()},Kw=new Map;function qw(e){let t=Kw.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[Ww];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)},Kw.set(e,t)),t}var Jw=class extends YC{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===Ww)return this.outputRef.current;if(t===Ow)return this.index;if(t===ZC)return this.tagRef.current;let r=JC(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=qw(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===Ww||t===Ow||t===ZC||t in this.outputRef.current}},Yw=e=>{let t=K(null),n=K(null),r=kS(()=>({}),[e.hook,e.key]),i=jw().length,a=kS(()=>new Proxy({},new Jw(t,n,i)),[i]),o=Mw(a,function(){return PC(e)});return t.current||(t.current=o,n.current=r),q(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},Xw=KS(Yw),Zw=(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]))},Qw=e=>{let t=kS(()=>({}),[]);return t.v!==void 0&&Zw(t.v,e)?t.v:(t.v=e,e)},$w=e=>{let t=G(2),n=K(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&Zw(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},eT=(()=>{try{return!1}catch{return!1}})(),tT=(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=Sw(e.hook);if(a){a(n,t),i=!0;break}}}return n},nT=e=>e.hook===TT,rT=e=>{if(!nT(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},iT=Symbol.for(`aui.event-receiver-ref`),aT=(e,t)=>{let n=e===dw?fw():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=sw(r),enumerable:!1}),r},oT=({notifications:e,clientRef:t})=>kS(()=>({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}=Cw(n),o=n[iT];if(i!==`*`&&!o&&tw(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(!ew(a))return;let s=nw(a);if(s===n[kw(s)])return r(e)});if(i!==`*`){if(o){if(t.parent===dw)return s}else if(tw(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),sT=e=>{let t=G(5),n;t[0]===e?n=t[1]:(n=rT(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=Qw(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],Qw(o)},cT=(e,t)=>{let n=G(3),r;return n[0]!==t||n[1]!==e?(r=t?e:Xw(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],PC(r)},lT=KS((e,t)=>{let n=vw(),r=nT(t),i=cT(t,r),a=r?i:i.methods,o=sT(t),s=kS(()=>QC({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),uT=e=>{let t=G(2),n;return t[0]===e?n=t[1]:(n=e.map(bT),t[0]=e,t[1]=n),RC(n)},dT=(e,t)=>{let n=Qw(t),r=kS(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},fT=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=aT(e,oT({notifications:r,clientRef:n}));return{client:dT(i,[e,...Fw({clientRef:n,emit:r.emit},function(){return yw(i,function(){return uT(t)})})])}},pT=({parent:e,entries:t,destroySignal:n})=>{let r=K({parent:e,current:null}).current,{value:i,effects:a}=BC(function(){let i=Dw(),{client:a}=Vw(n,function(){return fT({parent:e,entries:t,clientRef:r,notifications:i})});return q(()=>e.subscribe(i.notifySubscribers),[e,i]),q(()=>i.notifySubscribers()),a});return FS(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},mT=({parent:e,entries:t,destroySignal:n})=>{let r=K({parent:e,current:null}).current,{value:i,effects:a}=BC(function(){let i=Dw(),a=kC(function(){return Vw(n,function(){return fT({parent:e,entries:t,clientRef:r,notifications:i})})}),o=NS(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return q(()=>{let t=()=>aC(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return FS(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},hT=(e,t,n,r)=>{let{get:i}=r.args[0],a=NS(e.subscribe,()=>i(e),()=>i(e)),o=sT(r),s=kS(()=>QC({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},gT=(e,t)=>{if(eT){let[e]=DS(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!nT(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=K({parent:e,current:null}).current,r=aT(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}=Cw(t);if(i===`*`)return e.on(t,r);let o=t[iT];if(!o&&tw(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[iT]:o??n},r)}}),i=dT(r,[e,...t.map(([t,n])=>hT(e,r,t,n))]);return FS(()=>{n.parent=e,n.current=i},[i,e,n]),i},_T=(e,t)=>{let n=G(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(tT(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(xT),n[3]=i,n[4]=a);let[o]=DS(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},vT=(e,t,n,r)=>{let{entries:i,rooted:a}=_T(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:gT(e,i)}},yT=(e,t,n)=>vT(e,t,pT,n);function Y(e){let t=vw();if(e){let{client:n,effects:r}=vT(t,e,mT,Hw());return r&&_w(n,r),n}return t}function bT(e){let[t,n]=e;return qS(t,lT(t,n))}function xT(e){let[,t]=e;return!nT(t)}var ST=e=>{let t;class n extends YC{get(t,n){let r=JC(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!iw(i)&&ew(e[i]))return Gw(e[i]())}ownKeys(){return aw(e)}has(t,n){return!iw(n)&&n in e}}class r extends YC{get(r,i){let a=JC(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!iw(o))return Gw(e[o]())}ownKeys(){return[...aw(e),`optional`]}has(t,n){return n===`optional`||!iw(n)&&n in e}}return new Proxy({},new r)},CT=new WeakMap,wT=e=>{let t=CT.get(e);return t||(t=ST(e),CT.set(e,t)),t},X=e=>{let t=G(6),n=Y(),r;t[0]===n?r=t[1]:(r=wT(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=NS(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 PS(s),s},TT=e=>{let t=G(3),{get:n}=e,r=Y(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],X(i)},ET=KS(TT),DT=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function OT(e){let t=G(12),n;t[0]===e?n=t[1]:(n=e.map(jT),t[0]=e,t[1]=n);let r=RC(n),i;t[2]===e?i=t[3]:(i=e.reduce(AT,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(kT),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 kT(e){return e.state}function AT(e,t,n){return e[DT(t)]=n,e}function jT(e){return qS(DT(e),Xw(e),e.deps)}var MT=(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,NT=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,PT=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,FT=Symbol(`skip-update`),IT=(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)}},LT=e=>{IT(e)},RT=(e,t)=>e===void 0||t===void 0?e===t:Zw(e,t),zT=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(){IT(this._subscribers)}},BT=class extends zT{_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())}},VT=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){GC(this._subscriptions,e,t);return}IT(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()}}},HT=class extends VT{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===FT)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===FT||RT(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},UT=class extends VT{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!==FT&&(this._previousState===void 0||!RT(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}},WT=class extends VT{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()=>LT([()=>r?.(),()=>n?.()])}},GT=class extends VT{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()=>LT([()=>i?.(),()=>r?.()])}},KT=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return WC(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(){IT(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},qT=[],JT={modelName:void 0,toolNames:qT},YT=(e,t)=>e===t||Zw(e,t),XT=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():qT,a=i.length?i:qT;return r===t.modelName&&YT(a,t.toolNames)?t:{modelName:r,toolNames:a}},ZT=KS(()=>{let e=G(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new KT,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>XT(n,JT),e[1]=r):r=e[1];let[i,a]=DS(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>XT(n,e)),n.subscribe(()=>{a(e=>XT(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),q(o,s);let c;e[4]===i?c=e[5]:(c=()=>XT(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}),QT=(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},$T=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,eE=e=>function(t){return QT(e,t)},tE=e=>{let t=G(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[qS(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=RC(i)[0],[o,s]=DS(rE),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=Lw(),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=kx(t);return n[e]=[...n[e]??[],r],n}),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[],i=kx(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?eE(i):void 0);a&&e.push(f(t,a,{standalone:$T(r),renderText:i}))}return()=>{e.forEach(iE)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),q(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(aE,kx());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),Rw(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},nE=KS(tE);xw(tE,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=ZT())});function rE(){return kx()}function iE(e){return e()}function aE(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 oE=e=>NS(e.subscribe,e.getState,e.getServerSnapshot),sE=Symbol.for(`assistant-ui.silent-runtime-action`),cE=e=>typeof e==`object`&&!!e&&sE in e,lE=(e,t)=>{let n=t();return n.catch(t=>{cE(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},uE=KS(e=>{let t=G(9),{runtime:n}=e,r=oE(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=()=>lE(`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}),dE=KS(e=>{let t=G(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=uE({runtime:a}),t[3]=a,t[4]=o),PC(o)}),fE=KS(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),pE=KS(e=>{let t=G(63),{threadIdRef:n,messageIdRef:r,runtime:i,isSuggestion:a}=e,o=oE(i),s=zw(),c=K(!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]),q(l,u);let d;if(t[6]!==i||t[7]!==o.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>qS(e.id,dE({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=OT(d),p=o.queue,m;if(t[11]!==p||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>qS(e.id,fE({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=OT(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??mE,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 mE(){throw Error(`beginEdit is not supported in this runtime`)}var hE=e=>({get current(){return e()}}),gE=KS(e=>{let t=G(13),{runtime:n}=e,r=oE(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}),_E=KS(e=>{let t=G(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=uE({runtime:a}),t[3]=a,t[4]=o),PC(o)}),vE=KS(e=>{let t=G(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=gE({runtime:a}),t[3]=a,t[4]=o),PC(o)}),yE=KS(e=>{let t=G(74),{runtime:n,threadIdRef:r,threadId:i}=e,a=oE(n),o=zw(),[s,c]=DS(!1),[l,u]=DS(!1),d;t[0]===n?d=t[1]:(d=hE(()=>n.getState().id),t[0]=n,t[1]=d);let f=d,p=K(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]),q(g,_);let v;t[12]!==f||t[13]!==n.composer||t[14]!==r?(v=pE({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=Yw(v),b;if(t[16]!==n||t[17]!==a.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>qS(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,vE({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=OT(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)=>qS(e.id,_E({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=OT(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 ee;t[38]===n?ee=t[39]:(ee=()=>n.delete(),t[38]=n,t[39]=ee);let A,j;t[40]!==h||t[41]!==n?(A=e=>(h(`message.reload`),n.reload(e)),j=()=>(h(`message.speak`),n.speak()),t[40]=h,t[41]=n,t[42]=A,t[43]=j):(A=t[42],j=t[43]);let te,ne;t[44]===n?(te=t[45],ne=t[46]):(te=()=>n.stopSpeaking(),ne=e=>n.submitFeedback(e),t[44]=n,t[45]=te,t[46]=ne);let re;t[47]!==h||t[48]!==n?(re=e=>(h(`message.branchSwitched`),n.switchToBranch(e)),t[47]=h,t[48]=n,t[49]=re):re=t[49];let M;t[50]===n?M=t[51]:(M=()=>n.unstable_getCopyText(),t[50]=n,t[51]=M);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]!==ee||t[63]!==A||t[64]!==j||t[65]!==te||t[66]!==ne||t[67]!==re||t[68]!==M||t[69]!==ie||t[70]!==ae||t[71]!==oe||t[72]!==se?(ce={getState:O,composer:k,delete:ee,reload:A,speak:j,stopSpeaking:te,submitFeedback:ne,switchToBranch:re,getCopyText:M,part:ie,attachment:ae,setIsCopied:oe,setIsHovering:u,__internal_getRuntime:se},t[60]=O,t[61]=k,t[62]=ee,t[63]=A,t[64]=j,t[65]=te,t[66]=ne,t[67]=re,t[68]=M,t[69]=ie,t[70]=ae,t[71]=oe,t[72]=se,t[73]=ce):ce=t[73],ce}),bE=e=>{let t=kS(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n?.suggestions[r.length];r.push(t&&Zw(t,e)?t:e)});let i=n&&Zw(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},xE=KS(e=>({getState:()=>e})),SE=e=>{let t=G(9),n=bE(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(wE),t[0]=n.suggestions,t[1]=r);let i=OT(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},CE=KS(e=>{let t=G(4),n;t[0]===e?n=t[1]:(n=e.map(TE),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),SE(r)});function wE(e,t){return qS(t,xE(e),[e])}function TE(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var EE=Object.freeze({type:`complete`}),DE=Object.freeze({type:`running`}),OE=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`})}),kE=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return DE;if(n===`complete`)return EE;if(n!==`incomplete`)return;let{reason:r}=t;return OE[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},AE=(e,t,n)=>{if(e.role!==`assistant`)return EE;if(n.type===`tool-call`)return n.result===void 0?e.status:EE;if(e.status.type===`running`){let e=kE(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?EE:r?e.status:EE},jE=e=>`reason`in e?e.reason:void 0,ME=e=>`error`in e?e.error:void 0,NE=32,PE=new WeakMap,FE=e=>PE.get(e)??e.id,IE=(e,t,n)=>`status`in e&&e.status?AE(e,t,n):EE,LE=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>NE))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=IE(u,e,d),m=jE(p),h=ME(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,PE.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}},RE=KS(({task:e})=>({getState:()=>e})),zE=KS(e=>{let t=G(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=yE({runtime:s,threadIdRef:i,threadId:a}),t[3]=s,t[4]=a,t[5]=i,t[6]=c):c=t[6],PC(c)}),BE=KS(e=>{let t=G(93),{runtime:n}=e,r=oE(n),i=zw(),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]),q(a,o);let s;t[4]===n?s=t[5]:(s=hE(()=>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=pE({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=Yw(p),h;t[15]===r.suggestions?h=t[16]:(h=CE(r.suggestions),t[15]=r.suggestions,t[16]=h);let g=Yw(h),_;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=LE(),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(VE),t[20]=b,t[21]=x);let S=OT(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=>qS(e.id,zE({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=OT(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 ee;t[49]===g?ee=t[50]:(ee=()=>g.methods,t[49]=g,t[50]=ee);let A;t[51]!==S||t[52]!==b?(A=e=>{if(`id`in e){let t=b.find(t=>t.id===e.id);return S.get({key:t?FE(t):e.id})}return S.get(e)},t[51]=S,t[52]=b,t[53]=A):A=t[53];let j;t[54]!==i||t[55]!==f||t[56]!==n?(j=e=>{let t=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if((t.role??`user`)===`user`){let e=t.content.map(HE).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]=j):j=t[57];let te;t[58]!==u||t[59]!==n||t[60]!==r.isRunning?(te=()=>{r.isRunning&&u(`thread.cancelRun`),n.cancelRun()},t[58]=u,t[59]=n,t[60]=r.isRunning,t[61]=te):te=t[61];let ne;t[62]!==u||t[63]!==n?(ne=()=>{n.connectVoice(),u(`thread.voiceStarted`)},t[62]=u,t[63]=n,t[64]=ne):ne=t[64];let re;t[65]===w?re=t[66]:(re=e=>`id`in e?w.get({key:e.id}):w.get(e),t[65]=w,t[66]=re);let M;t[67]===n?M=t[68]:(M=()=>n,t[67]=n,t[68]=M);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]!==ee||t[86]!==A||t[87]!==j||t[88]!==te||t[89]!==ne||t[90]!==re||t[91]!==M?(ie={getState:O,composer:k,suggestions:ee,task:A,append:j,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:te,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:ne,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:re,__internal_getRuntime:M},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]=ee,t[86]=A,t[87]=j,t[88]=te,t[89]=ne,t[90]=re,t[91]=M,t[92]=ie):ie=t[92],ie});function VE(e){return qS(FE(e),RE({task:e}),[e])}function HE(e){return e.type===`text`?e.text:``}var UE=(e,t)=>lE(`thread list ${e}`,t),WE=KS(e=>{let t=G(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=oE(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=zw(),{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=K(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]),q(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=>UE(`switch`,()=>n.switchTo(e)),x=e=>UE(`rename`,()=>n.rename(e)),S=e=>UE(`update custom metadata`,()=>n.updateCustom(e)),g=()=>UE(`archive`,()=>n.archive()),_=()=>UE(`unarchive`,()=>n.unarchive()),v=()=>UE(`delete`,()=>n.delete()),y=e=>UE(`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}),GE=e=>{let t=G(4),n=zw(),r=K(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]),q(i,a)},KE=KS(e=>{let t=G(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=WE({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],PC(s)}),qE=KS(e=>{let t=G(48),{runtime:n,__internal_assistantRuntime:r}=e,i=oE(n);GE(i.mainThreadId);let a=zw(),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]),q(o,s);let c;t[4]===n.main?c=t[5]:(c=BE({runtime:n.main}),t[4]=n.main,t[5]=c);let l=Yw(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>qS(e,KE({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=OT(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)=>UE(`switch`,()=>n.switchToThread(e,t)),y=()=>UE(`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}),JE=(e,t)=>{e.thread??=ET({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=ET({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=ET({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=ZT()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=ET({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},YE=e=>{let t=G(7),n=Lw(),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),Rw(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=qE({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),PC(a)},XE=KS(YE);xw(YE,(e,t)=>{JE(e,t),!e.tools&&t.tools.source===null&&(e.tools=nE({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=VC())});var ZE=e=>{let{children:t,condition:n}=e;return X(n)?t:null};ZE.displayName=`AuiIf`;var QE=KC({}),$E=({effects:e})=>{"use no memo";return jS(e),null},eD=J(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=vw();if(eT){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!==dw)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??dw:a?e.value??dw:o,c=Hw(),{client:l,effects:u}=yT(s,n??QE,c);return LS(t,()=>l,[l]),(0,P.jsx)(Bw.Provider,{value:c,children:(0,P.jsxs)(pw.Provider,{value:l,children:[(0,P.jsx)($E,{effects:gw(s)}),u&&(0,P.jsx)($E,{effects:u}),r]})})}),tD=e=>{let t=Y(),n=K(!1),r=n.current?null:e(t);return X(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},nD=Object.freeze({});function rD(e){let t=G(3),{getItemState:n,children:r}=e,i=tD(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],iD(a)}var iD=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return kS(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?nD:t?.props])??e},aD=(e,t)=>{let n=G(11),r=Y(),i=MS(t),a;n[0]===e?a=n[1]:(a=Cw(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],q(c,l)},oD=e=>e._core?.RenderComponent,sD=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=oD(e),a=KC({...n,threads:XE(e)});return(0,P.jsxs)(eD,{extends:t,config:a,children:[i&&(0,P.jsx)(i,{}),r]})},cD=RS(e=>{let t=G(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)(sD,{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 lD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function uD(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=>uD(e,t+1)):lD(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&uD(n,t+1)):!1}var dD=100,fD=(e,t,n)=>{if(e===t)return!0;if(n>dD||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>fD(e,t[r],n+1));if(Array.isArray(t)||!lD(e)||!lD(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&fD(e[r],t[r],n+1))},pD=(e,t)=>!uD(e)||!uD(t)?!1:fD(e,t,0),mD=Symbol.for(`aui.tool-response`),hD=`<no result>`,gD=class e{get[mD](){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?hD: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&&mD in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?hD:t})}},_D=()=>{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}},vD=()=>{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=_D(),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)}}}},yD=e=>e instanceof TypeError,bD=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!yD(e))throw e;n?.(e)}},xD=e=>{try{e.close()}catch(e){if(!yD(e))throw e}},SD=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),CD=(e,t)=>{let n;return[SD({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},wD=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 bD(this._controller,t,this._warnDroppedAfterClose),this}return bD(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,bD(this._controller,{type:`part-finish`,path:[]}),xD(this._controller))}},TD=(e,t={})=>SD(e,e=>new wD(e,t)),ED=(e={})=>CD(t=>new wD(t,e)),DD=class{_isClosed=!1;_mergeTask;_controller;constructor(e,t={}){this._controller=e;let n=TD({start:e=>{this._argsTextController=e}},t),r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:r=!0,bD(this._controller,e);break;case`part-finish`:r||bD(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),bD(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;bD(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?hD: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,bD(this._controller,{type:`part-finish`,path:[]}),xD(this._controller))}},OD=(e={})=>CD(t=>new DD(t,e)),kD=class{value=-1;up(){return++this.value}},AD=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var jD=class extends TransformStream{constructor(e){let t=new kD,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]})}})}},MD=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},ND=MD(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),PD=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:vD(),contentCounter:new kD}}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 AD(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new jD(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]=ED({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=ED({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??ND(),[i,a]=OD({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 FD(e,t={}){let n=new PD(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 ID(e={}){let{resolve:t,promise:n}=_D(),r;return[FD(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var LD=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},RD=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})),zD=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)}})}},BD=/[0-9a-fA-F]/;function VD(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(!BD.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 HD=n(RD(),1),UD=Symbol(`aui.parse-partial-json-object.meta`),WD=e=>e?.[UD],GD=e=>{if(e.length===0)return{[UD]:{state:`partial`,partialPath:[]}};try{let t=HD.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[UD]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=VD(e),r=HD.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[UD]={state:`partial`,partialPath:n},r}catch{return}}},KD=(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 KD(s,{state:`partial`,partialPath:o},i)},qD=(e,t)=>{let n=WD(e);if(!n)throw Error(`unable to determine object state`);return KD(e,n,t.map(String))},JD=new Set([`__proto__`,`constructor`,`prototype`]);function YD(e){if(JD.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var XD=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(YD(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}},ZD=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}}},QD=(e,t)=>({...e,parts:t,get content(){return this.parts}}),$D=(e,t)=>QD(e,[...e.parts,t]),eO=({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:{}}}),tO=16,nO=(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:QD(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},rO=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return $D(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 $D(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 $D(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 $D(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return $D(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`),$D(e,{type:`reasoning`,text:``,status:{type:`running`}})}},iO=(e,t,n)=>nO(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)),aO=(e,t,n)=>nO(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),oO=(e,t,n)=>nO(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=GD(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}),sO=(e,t,n)=>nO(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)),cO=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=lO(t);return{...e,status:n}},lO=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},uO=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),dO=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),fO=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),pO=(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:ND(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},mO=(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}}}}},hO=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),gO=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},_O=(e,t,n=0)=>{let r=n>0?n:gO(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)},vO=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},yO=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??eO(),a,o,s=new ZD,c=new Set,l=(e,t)=>{c.has(e)||c.size>=tO||(c.add(e),console.warn(t))},u,d=t?vO(()=>{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=rO(i,e,l),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=iO(i,e,l);break;case`part-finish`:i=aO(i,e,l);break;case`text-delta`:{let t=oO(i,e,l);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=sO(i,e,l);break;case`message-finish`:o=e.usage?.outputTokens,i=cO(i,e);break;case`annotations`:i=uO(i,e);break;case`data`:i=dO(i,e);break;case`step-start`:i=fO(i,e);break;case`step-finish`:i=pO(i,e);break;case`error`:i=mO(i,e),n?.(e.error);break;case`update-state`:a??=new XD(i.metadata.unstable_state,{strict:r}),i=hO(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:_O(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=cO(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:_O(s,i,o)}},e.enqueue(i)}}})}};async function*bO(){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 xO(e){return e[Symbol.asyncIterator]??=bO,e}var SO=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new yO))}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 xO(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function CO(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 wO(e,t){let n=e;for(let e of t){if(n==null||!Object.hasOwn(n,e))return;n=n[e]}return n}var TO=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(qD(e,this.fieldPath)===`complete`){let t=wO(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=wO(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},EO=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=wO(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),qD(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}},DO=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=wO(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)}qD(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}},OO=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=wO(e,this.fieldPath);if(!Array.isArray(t))return;for(;this.nextIndex<t.length&&qD(e,[...this.fieldPath,this.nextIndex])===`complete`;this.nextIndex++)this.controller.enqueue(t[this.nextIndex]);qD(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}},kO=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=GD(this.accumulatedText);return this.parsedTextLength=this.accumulatedText.length,e===void 0?(this.args??=GD(``),!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 TO(t,n,e);this.activateHandle(r)})}streamValues(...e){let t=e,n;return xO(new ReadableStream({start:e=>{n=new EO(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return xO(new ReadableStream({start:e=>{n=new DO(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return xO(new ReadableStream({start:e=>{n=new OO(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},AO=class{promise;constructor(e){this.promise=e}get(){return this.promise}},jO=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new kO(e.readable);let{promise:t,resolve:n}=_D();this.resolve=n,this.response=new AO(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}},MO=Symbol.for(`assistant-stream.tool-execution-id`),NO=(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)}},PO=e=>e.join(`,`),FO=(e,t)=>{let n={...e};return Object.defineProperty(n,MO,{value:t,enumerable:!0}),n},IO=class extends LD{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(PO(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?FO(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new jO,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(PO(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(PO(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new gD({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(PO(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=CO(()=>{let e;try{e=HD.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,NO(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&NO(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new gD({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),bD(s,FO({type:`result`,path:e.path,...r},l))},n=>{d&&NO(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new gD({result:String(n),isError:!0});u.setResponse(r),bD(s,FO({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(PO(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(PO(e.path)))};o?o.then(()=>{c(),bD(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new zD).pipeThrough(s)})}},LO=Symbol.for(`assistant-stream.tool-execution-id`),RO=Symbol(`assistant-stream.tool-aborted`),zO=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,BO=e=>typeof e?.then==`function`,VO=async(e,t,n=!1)=>{let r,i=new Promise(e=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>e(RO))):e(RO)},t.aborted?r():t.addEventListener(`abort`,r,{once:!0})});try{return await Promise.race([e,i])}finally{t.removeEventListener(`abort`,r)}},HO=()=>new gD({result:`Tool execution was cancelled.`,isError:!0});function UO(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return HO();let a=e;if(zO(i.parameters)){let e=i.parameters[`~standard`].validate(n.args),r=BO(e)?await VO(e,t):e;if(r===RO)return HO();r.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(r.issues)}`)}))}if(t.aborted)return HO();let o=await VO((async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[LO]:n.executionId},o=await a(n.args,e),s=gD.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 gD({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===RO?HO():o})(i.execute):void 0}function WO(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[LO]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function GO(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new IO({execute:e=>UO(i(),a(),e,s),streamCall:({reader:e,...t})=>WO(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}function KO(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 qO(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var JO=e=>{if(!lD(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function YO(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=JO(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=JO(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}r=r.map(t=>{let n=JO(t);if(n===void 0||!lD(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(!lD(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 XO(e,t,n){if(!lD(e)||!lD(t))return t;let r=lD(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)&&lD(a)){let r=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0;i.push([e,YO(t,a,r)])}else i.push([e,a])}return Object.fromEntries(i)}function ZO(e,t){if(!lD(e)||!lD(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)||!pD(e[r],i))&&n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var QO=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},$O=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=lD(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},ek=e=>{let t=lD(e)?e.addedItemIds:void 0;if(!lD(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()},tk=new WeakMap;function nk(e,t,n){let r=tk.get(e);r||(r=new Map,tk.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=qO(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=KO(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:XO(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=QO(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&&$O(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=ek(r.result);s.push({state:i?XO(e.state,n,{idFactory:i}):XO(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function rk(e,t,n){let r=nk(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function ik(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=rk(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(pD(r.state,n.state))continue;let i=ZO(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 ak=US(null),ok=(e,t)=>Yx(ak,e,t),sk=()=>GS(ak),ck={},lk=e=>{let t=Qw(e??ck);return e==null?null:t},uk=Symbol(`innerMessage`),dk=Symbol(`innerMessages`),fk=[],pk=(e,t)=>{uk in e||(e[uk]=t)},mk=e=>{let t=`messages`in e?e.messages:e,n=t[dk]||t[uk];return n?Array.isArray(n)?n:(t[dk]=[n],t[dk]):fk},hk=`__external_store_fallback_`,gk=MD(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7);function _k(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var vk=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},yk=(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`?_k(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-${gk()}`,...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:GD(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=vk(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=vk(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=>vk(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}`)}},bk=e=>e.type===`tool-call`&&e.result===void 0,xk=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`},Sk=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,Ck=Symbol(`autoStatus`),wk=Object.freeze(Object.assign({type:`running`},{[Ck]:!0})),Tk=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[Ck]:!0})),Ek=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[Ck]:!0})),Dk=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[Ck]:!0})),Ok=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[Ck]:!0})),kk=e=>e[Ck]===!0,Ak=(e,t,n,r,i,a,o)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[Ck]:!0}):e&&t?wk:n?Ok:o&&!a?wk:r?Dk:a?Ek:Tk,jk=e=>Ak(!1,!1,typeof e!=`string`&&e.some(Sk),typeof e!=`string`&&e.some(bk)),Mk=(e,t,n)=>Ak(t,n,typeof e!=`string`&&e.some(Sk),typeof e!=`string`&&e.some(bk),void 0,void 0,typeof e!=`string`&&e.some(xk)),Nk=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})}},Pk=(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},Fk=e=>{let t=G(6),{index:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({attachment:ET({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Ik=e=>{let t=G(6),{index:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({attachment:ET({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Lk=e=>{let t=G(6),{runtime:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({threadListItem:WE({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Rk=e=>{let t=G(6),{index:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({message:ET({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:ET({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},zk=e=>{let t=G(6),{index:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({part:ET({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Bk=KS(e=>{let t=G(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:Hk,resumeToolCall:Uk,respondToToolApproval:Wk},t[5]=o,t[6]=s),s}),Vk=e=>{let t=G(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=Y(),s;t[0]!==a||t[1]!==n?(s=KC({part:Bk({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)(eD,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function Hk(){throw Error(`Not supported`)}function Uk(){throw Error(`Not supported`)}function Wk(){throw Error(`Not supported`)}var Gk=e=>{for(let t of e)if(t?.status.type===`running`)return DE;return e.at(-1)?.status??EE},Kk=(e,t)=>{let n={running:0,complete:0,incomplete:0,requiresAction:0},r=EE,i=!1;for(let a of t)switch(r=e[a]?.status??EE,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?DE:r,counts:n}},qk=KS(e=>{let t=G(11),{parts:n,getMessagePart:r}=e,[i,a]=DS(!0),o;t[0]===n?o=t[1]:(o=Gk(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}),Jk=e=>{let t=G(4),{startIndex:n,endIndex:r,children:i}=e,a=X(Yk).slice(n,r+1),o=Y(),s=KC({chainOfThought:qk({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)(eD,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function Yk(e){return e.message.parts}var Xk=e=>{let t=G(7),{index:n,archived:r,children:i}=e,a=Y(),o;t[0]!==r||t[1]!==n?(o=KC({threadListItem:ET({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)(eD,{extends:a,config:s,children:i}),t[3]=a,t[4]=i,t[5]=s,t[6]=c):c=t[6],c},Zk=e=>{let t=G(6),{index:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({suggestion:ET({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Qk=e=>{let t=G(6),{index:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({queueItem:ET({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},$k=Symbol.for(`assistant-ui.message-not-sent`),eA=e=>typeof e==`object`&&!!e&&$k in e,tA=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)}},nA=class extends tA{_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)}},rA=class extends nA{get source(){return`thread-composer`}},iA=class extends nA{get source(){return`edit-composer`}},aA=class extends tA{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},oA=Object.freeze([]),sA=Object.freeze({}),cA=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??oA,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??sA,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??oA,value:e?.text??``}),lA=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??oA,runConfig:e?.runConfig??sA,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??oA,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),uA=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 GT({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},dA=class extends uA{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new UT({path:e.path,getState:()=>cA(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 rA(new HT({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`}:FT},subscribe:e=>this._core.subscribe(e)}),this._core)}},fA=class extends uA{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new UT({path:e.path,getState:()=>lA(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 iA(new HT({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`}:FT},subscribe:e=>this._core.subscribe(e)}),this._core)}},pA=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
63
+
64
+ `),mA=`ui://`,hA=e=>!!e?.startsWith(mA),gA=e=>e.display===`text`||e.allowFreeform===!0,_A={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},vA=(e,t)=>{let n=t.text;if(n!==void 0&&!gA(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(_A,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=_A[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}}},yA=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=gD.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(vA(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},bA=(e,t)=>{let n=e.content[t];if(!n)return FT;let r=AE(e,t,n);return Object.freeze({...n,[uk]:n[uk],status:r})},xA=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new fA(new WT({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 pA(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new yA(new HT({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>bA(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new yA(new HT({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?FT:bA(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new aA(new HT({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`}:FT},subscribe:e=>this._core.subscribe(e)}))}},SA=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),CA=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),wA=(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},TA=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},EA=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:TA(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),DA=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new HT({path:e.path,getState:()=>EA(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>LT([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 dA(new WT({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(wA(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!eA(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(CA(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(SA(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 xA(new HT({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 FT;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[uk]:e[uk],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 GT({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},OA=(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()=>{}}}),kA=class extends zT{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()=>{}}},AA=e=>{let t=G(6),{adapters:n,children:r}=e,i=GS(ak),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)(ak.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},jA=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||GC([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}},MA=Promise.resolve(),NA=()=>{},PA=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}),FA=(e,t)=>{if(t===void 0)return FT;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}:FT},IA=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=DA){this._core=e,this._runtimeFactory=t;let n=new UT({path:{},getState:()=>PA(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new jA(new HT({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>FA(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new WT({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)??NA}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??MA}reloadMainThread(){return this._core.reloadMainThread?.()??MA}loadMore(){return this._core.loadMore?.()??MA}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new HT({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>FA(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new WT({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 jA(new HT({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>FA(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new jA(new HT({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>FA(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new jA(this._createItemStateBinding(e),this._core)}},LA=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new IA(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)}},RA=new WeakMap,zA=e=>RA.get(e)??0,BA=(e,t)=>zA(e)===t,VA=e=>{RA.set(e,zA(e)+1)},HA=class{_contextProvider=new KT;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},UA=Object.freeze([]),WA=`DEFAULT_THREAD_ID`,GA=Object.freeze([WA]),KA=Object.freeze({id:WA,remoteId:void 0,externalId:void 0,status:`regular`}),qA=Promise.resolve(),JA=Object.freeze(kx({[WA]:KA})),YA=class extends zT{_mainThreadId=WA;_threads=GA;_archivedThreads=UA;_threadData=JA;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 qA}_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??WA,i=e.threads??UA,a=e.archivedThreads??UA,o=n.threadId??WA,s=n.threads??UA,c=n.archivedThreads??UA;(t||(n.isLoading??!1)!==(e.isLoading??!1)||o!==r||s!==i||c!==a)&&((s!==i||c!==a||o!==r)&&(this._threadData=kx(JA,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)??UA),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??UA),(t||o!==r)&&(t||VA(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=kx(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.`)}},XA={fromArray:e=>{let t=e.map(e=>yk(e,gk(),jk(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:yk(e,e.id,jk(e.content))}})})},ZA=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},QA=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}},$A=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,ZA(t)===this.head?this.selectPathTo(t):i.next===null&&(i.next=t,this.head===i&&(this.head=ZA(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new QA(()=>{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=ZA(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=ZA(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)}},ej=Object.freeze([]);function*tj(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*tj(e.messages)))}function nj(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 rj(e){let t=gk();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 ij(e){let t=[];for(let n of e)n.type!==`text`&&t.push(rj(n));return t}var aj=e=>`content`in e&&!(`lastModified`in e),oj=e=>e.status.type===`complete`,sj=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()}},cj=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},lj=class extends zT{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 sj;_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=>!oj(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(oj(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){eA(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return ej}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(aj(e)){let t=this.getAttachmentAdapter();if(t&&!nj({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??gk(),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(!nj({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 cj(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),!oj(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&&!oj(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&&GC(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)}}},uj=e=>e.capabilities?.cancel?TA(e):!1,dj=class extends lj{get canCancel(){return uj(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this.runtime.voice&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??ej,t=this.runtime.getQueueItems?.()??ej,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()}},fj=class extends lj{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(pA(r)),this.setRole(r.role);let o;r.role===`user`?(o=[...r.attachments??[],...ij(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()}},pj=class extends zT{_isInitialized=!1;repository=new $A;_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 dj(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=ik(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 fj(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&&GC(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(pA(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`?IT([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{IT([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`);IT([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{IT(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,GC(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:gk(),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:gk(),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{IT([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>GC(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(XA.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>GC([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)&&GC([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},mj=Symbol.for(`assistant-stream.tool-execution-id`),hj=e=>{try{return JSON.parse(e),!0}catch{return!1}},gj=e=>{try{return JSON.parse(e)}catch{return}},_j=(e,t)=>{let n=gj(e),r=gj(t);return n===void 0||r===void 0?!1:pD(n,r)},vj=e=>e[mj],yj=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]=ID();this._controller=t;let n=GO(()=>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 zD).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=vj(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=vj(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=vj(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:hj(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)_j(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(hj(e.argsText)&&hj(t.argsText)&&_j(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 tj(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||hj(r.argsText)&&hj(n.argsText)&&_j(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 gD({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent===void 0?{}:{modelContent:n.modelContent}})),e.close()}}}},bj=Object.freeze([]),xj=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},Sj=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,Cj=class extends pj{_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 Nk;_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??bj;Zw(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};Zw(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 Nk;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=`${hk}${i}`;if(t&&(t.role!==`assistant`||!kk(t.status)||t.status===Mk(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return pk(e,n),e}return t}let s=e.convertMessage(n,i),c=yk(s,o,Mk(s.content,a,r));return pk(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(Sj(r,c)){let e=c.at(-1)?.id??null;this._optimistic?.parentId!==e&&(this._optimistic={id:gk(),parentId:e}),l=this._optimistic.id,this.repository.addOrUpdateMessage(e,yk({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||!Pk(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 yj(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;xj(`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 tj(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=zA(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!n&&this._store.queue){if(i&&await i,!BA(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}),BA(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();Pk(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){return this._store?.queue?.items??ej}getSteerQueueItems(){return this._store?.queue?.steerItems??ej}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=zA(this);this._toolInvocations?.abort({discardPending:!0}),this._store.queue?.__internal_notifyCancelled?.(),xj(`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:pA(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(BA(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.`);xj(`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 $A;t.import(XA.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(mk))}},wj=e=>e.adapters?.threadList??{},Tj=class extends HA{threads;constructor(e){super(),this.threads=new YA(wj(e),()=>new Cj(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(wj(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},Ej=e=>{let t=G(21),{modelContext:n,feedback:r}=sk()??{},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 Tj(a),t[6]=a,t[7]=o);let[s]=DS(o),c;t[8]===s.threads?c=t[9]:(c=()=>()=>{VA(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),q(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],q(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]),q(d,f);let p;return t[19]===s?p=t[20]:(p=new LA(s),t[19]=s,t[20]=p),p},Dj=e=>e.status?.type!==`running`,Oj=async(e,t)=>{let n=SO.fromAssistantStream(e);for await(let e of n){let n=e.parts.filter(e=>e.type===`text`)[0]?.text;n?.trim()&&await t(n)}},kj=(e,t)=>{let n=()=>void t.generateTitle({automatic:!0}).catch(e=>{cE(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(Dj);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},Aj=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=AS(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=K(!1);c.current||s(),q(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=K(void 0),u=K(!1),d=K(void 0),f=K(!1),p=MS(()=>{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=kj(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=MS(()=>(p(),l.current));return q(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),q(()=>{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},jj=KS(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s})=>{let c=kS(()=>new jA(new HT({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}:FT},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:l}=yT(i,{threadListItem:WE({runtime:c})});return Vw(s,function(){return yw(l,function(){return ok(a,function(){return Aj({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:c})})})})}),Mj=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],Nj=e=>{let t=G(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),jS(r,i),null},Pj=class extends zT{runtimeHook;adapterStore=new BT({defaultAdapters:null,threadAdapters:new Map});hostStore=new BT({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&&VA(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&&IT(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,TA(n));let r=[n.subscribe(()=>{this._setRunning(t,TA(n))}),...Mj.map(t=>n.unstable_on(t,()=>{GC(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,IT(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&VA(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 qS(`${t}:${a}:${n}`,jj({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:s,publish:this._publish,destroySignal:o}))})}__internal_useHost(e){let t=oE(this.hostStore),n=oE(this.adapterStore);return RC(this._threadElements(e,t,n))}__internal_RenderThreadRuntimes=({provider:e})=>(oE(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=oE(this.hostStore),n=oE(this.adapterStore),r=this._threadElements(e,t,n),{effects:i}=BC(function(){return RC(r)});return jS(i),null};_OuterActiveThreadProvider=RS(({threadId:e,provider:t})=>{let n=kS(()=>new IA(this.parent).getItemById(e),[e]),r=K(!1);return q(()=>{},[t]),(0,P.jsx)(Lk,{runtime:n,children:(0,P.jsx)(t,{children:(0,P.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=sk();return this.pendingThreadAdapters.set(e,n),jS(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,P.jsx)(Nj,{detectorRef:t})}};function Fj(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 Ij=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),Lj=class extends zT{_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=>Ij(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=Ij(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()}}},Rj=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."),zj=new class extends kA{get error(){return Rj}messages=[];composer=OA(Rj,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(Rj)}};function Bj(e){return e}var Vj=`__LOCALID_`,Hj=e=>e||void 0,Uj=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=kx(t.threadIdMap),a=kx(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??Bj(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}},Wj=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:kx(),threadData:kx()}),Gj=e=>{let t;do t=`${Vj}${gk()}`;while(e.threadIdMap[t]);let n=Bj(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:kx(e.threadIdMap,{[t]:n}),threadData:kx(e.threadData,{[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},Kj=(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]}},qj=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),Jj=(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},Yj=(e,t,n,r,i)=>{let a=Bj(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=kx(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=kx(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}},Xj=(e,t,n,r)=>{let i=Jj(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=kx(c.threadData);delete r[n],c.threadData=r;let i=kx(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},Zj=(e,t,n)=>Xj(e,t,n,void 0),Qj=(e,t,n)=>Xj(e,t,`regular`,n),$j=class extends Error{[sE]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}};function eM(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 tM(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 nM(e,t){return!t.superseded&&(e.latestExplicit?.order??0)<=t.order}function rM(e,t){return(e.latestExplicit?.order??0)<t.order}function iM(e,t,n){let r=eM(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 aM(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)),tM(e,t,i))}function oM(e,t,n){let r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,tM(e,t,n),r}function sM(e,t){e.delete(t)}function cM(e,t,n){let r=eM(e,t);if(n&&r.pendingClaim===null&&oM(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 lM({states:e,threadId:t,automatic:n,generate:r,rename:i,applyTitle:a}){let o=eM(e,t),s=cM(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&&oM(e,t,o)!==void 0,f=async()=>{if(c!==void 0)for(;;){let e=s.claim;if(e!==null&&e.order>l&&rM(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(!nM(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}}nM(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&&nM(o,s)&&await a(t);return}if(!rM(o,n))return;if(await i(n.title),c=n.title,l=n.order,s.claim===n){if(!nM(o,s))return;await a(n.title),s.superseded=!0;return}}}};try{await p(),await f()}finally{s.settlePersisted(c),o.generations.delete(s),tM(e,t,o)}}var uM=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),dM=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),fM=Wj(),pM=class extends zT{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_titleStates=new Map;_mainThreadId;_state=new Lj(fM);_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=lk(e());return n==null?t:(0,P.jsx)(AA,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?zS:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=qj(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,Hj(i.nextCursor));let a=Uj(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return Kj({...r,isLoading:!1,loadError:void 0,cursor:Hj(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=Uj(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:Hj(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 Pj(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 BT(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 $j}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new $j}_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:kx(),threadData:kx()};for(let e of r){let t=Bj(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}=Uj(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=Bj(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(Jj(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=Gj(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 Jj(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&Fj(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||zj}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw uM(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 Jj(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 $j;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=Bj(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 uM(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=Gj(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 uM(e,`initializing it`);if(t.status===`new`)throw dM(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=>Qj(t,e,r),then:(t,{remoteId:r,externalId:a})=>{if(n!==this._adapterGeneration)return t;let o=Yj(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 uM(e,`generating its title`);if(i.status===`new`)throw dM(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(Dj);await lM({states:this._titleStates,threadId:i.id,automatic:t?.automatic===!0,generate:async e=>{let t=await n.generateTitle(a,s);this._requireAdapterGeneration(r),await Oj(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=Jj(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 uM(e,`renaming it`);if(i.status===`new`)throw dM(e,i.status,`be renamed`);let a=iM(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=Jj(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}});return aM(this._titleStates,i.id,a,!0),o}catch(e){throw aM(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 uM(e,`updating its custom metadata`);if(i.status===`new`)throw dM(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=Jj(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 uM(e,`archiving it`);if(r.status!==`regular`)throw dM(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=>Zj(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw uM(e,`unarchiving it`);if(r.status!==`archived`)throw dM(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=>Zj(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw uM(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw dM(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=>Zj(e,r.id,`deleted`)});return this._hookManager.stopThreadRuntime(r.id),sM(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 uM(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw dM(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new BT([]);__internal_RenderComponent=()=>{let e=IS();q(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=oE(this.boundIdsStore),n=oE(this.providerStore),r=Y();return(t.length===0||t[0]===e)&&(0,P.jsxs)(AA,{adapters:this._runtimeAdapters,children:[(0,P.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,P.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},mM=class extends HA{threads;constructor(e){super(),this.threads=new pM(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},hM=e=>{let t=G(18),n;t[0]===e?n=t[1]:(n=()=>new mM(e),t[0]=e,t[1]=n);let[r]=DS(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),FS(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],q(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),q(c,l);let u;return t[16]===r?u=t[17]:(u=new LA(r),t[16]=r,t[17]=u),u},gM=e=>{let[t]=DS(()=>new BT(e.runtimeHook));jS(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=K(e.initialThreadId),r=AS(function(){return oE({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()},[t]),i=MS(t=>e.onThreadIdChange?.(t)),a=kS(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(Y().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 hM(a)},_M=e=>{let t=G(6),{id:n,children:r}=e,i=Y(),a;t[0]===n?a=t[1]:(a=KC({message:ET({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:ET({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)(eD,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},vM=(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,yM=()=>null,bM=new WeakMap,xM=(e,t)=>{let n=bM.get(e);return n||(n=new Set(e.map(e=>e.id)),bM.set(e,n)),n.has(t)},SM=(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??yM:e.SystemMessage??e.Message??yM;default:throw Error(`Unknown message role: ${t}`)}},CM=e=>{let t=G(6),{components:n}=e,r=X(kM),i=X(AM),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=SM(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},wM=RS(e=>{let t=G(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(CM,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Rk,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&vM(e.components,t.components));wM.displayName=`ThreadPrimitive.MessageByIndex`;var TM=RS(e=>{let t=G(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>xM(e.thread.messages,n),t[0]=n,t[1]=i),!X(i))return null;let a;t[2]===r?a=t[3]:(a=(0,P.jsx)(CM,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,P.jsx)(_M,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&vM(e.components,t.components));TM.displayName=`ThreadPrimitive.Unstable_MessageById`;var EM=({children:e})=>{let t=X($w(e=>e.thread.messages.map(e=>e.id)));return kS(()=>t.length===0?null:t.map((t,n)=>(0,P.jsx)(Rk,{index:n,children:(0,P.jsx)(rD,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},t)),[t,e])},DM=e=>{let t=G(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(EM,{children:()=>(0,P.jsx)(CM,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(EM,{children:r}),t[2]=r,t[3]=i),i};DM.displayName=`ThreadPrimitive.Messages`;var OM=RS(DM,(e,t)=>e.children||t.children?e.children===t.children:vM(e.components,t.components));function kM(e){return e.message.role}function AM(e){return e.message.composer.isEditing}var jM=e=>{let t=e.message.metadata;if(t&&typeof t==`object`)return t.custom?.quote},MM=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},NM=e=>typeof e==`object`&&!!e,PM=e=>e==null?[]:Array.isArray(e)?e:[e],FM=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!NM(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 MM(i)}return BS(c,{...a??{},key:s??r},...PM(o).map((e,i)=>FM(e,t,n,`${r}/${i}`)))},IM=e=>{let t=G(11),{spec:n,components:r,Fallback:i}=e,a=n?.root,o;t[0]===a?o=t[1]:(o=PM(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)=>FM(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};IM.displayName=`GenerativeUIRender`;var LM=e=>{let t=G(4),{components:n,spec:r,Fallback:i}=e,a=X(RM),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,P.jsx)(IM,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};LM.displayName=`MessagePrimitive.GenerativeUI`;function RM(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var zM=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})}}},BM=(e,t,n)=>{let r=[];if(t){let t=zM(`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=zM(`toolGroup`),n=zM(`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},VM=e=>{let t=G(10),n=X($w(dN)),r=X($w(pN)),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=BM(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},HM=e=>{let t=G(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=X(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},UM=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),WM=e=>{let t=G(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=>UM(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=X(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},GM={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},KM=e=>{let t=G(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?GM.Text:i,m=a===void 0?GM.Reasoning:a,h=o===void 0?GM.Image:o,g=s===void 0?GM.Source:s,_=c===void 0?GM.File:c,v=l===void 0?GM.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=Y(),S=X(mN),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)(HM,{...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)(WM,{...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)(IM,{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}},qM=RS(e=>{let t=G(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(KM,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(zk,{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);qM.displayName=`MessagePrimitive.PartByIndex`;var JM=e=>{let t=G(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)(Vk,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},YM=Object.freeze({type:`complete`}),XM=Object.freeze({type:`running`}),ZM=RS(e=>{let t=G(6),{components:n}=e,r=X(hN);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??GM.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(JM,{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),QM=RS(e=>{let t=G(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),!X(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,P.jsx)(ZM,{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),$M=RS(e=>{let t=G(4),{Quote:n}=e,r=X(jM);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 eN(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(hA(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var tN=()=>{let e=G(6),t=Y(),n=X(gN),r=X(_N);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},nN=()=>{let e=G(3),t=X(vN),n=X(yN);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},rN=()=>{let e=G(2),t=X(bN);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(tN,{}),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)(nN,{}),e[1]=t):t=e[1],t}return null},iN=Object.freeze({type:`text`,text:``,status:XM}),aN=({children:e})=>{let t=Y(),n=X(e=>e.dataRenderers);return(0,P.jsx)(rD,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=eN(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,P.jsx)(tN,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=UM(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,P.jsx)(nN,{}):null}}return e}})})},oN=e=>{let t=G(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(aN,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(zk,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},sN=e=>{let t=G(9),{children:n}=e,r=X(xN),i=X(SN),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:iN}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,P.jsx)(Vk,{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)(oN,{index:t,children:e=>n(e)??(0,P.jsx)(rN,{})},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},cN=e=>{let t=G(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)(sN,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,P.jsx)(lN,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};cN.displayName=`MessagePrimitive.Parts`;var lN=e=>{let t=G(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=X(CN),{ranges:a,partIds:o}=VM(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,P.jsx)(ZM,{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)(qM,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,P.jsx)(Jk,{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??GM.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)(qM,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??GM.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)(qM,{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)($M,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,P.jsx)(QM,{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 uN(e){return e.type}function dN(e){return e.message.parts.map(uN)}function fN(e){return e.type===`tool-call`?e.toolCallId:void 0}function pN(e){return e.message.parts.map(fN)}function mN(e){return e.part}function hN(e){return e.message.status??YM}function gN(e){return e.part}function _N(e){return e.part.type===`tool-call`?eN(e.tools,e.part):null}function vN(e){return e.part}function yN(e){return e.part.type===`data`?UM(e.dataRenderers,e.part.name,void 0)??null:null}function bN(e){return e.part.type}function xN(e){return e.message.parts.length}function SN(e){return(e.message.status?.type??`complete`)===`running`}function CN(e){return e.message.parts.length}var wN=Symbol.for(`@assistant-ui/groupBy.memoKey`),TN=e=>{let t=e,n=((e,n)=>{if(e.type===`tool-call`){if((hA(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[wN]=`groupPartByType:${JSON.stringify(r)}`,n},EN=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},DN=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},ON=(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:DN(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:EN(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:EN(s),idKey:DN(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},kN=(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`}}},AN=()=>{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.")},jN=(e,t,n)=>{if(e.type===`part`)return(0,P.jsx)(oN,{index:e.index,children:({part:e})=>n({part:e,children:(0,P.jsx)(AN,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let{status:r,counts:i}=Kk(t,e.indices),a={type:e.key,status:r,counts:i,indices:e.indices};return(0,P.jsx)(zS,{children:n({part:a,children:(0,P.jsx)(P.Fragment,{children:e.children.map(e=>jN(e,t,n))})})},e.idKey??e.nodeKey)},MN=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=X($w(e=>e.message.parts)),i=X(e=>e.tools.toolUIs),a=X(e=>t!==`never`&&e.message.status?.type===`running`),o=kS(()=>{let t={toolUIs:i};return ON(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[wN]??e,i]);return(0,P.jsxs)(P.Fragment,{children:[o.map(e=>jN(e,r,n)),kN(t,r,a)&&n({part:{type:`indicator`},children:(0,P.jsx)(AN,{})})]})};MN.displayName=`MessagePrimitive.GroupedParts`;var NN=RS(e=>{let t=G(5),{children:n}=e,r=X(jM);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});NN.displayName=`MessagePrimitive.Quote`;var PN=(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}},FN=e=>{let t=G(5),{components:n}=e,r=X(zN);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=PN(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},IN=RS(e=>{let t=G(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(FN,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Fk,{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);IN.displayName=`MessagePrimitive.AttachmentByIndex`;var LN=({children:e})=>{let t=X($w(e=>e.message.role===`user`?(e.message.attachments??[]).map(e=>e.id):[]));return kS(()=>t.map((t,n)=>(0,P.jsx)(Fk,{index:n,children:(0,P.jsx)(rD,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},RN=e=>{let t=G(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(LN,{children:e=>{let{attachment:t}=e,r=PN(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)(LN,{children:r}),t[2]=r,t[3]=i),i};RN.displayName=`MessagePrimitive.Attachments`;function zN(e){return e.attachment}var BN=(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}},VN=e=>{let t=G(5),{components:n}=e,r=X(GN);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=BN(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},HN=RS(e=>{let t=G(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(VN,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Ik,{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);HN.displayName=`ComposerPrimitive.AttachmentByIndex`;var UN=({children:e})=>{let t=X($w(e=>e.composer.attachments.map(e=>e.id)));return kS(()=>t.map((t,n)=>(0,P.jsx)(Ik,{index:n,children:(0,P.jsx)(rD,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},WN=e=>{let t=G(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(UN,{children:e=>{let{attachment:t}=e,r=BN(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)(UN,{children:r}),t[2]=r,t[3]=i),i};WN.displayName=`ComposerPrimitive.Attachments`;function GN(e){return e.attachment}var KN=RS(({children:e})=>{let t=X($w(e=>e.composer.queue.map(e=>e.id)));return kS(()=>t.map((t,n)=>(0,P.jsx)(Qk,{index:n,children:(0,P.jsx)(rD,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});KN.displayName=`ComposerPrimitive.Queue`;var qN=RS(e=>{let t=G(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)(Xk,{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);qN.displayName=`ThreadListPrimitive.ItemByIndex`;var JN=({archived:e,children:t})=>{let n=X($w(t=>e?t.threads.archivedThreadIds:t.threads.threadIds));return kS(()=>n.map((n,r)=>(0,P.jsx)(Xk,{index:r,archived:e,children:(0,P.jsx)(rD,{getItemState:t=>t.threads.item({index:r,archived:e}).getState(),children:e=>t({get threadListItem(){return e()}})})},n)),[n,e,t])},YN=e=>{let t=G(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)(JN,{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)(JN,{archived:a,children:i}),t[5]=a,t[6]=i,t[7]=o):o=t[7],o};YN.displayName=`ThreadListPrimitive.Items`;var XN=e=>{let{children:t}=e;return X(ZN)?t:null};XN.displayName=`MessagePartPrimitive.InProgress`;function ZN(e){return e.part.status.type===`running`}var QN=e=>{let t=G(2),{fallback:n}=e,r=X($N)||n,i;return t[0]===r?i=t[1]:(i=(0,P.jsx)(P.Fragment,{children:r}),t[0]=r,t[1]=i),i};QN.displayName=`ThreadListItemPrimitive.Title`;function $N(e){return e.threadListItem.title}var eP=e=>{let t=G(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},tP=RS(e=>{let t=G(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(eP,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Zk,{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);tP.displayName=`ThreadPrimitive.SuggestionByIndex`;var nP=({children:e})=>{let t=X(e=>e.suggestions.suggestions.length);return kS(()=>t===0?null:Array.from({length:t},(t,n)=>(0,P.jsx)(Zk,{index:n,children:(0,P.jsx)(rD,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},rP=e=>{let t=G(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(nP,{children:()=>(0,P.jsx)(eP,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(nP,{children:r}),t[2]=r,t[3]=i),i};rP.displayName=`ThreadPrimitive.Suggestions`;var iP=RS(rP,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),aP=e=>{let t=G(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],X(n)},oP=e=>{let t=G(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),aP(r)?n:null};oP.displayName=`ComposerPrimitive.If`;var sP=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,cP=e=>!e.composer.canCancel,lP=e=>e.composer.isEditing||e.optional.thread?.voice!==void 0||e.optional.thread?.capabilities.edit===!1,uP=e=>e.thread.isRunning||e.thread.isDisabled||e.thread.voice!==void 0||e.message.role!==`assistant`||!e.thread.capabilities.reload,dP=e=>e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(e=>e.type===`text`&&e.text.length>0),fP=e=>e.message.branchNumber<=1||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,pP=e=>e.message.branchNumber>=e.message.branchCount||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,mP=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,hP=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`},gP=e=>!e.threads.hasMore||e.threads.isLoading||e.threads.isLoadingMore,_P=()=>{let e=G(5),t=Y(),n=X(sP),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},vP=()=>{let e=G(5),t=Y(),n=X(cP),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},yP=()=>{let e=G(5),t=Y(),n=X(bP),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 bP(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var xP=()=>{let e=G(5),t=Y(),n=X(SP),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 SP(e){return!e.composer.isEditing}var CP=e=>{let t=G(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=Y(),s=X(dP),c=X(wP),l=X(TP),u=X(EP),d=K(void 0),f=K(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),q(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))},DP)},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 wP(e){return e.message.isCopied}function TP(e){return e.composer.isEditing}function EP(e){return e.composer.text}function DP(){}var OP=()=>{let e=G(5),t=Y(),n=X(lP),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},kP=()=>{let e=G(5),t=Y(),n=X(uP),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},AP=()=>{let e=G(5),t=Y(),n=X(MP),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},jP=()=>{let e=G(5),t=Y(),n=X(NP),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 MP(e){return e.message.metadata.submittedFeedback?.type===`positive`}function NP(e){return e.message.metadata.submittedFeedback?.type===`negative`}var PP=()=>{let e=G(5),t=Y(),n=X(IP),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 FP(e){return e.type===`text`&&e.text.length>0}function IP(e){return e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(FP)}var LP=()=>{let e=G(5),t=Y(),n=X(RP),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 RP(e){return e.message.speech==null}var zP=()=>{let e=G(5),t=Y(),n=X(pP),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},BP=()=>{let e=G(5),t=Y(),n=X(fP),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},VP=e=>{let t=G(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=Y(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>mP(e,s),t[0]=s,t[1]=c);let l=X(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(HP).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 HP(e){return e.trim()}var UP=()=>{let e=G(4),t=Y(),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},WP=()=>{let e=G(4),t=Y(),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},GP=()=>{let e=G(4),t=Y(),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},KP=()=>{let e=G(4),t=Y(),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},qP=()=>{let e=G(4),t=Y(),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},JP=()=>{let e=G(5),t=Y(),n=X(gP),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},YP=()=>X(hP),XP=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 ZP(e,t){function n(n){let r=GS(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function QP(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 $P=US(null),{useThreadViewport:eF,useThreadViewportStore:tF}=QP(ZP($P,`ThreadPrimitive.Viewport`),`useThreadViewport`),nF=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},rF=(e=>e?nF(e):nF),iF=e=>e;function aF(e,t=iF){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 oF=e=>{let t=rF(e),n=e=>aF(t,e);return Object.assign(n,t),n},sF=(e=>e?oF(e):oF),cF=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()}}}}},lF=(e={})=>{let t=new Set,n=cF(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=cF(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=sF(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{GC(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},uF=e=>e,dF=e=>{let t=G(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=tF(n),i;t[1]===e?i=t[2]:(i=()=>lF(e),t[1]=e,t[2]=i);let[a]=DS(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]),q(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&uF(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]),q(c,l),a},fF=e=>{let t=G(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=dF(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=DS(o),c;return t[4]!==n||t[5]!==s?(c=(0,P.jsx)($P.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},pF=()=>{let e=G(3),t=Y(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),q(n,r),null},mF=RS(e=>{let t=G(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)(pF,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,P.jsx)(fF,{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)(cD,{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}),hF=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,gF={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(hF)){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}},_F=Object.defineProperty,vF=(e,t)=>_F(e,`name`,{value:t,configurable:!0});function yF(e,t=globalThis?.document){let n=rn(e);N.useEffect(()=>{let e=vF(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}vF(yF,`useEscapeKeydown`);var bF=f;bF.dispatchDiscreteCustomEvent=v,bF.Root=f;var xF=Object.defineProperty,SF=(e,t)=>{let n={};for(var r in e)xF(n,r,{get:e[r],enumerable:!0});return t||xF(n,Symbol.toStringTag,{value:`Module`}),n},CF=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function wF(e,t){return VS(e,void 0,t===void 0?e.props.children:t)}function TF(e,t,n){return(0,P.jsx)(c,{...n,children:wF(e,t)})}function EF(e){let t=J((t,n)=>{let r=G(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&&HS(o)){let e=s,t;r[5]!==a||r[6]!==o?(t=wF(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 DF(e){let t=bF[e],n=EF(t);return n.displayName=`Primitive.${e}`,n}var OF=CF.reduce((e,t)=>(e[t]=DF(t),e),{}),kF={Hidden:`hidden`,Floating:`floating`,Normal:`normal`},AF=e=>{let t=G(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 kF.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?kF.Floating:kF.Normal:kF.Hidden:kF.Normal},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],X(o)},jF=US(null),MF=()=>GS(jF),NF=J((e,t)=>{let n=G(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]=DS(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(PF),()=>{e||(e=!0,c(FF))}},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=AF(m);if(h===kF.Hidden)return null;let g;n[12]===h?g=n[13]:(g=h===kF.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)(jF.Provider,{value:f,children:(0,P.jsx)(OF.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});NF.displayName=`ActionBarPrimitive.Root`;function PF(e){return e+1}function FF(e){return Math.max(0,e-1)}var IF=e=>{let t=G(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:RF},t[2]=i,t[3]=a);let{copy:o,disabled:s}=CP(a);return s?null:o},LF=J((e,t)=>{let n=G(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=X(zF),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=IF(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)(OF.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});LF.displayName=`ActionBarPrimitive.Copy`;function RF(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function zF(e){return e.message.isCopied}var BF=(e,t,n=[])=>{let r=J((e,r)=>{let i=G(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=OF,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},VF=BF(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=kP();return e?null:t}),HF=BF(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=OP();return e?null:t}),UF=BF(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=PP();return e?null:t}),WF=()=>{let{disabled:e,stopSpeaking:t}=LP();return e?null:t},GF=J((e,t)=>{let n=G(10),r=WF(),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)(OF.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});GF.displayName=`ActionBarPrimitive.StopSpeaking`;var KF=()=>{let{submit:e}=AP();return e},qF=J((e,t)=>{let n=G(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=X(JF),s=KF(),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)(OF.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});qF.displayName=`ActionBarPrimitive.FeedbackPositive`;function JF(e){return e.message.metadata.submittedFeedback?.type===`positive`}var YF=()=>{let{submit:e}=jP();return e},XF=J((e,t)=>{let n=G(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=X(ZF),s=YF(),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)(OF.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});XF.displayName=`ActionBarPrimitive.FeedbackNegative`;function ZF(e){return e.message.metadata.submittedFeedback?.type===`negative`}var QF=e=>{let t=G(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=Y(),o=X(tI),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},$F=J((e,t)=>{let n=G(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=QF(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.().catch(nI)},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)(OF.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});$F.displayName=`ActionBarPrimitive.ExportMarkdown`;function eI(e){return e.type===`text`&&e.text.length>0}function tI(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(eI)}function nI(e){console.error(`[assistant-ui] markdown export failed:`,e)}var rI=SF({Copy:()=>LF,Edit:()=>HF,ExportMarkdown:()=>$F,FeedbackNegative:()=>XF,FeedbackPositive:()=>qF,Reload:()=>VF,Root:()=>NF,Speak:()=>UF,StopSpeaking:()=>GF}),iI=eu(),aI=e=>{let t=G(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=iI(n),s=MF(),c=K(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]),q(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]),q(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)(Su,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};aI.displayName=`ActionBarMorePrimitive.Root`;var oI=EF(Cu),sI=EF(Tu),cI=EF(Ou),lI=EF(Nu),uI=J((e,t)=>{let n=G(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=iI(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(oI,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});uI.displayName=`ActionBarMorePrimitive.Trigger`;var dI=J((e,t)=>{let n=G(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=iI(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,P.jsx)(sI,{...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)(wu,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});dI.displayName=`ActionBarMorePrimitive.Content`;var fI=J((e,t)=>{let n=G(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=iI(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(cI,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});fI.displayName=`ActionBarMorePrimitive.Item`;var pI=J((e,t)=>{let n=G(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=iI(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(lI,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});pI.displayName=`ActionBarMorePrimitive.Separator`;var mI=SF({Content:()=>dI,Item:()=>fI,Root:()=>aI,Separator:()=>pI,Trigger:()=>uI}),hI=J((e,t)=>{let n=G(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(OF.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});hI.displayName=`AttachmentPrimitive.Root`;var gI=J((e,t)=>{let n=G(4),r=X(_I),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(OF.div,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});gI.displayName=`AttachmentPrimitive.unstable_Thumb`;function _I(e){let t=e.attachment.name,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?`.${t.slice(n+1)}`:e.attachment.type}var vI=()=>{let e=G(2),t=X(yI),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};vI.displayName=`AttachmentPrimitive.Name`;function yI(e){return e.attachment.name}var bI=BF(`AttachmentPrimitive.Remove`,()=>{let e=G(2),t=Y(),n;return e[0]===t.attachment?n=e[1]:(n=()=>{t.attachment.remove()},e[0]=t.attachment,e[1]=n),n}),xI=SF({Name:()=>vI,Remove:()=>bI,Root:()=>hI,unstable_Thumb:()=>gI}),SI=BF(`BranchPickerPrimitive.Next`,()=>{let{disabled:e,next:t}=zP();return e?null:t}),CI=BF(`BranchPickerPrimitive.Previous`,()=>{let{disabled:e,previous:t}=BP();return e?null:t}),wI=()=>X(EI),TI=()=>{let e=G(2),t=wI(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};TI.displayName=`BranchPickerPrimitive.Count`;function EI(e){return e.message.branchCount}var DI=()=>X(kI),OI=()=>{let e=G(2),t=DI(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};OI.displayName=`BranchPickerPrimitive.Number`;function kI(e){return e.message.branchNumber}var AI=J((e,t)=>{let n=G(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)(OF.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)(ZE,{condition:a,children:o}),n[8]=a,n[9]=o,n[10]=s):s=n[10],s});AI.displayName=`BranchPickerPrimitive.Root`;var jI=SF({Count:()=>TI,Next:()=>SI,Number:()=>OI,Previous:()=>CI,Root:()=>AI}),MI=US(null),NI=()=>GS(MI),PI=e=>{let t=G(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=K(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=K(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(FI),o.current=e.map(II)},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)(MI.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function FI(e,t){return t[1]-e[1]}function II(e){let[t]=e;return t}var LI=US(null),RI=US(null),zI=()=>{let e=GS(LI);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},BI=()=>GS(LI),VI=()=>{let e=GS(RI);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},HI=()=>{let e=zI();return NS(e.subscribe,e.getTriggers,e.getTriggers)},UI=new Map,WI=()=>()=>{},GI=()=>UI,KI=()=>{let e=BI();return NS(e?e.subscribe:WI,e?e.getTriggers:GI,e?e.getTriggers:GI)},qI=()=>null,JI=()=>{let e=BI();return NS(e?e.subscribeAria:WI,e?e.getActiveAria:qI,e?e.getActiveAria:qI)};function YI(){let e=G(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=K(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 XI=e=>{let t=G(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=K(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=K(a),{notify:s,subscribe:c}=YI(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return QI;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=K(null),g=K(null),{notify:_,subscribe:v}=YI(),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)(RI.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)(LI.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},ZI=e=>{let t=G(4),{children:n}=e;if(NI()){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(XI,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,P.jsx)(PI,{children:(0,P.jsx)(XI,{children:n})}),t[2]=n,t[3]=r),r};ZI.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function QI(){}var $I=/\s/u;function eL(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 tL(e,t,n,r){if(r)return eL(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($I.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!$I.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var nL=KS(e=>{let t=G(8),{text:n,triggerChar:r,matcher:i}=e,[a,o]=DS(n.length),s=Math.min(a,n.length),c;t[0]!==i||t[1]!==s||t[2]!==n||t[3]!==r?(c=tL(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 rL(e){return`type`in e}var iL=KS(e=>{let t=G(22),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=DS(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]=DS(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=MS(_),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&&(rL(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=MS(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 aL(e,t){return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var oL=KS(e=>{let t=G(35),{adapter:n,query:r,open:i}=e,[a,o]=DS(null),[s,c]=DS(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))aL(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=>aL(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=MS(C),T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[26]=T):T=t[26];let E=MS(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}),sL=KS(e=>{let t=G(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=K(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=MS(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=MS(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=MS(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}),cL=KS(e=>{let t=G(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=nL({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=PC(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=oL({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=PC(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=MS(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=sL({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=PC(_),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=iL({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=PC(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}),lL=US(null),uL=()=>{let e=GS(lL);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},dL=()=>GS(lL),fL=US(null),pL=()=>{let e=GS(fL);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},mL=J((e,t)=>{let n=G(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=Y(),f=X(hL),p=IS(),m=K(s),h;n[8]===s?h=n[9]:(h=()=>{m.current=s},n[8]=s,n[9]=h),q(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[_]=DS(g),v=s!==void 0,y=K(null),[b,x]=DS(null),S=K(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=cL({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=PC(O),ee;n[24]===k?ee=n[25]:(ee=()=>k,n[24]=k,n[25]=ee);let A=MS(ee),j=zI(),te;n[26]!==b||n[27]!==a||n[28]!==A||n[29]!==v||n[30]!==_||n[31]!==j?(te=()=>j.register({char:a,...v?{matcher:_}:{},...b?{behavior:b}:{},resource:A()}),n[26]=b,n[27]=a,n[28]=A,n[29]=v,n[30]=_,n[31]=j,n[32]=te):te=n[32];let ne;n[33]!==b||n[34]!==a||n[35]!==v||n[36]!==j?(ne=[j,a,v,b],n[33]=b,n[34]=a,n[35]=v,n[36]=j,n[37]=ne):ne=n[37],q(te,ne);let re=NI(),M;n[38]!==A||n[39]!==re?(M=()=>{if(re)return re.register(A())},n[38]=A,n[39]=re,n[40]=M):M=n[40];let ie;n[41]===re?ie=n[42]:(ie=[re],n[41]=re,n[42]=ie),q(M,ie);let ae=b!==null&&k.open,oe=VI(),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]),q(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]),q(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)(OF.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)(lL.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)(fL.Provider,{value:E,children:fe}),n[66]=E,n[67]=fe,n[68]=pe):pe=n[68],pe});mL.displayName=`ComposerPrimitive.TriggerPopover`;function hL(e){return e.composer.text}var gL=()=>{let e=G(2),{disabled:t,send:n}=_P(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},_L=BF(`ComposerPrimitive.Send`,gL),vL=US(null),yL=()=>GS(vL),bL=`[contenteditable]:not([contenteditable='false'])`,xL=`textarea:not(:disabled), ${bL}`,SL=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,bL,`[tabindex]`].join(`, `),CL=J((e,t)=>{let n=G(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=gL(),[c,l]=DS(!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(`
65
+ `):!1,n[6]=r,n[7]=f);let p=X(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=wL,_=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)(OF.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)(vL.Provider,{value:_,children:x}),n[21]=_,n[22]=x,n[23]=S):S=n[23],S});CL.displayName=`ComposerPrimitive.Root`;function wL(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(SL);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(xL);r&&(e.preventDefault(),r.focus())}var TL=e=>{let t=G(4),n=rn(e),r=eF(EL),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]),q(i,a)};function EL(e){return e.onScrollToBottom}var DL=()=>!1,OL=()=>{},kL=e=>{let t=G(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return OL;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),NS(r,i,DL)};function AL(){return X(jL)}function jL(e){return e.composer.isEditing?e.composer.text:``}function ML(e){return!!X(NL)||!!e}function NL(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function PL(){let e=G(4),t=JI();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 FL(){return FL=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},FL.apply(null,arguments)}function IL(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 LL=N.useLayoutEffect,RL=function(e){var t=N.useRef(e);return LL(function(){t.current=e}),t},zL=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},BL=function(e,t){var n=N.useRef();return N.useCallback(function(r){e.current=r,n.current&&zL(n.current,null),n.current=t,t&&zL(t,r)},[t])},VL={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},HL=function(e){Object.keys(VL).forEach(function(t){e.style.setProperty(t,VL[t],`important`)})},UL=null,WL=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function GL(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),UL||(UL=document.createElement(`textarea`),UL.setAttribute(`tabindex`,`-1`),UL.setAttribute(`aria-hidden`,`true`),HL(UL)),UL.parentNode===null&&document.body.appendChild(UL);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;UL.style[t]=o[t]}),HL(UL),UL.value=t;var c=WL(UL,e);UL.value=t,c=WL(UL,e),UL.value=`x`;var l=UL.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 KL=function(){},qL=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},JL=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],YL=!!document.documentElement.currentStyle,XL=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=qL(JL,t),r=n.boxSizing;return r===``?null:(YL&&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 ZL(e,t,n){var r=RL(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 QL=function(e,t){ZL(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},$L=function(e){ZL(window,`resize`,e)},eR=function(e){ZL(document.fonts,`loadingdone`,e)},tR=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],nR=N.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?KL:a,s=e.onHeightChange,c=s===void 0?KL:s,l=IL(e,tR),u=l.value!==void 0,d=N.useRef(null),f=BL(d,t),p=N.useRef(0),m=N.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:XL(e);if(t){m.current=t;var a=GL(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),QL(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),$L(h),eR(h),N.createElement(`textarea`,FL({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),rR=`(pointer: coarse) and (not (any-pointer: fine))`,iR=J(({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=Y(),S=NI(),C=yL(),w=u??(l===!1?`none`:`enter`),T=kL(g?rR:null),E=g&&T&&w===`enter`?`none`:w,D=AL(),O=ML(r),k=K(null),ee=d(b,k),A=K(!1);yF(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 j=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())}}},te=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{}})))},ne=(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)},re=e&&!O,M=AS(()=>{let e=k.current;e&&re&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[re]);q(()=>M(),[M]),TL(()=>{x.composer.getState().type===`thread`&&m&&M()}),q(()=>{if(x.composer.getState().type===`thread`&&p)return x.on(`thread.runStart`,M)},[p,M,x]),q(()=>{if(x.composer.getState().type===`thread`&&h)return x.on(`threads.selectionChanged`,M)},[h,M,x]),q(()=>{D===``&&C?.setMultiline(!1)},[D,C]);let ie=PL(),ae={name:`input`,value:D,...y,...ie,ref:ee,disabled:O,onChange:F(i,e=>{if(!x.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;A.current&&!t&&(A.current=!1);let n=t||A.current;if(aC(()=>{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,j),onCompositionStart:F(y.onCompositionStart,()=>{A.current=!0}),onCompositionEnd:F(y.onCompositionEnd,e=>{if(A.current=!1,!x.composer.getState().isEditing)return;let t=e.target;aC(()=>{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(A.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,te),...C?{onHeightChange:ne}:v===void 0?{}:{onHeightChange:v}};if(n&&HS(n))return TF(n,y.children,ae);let oe=t?c:nR;return(0,P.jsx)(oe,{...ae})});iR.displayName=`ComposerPrimitive.Input`;var aR=BF(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=vP();return e?null:t}),oR=BF(`ComposerPrimitive.AddAttachment`,e=>{let t=G(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}=xP(),s=Y(),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`]),sR=J(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,s]=DS(!1),l=Y(),u=AS(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=AS(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=AS(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||s(!1)},[e]),p=AS(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&&HS(n))return TF(n,r,m);let h=t?c:`div`;return(0,P.jsx)(h,{...m,children:r})});sR.displayName=`ComposerPrimitive.AttachmentDropzone`;var cR=BF(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=yP();return e?null:t}),lR=BF(`ComposerPrimitive.StopDictation`,()=>{let e=G(2),t=Y(),n=X(uR),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function uR(e){return e.composer.dictation!=null}var dR=J((e,t)=>{let n=G(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=X(fR);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(OF.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});dR.displayName=`ComposerPrimitive.DictationTranscript`;function fR(e){return e.composer.dictation?.transcript}var pR=J((e,t)=>{let n=G(3);if(!X(gR))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(OF.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});pR.displayName=`ComposerPrimitive.Quote`;var mR=J((e,t)=>{let n=G(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=X(_R);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(OF.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});mR.displayName=`ComposerPrimitive.QuoteText`;var hR=J((e,t)=>{let n=G(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=Y(),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)(OF.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});hR.displayName=`ComposerPrimitive.QuoteDismiss`;function gR(e){return e.composer.quote}function _R(e){return e.composer.quote?.text}var vR=J((e,t)=>{let n=G(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}=uL();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)(OF.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});vR.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var yR=J((e,t)=>{let n=G(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}=uL(),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)(OF.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});yR.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var bR=J((e,t)=>{let n=G(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}=uL();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)(OF.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});bR.displayName=`ComposerPrimitive.TriggerPopoverItems`;var xR=J((e,t)=>{let n=G(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}=uL(),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)(OF.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});xR.displayName=`ComposerPrimitive.TriggerPopoverItem`;var SR=J((e,t)=>{let n=G(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}=uL();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)(OF.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});SR.displayName=`ComposerPrimitive.TriggerPopoverBack`;var CR=e=>{let t=G(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=pL(),o=K(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),FS(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e={kind:`action`,formatter:n??gF,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]),q(l,u),null};CR.displayName=`ComposerPrimitive.TriggerPopoverAction`;var wR=e=>{let t=G(7),{formatter:n,onInserted:r}=e,{register:i}=pL(),a=K(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),FS(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n??gF,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]),q(c,l),null};wR.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var TR=Object.assign(mL,{Directive:wR,Action:CR}),ER=SF({AddAttachment:()=>oR,AttachmentByIndex:()=>HN,AttachmentDropzone:()=>sR,Attachments:()=>WN,Cancel:()=>aR,Dictate:()=>cR,DictationTranscript:()=>dR,If:()=>oP,Input:()=>iR,Queue:()=>KN,Quote:()=>pR,QuoteDismiss:()=>hR,QuoteText:()=>mR,Root:()=>CL,Send:()=>_L,StopDictation:()=>lR,Unstable_TriggerPopover:()=>TR,Unstable_TriggerPopoverBack:()=>SR,Unstable_TriggerPopoverCategories:()=>vR,Unstable_TriggerPopoverCategoryItem:()=>yR,Unstable_TriggerPopoverItem:()=>xR,Unstable_TriggerPopoverItems:()=>bR,Unstable_TriggerPopoverRoot:()=>ZI,unstable_useTriggerPopoverRootContext:()=>zI,unstable_useTriggerPopoverRootContextOptional:()=>BI,unstable_useTriggerPopoverScopeContext:()=>uL,unstable_useTriggerPopoverScopeContextOptional:()=>dL,unstable_useTriggerPopoverTriggers:()=>HI,unstable_useTriggerPopoverTriggersOptional:()=>KI}),DR=Object.freeze({type:`complete`}),OR=Object.freeze({type:`text`,text:``,status:DR}),kR=()=>X(AR);function AR(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?OR:e.part}var jR=US(null),MR=e=>({useSmoothStatus:sF(()=>e)}),NR=e=>{let t=G(6),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={optional:!0},t[0]=r):r=t[0];let i=FR(r),a=Y(),o;t[1]===a.part?o=t[2]:(o=()=>MR(a.part.getState().status),t[1]=a.part,t[2]=o);let[s]=DS(o);if(i)return n;let c;return t[3]!==n||t[4]!==s?(c=(0,P.jsx)(jR.Provider,{value:s,children:n}),t[3]=n,t[4]=s,t[5]=c):c=t[5],c},PR=e=>{let t=J((t,n)=>{let r=G(3),i=t,a;return r[0]!==n||r[1]!==i?(a=(0,P.jsx)(NR,{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 FR(e){let t=GS(jR);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:IR,useSmoothStatusStore:LR}=QP(FR,`useSmoothStatus`),RR=250,zR=5,BR=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=RR;maxCharIntervalMs=zR;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)))}},VR=Object.freeze({type:`running`}),HR=(e,t)=>e!==void 0&&e>0?e:t,UR=(e,t=!1)=>{let{text:n}=e,r=kL(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=HR(i?.drainMs,RR),s=HR(i?.maxCharIntervalMs,zR),c=HR(i?.maxCharsPerFrame,1/0),l=HR(i?.minCommitMs,0),[u,d]=DS(e.status.type===`running`?``:n),f=Y(),p=X(()=>f.part),[m,h]=DS(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=LR({optional:!0}),_=rn(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?VR:e.status;uF(g).setState(n,!0)}});q(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?VR:e.status;uF(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=DS(new BR(u,_));q(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=K(p);return q(()=>{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,_]),q(()=>()=>{v.stop()},[v]),kS(()=>a?{...e,text:u,status:n===u?e.status:VR}:e,[a,u,e,n])},WR=Object.freeze({type:`complete`}),GR=Object.freeze({type:`image`,image:``,status:WR}),KR=()=>X(qR);function qR(e){return e.part.type===`image`?e.part:GR}var JR=J(({smooth:e=!0,component:t=OF.span,render:n,...r},i)=>{let{text:a,status:o}=UR(kR(),e),s={"data-status":o.type,...r,ref:i};return n&&HS(n)?TF(n,a,s):(0,P.jsx)(t,{...s,children:a})});JR.displayName=`MessagePartPrimitive.Text`;var YR=J((e,t)=>{let n=G(4),{image:r}=KR(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,P.jsx)(OF.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});YR.displayName=`MessagePartPrimitive.Image`;var XR=J((e,t)=>{let n=G(3),r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(OF.div,{role:`alert`,...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});XR.displayName=`ErrorPrimitive.Root`;var ZR=J((e,t)=>{let n=G(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=YP();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)(OF.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});ZR.displayName=`ErrorPrimitive.Message`;var QR=SF({Message:()=>ZR,Root:()=>XR}),$R=e=>{let t=G(2),n=K(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},ez=(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},tz=e=>e.dataset.messageId,nz=()=>{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},rz=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},iz=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},az=()=>{let e=G(4),t=Y(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=X(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),$R(i)},oz=()=>{let e=G(2),t=eF(pz),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),X(n)},sz=()=>{let e=G(2),t=eF(mz),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),X(n)},cz=(e,t)=>{let n=G(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],$R(r)},lz=e=>{let t=G(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:ez(i.tallerThan,e),visibleHeight:ez(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],$R(i)},uz=e=>{let t=G(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=az(),a=d(n,i),o=X(hz),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,P.jsx)(OF.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},dz=e=>{let t=G(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=az(),o=oz(),s=sz(),c=cz(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=lz(l),f=d(n,a,c,u),p=X(gz),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)(OF.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},fz=J((e,t)=>{let n=G(7),r=tF();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,P.jsx)(dz,{...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)(uz,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});fz.displayName=`MessagePrimitive.Root`;function pz(e){return e.topAnchorTurn?.anchorId}function mz(e){return e.topAnchorTurn?.targetId}function hz(e){return e.message.id}function gz(e){return e.message.id}var _z={...GM,Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(JR,{}),(0,P.jsx)(XN,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,P.jsx)(YR,{})},vz=e=>{let t=G(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,P.jsx)(cN,{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??_z.Text,Image:n.Image??_z.Image}:_z,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,P.jsx)(cN,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};vz.displayName=`MessagePrimitive.Parts`;var yz=e=>{let t=G(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],X(n)},bz=e=>{let t=G(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),yz(r)?n:null};bz.displayName=`MessagePrimitive.If`;var xz=e=>{let{children:t}=e;return YP()===void 0?null:t};xz.displayName=`MessagePrimitive.Error`;var Sz=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},Cz=e=>{let t=G(4),n=X(Pz),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},wz=e=>{let t=G(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=X(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},Tz=e=>{let t=G(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=X(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},Ez={Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(JR,{}),(0,P.jsx)(XN,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,P.jsx)(YR,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},Dz=e=>{let t=G(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?Ez.Text:i,p=a===void 0?Ez.Reasoning:a,m=o===void 0?Ez.Image:o,h=s===void 0?Ez.Source:s,g=c===void 0?Ez.File:c,_=l===void 0?Ez.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=Y(),x=X(Fz),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)(wz,{...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)(Tz,{...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}},Oz=RS(e=>{let t=G(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(Dz,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(zk,{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),kz=e=>{let t=G(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)(Vk,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},Az=Object.freeze({type:`complete`}),jz=RS(e=>{let t=G(6),{components:n}=e,r=X(Iz);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??Ez.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(kz,{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),Mz=e=>{let t=G(9),{groupingFunction:n,components:r}=e,i=X(Lz),a=Cz(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,P.jsx)(jz,{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??Ez.Group;return(0,P.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,P.jsx)(Oz,{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};Mz.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var Nz=e=>{let t=G(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)(Mz,{...r,components:n,groupingFunction:Sz}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};Nz.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function Pz(e){return e.message.parts}function Fz(e){return e.part}function Iz(e){return e.message.status??Az}function Lz(e){return e.message.parts.length}var Rz=SF({AttachmentByIndex:()=>IN,Attachments:()=>RN,Content:()=>vz,Error:()=>xz,GenerativeUI:()=>LM,GroupedParts:()=>MN,If:()=>bz,PartByIndex:()=>qM,Parts:()=>vz,Quote:()=>NN,Root:()=>fz,Unstable_PartsGrouped:()=>Mz,Unstable_PartsGroupedByParentId:()=>Nz}),zz=e=>{let t=G(2),n=rn(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(Bz)&&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),$R(r)};function Bz(e){return e.type!==`attributes`||e.attributeName!==`style`}var Vz=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=K(null),a=X(e=>e.thread.messages.length>0),o=X(e=>e.thread.isRunning),s=K(!1),c=K(null),l=tF();e===void 0&&(e=l.getState().turnAnchor!==`top`);let u=K(0),f=K(0),p=K(0),m=K(0),h=K(null),g=K(e),_=K(e);jS(()=>{let t=_.current;if(_.current=e,t||!e)return;let n=i.current;g.current=n!==null&&MT(n)},[e]);let v=AS(e=>{let t=i.current;t&&(g.current=!0,h.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),y=AS(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),b=AS(e=>{h.current=e,y(),c.current=requestAnimationFrame(()=>{c.current=null,v(e)})},[y,v]);jS(()=>()=>y(),[y]);let x=AS(()=>{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=MT(t);if(!(!r&&u.current<t.scrollTop)){let i=PT({scrollTop:u.current,scrollHeight:f.current},t);r?(NT(t)&&(h.current=null),e&&(g.current=!0)):i&&(y(),h.current=null,g.current=!1),(r||h.current===null)&&r!==n&&uF(l).setState({isAtBottom:r})}u.current=t.scrollTop,f.current=t.scrollHeight},C=zz(()=>{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=$R(e=>{let t=()=>{h.current=null};return e.addEventListener(`scroll`,S),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,S),e.removeEventListener(`pointerdown`,t)}});return jS(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,h.current===null&&b(`instant`))}},[a,b,n]),TL(({behavior:e})=>{v(e)}),aD(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&b(`auto`)}),aD(`threads.selectionChanged`,()=>{r&&b(`instant`)}),d(C,w,i)},Hz=J((e,t)=>{let n=G(6),r=Y(),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),q(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,P.jsx)(OF.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});Hz.displayName=`ThreadPrimitive.Root`;var Uz=e=>{let{children:t}=e;return X(Wz)?t:null};Uz.displayName=`ThreadPrimitive.Empty`;function Wz(e){return e.thread.isEmpty}var Gz=e=>{let t=G(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],X(n)},Kz=e=>{let t=G(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),Gz(r)?n:null};Kz.displayName=`ThreadPrimitive.If`;var qz=(e,t)=>{let n=G(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],$R(r)},Jz=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},Yz=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:Jz(e)-Jz(t)},Xz=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=Yz(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},Zz=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=Xz(t)+n.clientHeight;return Math.max(0,r-e)},Qz=({viewport:e,reserve:t,...n})=>Zz({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),$z=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}},eB=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},tB=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&&(rz(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&&(rz(t,0),t.remove());return}if(t??=nz(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),rz(t,Qz({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=tz(s);if(u!==void 0&&n===u)return;let d=iz(Xz({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=eB(r),a=$z(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},nB=e=>{let t=G(4),n=tF(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return tB(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),jS(r,i)},rB=(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`)},iB=({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}},aB=e=>iB(e)?.anchorId,oB=e=>iB(e)?.targetId,sB=()=>qz(eF(fB),pB),cB=()=>$R(eF(mB)),lB=e=>{let t=G(19),n=tF(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return aB(t.thread)},t[0]=e,t[1]=r);let i=X(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return oB(t.thread)},t[2]=e,t[3]=a);let o=X(a),s=eF(hB),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&&rB(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=X(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]),jS(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]),jS(m,h)},uB=J((e,t)=>{let n=G(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=Vz(l),f=sB(),p=cB(),m=tF(),h;n[12]===m?h=n[13]:(h=m.getState(),n[12]=m,n[13]=h);let g=h.turnAnchor===`top`;lB(g),nB(g);let _=d(t,u,f,p),v;return n[14]!==i||n[15]!==_||n[16]!==a?(v=(0,P.jsx)(OF.div,{...a,ref:_,children:i}),n[14]=i,n[15]=_,n[16]=a,n[17]=v):v=n[17],v});uB.displayName=`ThreadPrimitive.ViewportScrollable`;var dB=J((e,t)=>{let n=G(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)(uB,{...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)(fF,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});dB.displayName=`ThreadPrimitive.Viewport`;function fB(e){return e.registerViewport}function pB(e){return e.clientHeight}function mB(e){return e.registerViewportElement}function hB(e){return e.topAnchorTurn}var gB=J((e,t)=>{let n=G(3),r=qz(eF(_B),vB),i=d(t,r),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(OF.div,{...e,ref:i}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});gB.displayName=`ThreadPrimitive.ViewportFooter`;function _B(e){return e.registerContentInset}function vB(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var yB=BF(`ThreadPrimitive.ScrollToBottom`,e=>{let t=G(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=eF(bB),a=tF(),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 bB(e){return e.isAtBottom}var xB=BF(`ThreadPrimitive.Suggestion`,e=>{let t=G(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}=VP(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),SB=SF({Empty:()=>Uz,If:()=>Kz,MessageByIndex:()=>wM,Messages:()=>OM,Root:()=>Hz,ScrollToBottom:()=>yB,Suggestion:()=>xB,SuggestionByIndex:()=>tP,Suggestions:()=>iP,Unstable_MessageById:()=>TM,Viewport:()=>dB,ViewportFooter:()=>gB,ViewportProvider:()=>fF}),CB=J((e,t)=>{let n=G(4),r=X(wB),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(OF.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});CB.displayName=`SuggestionPrimitive.Title`;function wB(e){return e.suggestion.title}var TB=J((e,t)=>{let n=G(4),r=X(EB),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(OF.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});TB.displayName=`SuggestionPrimitive.Description`;function EB(e){return e.suggestion.label}var DB=BF(`SuggestionPrimitive.Trigger`,e=>{let t=G(4),{send:n,clearComposer:r}=e,i=X(OB),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}=VP(a);return s?null:o},[`send`,`clearComposer`]);function OB(e){return e.suggestion.prompt}var kB=SF({Description:()=>TB,Title:()=>CB,Trigger:()=>DB}),AB=J((e,t)=>{let n=G(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=X(jB),{switchToNewThread:s}=qP(),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)(OF.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});AB.displayName=`ThreadListPrimitive.New`;function jB(e){return e.threads.newThreadId===e.threads.mainThreadId}var MB=BF(`ThreadListPrimitive.LoadMore`,()=>{let{loadMore:e,disabled:t}=JP();return t?null:e}),[NB,PB]=We(`ThreadList`),FB=NB,IB=US(null),LB=IB.Provider,RB=()=>GS(IB),zB=J((e,t)=>{let n=G(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(FB.Provider,{scope:void 0,children:(0,P.jsx)(FB.Slot,{scope:void 0,children:(0,P.jsx)(OF.div,{...e,ref:t})})}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});zB.displayName=`ThreadListPrimitive.Root`;var BB=SF({ItemByIndex:()=>qN,Items:()=>YN,LoadMore:()=>MB,New:()=>AB,Root:()=>zB}),VB=J((e,t)=>{let n=X(e=>e.threads.mainThreadId===e.threadListItem.id),r=K(null),i=K(null),a=kS(()=>({triggerRef:r,moreRef:i}),[]),o=PB(void 0),s=en(),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)(LB,{value:a,children:(0,P.jsx)(OF.div,{...n?{"data-active":`true`,"aria-current":`true`}:null,...e,onKeyDown:F(e.onKeyDown,c),ref:t})})});VB.displayName=`ThreadListItemPrimitive.Root`;var HB=BF(`ThreadListItemPrimitive.Archive`,()=>{let{archive:e}=UP();return e}),UB=BF(`ThreadListItemPrimitive.Unarchive`,()=>{let{unarchive:e}=GP();return e}),WB=BF(`ThreadListItemPrimitive.Delete`,()=>{let{delete:e}=WP();return e}),GB=BF(`ThreadListItemPrimitive.Trigger`,()=>{let{switchTo:e}=KP();return e}),KB=J((e,t)=>{let n=G(3),r=RB(),i=d(t,r?.triggerRef),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(FB.ItemSlot,{scope:void 0,children:(0,P.jsx)(GB,{...e,ref:i})}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});KB.displayName=`ThreadListItemPrimitive.Trigger`;var qB=SF({Archive:()=>HB,Delete:()=>WB,Root:()=>VB,Title:()=>QN,Trigger:()=>KB,Unarchive:()=>UB}),JB=eu(),YB=US(()=>{}),XB=()=>GS(YB),ZB=US(!1),QB=()=>GS(ZB),$B=e=>{let t=G(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=JB(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]=_t(m),_;t[14]!==u||t[15]!==h||t[16]!==s||t[17]!==d||t[18]!==g?(_=(0,P.jsx)(Su,{...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)(YB.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)(ZB.Provider,{value:l,children:v}),t[23]=l,t[24]=v,t[25]=y):y=t[25],y};$B.displayName=`ThreadListItemMorePrimitive.Root`;var eV=J((e,t)=>{let n=G(10),{__scopeThreadListItemMore:r,...i}=e,a=JB(r),o=RB(),s=XB(),c=QB(),l=d(t,o?.moreRef),u=en()===`rtl`?`ArrowLeft`:`ArrowRight`,f=oI,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});eV.displayName=`ThreadListItemMorePrimitive.Trigger`;var tV=J((e,t)=>{let n=G(21),{__scopeThreadListItemMore:r,portalProps:i,sideOffset:a,...o}=e,s=a===void 0?4:a,c=JB(r),l=XB(),u=RB(),d=QB(),f=en()===`rtl`?`ArrowRight`:`ArrowLeft`,p=Yl,m=sI,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});tV.displayName=`ThreadListItemMorePrimitive.Content`;var nV=J((e,t)=>{let n=G(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=JB(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(cI,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});nV.displayName=`ThreadListItemMorePrimitive.Item`;var rV=J((e,t)=>{let n=G(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=JB(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(lI,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});rV.displayName=`ThreadListItemMorePrimitive.Separator`;var iV=SF({Content:()=>tV,Item:()=>nV,Root:()=>$B,Separator:()=>rV,Trigger:()=>eV}),aV=(e,t)=>{let n=G(5),r=K(null),i=K(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]),q(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},oV=()=>{let e=G(3),t=X(sV),n=X(cV),r=t!==void 0&&t.completedAt===void 0&&n,[i,a]=DS(lV),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),q(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 sV(e){let t=e.optional.part;return t?.type===`tool-call`?t.timing:void 0}function cV(e){let t=e.optional.part;return t?.type===`tool-call`&&t.status.type===`running`}function lV(){return Date.now()}var uV=SF({AssistantRuntimeImpl:()=>LA,BaseAssistantRuntimeCore:()=>HA,CompositeContextProvider:()=>KT,DefaultThreadComposerRuntimeCore:()=>dj,MessageRepository:()=>$A,ThreadRuntimeImpl:()=>DA,getAutoStatus:()=>Ak,splitLocalRuntimeOptions:()=>XP,useComposerInputPluginRegistryOptional:()=>NI,useSmooth:()=>UR,useSmoothStatus:()=>IR,withSmoothContextProvider:()=>PR}),dV=(e,t)=>`${e}:${t}`,fV=e=>({id:e,status:`idle`}),pV=e=>({threadId:e,metadata:fV(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}),mV=e=>e?.role===`assistant`,hV=(e,t)=>e.status===t?e:{...e,status:t},gV=(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},_V=(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:gV(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`}},vV=(e,t,n)=>{let r=e.slice();return r[t]=n,r},yV=(e,t,n)=>({...e,toolExecutions:{...e.toolExecutions,[t]:{toolCallId:t,status:`running`,...e.toolExecutions[t],...n}}}),bV=(e,t)=>e.hostUiRequests.some(e=>e.id===t)?{...e,hostUiRequests:e.hostUiRequests.filter(e=>e.id!==t)}:e,xV=(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(_V(e,t.snapshot));case`agent_start`:return n({...e,runStatus:`running`,lastError:void 0,metadata:hV(e.metadata,`running`)});case`agent_end`:{let r=t.willRetry===!0;return n({...e,runStatus:r?`running`:`idle`,streamingMessageIndex:void 0,metadata:hV(e.metadata,r?`running`:`idle`)})}case`message_start`:{let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:mV(t.message)?r.length-1:e.streamingMessageIndex})}case`message_update`:{if(e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length)return n({...e,messages:vV(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:vV(e.messages,e.streamingMessageIndex,t.message),streamingMessageIndex:void 0}):n({...e,streamingMessageIndex:void 0});case`tool_execution_start`:return n(yV(e,t.toolCallId,{toolName:t.toolName,args:t.args,status:`running`}));case`tool_execution_update`:return n(yV(e,t.toolCallId,{...t.toolName===void 0?{}:{toolName:t.toolName},partialResult:t.partialResult,status:`running`}));case`tool_execution_end`:return n(yV(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:gV(e.metadata,r,e.retry)})}case`compaction_end`:{let t={active:!1};return n({...e,compaction:t,metadata:gV(e.metadata,t,e.retry)})}case`auto_retry_start`:{let r={active:!0,attempt:t.attempt};return n({...e,retry:r,metadata:gV(e.metadata,e.compaction,r)})}case`auto_retry_end`:{let t={active:!1,attempt:0};return n({...e,retry:t,metadata:gV(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(bV(e,t.requestId));case`error`:return n({...e,lastError:t.error,runStatus:`failed`,metadata:hV(e.metadata,`failed`)});case`agent_settled`:case`entry_appended`:return n(e);default:return n(e)}},SV=e=>{let t=new Map,n=[];for(let r of e)r.toolCallId!==void 0&&wV(r)?t.has(r.toolCallId)?n.push(r):t.set(r.toolCallId,r):n.push(r);return{toolAssociated:t,freeStanding:n}},CV=(e,t)=>({requestId:e,confirmed:t}),wV=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`}}},TV=(e,t)=>{if(e.kind===`confirm`)return CV(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}},EV=e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(e.dismissed)return;if(typeof e.value==`string`)return e.value}},DV=(e,t)=>{let n=EV(t);return n===void 0?{requestId:e,dismissed:!0}:{requestId:e,value:n}};function OV(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}function kV(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 AV=e=>`pi-msg:${e}`,jV=e=>`pi-step:${e}`,MV=(e,t)=>/^data:/i.test(e)?e:`data:${t};base64,${e}`,NV=e=>new Date(typeof e.timestamp==`number`?e.timestamp:0),PV=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=OV(e.data);return[{type:`file`,data:t?.data??e.data,mediaType:t?.mimeType??e.mimeType}]})}},FV=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`))},IV=e=>typeof e==`string`?[{type:`text`,text:e}]:e.map(e=>e.type===`image`?{type:`image`,image:MV(e.data,e.mimeType)}:{type:`text`,text:e.text}),LV=(e,t)=>({type:`data`,name:e,data:t}),RV=e=>{let t=new Map;for(let n of e){if(n.role!==`toolResult`)continue;let e=n;t.set(e.toolCallId,{...PV(FV({content:e.content})),isError:e.isError,details:e.details})}return t},zV=(e,t,n,r,i,a)=>{let o=jV(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??PV(FV(s?.partialResult)),l=t?.isError??s?.status===`error`,u=a.get(n.id),d=u&&wV(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)}},BV=(e,t,n)=>{let r=e.lastAssistant,i=VV(e,t,n);return{id:AV(e.firstIndex),role:`assistant`,createdAt:NV(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}:{}}}}}},VV=(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`}},HV=e=>{let{messages:t}=e,n=RV(t),r=SV(e.hostUiRequests).toolAssociated,i=[],a=null,o=t=>{a&&=(i.push(BV(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},zV(a,s,c,e,n,r),l&&o(!0);break;case`toolResult`:break;case`user`:o(!1),i.push({id:AV(c),role:`user`,createdAt:NV(s),content:IV(s.content)});break;case`bashExecution`:{o(!1);let e=s;i.push(UV(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:AV(c),role:`assistant`,createdAt:NV(e),content:[LV(`pi-custom-message`,{customType:e.customType,details:e.details}),...IV(e.content)]});break}case`branchSummary`:{o(!1);let e=s;i.push(UV(c,e,`pi-branch-summary`,{summary:e.summary,fromId:e.fromId}));break}case`compactionSummary`:{o(!1);let e=s;i.push(UV(c,e,`pi-compaction-summary`,{summary:e.summary,tokensBefore:e.tokensBefore}));break}default:o(!1),i.push(UV(c,s,`pi-unsupported-message`,{role:s.role,message:s}))}}),o(!0),i},UV=(e,t,n,r)=>({id:AV(e),role:`assistant`,createdAt:NV(t),content:[LV(n,r)]}),WV=(e,t)=>e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():void 0,GV=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,KV=(e,t)=>{if(e===t)return!0;let n=WV(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(!KV(e[n],t[n]))return!1;return!0}if(GV(e)||GV(t)){if(!GV(e)||!GV(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)||!KV(e[r],t[r]))return!1;return!0}return!1},qV=(e,t)=>e.id===t.id&&e.role===t.role&&KV(e.createdAt,t.createdAt)&&KV(e.content,t.content)&&KV(e.status,t.status)&&KV(e.metadata,t.metadata),JV=(e,t)=>{let n=e.length!==t.length,r=e.map((e,r)=>{let i=t[r];return i&&qV(e,i)?i:(n=!0,e)});return n?r:t},YV=(e,t)=>JV(HV(e),t),XV={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},ZV=e=>Object.prototype.hasOwnProperty.call(XV,e),QV=e=>e instanceof Error?e.message:String(e),$V=e=>{if(typeof globalThis.requestAnimationFrame==`function`){globalThis.requestAnimationFrame(()=>e());return}setTimeout(e,16)},eH=e=>{for(let t of e)try{t()}catch(e){console.error(`[react-pi] Listener threw an error`,e)}},tH=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`]),nH=new Set([`message_update`,`tool_execution_update`]),rH=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`]),iH=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}},aH=e=>[...e.content,...e.attachments?.flatMap(e=>e.content??[])??[]],oH=(e,t)=>{let n=aH(e),r=[],i=[];for(let e of n)e.type===`text`?r.push(e.text):e.type===`image`&&i.push(iH(e.image));return{content:r.join(`
66
+
67
+ `),...i.length>0?{attachments:i}:{},...t?{streamingBehavior:t}:{}}},sH=e=>{let t=e.runConfig?.custom?.streamingBehavior;return t===`followUp`||t===`steer`?t:void 0},cH=e=>({role:`user`,content:e.attachments&&e.attachments.length>0?[{type:`text`,text:e.content},...e.attachments]:e.content,timestamp:Date.now()}),lH=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(`
68
+ `):null},uH=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`}},dH=class{state;stateSnapshot;projectedMessages=[];messageRepository=XA.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=pV(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:QV(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??sH(e)??(n?`followUp`:void 0),i=oH(e,r);if(this.ensureEventSubscription({includeSnapshot:!1}),n)return this.sendQueued(i,r??`followUp`);let a=cH(i);this.optimisticUserMessages.push({message:a,baseMessageCount:this.state.messages.length}),this.setState(uH(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:QV(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:QV(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:QV(e)}),e}}async setModel(e){try{await this.client.setModel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:QV(e)}),e}await this.refresh()}async setThinkingLevel(e){try{await this.client.setThinkingLevel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:QV(e)}),e}await this.refresh()}async respondToToolApproval(e,t){let n=this.state.hostUiRequests.find(t=>t.id===e);await this.respond(n?TV(n,{approvalId:e,approved:t}):CV(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(CV(n.id,t===!0)):await this.respond(DV(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:QV(e)}),e}let t=bV(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=xV(this.state,e),n=t!==this.state;n&&(this.state=t),this.reconcileOptimisticUserMessages(),n&&rH.has(e.type)&&this.notifyMetadataListeners(),n&&tH.has(e.type)&&(nH.has(e.type)?this.scheduleProjectedMessageFlush():this.recomputeProjectedMessagesAndNotify()),(!ZV(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=lH(t.message);this.state.messages.slice(t.baseMessageCount).some(e=>lH(e)===n)||e.push(t)}e.length!==this.optimisticUserMessages.length&&(this.optimisticUserMessages.length=0,this.optimisticUserMessages.push(...e))}projectMessages(){return YV({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=XA.fromArray(e),this.notifyMessageListeners()}scheduleProjectedMessageFlush(){this.messageFlushScheduled||(this.messageFlushScheduled=!0,(this.options.scheduleNotify??$V)(()=>{this.messageFlushScheduled=!1,this.recomputeProjectedMessagesAndNotify()}))}bumpVersion(){this.version+=1}publishState(){this.stateSnapshot=this.state,this.bumpVersion(),eH(this.allListeners)}notifyMetadataListeners(){this.stateSnapshot=this.state,this.bumpVersion(),eH(this.metadataListeners),eH(this.allListeners)}notifyMessageListeners(){this.stateSnapshot=this.state,this.bumpVersion(),eH(this.messageListeners),eH(this.allListeners)}},fH=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}}},pH=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 X(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}},mH=(e=>pH(fH(e)))(`usePiRuntime`),hH=pV(`__pending__`),gH=[],_H=XA.fromArray([]),vH=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()}}},yH=(e,t)=>{let n=e.controllers.get(t);if(n)return n;let r=new dH(e.client,t);return e.controllers.set(t,r),r},bH={getState:()=>hH,getProjectedMessages:()=>gH,getMessageRepository:()=>_H,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:()=>{}},xH=(e,t)=>{kV(`react-pi`,`onError`,e,t)},SH=(e,t)=>{let{freeStanding:n}=SV(t.hostUiRequests);return mH.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)})},CH=SH(bH,hH),wH=e=>e.getStateSnapshot?.()??e.getState(),TH=e=>{let t=(0,N.useCallback)(()=>wH(e),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribe(t),[e]),t,t)},EH=e=>{let t=(0,N.useCallback)(()=>e.getMessageRepository(),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribeMessages(t),[e]),t,t)},DH=e=>e.runStatus===`running`||e.compaction.active||e.retry.active,OH=(e,t)=>{let n=TH(e),r=EH(e),{adapters:i,isDisabled:a,isSendDisabled:o,onError:s,suggestions:c,unstable_capabilities:l}=t,u=n.loadState===`loading`,d=DH(n),f=(0,N.useEffectEvent)(e=>{xH(s,e)});(0,N.useEffect)(()=>{e!==bH&&e.load().catch(f)},[e]),(0,N.useEffect)(()=>{if(e!==bH&&d)return e.connect()},[e,d]);let p=(0,N.useMemo)(()=>SH(e,n),[e,n]),m=(0,N.useMemo)(()=>({items:n.queue.followUp.map((e,t)=>({id:dV(`followUp`,t),prompt:e,parts:[{type:`text`,text:e}]})),steerItems:n.queue.steering.map((e,t)=>({id:dV(`steer`,t),prompt:e,parts:[{type:`text`,text:e}]})),enqueue:t=>{e.sendMessage(t).catch(e=>xH(s,e))},steer:t=>{e.sendMessage(t,{streamingBehavior:`steer`}).catch(e=>xH(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 xH(s,e),e}},onCancel:async()=>{try{try{await e.clearQueue()}finally{await e.cancel()}}catch(e){throw xH(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(TV(n,t))}catch(e){throw xH(s,e),e}},onResumeToolCall:({toolCallId:t,payload:n})=>{e.resumeToolCall(t,n).catch(e=>xH(s,e))}}),[e,p,r,m,i,a,u,d,o,s,c,l])},kH=(e,t)=>({id:`pi-new-user:${t}`,role:`user`,createdAt:new Date,content:aH(e)}),AH=(e,t)=>{let n=Y(),{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)(()=>XA.fromArray(l),[l]);return(0,N.useMemo)(()=>({isDisabled:i??!1,isSendDisabled:a,unstable_capabilities:c,suggestions:s,isLoading:!1,isRunning:!1,messageRepository:f,extras:CH,...r?{adapters:r}:{},onNew:async t=>{let r=kH(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 yH(e,a??r).sendMessage(t),i()}catch(e){throw i(),xH(o,e),e}}}),[n,f,e,r,i,a,o,s,c])},jH=(e,t)=>{let n=X(e=>e.threadListItem),r=X(e=>e.threads.mainThreadId===e.threadListItem.id),i=n.externalId??n.remoteId,a=i?yH(e,i):bH,o=OH(r?a:bH,t),s=AH(e,t);return Ej(i?o:s)},MH=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}}}),NH=e=>{let{client:t}=e,n=(0,N.useMemo)(()=>vH(t),[t]);return(0,N.useEffect)(()=>(n.activate(),()=>n.dispose()),[n]),gM({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(MH)}),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=>MH((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:()=>jH(n,e)})},PH=()=>mH.use(e=>e,CH),FH=()=>mH.use(e=>e.metadata,null),IH=()=>{let e=mH.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 LH({delayDuration:e=0,...t}){return(0,P.jsx)(_d,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function RH({...e}){return(0,P.jsx)(vd,{"data-slot":`tooltip`,...e})}function zH({...e}){return(0,P.jsx)(yd,{"data-slot":`tooltip-trigger`,...e})}function BH({className:e,sideOffset:t=0,children:n,...r}){return(0,P.jsx)(bd,{children:(0,P.jsxs)(xd,{"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)(Sd,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function VH({...e}){return(0,P.jsx)(gi,{"data-slot":`dialog`,...e})}function HH({...e}){return(0,P.jsx)(vi,{"data-slot":`dialog-trigger`,...e})}function UH({...e}){return(0,P.jsx)(Si,{"data-slot":`dialog-portal`,...e})}function WH({className:e,...t}){return(0,P.jsx)(wi,{"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 GH({className:e,children:t,showCloseButton:n=!0,...r}){return(0,P.jsxs)(UH,{"data-slot":`dialog-portal`,children:[(0,P.jsx)(WH,{}),(0,P.jsxs)(Oi,{"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)(Fi,{"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)(Me,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function KH({className:e,...t}){return(0,P.jsx)(Ni,{"data-slot":`dialog-title`,className:a(`text-lg leading-none font-semibold`,e),...t})}function qH({className:e,size:t=`default`,...n}){return(0,P.jsx)(Gi,{"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 JH({className:e,...t}){return(0,P.jsx)(qi,{"data-slot":`avatar-image`,className:a(`aspect-square size-full`,e),...t})}function YH({className:e,...t}){return(0,P.jsx)(Yi,{"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 XH=(0,N.forwardRef)(({children:e,tooltip:t,side:n=`bottom`,className:r,...i},o)=>(0,P.jsx)(LH,{delayDuration:0,children:(0,P.jsxs)(RH,{children:[(0,P.jsx)(zH,{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)(BH,{side:n,children:t})]})}));XH.displayName=`TooltipIconButton`;var ZH=e=>Symbol.iterator in e,QH=e=>`entries`in e,$H=(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},eU=(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 tU(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:ZH(e)&&ZH(t)?QH(e)&&QH(t)?$H(e,t):eU(e,t):$H({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function nU(e){let t=N.useRef(void 0);return n=>{let r=e(n);return tU(t.current,r)?t.current:t.current=r}}var rU=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},iU=()=>{let{file:e,src:t}=X(nU(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 rU(e)??t},aU=({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)})},oU=({children:e})=>{let t=iU();return t?(0,P.jsxs)(VH,{children:[(0,P.jsx)(HH,{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)(GH,{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)(KH,{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)(aU,{src:t})})]})]}):e},sU=()=>{let e=iU();return(0,P.jsxs)(qH,{className:`aui-attachment-tile-avatar h-full w-full rounded-none`,children:[(0,P.jsx)(JH,{src:e,alt:`Attachment preview`,className:`aui-attachment-tile-image rounded-none object-cover`}),(0,P.jsx)(YH,{children:(0,P.jsx)(se,{className:`aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]`})})]})},cU=()=>{let e=Y().attachment.source!==`message`,t=X(e=>e.attachment.type===`image`),n=X(e=>{let t=e.attachment.type;switch(t){case`image`:return`Image`;case`document`:return`Document`;case`file`:return`File`;default:return t}}),r=X(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=X(e=>e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?e.attachment.status.message??`Upload failed`:void 0);return(0,P.jsx)(LH,{children:(0,P.jsxs)(RH,{children:[(0,P.jsxs)(xI.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)(oU,{children:(0,P.jsx)(zH,{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)(sU,{}),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)(fe,{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)(lU,{})]}),(0,P.jsxs)(BH,{side:`top`,children:[(0,P.jsx)(xI.Name,{}),s&&(0,P.jsx)(`p`,{className:`aui-attachment-error-message`,children:s})]})]})})},lU=()=>(0,P.jsx)(xI.Remove,{asChild:!0,children:(0,P.jsx)(XH,{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)(Me,{className:`aui-attachment-remove-icon size-3 stroke-[2.5]`})})}),uU=()=>(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)(Rz.Attachments,{children:()=>(0,P.jsx)(cU,{})})}),dU=()=>(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)(ER.Attachments,{children:()=>(0,P.jsx)(cU,{})})}),fU=()=>(0,P.jsx)(ER.AddAttachment,{asChild:!0,children:(0,P.jsx)(XH,{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)(ye,{className:`aui-attachment-add-icon size-4`})})}),pU=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 mU(e){let t=e.toLowerCase();return t.startsWith(`image/`)?ue:t===`application/pdf`?se:t===`application/json`?D:t.startsWith(`text/`)?se:t.startsWith(`audio/`)?he:t.startsWith(`video/`)?je:ce}function hU(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 gU(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 _U(e){return gU(/[\t\n\f\r ]/.test(e)?e.replace(/[\t\n\f\r ]/g,``):e)}function vU(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,``)),gU(i)):new TextEncoder().encode(i.replace(/%[\da-f]{2}/gi,`_`)).byteLength}function yU(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function bU({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(pU({variant:t,size:n,className:e})),...i,children:r})}function xU({mimeType:e,className:t,children:n,...r}){let i=e?mU(e):ce;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 SU({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 CU({bytes:e,className:t,...n}){return(0,P.jsx)(`span`,{"data-slot":`file-size`,className:a(`text-muted-foreground shrink-0`,t),...n,children:yU(e)})}function wU({data:e,mimeType:t,filename:n,sourceType:r,className:i,children:o,...s}){if(typeof e!=`string`)return null;let c=hU(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)(ie,{className:`size-4`})})}var TU=(0,N.memo)(({filename:e,data:t,mimeType:n,sourceType:r})=>{let i=hU(t,r);return(0,P.jsxs)(bU,{children:[(0,P.jsx)(xU,{mimeType:n}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,P.jsx)(SU,{children:e}),typeof t==`string`&&(i===`base64`||i===`data-uri`)&&(0,P.jsx)(CU,{bytes:i===`data-uri`?vU(t):_U(t),className:`text-xs`})]}),(0,P.jsx)(wU,{data:t,mimeType:n,...e!==void 0&&{filename:e},...r!==void 0&&{sourceType:r}})]})});TU.displayName=`File`,TU.Root=bU,TU.Icon=xU,TU.Name=SU,TU.Size=CU,TU.Download=wU;var EU=()=>{let e=X(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)(SB.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))})})},DU=()=>(0,P.jsx)(ZE,{condition:e=>!e.thread.isEmpty&&!e.thread.isRunning&&e.thread.suggestions.length>0,children:(0,P.jsx)(EU,{})}),OU=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`}},kU=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})},AU=e=>e.match(/^data:([^;,]+)/i)?.[1]?.toLowerCase(),jU=e=>{if(typeof document>`u`)return;let t=OU(AU(e.image)),n=e.filename??`image.${t}`,r=/^data:/i.test(e.image),i=r?kU(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)},MU=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)?kU(e.image):await fetch(e.image).then(e=>e.blob());if(!t)return;let n=AU(e.image)??t.type??`image/png`;await navigator.clipboard.write([new ClipboardItem({[n]:t})])},NU=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 PU({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(NU({variant:t,size:n,className:e})),...i,children:r})}function FU({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)(ue,{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)(le,{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 IU({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 LU({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,In.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)(Me,{className:`size-5`})})]}),document.body)]})}function RU({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)(fe,{className:`text-muted-foreground size-8 animate-spin`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Generating image…`})]})}function zU({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)(Ce,{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 BU({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)(be,{className:a(`size-4`,t&&`animate-spin`)})})}function VU({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:()=>jU(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)(ie,{className:`size-4`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{MU(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)(M,{className:`size-4`})}),t&&(0,P.jsx)(BU,{onRegenerate:t})]})}var HU=(0,N.memo)(e=>{let{image:t,filename:n,status:r}=e;return r?.type===`running`?(0,P.jsxs)(PU,{children:[(0,P.jsx)(RU,{}),(0,P.jsx)(IU,{children:n})]}):r?.type===`incomplete`&&r.reason===`content-filter`?(0,P.jsx)(PU,{children:(0,P.jsx)(zU,{reason:`The provider blocked this image.`})}):(0,P.jsxs)(PU,{children:[(0,P.jsx)(LU,{src:t,alt:n||`Image content`,children:(0,P.jsx)(FU,{src:t,alt:n||`Image content`})}),(0,P.jsx)(IU,{children:n})]})});HU.displayName=`Image`,HU.Root=PU,HU.Preview=FU,HU.Filename=IU,HU.Zoom=LU,HU.Actions=VU,HU.Generating=RU,HU.ContentFilterError=zU;var UU=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),WU=(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))&&UU(e.children,t.children)},GU=(e,t)=>WU(e.node,t.node),KU=(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}),GU)]})),qU=(0,N.createContext)(null),JU=()=>(0,N.useContext)(qU)!==null,YU=(0,N.memo)(({children:e,fallbackPre:t,...n})=>n.node?.children.some(e=>e.type===`element`&&e.tagName===`code`)??!0?(0,P.jsx)(qU.Provider,{value:n,children:e}):(0,P.jsx)(t,{...n,children:e}),(e,t)=>e.fallbackPre===t.fallbackPre&&GU(e,t)),XU=({node:e,...t})=>(0,P.jsx)(`pre`,{...t}),ZU=({node:e,...t})=>(0,P.jsx)(`code`,{...t}),QU=({node:e,components:{Pre:t,Code:n},code:r})=>(0,P.jsx)(t,{children:(0,P.jsx)(n,{node:e,children:r})}),$U=()=>null,eW=e=>/language-([^\s]+)/.exec(e??``)?.[1]??``,tW=({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})]})},nW=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),rW=({className:e,...t})=>({className:n,...r})=>({className:(0,nW.default)(e,n),...t,...r});function iW(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=``;for(let n of e)t+=iW(n);return t}return(0,N.isValidElement)(e)?iW(e.props.children):``}var aW=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=rW((0,N.useContext)(qU)),l=rn(e=>(0,P.jsx)(t,{...c(e)})),u=rW(s),d=rn(e=>(0,P.jsx)(n,{...u(e)})),f=eW(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:iW(o)}),(0,P.jsx)(QU,{node:e,components:{Pre:l,Code:d},code:o})]}):(0,P.jsx)(tW,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:p,CodeHeader:m},language:f,code:o??``})},oW=({node:e,components:t,componentsByLanguage:n,...r})=>JU()?(0,P.jsx)(aW,{node:e,components:t,componentsByLanguage:n,...r}):(0,P.jsx)(t.Code,{...r}),sW=(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},cW=(0,N.memo)(oW,(e,t)=>e.components===t.components&&sW(e.componentsByLanguage,t.componentsByLanguage)&&GU(e,t));function lW(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var uW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fW={};function pW(e,t){return((t||fW).jsx?dW:uW).test(e)}var mW=/[ \t\n\f\r]/g;function hW(e){return typeof e==`object`?e.type===`text`&&gW(e.value):gW(e)}function gW(e){return e.replace(mW,``)===``}var _W=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};_W.prototype.normal={},_W.prototype.property={},_W.prototype.space=void 0;function vW(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new _W(n,r,t)}function yW(e){return e.toLowerCase()}var bW=class{constructor(e,t){this.attribute=t,this.property=e}};bW.prototype.attribute=``,bW.prototype.booleanish=!1,bW.prototype.boolean=!1,bW.prototype.commaOrSpaceSeparated=!1,bW.prototype.commaSeparated=!1,bW.prototype.defined=!1,bW.prototype.mustUseProperty=!1,bW.prototype.number=!1,bW.prototype.overloadedBoolean=!1,bW.prototype.property=``,bW.prototype.spaceSeparated=!1,bW.prototype.space=void 0;var xW=e({boolean:()=>Z,booleanish:()=>CW,commaOrSpaceSeparated:()=>DW,commaSeparated:()=>EW,number:()=>Q,overloadedBoolean:()=>wW,spaceSeparated:()=>TW}),SW=0,Z=OW(),CW=OW(),wW=OW(),Q=OW(),TW=OW(),EW=OW(),DW=OW();function OW(){return 2**++SW}var kW=Object.keys(xW),AW=class extends bW{constructor(e,t,n,r){let i=-1;if(super(e,t),jW(this,`space`,r),typeof n==`number`)for(;++i<kW.length;){let e=kW[i];jW(this,kW[i],(n&xW[e])===xW[e])}}};AW.prototype.defined=!0;function jW(e,t,n){n&&(e[t]=n)}function MW(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new AW(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[yW(r)]=r,n[yW(a.attribute)]=r}return new _W(t,n,e.space)}var NW=MW({properties:{ariaActiveDescendant:null,ariaAtomic:CW,ariaAutoComplete:null,ariaBusy:CW,ariaChecked:CW,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:TW,ariaCurrent:null,ariaDescribedBy:TW,ariaDetails:null,ariaDisabled:CW,ariaDropEffect:TW,ariaErrorMessage:null,ariaExpanded:CW,ariaFlowTo:TW,ariaGrabbed:CW,ariaHasPopup:null,ariaHidden:CW,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:TW,ariaLevel:Q,ariaLive:null,ariaModal:CW,ariaMultiLine:CW,ariaMultiSelectable:CW,ariaOrientation:null,ariaOwns:TW,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:CW,ariaReadOnly:CW,ariaRelevant:null,ariaRequired:CW,ariaRoleDescription:TW,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:CW,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function PW(e,t){return t in e?e[t]:t}function FW(e,t){return PW(e,t.toLowerCase())}var IW=MW({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:EW,acceptCharset:TW,accessKey:TW,action:null,allow:null,allowFullScreen:Z,allowPaymentRequest:Z,allowUserMedia:Z,alpha:Z,alt:null,as:null,async:Z,autoCapitalize:null,autoComplete:TW,autoFocus:Z,autoPlay:Z,blocking:TW,capture:null,charSet:null,checked:Z,cite:null,className:TW,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:CW,controls:Z,controlsList:TW,coords:Q|EW,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Z,defer:Z,dir:null,dirName:null,disabled:Z,download:wW,draggable:CW,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Z,formTarget:null,headers:TW,height:Q,hidden:wW,high:Q,href:null,hrefLang:null,htmlFor:TW,httpEquiv:TW,id:null,imageSizes:null,imageSrcSet:null,inert:Z,inputMode:null,integrity:null,is:null,isMap:Z,itemId:null,itemProp:TW,itemRef:TW,itemScope:Z,itemType:TW,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Z,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Z,muted:Z,name:null,nonce:null,noModule:Z,noValidate:Z,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:Z,optimum:Q,pattern:null,ping:TW,placeholder:null,playsInline:Z,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Z,referrerPolicy:null,rel:TW,required:Z,reversed:Z,rows:Q,rowSpan:Q,sandbox:TW,scope:null,scoped:Z,seamless:Z,selected:Z,shadowRootClonable:Z,shadowRootCustomElementRegistry:Z,shadowRootDelegatesFocus:Z,shadowRootMode:null,shadowRootSerializable:Z,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:CW,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Z,useMap:null,value:CW,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:TW,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Z,declare:Z,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Z,noHref:Z,noShade:Z,noWrap:Z,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:CW,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Z,disablePictureInPicture:Z,disableRemotePlayback:Z,exportParts:EW,part:TW,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:FW}),LW=MW({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:DW,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:TW,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:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Z,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,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:EW,g2:EW,glyphName:EW,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:DW,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,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:Q,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:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:TW,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:DW,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:DW,rev:DW,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:DW,requiredFeatures:DW,requiredFonts:DW,requiredFormats:DW,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:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:DW,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:DW,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:DW,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:PW}),RW=MW({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()}}),zW=MW({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:FW}),BW=MW({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),VW={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`},HW=/[A-Z]/g,UW=/-[a-z]/g,WW=/^data[-\w.:]+$/i;function GW(e,t){let n=yW(t),r=t,i=bW;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&WW.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(UW,qW);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!UW.test(e)){let n=e.replace(HW,KW);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=AW}return new i(r,t)}function KW(e){return`-`+e.toLowerCase()}function qW(e){return e.charAt(1).toUpperCase()}var JW=vW([NW,IW,RW,zW,BW],`html`),YW=vW([NW,LW,RW,zW,BW],`svg`);function XW(e){return e.join(` `).trim()}var ZW=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(`
69
+ `);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})),QW=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(ZW());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}})),$W=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))}})),eG=r(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(QW()),r=$W();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})),tG=rG(`end`),nG=rG(`start`);function rG(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 iG(e){let t=nG(e),n=tG(e);if(t&&n)return{start:t,end:n}}function aG(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?sG(e.position):`start`in e||`end`in e?sG(e):`line`in e||`column`in e?oG(e):``}function oG(e){return cG(e&&e.line)+`:`+cG(e&&e.column)}function sG(e){return oG(e&&e.start)+`-`+oG(e&&e.end)}function cG(e){return e&&typeof e==`number`?e:1}var lG=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=aG(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}};lG.prototype.file=``,lG.prototype.name=``,lG.prototype.reason=``,lG.prototype.message=``,lG.prototype.stack=``,lG.prototype.column=void 0,lG.prototype.line=void 0,lG.prototype.ancestors=void 0,lG.prototype.cause=void 0,lG.prototype.fatal=void 0,lG.prototype.place=void 0,lG.prototype.ruleId=void 0,lG.prototype.source=void 0;var uG=n(eG(),1),dG={}.hasOwnProperty,fG=new Map,pG=/[A-Z]/g,mG=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),hG=new Set([`td`,`th`]),gG=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function _G(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=OG(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=DG(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`?YW:JW,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=vG(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function vG(e,t,n){if(t.type===`element`)return yG(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return bG(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return SG(e,t,n);if(t.type===`mdxjsEsm`)return xG(e,t);if(t.type===`root`)return CG(e,t,n);if(t.type===`text`)return wG(e,t)}function yG(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=YW,e.schema=i),e.ancestors.push(t);let a=PG(e,t.tagName,!1),o=kG(e,t),s=jG(e,t);return mG.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!hW(e)})),TG(e,o,a,t),EG(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function bG(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)}FG(e,t.position)}function xG(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);FG(e,t.position)}function SG(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=YW,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:PG(e,t.name,!0),o=AG(e,t),s=jG(e,t);return TG(e,o,a,t),EG(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function CG(e,t,n){let r={};return EG(r,jG(e,t)),e.create(t,e.Fragment,r,n)}function wG(e,t){return t.value}function TG(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function EG(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function DG(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 OG(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=nG(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 kG(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&dG.call(t.properties,i)){let a=MG(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&hG.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 AG(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 FG(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 FG(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function jG(e,t){let n=[],r=-1,i=e.passKeys?new Map:fG;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=vG(e,a,o);s!==void 0&&n.push(s)}return n}function MG(e,t,n){let r=GW(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?lW(n):XW(n)),r.property===`style`){let t=typeof n==`object`?n:NG(e,String(n));return e.stylePropertyNameCase===`css`&&(t=IG(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?VW[r.property]||r.property:r.attribute,n]}}function NG(e,t){try{return(0,uG.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new lG("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=gG+`#cannot-parse-style-attribute`,r}}function PG(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=pW(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=pW(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return dG.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);FG(e)}function FG(e,t){let n=new lG("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=gG+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function IG(e){let t={},n;for(n in e)dG.call(e,n)&&(t[LG(n)]=e[n]);return t}function LG(e){let t=e.replace(pG,RG);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function RG(e){return`-`+e.toLowerCase()}var zG={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`]},BG={};function VG(e,t){let n=t||BG;return HG(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function HG(e,t,n){if(WG(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 UG(e.children,t,n)}return Array.isArray(e)?UG(e,t,n):``}function UG(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=HG(e[i],t,n);return r.join(``)}function WG(e){return!!(e&&typeof e==`object`)}var GG=document.createElement(`i`);function KG(e){let t=`&`+e+`;`;GG.innerHTML=t;let n=GG.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function qG(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 JG(e,t){return e.length>0?(qG(e,e.length,0,t),e):t}var YG={}.hasOwnProperty;function XG(e){let t={},n=-1;for(;++n<e.length;)ZG(t,e[n]);return t}function ZG(e,t){let n;for(n in t){let r=(YG.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){YG.call(r,a)||(r[a]=[]);let e=i[a];QG(r[a],Array.isArray(e)?e:e?[e]:[])}}}function QG(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);qG(e,0,0,r)}function $G(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 eK(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var tK=fK(/[A-Za-z]/),nK=fK(/[\dA-Za-z]/),rK=fK(/[#-'*+\--9=?A-Z^-~]/);function iK(e){return e!==null&&(e<32||e===127)}var aK=fK(/\d/),oK=fK(/[\dA-Fa-f]/),sK=fK(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function cK(e){return e!==null&&(e<0||e===32)}function lK(e){return e===-2||e===-1||e===32}var uK=fK(/\p{P}|\p{S}/u),dK=fK(/\s/);function fK(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function pK(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&nK(e.charCodeAt(n+1))&&nK(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 mK(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return lK(r)?(e.enter(n),s(r)):t(r)}function s(r){return lK(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var hK={tokenize:gK};function gK(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`),mK(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 $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var _K={tokenize:yK},vK={tokenize:bK};function yK(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 qG(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(vK,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(vK,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 $(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++;qG(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 bK(e,t,n){return mK(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function xK(e){if(e===null||cK(e)||dK(e))return 1;if(uK(e))return 2}function SK(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 CK={name:`attention`,resolveAll:wK,tokenize:TK};function wK(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};EK(d,-c),EK(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=JG(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=JG(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=JG(l,SK(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=JG(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=JG(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,qG(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 TK(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=xK(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=xK(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 EK(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var DK={name:`autolink`,tokenize:OK};function OK(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 tK(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||nK(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||nK(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||iK(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):rK(t)?(e.consume(t),l):n(t)}function u(e){return nK(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||nK(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var kK={partial:!0,tokenize:AK};function AK(e,t,n){return r;function r(t){return lK(t)?mK(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var jK={continuation:{tokenize:NK},exit:PK,name:`blockQuote`,tokenize:MK};function MK(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 lK(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function NK(e,t,n){let r=this;return i;function i(t){return lK(t)?mK(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(jK,t,n)(r)}}function PK(e){e.exit(`blockQuote`)}var FK={name:`characterEscape`,tokenize:IK};function IK(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 sK(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var LK={name:`characterReference`,tokenize:RK};function RK(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=nK,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=oK,u):(e.enter(`characterReferenceValue`),a=7,o=aK,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===nK&&!KG(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 zK={partial:!0,tokenize:HK},BK={concrete:!0,name:`codeFenced`,tokenize:VK};function VK(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`),lK(t)?mK(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(zK,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):lK(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),mK(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(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&&lK(t)?mK(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(zK,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(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`),lK(t)?mK(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`),lK(t)?mK(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function HK(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 UK={name:`codeIndented`,tokenize:GK},WK={partial:!0,tokenize:KK};function GK(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),mK(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):$(t)?e.attempt(WK,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||$(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function KK(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):mK(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):$(e)?i(e):n(e)}}var qK={name:`codeText`,previous:YK,resolve:JK,tokenize:XK};function JK(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 YK(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function XK(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)):$(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||$(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 ZK=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&&QK(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),QK(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),QK(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);QK(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);QK(this.left,t.reverse())}}}};function QK(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 $K(e){let t={},n=-1,r,i,a,o,s,c,l,u=new ZK(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,eq(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 qG(e,0,1/0,u.slice(0)),!l}function eq(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 tq={resolve:rq,tokenize:iq},nq={partial:!0,tokenize:aq};function rq(e){return $K(e),e}function iq(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):$(t)?e.check(nq,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 aq(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),mK(e,a,`linePrefix`)}function a(i){if(i===null||$(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 oq(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||iK(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||$(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||cK(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||iK(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 sq(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):$(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||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!lK(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function cq(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):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),mK(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(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 lq(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):lK(i)?mK(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var uq={name:`definition`,tokenize:fq},dq={partial:!0,tokenize:pq};function fq(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return sq.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=eK(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 cK(t)?lq(e,l)(t):l(t)}function l(t){return oq(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(dq,d,d)(t)}function d(t){return lK(t)?mK(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function pq(e,t,n){return r;function r(t){return cK(t)?lq(e,i)(t):n(t)}function i(t){return cq(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return lK(t)?mK(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var mq={name:`hardBreakEscape`,tokenize:hq};function hq(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var gq={name:`headingAtx`,resolve:_q,tokenize:vq};function _q(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`},qG(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function vq(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||cK(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):lK(n)?mK(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||cK(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var yq=`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(`.`),bq=[`pre`,`script`,`style`,`textarea`],xq={concrete:!0,name:`htmlFlow`,resolveTo:wq,tokenize:Tq},Sq={partial:!0,tokenize:Dq},Cq={partial:!0,tokenize:Eq};function wq(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 Tq(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:M):tK(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):tK(a)?(e.consume(a),i=4,r.interrupt?t:M):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:M):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 tK(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||cK(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&bq.includes(l)?(i=1,r.interrupt?t(s):O(s)):yq.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||nK(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 lK(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||tK(t)?(e.consume(t),b):lK(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||nK(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):lK(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):lK(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(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||cK(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||lK(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):lK(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),te):t===62&&i===4?(e.consume(t),ie):t===63&&i===3?(e.consume(t),M):t===93&&i===5?(e.consume(t),re):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Sq,ae,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Cq,ee,ae)(t)}function ee(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A}function A(t){return t===null||$(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),M):O(t)}function te(t){return t===47?(e.consume(t),o=``,ne):O(t)}function ne(t){if(t===62){let n=o.toLowerCase();return bq.includes(n)?(e.consume(t),ie):O(t)}return tK(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ne):O(t)}function re(t){return t===93?(e.consume(t),M):O(t)}function M(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),M):O(t)}function ie(t){return t===null||$(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),ie)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function Eq(e,t,n){let r=this;return i;function i(t){return $(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 Dq(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(kK,t,n)}}var Oq={name:`htmlText`,tokenize:kq};function kq(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):tK(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):tK(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):$(t)?(o=d,te(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(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):$(t)?(o=h,te(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):$(t)?(o=v,te(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,te(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return tK(t)?(e.consume(t),S):n(t)}function S(t){return t===45||nK(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,te(t)):lK(t)?(e.consume(t),C):j(t)}function w(t){return t===45||nK(t)?(e.consume(t),w):t===47||t===62||cK(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||tK(t)?(e.consume(t),E):$(t)?(o=T,te(t)):lK(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||nK(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,te(t)):lK(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):$(t)?(o=O,te(t)):lK(t)?(e.consume(t),O):(e.consume(t),ee)}function k(t){return t===i?(e.consume(t),i=void 0,A):t===null?n(t):$(t)?(o=k,te(t)):(e.consume(t),k)}function ee(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||cK(t)?T(t):(e.consume(t),ee)}function A(e){return e===47||e===62||cK(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function te(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return lK(t)?mK(e,re,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):re(t)}function re(t){return e.enter(`htmlTextData`),o(t)}}var Aq={name:`labelEnd`,resolveAll:Pq,resolveTo:Fq,tokenize:Iq},jq={tokenize:Lq},Mq={tokenize:Rq},Nq={tokenize:zq};function Pq(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&&qG(e,0,e.length,n),e}function Fq(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=JG(s,e.slice(a+1,a+r+3)),s=JG(s,[[`enter`,u,t]]),s=JG(s,SK(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=JG(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=JG(s,e.slice(o+1)),s=JG(s,[[`exit`,c,t]]),qG(e,a,e.length,s),e}function Iq(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(eK(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(jq,u,o?u:d)(t):t===91?e.attempt(Mq,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Nq,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Lq(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 cK(t)?lq(e,a)(t):a(t)}function a(t){return t===41?u(t):oq(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return cK(t)?lq(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?cq(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return cK(t)?lq(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 Rq(e,t,n){let r=this;return i;function i(t){return sq.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(eK(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function zq(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 Bq={name:`labelStartImage`,resolveAll:Aq.resolveAll,tokenize:Vq};function Vq(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 Hq={name:`labelStartLink`,resolveAll:Aq.resolveAll,tokenize:Uq};function Uq(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 Wq={name:`lineEnding`,tokenize:Gq};function Gq(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),mK(e,t,`linePrefix`)}}var Kq={name:`thematicBreak`,tokenize:qq};function qq(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||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),lK(t)?mK(e,s,`whitespace`)(t):s(t))}}var Jq={continuation:{tokenize:Qq},exit:eJ,name:`list`,tokenize:Zq},Yq={partial:!0,tokenize:tJ},Xq={partial:!0,tokenize:$q};function Zq(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:aK(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(Kq,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 aK(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(kK,r.interrupt?n:u,e.attempt(Yq,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return lK(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 Qq(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(kK,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,mK(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!lK(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(Xq,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,mK(e,e.attempt(Jq,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function $q(e,t,n){let r=this;return mK(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 eJ(e){e.exit(this.containerState.type)}function tJ(e,t,n){let r=this;return mK(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!lK(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var nJ={name:`setextUnderline`,resolveTo:rJ,tokenize:iJ};function rJ(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 iJ(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`),lK(t)?mK(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var aJ={tokenize:oJ};function oJ(e){let t=this,n=e.attempt(kK,r,e.attempt(this.parser.constructs.flowInitial,i,mK(e,e.attempt(this.parser.constructs.flow,i,e.attempt(tq,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 sJ={resolveAll:dJ()},cJ=uJ(`string`),lJ=uJ(`text`);function uJ(e){return{resolveAll:dJ(e===`text`?fJ: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 dJ(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 fJ(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 pJ=e({attentionMarkers:()=>xJ,contentInitial:()=>hJ,disable:()=>SJ,document:()=>mJ,flow:()=>_J,flowInitial:()=>gJ,insideSpan:()=>bJ,string:()=>vJ,text:()=>yJ}),mJ={42:Jq,43:Jq,45:Jq,48:Jq,49:Jq,50:Jq,51:Jq,52:Jq,53:Jq,54:Jq,55:Jq,56:Jq,57:Jq,62:jK},hJ={91:uq},gJ={[-2]:UK,[-1]:UK,32:UK},_J={35:gq,42:Kq,45:[nJ,Kq],60:xq,61:nJ,95:Kq,96:BK,126:BK},vJ={38:LK,92:FK},yJ={[-5]:Wq,[-4]:Wq,[-3]:Wq,33:Bq,38:LK,42:CK,60:[DK,Oq],91:Hq,92:[mq,FK],93:Aq,95:CK,96:qK},bJ={null:[CK,sJ]},xJ={null:[42,95]},SJ={null:[]};function CJ(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=JG(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=SK(a,l.events,l),l.events):[]}function f(e,t){return TJ(p(e),t)}function p(e){return wJ(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){$(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&&qG(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 wJ(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 TJ(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=`
70
+ `;break;case-3:o=`\r
71
+ `;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 EJ(e){let t={constructs:XG([pJ,...(e||{}).extensions||[]]),content:n(hK),defined:[],document:n(_K),flow:n(aJ),lazy:{},string:n(cJ),text:n(lJ)};return t;function n(e){return n;function n(n){return CJ(t,e,n)}}}function DJ(e){for(;!$K(e););return e}var OJ=/[\0\t\n\r]/g;function kJ(){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(OJ.lastIndex=u,c=OJ.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 AJ=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function jJ(e){return e.replace(AJ,MJ)}function MJ(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return $G(n.slice(t?2:1),t?16:10)}return KG(n)||e}var NJ={}.hasOwnProperty;function PJ(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),FJ(n)(DJ(EJ(n).document().write(kJ()(e,t,!0))))}function FJ(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(A),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(ee),htmlTextData:E,image:c(te),label:re,labelText:ne,lineEnding:D,link:c(j),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:M,resourceTitleString:ie,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};LJ(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]];NJ.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]||zJ).call(a,void 0,e[0])}for(r.position={start:IJ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:IJ(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:IJ(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]||zJ).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+aG({start:e.start,end:e.end})+`): it’s not open`);n.position.end=IJ(e.end)}function u(){return VG(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=eK(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:IJ(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=IJ(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=IJ(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 ee(){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.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(){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 ne(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=jJ(t),n.identifier=eK(t).toLowerCase()}function re(){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 M(){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=eK(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=$G(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=KG(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=IJ(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 IJ(e){return{line:e.line,column:e.column,offset:e.offset}}function LJ(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?LJ(e,r):RJ(e,r)}}function RJ(e,t){let n;for(n in t)if(NJ.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 zJ(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+aG({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+aG({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+aG({start:t.start,end:t.end})+`) is still open`)}function BJ(e){let t=this;t.parser=n;function n(n){return PJ(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function VJ(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 HJ(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
72
+ `}]}function UJ(e,t){let n=t.value?t.value+`
73
+ `:``,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 WJ(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GJ(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function KJ(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=pK(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 qJ(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 JJ(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function YJ(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 XJ(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return YJ(e,t);let i={src:pK(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 ZJ(e,t){let n={src:pK(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 QJ(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 $J(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return YJ(e,t);let i={href:pK(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 eY(e,t){let n={href:pK(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 tY(e,t,n){let r=e.all(t),i=n?nY(n):rY(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:`
74
+ `}),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:`
75
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function nY(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=rY(n[r])}return t}function rY(e){return e.spread??e.children.length>1}function iY(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 aY(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oY(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function sY(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cY(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=nG(t.children[1]),o=tG(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 lY(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 uY(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var dY=9,fY=32;function pY(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(mY(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(mY(t.slice(i),i>0,!1)),a.join(``)}function mY(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===dY||t===fY;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===dY||t===fY;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function hY(e,t){let n={type:`text`,value:pY(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function gY(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var _Y={blockquote:VJ,break:HJ,code:UJ,delete:WJ,emphasis:GJ,footnoteReference:KJ,heading:qJ,html:JJ,imageReference:XJ,image:ZJ,inlineCode:QJ,linkReference:$J,link:eY,listItem:tY,list:iY,paragraph:aY,root:oY,strong:sY,table:cY,tableCell:uY,tableRow:lY,text:hY,thematicBreak:gY,toml:vY,yaml:vY,definition:vY,footnoteDefinition:vY};function vY(){}var{defineProperty:yY}=Object,bY=typeof self==`object`?self:globalThis,xY=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new bY[e](t)},SY=(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__`?yY(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 bY[e]==`function`?xY(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(xY(a,o),i)};return r},CY=e=>SY(new Map,e)(0),wY=``,{toString:TY}={},{keys:EY,is:DY}=Object,OY=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=TY.call(e).slice(8,-1);switch(n){case`Array`:return[1,wY];case`Object`:return[2,wY];case`Date`:return[3,wY];case`RegExp`:return[4,wY];case`Map`:return[5,wY];case`Set`:return[6,wY];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},kY=([e,t])=>e===0&&(t===`function`||t===`symbol`),AY=(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]=OY(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&DY(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 EY(o))(e||!kY(OY(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?wY: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||!(kY(OY(n))||kY(OY(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!kY(OY(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},jY=(e,{json:t,lossy:n}={})=>{let r=[];return AY(!(t||n),!!t,new Map,r)(e),r},MY=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?CY(jY(e,t)):structuredClone(e):(e,t)=>CY(jY(e,t));function NY(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 PY(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function FY(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||NY,r=e.options.footnoteBackLabel||PY,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=pK(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:{...MY(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
76
+ `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
77
+ `}]}}var IY=(function(e){if(e==null)return VY;if(typeof e==`function`)return BY(e);if(typeof e==`object`)return Array.isArray(e)?LY(e):RY(e);if(typeof e==`string`)return zY(e);throw Error(`Expected function, string, or object as test`)});function LY(e){let t=[],n=-1;for(;++n<e.length;)t[n]=IY(e[n]);return BY(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function RY(e){let t=e;return BY(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function zY(e){return BY(t);function t(t){return t&&t.type===e}}function BY(e){return t;function t(t,n,r){return!!(HY(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function VY(){return!0}function HY(e){return typeof e==`object`&&!!e&&`type`in e}function UY(e){return e}var WY=[];function GY(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=IY(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 (`+UY(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=WY,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=KY(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 KY(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?WY:[e]}function qY(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),GY(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 JY={}.hasOwnProperty,YY={};function XY(e,t){let n=t||YY,r=new Map,i=new Map,a={all:s,applyData:QY,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{..._Y,...n.handlers},one:o,options:n,patch:ZY,wrap:eX};return qY(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(JY.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=MY(n);return r.children=a.all(e),r}return MY(e)}return(a.options.unknownHandler||$Y)(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=tX(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=tX(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function ZY(e,t){e.position&&(t.position=iG(e))}function QY(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,MY(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function $Y(e,t){let n=t.data||{},r=`value`in t&&!(JY.call(n,`hProperties`)||JY.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 eX(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
78
+ `});++r<e.length;)r&&n.push({type:`text`,value:`
79
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
80
+ `}),n}function tX(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function nX(e,t){let n=XY(e,t),r=n.one(e,void 0),i=FY(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
81
+ `},i)),a}function rX(e,t){return e&&`run`in e?async function(n,r){let i=nX(n,{file:r,...t});await e.run(i,r)}:function(n,r){return nX(n,{file:r,...e||t})}}function iX(e){if(e)throw e}var aX=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 oX(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 sX(){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?cX(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 cX(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 lX={basename:uX,dirname:dX,extname:fX,join:pX,sep:`/`};function uX(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);gX(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 dX(e){if(gX(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 fX(e){gX(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 pX(...e){let t=-1,n;for(;++t<e.length;)gX(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:mX(n)}function mX(e){gX(e);let t=e.codePointAt(0)===47,n=hX(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function hX(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 gX(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var _X={cwd:vX};function vX(){return`/`}function yX(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function bX(e){if(typeof e==`string`)e=new URL(e);else if(!yX(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 xX(e)}function xX(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 SX=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],CX=class{constructor(e){let t;t=e?yX(e)?{path:e}:typeof e==`string`||DX(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:_X.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<SX.length;){let e=SX[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)SX.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?lX.basename(this.path):void 0}set basename(e){TX(e,`basename`),wX(e,`basename`),this.path=lX.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?lX.dirname(this.path):void 0}set dirname(e){EX(this.basename,`dirname`),this.path=lX.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?lX.extname(this.path):void 0}set extname(e){if(wX(e,`extname`),EX(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=lX.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){yX(e)&&(e=bX(e)),TX(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?lX.basename(this.path,this.extname):void 0}set stem(e){TX(e,`stem`),wX(e,`stem`),this.path=lX.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 lG(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 wX(e,t){if(e&&e.includes(lX.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+lX.sep+"`")}function TX(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function EX(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function DX(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var OX=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),kX=n(aX(),1),AX={}.hasOwnProperty,jX=new class e extends OX{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=sX()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,kX.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(PX(`data`,this.frozen),this.namespace[e]=t,this):AX.call(this.namespace,e)&&this.namespace[e]||void 0:e?(PX(`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=LX(e),n=this.parser||this.Parser;return MX(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),MX(`process`,this.parser||this.Parser),NX(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=LX(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);zX(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(),MX(`processSync`,this.parser||this.Parser),NX(`processSync`,this.compiler||this.Compiler),this.process(e,r),IX(`processSync`,`process`,t),n;function r(e,r){t=!0,iX(e),n=r}}run(e,t,n){FX(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=LX(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),IX(`runSync`,`run`,n),r;function i(e,t){iX(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=LX(t),r=this.compiler||this.Compiler;return NX(`stringify`,r),FX(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(PX(`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,kX.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];oX(o)&&oX(r)&&(r=(0,kX.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function MX(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function NX(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function PX(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 FX(e){if(!oX(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function IX(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function LX(e){return RX(e)?e:new CX(e)}function RX(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function zX(e){return typeof e==`string`||BX(e)}function BX(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var VX=[],HX={allowDangerousHtml:!0},UX=/^(https?|ircs?|mailto|xmpp)$/i,WX=[{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 GX(e){let t=KX(e),n=qX(e);return JX(t.runSync(t.parse(n),n),e)}function KX(e){let t=e.rehypePlugins||VX,n=e.remarkPlugins||VX,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...HX}:HX;return jX().use(BJ).use(n).use(rX,r).use(t)}function qX(e){let t=e.children||``,n=new CX;return typeof t==`string`?n.value=t:``+t,n}function JX(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||YX;for(let e of WX)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return qY(e,l),_G(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 zG)if(Object.hasOwn(zG,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=zG[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 YX(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||UX.test(e.slice(0,t))?e:``}var{useSmooth:XX,useSmoothStatus:ZX,withSmoothContextProvider:QX}=uV,$X=(0,N.memo)(({text:e,overrideVersion:t,...n})=>(0,P.jsx)(GX,{...n,children:e}));$X.displayName=`MarkdownRenderer`;var eZ=({text:e,...t})=>{let n=(0,N.useDeferredValue)(e);return(0,P.jsx)($X,{text:n,...t})},tZ=e=>typeof e==`object`&&!!e&&!Array.isArray(e),nZ=(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(!nZ(e[r],t[r],n-1))return!1;return!0}if(tZ(e)&&tZ(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&nZ(e[r],t[r],n-1))}return!1};function rZ(e,t){let n=(0,N.useRef)(e);return nZ(e,n.current,t)||(n.current=e),n.current}function iZ(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)&&nZ(n(e,r),n(t.current,r)))||(t.current=e),t.current}var aZ=({components:e,componentsByLanguage:t,smooth:n=!0,defer:r=!1,preprocess:i,...a})=>{let{text:o}=XX(kR(),n),s=(0,N.useMemo)(()=>i?i(o):o,[i,o]),{pre:c=XU,code:l=ZU,SyntaxHighlighter:u=QU,CodeHeader:d=$U}=e??{},f=(0,N.useMemo)(()=>({Pre:c,Code:l,SyntaxHighlighter:u,CodeHeader:d}),[c,l,u,d]),p=rn(e=>(0,P.jsx)(cW,{components:f,componentsByLanguage:t,...e})),m=rn(e=>(0,P.jsx)(YU,{fallbackPre:c,...e})),h=iZ((0,N.useMemo)(()=>{let{pre:t,code:n,SyntaxHighlighter:r,CodeHeader:i,...a}=e??{};return{...a,pre:m,code:p}},[p,m,e])),g=rZ((0,N.useMemo)(()=>({components:f,componentsByLanguage:t}),[f,t]),3),_=r?eZ:$X,v=iZ(a);return(0,P.jsx)(_,{text:s,components:h,overrideVersion:g,...v})},oZ=(0,N.forwardRef)(({className:e,containerProps:t,containerComponent:n=`div`,...r},i)=>{let a=ZX();return(0,P.jsx)(n,{"data-status":a.type,...t,className:(0,nW.default)(e,t?.className),ref:i,children:(0,P.jsx)(aZ,{...r})})});oZ.displayName=`MarkdownTextPrimitive`;var sZ=QX(oZ);function cZ(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 lZ(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function uZ(e,t,n){let r=IY((n||{}).ignore||[]),i=dZ(t),a=-1;for(;++a<i.length;)GY(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 dZ(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([fZ(e[0]),pZ(e[1])])}return t}function fZ(e){return typeof e==`string`?new RegExp(lZ(e),`g`):e}function pZ(e){return typeof e==`function`?e:function(){return e}}var mZ=`phrasing`,hZ=[`autolink`,`link`,`image`,`label`];function gZ(){return{transforms:[wZ],enter:{literalAutolink:vZ,literalAutolinkEmail:yZ,literalAutolinkHttp:yZ,literalAutolinkWww:yZ},exit:{literalAutolink:CZ,literalAutolinkEmail:SZ,literalAutolinkHttp:bZ,literalAutolinkWww:xZ}}}function _Z(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:mZ,notInConstruct:hZ},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:mZ,notInConstruct:hZ},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:mZ,notInConstruct:hZ}]}}function vZ(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function yZ(e){this.config.enter.autolinkProtocol.call(this,e)}function bZ(e){this.config.exit.autolinkProtocol.call(this,e)}function xZ(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 SZ(e){this.config.exit.autolinkEmail.call(this,e)}function CZ(e){this.exit(e)}function wZ(e){uZ(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,TZ],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,EZ]],{ignore:[`link`,`linkReference`]})}function TZ(e,t,n,r,i){let a=``;if(!kZ(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!DZ(n)))return!1;let o=OZ(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 EZ(e,t,n,r){return!kZ(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function DZ(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 OZ(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=cZ(e,`(`),a=cZ(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 kZ(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||dK(n)||uK(n))&&(!t||n!==47)}zZ.peek=RZ;function AZ(){this.buffer()}function jZ(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function MZ(){this.buffer()}function NZ(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function PZ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=eK(this.sliceSerialize(e)).toLowerCase(),n.label=t}function FZ(e){this.exit(e)}function IZ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=eK(this.sliceSerialize(e)).toLowerCase(),n.label=t}function LZ(e){this.exit(e)}function RZ(){return`[`}function zZ(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 BZ(){return{enter:{gfmFootnoteCallString:AZ,gfmFootnoteCall:jZ,gfmFootnoteDefinitionLabelString:MZ,gfmFootnoteDefinition:NZ},exit:{gfmFootnoteCallString:PZ,gfmFootnoteCall:FZ,gfmFootnoteDefinitionLabelString:IZ,gfmFootnoteDefinition:LZ}}}function VZ(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:zZ},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?`
82
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?UZ:HZ))),s(),o}}function HZ(e,t,n){return t===0?e:UZ(e,t,n)}function UZ(e,t,n){return(n?``:` `)+e}var WZ=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];YZ.peek=XZ;function GZ(){return{canContainEols:[`delete`],enter:{strikethrough:qZ},exit:{strikethrough:JZ}}}function KZ(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:WZ}],handlers:{delete:YZ}}}function qZ(e){this.enter({type:`delete`,children:[]},e)}function JZ(e){this.exit(e)}function YZ(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 XZ(){return`~`}function ZZ(e){return e.length}function QZ(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||ZZ,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=$Z(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]=eQ(r[d]);else{let e=eQ(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(`
83
+ `)}function $Z(e){return e==null?``:String(e)}function eQ(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 tQ(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()),nQ);return i(),o}function nQ(e,t,n){return`>`+(n?``:` `)+e}function rQ(e,t){return iQ(e,t.inConstruct,!0)&&!iQ(e,t.notInConstruct,!1)}function iQ(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 aQ(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
84
+ `&&rQ(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
85
+ `}function oQ(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 sQ(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 cQ(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function lQ(e,t,n,r){let i=cQ(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(sQ(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,uQ);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(oQ(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:`
86
+ `,encode:["`"],...s.current()})),t()}return u+=s.move(`
87
+ `),a&&(u+=s.move(a+`
88
+ `)),u+=s.move(c),l(),u}function uQ(e,t,n){return(n?``:` `)+e}function dQ(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function fQ(e,t,n,r){let i=dQ(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?` `:`
89
+ `,...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 pQ(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function mQ(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function hQ(e,t,n){let r=xK(e),i=xK(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}}gQ.peek=_Q;function gQ(e,t,n,r){let i=pQ(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=hQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=mQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=hQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+mQ(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function _Q(e,t,n){return n.options.emphasis||`*`}function vQ(e,t){let n=!1;return qY(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)&&VG(e)&&(t.options.setext||n))}function yQ(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(vQ(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
90
+ `,after:`
91
+ `});return r(),t(),o+`
92
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
93
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
94
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=mQ(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}bQ.peek=xQ;function bQ(e){return e.value||``}function xQ(){return`<`}SQ.peek=CQ;function SQ(e,t,n,r){let i=dQ(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 CQ(){return`!`}wQ.peek=TQ;function wQ(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 TQ(){return`!`}EQ.peek=DQ;function EQ(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 DQ(){return"`"}function OQ(e,t){let n=VG(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))}kQ.peek=AQ;function kQ(e,t,n,r){let i=dQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(OQ(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 AQ(e,t,n){return OQ(e,n)?`<`:`[`}jQ.peek=MQ;function jQ(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 MQ(){return`[`}function NQ(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 PQ(e){let t=NQ(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 FQ(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function IQ(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 LQ(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?FQ(n):NQ(n),s=e.ordered?o===`.`?`)`:`.`:PQ(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),IQ(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 RQ(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 zQ(e,t,n,r){let i=RQ(n),a=n.bulletCurrent||NQ(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 BQ(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var VQ=IY([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function HQ(e,t,n,r){return(e.children.some(function(e){return VQ(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function UQ(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}WQ.peek=GQ;function WQ(e,t,n,r){let i=UQ(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=hQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=mQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=hQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+mQ(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function GQ(e,t,n){return n.options.strong||`*`}function KQ(e,t,n,r){return n.safe(e.value,r)}function qQ(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 JQ(e,t,n){let r=(IQ(n)+(n.options.ruleSpaces?` `:``)).repeat(qQ(n));return n.options.ruleSpaces?r.slice(0,-1):r}var YQ={blockquote:tQ,break:aQ,code:lQ,definition:fQ,emphasis:gQ,hardBreak:aQ,heading:yQ,html:bQ,image:SQ,imageReference:wQ,inlineCode:EQ,link:kQ,linkReference:jQ,list:LQ,listItem:zQ,paragraph:BQ,root:HQ,strong:WQ,text:KQ,thematicBreak:JQ};function XQ(){return{enter:{table:ZQ,tableData:t$,tableHeader:t$,tableRow:$Q},exit:{codeText:n$,table:QQ,tableData:e$,tableHeader:e$,tableRow:e$}}}function ZQ(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 QQ(e){this.exit(e),this.data.inTable=void 0}function $Q(e){this.enter({type:`tableRow`,children:[]},e)}function e$(e){this.exit(e)}function t$(e){this.enter({type:`tableCell`,children:[]},e)}function n$(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,r$));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function r$(e,t){return t===`|`?t:e}function i$(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
95
+ `,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(`
96
+ `))}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 QZ(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=YQ.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function a$(){return{exit:{taskListCheckValueChecked:s$,taskListCheckValueUnchecked:s$,paragraph:c$}}}function o$(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:l$}}}function s$(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function c$(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 l$(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=YQ.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 u$(){return[gZ(),BZ(),GZ(),XQ(),a$()]}function d$(e){return{extensions:[_Z(),VZ(e),KZ(),i$(e),o$()]}}var f$={tokenize:E$,partial:!0},p$={tokenize:D$,partial:!0},m$={tokenize:O$,partial:!0},h$={tokenize:k$,partial:!0},g$={tokenize:A$,partial:!0},_$={name:`wwwAutolink`,tokenize:w$,previous:j$},v$={name:`protocolAutolink`,tokenize:T$,previous:M$},y$={name:`emailAutolink`,tokenize:C$,previous:N$},b$={};function x$(){return{text:b$}}for(var S$=48;S$<123;)b$[S$]=y$,S$++,S$===58?S$=65:S$===91&&(S$=97);b$[43]=y$,b$[45]=y$,b$[46]=y$,b$[95]=y$,b$[72]=[y$,v$],b$[104]=[y$,v$],b$[87]=[y$,_$],b$[119]=[y$,_$];function C$(e,t,n){let r=this,i,a;return o;function o(t){return!P$(t)||!N$.call(r,r.previous)||F$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return P$(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(g$,u,l)(t):t===45||t===95||nK(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&&tK(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function w$(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!j$.call(r,r.previous)||F$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(f$,e.attempt(p$,e.attempt(m$,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function T$(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&M$.call(r,r.previous)&&!F$(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(tK(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||iK(t)||cK(t)||dK(t)||uK(t)?n(t):e.attempt(p$,e.attempt(m$,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function E$(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 D$(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(h$,c,s)(t):t===null||cK(t)||dK(t)||t!==45&&uK(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 O$(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(h$,t,a)(o):o===null||cK(o)||dK(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function k$(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||cK(o)||dK(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||cK(e)||dK(e)?t(e):r(e)}function a(e){return tK(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):tK(t)?(e.consume(t),o):n(t)}}function A$(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return nK(e)?n(e):t(e)}}function j$(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||cK(e)}function M$(e){return!tK(e)}function N$(e){return!(e===47||P$(e))}function P$(e){return e===43||e===45||e===46||e===95||nK(e)}function F$(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 I$={tokenize:W$,partial:!0};function L$(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:V$,continuation:{tokenize:H$},exit:U$}},text:{91:{name:`gfmFootnoteCall`,tokenize:B$},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:R$,resolveTo:z$}}}}function R$(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=eK(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 z$(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 B$(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||cK(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(eK(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return cK(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 V$(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||cK(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=eK(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return cK(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),mK(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function H$(e,t,n){return e.check(kK,t,e.attempt(I$,t,n))}function U$(e){e.exit(`gfmFootnoteDefinition`)}function W$(e,t,n){let r=this;return mK(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 G$(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&&qG(o,o.length,0,SK(s,e.slice(r+1,n),t)),qG(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),qG(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=xK(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=xK(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var K$=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){q$(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 q$(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 J$(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 Y$(){return{flow:{null:{name:`table`,tokenize:X$,resolveAll:Z$}}}}function X$(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):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):lK(t)?mK(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||cK(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,lK(t)?mK(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 lK(t)?mK(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||$(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 lK(t)?mK(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(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||$(n)?(e.exit(`tableRow`),t(n)):lK(n)?mK(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||cK(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 Z$(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 K$;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&($$(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=Q$(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=Q$(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=Q$(f,t,o,i,n,d)):(o[0]=o[1],d=Q$(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&$$(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=J$(t.events,n))}return e}function Q$(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},e1(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=e1(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=e1(t.events,n[2]),a=e1(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({},e1(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function $$(e,t,n,r,i){let a=[],o=e1(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 e1(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var t1={name:`tasklistCheck`,tokenize:r1};function n1(){return{text:{91:t1}}}function r1(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 cK(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 $(r)?t(r):lK(r)?e.check({tokenize:i1},t,n)(r):n(r)}}function i1(e,t,n){return mK(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function a1(e){return XG([x$(),L$(),G$(e),Y$(),n1()])}var o1={};function s1(e){let t=this,n=e||o1,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(a1(n)),a.push(u$()),o.push(d$(n))}var c1=({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))},()=>{})}}},l1=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},u1=(0,N.memo)(({components:e})=>{let t=l1(e),n=(0,N.useMemo)(()=>t?{...d1,...KU(t)}:d1,[t]);return(0,P.jsx)(sZ,{remarkPlugins:[s1],className:`aui-md`,components:n,defer:!0})}),d1=KU({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=JU();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}=c1();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)(XH,{tooltip:`Copy`,onClick:()=>{t&&!n&&r(t)},children:[!n&&(0,P.jsx)(M,{className:`animate-in zoom-in-75 fade-in duration-150`}),n&&(0,P.jsx)(k,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})]})]})}});function f1({...e}){return(0,P.jsx)(Xt,{"data-slot":`collapsible`,...e})}function p1({...e}){return(0,P.jsx)(Gt,{"data-slot":`collapsible-trigger`,...e})}function m1({...e}){return(0,P.jsx)(qt,{"data-slot":`collapsible-content`,...e})}var h1=(0,N.createContext)(!1),g1=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 _1({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)(f1,{"data-slot":`reasoning-root`,"data-variant":t,open:m,onOpenChange:_,className:a(`group/reasoning-root`,g1({variant:t,className:e})),style:{"--animation-duration":`200ms`},...l,children:(0,P.jsx)(h1.Provider,{value:h,children:c})})}function v1({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 y1({active:e,duration:t,className:n,...r}){let i=t?` (${t}s)`:``;return(0,P.jsxs)(p1,{"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)(O,{"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)(ee,{"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 b1({className:e,children:t,...n}){let r=(0,N.useContext)(h1);return(0,P.jsxs)(m1,{"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)(v1,{side:`top`}),t,r?(0,P.jsx)(v1,{}):null]})}function x1({className:e,children:t,...n}){let r=(0,N.useContext)(h1),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 S1({ref:e,onAnimationStart:t,...n}){let r=(0,N.useRef)(null),i=aV(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)(_1,{ref:o,onAnimationStart:a,...n})}var C1=()=>(0,P.jsx)(u1,{}),w1=({children:e,startIndex:t,endIndex:n})=>{let r=X(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)(S1,{streaming:r,children:[(0,P.jsx)(y1,{active:r}),(0,P.jsx)(b1,{"aria-busy":r,children:(0,P.jsx)(x1,{children:e})})]})},T1=(0,N.memo)(C1);T1.displayName=`Reasoning`,T1.Root=S1,T1.Trigger=y1,T1.Content=b1,T1.Text=x1,T1.Fade=v1;var E1=(0,N.memo)(w1);E1.displayName=`ReasoningGroup`;function D1({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 O1=200,k1=`active:scale-[0.98]`;function A1({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=aV(s,O1),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)(f1,{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":`${O1}ms`},...o,children:i})}var j1={running:pe,complete:k,incomplete:ne,"requires-action":te},M1=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 N1({className:e,...t}){let n=oV();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:M1(n)})}function P1({toolName:e,status:t,className:n,...r}){let i=t?.type??`complete`,o=i===`running`,s=t?.type===`incomplete`&&t.reason===`cancelled`,c=j1[i],l=s?`Cancelled tool`:`Used tool`;return(0,P.jsxs)(p1,{"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)(N1,{}),(0,P.jsx)(ee,{"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 F1({className:e,children:t,...n}){return(0,P.jsx)(m1,{"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 I1({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 L1=(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 R1({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:L1(e,2)})]})}function z1({status:e,className:t,...n}){if(e?.type!==`incomplete`)return null;let r=e.error,i=r==null?null:L1(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 B1=`Approved by user`,V1=`User denied tool execution`,H1={"allow-once":`Allow`,"allow-always":`Always allow`,"reject-once":`Deny`,"reject-always":`Always deny`},U1=e=>Object.hasOwn(H1,e),W1=e=>e===`allow-once`||e===`allow-always`,G1=e=>e.label??(U1(e.kind)?H1[e.kind]:void 0)??e.id,K1=e=>e?.display===`select`||e?.display===`text`,q1=(e,t,n)=>e?.type!==`requires-action`||e.reason!==`interrupt`||t!=null||n!=null;function J1({className:e,addResult:t,resume:n,interrupt:r,approval:i,respondToApproval:o,status:c,...l}){let[u,d]=(0,N.useState)(!1),f=X(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)||!q1(c,i,r))return null;let b=o?i?.options:void 0,x=i!=null&&o!=null&&gA(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?B1:V1))}},w=e=>{p||(h(null),S(()=>o?.(U1(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),ee=K1(i),A=ee&&o!=null&&i?.dismissible===!0?(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:k1,onClick:D,disabled:p,children:`Dismiss`}):null,j=i?.prompt?(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-foreground whitespace-pre-line`,children:i.prompt}):null,te=v?(0,P.jsx)(`p`,{role:`alert`,className:`aui-tool-fallback-approval-error text-destructive text-xs whitespace-pre-line`,children:v}):null,ne=x?(0,P.jsxs)(`div`,{className:`aui-tool-fallback-approval-answer flex flex-col items-start gap-2`,children:[(0,P.jsx)(D1,{value:g,onChange:e=>_(e.target.value),disabled:p,"aria-label":ee?i?.prompt??`Answer`:`Note`,placeholder:ee?`Type your answer`:`Add a note to your decision`}),ee&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:k1,onClick:E,disabled:p,children:`Send`}),A]})]}):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??`${G1(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:k1,onClick:()=>w(k),disabled:p,children:`Confirm`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:k1,onClick:()=>h(null),disabled:p,children:`Back`})]})]})}if(b&&b.length>0){let t=b.filter(e=>W1(e.kind)),n=b.filter(e=>!U1(e.kind)),r=b.filter(e=>U1(e.kind)&&!W1(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:[j,(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:k1,onClick:()=>O(e),disabled:p,children:G1(e)},e.id)),r.length===0&&!ee&&(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:k1,onClick:()=>C(!1),disabled:p,children:`Deny`}),!x&&A]}),ne,te]})}return 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:[j,ne,!x&&A&&(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:A}),te]}):(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:[j,(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:k1,onClick:()=>C(!0),disabled:p,children:`Allow`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:k1,onClick:()=>C(!1),disabled:p,children:`Deny`})]}),ne,te]})}var Y1=(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&&q1(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)(A1,{open:p,onOpenChange:m,children:[(0,P.jsx)(P1,{toolName:e,status:r}),(0,P.jsxs)(F1,{children:[(0,P.jsx)(z1,{status:r}),(0,P.jsx)(I1,{argsText:t,className:a(u&&`opacity-60`)}),f&&(0,P.jsx)(J1,{addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l,status:r}),(0,P.jsx)(R1,{result:n})]})]})});Y1.displayName=`ToolFallback`,Y1.Root=A1,Y1.Trigger=P1,Y1.Content=F1,Y1.Args=I1,Y1.Result=R1,Y1.Error=z1,Y1.Approval=J1;var X1=200,Z1=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 Q1({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=aV(c,X1),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)(f1,{ref:c,"data-slot":`tool-group-root`,"data-variant":t??`outline`,open:p,onOpenChange:m,className:a(Z1({variant:t}),`group/tool-group-root`,e),style:{"--animation-duration":`${X1}ms`},...s,children:o})}function $1({count:e,active:t=!1,className:n,...r}){let i=`${e} tool ${e===1?`call`:`calls`}`;return(0,P.jsxs)(p1,{"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)(pe,{"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)(ee,{"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 e0({className:e,children:t,...n}){return(0,P.jsx)(m1,{"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 t0=(0,N.memo)(({children:e,startIndex:t,endIndex:n})=>{let r=n-t+1;return(0,P.jsxs)(Q1,{children:[(0,P.jsx)($1,{count:r}),(0,P.jsx)(e0,{children:e})]})});t0.displayName=`ToolGroup`,t0.Root=Q1,t0.Trigger=$1,t0.Content=e0;function n0({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`skeleton`,className:a(`animate-pulse rounded-md bg-accent`,e),...t})}var r0=TN({reasoning:[`group-chainOfThought`,`group-reasoning`],"tool-call":[`group-chainOfThought`,`group-tool`],"standalone-tool-call":[]}),i0=[`group-chainOfThought`,`group-task`],a0=(e,t)=>{let n=r0(e,t);return e.type===`tool-call`&&e.messages!==void 0&&n.length>0&&!t?.toolUIs?.[e.toolName]?.length?i0:n},o0={},s0=(0,N.createContext)(o0),c0=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading),l0=e=>e.thread.messages.length===0&&e.thread.isLoading&&!e.thread.isDisabled&&!e.threads.isLoading,u0=()=>(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)(n0,{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)(n0,{className:`h-4 w-11/12 motion-reduce:animate-none`}),(0,P.jsx)(n0,{className:`h-4 w-4/5 motion-reduce:animate-none`}),(0,P.jsx)(n0,{className:`h-4 w-3/5 motion-reduce:animate-none`})]}),(0,P.jsx)(n0,{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)(n0,{className:`h-4 w-10/12 motion-reduce:animate-none`}),(0,P.jsx)(n0,{className:`h-4 w-2/3 motion-reduce:animate-none`})]})]}),d0=({components:e=o0,autoFocus:t=!0})=>{let n=X(c0);return(0,P.jsx)(s0.Provider,{value:e,children:(0,P.jsx)(f0,{isEmpty:n,autoFocus:t})})},f0=({isEmpty:e,autoFocus:t})=>{let{Welcome:n=y0}=(0,N.useContext)(s0);return(0,P.jsx)(SB.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)(SB.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)(ZE,{condition:c0,children:(0,P.jsx)(n,{})}),(0,P.jsx)(ZE,{condition:l0,children:(0,P.jsx)(u0,{})}),(0,P.jsx)(`div`,{"data-slot":`aui_message-group`,className:`mb-14 flex flex-col gap-y-6 empty:hidden`,children:(0,P.jsx)(SB.Messages,{children:()=>(0,P.jsx)(p0,{})})}),(0,P.jsxs)(SB.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)(v0,{}),(0,P.jsx)(DU,{}),(0,P.jsx)(S0,{autoFocus:t}),(0,P.jsx)(ZE,{condition:e=>c0(e)&&e.composer.isEmpty,children:(0,P.jsx)(b0,{})})]})]})})})},p0=()=>{let{AssistantMessage:e=T0}=(0,N.useContext)(s0),t=X(e=>e.message.role),n=X(e=>e.message.composer.isEditing),r=X(e=>e.message.metadata.modality===`voice`);return n?(0,P.jsx)(j0,{}):r?(0,P.jsx)(g0,{}):t===`user`?(0,P.jsx)(k0,{}):(0,P.jsx)(e,{})},m0=()=>X(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`}),h0=({text:e})=>(0,P.jsx)(`p`,{className:`aui-spoken-message-text m-0`,children:e}),g0=()=>{let e=X(e=>e.message.role),t=m0(),n=X(e=>e.message.role===`assistant`&&e.message.status?.type===`running`),r=t===`start`||t===`single`;return(0,P.jsxs)(Rz.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)(ve,{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)(me,{className:`size-3.5`}):(0,P.jsx)(E,{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)(Rz.Parts,{components:{Text:h0}}),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)(_0,{})]})]})},_0=()=>(0,P.jsx)(rI.Root,{hideWhenRunning:!0,autohide:`always`,className:`aui-spoken-action-bar text-muted-foreground flex shrink-0 gap-1`,children:(0,P.jsx)(rI.Copy,{asChild:!0,children:(0,P.jsxs)(XH,{tooltip:`Copy`,className:`size-6`,children:[(0,P.jsx)(ZE,{condition:e=>e.message.isCopied,children:(0,P.jsx)(k,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(ZE,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(M,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})})}),v0=()=>(0,P.jsx)(SB.ScrollToBottom,{asChild:!0,children:(0,P.jsx)(XH,{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,{})})}),y0=()=>(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?`})}),b0=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-suggestions flex w-full flex-col`,children:(0,P.jsx)(SB.Suggestions,{children:()=>(0,P.jsx)(x0,{})})}),x0=()=>(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)(kB.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)(kB.Title,{className:`aui-thread-welcome-suggestion-text-1 text-foreground`}),` `,(0,P.jsx)(kB.Description,{className:`aui-thread-welcome-suggestion-text-2 text-muted-foreground empty:hidden`})]})]})})}),S0=({autoFocus:e})=>(0,P.jsx)(ER.Root,{className:`aui-composer-root relative flex w-full flex-col`,children:(0,P.jsx)(ER.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)(dU,{}),(0,P.jsx)(ER.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)(C0,{})]})})}),C0=()=>(0,P.jsxs)(`div`,{className:`aui-composer-action-wrapper relative flex items-center justify-between`,children:[(0,P.jsx)(fU,{}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsxs)(ZE,{condition:e=>e.thread.capabilities.dictation,children:[(0,P.jsx)(ZE,{condition:e=>e.composer.dictation==null,children:(0,P.jsx)(ER.Dictate,{asChild:!0,children:(0,P.jsx)(XH,{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)(me,{className:`aui-composer-dictate-icon size-4`})})})}),(0,P.jsx)(ZE,{condition:e=>e.composer.dictation!=null,children:(0,P.jsx)(ER.StopDictation,{asChild:!0,children:(0,P.jsx)(XH,{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)(Te,{className:`aui-composer-stop-dictation-icon size-3.5 animate-pulse fill-current`})})})})]}),(0,P.jsx)(ZE,{condition:e=>!e.thread.isRunning||e.thread.voice!==void 0,children:(0,P.jsx)(ER.Send,{asChild:!0,children:(0,P.jsx)(XH,{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)(T,{className:`aui-composer-send-icon size-4`})})})}),(0,P.jsx)(ZE,{condition:e=>e.thread.isRunning&&e.thread.voice===void 0,children:(0,P.jsx)(ER.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)(Te,{className:`aui-composer-cancel-icon size-3.5 fill-current`})})})})]})]}),w0=()=>(0,P.jsx)(Rz.Error,{children:(0,P.jsx)(QR.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)(QR.Message,{className:`aui-message-error-message line-clamp-2`})})}),T0=()=>{let{ToolFallback:e=Y1,ToolGroup:t,ReasoningGroup:n,TaskGroup:r}=(0,N.useContext)(s0),i=r?a0:r0;return(0,P.jsxs)(Rz.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)(Rz.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)(Q1,{variant:`ghost`,children:[(0,P.jsx)($1,{count:i.indices.length,active:i.status.type===`running`}),(0,P.jsx)(e0,{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)(S1,{streaming:e,children:[(0,P.jsx)(y1,{active:e}),(0,P.jsx)(b1,{"aria-busy":e,children:(0,P.jsx)(x1,{children:a})})]})}case`text`:return(0,P.jsx)(u1,{});case`reasoning`:return(0,P.jsx)(T1,{...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)(TU,{...i})});case`image`:return(0,P.jsx)(`div`,{"data-slot":`aui_assistant-message-image`,className:`py-1`,children:(0,P.jsx)(HU,{...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)(w0,{})]}),(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)(M0,{}),(0,P.jsx)(E0,{})]})]})},E0=()=>(0,P.jsxs)(rI.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)(rI.Copy,{asChild:!0,children:(0,P.jsxs)(XH,{tooltip:`Copy`,children:[(0,P.jsx)(ZE,{condition:e=>e.message.isCopied,children:(0,P.jsx)(k,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(ZE,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(M,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})}),(0,P.jsxs)(ZE,{condition:e=>e.thread.capabilities.feedback,children:[(0,P.jsx)(rI.FeedbackPositive,{asChild:!0,children:(0,P.jsx)(XH,{tooltip:`Helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(Oe,{})})}),(0,P.jsx)(rI.FeedbackNegative,{asChild:!0,children:(0,P.jsx)(XH,{tooltip:`Not helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(De,{})})})]}),(0,P.jsx)(rI.Reload,{asChild:!0,children:(0,P.jsx)(XH,{tooltip:`Refresh`,children:(0,P.jsx)(be,{})})}),(0,P.jsxs)(mI.Root,{children:[(0,P.jsx)(mI.Trigger,{asChild:!0,children:(0,P.jsx)(XH,{tooltip:`More`,className:`data-[state=open]:bg-accent`,children:(0,P.jsx)(ae,{})})}),(0,P.jsx)(mI.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)(rI.ExportMarkdown,{asChild:!0,children:(0,P.jsxs)(mI.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)(ie,{className:`size-4`}),`Export as Markdown`]})})})]})]}),D0=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-file`,className:`py-1`,children:(0,P.jsx)(TU,{...e})}),O0=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-image`,className:`py-1`,children:(0,P.jsx)(HU,{...e})}),k0=()=>(0,P.jsxs)(Rz.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)(uU,{}),(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)(Rz.Parts,{components:{File:D0,Image:O0}})}),(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)(A0,{})})]}),(0,P.jsx)(M0,{"data-slot":`aui_user-branch-picker`,className:`col-span-full col-start-1 -me-1 justify-end`})]}),A0=()=>(0,P.jsx)(rI.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-user-action-bar-root flex flex-col items-end`,children:(0,P.jsx)(rI.Edit,{asChild:!0,children:(0,P.jsx)(XH,{tooltip:`Edit`,className:`aui-user-action-edit`,children:(0,P.jsx)(_e,{})})})}),j0=()=>(0,P.jsx)(Rz.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)(ER.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)(ER.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)(ER.Cancel,{asChild:!0,children:(0,P.jsx)(s,{variant:`ghost`,size:`sm`,className:`h-8 px-3`,children:`Cancel`})}),(0,P.jsx)(ER.Send,{asChild:!0,children:(0,P.jsx)(s,{size:`sm`,className:`h-8 px-3`,children:`Update`})})]})]})}),M0=({className:e,...t})=>(0,P.jsxs)(jI.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)(jI.Previous,{asChild:!0,children:(0,P.jsx)(XH,{tooltip:`Previous`,children:(0,P.jsx)(A,{})})}),(0,P.jsxs)(`span`,{className:`aui-branch-picker-state font-medium`,children:[(0,P.jsx)(jI.Number,{}),` / `,(0,P.jsx)(jI.Count,{})]}),(0,P.jsx)(jI.Next,{asChild:!0,children:(0,P.jsx)(XH,{tooltip:`Next`,children:(0,P.jsx)(j,{})})})]}),N0=()=>{let[e,t]=(0,N.useState)(``),n=X(e=>e.threads.threadIds.length>0);return(0,P.jsxs)(F0,{children:[(0,P.jsx)(H0,{}),n&&(0,P.jsx)(P0,{value:e,onValueChange:t}),(0,P.jsx)(I0,{searchQuery:n?e:``})]})},P0=(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)(Se,{"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})]}));P0.displayName=`ThreadListSearch`;var F0=({className:e,...t})=>(0,P.jsx)(BB.Root,{"data-slot":`aui_thread-list-root`,className:a(`flex flex-col gap-0.5`,e),...t}),I0=({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)(ZE,{condition:e=>e.threads.isLoading,children:(0,P.jsx)(U0,{})}),(0,P.jsx)(ZE,{condition:e=>!e.threads.isLoading,children:(0,P.jsx)(B0,{searchQuery:t})})]}),L0=864e5,R0=(e,t)=>!e||e.getTime()>=t?`Today`:e.getTime()>=t-L0?`Yesterday`:`Earlier`,z0=(e=``)=>{let t=X(e=>e.threads.threadIds),n=X(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=R0(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])},B0=({searchQuery:e=``})=>{let{threadIds:t,filteredIndices:n,archivedIndices:r,groups:i}=z0(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)(BB.ItemByIndex,{index:e,components:{ThreadListItem:W0}},t[e]))]},e.label)),(0,P.jsx)(V0,{threadIds:t,indices:r})]}):(0,P.jsxs)(P.Fragment,{children:[n.map(e=>(0,P.jsx)(BB.ItemByIndex,{index:e,components:{ThreadListItem:W0}},t[e])),(0,P.jsx)(V0,{threadIds:t,indices:r})]})},V0=({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)(BB.ItemByIndex,{index:t,components:{ThreadListItem:W0}},e[t]))]}):null,H0=(0,N.forwardRef)(({className:e,labelClassName:t,children:n,...r},i)=>(0,P.jsx)(BB.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)(ye,{"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`})]})})}));H0.displayName=`ThreadListNew`;var U0=()=>(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)(n0,{"data-slot":`aui_thread-list-skeleton`,className:`h-3.5 w-full`})},t))}),W0=()=>{let e=X(e=>e.threadListItem.isRunning),t=X(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)(qB.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)(G0,{onDone:e=>{o.current=e,r(!1)}}):(0,P.jsxs)(qB.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)(fe,{"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)(qB.Title,{fallback:`New Chat`})}),e&&(0,P.jsx)(`span`,{className:`sr-only`,children:`Running`})]}),(0,P.jsx)(K0,{archived:t,onRename:()=>r(!0)})]})},G0=({onDone:e})=>{let t=Y(),n=X(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())}})},K0=({archived:e,onRename:t})=>(0,P.jsxs)(iV.Root,{sharedFocusGroup:!0,children:[(0,P.jsx)(iV.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)(ae,{className:`size-3.5`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`More options`})]})}),(0,P.jsxs)(iV.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)(iV.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)(_e,{className:`size-4`}),`Rename`]}),e?(0,P.jsx)(qB.Unarchive,{asChild:!0,children:(0,P.jsxs)(iV.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)(qB.Archive,{asChild:!0,children:(0,P.jsxs)(iV.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)(qB.Delete,{asChild:!0,children:(0,P.jsxs)(iV.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)(ke,{className:`size-4`}),`Delete`]})})]})]}),q0=`bg-background border border-border/60 dark:bg-popover`;function J0({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(q0,`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)(re,{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)(fe,{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)(k,{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`]})]})]})}function Y0({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)(we,{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)(D1,{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 X0(){let{requests:e,respond:t}=IH();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)(Y0,{request:e,respond:t},e.id))})}function Z0({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 Q0=6e4,$0=500,e2=1e4,t2=100,n2=new Set([`listThreads`,`getThread`,`getAvailableModels`]),r2=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchTransportError`}},i2=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchRpcError`}};function a2(){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/api/v1/workbench/ws`}function o2(e={}){let t=e.url??a2(),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 r2(`OUTCOME_UNKNOWN`,`Confirmation for ${e.frame.method} was lost. The request may have been accepted. Reconnect and check the thread before retrying.`):new r2(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 r2(`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??$0)*2**a,e2);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=u2(JSON.parse(String(e.data)))}catch{d(new r2(`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 i2(t.code,t.message));return}if(!d2(a.frame.method,t.result)){f(t.id,new r2(`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 r2(`DISPOSED`,`The workspace connection was closed.`));if(!n2.has(t)&&i?.readyState!==WebSocket.OPEN)return Promise.reject(new r2(`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`));if(n.size>=t2)return Promise.reject(new r2(`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??Q0),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 r2(`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 s2(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c2(e){return s2(e)&&typeof e.id==`string`&&[`idle`,`running`,`failed`].includes(String(e.status))}function l2(e){return s2(e)&&c2(e.metadata)&&Array.isArray(e.messages)}function u2(e){if(!s2(e))throw Error(`Invalid frame`);if(e.kind===`event`){let t=e.event;if(s2(t)&&typeof t.type==`string`&&typeof t.threadId==`string`&&Number.isSafeInteger(t.seq)&&Number(t.seq)>=0&&(t.type!==`snapshot`||l2(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 d2(e,t){switch(e){case`listThreads`:return Array.isArray(t)&&t.every(c2);case`getThread`:case`createThread`:return l2(t);case`getAvailableModels`:return Array.isArray(t)&&t.every(e=>s2(e)&&typeof e.provider==`string`&&typeof e.modelId==`string`);case`clearQueue`:return s2(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 f2(){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 p2={connecting:`reconnecting`,open:`online`,closed:`dropped`};function m2(){let{compaction:e,retry:t,contextUsage:n,readiness:r}=PH(),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)(ax,{variant:`high`,children:i.message}):null,e.active?(0,P.jsx)(ax,{variant:`secondary`,children:`Compacting context…`}):null,t.active?(0,P.jsxs)(ax,{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 h2=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function g2({client:e}){let t=FH(),n=X(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)(Z0,{"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)(Z0,{"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…`}),h2.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 _2({status:e,client:t}){let n=FH();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:n?.title??`Live Workspace`}),n?.status===`running`?(0,P.jsx)(ax,{variant:`low`,children:`streaming`}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(m2,{}),(0,P.jsx)(g2,{client:t}),e===`open`?null:(0,P.jsx)(J0,{phase:p2[e]})]})]})}function v2(){let[e,t]=(0,N.useState)(`connecting`),n=(0,N.useMemo)(()=>o2({onStatusChange:t}),[]);(0,N.useEffect)(()=>()=>n.dispose(),[n]);let r=NH({client:n,includeArchived:!0});return(0,P.jsx)(mF,{runtime:r,children:(0,P.jsxs)(`div`,{className:`grid h-[var(--workspace-height)] min-h-120 grid-cols-1 gap-4 md:grid-cols-[minmax(0,17rem)_minmax(0,1fr)]`,children:[(0,P.jsx)(g,{className:`hidden min-h-0 overflow-hidden p-0 md:flex`,children:(0,P.jsx)(N0,{})}),(0,P.jsxs)(g,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:[(0,P.jsx)(_2,{status:e,client:n}),(0,P.jsx)(X0,{}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,P.jsx)(d0,{})})]})]})})}function y2({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 b2({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 x2({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)(Z0,{"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 S2=new kf({defaultOptions:{queries:{staleTime:1e4,retry:2,refetchOnWindowFocus:!0}}});function C2({section:e}){return(0,P.jsx)(Mf,{client:S2,children:(0,P.jsx)(T2,{section:e})})}function w2(){let e=Kf({queryKey:[`workbench-status`],queryFn:f2,retry:1,staleTime:15e3});return e.isLoading?(0,P.jsx)(D2,{compact:!0,title:`Connecting to the live workspace…`,detail:`Checking the platform agent runtime.`}):e.data&&e.data!==`up`?(0,P.jsx)(y2,{state:e.data}):(0,P.jsx)(v2,{})}function T2({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=Kf({queryKey:[`agent-sessions`],queryFn:Ob.agentSessions,enabled:e===`history`||e===`agent`||e===`findings`||e===`dashboard`||e===`lifecycle`,refetchInterval:2e3}),a=t===`all`?void 0:t||i.data?.items?.[0]?.id,o=Kf({queryKey:[`workflows`],queryFn:Ob.workflows,enabled:e===`workflows`||e===`assessments`}),c=Kf({queryKey:[`overview`,a],queryFn:()=>Ob.overview(a),enabled:e===`dashboard`||e===`assessments`||e===`lifecycle`,refetchInterval:2e3}),l=Kf({queryKey:[`runs`,a],queryFn:()=>Ob.runs({sessionId:a}),enabled:e===`runs`,refetchInterval:2e3}),u=Kf({queryKey:[`projects`],queryFn:Ob.projects,enabled:e===`assessments`}),d=Kf({queryKey:[`assessment-profiles`],queryFn:Ob.assessmentProfiles,enabled:e===`assessments`}),f=Kf({queryKey:[`findings`,a],queryFn:()=>Ob.findings({sessionId:a}),enabled:e===`findings`||e===`dashboard`||e===`lifecycle`||e===`governance`,refetchInterval:6e3}),p=Kf({queryKey:[`agent-session`,t],queryFn:()=>Ob.agentSession(t),enabled:e===`history`&&!!t,refetchInterval:2e3}),h=Kf({queryKey:[`governance-events`],queryFn:Ob.governanceEvents,enabled:e===`governance`}),v=Kf({queryKey:[`workers`],queryFn:Ob.workers,enabled:e===`administration`}),y=Kf({queryKey:[`tokens`],queryFn:Ob.tokens,enabled:e===`administration`}),[x,S]=(0,N.useState)(``),[C,T]=(0,N.useState)(30),[E,D]=(0,N.useState)(!1),[O,ee]=(0,N.useState)(null),[A,j]=(0,N.useState)(!1),[te,ne]=(0,N.useState)(!1),[re,ie]=(0,N.useState)(null),[ae,oe]=(0,N.useState)(null);async function se(e){e.preventDefault(),D(!0),ie(null);try{let e=await Ob.mintToken({label:x.trim()||`CLI Token`,expiresInDays:C});ee(e),S(``),S2.invalidateQueries({queryKey:[`tokens`]})}catch(e){ie(e instanceof Error?e.message:`Failed to mint token`)}finally{D(!1)}}async function ce(e){if(confirm(`Are you sure you want to revoke this token? Any CLI session or automation using it will immediately lose access.`)){oe(e);try{await Ob.revokeToken(e),S2.invalidateQueries({queryKey:[`tokens`]})}catch(e){alert(e instanceof Error?e.message:`Failed to revoke token`)}finally{oe(null)}}}let le=[...e===`workflows`||e===`assessments`?[o]:[],...e===`dashboard`?[c,f]:[],...e===`lifecycle`?[c,f]:[],...e===`runs`?[l]:[],...e===`assessments`?[c,u,d]:[],...e===`findings`?[f]:[],...e===`history`?[i]:[],...e===`history`&&t?[p]:[],...e===`governance`?[h,f]:[],...e===`administration`?[v,y]:[]];if(le.some(e=>e.isLoading))return(0,P.jsx)(D2,{title:`Loading workspace`,detail:`Reading durable platform state…`});let ue=le.find(e=>e.isError);if(ue){let e=ue.error,t=e&&typeof e==`object`&&`status`in e&&e.status===401;return(0,P.jsx)(D2,{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 ue.refetch(),children:[(0,P.jsx)(be,{}),` Retry`]})})}let fe=Ub(f.data?.findings??[]),pe=fe.filter(Bb);if(e===`dashboard`){let e=Object.fromEntries(Nb.map(e=>[e,pe.filter(t=>t.severity===e).length])),n=c.data?.runs??{},a=Object.values(n).reduce((e,t)=>e+t,0),o=(n.queued??0)+(n.running??0),l=Wb(fe),u=fe.filter(e=>e.status===`confirmed`||e.status===`verified`);return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(b2,{actions:(0,P.jsx)(x2,{onChange:r,sessions:i.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)(Kb,{children:[(0,P.jsx)(qb,{hero:!0,tone:l??void 0,label:`Client posture`,value:l?Ib[l].toUpperCase():`NO CONFIRMED RISK`,meta:l?`Worst confirmed finding across ${u.length} confirmed finding${u.length===1?``:`s`}.`:`No finding has been confirmed yet.`}),(0,P.jsx)(qb,{label:`Open findings`,value:pe.length,meta:`${fe.length-pe.length} resolved`}),(0,P.jsx)(qb,{label:`Critical / High`,value:`${e.critical} / ${e.high}`,meta:`${u.length} confirmed overall`}),(0,P.jsx)(qb,{label:`Assessments`,value:a,meta:`${o} in flight`})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)(Gb,{title:`Open findings by severity`,sub:`${pe.length} active`,children:(0,P.jsx)(Jb,{counts:e})}),(0,P.jsx)(Gb,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,P.jsx)(Yb,{findings:pe})})]}),(0,P.jsx)(Gb,{title:`Highest-priority open findings`,sub:(0,P.jsx)(`a`,{className:`link-more`,href:`/findings`,children:`View all`}),children:(0,P.jsx)(Xb,{findings:zb(pe).slice(0,5),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)(w,{"aria-hidden":`true`})]})]}),c.data?.recentRuns.filter(e=>e.status===`queued`||e.status===`running`).length?(0,P.jsx)(j2,{runs:c.data.recentRuns.filter(e=>e.status===`queued`||e.status===`running`)}):(0,P.jsx)(D2,{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)(k2,{findings:pe});if(e===`workflows`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(E2,{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:o.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)(ax,{variant:ix(N2(e.stages)),children:[`Highest risk `,N2(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)(w,{})]})})]},e.key))})]});if(e===`runs`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(E2,{title:`Runs`,detail:`Real-time and historical execution records for governed assessment runs.`}),l.data?.runs.length?(0,P.jsx)(j2,{runs:l.data.runs}):(0,P.jsx)(D2,{compact:!0,title:`No runs yet`,detail:`Initialize an assessment to start the first governed run.`})]});if(e===`assessments`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(E2,{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)(O2,{label:`Projects`,value:String(u.data?.items.length??0),detail:`Active workspace project boundaries`}),(0,P.jsx)(O2,{label:`Target bindings`,value:String(d.data?.items.length??0),detail:`Bound endpoints and infrastructure`}),(0,P.jsx)(O2,{label:`Recent runs`,value:String(c.data?.recentRuns.length??0),detail:`Assessment runs recorded in this workspace`})]}),d.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:d.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)(ax,{variant:ix(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)(D2,{compact:!0,title:`No targets yet`,detail:`Configure a new target endpoint from the dashboard to initialize assessment tracking.`})]});if(e===`findings`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(b2,{actions:(0,P.jsx)(x2,{id:`findings-session`,onChange:r,sessions:i.data?.items??[],value:t}),title:`Findings`,description:`Findings ingested from agent runs. Source findings stay unverified until operation-level evidence confirms them.`}),f.data?.findings.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:f.data.findings.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(ax,{variant:ix(e.severity),children:e.severity}),(0,P.jsx)(ax,{variant:ix(e.status),children:P2(e.status)})]}),(0,P.jsx)(`h2`,{children:e.title}),(0,P.jsx)(`p`,{children:e.description})]},e.id))}):(0,P.jsx)(D2,{compact:!0,title:`No findings`,detail:`Discovered findings will appear here upon completion of assessment stages.`})]});if(e===`agent`)return(0,P.jsx)(w2,{});if(e===`history`){if(t&&p.data){let e=p.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:`Agent Workspace`}),(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:`/history`,children:`All sessions`})})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,P.jsx)(O2,{label:`Status`,value:P2(e.session.status),detail:`${e.session.runCount} run${e.session.runCount===1?``:`s`} in this session`}),(0,P.jsx)(O2,{label:`Tool calls`,value:String(e.session.operationCount),detail:t?`${t} did not complete`:`All completed`}),(0,P.jsx)(O2,{label:`Findings`,value:String(e.session.findingCount),detail:e.session.findingCount?`Ingested through report_finding`:`The agent reported none 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)(`div`,{className:`flex items-start justify-between gap-4`,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)(ax,{variant:ix(e.status),children:P2(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)(D2,{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)(`div`,{className:`flex items-start justify-between gap-4`,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)(ax,{variant:ix(e.status),children:P2(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)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,P.jsx)(`h2`,{id:`agent-findings`,children:`Findings from this session`})}),(0,P.jsx)(M2,{findings:e.findings})]}):null]})}return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(E2,{title:`Agent Workspace`,detail:`Interactive and headless autonomous agent assessment sessions.`}),i.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:i.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)(ax,{variant:ix(e.status),children:P2(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:`/history?session=${e.id}`,children:`Open session`})})]},e.id))}):(0,P.jsx)(D2,{compact:!0,title:`No agent sessions`,detail:`Sessions appear here once an agent run reaches the platform.`})]})}if(e===`governance`)return(0,P.jsx)(A2,{events:h.data?.items??[],findings:fe});if(e===`reports`)return(0,P.jsx)(lx,{});if(e===`administration`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(E2,{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)(de,{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.`}),O&&(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)(k,{size:16}),` Token Minted: `,O.label]}),(0,P.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>ee(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:O.token,className:`flex-1 font-mono`}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(O.token),j(!0),setTimeout(()=>j(!1),2e3)},children:[A?(0,P.jsx)(k,{size:14}):(0,P.jsx)(M,{size:14}),A?`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 `,O.token]}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(`kifaru session login --token `+O.token),ne(!0),setTimeout(()=>ne(!1),2e3)},children:[te?(0,P.jsx)(k,{size:14}):(0,P.jsx)(M,{size:14}),te?`Copied`:`Copy Command`]})]})]})]})]}),(0,P.jsxs)(`form`,{onSubmit:se,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:x,onChange:e=>S(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)(Z0,{id:`mint-expiry`,value:C,onChange:e=>T(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:E,size:`sm`,children:[(0,P.jsx)(ye,{size:15}),E?`Minting…`:`Mint Token`]})]}),re&&(0,P.jsx)(`p`,{className:`text-destructive text-sm`,style:{marginBottom:`1rem`},children:re}),(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`}),y.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:y.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)(ax,{variant:ix(`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:ae===e.id,onClick:()=>ce(e.id),children:[(0,P.jsx)(Ae,{size:13}),ae===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)(Ee,{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`}),v.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:v.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)(ax,{variant:ix(e.status),children:P2(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)(D2,{compact:!0,title:`No workers registered`,detail:`Connect an execution worker before launching capability-bound workflows.`})]})]});let me={evidence:{title:`Evidence Map`,detail:`Cryptographic evidence graph linking discovered vulnerabilities to raw execution artifacts.`,icon:b,action:`Filter evidence`}}[e],he=me.icon;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(E2,{title:me.title,detail:me.detail}),(0,P.jsx)(D2,{compact:!0,title:`${me.title}`,detail:me.detail,action:(0,P.jsxs)(s,{children:[(0,P.jsx)(he,{}),` `,me.action]})})]})}function E2({title:e,detail:t}){return(0,P.jsx)(b2,{description:t,title:e})}function D2({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 O2({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 k2({findings:e}){let[t,n]=(0,N.useState)(4),r=Ab(t),i=zb(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)(b2,{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)(Zb,{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)(Gb,{title:`Stage ${r.n} · ${r.name}`,sub:`${i.length} finding${i.length===1?``:`s`}`,children:(0,P.jsx)(Xb,{findings:i,emptyLabel:`No open findings at this stage.`})}),(0,P.jsxs)(Gb,{title:`Control pillar × lifecycle stage`,sub:`cell = open findings`,children:[(0,P.jsx)(Qb,{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(${Fb[e]})`}}),`worst: `,Ib[e]]},e))})]})]})]})}function A2({events:e,findings:t}){let n=zb(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=Kf({queryKey:[`finding`,a?.id],queryFn:()=>Ob.finding(a.id),enabled:!!a});return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(b2,{eyebrow:`Provenance`,title:`Audit-ready evidence`,description:`Every platform mutation is recorded, and every finding carries the evidence chain that produced it.`}),(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:Ib[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:Ib[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)($b,{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(${Ab(a.stage).v})`}}),a.stage,` · `,jb(Ab(a.stage))]})}]}),(0,P.jsx)(ex,{title:`Evidence chain — provenance`,children:o.data?.finding.evidence.length?o.data.finding.evidence.map(e=>(0,P.jsx)(tx,{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)(ex,{title:`Remediation`,children:(0,P.jsx)(`p`,{children:o.data.finding.remediation})}):null]}):(0,P.jsx)(D2,{compact:!0,title:`Nothing to audit yet`,detail:`Evidence appears once an agent reports a finding through report_finding.`})})]}),(0,P.jsx)(Gb,{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)(ax,{variant:ix(e.outcome),children:e.outcome})}),(0,P.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()})]},e.id))})]})}):(0,P.jsx)(D2,{compact:!0,title:`No governance events`,detail:`Run creation, state transitions, tool calls and finding ingestion are all recorded here.`})})]})}function j2({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:P2(e.kind)}),(0,P.jsx)(`td`,{children:(0,P.jsx)(ax,{variant:ix(e.status),children:P2(e.status)})}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function M2({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)(ax,{variant:ix(e.severity),children:P2(e.severity)})}),(0,P.jsx)(`td`,{children:(0,P.jsx)(ax,{variant:ix(e.status),children:P2(e.status)})}),(0,P.jsx)(`td`,{children:e.path??`—`}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function N2(e){return e.some(e=>e.risk===`R2`)?`R2`:e.some(e=>e.risk===`R1`)?`R1`:`R0`}function P2(e){return e.replaceAll(`_`,` `).replaceAll(`-`,` `).replace(/\b\w/g,e=>e.toUpperCase())}export{C2 as PlatformRoute};