@deepagents/devtool 7.49.0 → 7.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./css-DUjzNfgv.js","./css-BGIxQoYs.js","./html-BHZv6uqE.js","./javascript-BzbQS41l.js","./javascript-Yelw-5ZN.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./preload-helper-DtyrgAzE.js";import{$ as u,$a as d,$n as f,A as p,Aa as m,An as h,Ar as g,B as _,Ba as v,Bi as y,Cn as b,Cr as x,Ct as S,D as C,Di as w,Dn as T,Dr as E,E as D,Ea as ee,En as te,Er as O,F as ne,Fa as k,Fn as re,Fr as A,G as j,Ga as ie,Gi as M,Gn as ae,H as oe,Ha as se,Hi as N,Hn as ce,I as le,Ia as ue,In as de,It as fe,J as pe,Ja as me,Ji as he,Jn as ge,Jr as _e,K as ve,Ka as ye,Kn as be,Kr as P,L as xe,La as Se,Li as Ce,Ln as we,M as Te,Mn as Ee,Mr as De,N as Oe,Na as ke,Nn as Ae,Nr as je,O as Me,Oa as Ne,Oi as Pe,On as Fe,Ot as Ie,P as Le,Pa as Re,Pn as ze,Pr as Be,Q as Ve,Qa as He,Qn as Ue,Qr as We,R as Ge,Ra as Ke,Ri as qe,Rn as Je,S as Ye,Sn as Xe,Sr as Ze,St as Qe,T as F,Ta as $e,Tn as et,Tr as tt,Tt as nt,U as rt,Ua as it,Ui as at,Un as ot,Ur as st,V as ct,Va as lt,Vi as ut,Vn as dt,Vr as ft,W as pt,Wi as mt,Wn as ht,X as gt,Xa as _t,Y as vt,Ya as yt,Yi as bt,Yn as xt,Z as St,Za as Ct,Zi as wt,Zn as Tt,Zr as Et,_ as Dt,_n as Ot,_r as kt,_t as At,ao as jt,at as Mt,b as Nt,ba as Pt,bn as Ft,br as It,bt as Lt,ca as Rt,cr as zt,ct as Bt,dr as Vt,dt as Ht,ea as Ut,ei as Wt,eo as Gt,er as Kt,et as qt,f as I,fi as Jt,fr as Yt,ft as Xt,g as Zt,ga as Qt,gn as $t,gr as en,gt as tn,h as nn,hn as rn,hr as an,ht as on,i as sn,ia as cn,in as ln,io as un,ir as dn,it as fn,j as pn,jn as mn,jr as hn,jt as gn,k as L,kn as _n,la as vn,lt as yn,m as bn,mi as xn,mn as Sn,mr as Cn,mt as wn,na as Tn,ni as En,no as Dn,nr as On,nt as kn,oa as An,or as jn,ot as Mn,p as Nn,pi as Pn,pn as Fn,pr as In,pt as Ln,q as Rn,qa as zn,qi as Bn,qn as Vn,qr as Hn,rr as Un,rt as Wn,sr as Gn,st as Kn,t as qn,ti as Jn,to as Yn,tt as Xn,ur as Zn,ut as Qn,v as $n,vn as er,vt as tr,w as nr,wn as rr,wr as ir,wt as ar,x as or,xn as sr,xr as cr,xt as lr,y as ur,yn as dr,yr as fr,yt as pr,z as mr,za as hr,zi as gr,zn as _r,zr as vr}from"./runtime-data-D25NI3GU.js";import{A as yr,C as br,D as xr,E as Sr,F as Cr,I as wr,M as Tr,N as Er,O as Dr,P as Or,S as kr,T as Ar,_ as jr,a as Mr,b as Nr,c as Pr,d as Fr,f as Ir,g as Lr,h as Rr,j as zr,k as Br,l as Vr,m as Hr,o as Ur,p as Wr,s as Gr,t as Kr,v as qr,x as Jr,y as Yr}from"./chunk-RIHGWQV5-B2_k0rRP.js";var Xr={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};Xr.node;var Zr=Dn(Xr),Qr={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Qr.node;var eee=Dn(Qr),$r={name:`circle-x`,size:24,node:[[`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`}]],aliases:[`x-circle`]};$r.node;var ei=Dn($r),ti={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};ti.node;var ni=Dn(ti),ri={name:`copy`,size:24,node:[[`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`}]]};ri.node;var ii=Dn(ri),ai={name:`corner-down-right`,size:24,node:[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]};ai.node;var oi=Dn(ai),si={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};si.node;var ci=Dn(si),li={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};li.node;var ui=Dn(li),di={name:`loader`,size:24,node:[[`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`}]]};di.node;var fi=Dn(di),pi={name:`mic`,size:24,node:[[`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`}]]};pi.node;var mi=Dn(pi),hi={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};hi.node;var gi=Dn(hi),_i={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};_i.node;var vi=Dn(_i),yi={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};yi.node;var bi=Dn(yi),xi={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};xi.node;var Si=Dn(xi),Ci={name:`refresh-cw`,size:24,node:[[`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`}]]};Ci.node;var wi=Dn(Ci),Ti={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Ti.node;var Ei=Dn(Ti),Di={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};Di.node;var Oi=Dn(Di),R=n(e(),1);function ki(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=ie({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=Rt(a,!0,!0),u=m(),[d,f]=R.useState(),p=d===null?void 0:d??u,h=it(e=>{let t=!a,n=Ne(ee,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return R.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,h,s,a,p,c,o,f,l])}var Ai=R.createContext(void 0);function ji(){let e=R.useContext(Ai);if(e===void 0)throw Error(Se(15));return e}var Mi=`data-open`,Ni=`data-closed`,Pi=An,Fi=`data-panel-open`,Ii={[Mi]:``},Li={[Ni]:``},Ri={open(e){return e?{[Fi]:``}:null}},zi={open(e){return e?Ii:Li}},Bi={height:void 0,width:void 0};function Vi(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=R.useRef(null),f=R.useRef(null),[p,m]=R.useState(Bi),h=R.useRef(Bi),g=R.useRef(!1),_=R.useRef(s),v=R.useRef(!1),[y,b]=R.useState(!1),x=R.useRef(null),S=ue(t,d),C=mt(s),w=at(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),ee=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,te=n&&T&&f.current!==`css-animation`,O=it((e,t=!0)=>{t&&(h.current=e),m(e)}),ne=it(()=>{x.current?.(),x.current=null}),k=it(e=>{ne(),x.current=()=>{x.current=null,e()}}),re=it(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});hr(()=>{!y||u===`starting`||b(!1)},[y,u]),R.useEffect(()=>()=>{re(),ne()},[re,ne]),hr(()=>{s||(_.current=!1,v.current=!1);let e=d.current;if(!e)return;!s&&x.current&&ne();let t=Ui(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=Hi(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){O(Hi(e)),b(!0);return}if(t===`css-transition`){let t=Ki(e);if(O(Hi(e)),!n)return t;let r=Gi(e,`transition-duration`,`0s`);return k(r),b(!0),t}O(Hi(e));let r=Gi(e,`animation-name`,`none`);if(!n){r();return}let i=Gi(e,`animation-duration`,`0s`);r(),k(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(t===`none`){O(Bi,!1),c(!1);return}O(Hi(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=Hi(e);if(!(n.height>0||n.width>0)){c(!1);return}O(n),t===`css-animation`&&Gi(e,`animation-name`,`none`)()},[a,s,ne,O,c,k,D,u]),N({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&O(Bi,!1)}}),R.useEffect(()=>{if(s||!a||E!==`ending`)return;if(!d.current){c(!1),O(Bi,!1);return}let e=new AbortController,t=-1;function n(){C.current||(c(!1),O(Bi,!1))}return t=vn.request(()=>{w(n,e.signal)}),()=>{vn.cancel(t),e.abort()}},[C,a,s,E,w,O,c]),hr(()=>{let e=d.current;!e||!n||!T||e.setAttribute(`hidden`,`until-found`)},[T,n]),R.useEffect(function(){let e=d.current;if(!e)return;let t=M.create(),n=-1,r=(r,i)=>{t.start(0,()=>{C.current||(n=vn.request(()=>{C.current||(r&&(g.current=!1),i&&e.setAttribute(Pi,``),e.setAttribute(`hidden`,`until-found`))}))})},i=Bn(e,`beforematch`,t=>{let n=Ne(Pt,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}g.current=!0;let i=e.hasAttribute(Pi);e.removeAttribute(Pi),l(!0),r(!0,i)});return()=>{t.clear(),vn.cancel(n),i()}},[C,o,l]);let A=i||n||a||s;return{height:ee.height,props:{...te?{[Pi]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:A,transitionStatus:E,width:ee.width}}function Hi(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Ui(e,t){let n=Ut(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&Wi(n.animationDuration),i=Wi(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function Wi(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Gi(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function Ki(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=vn.request(n);return()=>{vn.cancel(r),n()}}var z=r(),qi=gr(`group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed`,{variants:{size:{default:`gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2`,sm:`gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5`,xs:`gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1`},orientation:{horizontal:`min-w-40 items-center`,vertical:`w-24 flex-col has-data-[slot=attachment-content]:w-30`}}});function Ji({className:e,state:t=`done`,size:n=`default`,orientation:r=`horizontal`,...i}){return(0,z.jsx)(`div`,{"data-slot":`attachment`,"data-state":t,"data-size":n,"data-orientation":r,className:ut(qi({size:n,orientation:r}),e),...i})}var Yi=gr(`relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5`,{variants:{variant:{icon:``,image:`opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover`}},defaultVariants:{variant:`icon`}});function Xi({className:e,variant:t=`icon`,...n}){return(0,z.jsx)(`div`,{"data-slot":`attachment-media`,"data-variant":t,className:ut(Yi({variant:t}),e),...n})}function Zi({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`attachment-group`,className:ut(`flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start`,e),...t})}function Qi({className:e,orientation:t=`horizontal`,...n}){return(0,z.jsx)(ze,{"data-slot":`separator`,orientation:t,className:ut(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function $i({className:e,size:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:ut(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function ea({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-header`,className:ut(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function ta({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-title`,className:ut(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function na({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-description`,className:ut(`text-sm text-muted-foreground`,e),...t})}function ra({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-action`,className:ut(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function ia({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-content`,className:ut(`px-(--card-spacing)`,e),...t})}function aa({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-footer`,className:ut(`flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)`,e),...t})}function oa(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var sa=`data-checked`,ca=`data-unchecked`;function la(e){return{checked(t){return e.indeterminate?{}:t?{[sa]:``}:{[ca]:``}},...Ae}}var ua=R.createContext({disabled:!1});function da(){return R.useContext(ua)}function fa(e,t,n,r=!0,i,a){let[o,s]=R.useState(),c=m(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return hr(()=>{let i=e||t||l||!r?void 0:pa(n.current,c);o!==i&&s(i)}),u}function pa(e,t){let n=ma(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function ma(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var ha=R.createContext(void 0);function ga(){return R.useContext(ha)}var _a=R.createContext(void 0);function va(){let e=R.useContext(_a);if(e===void 0)throw Error(Se(14));return e}var ya=`data-parent`,ba=R.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:g=!1,render:_,required:v=!1,uncheckedValue:y,value:b,nativeButton:x=!1,style:S,...C}=e,{clearErrors:w}=Fe(),{disabled:E,name:D,setDirty:ee,setFilled:O,setTouched:ne,state:k,validationMode:re,validityData:A,validation:j}=mn(),M=da(),{labelId:ae,registerControlId:oe,getDescriptionProps:se}=T(),N=ga(),le=N?.allValues===void 0?void 0:N.parent,de=le!==void 0,fe=E||M.disabled||N?.disabled||o,pe=D??d,me=b??pe,ge=m(),_e=N?.registerControlId!==oe,ve=te({id:c||void 0,enabled:_e}),ye=x?ve:ge,be={};de&&(p?be=le.getParentProps():me!==void 0&&(be=le.getChildProps(me)));let{checked:P=n,indeterminate:xe=l,onCheckedChange:Se,...Ce}=be,we=N?.value,Te=R.useRef(null),Ee=h(fe,Te),{getButtonProps:De,buttonRef:Oe}=he({disabled:fe,native:x}),Ae=N?.validation??j,[je,Me]=ie({controlled:me!==void 0&&we!==void 0&&!p?we.includes(me):P,default:i,name:`Checkbox`,state:`checked`}),Pe=de?!!P:je,Ie=de&&xe||l;_n(Te,ge,je,void 0,!N&&!fe,d);let Le=le?.registerChildId,ze=R.useRef(null),Be=Ae.registerInput,Ve=N?me:void 0,He=R.useCallback(e=>Be(e,{controlRef:Te,value:Ve}),[Be,Ve]),Ue=ue(u,ze,p?void 0:He),We=fa(a,ae,ze,!x,ve,C[`aria-label`]);hr(()=>{ze.current&&(ze.current.indeterminate=Ie),N||O(je)},[je,Ie,N,O]),ce(je,()=>{N||(w(pe),ee(je!==A.initialValue),Ae.change(je))});let Ge=Re({checked:je,disabled:fe,form:s,name:p?void 0:pe,id:x?void 0:ve,required:v,ref:Ue,style:pe?En:Jn,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(g){e.preventDefault();return}let t=e.currentTarget.checked,n=Ne(Pt,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(Se?.(t,n),!n.isCanceled&&(Me(t),me!==void 0&&N!==void 0&&!p&&!de))){let e=t?[...N.value,me]:N.value.filter(e=>e!==me);N.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){Te.current?.focus()}},b===void 0?lt:{value:(N?je&&b:b)||``},se,e=>Ae.getValidationProps(fe,e));R.useEffect(()=>{if(!le||me===void 0)return;let e=le.disabledStatesRef.current;return e.set(me,fe),()=>{e.delete(me)}},[le,fe,me]);let Ke=R.useMemo(()=>({...k,checked:Pe,disabled:fe,readOnly:g,required:v,indeterminate:Ie}),[k,Pe,fe,g,v,Ie]),qe=la(Ke),Je=ke(`span`,e,{state:Ke,ref:[Oe,Te,t],props:[{id:ye,role:`checkbox`,"aria-checked":Ie?`mixed`:Pe,"aria-readonly":g||void 0,"aria-required":v||void 0,"aria-labelledby":We,[ya]:p?``:void 0,onFocus(){Ee(!0)},onBlur(){let e=ze.current;e&&(ne(!0),Ee(!1),re===`onBlur`&&Ae.commit(N?we:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=ze.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),Ut(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||oa(t)?.click()})},onClick(e){if(g||fe)return;e.preventDefault();let t=ze.current;t&&bt(t,e)}},C,Ce,De,se,e=>Ae.getValidationProps(fe,e)],stateAttributesMapping:qe}),Ye=Je.props.id;return hr(()=>{if(!(!Le||p||me===void 0||Ye===void 0))return Le(me,Ye)},[Le,p,me,Ye]),(0,z.jsxs)(_a.Provider,{value:Ke,children:[Je,!je&&!N&&pe&&!p&&y!==void 0&&(0,z.jsx)(`input`,{type:`hidden`,form:s,name:pe,value:y,disabled:fe}),(0,z.jsx)(`input`,{...Ge,suppressHydrationWarning:!0})]})}),xa=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=va(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Rt(c),f=R.useRef(null),p={...s,transitionStatus:u};N({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...la(s),...cn},h=a||l,g=ke(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function Sa({className:e,...t}){return(0,z.jsx)(ba,{"data-slot":`checkbox`,className:ut(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(xa,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,z.jsx)(d,{})})})}var Ca=gr(`group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs`,{variants:{variant:{default:`border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30`,destructive:`border border-destructive/30 text-destructive dark:border-destructive/40`}},defaultVariants:{variant:`default`}});function wa({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,z.jsx)(`div`,{"data-slot":`code-block`,"data-variant":t,"data-size":n,className:ut(Ca({variant:t}),e),...r})}function Ta({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`code-block-actions`,className:ut(`-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10`,e),...t})}function Ea({className:e,children:t,style:n,wrap:r=!1,lineNumbers:i=!1,startLine:a=1,...o}){return(0,z.jsx)(`pre`,{"data-slot":`code-block-content`,"data-wrap":r||void 0,"data-numbered":i||void 0,dir:`ltr`,tabIndex:0,style:{counterReset:`line ${a-1}`,...n},className:ut(`min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap`,e),...o,children:(0,z.jsx)(`code`,{"data-slot":`code-block-code`,className:`grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0`,children:i&&typeof t==`string`?t.replace(/\n$/,``).split(`
|
|
2
|
+
import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./preload-helper-DtyrgAzE.js";import{$ as u,$a as d,$n as f,A as p,Aa as m,An as h,Ar as g,B as _,Ba as v,Bi as y,Cn as b,Cr as x,Ct as S,D as C,Di as w,Dn as T,Dr as E,E as D,Ea as O,En as ee,Er as k,F as te,Fa as A,Fn as ne,Fr as j,G as re,Ga as ie,Gi as M,Gn as ae,H as oe,Ha as se,Hi as N,Hn as ce,I as le,Ia as ue,In as de,It as fe,J as pe,Ja as me,Ji as he,Jn as ge,Jr as _e,K as ve,Ka as ye,Kn as be,Kr as P,L as xe,La as Se,Li as Ce,Ln as we,M as Te,Mn as Ee,Mr as De,N as Oe,Na as ke,Nn as Ae,Nr as je,O as Me,Oa as Ne,Oi as Pe,On as Fe,Ot as Ie,P as Le,Pa as Re,Pn as ze,Pr as Be,Q as Ve,Qa as He,Qn as Ue,Qr as We,R as Ge,Ra as Ke,Ri as qe,Rn as Je,S as Ye,Sn as Xe,Sr as Ze,St as Qe,T as F,Ta as $e,Tn as et,Tr as tt,Tt as nt,U as rt,Ua as it,Ui as at,Un as ot,Ur as st,V as ct,Va as lt,Vi as ut,Vn as dt,Vr as ft,W as pt,Wi as mt,Wn as ht,X as gt,Xa as _t,Y as vt,Ya as yt,Yi as bt,Yn as xt,Z as St,Za as Ct,Zi as wt,Zn as Tt,Zr as Et,_ as Dt,_n as Ot,_r as kt,_t as At,ao as jt,at as Mt,b as Nt,ba as Pt,bn as Ft,br as It,bt as Lt,ca as Rt,cr as zt,ct as Bt,dr as Vt,dt as Ht,ea as Ut,ei as Wt,eo as Gt,er as Kt,et as qt,f as I,fi as Jt,fr as Yt,ft as Xt,g as Zt,ga as Qt,gn as $t,gr as en,gt as tn,h as nn,hn as rn,hr as an,ht as on,i as sn,ia as cn,in as ln,io as un,ir as dn,it as fn,j as pn,jn as mn,jr as hn,jt as gn,k as L,kn as _n,la as vn,lt as yn,m as bn,mi as xn,mn as Sn,mr as Cn,mt as wn,na as Tn,ni as En,no as Dn,nr as On,nt as kn,oa as An,or as jn,ot as Mn,p as Nn,pi as Pn,pn as Fn,pr as In,pt as Ln,q as Rn,qa as zn,qi as Bn,qn as Vn,qr as Hn,rr as Un,rt as Wn,sr as Gn,st as Kn,t as qn,ti as Jn,to as Yn,tt as Xn,ur as Zn,ut as Qn,v as $n,vn as er,vt as tr,w as nr,wn as rr,wr as ir,wt as ar,x as or,xn as sr,xr as cr,xt as lr,y as ur,yn as dr,yr as fr,yt as pr,z as mr,za as hr,zi as gr,zn as _r,zr as vr}from"./runtime-data-D25NI3GU.js";import{A as yr,C as br,D as xr,E as Sr,F as Cr,I as wr,M as Tr,N as Er,O as Dr,P as Or,S as kr,T as Ar,_ as jr,a as Mr,b as Nr,c as Pr,d as Fr,f as Ir,g as Lr,h as Rr,j as zr,k as Br,l as Vr,m as Hr,o as Ur,p as Wr,s as Gr,t as Kr,v as qr,x as Jr,y as Yr}from"./chunk-RIHGWQV5-B2_k0rRP.js";var Xr={name:`circle-check-big`,size:24,node:[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]],aliases:[`check-circle`]};Xr.node;var Zr=Dn(Xr),Qr={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5`,key:`1awbb0`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Qr.node;var eee=Dn(Qr),$r={name:`circle-x`,size:24,node:[[`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`}]],aliases:[`x-circle`]};$r.node;var ei=Dn($r),ti={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};ti.node;var ni=Dn(ti),ri={name:`copy`,size:24,node:[[`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`}]]};ri.node;var ii=Dn(ri),ai={name:`corner-down-right`,size:24,node:[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]};ai.node;var oi=Dn(ai),si={name:`lightbulb`,size:24,node:[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]};si.node;var ci=Dn(si),li={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};li.node;var ui=Dn(li),di={name:`loader`,size:24,node:[[`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`}]]};di.node;var fi=Dn(di),pi={name:`mic`,size:24,node:[[`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`}]]};pi.node;var mi=Dn(pi),hi={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};hi.node;var gi=Dn(hi),_i={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};_i.node;var vi=Dn(_i),yi={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};yi.node;var bi=Dn(yi),xi={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};xi.node;var Si=Dn(xi),Ci={name:`refresh-cw`,size:24,node:[[`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`}]]};Ci.node;var wi=Dn(Ci),Ti={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Ti.node;var Ei=Dn(Ti),Di={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};Di.node;var Oi=Dn(Di),R=n(e(),1);function ki(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=ie({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=Rt(a,!0,!0),u=m(),[d,f]=R.useState(),p=d===null?void 0:d??u,h=it(e=>{let t=!a,n=Ne(O,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return R.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:h,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,h,s,a,p,c,o,f,l])}var Ai=R.createContext(void 0);function ji(){let e=R.useContext(Ai);if(e===void 0)throw Error(Se(15));return e}var Mi=`data-open`,Ni=`data-closed`,Pi=An,Fi=`data-panel-open`,Ii={[Mi]:``},Li={[Ni]:``},Ri={open(e){return e?{[Fi]:``}:null}},zi={open(e){return e?Ii:Li}},Bi={height:void 0,width:void 0};function Vi(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=R.useRef(null),f=R.useRef(null),[p,m]=R.useState(Bi),h=R.useRef(Bi),g=R.useRef(!1),_=R.useRef(s),v=R.useRef(!1),[y,b]=R.useState(!1),x=R.useRef(null),S=ue(t,d),C=mt(s),w=at(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),O=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,ee=n&&T&&f.current!==`css-animation`,k=it((e,t=!0)=>{t&&(h.current=e),m(e)}),te=it(()=>{x.current?.(),x.current=null}),A=it(e=>{te(),x.current=()=>{x.current=null,e()}}),ne=it(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});hr(()=>{!y||u===`starting`||b(!1)},[y,u]),R.useEffect(()=>()=>{ne(),te()},[ne,te]),hr(()=>{s||(_.current=!1,v.current=!1);let e=d.current;if(!e)return;!s&&x.current&&te();let t=Ui(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=Hi(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){k(Hi(e)),b(!0);return}if(t===`css-transition`){let t=Ki(e);if(k(Hi(e)),!n)return t;let r=Gi(e,`transition-duration`,`0s`);return A(r),b(!0),t}k(Hi(e));let r=Gi(e,`animation-name`,`none`);if(!n){r();return}let i=Gi(e,`animation-duration`,`0s`);r(),A(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(t===`none`){k(Bi,!1),c(!1);return}k(Hi(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=Hi(e);if(!(n.height>0||n.width>0)){c(!1);return}k(n),t===`css-animation`&&Gi(e,`animation-name`,`none`)()},[a,s,te,k,c,A,D,u]),N({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&k(Bi,!1)}}),R.useEffect(()=>{if(s||!a||E!==`ending`)return;if(!d.current){c(!1),k(Bi,!1);return}let e=new AbortController,t=-1;function n(){C.current||(c(!1),k(Bi,!1))}return t=vn.request(()=>{w(n,e.signal)}),()=>{vn.cancel(t),e.abort()}},[C,a,s,E,w,k,c]),hr(()=>{let e=d.current;!e||!n||!T||e.setAttribute(`hidden`,`until-found`)},[T,n]),R.useEffect(function(){let e=d.current;if(!e)return;let t=M.create(),n=-1,r=(r,i)=>{t.start(0,()=>{C.current||(n=vn.request(()=>{C.current||(r&&(g.current=!1),i&&e.setAttribute(Pi,``),e.setAttribute(`hidden`,`until-found`))}))})},i=Bn(e,`beforematch`,t=>{let n=Ne(Pt,t);if(o(!0,n),n.isCanceled){r(!1,!1);return}g.current=!0;let i=e.hasAttribute(Pi);e.removeAttribute(Pi),l(!0),r(!0,i)});return()=>{t.clear(),vn.cancel(n),i()}},[C,o,l]);let j=i||n||a||s;return{height:O.height,props:{...ee?{[Pi]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:j,transitionStatus:E,width:O.width}}function Hi(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Ui(e,t){let n=Ut(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&Wi(n.animationDuration),i=Wi(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function Wi(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function Gi(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function Ki(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=vn.request(n);return()=>{vn.cancel(r),n()}}var z=r(),qi=gr(`group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed`,{variants:{size:{default:`gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2`,sm:`gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5`,xs:`gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1`},orientation:{horizontal:`min-w-40 items-center`,vertical:`w-24 flex-col has-data-[slot=attachment-content]:w-30`}}});function Ji({className:e,state:t=`done`,size:n=`default`,orientation:r=`horizontal`,...i}){return(0,z.jsx)(`div`,{"data-slot":`attachment`,"data-state":t,"data-size":n,"data-orientation":r,className:ut(qi({size:n,orientation:r}),e),...i})}var Yi=gr(`relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5`,{variants:{variant:{icon:``,image:`opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover`}},defaultVariants:{variant:`icon`}});function Xi({className:e,variant:t=`icon`,...n}){return(0,z.jsx)(`div`,{"data-slot":`attachment-media`,"data-variant":t,className:ut(Yi({variant:t}),e),...n})}function Zi({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`attachment-group`,className:ut(`flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start`,e),...t})}function Qi({className:e,orientation:t=`horizontal`,...n}){return(0,z.jsx)(ze,{"data-slot":`separator`,orientation:t,className:ut(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}function $i({className:e,size:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:ut(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function ea({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-header`,className:ut(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function ta({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-title`,className:ut(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function na({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-description`,className:ut(`text-sm text-muted-foreground`,e),...t})}function ra({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-action`,className:ut(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function ia({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-content`,className:ut(`px-(--card-spacing)`,e),...t})}function aa({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`card-footer`,className:ut(`flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)`,e),...t})}function oa(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var sa=`data-checked`,ca=`data-unchecked`;function la(e){return{checked(t){return e.indeterminate?{}:t?{[sa]:``}:{[ca]:``}},...Ae}}var ua=R.createContext({disabled:!1});function da(){return R.useContext(ua)}function fa(e,t,n,r=!0,i,a){let[o,s]=R.useState(),c=m(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return hr(()=>{let i=e||t||l||!r?void 0:pa(n.current,c);o!==i&&s(i)}),u}function pa(e,t){let n=ma(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function ma(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var ha=R.createContext(void 0);function ga(){return R.useContext(ha)}var _a=R.createContext(void 0);function va(){let e=R.useContext(_a);if(e===void 0)throw Error(Se(14));return e}var ya=`data-parent`,ba=R.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:g=!1,render:_,required:v=!1,uncheckedValue:y,value:b,nativeButton:x=!1,style:S,...C}=e,{clearErrors:w}=Fe(),{disabled:E,name:D,setDirty:O,setFilled:k,setTouched:te,state:A,validationMode:ne,validityData:j,validation:re}=mn(),M=da(),{labelId:ae,registerControlId:oe,getDescriptionProps:se}=T(),N=ga(),le=N?.allValues===void 0?void 0:N.parent,de=le!==void 0,fe=E||M.disabled||N?.disabled||o,pe=D??d,me=b??pe,ge=m(),_e=N?.registerControlId!==oe,ve=ee({id:c||void 0,enabled:_e}),ye=x?ve:ge,be={};de&&(p?be=le.getParentProps():me!==void 0&&(be=le.getChildProps(me)));let{checked:P=n,indeterminate:xe=l,onCheckedChange:Se,...Ce}=be,we=N?.value,Te=R.useRef(null),Ee=h(fe,Te),{getButtonProps:De,buttonRef:Oe}=he({disabled:fe,native:x}),Ae=N?.validation??re,[je,Me]=ie({controlled:me!==void 0&&we!==void 0&&!p?we.includes(me):P,default:i,name:`Checkbox`,state:`checked`}),Pe=de?!!P:je,Ie=de&&xe||l;_n(Te,ge,je,void 0,!N&&!fe,d);let Le=le?.registerChildId,ze=R.useRef(null),Be=Ae.registerInput,Ve=N?me:void 0,He=R.useCallback(e=>Be(e,{controlRef:Te,value:Ve}),[Be,Ve]),Ue=ue(u,ze,p?void 0:He),We=fa(a,ae,ze,!x,ve,C[`aria-label`]);hr(()=>{ze.current&&(ze.current.indeterminate=Ie),N||k(je)},[je,Ie,N,k]),ce(je,()=>{N||(w(pe),O(je!==j.initialValue),Ae.change(je))});let Ge=Re({checked:je,disabled:fe,form:s,name:p?void 0:pe,id:x?void 0:ve,required:v,ref:Ue,style:pe?En:Jn,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(g){e.preventDefault();return}let t=e.currentTarget.checked,n=Ne(Pt,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(Se?.(t,n),!n.isCanceled&&(Me(t),me!==void 0&&N!==void 0&&!p&&!de))){let e=t?[...N.value,me]:N.value.filter(e=>e!==me);N.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){Te.current?.focus()}},b===void 0?lt:{value:(N?je&&b:b)||``},se,e=>Ae.getValidationProps(fe,e));R.useEffect(()=>{if(!le||me===void 0)return;let e=le.disabledStatesRef.current;return e.set(me,fe),()=>{e.delete(me)}},[le,fe,me]);let Ke=R.useMemo(()=>({...A,checked:Pe,disabled:fe,readOnly:g,required:v,indeterminate:Ie}),[A,Pe,fe,g,v,Ie]),qe=la(Ke),Je=ke(`span`,e,{state:Ke,ref:[Oe,Te,t],props:[{id:ye,role:`checkbox`,"aria-checked":Ie?`mixed`:Pe,"aria-readonly":g||void 0,"aria-required":v||void 0,"aria-labelledby":We,[ya]:p?``:void 0,onFocus(){Ee(!0)},onBlur(){let e=ze.current;e&&(te(!0),Ee(!1),ne===`onBlur`&&Ae.commit(N?we:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=ze.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),Ut(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||oa(t)?.click()})},onClick(e){if(g||fe)return;e.preventDefault();let t=ze.current;t&&bt(t,e)}},C,Ce,De,se,e=>Ae.getValidationProps(fe,e)],stateAttributesMapping:qe}),Ye=Je.props.id;return hr(()=>{if(!(!Le||p||me===void 0||Ye===void 0))return Le(me,Ye)},[Le,p,me,Ye]),(0,z.jsxs)(_a.Provider,{value:Ke,children:[Je,!je&&!N&&pe&&!p&&y!==void 0&&(0,z.jsx)(`input`,{type:`hidden`,form:s,name:pe,value:y,disabled:fe}),(0,z.jsx)(`input`,{...Ge,suppressHydrationWarning:!0})]})}),xa=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=va(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Rt(c),f=R.useRef(null),p={...s,transitionStatus:u};N({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...la(s),...cn},h=a||l,g=ke(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function Sa({className:e,...t}){return(0,z.jsx)(ba,{"data-slot":`checkbox`,className:ut(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(xa,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,z.jsx)(d,{})})})}var Ca=gr(`group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs`,{variants:{variant:{default:`border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30`,destructive:`border border-destructive/30 text-destructive dark:border-destructive/40`}},defaultVariants:{variant:`default`}});function wa({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,z.jsx)(`div`,{"data-slot":`code-block`,"data-variant":t,"data-size":n,className:ut(Ca({variant:t}),e),...r})}function Ta({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`code-block-actions`,className:ut(`-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10`,e),...t})}function Ea({className:e,children:t,style:n,wrap:r=!1,lineNumbers:i=!1,startLine:a=1,...o}){return(0,z.jsx)(`pre`,{"data-slot":`code-block-content`,"data-wrap":r||void 0,"data-numbered":i||void 0,dir:`ltr`,tabIndex:0,style:{counterReset:`line ${a-1}`,...n},className:ut(`min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap`,e),...o,children:(0,z.jsx)(`code`,{"data-slot":`code-block-code`,className:`grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0`,children:i&&typeof t==`string`?t.replace(/\n$/,``).split(`
|
|
3
3
|
`).map((e,t)=>(0,z.jsx)(Oa,{children:e},t)):t})})}var Da=gr(`relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']`,{variants:{variant:{default:``,added:`bg-muted after:content-['+']`,removed:`bg-destructive/10 after:text-destructive after:content-['−']`,highlighted:`bg-muted`}},defaultVariants:{variant:`default`}});function Oa({className:e,variant:t=`default`,children:n,...r}){let i=n==null||n===``||Array.isArray(n)&&n.length===0;return(0,z.jsx)(`span`,{"data-slot":`code-block-line`,"data-variant":t,className:ut(Da({variant:t}),e),...r,children:(0,z.jsx)(`span`,{"data-slot":`code-block-line-content`,className:`min-w-0`,children:i?`
|
|
4
|
-
`:n})})}var ka={...zi,...cn},Aa=R.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=it(o),d=ki({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=R.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=R.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=ke(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:ka});return(0,z.jsx)(Ai.Provider,{value:p,children:m})}),ja={...Ri,...cn},Ma=R.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=ji(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=he({disabled:c,native:u});return ke(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:ja})}),Na=`--collapsible-panel-height`,Pa=`--collapsible-panel-width`,Fa=R.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=ji(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;hr(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:ee}=Vi({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),te={...g,transitionStatus:D},O=k(s,te),ne=ke(`div`,{...e,style:void 0},{state:te,ref:w,props:[C,{style:{[Na]:S===void 0?`auto`:`${S}px`,[Pa]:ee===void 0?`auto`:`${ee}px`}},c,O?{style:O}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:ka});return E?ne:null});function Ia({...e}){return(0,z.jsx)(Aa,{"data-slot":`collapsible`,...e})}function La({...e}){return(0,z.jsx)(Ma,{"data-slot":`collapsible-trigger`,...e})}function Ra({...e}){return(0,z.jsx)(Fa,{"data-slot":`collapsible-content`,...e})}var za=R.createContext(void 0);function Ba(e=!1){let t=R.useContext(za);if(!t&&!e)throw Error(Se(86));return t}Object.keys(Ee);function Va(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var Ha=`data-composite-item-active`;function Ua(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:p=v}=e,[m,h]=R.useState(0),g=r!=null,_=R.useRef(null),y=ue(_,c),b=R.useRef([]),x=R.useRef(!1),S=R.useRef(null),C=o??m,w=it((e,t=!1)=>{if(S.current=b.current[e]??null,(s??h)(e),t){let t=b.current[e];Kt(_.current,t,a,n)}}),T=it(e=>{if(e.size===0)return;if(x.current){let e=b.current,t=e.indexOf(S.current);if(t===-1){let t=e[C];!t||We(e,C,d)?w(Wa(e,d)):S.current=t}else t!==C&&w(t);return}x.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)w(i);else if(We(t,C,d)){let e=P(t,{disabledIndices:d});Et(t,e)||w(e)}Kt(_.current,r,a,n)});hr(()=>{if(d==null||o!=null||!x.current)return;let e=b.current;if(We(e,C,d)){let t=P(e,{disabledIndices:d});Et(e,t)||w(t)}},[d,o,C,b,w]);let E=it((e,t,n)=>i?i(e,t,n,b):n),D=it(e=>{let o=e.key===`Home`||e.key===`End`;if(!xt.has(e.key)||!l&&o||Ga(e,p)||!_.current)return;let s=a===`rtl`,c=s?be:Vn,m=s?Vn:be,h=n===`vertical`?ae:c,v=n===`vertical`?ge:m,y=Pe(e.nativeEvent);if(y!=null&&f(y)&&!Sn(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==h&&t>0)return}let x=C,S=_e(b,d),T=Hn(b,d);r!=null&&(x=r({disabledIndices:d,elementsRef:b,event:e,highlightedIndex:C,loopFocus:t,maxIndex:T,minIndex:S,onLoop:E,orientation:n,rtl:s}));let D=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,ee=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?x=S:e.key===`End`&&(x=T)),x===C&&(D||ee)&&(t&&x===T&&D?(x=S,i&&(x=i(e,C,x,b))):t&&x===S&&ee?(x=T,i&&(x=i(e,C,x,b))):x=P(b.current,{startingIndex:x,decrement:ee,disabledIndices:d})),x!==C&&!Et(b.current,x)&&(u&&e.stopPropagation(),(g||o||D||ee)&&e.preventDefault(),w(x,!0),queueMicrotask(()=>{b.current[x]?.focus()}))});return{props:{ref:y,onFocus(e){let t=_.current,n=Pe(e.nativeEvent);!t||n==null||!f(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:C,onHighlightedIndexChange:w,elementsRef:b,onMapChange:T,relayKeyboardEvent:D}}function Wa(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(!(!i||We(e,r,t))){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function Ga(e,t){for(let n of Tt)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Ka(e){let{render:t,className:n,style:r,refs:i=v,props:a=v,state:o=lt,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:y,modifierKeys:x,highlightItemOnHover:S=!1,tag:C=`div`,...w}=e,{props:T,highlightedIndex:E,onHighlightedIndexChange:D,elementsRef:ee,onMapChange:te,relayKeyboardEvent:O}=Ua({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:b(),disabledIndices:y,modifierKeys:x}),ne=ke(C,e,{state:o,ref:i,props:[T,...a,w],stateAttributesMapping:s}),k=R.useMemo(()=>({highlightedIndex:E,onHighlightedIndexChange:D,highlightItemOnHover:S,relayKeyboardEvent:O}),[E,D,S,O]);return(0,z.jsx)(wt.Provider,{value:k,children:(0,z.jsx)(Ke,{elementsRef:ee,onMapChange:e=>{h?.(e),te(e)},children:ne})})}var qa=R.createContext(void 0);function Ja(e){let t=R.useContext(qa);if(t===void 0&&!e)throw Error(Se(47));return t}var Ya=n(o(),1),Xa={...zt,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!zt.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&zt.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>zt.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Za=class extends Zn{constructor(e,t,n){let r=new an;super(Qa(e,r,t,n),$a(r),Xa)}setOpen=(e,t)=>{let n=t.reason===$e,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=fr(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=cr(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),Ya.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Qa(e,t,n,r=!1){let i={...Gn(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function $a(e){return{popupRef:R.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:R.createRef(),beforeTriggerFocusGuardRef:R.createRef(),beforeContentFocusGuardRef:R.createRef(),stickIfOpenTimeout:new M,stickIfOpen:!0,triggerElements:e}}var eo=Vt(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=no(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),O(u,d),Ze(u);let{forceUnmount:m}=x(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),R.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),R.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ne(Qt))}),[m,u]);let h=d||f||s!=null;return(0,z.jsxs)(qa.Provider,{value:u,children:[s&&(0,z.jsx)(kt,{handle:s,store:u}),h&&(0,z.jsx)(ro,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function to(e){return Ja(!0)?(0,z.jsx)(eo,{props:e}):(0,z.jsx)(Be,{children:(0,z.jsx)(eo,{props:e})})}function no(e,t){let n=tt((e,n)=>new Za(t,e,n));return R.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function ro({store:e,modal:t}){let n=g(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return ir(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var io=Yt(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,h=Ja(!0),g=jn(s)??h;if(!g)throw Error(Se(74));let _=m(f),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=R.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=E(_,S,g,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),T=g.useState(`isPressOpenedByTrigger`,_),D=g.useState(`isTouchPressOpen`,l),ee=g.useState(`hasTriggerFocusGuards`,_),te=Un(y,{enabled:!a&&l&&!D,mouseOnly:!0,move:!1,handleClose:On(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),O=hn(y,{stickIfOpen:it(()=>g.context.stickIfOpen)}),ne=dt(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),k=g.useState(`triggerProps`,w),{getButtonProps:re,buttonRef:A}=he({disabled:a,native:o}),j={open(e){return T?Pn.open(e):xn.open(e)}},{handlePreFocusGuardFocus:ie,handleFocusTargetFocus:M}=rn(g,S),ae=ke(`button`,e,{state:{disabled:a,open:b},ref:[A,t,C,S],props:[O.reference,te,k,ne,{[ft]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,re],stateAttributesMapping:j}),oe=(0,z.jsx)(R.Fragment,{children:ae},_);return ee?(0,z.jsxs)(R.Fragment,{children:[(0,z.jsx)(Wt,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:ie}),oe,(0,z.jsx)(Wt,{ref:g.context.triggerFocusTargetRef,onFocus:M})]}):oe}),ao=R.createContext(void 0);function oo(){let e=R.useContext(ao);if(e===void 0)throw Error(Se(45));return e}var so=R.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Ja().useState(`mounted`)||n?(0,z.jsx)(ao.Provider,{value:n,children:(0,z.jsx)(vr,{ref:t,...r})}):null}),co=R.createContext(void 0);function lo(){let e=R.useContext(co);if(!e)throw Error(Se(46));return e}var uo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=st,..._}=e,v=Ja(),y=oo(),b=A(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),ee=v.useState(`positionerElement`),te=v.useState(`instantType`),O=v.useState(`transitionStatus`),ne=Xe({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});Ot({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:ee,open:C});let k=E===!0&&w!==`trigger-hover`;dr(C&&k,D===`touch`,ee,T);let re=v.useStateSetter(`positionerElement`),j=Ft(e,{open:C,side:ne.side,align:ne.align,anchorHidden:ne.anchorHidden,instant:te},{styles:ne.positionerStyles,transitionStatus:O,props:_,refs:[t,re],hidden:!S,inert:!C});return(0,z.jsxs)(co.Provider,{value:ne,children:[S&&k&&(0,z.jsx)(ot,{inert:ht(!C),cutout:T}),(0,z.jsx)(je,{id:b,children:j})]})}),fo=R.createContext(void 0);function po(){let[e,t]=R.useState(0),n=it(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:R.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var mo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Ja(),l=lo(),u=er(!0)!=null,{context:d,hasClosePart:f}=po(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),ee=c.useState(`closeDelay`);N({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),dn(w,{enabled:D&&!E,closeDelay:ee});let te=a===void 0?It(c.context.popupRef):a,O=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,O);let ne=c.useStateSetter(`popupElement`),k=ke(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,ne],props:[_,{id:T,role:`dialog`,...en,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&xt.has(e.key)&&e.stopPropagation()}},sr(g),s],stateAttributesMapping:Jt});return(0,z.jsx)(De,{context:w,openInteractionType:m,modal:O,disabled:!x||S===`trigger-hover`,initialFocus:te,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:Tn(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,z.jsx)(fo.Provider,{value:d,children:k})})}),ho=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ja(),s=m(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),ke(`h2`,e,{ref:t,props:[{id:s},a]})}),go=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ja(),s=m(a.id);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),ke(`p`,e,{ref:t,props:[{id:s},a]})}),_o=`data-checked`,vo=`data-unchecked`,yo={checked(e){return e?{[_o]:``}:{[vo]:``}},...cn,...Ae},bo=R.createContext(void 0);function xo(){return R.useContext(bo)}var So=R.createContext(void 0);function Co(){let e=R.useContext(So);if(e===void 0)throw Error(Se(52));return e}var wo=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,g=xo(),{disabled:_,readOnly:v,required:y,form:b,checkedValue:x,touched:S=!1,validation:C,name:w,setCheckedValue:E=se,setTouched:D=se,registerInputRef:ee=se}=g??{},{setTouched:O,setFilled:ne,state:k,disabled:re}=mn(),A=da(),{labelId:j,getDescriptionProps:ie}=T(),M=re||A.disabled||_||i,ae=v||a,oe=y||o,N=b,ce=g?x===c:c===``,le=R.useRef(null),de=h(M,le),fe=R.useRef(null),pe=C?.registerInput,me=ue(l,fe,ee,R.useCallback(e=>pe?.(e,{controlRef:le,value:void 0}),[pe]));hr(()=>{fe.current?.checked&&ne(!0)},[ne]),hr(()=>{if(fe.current){if(M&&ce){ee(null);return}ee(fe.current)}},[ce,M,ee]);let ge=m(),_e=te({id:d}),ve=u?void 0:_e,ye={role:`radio`,"aria-checked":ce,"aria-labelledby":fa(s,j,fe,!u,ve,p[`aria-label`]),[Ha]:ce?``:void 0,id:u?_e:ge,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||M||ae)return;e.preventDefault();let t=fe.current;t&&bt(t,e)},onFocus(e){de(!0),!(e.defaultPrevented||M||ae||!S)&&(fe.current?.click(),D(!1))},onBlur(){g||de(!1)}},{getButtonProps:be,buttonRef:P}=he({disabled:M,native:u,composite:!1}),xe={type:`radio`,ref:me,form:N,id:ve,name:w,tabIndex:-1,style:w?En:Jn,"aria-hidden":!0,...c===void 0?lt:{value:rr(c)},disabled:M,checked:ce,required:oe,readOnly:ae,onChange(e){if(e.nativeEvent.defaultPrevented||M||ae||c===void 0)return;let t=Ne(Pt,e.nativeEvent);E(c,t),!t.isCanceled&&O(!0)},onClick(e){e.stopPropagation()},onFocus(){le.current?.focus()}},Se=R.useMemo(()=>({...k,required:oe,disabled:M,readOnly:ae,checked:ce}),[k,M,ae,ce,oe]),Ce=Se,we=g!==void 0,Te=[t,le,P],Ee=[ye,p,be,ie,C?e=>C.getValidationProps(M,e):lt],De=ke(`span`,e,{enabled:!we,state:Se,ref:Te,props:Ee,stateAttributesMapping:yo});return(0,z.jsxs)(So.Provider,{value:Ce,children:[we?(0,z.jsx)($t,{tag:`span`,render:n,className:r,style:f,state:Se,refs:Te,props:Ee,stateAttributesMapping:yo}):De,(0,z.jsx)(`input`,{...xe,suppressHydrationWarning:!0})]})}),To=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Co(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Rt(c),f={...s,transitionStatus:u},p=R.useRef(null),m=a||l,h=ke(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:yo});return N({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),Eo=[Ue],Do=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:h,...g}=e,{setTouched:_,setFocused:v,validationMode:y,name:b,disabled:x,state:S,validation:C,setDirty:E,setFilled:D,validityData:ee}=mn(),{labelId:te}=T(),{clearErrors:O,elementRef:ne}=Fe(),k=Ba(!0),re=x||i,A=b??d,j=m(p),[M,ae]=ie({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[oe,se]=R.useState(!1),N=it((e,t)=>{s?.(e,t),!t.isCanceled&&ae(e)}),le=C.getInputControl,de=R.useMemo(()=>({get current(){return le()}}),[le]),fe=R.useRef(null),pe=R.useRef(null),me=ue(fe,f),he=R.useRef(me),ge=it(e=>{fe.current===e&&he.current===me||(he.current=me,me?.(e))});hr(()=>{ge(fe.current)},[me,ge]);let _e=it(e=>{if(e){if(!e.disabled){pe.current||=e;let t=fe.current;(e.checked||t==null||t.disabled)&&ge(e)}return()=>{pe.current===e&&(pe.current=null),fe.current===e&&ge(null)}}}),ve=it(()=>{let e=ne.current;if(!e)return M??null;for(let t of C.registeredInputs.keys())if(t.checked&&Va(t,e))return M??null;return null});_n(de,j,M??null,ve,!re,d),ce(M,()=>{O(A),E(M!==ee.initialValue),D(M!=null),C.change(M);let e=pe.current;M==null&&e&&!e.disabled&&ge(e)});let ye=te??k?.legendId,be={...S,disabled:re??!1,required:o??!1,readOnly:a??!1},P=R.useMemo(()=>({checkedValue:M,disabled:re,form:u,validation:C,name:A,readOnly:a,registerInputRef:_e,required:o,setCheckedValue:N,setTouched:se,touched:oe}),[M,re,u,C,A,a,_e,o,N,se,oe]),xe={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":re||void 0,"aria-readonly":a||void 0,"aria-labelledby":ye,onBlur(e){w(e.currentTarget,e.relatedTarget)||(se(!1),_(!0),v(!1),y===`onBlur`&&C.commit(M))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&se(!0)}};return(0,z.jsx)(bo.Provider,{value:P,children:(0,z.jsx)(Ka,{render:n,className:r,style:h,state:be,props:[xe,g,e=>C.getValidationProps(re??!1,e)],refs:[t],stateAttributesMapping:Ae,enableHomeAndEndKeys:!1,modifierKeys:Eo})})}),Oo=gr(`group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-2.5 px-3 py-2.5`,sm:`gap-2.5 px-3 py-2.5`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function ko({className:e,variant:t=`default`,size:n=`default`,render:r,...i}){return de({defaultTagName:`div`,props:Re({className:ut(Oo({variant:t,size:n,className:e}))},i),render:r,state:{slot:`item`,variant:t,size:n}})}var Ao=gr(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function jo({className:e,variant:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:ut(Ao({variant:t,className:e})),...n})}function Mo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-content`,className:ut(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none`,e),...t})}function No({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-title`,className:ut(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function Po({className:e,...t}){return(0,z.jsx)(`p`,{"data-slot":`item-description`,className:ut(`line-clamp-2 text-start text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function Fo({...e}){return(0,z.jsx)(to,{"data-slot":`popover`,...e})}function Io({...e}){return(0,z.jsx)(io,{"data-slot":`popover-trigger`,...e})}function Lo({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,z.jsx)(so,{children:(0,z.jsx)(uo,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,z.jsx)(mo,{"data-slot":`popover-content`,className:ut(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-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-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function Ro({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`popover-header`,className:ut(`flex flex-col gap-0.5 text-sm`,e),...t})}function zo({className:e,...t}){return(0,z.jsx)(ho,{"data-slot":`popover-title`,className:ut(`font-medium`,e),...t})}function Bo({className:e,...t}){return(0,z.jsx)(go,{"data-slot":`popover-description`,className:ut(`text-muted-foreground`,e),...t})}function Vo({className:e,...t}){return(0,z.jsx)(Do,{"data-slot":`radio-group`,className:ut(`grid w-full gap-2`,e),...t})}function Ho({className:e,...t}){return(0,z.jsx)(wo,{"data-slot":`radio-group-item`,className:ut(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(To,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`absolute top-1/2 start-1/2 size-2 -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}function Uo({className:e,...t}){return(0,z.jsx)(me,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:ut(`size-4 animate-spin`,e),...t})}var Wo=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function Go(e){return Ko(e)}function Ko(e){return Array.isArray(e)?qo(e):e instanceof RegExp?e:typeof e==`object`?Jo(e):e}function qo(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Ko(e[n]);return t}function Jo(e){let t={};for(let n in e)t[n]=Ko(e[n]);return t}function Yo(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Xo(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Xo(e.substring(0,e.length-1)):e.substr(~t+1)}var Zo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Qo=class{static hasCaptures(e){return e===null?!1:(Zo.lastIndex=0,Zo.test(e))}static replaceCaptures(e,t,n){return e.replace(Zo,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function $o(e,t){return e<t?-1:+(e>t)}function es(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=$o(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function ts(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function ns(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var rs=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},is=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(us(e),t)}static createFromParsedTheme(e,t){return ps(e,t)}_cachedMatchRoot=new rs(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>ss(e.parent,t.parentScopes));return n?new ls(n.fontStyle,n.foreground,n.background):null}},as=class e{constructor(e,t){this.parent=e,this.scopeName=t}parent;scopeName;static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function ss(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!cs(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function cs(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var ls=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function us(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&ts(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&ts(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new ds(l,u,e,o,s,c)}}return n}var ds=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}scope;parentScopes;index;fontStyle;foreground;background},fs=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(fs||{});function ps(e,t){e.sort((e,t)=>{let n=$o(e.scope,t.scope);return n!==0||(n=es(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new ms(t),o=new ls(n,a.getId(r),a.getId(i)),s=new _s(new gs(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new is(a,o,s)}var ms=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},hs=Object.freeze([]),gs=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||hs,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},_s=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),gs.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(es(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new gs(e,t,n,r,i))}},vs=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=bs(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function ys(e){return e}function bs(e){return e}function xs(e,t){let n=[],r=Cs(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(Ss(i)){let e=[];do e.push(i),i=r.next();while(Ss(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function Ss(e){return!!e&&!!e.match(/[\w\.:]+/)}function Cs(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function ws(e){typeof e.dispose==`function`&&e.dispose()}var Ts=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},Es=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Ds=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Os=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Ts(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ds;for(let n of e)ks(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof Ts){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function ks(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof Ts?js({baseGrammar:a,selfGrammar:i},r):As(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new Ts(e))}function As(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Ms([r],t,n)}}function js(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ms(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ms(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ms(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Yo({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Ms(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Ls(i);switch(a.kind){case 0:js({...t,selfGrammar:t.baseGrammar},n);break;case 1:js(t,n);break;case 2:As(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?As(a.ruleName,i,n):js(i,n)}else a.kind===4?n.add(new Es(a.scopeName,a.ruleName)):n.add(new Ts(a.scopeName));break}}}var Ns=class{kind=0},Ps=class{kind=1},Fs=class{constructor(e){this.ruleName=e}ruleName;kind=2},Is=class{constructor(e){this.scopeName=e}scopeName;kind=3},tee=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function Ls(e){if(e===`$base`)return new Ns;if(e===`$self`)return new Ps;let t=e.indexOf(`#`);return t===-1?new Is(e):t===0?new Fs(e.substring(1)):new tee(e.substring(0,t),e.substring(t+1))}var Rs=/\\(\d+)/,zs=/\\(\d+)/g,Bs=-1,Vs=-2;function Hs(e){return e}function Us(e){return e}var Ws=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Qo.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Qo.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Xo(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Qo.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Qo.replaceCaptures(this._contentName,e,t)}},Gs=class extends Ws{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Ks=class extends Ws{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Zs(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Qs,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},qs=class extends Ws{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Qs,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Js=class extends Ws{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Zs(i,this.id),this.beginCaptures=a,this._end=new Zs(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Qs;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Ys=class extends Ws{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Zs(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Zs(o,Vs),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Qs;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Qs,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},Xs=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Gs(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Ks(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Yo({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new qs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Ys(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Js(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Ls(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof qs||e instanceof Js||e instanceof Ys)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Zs=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=Rs.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return zs.lastIndex=0,this.source.replace(zs,(e,t)=>ns(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Qs=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new $s(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new $s(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},$s=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
4
|
+
`:n})})}var ka={...zi,...cn},Aa=R.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=it(o),d=ki({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=R.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=R.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=ke(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:ka});return(0,z.jsx)(Ai.Provider,{value:p,children:m})}),ja={...Ri,...cn},Ma=R.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=ji(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=he({disabled:c,native:u});return ke(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:ja})}),Na=`--collapsible-panel-height`,Pa=`--collapsible-panel-width`,Fa=R.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=ji(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;hr(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=Vi({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),ee={...g,transitionStatus:D},k=A(s,ee),te=ke(`div`,{...e,style:void 0},{state:ee,ref:w,props:[C,{style:{[Na]:S===void 0?`auto`:`${S}px`,[Pa]:O===void 0?`auto`:`${O}px`}},c,k?{style:k}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:ka});return E?te:null});function Ia({...e}){return(0,z.jsx)(Aa,{"data-slot":`collapsible`,...e})}function La({...e}){return(0,z.jsx)(Ma,{"data-slot":`collapsible-trigger`,...e})}function Ra({...e}){return(0,z.jsx)(Fa,{"data-slot":`collapsible-content`,...e})}var za=R.createContext(void 0);function Ba(e=!1){let t=R.useContext(za);if(!t&&!e)throw Error(Se(86));return t}Object.keys(Ee);function Va(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var Ha=`data-composite-item-active`;function Ua(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:p=v}=e,[m,h]=R.useState(0),g=r!=null,_=R.useRef(null),y=ue(_,c),b=R.useRef([]),x=R.useRef(!1),S=R.useRef(null),C=o??m,w=it((e,t=!1)=>{if(S.current=b.current[e]??null,(s??h)(e),t){let t=b.current[e];Kt(_.current,t,a,n)}}),T=it(e=>{if(e.size===0)return;if(x.current){let e=b.current,t=e.indexOf(S.current);if(t===-1){let t=e[C];!t||We(e,C,d)?w(Wa(e,d)):S.current=t}else t!==C&&w(t);return}x.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)w(i);else if(We(t,C,d)){let e=P(t,{disabledIndices:d});Et(t,e)||w(e)}Kt(_.current,r,a,n)});hr(()=>{if(d==null||o!=null||!x.current)return;let e=b.current;if(We(e,C,d)){let t=P(e,{disabledIndices:d});Et(e,t)||w(t)}},[d,o,C,b,w]);let E=it((e,t,n)=>i?i(e,t,n,b):n),D=it(e=>{let o=e.key===`Home`||e.key===`End`;if(!xt.has(e.key)||!l&&o||Ga(e,p)||!_.current)return;let s=a===`rtl`,c=s?be:Vn,m=s?Vn:be,h=n===`vertical`?ae:c,v=n===`vertical`?ge:m,y=Pe(e.nativeEvent);if(y!=null&&f(y)&&!Sn(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==v&&t<r.length||e.key!==h&&t>0)return}let x=C,S=_e(b,d),T=Hn(b,d);r!=null&&(x=r({disabledIndices:d,elementsRef:b,event:e,highlightedIndex:C,loopFocus:t,maxIndex:T,minIndex:S,onLoop:E,orientation:n,rtl:s}));let D=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,O=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?x=S:e.key===`End`&&(x=T)),x===C&&(D||O)&&(t&&x===T&&D?(x=S,i&&(x=i(e,C,x,b))):t&&x===S&&O?(x=T,i&&(x=i(e,C,x,b))):x=P(b.current,{startingIndex:x,decrement:O,disabledIndices:d})),x!==C&&!Et(b.current,x)&&(u&&e.stopPropagation(),(g||o||D||O)&&e.preventDefault(),w(x,!0),queueMicrotask(()=>{b.current[x]?.focus()}))});return{props:{ref:y,onFocus(e){let t=_.current,n=Pe(e.nativeEvent);!t||n==null||!f(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:C,onHighlightedIndexChange:w,elementsRef:b,onMapChange:T,relayKeyboardEvent:D}}function Wa(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(!(!i||We(e,r,t))){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function Ga(e,t){for(let n of Tt)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Ka(e){let{render:t,className:n,style:r,refs:i=v,props:a=v,state:o=lt,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:y,modifierKeys:x,highlightItemOnHover:S=!1,tag:C=`div`,...w}=e,{props:T,highlightedIndex:E,onHighlightedIndexChange:D,elementsRef:O,onMapChange:ee,relayKeyboardEvent:k}=Ua({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:b(),disabledIndices:y,modifierKeys:x}),te=ke(C,e,{state:o,ref:i,props:[T,...a,w],stateAttributesMapping:s}),A=R.useMemo(()=>({highlightedIndex:E,onHighlightedIndexChange:D,highlightItemOnHover:S,relayKeyboardEvent:k}),[E,D,S,k]);return(0,z.jsx)(wt.Provider,{value:A,children:(0,z.jsx)(Ke,{elementsRef:O,onMapChange:e=>{h?.(e),ee(e)},children:te})})}var qa=R.createContext(void 0);function Ja(e){let t=R.useContext(qa);if(t===void 0&&!e)throw Error(Se(47));return t}var Ya=n(o(),1),Xa={...zt,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!zt.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&zt.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>zt.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Za=class extends Zn{constructor(e,t,n){let r=new an;super(Qa(e,r,t,n),$a(r),Xa)}setOpen=(e,t)=>{let n=t.reason===$e,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=fr(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=cr(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),Ya.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Qa(e,t,n,r=!1){let i={...Gn(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function $a(e){return{popupRef:R.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:R.createRef(),beforeTriggerFocusGuardRef:R.createRef(),beforeContentFocusGuardRef:R.createRef(),stickIfOpenTimeout:new M,stickIfOpen:!0,triggerElements:e}}var eo=Vt(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=no(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),k(u,d),Ze(u);let{forceUnmount:m}=x(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),R.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),R.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ne(Qt))}),[m,u]);let h=d||f||s!=null;return(0,z.jsxs)(qa.Provider,{value:u,children:[s&&(0,z.jsx)(kt,{handle:s,store:u}),h&&(0,z.jsx)(ro,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function to(e){return Ja(!0)?(0,z.jsx)(eo,{props:e}):(0,z.jsx)(Be,{children:(0,z.jsx)(eo,{props:e})})}function no(e,t){let n=tt((e,n)=>new Za(t,e,n));return R.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function ro({store:e,modal:t}){let n=g(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return ir(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var io=Yt(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,h=Ja(!0),g=jn(s)??h;if(!g)throw Error(Se(74));let _=m(f),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=R.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=E(_,S,g,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),T=g.useState(`isPressOpenedByTrigger`,_),D=g.useState(`isTouchPressOpen`,l),O=g.useState(`hasTriggerFocusGuards`,_),ee=Un(y,{enabled:!a&&l&&!D,mouseOnly:!0,move:!1,handleClose:On(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),k=hn(y,{stickIfOpen:it(()=>g.context.stickIfOpen)}),te=dt(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),A=g.useState(`triggerProps`,w),{getButtonProps:ne,buttonRef:j}=he({disabled:a,native:o}),re={open(e){return T?Pn.open(e):xn.open(e)}},{handlePreFocusGuardFocus:ie,handleFocusTargetFocus:M}=rn(g,S),ae=ke(`button`,e,{state:{disabled:a,open:b},ref:[j,t,C,S],props:[k.reference,ee,A,te,{[ft]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,ne],stateAttributesMapping:re}),oe=(0,z.jsx)(R.Fragment,{children:ae},_);return O?(0,z.jsxs)(R.Fragment,{children:[(0,z.jsx)(Wt,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:ie}),oe,(0,z.jsx)(Wt,{ref:g.context.triggerFocusTargetRef,onFocus:M})]}):oe}),ao=R.createContext(void 0);function oo(){let e=R.useContext(ao);if(e===void 0)throw Error(Se(45));return e}var so=R.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Ja().useState(`mounted`)||n?(0,z.jsx)(ao.Provider,{value:n,children:(0,z.jsx)(vr,{ref:t,...r})}):null}),co=R.createContext(void 0);function lo(){let e=R.useContext(co);if(!e)throw Error(Se(46));return e}var uo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=st,..._}=e,v=Ja(),y=oo(),b=j(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),ee=v.useState(`instantType`),k=v.useState(`transitionStatus`),te=Xe({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});Ot({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let A=E===!0&&w!==`trigger-hover`;dr(C&&A,D===`touch`,O,T);let ne=v.useStateSetter(`positionerElement`),re=Ft(e,{open:C,side:te.side,align:te.align,anchorHidden:te.anchorHidden,instant:ee},{styles:te.positionerStyles,transitionStatus:k,props:_,refs:[t,ne],hidden:!S,inert:!C});return(0,z.jsxs)(co.Provider,{value:te,children:[S&&A&&(0,z.jsx)(ot,{inert:ht(!C),cutout:T}),(0,z.jsx)(je,{id:b,children:re})]})}),fo=R.createContext(void 0);function po(){let[e,t]=R.useState(0),n=it(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:R.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var mo=R.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Ja(),l=lo(),u=er(!0)!=null,{context:d,hasClosePart:f}=po(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);N({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),dn(w,{enabled:D&&!E,closeDelay:O});let ee=a===void 0?It(c.context.popupRef):a,k=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,k);let te=c.useStateSetter(`popupElement`),A=ke(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,te],props:[_,{id:T,role:`dialog`,...en,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&xt.has(e.key)&&e.stopPropagation()}},sr(g),s],stateAttributesMapping:Jt});return(0,z.jsx)(De,{context:w,openInteractionType:m,modal:k,disabled:!x||S===`trigger-hover`,initialFocus:ee,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:Tn(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,z.jsx)(fo.Provider,{value:d,children:A})})}),ho=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ja(),s=m(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),ke(`h2`,e,{ref:t,props:[{id:s},a]})}),go=R.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Ja(),s=m(a.id);return o.useSyncedValueWithCleanup(`descriptionElementId`,s),ke(`p`,e,{ref:t,props:[{id:s},a]})}),_o=`data-checked`,vo=`data-unchecked`,yo={checked(e){return e?{[_o]:``}:{[vo]:``}},...cn,...Ae},bo=R.createContext(void 0);function xo(){return R.useContext(bo)}var So=R.createContext(void 0);function Co(){let e=R.useContext(So);if(e===void 0)throw Error(Se(52));return e}var wo=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,g=xo(),{disabled:_,readOnly:v,required:y,form:b,checkedValue:x,touched:S=!1,validation:C,name:w,setCheckedValue:E=se,setTouched:D=se,registerInputRef:O=se}=g??{},{setTouched:k,setFilled:te,state:A,disabled:ne}=mn(),j=da(),{labelId:re,getDescriptionProps:ie}=T(),M=ne||j.disabled||_||i,ae=v||a,oe=y||o,N=b,ce=g?x===c:c===``,le=R.useRef(null),de=h(M,le),fe=R.useRef(null),pe=C?.registerInput,me=ue(l,fe,O,R.useCallback(e=>pe?.(e,{controlRef:le,value:void 0}),[pe]));hr(()=>{fe.current?.checked&&te(!0)},[te]),hr(()=>{if(fe.current){if(M&&ce){O(null);return}O(fe.current)}},[ce,M,O]);let ge=m(),_e=ee({id:d}),ve=u?void 0:_e,ye={role:`radio`,"aria-checked":ce,"aria-labelledby":fa(s,re,fe,!u,ve,p[`aria-label`]),[Ha]:ce?``:void 0,id:u?_e:ge,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||M||ae)return;e.preventDefault();let t=fe.current;t&&bt(t,e)},onFocus(e){de(!0),!(e.defaultPrevented||M||ae||!S)&&(fe.current?.click(),D(!1))},onBlur(){g||de(!1)}},{getButtonProps:be,buttonRef:P}=he({disabled:M,native:u,composite:!1}),xe={type:`radio`,ref:me,form:N,id:ve,name:w,tabIndex:-1,style:w?En:Jn,"aria-hidden":!0,...c===void 0?lt:{value:rr(c)},disabled:M,checked:ce,required:oe,readOnly:ae,onChange(e){if(e.nativeEvent.defaultPrevented||M||ae||c===void 0)return;let t=Ne(Pt,e.nativeEvent);E(c,t),!t.isCanceled&&k(!0)},onClick(e){e.stopPropagation()},onFocus(){le.current?.focus()}},Se=R.useMemo(()=>({...A,required:oe,disabled:M,readOnly:ae,checked:ce}),[A,M,ae,ce,oe]),Ce=Se,we=g!==void 0,Te=[t,le,P],Ee=[ye,p,be,ie,C?e=>C.getValidationProps(M,e):lt],De=ke(`span`,e,{enabled:!we,state:Se,ref:Te,props:Ee,stateAttributesMapping:yo});return(0,z.jsxs)(So.Provider,{value:Ce,children:[we?(0,z.jsx)($t,{tag:`span`,render:n,className:r,style:f,state:Se,refs:Te,props:Ee,stateAttributesMapping:yo}):De,(0,z.jsx)(`input`,{...xe,suppressHydrationWarning:!0})]})}),To=R.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Co(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Rt(c),f={...s,transitionStatus:u},p=R.useRef(null),m=a||l,h=ke(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:yo});return N({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null}),Eo=[Ue],Do=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:h,...g}=e,{setTouched:_,setFocused:v,validationMode:y,name:b,disabled:x,state:S,validation:C,setDirty:E,setFilled:D,validityData:O}=mn(),{labelId:ee}=T(),{clearErrors:k,elementRef:te}=Fe(),A=Ba(!0),ne=x||i,j=b??d,re=m(p),[M,ae]=ie({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[oe,se]=R.useState(!1),N=it((e,t)=>{s?.(e,t),!t.isCanceled&&ae(e)}),le=C.getInputControl,de=R.useMemo(()=>({get current(){return le()}}),[le]),fe=R.useRef(null),pe=R.useRef(null),me=ue(fe,f),he=R.useRef(me),ge=it(e=>{fe.current===e&&he.current===me||(he.current=me,me?.(e))});hr(()=>{ge(fe.current)},[me,ge]);let _e=it(e=>{if(e){if(!e.disabled){pe.current||=e;let t=fe.current;(e.checked||t==null||t.disabled)&&ge(e)}return()=>{pe.current===e&&(pe.current=null),fe.current===e&&ge(null)}}}),ve=it(()=>{let e=te.current;if(!e)return M??null;for(let t of C.registeredInputs.keys())if(t.checked&&Va(t,e))return M??null;return null});_n(de,re,M??null,ve,!ne,d),ce(M,()=>{k(j),E(M!==O.initialValue),D(M!=null),C.change(M);let e=pe.current;M==null&&e&&!e.disabled&&ge(e)});let ye=ee??A?.legendId,be={...S,disabled:ne??!1,required:o??!1,readOnly:a??!1},P=R.useMemo(()=>({checkedValue:M,disabled:ne,form:u,validation:C,name:j,readOnly:a,registerInputRef:_e,required:o,setCheckedValue:N,setTouched:se,touched:oe}),[M,ne,u,C,j,a,_e,o,N,se,oe]),xe={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":ne||void 0,"aria-readonly":a||void 0,"aria-labelledby":ye,onBlur(e){w(e.currentTarget,e.relatedTarget)||(se(!1),_(!0),v(!1),y===`onBlur`&&C.commit(M))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&se(!0)}};return(0,z.jsx)(bo.Provider,{value:P,children:(0,z.jsx)(Ka,{render:n,className:r,style:h,state:be,props:[xe,g,e=>C.getValidationProps(ne??!1,e)],refs:[t],stateAttributesMapping:Ae,enableHomeAndEndKeys:!1,modifierKeys:Eo})})}),Oo=gr(`group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-2.5 px-3 py-2.5`,sm:`gap-2.5 px-3 py-2.5`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function ko({className:e,variant:t=`default`,size:n=`default`,render:r,...i}){return de({defaultTagName:`div`,props:Re({className:ut(Oo({variant:t,size:n,className:e}))},i),render:r,state:{slot:`item`,variant:t,size:n}})}var Ao=gr(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function jo({className:e,variant:t=`default`,...n}){return(0,z.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:ut(Ao({variant:t,className:e})),...n})}function Mo({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-content`,className:ut(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none`,e),...t})}function No({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`item-title`,className:ut(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function Po({className:e,...t}){return(0,z.jsx)(`p`,{"data-slot":`item-description`,className:ut(`line-clamp-2 text-start text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function Fo({...e}){return(0,z.jsx)(to,{"data-slot":`popover`,...e})}function Io({...e}){return(0,z.jsx)(io,{"data-slot":`popover-trigger`,...e})}function Lo({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,z.jsx)(so,{children:(0,z.jsx)(uo,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,z.jsx)(mo,{"data-slot":`popover-content`,className:ut(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-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-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function Ro({className:e,...t}){return(0,z.jsx)(`div`,{"data-slot":`popover-header`,className:ut(`flex flex-col gap-0.5 text-sm`,e),...t})}function zo({className:e,...t}){return(0,z.jsx)(ho,{"data-slot":`popover-title`,className:ut(`font-medium`,e),...t})}function Bo({className:e,...t}){return(0,z.jsx)(go,{"data-slot":`popover-description`,className:ut(`text-muted-foreground`,e),...t})}function Vo({className:e,...t}){return(0,z.jsx)(Do,{"data-slot":`radio-group`,className:ut(`grid w-full gap-2`,e),...t})}function Ho({className:e,...t}){return(0,z.jsx)(wo,{"data-slot":`radio-group-item`,className:ut(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary`,e),...t,children:(0,z.jsx)(To,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`absolute top-1/2 start-1/2 size-2 -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})})})}function Uo({className:e,...t}){return(0,z.jsx)(me,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:ut(`size-4 animate-spin`,e),...t})}var Wo=class extends Error{constructor(e){super(e),this.name=`ShikiError`}};function Go(e){return Ko(e)}function Ko(e){return Array.isArray(e)?qo(e):e instanceof RegExp?e:typeof e==`object`?Jo(e):e}function qo(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Ko(e[n]);return t}function Jo(e){let t={};for(let n in e)t[n]=Ko(e[n]);return t}function Yo(e,...t){return t.forEach(t=>{for(let n in t)e[n]=t[n]}),e}function Xo(e){let t=~e.lastIndexOf(`/`)||~e.lastIndexOf(`\\`);return t===0?e:~t===e.length-1?Xo(e.substring(0,e.length-1)):e.substr(~t+1)}var Zo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Qo=class{static hasCaptures(e){return e===null?!1:(Zo.lastIndex=0,Zo.test(e))}static replaceCaptures(e,t,n){return e.replace(Zo,(e,r,i,a)=>{let o=n[parseInt(r||i,10)];if(o){let e=t.substring(o.start,o.end);for(;e[0]===`.`;)e=e.substring(1);switch(a){case`downcase`:return e.toLowerCase();case`upcase`:return e.toUpperCase();default:return e}}else return e})}};function $o(e,t){return e<t?-1:+(e>t)}function es(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r<n;r++){let n=$o(e[r],t[r]);if(n!==0)return n}return 0}return n-r}function ts(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function ns(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,`\\$&`)}var rs=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},is=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(us(e),t)}static createFromParsedTheme(e,t){return ps(e,t)}_cachedMatchRoot=new rs(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,n=this._cachedMatchRoot.get(t).find(t=>ss(e.parent,t.parentScopes));return n?new ls(n.fontStyle,n.foreground,n.background):null}},as=class e{constructor(e,t){this.parent=e,this.scopeName=t}parent;scopeName;static push(t,n){for(let r of n)t=new e(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new e(n,t[r]);return n}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(` `)}extends(e){return this===e||this.parent!==null&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push(n.scopeName),n=n.parent;return n===e?t.reverse():void 0}};function ss(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],i=!1;if(r===`>`){if(n===t.length-1)return!1;r=t[++n],i=!0}for(;e&&!cs(e.scopeName,r);){if(i)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function cs(e,t){return t===e||e.startsWith(t)&&e[t.length]===`.`}var ls=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function us(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let e=0,i=t.length;e<i;e++){let i=t[e];if(!i.settings)continue;let a;if(typeof i.scope==`string`){let e=i.scope;e=e.replace(/^[,]+/,``),e=e.replace(/[,]+$/,``),a=e.split(`,`)}else a=Array.isArray(i.scope)?i.scope:[``];let o=-1;if(typeof i.settings.fontStyle==`string`){o=0;let e=i.settings.fontStyle.split(` `);for(let t=0,n=e.length;t<n;t++)switch(e[t]){case`italic`:o|=1;break;case`bold`:o|=2;break;case`underline`:o|=4;break;case`strikethrough`:o|=8;break}}let s=null;typeof i.settings.foreground==`string`&&ts(i.settings.foreground)&&(s=i.settings.foreground);let c=null;typeof i.settings.background==`string`&&ts(i.settings.background)&&(c=i.settings.background);for(let t=0,i=a.length;t<i;t++){let i=a[t].trim().split(` `),l=i[i.length-1],u=null;i.length>1&&(u=i.slice(0,i.length-1),u.reverse()),n[r++]=new ds(l,u,e,o,s,c)}}return n}var ds=class{constructor(e,t,n,r,i,a){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=i,this.background=a}scope;parentScopes;index;fontStyle;foreground;background},fs=(e=>(e[e.NotSet=-1]=`NotSet`,e[e.None=0]=`None`,e[e.Italic=1]=`Italic`,e[e.Bold=2]=`Bold`,e[e.Underline=4]=`Underline`,e[e.Strikethrough=8]=`Strikethrough`,e))(fs||{});function ps(e,t){e.sort((e,t)=>{let n=$o(e.scope,t.scope);return n!==0||(n=es(e.parentScopes,t.parentScopes),n!==0)?n:e.index-t.index});let n=0,r=`#000000`,i=`#ffffff`;for(;e.length>=1&&e[0].scope===``;){let t=e.shift();t.fontStyle!==-1&&(n=t.fontStyle),t.foreground!==null&&(r=t.foreground),t.background!==null&&(i=t.background)}let a=new ms(t),o=new ls(n,a.getId(r),a.getId(i)),s=new _s(new gs(0,null,-1,0,0),[]);for(let t=0,n=e.length;t<n;t++){let n=e[t];s.insert(0,n.scope,n.parentScopes,n.fontStyle,a.getId(n.foreground),a.getId(n.background))}return new is(a,o,s)}var ms=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},hs=Object.freeze([]),gs=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,n,r,i){this.scopeDepth=e,this.parentScopes=t||hs,this.fontStyle=n,this.foreground=r,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=e[n].clone();return t}acceptOverwrite(e,t,n,r){this.scopeDepth>e?console.log(`how did this happen?`):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),n!==0&&(this.foreground=n),r!==0&&(this.background=r)}},_s=class e{constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let n=0,r=0;for(;e.parentScopes[n]===`>`&&n++,t.parentScopes[r]===`>`&&r++,!(n>=e.parentScopes.length||r>=t.parentScopes.length);){let i=t.parentScopes[r].length-e.parentScopes[n].length;if(i!==0)return i;n++,r++}return t.parentScopes.length-e.parentScopes.length}match(t){if(t!==``){let e=t.indexOf(`.`),n,r;if(e===-1?(n=t,r=``):(n=t.substring(0,e),r=t.substring(e+1)),this._children.hasOwnProperty(n))return this._children[n].match(r)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(e._cmpBySpecificity),n}insert(t,n,r,i,a,o){if(n===``){this._doInsertHere(t,r,i,a,o);return}let s=n.indexOf(`.`),c,l;s===-1?(c=n,l=``):(c=n.substring(0,s),l=n.substring(s+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new e(this._mainRule.clone(),gs.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,i,a,o)}_doInsertHere(e,t,n,r,i){if(t===null){this._mainRule.acceptOverwrite(e,n,r,i);return}for(let a=0,o=this._rulesWithParentScopes.length;a<o;a++){let o=this._rulesWithParentScopes[a];if(es(o.parentScopes,t)===0){o.acceptOverwrite(e,n,r,i);return}}n===-1&&(n=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new gs(e,t,n,r,i))}},vs=class e{static toBinaryStr(e){return e.toString(2).padStart(32,`0`)}static print(t){let n=e.getLanguageId(t),r=e.getTokenType(t),i=e.getFontStyle(t),a=e.getForeground(t),o=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:i,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!=0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(t,n,r,i,a,o,s){let c=e.getLanguageId(t),l=e.getTokenType(t),u=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),f=e.getForeground(t),p=e.getBackground(t);return n!==0&&(c=n),r!==8&&(l=bs(r)),i!==null&&(u=+!!i),a!==-1&&(d=a),o!==0&&(f=o),s!==0&&(p=s),(c<<0|l<<8|u<<10|d<<11|f<<15|p<<24)>>>0}};function ys(e){return e}function bs(e){return e}function xs(e,t){let n=[],r=Cs(e),i=r.next();for(;i!==null;){let e=0;if(i.length===2&&i.charAt(1)===`:`){switch(i.charAt(0)){case`R`:e=1;break;case`L`:e=-1;break;default:console.log(`Unknown priority ${i} in scope selector`)}i=r.next()}let t=o();if(n.push({matcher:t,priority:e}),i!==`,`)break;i=r.next()}return n;function a(){if(i===`-`){i=r.next();let e=a();return t=>!!e&&!e(t)}if(i===`(`){i=r.next();let e=s();return i===`)`&&(i=r.next()),e}if(Ss(i)){let e=[];do e.push(i),i=r.next();while(Ss(i));return n=>t(e,n)}return null}function o(){let e=[],t=a();for(;t;)e.push(t),t=a();return t=>e.every(e=>e(t))}function s(){let e=[],t=o();for(;t&&(e.push(t),i===`|`||i===`,`);){do i=r.next();while(i===`|`||i===`,`);t=o()}return t=>e.some(e=>e(t))}}function Ss(e){return!!e&&!!e.match(/[\w\.:]+/)}function Cs(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function ws(e){typeof e.dispose==`function`&&e.dispose()}var Ts=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},Es=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Ds=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Os=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Ts(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ds;for(let n of e)ks(n,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof Ts){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function ks(e,t,n,r){let i=n.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=n.lookup(t);e instanceof Ts?js({baseGrammar:a,selfGrammar:i},r):As(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},r);let o=n.injections(e.scopeName);if(o)for(let e of o)r.add(new Ts(e))}function As(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Ms([r],t,n)}}function js(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ms(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ms(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ms(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let e=r.repository?Yo({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Ms(r.patterns,{...t,repository:e},n);let i=r.include;if(!i)continue;let a=Ls(i);switch(a.kind){case 0:js({...t,selfGrammar:t.baseGrammar},n);break;case 1:js(t,n);break;case 2:As(a.ruleName,{...t,repository:e},n);break;case 3:case 4:let r=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){let i={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};a.kind===4?As(a.ruleName,i,n):js(i,n)}else a.kind===4?n.add(new Es(a.scopeName,a.ruleName)):n.add(new Ts(a.scopeName));break}}}var Ns=class{kind=0},Ps=class{kind=1},Fs=class{constructor(e){this.ruleName=e}ruleName;kind=2},Is=class{constructor(e){this.scopeName=e}scopeName;kind=3},tee=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function Ls(e){if(e===`$base`)return new Ns;if(e===`$self`)return new Ps;let t=e.indexOf(`#`);return t===-1?new Is(e):t===0?new Fs(e.substring(1)):new tee(e.substring(0,t),e.substring(t+1))}var Rs=/\\(\d+)/,zs=/\\(\d+)/g,Bs=-1,Vs=-2;function Hs(e){return e}function Us(e){return e}var Ws=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Qo.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Qo.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Xo(this.$location.filename)}:${this.$location.line}`:`unknown`;return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Qo.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Qo.replaceCaptures(this._contentName,e,t)}},Gs=class extends Ws{retokenizeCapturedWithRuleId;constructor(e,t,n,r,i){super(e,t,n,r),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error(`Not supported!`)}compile(e,t){throw Error(`Not supported!`)}compileAG(e,t,n,r){throw Error(`Not supported!`)}},Ks=class extends Ws{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Zs(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Qs,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},qs=class extends Ws{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,r),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Qs,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Js=class extends Ws{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r),this._begin=new Zs(i,this.id),this.beginCaptures=a,this._end=new Zs(o||``,-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=s,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Qs;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Ys=class extends Ws{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r),this._begin=new Zs(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Zs(o,Vs),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&=(this._cachedCompiledPatterns.dispose(),null),this._cachedCompiledWhilePatterns&&=(this._cachedCompiledWhilePatterns.dispose(),null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Qs;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Qs,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},Xs=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Gs(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Ks(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,n,r));if(t.begin===void 0){t.repository&&(r=Yo({},r,t.repository));let i=t.patterns;return i===void 0&&t.include&&(i=[{include:t.include}]),new qs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new Ys(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,e._compileCaptures(t.whileCaptures||t.captures,n,r),e._compilePatterns(t.patterns,n,r)):new Js(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,e._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,e._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let i=[];if(t){let a=0;for(let e in t){if(e===`$vscodeTextmateLocation`)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if(a===`$vscodeTextmateLocation`)continue;let o=parseInt(a,10),s=0;t[a].patterns&&(s=e.getCompiledRuleId(t[a],n,r)),i[o]=e.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,s)}}return i}static _compilePatterns(t,n,r){let i=[];if(t)for(let a=0,o=t.length;a<o;a++){let o=t[a],s=-1;if(o.include){let t=Ls(o.include);switch(t.kind){case 0:case 1:s=e.getCompiledRuleId(r[o.include],n,r);break;case 2:let i=r[t.ruleName];i&&(s=e.getCompiledRuleId(i,n,r));break;case 3:case 4:let a=t.scopeName,c=t.kind===4?t.ruleName:null,l=n.getExternalGrammar(a,r);if(l)if(c){let t=l.repository[c];t&&(s=e.getCompiledRuleId(t,n,l.repository))}else s=e.getCompiledRuleId(l.repository.$self,n,l.repository);break}}else s=e.getCompiledRuleId(o,n,r);if(s!==-1){let e=n.getRule(s),t=!1;if((e instanceof qs||e instanceof Js||e instanceof Ys)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Zs=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e==`string`){let t=e.length,n=0,r=[],i=!1;for(let a=0;a<t;a++)if(e.charAt(a)===`\\`&&a+1<t){let t=e.charAt(a+1);t===`z`?(r.push(e.substring(n,a)),r.push(`$(?!\\n)(?<!\\n)`),n=a+2):(t===`A`||t===`G`)&&(i=!0),a++}this.hasAnchor=i,n===0?this.source=e:(r.push(e.substring(n,t)),this.source=r.join(``))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source==`string`?this.hasBackReferences=Rs.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let n=t.map(t=>e.substring(t.start,t.end));return zs.lastIndex=0,this.source.replace(zs,(e,t)=>ns(n[parseInt(t,10)]||``))}_buildAnchorCache(){if(typeof this.source!=`string`)throw Error(`This method should only be called if the source is a string`);let e=[],t=[],n=[],r=[],i,a,o,s;for(i=0,a=this.source.length;i<a;i++)o=this.source.charAt(i),e[i]=o,t[i]=o,n[i]=o,r[i]=o,o===`\\`&&i+1<a&&(s=this.source.charAt(i+1),s===`A`?(e[i+1]=``,t[i+1]=``,n[i+1]=`A`,r[i+1]=`A`):s===`G`?(e[i+1]=``,t[i+1]=`G`,n[i+1]=``,r[i+1]=`G`):(e[i+1]=s,t[i+1]=s,n[i+1]=s,r[i+1]=s),i++);return{A0_G0:e.join(``),A0_G1:t.join(``),A1_G0:n.join(``),A1_G1:r.join(``)}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!=`string`?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Qs=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&=(this._cached.dispose(),null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new $s(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){return new $s(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},$s=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose==`function`&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(` - `+this.rules[t]+`: `+this.regExps[t]);return e.join(`
|
|
5
5
|
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},ec=class{constructor(e,t){this.languageId=e,this.tokenType=t}languageId;tokenType},tc=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new ec(e,8),this._embeddedLanguagesMatcher=new nc(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new ec(0,0);_getBasicScopeAttributes=new rs(e=>new ec(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let n=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case`comment`:return 1;case`string`:return 2;case`regex`:return 3;case`meta.embedded`:return 0}throw Error(`Unexpected match for standard token type!`)}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},nc=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([e,t])=>ns(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(`)|(`)}))($|\\.)`,``)}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};typeof process<`u`&&{}.VSCODE_TEXTMATE_DEBUG;var rc=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}stack;stoppedEarly};function ic(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=ac(e,t,n,r,i,a);i=o.stack,r=o.linePos,n=o.isFirstLine,u=o.anchorPosition}let d=Date.now();for(;!l;){if(s!==0&&Date.now()-d>s)return new rc(i,!0);f()}return new rc(i,!1);function f(){let o=oc(e,t,n,r,i,u);if(!o){a.produce(i,c),l=!0;return}let s=o.captureIndices,d=o.matchedRuleId,f=s&&s.length>0?s[0].end>r:!1;if(d===Bs){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),dc(e,t,n,i,a,o.endCaptures,s),a.produce(i,s[0].end);let d=i;if(i=i.parent,u=d.getAnchorPos(),!f&&d.getEnterPos()===r){i=d,a.produce(i,c),l=!0;return}}else{let o=e.getRule(d);a.produce(i,s[0].start);let p=i,m=o.getName(t.content,s),h=i.contentNameScopesList.pushAttributed(m,e);if(i=i.push(d,r,u,s[0].end===c,null,h,h),o instanceof Js){let r=o;dc(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.endHasBackReferences&&(i=i.withEndRule(r.getEndWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(o instanceof Ys){let r=o;dc(e,t,n,i,a,r.beginCaptures,s),a.produce(i,s[0].end),u=s[0].end;let d=r.getContentName(t.content,s),m=h.pushAttributed(d,e);if(i=i.withContentNameScopesList(m),r.whileHasBackReferences&&(i=i.withEndRule(r.getWhileWithResolvedBackReferences(t.content,s))),!f&&p.hasSameRuleAs(i)){i=i.pop(),a.produce(i,c),l=!0;return}}else if(dc(e,t,n,i,a,o.captures,s),a.produce(i,s[0].end),i=i.pop(),!f){i=i.safePop(),a.produce(i,c),l=!0;return}}s[0].end>r&&(r=s[0].end,n=!1)}}function ac(e,t,n,r,i,a){let o=i.beginRuleCapturedEOL?0:-1,s=[];for(let t=i;t;t=t.pop()){let n=t.getRule(e);n instanceof Ys&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=uc(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==Vs){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),dc(e,t,n,c.stack,a,c.rule.whileCaptures,u.captureIndices),a.produce(c.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>r&&(r=u.captureIndices[0].end,n=!1))}else{i=c.stack.pop();break}}return{stack:i,linePos:r,anchorPosition:o,isFirstLine:n}}function oc(e,t,n,r,i,a){let o=sc(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=cc(s,e,t,n,r,i,a);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function sc(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=lc(i.getRule(e),e,i.endRule,n,r===a),c=o.findNextMatchSync(t,r,s);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function cc(e,t,n,r,i,a,o){let s=Number.MAX_VALUE,c=null,l,u=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,f=e.length;a<f;a++){let f=e[a];if(!f.matcher(d))continue;let{ruleScanner:p,findOptions:m}=lc(t.getRule(f.ruleId),t,null,r,i===o),h=p.findNextMatchSync(n,i,m);if(!h)continue;let g=h.captureIndices[0].start;if(!(g>=s)&&(s=g,c=h.captureIndices,l=h.ruleId,u=f.priority,s===i))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function lc(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function uc(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function dc(e,t,n,r,i,a,o){if(a.length===0)return;let s=t.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let t=0;t<c;t++){let c=a[t];if(c===null)continue;let d=o[t];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?i.produceFromScopes(l[l.length-1].scopes,d.start):i.produce(r,d.start),c.retokenizeCapturedWithRuleId){let t=c.getName(s,o),a=r.contentNameScopesList.pushAttributed(t,e),l=c.getContentName(s,o),u=a.pushAttributed(l,e),f=r.push(c.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,u),p=e.createOnigString(s.substring(0,d.end));ic(e,p,n&&d.start===0,d.start,f,i,!1,0),ws(p);continue}let f=c.getName(s,o);if(f!==null){let t=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(f,e);l.push(new fc(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var fc=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function pc(e,t,n,r,i,a,o,s){return new _c(e,t,n,r,i,a,o,s)}function mc(e,t,n,r,i){let a=xs(t,hc),o=Xs.getCompiledRuleId(n,r,i.repository);for(let n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:o,grammar:i,priority:n.priority})}function hc(e,t){if(t.length<e.length)return!1;let n=0;return e.every(e=>{for(let r=n;r<t.length;r++)if(gc(t[r],e))return n=r+1,!0;return!1})}function gc(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]===`.`}var _c=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new tc(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=vc(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=xs(e,hc);for(let n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:i[e]})}}_rootScopeName;balancedBracketSelectors;_onigLib;_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let e=r.injections;if(e)for(let n in e)mc(t,n,e[n],this,r);let i=this._grammarRepository.injections(n);i&&i.forEach(e=>{let n=this.getExternalGrammar(e);if(n){let e=n.injectionSelector;e&&mc(t,e,n,this,n)}})}return t.sort((e,t)=>e.priority-t.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(Hs(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Us(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=vc(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=Xs.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===bc.NULL){i=!0;let e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=vs.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null),o;o=a?yc.createRootAndLookUpScopeName(a,r,this):yc.createRoot(`unknown`,r),t=new bc(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
|
|
6
6
|
`;let a=this.createOnigString(e),o=a.content.length,s=new Sc(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=ic(this,a,i,0,t,s,!0,r);return ws(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function vc(e,t){return e=Go(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var yc=class e{constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,i=t?.scopePath??null;for(let t of n)i=as.push(i,t.scopeNames),r=new e(r,i,t.encodedTokenAttributes);return r}static createRoot(t,n){return new e(null,new as(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let i=r.getMetadataForScope(t),a=new as(null,t),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(n,i,o);return new e(null,a,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(` `)}equals(t){return e.equals(this,t)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,n){let r=-1,i=0,a=0;return n!==null&&(r=n.fontStyle,i=n.foregroundId,a=n.backgroundId),vs.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(` `)===-1)return e._pushAttributed(this,t,n);let r=t.split(/ /g),i=this;for(let t of r)i=e._pushAttributed(i,t,n);return i}static _pushAttributed(t,n,r){let i=r.getMetadataForScope(n),a=t.scopePath.push(n),o=r.themeProvider.themeMatch(a),s=e.mergeAttributes(t.tokenAttributes,i,o);return new e(t,a,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}},bc=class e{constructor(e,t,n,r,i,a,o,s){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=o,this.contentNameScopesList=s,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t!==null&&e._equals(this,t)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?yc.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,i,a,o,s){return new e(this,t,n,r,i,a,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),`[`+e.join(`,`)+`]`}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:Us(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=yc.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Hs(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,yc.fromExtension(r,n.contentNameScopesList))}},xc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):xs(e,hc).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>xs(e,hc).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Sc=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(n=vs.set(n,0,ys(e.type),null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(t))}if(r&&(n=vs.set(n,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(n),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)n[e]=this._binaryTokens[e];return n}},Cc=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,pc(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},wc=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Cc(is.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(is.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new xc(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,i){let a=new Os(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,n,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections==`function`?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,i)}},Tc=bc.NULL;function Ec(e,t){let n=typeof e==`string`?{}:{...e.colorReplacements},r=typeof e==`string`?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))typeof i==`string`?n[e]=i:e===r&&Object.assign(n,i);return n}function Dc(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Oc(e){return Array.isArray(e)?e:[e]}async function kc(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function Ac(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function jc(e){return e===`ansi`||Ac(e)}function Mc(e){return e===`none`}function Nc(e){return Mc(e)}var Pc=/(\r?\n)/g;function Fc(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(Pc),r=0,i=[];for(let e=0;e<n.length;e+=2){let a=t?n[e]+(n[e+1]||``):n[e];i.push([a,r]),r+=n[e].length,r+=n[e+1]?.length||0}return i}var Ic={light:`#333333`,dark:`#bbbbbb`},Lc={light:`#fffffe`,dark:`#1e1e1e`},Rc=`__shiki_resolved`;function zc(e){if(e?.[Rc])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||=`dark`,t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(r=e.settings.foreground),e?.settings?.background&&(n=e.settings.background),!r&&t?.colors?.[`editor.foreground`]&&(r=t.colors[`editor.foreground`]),!n&&t?.colors?.[`editor.background`]&&(n=t.colors[`editor.background`]),r||=t.type===`light`?Ic.light:Ic.dark,n||=t.type===`light`?Lc.light:Lc.dark,t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function o(e){if(a.has(e))return a.get(e);i+=1;let n=`#${i.toString(16).padStart(8,`0`).toLowerCase()}`;return t.colorReplacements?.[`#${n}`]?o(e):(a.set(e,n),n)}t.settings=t.settings.map(e=>{let n=e.settings?.foreground&&!e.settings.foreground.startsWith(`#`),r=e.settings?.background&&!e.settings.background.startsWith(`#`);if(!n&&!r)return e;let i={...e,settings:{...e.settings}};if(n){let n=o(e.settings.foreground);t.colorReplacements[n]=e.settings.foreground,i.settings.foreground=n}if(r){let n=o(e.settings.background);t.colorReplacements[n]=e.settings.background,i.settings.background=n}return i});for(let e of Object.keys(t.colors||{}))if((e===`editor.foreground`||e===`editor.background`||e.startsWith(`terminal.ansi`))&&!t.colors[e]?.startsWith(`#`)){let n=o(t.colors[e]);t.colorReplacements[n]=t.colors[e],t.colors[e]=n}return Object.defineProperty(t,Rc,{enumerable:!1,writable:!1,value:!0}),t}async function Bc(e){return[...new Set((await Promise.all(e.filter(e=>!jc(e)).map(async e=>await kc(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function Vc(e){return(await Promise.all(e.map(async e=>Nc(e)?null:zc(await kc(e))))).filter(e=>!!e)}function Hc(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new Wo(`Circular alias \`${[...n].join(` -> `)} -> ${e}\``);n.add(e)}}return e}var Uc=class extends wc{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}getTheme(e){return typeof e==`string`?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=zc(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||=[...this._resolvedThemes.keys()],this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=is.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Hc(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||[`*`],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null;for(let e of t)this.reloadLanguage(e);if(e.injectTo){let t=[...this._langMap.values()].filter(t=>t!==e&&this._resolvedGrammars.has(t.name)&&e.injectTo.some(e=>t.scopeName===e||t.scopeName.startsWith(`${e}.`))&&!this.hasCurrentInjections(t.scopeName));for(let e of t)this.reloadLanguage(e)}}hasCurrentInjections(e){let t=this._syncRegistry?._injectionGrammars?.get(e)||[],n=this._resolver.getInjections(e)||[];return t.length===n.length&&t.every((e,t)=>e===n[t])}reloadLanguage(e){this._syncRegistry?._grammars?.get(e.scopeName)?.dispose(),this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._grammars?.delete(e.scopeName),this._syncRegistry?._injectionGrammars?.set(e.scopeName,this._resolver.getInjections(e.scopeName)||[]),this.loadLanguage(this._langMap.get(e.name)||e)}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=[...this._langGraph.entries()],n=t.filter(([e,t])=>!t);if(n.length){let e=t.filter(([e,t])=>t?(t.embeddedLanguages||t.embeddedLangs)?.some(e=>n.map(([e])=>e).includes(e)):!1).filter(e=>!n.includes(e));throw new Wo(`Missing languages ${n.map(([e])=>`\`${e}\``).join(`, `)}, required by ${e.map(([e])=>`\`${e}\``).join(`, `)}`)}for(let[e,n]of t)this._resolver.addLanguage(n);for(let[e,n]of t)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])],this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}},Wc=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split(`.`),n=[];for(let e=1;e<=t.length;e++){let r=t.slice(0,e).join(`.`);n=[...n,...this._injections.get(r)||[]]}return n}},Gc=0;function Kc(e){Gc+=1,e.warnings!==!1&&Gc>=10&&Gc%10==0&&console.warn(`[Shiki] ${Gc} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Wo("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(zc),i=new Uc(new Wc(e.engine,n),r,n,e.langAlias),a;function o(t){return Hc(t,e.langAlias)}function s(e){g();let t=i.getGrammar(typeof e==`string`?e:e.name);if(!t)throw new Wo(`Language \`${e}\` not found, you may need to load it first`);return t}function c(e){if(e===`none`)return{bg:``,fg:``,name:`none`,settings:[],type:`dark`};g();let t=i.getTheme(e);if(!t)throw new Wo(`Theme \`${e}\` not found, you may need to load it first`);return t}function l(e){g();let t=c(e);return a!==e&&(i.setTheme(t),a=e),{theme:t,colorMap:i.getColorMap()}}function u(){return g(),i.getLoadedThemes()}function d(){return g(),i.getLoadedLanguages()}function f(...e){g(),i.loadLanguages(e.flat(1))}async function p(...e){return f(await Bc(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await Vc(e))}function g(){if(t)throw new Wo(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Gc)}return{setTheme:l,getTheme:c,getLanguage:s,getLoadedThemes:u,getLoadedLanguages:d,resolveLangAlias:o,loadLanguage:p,loadLanguageSync:f,loadTheme:h,loadThemeSync:m,dispose:_,[Symbol.dispose]:_}}async function qc(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([Vc(e.themes||[]),Bc(e.langs||[]),e.engine]);return Kc({...e,themes:t,langs:n,engine:r})}var Jc=new WeakMap;function Yc(e,t){Jc.set(e,t)}function Xc(e){return Jc.get(e)}var Zc=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new e(Object.fromEntries(Oc(n).map(e=>[e,Tc])),t)}constructor(...e){if(e.length===2){let[t,n]=e;this.lang=n,this._stacks=t}else{let[t,n,r]=e;this.lang=n,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Qc(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Qc(e){let t=[],n=new Set;function r(e){if(n.has(e))return;n.add(e);let i=e?.nameScopesList?.scopeName;i&&t.push(i),e.parent&&r(e.parent)}return r(e),t}function $c(e,t){if(!(e instanceof Zc))throw new Wo(`Invalid grammar state`);return e.getInternalStack(t)}var el=/,/,tl=/ /;function nl(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Ac(e.resolveLangAlias(n.lang||`text`))||Mc(r))return Fc(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:i,colorMap:a}=e.setTheme(r),o=e.getLanguage(n.lang||`text`);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new Wo(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(i.name))throw new Wo(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return il(t,o,i,a,n)}function rl(...e){if(e.length===2)return Xc(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(Ac(i)||Mc(a))throw new Wo(`Plain language does not have grammar state`);if(i===`ansi`)throw new Wo(`ANSI language does not have grammar state`);let{theme:o,colorMap:s}=t.setTheme(a),c=t.getLanguage(i);return new Zc(al(n,c,o,s,r).stateStack,c.name,o.name)}function il(e,t,n,r,i){let a=al(e,t,n,r,i),o=new Zc(a.stateStack,t.name,n.name);return Yc(a.tokens,o),a.tokens}function al(e,t,n,r,i){let a=Ec(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=Fc(e),u=i.grammarState?$c(i.grammarState,n.name)??Tc:i.grammarContextCode==null?Tc:al(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack,d=[],f=[];for(let e=0,i=l.length;e<i;e++){let[i,p]=l[e];if(i===``){d=[],f.push([]);continue}if(o>0&&i.length>=o){d=[],f.push([{content:i,offset:p,color:``,fontStyle:0}]);continue}let m,h,g;c&&c!==`tokenType`&&(m=t.tokenizeLine(i,u,s),h=m.tokens,g=0);let _=t.tokenizeLine2(i,u,s),v=_.tokens.length/2;for(let e=0;e<v;e++){let t=_.tokens[2*e],o=e+1<v?_.tokens[2*e+2]:i.length;if(t===o)continue;let s=_.tokens[2*e+1],l=Dc(r[vs.getForeground(s)],a),u=vs.getFontStyle(s),f={content:i.substring(t,o),offset:p+t,color:l,fontStyle:u};if(c===`tokenType`)f.type=vs.getTokenType(s);else if(c){let e=[];if(c!==`scopeName`)for(let t of n.settings){let n;switch(typeof t.scope){case`string`:n=t.scope.split(el).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split(tl))})}f.explanation=[];let r=0;for(;t+r<o;){let t=h[g],n=i.substring(t.startIndex,t.endIndex);r+=n.length,f.explanation.push({content:n,scopes:c===`scopeName`?ol(t.scopes):sl(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function ol(e){return e.map(e=>({scopeName:e}))}function sl(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:ul(e,i,t.slice(0,r))}}return n}function cl(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function ll(e,t,n){if(!cl(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)cl(e[r],n[i])&&--r,--i;return r===-1}function ul(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(ll(e,t,n)){r.push(a);break}return r}function dl(e,t,n,r=nl){let i=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),a=i.map(i=>{let a=r(e,t,{...n,theme:i.theme});return{tokens:a,state:Xc(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=fl(...a.map(e=>e.tokens)),s=o[0].map((e,t)=>e.map((e,r)=>{let a={content:e.content,variants:{},offset:e.offset};return`includeExplanation`in n&&n.includeExplanation&&(a.explanation=e.explanation),o.forEach((e,n)=>{let{content:o,explanation:s,offset:c,...l}=e[t][r];a.variants[i[n].color]=l}),a})),c=a[0].state?new Zc(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&Yc(s,c),s}function fl(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let i=e.map(e=>e[r]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let o=i.map(()=>0),s=i.map(e=>e[0]);for(;s.every(e=>e);){let e=Math.min(...s.map(e=>e.content.length));for(let t=0;t<n;t++){let n=s[t];n.content.length===e?(a[t].push(n),o[t]+=1,s[t]=i[t][o[t]]):(a[t].push({...n,content:n.content.slice(0,e)}),s[t]={...n,content:n.content.slice(e),offset:n.offset+e})}}}return t}var pl=/["&'<>`]/g,ml=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,hl=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,gl=/[|\\{}()[\]^$+*?.]/g,_l=new WeakMap;function vl(e,t){if(e=e.replace(t.subset?yl(t.subset):pl,r),t.subset||t.escapeOnly)return e;return e.replace(ml,n).replace(hl,r);function n(e,n,r){return t.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),t)}function r(e,n,r){return t.format(e.charCodeAt(0),r.charCodeAt(n+1),t)}}function yl(e){let t=_l.get(e);return t||(t=bl(e),_l.set(e,t)),t}function bl(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(gl,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var xl=/[\dA-Fa-f]/;function Sl(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!xl.test(String.fromCharCode(t))?r:r+`;`}var Cl=/\d/;function wl(e,t,n){let r=`&#`+String(e);return n&&t&&!Cl.test(String.fromCharCode(t))?r:r+`;`}var Tl=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),El={nbsp:`\xA0`,iexcl:`¡`,cent:`¢`,pound:`£`,curren:`¤`,yen:`¥`,brvbar:`¦`,sect:`§`,uml:`¨`,copy:`©`,ordf:`ª`,laquo:`«`,not:`¬`,shy:``,reg:`®`,macr:`¯`,deg:`°`,plusmn:`±`,sup2:`²`,sup3:`³`,acute:`´`,micro:`µ`,para:`¶`,middot:`·`,cedil:`¸`,sup1:`¹`,ordm:`º`,raquo:`»`,frac14:`¼`,frac12:`½`,frac34:`¾`,iquest:`¿`,Agrave:`À`,Aacute:`Á`,Acirc:`Â`,Atilde:`Ã`,Auml:`Ä`,Aring:`Å`,AElig:`Æ`,Ccedil:`Ç`,Egrave:`È`,Eacute:`É`,Ecirc:`Ê`,Euml:`Ë`,Igrave:`Ì`,Iacute:`Í`,Icirc:`Î`,Iuml:`Ï`,ETH:`Ð`,Ntilde:`Ñ`,Ograve:`Ò`,Oacute:`Ó`,Ocirc:`Ô`,Otilde:`Õ`,Ouml:`Ö`,times:`×`,Oslash:`Ø`,Ugrave:`Ù`,Uacute:`Ú`,Ucirc:`Û`,Uuml:`Ü`,Yacute:`Ý`,THORN:`Þ`,szlig:`ß`,agrave:`à`,aacute:`á`,acirc:`â`,atilde:`ã`,auml:`ä`,aring:`å`,aelig:`æ`,ccedil:`ç`,egrave:`è`,eacute:`é`,ecirc:`ê`,euml:`ë`,igrave:`ì`,iacute:`í`,icirc:`î`,iuml:`ï`,eth:`ð`,ntilde:`ñ`,ograve:`ò`,oacute:`ó`,ocirc:`ô`,otilde:`õ`,ouml:`ö`,divide:`÷`,oslash:`ø`,ugrave:`ù`,uacute:`ú`,ucirc:`û`,uuml:`ü`,yacute:`ý`,thorn:`þ`,yuml:`ÿ`,fnof:`ƒ`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`,thetasym:`ϑ`,upsih:`ϒ`,piv:`ϖ`,bull:`•`,hellip:`…`,prime:`′`,Prime:`″`,oline:`‾`,frasl:`⁄`,weierp:`℘`,image:`ℑ`,real:`ℜ`,trade:`™`,alefsym:`ℵ`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,lArr:`⇐`,uArr:`⇑`,rArr:`⇒`,dArr:`⇓`,hArr:`⇔`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,prod:`∏`,sum:`∑`,minus:`−`,lowast:`∗`,radic:`√`,prop:`∝`,infin:`∞`,ang:`∠`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,sim:`∼`,cong:`≅`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,lceil:`⌈`,rceil:`⌉`,lfloor:`⌊`,rfloor:`⌋`,lang:`〈`,rang:`〉`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,quot:`"`,amp:`&`,lt:`<`,gt:`>`,OElig:`Œ`,oelig:`œ`,Scaron:`Š`,scaron:`š`,Yuml:`Ÿ`,circ:`ˆ`,tilde:`˜`,ensp:` `,emsp:` `,thinsp:` `,zwnj:``,zwj:``,lrm:``,rlm:``,ndash:`–`,mdash:`—`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,ldquo:`“`,rdquo:`”`,bdquo:`„`,dagger:`†`,Dagger:`‡`,permil:`‰`,lsaquo:`‹`,rsaquo:`›`,euro:`€`},Dl=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],Ol={}.hasOwnProperty,kl={},Al;for(Al in El)Ol.call(El,Al)&&(kl[El[Al]]=Al);var jl=/[^\dA-Za-z]/;function Ml(e,t,n,r){let i=String.fromCharCode(e);if(Ol.call(kl,i)){let e=kl[i],a=`&`+e;return n&&Tl.includes(e)&&!Dl.includes(e)&&(!r||t&&t!==61&&jl.test(String.fromCharCode(t)))?a:a+`;`}return``}function Nl(e,t,n){let r=Sl(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=Ml(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=wl(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function Pl(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Fl(e,t){return vl(e,Object.assign({format:Nl},t))}function Il(e,t){return vl(e,Object.assign({format:Pl},t))}var Ll=/^>|^->|<!--|-->|--!>|<!-$/g,Rl=[`>`],zl=[`<`,`>`];function Bl(e,t,n,r){return r.settings.bogusComments?`<?`+Fl(e.value,Object.assign({},r.settings.characterReferences,{subset:Rl}))+`>`:`<!--`+e.value.replace(Ll,i)+`-->`;function i(e){return Fl(e,Object.assign({},r.settings.characterReferences,{subset:zl}))}}function Vl(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var Hl=Gl(1),Ul=Gl(-1),Wl=[];function Gl(e){return t;function t(t,n,r){let i=t?t.children:Wl,a=(n||0)+e,o=i[a];if(!r)for(;o&&Dr(o);)a+=e,o=i[a];return o}}var Kl={}.hasOwnProperty;function ql(e){return t;function t(t,n,r){return Kl.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var Jl=ql({body:Zl,caption:Yl,colgroup:Yl,dd:tu,dt:eu,head:Yl,html:Xl,li:$l,optgroup:ru,option:iu,p:Ql,rp:nu,rt:nu,tbody:ou,td:lu,tfoot:su,th:lu,thead:au,tr:cu});function Yl(e,t,n){let r=Hl(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Dr(r.value.charAt(0)))}function Xl(e,t,n){let r=Hl(n,t);return!r||r.type!==`comment`}function Zl(e,t,n){let r=Hl(n,t);return!r||r.type!==`comment`}function Ql(e,t,n){let r=Hl(n,t);return r?r.type===`element`&&(r.tagName===`address`||r.tagName===`article`||r.tagName===`aside`||r.tagName===`blockquote`||r.tagName===`details`||r.tagName===`div`||r.tagName===`dl`||r.tagName===`fieldset`||r.tagName===`figcaption`||r.tagName===`figure`||r.tagName===`footer`||r.tagName===`form`||r.tagName===`h1`||r.tagName===`h2`||r.tagName===`h3`||r.tagName===`h4`||r.tagName===`h5`||r.tagName===`h6`||r.tagName===`header`||r.tagName===`hgroup`||r.tagName===`hr`||r.tagName===`main`||r.tagName===`menu`||r.tagName===`nav`||r.tagName===`ol`||r.tagName===`p`||r.tagName===`pre`||r.tagName===`section`||r.tagName===`table`||r.tagName===`ul`):!n||!(n.type===`element`&&(n.tagName===`a`||n.tagName===`audio`||n.tagName===`del`||n.tagName===`ins`||n.tagName===`map`||n.tagName===`noscript`||n.tagName===`video`||n.tagName.includes(`-`)))}function $l(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&r.tagName===`li`}function eu(e,t,n){let r=Hl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function tu(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function nu(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function ru(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function iu(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function au(e,t,n){let r=Hl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function ou(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function su(e,t,n){return!Hl(n,t)}function cu(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function lu(e,t,n){let r=Hl(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var uu=ql({body:pu,colgroup:mu,head:fu,html:du,tbody:hu});function du(e){let t=Hl(e,-1);return!t||t.type!==`comment`}function fu(e){let t=new Set;for(let n of e.children)if(n.type===`element`&&(n.tagName===`base`||n.tagName===`title`)){if(t.has(n.tagName))return!1;t.add(n.tagName)}let n=e.children[0];return!n||n.type===`element`}function pu(e){let t=Hl(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Dr(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function mu(e,t,n){let r=Ul(n,t);if(n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Jl(r,n.children.indexOf(r),n))return!1;let i=Hl(e,-1,!0);return!!(i&&i.type===`element`&&i.tagName===`col`)}function hu(e,t,n){let r=Ul(n,t);if(n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Jl(r,n.children.indexOf(r),n))return!1;let i=Hl(e,-1);return!!(i&&i.type===`element`&&i.tagName===`tr`)}var gu={name:[[`
|
|
7
7
|
\f\r &/=>`.split(``),`
|
|
@@ -167,7 +167,7 @@ ${a}`,l++}else Uh(e,n,i)?u=e.slice(e.charCodeAt(n+6)===zh?n+7:n+6,r)||void 0:p(e
|
|
|
167
167
|
${i}`,l++;return}if(Uh(e,t,r)){u=e.slice(e.charCodeAt(t+6)===zh?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===zh?t+4:t+3,n);s=r.includes(`\0`)?void 0:r;return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===zh?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){m(a,``,a);return}let d=a.slice(0,o),f=a.charCodeAt(o+1)===zh?2:1;m(d,a.slice(o+f),a)}function m(e,t,i){switch(e){case`event`:u=t||void 0;break;case`data`:c=l===0?t:`${c}
|
|
168
168
|
${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Ih(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Ih(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function h(){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0}function g(e={}){if(e.consume&&a.length>0){let e=a.join(``);p(e,0,e.length)}o=!0,s=void 0,c=``,l=0,u=void 0,a.length=0}return{feed:d,reset:g}}function Hh(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Uh(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Wh=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Vh({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};new TextDecoder;var{btoa:nee,atob:ree}=globalThis,Gh=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get,Kh=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`).get;function qh(e){return ArrayBuffer.isView(e)&&Gh.call(e)===`Uint8Array`}function Jh(e){if(typeof e!=`object`||!e||!(`byteLength`in e))return!1;try{return Kh.call(e),!0}catch{return!1}}function Yh(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var Xh=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new Ch({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},Zh=Xh();function Qh(e){return globalThis.Buffer?.isBuffer(e)??!1}function $h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var iee=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,aee=/"(?: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 eg(e){let t=JSON.parse(e);return typeof t!=`object`||!t||iee.test(e)===!1&&aee.test(e)===!1?t:oee(t)}function oee(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function see(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return eg(e)}try{return eg(e)}finally{Error.stackTraceLimit=t}}function tg(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&ng(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=ng(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(ng):ng(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(ng)),e.allOf!=null&&(e.allOf=e.allOf.map(ng)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(ng));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=ng(t[e]);return e}function ng(e){return typeof e==`boolean`?e:tg(e)}var cee=Symbol(`Let zodToJsonSchema decide on which parser to use`),rg={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},lee=e=>typeof e==`string`?{...rg,name:e}:{...rg,...e};function ig(){return{}}function uee(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=Gg(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function dee(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function fee(){return{type:`boolean`}}function ag(e,t){return Gg(e.type._def,t)}var pee=(e,t)=>Gg(e.innerType._def,t);function og(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>og(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return sg(e)}}var sg=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function cg(e,t){return{...Gg(e.innerType._def,t),default:e.defaultValue()}}function lg(e,t){return t.effectStrategy===`input`?Gg(e.schema._def,t):ig()}function ug(e){return{type:`string`,enum:Array.from(e.values)}}var dg=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function fg(e,t){let n=[Gg(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),Gg(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(dg(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function pg(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var mg=void 0,hg={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(mg===void 0&&(mg=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),mg),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function gg(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:bg(n,`email`,r.message,t);break;case`format:idn-email`:bg(n,`idn-email`,r.message,t);break;case`pattern:zod`:xg(n,hg.email,r.message,t)}break;case`url`:bg(n,`uri`,r.message,t);break;case`uuid`:bg(n,`uuid`,r.message,t);break;case`regex`:xg(n,r.regex,r.message,t);break;case`cuid`:xg(n,hg.cuid,r.message,t);break;case`cuid2`:xg(n,hg.cuid2,r.message,t);break;case`startsWith`:xg(n,RegExp(`^${_g(r.value,t)}`),r.message,t);break;case`endsWith`:xg(n,RegExp(`${_g(r.value,t)}$`),r.message,t);break;case`datetime`:bg(n,`date-time`,r.message,t);break;case`date`:bg(n,`date`,r.message,t);break;case`time`:bg(n,`time`,r.message,t);break;case`duration`:bg(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:xg(n,RegExp(_g(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&bg(n,`ipv4`,r.message,t),r.version!==`v4`&&bg(n,`ipv6`,r.message,t);break;case`base64url`:xg(n,hg.base64url,r.message,t);break;case`jwt`:xg(n,hg.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&xg(n,hg.ipv4Cidr,r.message,t),r.version!==`v4`&&xg(n,hg.ipv6Cidr,r.message,t);break;case`emoji`:xg(n,hg.emoji(),r.message,t);break;case`ulid`:xg(n,hg.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:bg(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:xg(n,hg.base64,r.message,t)}break;case`nanoid`:xg(n,hg.nanoid,r.message,t)}return n}function _g(e,t){return t.patternStrategy===`escape`?yg(e):e}var vg=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function yg(e){let t=``;for(let n=0;n<e.length;n++)vg.has(e[n])||(t+=`\\`),t+=e[n];return t}function bg(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function xg(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Sg(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Sg(t,r)}function Sg(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
169
169
|
]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
|
|
170
|
-
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Cg(e,t){let n={type:`object`,additionalProperties:Gg(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=gg(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=ag(e.keyType._def,t);return{...n,propertyNames:i}}return n}function mee(e,t){return t.mapStrategy===`record`?Cg(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Gg(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||ig(),Gg(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||ig()],minItems:2,maxItems:2}}}function wg(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function Tg(){return{not:ig()}}function Eg(){return{type:`null`}}var Dg={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Og(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Dg&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Dg[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return kg(e,t)}var kg=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Gg(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Ag(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Dg[e.innerType._def.typeName],`null`]};let n=Gg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function jg(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function Mg(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Pg(a),s=Gg(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=Ng(e,t);return a!==void 0&&(n.additionalProperties=a),n}function Ng(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Gg(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Pg(e){try{return e.isOptional()}catch{return!0}}var Fg=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Gg(e.innerType._def,t);let n=Gg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:ig()},n]}:ig()},Ig=(e,t)=>{if(t.pipeStrategy===`input`)return Gg(e.in._def,t);if(t.pipeStrategy===`output`)return Gg(e.out._def,t);let n=Gg(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Gg(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Lg(e,t){return Gg(e.type._def,t)}function Rg(e,t){let n={type:`array`,uniqueItems:!0,items:Gg(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function zg(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Gg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Gg(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Gg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Bg(){return{not:ig()}}function Vg(){return ig()}var Hg=(e,t)=>Gg(e.innerType._def,t),Ug=(e,t,n)=>{switch(t){case`ZodString`:return gg(e,n);case`ZodNumber`:return jg(e);case`ZodObject`:return Mg(e,n);case`ZodBigInt`:return dee(e);case`ZodBoolean`:return fee();case`ZodDate`:return og(e,n);case`ZodUndefined`:return Bg();case`ZodNull`:return Eg();case`ZodArray`:return uee(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return Og(e,n);case`ZodIntersection`:return fg(e,n);case`ZodTuple`:return zg(e,n);case`ZodRecord`:return Cg(e,n);case`ZodLiteral`:return pg(e);case`ZodEnum`:return ug(e);case`ZodNativeEnum`:return wg(e);case`ZodNullable`:return Ag(e,n);case`ZodOptional`:return Fg(e,n);case`ZodMap`:return mee(e,n);case`ZodSet`:return Rg(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Lg(e,n);case`ZodNaN`:case`ZodNever`:return Tg();case`ZodEffects`:return lg(e,n);case`ZodAny`:return ig();case`ZodUnknown`:return Vg();case`ZodDefault`:return cg(e,n);case`ZodBranded`:return ag(e,n);case`ZodReadonly`:return Hg(e,n);case`ZodCatch`:return pee(e,n);case`ZodPipeline`:return Ig(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},Wg=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function Gg(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==cee)return i}if(r&&!n){let e=Kg(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Ug(e,e.typeName,t),o=typeof a==`function`?Gg(a(),t):a;if(o&&qg(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Kg=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Wg(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),ig()):t.$refStrategy===`seen`?ig():void 0}},qg=(e,t,n)=>(e.description&&(n.description=e.description),n),Jg=e=>{let t=lee(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Yg=(e,t)=>{let n=Jg(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Gg(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??ig()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Gg(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??ig(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},Xg=Symbol.for(`vercel.ai.schema`);function Zg(e){let t;return()=>(t??=e(),t)}function Qg(e,{validate:t}={}){return{[Xg]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function $g(e){return typeof e==`object`&&!!e&&Xg in e&&e[Xg]===!0&&`jsonSchema`in e&&`validate`in e}function e_(e){return e==null?Qg({type:`object`,properties:{},additionalProperties:!1}):$g(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?o_(e):t_(e):e()}function t_(e){return Qg(()=>{if(!n_(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return tg(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return n.issues===void 0&&`value`in n?{success:!0,value:n.value}:{success:!1,error:new jh({value:t,cause:n.issues})}}})}function n_(e){return e[`~standard`].jsonSchema!=null}function r_(e,t){let n=t?.useReferences??!1;return Qg(()=>Yg(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function i_(e,t){Lt().localeError||Lt(pe());let n=t?.useReferences??!1;return Qg(()=>tg(Le(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await Oe(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function a_(e){return`_zod`in e}function o_(e,t){return a_(e)?i_(e,t):r_(e,t)}async function s_({value:e,schema:t,context:n}){let r=await c_({value:e,schema:t,context:n});if(!r.success)throw jh.wrap({value:e,cause:r.error,context:n});return r.value}async function c_({value:e,schema:t,context:n}){let r=e_(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:jh.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:jh.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function l_({text:e,schema:t}){try{let n=see(e);return t==null?{success:!0,value:n,rawValue:n}:await c_({value:n,schema:t})}catch(t){return{success:!1,error:Dh.isInstance(t)?t:new Dh({text:e,cause:t}),rawValue:void 0}}}function u_({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Wh).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await l_({text:e,schema:t}))}}))}async function d_(e){return typeof e==`function`&&(e=e()),e}new TextDecoder;var f_=tr(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);Qn.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){nt(this,`with`,e)},parse(e,t){return Ln(this,e,t,{callee:this.parse})},parseAsync(e,t){return wn(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return on(this,e,t)},safeParseAsync(e,t){return tn(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return lr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),p_=tr(`ZodMiniString`,(e,t)=>{Bt.init(e,t),f_.init(e,t)});function m_(e){return ve(p_,e)}var h_=tr(`ZodMiniNumber`,(e,t)=>{kn.init(e,t),f_.init(e,t)});function g_(e){return oe(h_,e)}var __=tr(`ZodMiniNumberFormat`,(e,t)=>{Wn.init(e,t),h_.init(e,t)});function v_(e){return xe(__,e)}var y_=tr(`ZodMiniBoolean`,(e,t)=>{gt.init(e,t),f_.init(e,t)});function b_(e){return ne(y_,e)}var x_=tr(`ZodMiniUnknown`,(e,t)=>{Xt.init(e,t),f_.init(e,t)});function S_(){return Rn(x_)}var C_=tr(`ZodMiniNever`,(e,t)=>{Xn.init(e,t),f_.init(e,t)});function w_(e){return _(C_,e)}var T_=tr(`ZodMiniArray`,(e,t)=>{vt.init(e,t),f_.init(e,t)});function E_(e,t){return new T_({type:`array`,element:e,...ar(t)})}var D_=tr(`ZodMiniObject`,(e,t)=>{fn.init(e,t),f_.init(e,t),S(e,`shape`,e=>e._zod.def.shape,!1)});function O_(e,t){return new D_({type:`object`,shape:e??{},...ar(t)})}function k_(e,t){return new D_({type:`object`,shape:e,catchall:S_(),...ar(t)})}function A_(e,t){return Qe(e,t)}var j_=tr(`ZodMiniUnion`,(e,t)=>{Ht.init(e,t),f_.init(e,t)});function M_(e,t){return new j_({type:`union`,options:e,...ar(t)})}var N_=tr(`ZodMiniDiscriminatedUnion`,(e,t)=>{Ve.init(e,t),f_.init(e,t)});function P_(e,t,n){return new N_({type:`union`,options:t,discriminator:e,...ar(n)})}var F_=tr(`ZodMiniRecord`,(e,t)=>{Kn.init(e,t),f_.init(e,t)});function I_(e,t,n){return!t||!t._zod?new F_({type:`record`,keyType:m_(),valueType:e,...ar(t)}):new F_({type:`record`,keyType:e,valueType:t,...ar(n)})}var L_=tr(`ZodMiniEnum`,(e,t)=>{u.init(e,t),f_.init(e,t),e.options=[...e._zod.values]});function R_(e,t){return new L_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ar(t)})}var z_=tr(`ZodMiniLiteral`,(e,t)=>{qt.init(e,t),f_.init(e,t)});function B_(e,t){return new z_({type:`literal`,values:Array.isArray(e)?e:[e],...ar(t)})}var V_=tr(`ZodMiniTransform`,(e,t)=>{yn.init(e,t),f_.init(e,t)});function H_(e){return new V_({type:`transform`,transform:e})}var U_=tr(`ZodMiniOptional`,(e,t)=>{Mt.init(e,t),f_.init(e,t)});function W_(e){return new U_({type:`optional`,innerType:e})}var G_=tr(`ZodMiniPipe`,(e,t)=>{Mn.init(e,t),f_.init(e,t)});function K_(e,t){return new G_({type:`pipe`,in:e,out:t})}var q_=tr(`ZodMiniCustom`,(e,t)=>{St.init(e,t),f_.init(e,t)});function J_(e,t){return le(q_,e??(()=>!0),t)}function Y_(e,t={}){return pt(q_,e,t)}var X_=`AI_InvalidArgumentError`,Z_=`vercel.ai.error.${X_}`,Q_=Symbol.for(Z_),$_=class extends uh{constructor({parameter:e,value:t,message:n}){super({name:X_,message:`Invalid argument for parameter ${e}: ${n}`}),this[Q_]=!0,this.parameter=e,this.value=t}static isInstance(e){return uh.hasMarker(e,Z_)}},ev=new Map([[`generateObject`,`AISDK_DEP_GENERATE_OBJECT`],[`streamObject`,`AISDK_DEP_STREAM_OBJECT`],[`experimental_generateSpeech`,`AISDK_DEP_EXPERIMENTAL_GENERATE_SPEECH`],[`experimental_transcribe`,`AISDK_DEP_EXPERIMENTAL_TRANSCRIBE`],[`"image" content part`,`AISDK_DEP_IMAGE_CONTENT_PART`],[`"tool-result" content of type "file-data"`,`AISDK_DEP_TOOL_RESULT_FILE_DATA`],[`"tool-result" content of type "file-url"`,`AISDK_DEP_TOOL_RESULT_FILE_URL`],[`"tool-result" content of type "file-id"`,`AISDK_DEP_TOOL_RESULT_FILE_ID`],[`"tool-result" content of type "file-reference"`,`AISDK_DEP_TOOL_RESULT_FILE_REFERENCE`],[`"tool-result" content of type "image-data"`,`AISDK_DEP_TOOL_RESULT_IMAGE_DATA`],[`"tool-result" content of type "image-url"`,`AISDK_DEP_TOOL_RESULT_IMAGE_URL`],[`"tool-result" content of type "image-file-id"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_ID`],[`"tool-result" content of type "image-file-reference"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_REFERENCE`],[`rawInput in output-error UI message parts`,`AISDK_DEP_UI_MESSAGE_RAW_INPUT`]]);function tv(e){return e.replace(/[^a-zA-Z0-9]/g,e=>`_${e.charCodeAt(0).toString(16).toUpperCase().padStart(4,`0`)}`)}function nv({setting:e,provider:t}){return t==null?ev.get(e)??`AISDK_DEP_SETTING_${tv(e)}`:`AISDK_DEP_PROVIDER_${tv(t)}__${tv(e)}`}function rv({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var iv=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,av=!1,ov=new Set;function sv({message:e,type:t,code:n}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,n==null?{type:t}:{type:t,code:n}):console.warn(n==null?e:`[${n}] ${e}`)}var cv=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}av||(av=!0,sv({message:iv,type:`Warning`}));for(let t of e.warnings){let n=t.type===`deprecated`?nv({setting:t.setting,provider:e.provider}):void 0;if(n!=null){if(ov.has(n))continue;ov.add(n)}sv({message:rv({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`,code:n})}}};function lv(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=lv(a,i):n[r]=i}return n}function uv(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function dv(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(typeof e!=`object`&&typeof t!=`object`)return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!dv(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!dv(e[i],t[i]))return!1;return!0}new TextEncoder,new TextEncoder;var fv=`AI_UIMessageStreamError`,pv=`vercel.ai.error.${fv}`,mv=Symbol.for(pv),hv=class extends uh{constructor({chunkType:e,chunkId:t,message:n}){super({name:fv,message:n}),this[mv]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return uh.hasMarker(e,pv)}};function gv(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);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`);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`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`)}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`)}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`)}break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;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`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function _v(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await l_({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await l_({text:gv(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}Xh({prefix:`steer`,size:24}),Xh({prefix:`aitxt`,size:24}),Xh({prefix:`call`,size:24}),TransformStream;var V={NEVER:pr,array:E_,boolean:b_,custom:J_,discriminatedUnion:P_,enum:R_,extend:A_,int:v_,literal:B_,looseObject:k_,maximum:Ge,minLength:mr,never:w_,nonnegative:ct,number:g_,object:O_,optional:W_,pipe:K_,positive:rt,record:I_,refine:Y_,safeParse:on,startsWith:j,string:m_,transform:H_,union:M_,unknown:S_},H={array:Zt,boolean:Dt,custom:$n,discriminatedUnion:ur,instanceof:bn,lazy:or,literal:Ye,null:nn,number:nr,object:F,record:C,string:L,union:p,unknown:pn},vv=H.lazy(()=>H.union([H.null(),H.string(),H.number(),H.boolean(),H.record(H.string(),vv.optional()),H.array(vv)])),U=H.record(H.string(),H.record(H.string(),vv.optional()));function yv(e){return V.object({source:V.discriminatedUnion(`sourceType`,[V.object({type:V.literal(`source`),sourceType:V.literal(`url`),id:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(e)}),V.object({type:V.literal(`source`),sourceType:V.literal(`document`),id:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(e)})]),startIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),endIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),citedText:V.optional(V.string())})}var bv=yv(U),xv=V.record(V.string(),V.optional(vv)),Sv=Zg(()=>o_(V.union([V.looseObject({type:V.literal(`text-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-end`),id:V.string(),citations:V.optional(V.array(bv)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`error`),errorText:V.string()}),V.looseObject({type:V.literal(`tool-input-start`),toolCallId:V.string(),toolName:V.string(),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-delta`),toolCallId:V.string(),inputTextDelta:V.string()}),V.looseObject({type:V.literal(`tool-input-available`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-error`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),errorText:V.string(),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-request`),approvalId:V.string(),toolCallId:V.string(),approvalDescriptor:V.optional(V.unknown()),inputSchemaInput:V.optional(V.unknown()),reason:V.optional(V.string()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-response`),approvalId:V.string(),approved:V.boolean(),reason:V.optional(V.string()),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`tool-output-available`),toolCallId:V.string(),output:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),preliminary:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-error`),toolCallId:V.string(),errorText:V.string(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-denied`),toolCallId:V.string()}),V.looseObject({type:V.literal(`reasoning-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-end`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`custom`),kind:V.pipe(V.string(),V.transform(e=>e)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`steering-message`),id:V.string(),parts:V.array(V.union([V.looseObject({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),mediaType:V.string(),url:V.string(),filename:V.optional(V.string()),providerReference:V.optional(V.record(V.string(),V.string())),providerMetadata:V.optional(U)})]))}),V.looseObject({type:V.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:V.optional(V.string()),data:V.unknown(),transient:V.optional(V.boolean())}),V.looseObject({type:V.literal(`start-step`)}),V.looseObject({type:V.literal(`finish-step`)}),V.looseObject({type:V.literal(`reset-step`)}),V.looseObject({type:V.literal(`start`),messageId:V.optional(V.string()),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`finish`),finishReason:V.optional(V.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`interrupted`,`other`])),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`abort`),reason:V.optional(V.string())}),V.looseObject({type:V.literal(`message-metadata`),messageMetadata:V.unknown()})])));function Cv(e){return e.type.startsWith(`data-`)}function wv(){return Object.create(null)}function Tv(e){return e.type===`text`}function Ev(e){return e.type===`reasoning`}function Dv(e){return e.type.startsWith(`tool-`)}function Ov(e){return e.type===`dynamic-tool`}function kv(e){return Dv(e)||Ov(e)}function Av(e){return e.type.split(`-`).slice(1).join(`-`)}function jv(e){return Ov(e)?e.toolName:Av(e)}function Mv({lastMessage:e,messageId:t}){let n=e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},r=wv(),i=n.parts.findLastIndex(e=>e.type===`step-start`),a=0;for(let e of n.parts.slice(i+1)){if(!kv(e))continue;let t=a;Dv(e)&&a++,e.state===`input-streaming`&&(r[e.toolCallId]={text:e.rawInput??``,inputEncoding:e.inputEncoding,index:t,toolName:e.type===`dynamic-tool`?e.toolName:Av(e),dynamic:e.type===`dynamic-tool`,title:e.title,toolMetadata:e.toolMetadata})}return{message:n,activeTextParts:wv(),activeReasoningParts:wv(),partialToolCalls:r}}function Nv({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o,resetStateOnMessageIdChange:s=!1,resetStateOnFirstMessageStart:c=!1}){let l=!0;return e.pipeThrough(new TransformStream({async transform(e,u){await r(async({state:r,write:d})=>{function f(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function p(){return f().filter(kv)}function m(e){let t=p().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(kv(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new hv({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function h(e){let t=r.message.parts.filter(kv).find(t=>t.approval?.id===e);if(t==null)throw new hv({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function g(e,t){let n=t??f().find(t=>Dv(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.type=`tool-${e.toolName}`,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}function _(e,t){let n=t??f().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}async function v(e){if(e!=null){let n=r.message.metadata==null?e:lv(r.message.metadata,e);t!=null&&await s_({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),d();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new hv({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new hv({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,e.citations!=null&&(t.citations=e.citations),t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],d();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),d();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),d();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new hv({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new hv({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],d();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),d();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),d();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),d();break;case`tool-input-start`:{let t=f().filter(Dv);r.partialToolCalls[e.toolCallId]={text:``,inputEncoding:e.inputEncoding,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),d();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new hv({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let n=t.inputEncoding===`text`?t.text:(await _v(t.text)).value;t.dynamic?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}):g({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}),d();break}case`tool-input-available`:e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),d(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=f().filter(kv).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),d();break}case`tool-approval-request`:{let t=m(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...Object.prototype.hasOwnProperty.call(e,`inputSchemaInput`)?{inputSchemaInput:e.inputSchemaInput}:{},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},d();break}case`tool-approval-response`:{let t=h(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),d();break}case`tool-output-denied`:{let t=m(e.toolCallId);t.state=`output-denied`,d();break}case`tool-output-available`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Av(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`tool-output-error`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Av(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`steering-message`:r.message.parts.push({type:`steering-message`,id:e.id,parts:e.parts}),d();break;case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=f();r.activeTextParts=wv(),r.activeReasoningParts=wv(),r.partialToolCalls=wv(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),d());break}case`start`:{let t=c&&l||s&&e.messageId!=null&&e.messageId!==r.message.id;l=!1,t&&Object.assign(r,Mv({lastMessage:void 0,messageId:e.messageId??r.message.id}),{finishReason:void 0}),e.messageId!=null&&(r.message.id=e.messageId),await v(e.messageMetadata),(t||e.messageId!=null||e.messageMetadata!=null)&&d({updateStatus:!1});break}case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`message-metadata`:await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`error`:i?.(Error(e.errorText));break;default:if(Cv(e)){let t=n?.[e.type.slice(5)];if(t!=null){let n=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=n>=0?n:r.message.parts.length;await s_({value:e.data,schema:t,context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let i=e;if(i.transient){o?.(i);break}let a=i.id==null?void 0:r.message.parts.find(e=>i.type===e.type&&i.id===e.id);a==null?r.message.parts.push(i):a.data=i.data,o?.(i),d()}}u.enqueue(e)})}}))}async function Pv({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function Fv(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}Xh({prefix:`aitxt`,size:24}),Xh({prefix:`call`,size:24}),Xh({prefix:`aitxt`,size:24}),Xh({prefix:`call`,size:24});function Iv(e){return e.dynamic=!1,e}var Lv={type:`deprecated`,setting:`rawInput in output-error UI message parts`,message:`Use the "input" field instead. The "rawInput" field will be removed in the next major version.`};function Rv(e){e.some(e=>e.parts.some(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&(e.type===`dynamic-tool`||e.type.startsWith(`tool-`))&&`state`in e&&e.state===`output-error`&&Object.prototype.hasOwnProperty.call(e,`rawInput`)&&`rawInput`in e&&e.rawInput!==void 0))&&cv({warnings:[Lv]})}var zv=Symbol(`invalid`);function Bv(e){let t=[],n=Vv(e,t,new Set);return n===zv?{success:!1,path:t}:{success:!0,value:n}}function Vv(e,t,n){switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:zv;case`object`:{if(e===null)return e;if(n.has(e))return zv;n.add(e);let r=Array.isArray(e)?Hv(e,t,n):Uv(e,t,n);return n.delete(e),r}default:return zv}}function Hv(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];t.push(i);let o=Vv(a,t,n);if(o===zv)return zv;t.pop(),r==null?o!==a&&(r=e.slice(0,i),r.push(o)):r.push(o)}return r??e}function Uv(e,t,n){if(!Gv(e)||Kv(e))return zv;let r=Object.keys(e),i;for(let a=0;a<r.length;a++){let o=r[a];if(o===`__proto__`){i??=Wv(e,r,a);continue}let s=e[o],c=s;if(s!==void 0){if(t.push(o),c=Vv(s,t,n),c===zv)return zv;t.pop()}i==null?c!==s&&(i=Wv(e,r,a),i[o]=c):i[o]=c}return i??e}function Wv(e,t,n){let r={};for(let i=0;i<n;i++)r[t[i]]=e[t[i]];return r}function Gv(e){let t=e.constructor;if(typeof t!=`function`)return!0;let n=t.prototype;return typeof n==`object`&&!!n&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)}function Kv(e){let t=Object.getOwnPropertySymbols(e);for(let n=0;n<t.length;n++)if(Object.prototype.propertyIsEnumerable.call(e,t[n]))return!0;return!1}var qv=V.pipe(V.unknown(),V.transform((e,t)=>{let n=Bv(e);return n.success?n.value:(t.issues.push({code:`custom`,message:`Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.`,input:e,path:n.path}),V.NEVER)})),Jv=V.custom(),Yv=V.pipe(qv,V.record(V.string(),Jv)),Xv=V.pipe(qv,V.record(V.string(),V.record(V.string(),Jv))),Zv=V.record(V.string(),V.string()),Qv=yv(Xv);function $v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function ey(e){let{type:t,...n}=e;return Iv({...n,type:`dynamic-tool`,toolName:t.slice(5)})}function ty(e){return e.approval!=null&&Object.prototype.hasOwnProperty.call(e.approval,`inputSchemaInput`)?{value:e.approval.inputSchemaInput}:void 0}function ny(e){return V.pipe(V.array(V.unknown()),V.transform((t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=V.safeParse(e(a),a);if(!t.success){for(let e of t.error.issues)n.issues.push({...e,path:[i,...e.path]});return V.NEVER}r.push(t.data)}return r}))}var ry=Zg(()=>{let e=V.object({id:V.string(),approved:V.optional(V.never()),descriptor:V.optional(V.unknown()),requestReason:V.optional(V.string()),reason:V.optional(V.never()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string()),inputSchemaInput:V.optional(V.unknown())}),t=V.extend(e,{approved:V.boolean(),reason:V.optional(V.string())}),n=V.extend(t,{approved:V.literal(!0)}),r=V.extend(t,{approved:V.literal(!1)}),i=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(Zv),providerMetadata:V.optional(Xv)})]),a=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),citations:V.optional(ny(()=>Qv)),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`reasoning`),id:V.optional(V.string()),text:V.string(),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`custom`),kind:V.string(),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(Zv),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`reasoning-file`),mediaType:V.string(),url:V.string(),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`steering-message`),id:V.string(),parts:ny(()=>i)}),V.object({type:V.literal(`step-start`)})],{error:e=>e.code===`invalid_union`?`Invalid UI message part type. Expected a known part type (for example "text" or "dynamic-tool") or a type starting with "data-" or "tool-".`:void 0}),o=V.object({type:V.string().check(V.startsWith(`data-`)),id:V.optional(V.string()),data:V.unknown()}),s=V.discriminatedUnion(`state`,[V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-streaming`),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Xv),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:e}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:t}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-error`),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-denied`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:r})]),c=V.discriminatedUnion(`state`,[V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-streaming`),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Xv),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:e}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:t}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-error`),providerExecuted:V.optional(V.boolean()),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-denied`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:r})]),l=V.object({id:V.string(),role:V.enum([`system`,`user`,`assistant`]),metadata:V.optional(V.unknown()),parts:ny(e=>{let t=e?.type;if(typeof t==`string`){if(t.startsWith(`data-`))return o;if(t.startsWith(`tool-`))return c;if(t===`dynamic-tool`)return s}return a})}).check(e=>{let t=e.value;t.role!==`assistant`&&t.parts.length===0&&e.issues.push({continue:!0,origin:`array`,code:`too_small`,minimum:1,inclusive:!0,input:t.parts,path:[`parts`],message:`Message must contain at least one part`})});return o_(ny(()=>l).check(V.minLength(1,`Messages array must not be empty`)))});async function iy({messages:e,metadataSchema:t,dataSchemas:n,tools:r,experimental_refineToolInput:i},{convertMissingTerminalToolsToDynamic:a}){try{if(e==null)return{success:!1,error:new $_({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let o=await s_({value:e,schema:ry});if(Rv(o),t)for(let[e,n]of o.entries())n.metadata=await s_({value:n.metadata,schema:t,context:{field:`messages[${e}].metadata`,entityId:n.id}});let s=r!=null||a;if(n||s)for(let[e,t]of o.entries())for(let[o,c]of t.parts.entries()){if(n&&c.type.startsWith(`data-`)){let t=c,r=t.type.slice(5),i=n[r];if(!i)return{success:!1,error:new jh({value:t.data,cause:`No data schema found for data part ${r}`,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})};t.data=await s_({value:t.data,schema:i,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})}if(s&&c.type.startsWith(`tool-`)){let n=c,s=n.type.slice(5),l=r==null?void 0:uv(r,s),u=n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`;if(!l&&u){(r!=null||a)&&(t.parts[o]=ey(n));continue}if(!l)return{success:!1,error:new jh({value:n.input,cause:`No tool schema found for tool part ${s}`,context:{field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId}})};let d={field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId},f=ty(n),p=f==null?n.input:f.value,m=!1;if(n.state!==`input-streaming`&&(n.state!==`output-error`||f!=null||n.input!==void 0)){let e=await c_({value:p,schema:l.inputSchema,context:d}),t;if(!e.success)t=e.error;else if(f!=null)try{let r=uv(i,s);dv(r==null?e.value:await r(e.value),n.input)||(t=new jh({value:n.input,cause:`Tool input does not match the output reconstructed from inputSchemaInput.`,context:d}))}catch(e){t=new jh({value:p,cause:e,context:d})}if(t!=null)if(n.state===`output-error`||n.state===`output-available`&&$v(n.input))m=!0;else throw t}n.state===`output-available`&&l.outputSchema&&await s_({value:n.output,schema:l.outputSchema,context:{field:`messages[${e}].parts[${o}].output`,entityName:s,entityId:n.toolCallId}}),m&&(t.parts[o]=ey(n))}}return{success:!0,data:o}}catch(e){return{success:!1,error:e}}}async function ay(e){return iy(e,{convertMissingTerminalToolsToDynamic:!1})}async function oy(e){let t=await ay(e);if(!t.success)throw t.error;return t.data}Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24}),new TextEncoder,Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24}),Xh({prefix:`aiobj`,size:24});var{atob:hee}=globalThis,sy=class{constructor(){this.queue=[],this.isProcessing=!1,this.idleWaiters=[]}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;this.queue.length>0;)await this.queue[0](),this.queue.shift()}finally{this.isProcessing=!1;for(let e of this.idleWaiters.splice(0))e()}}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}async waitForIdle(){!this.isProcessing&&this.queue.length===0||await new Promise(e=>{this.idleWaiters.push(e)})}};Xh({prefix:`aiobj`,size:24}),Xh({prefix:`call`,size:24});var cy=H.union([H.string(),H.custom(qh,{message:`Must be a Uint8Array`}),H.custom(Jh,{message:`Must be an ArrayBuffer`}),H.custom(Qh,{message:`Must be a Buffer`})]),ly=H.record(H.string(),H.string()),uy=H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),dy=H.object({type:H.literal(`image`),image:H.union([cy,H.instanceof(URL),ly]),mediaType:H.string().optional(),providerOptions:U.optional()}),fy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:cy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)}),H.object({type:H.literal(`reference`),reference:ly}),H.object({type:H.literal(`text`),text:H.string()})]),py=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:cy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)})]),my=H.object({type:H.literal(`file`),data:H.union([fy,cy,H.instanceof(URL),ly]),filename:H.string().optional(),mediaType:H.string(),providerOptions:U.optional()}),hy=H.object({type:H.literal(`reasoning`),text:H.string(),providerOptions:U.optional()}),gy=H.object({type:H.literal(`custom`),kind:H.string().transform(e=>e),providerOptions:U.optional()}),_y=H.object({type:H.literal(`reasoning-file`),data:H.union([py,cy,H.instanceof(URL)]),mediaType:H.string(),providerOptions:U.optional()}),gee=H.object({type:H.literal(`tool-call`),toolCallId:H.string(),toolName:H.string(),input:H.unknown(),providerOptions:U.optional(),providerExecuted:H.boolean().optional()}),vy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`json`),value:vv,providerOptions:U.optional()}),H.object({type:H.literal(`execution-denied`),reason:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`error-text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`error-json`),value:vv,providerOptions:U.optional()}),H.object({type:H.literal(`content`),value:H.array(H.union([H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`file`),data:fy,mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-data`),data:H.string(),mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-url`),url:H.string(),mediaType:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`image-data`),data:H.string(),mediaType:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-url`),url:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`custom`),providerOptions:U.optional()})]))})]),yy=H.object({type:H.literal(`tool-result`),toolCallId:H.string(),toolName:H.string(),output:vy,providerOptions:U.optional()}),by=H.object({type:H.literal(`tool-approval-request`),approvalId:H.string(),toolCallId:H.string(),reason:H.string().optional(),isAutomatic:H.boolean().optional(),signature:H.string().optional(),inputSchemaInput:H.unknown().optional()}),xy=H.object({type:H.literal(`tool-approval-response`),approvalId:H.string(),approved:H.boolean(),reason:H.string().optional()}),Sy=H.object({role:H.literal(`system`),content:H.string(),providerOptions:U.optional()}),Cy=H.object({role:H.literal(`user`),content:H.union([H.string(),H.array(H.union([uy,dy,my]))]),providerOptions:U.optional()}),wy=H.object({role:H.literal(`assistant`),content:H.union([H.string(),H.array(H.union([uy,gy,my,hy,_y,gee,yy,by]))]),providerOptions:U.optional()}),Ty=H.object({role:H.literal(`tool`),content:H.array(H.union([yy,xy])),providerOptions:U.optional()});H.union([Sy,Cy,wy,Ty]),V.object({token:V.string().check(V.refine(e=>e.trim().length>0)),url:V.string().check(V.refine(e=>{try{let t=new URL(e);return(t.protocol===`ws:`||t.protocol===`wss:`)&&t.hostname!==``}catch{return!1}})),expiresAt:V.optional(V.number().check(V.positive()).check(V.maximum(2**53-1))),tools:V.optional(V.array(V.object({type:V.literal(`function`),name:V.string().check(V.minLength(1)),description:V.optional(V.string()),parameters:V.record(V.string(),V.unknown())})))}),Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24});async function Ey({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new mh({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function Dy(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Fh({functionality:`FileList`,message:`FileList is not supported in the current environment`});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}function Oy(e,t){let n=e.search(/[?#]/),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r.endsWith(`/`)&&t.startsWith(`/`)?r.slice(0,-1):r}${t}${i}`}var ky=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await d_(this.body),r=await d_(this.headers),i=await d_(this.credentials),a={...Yh(r),...Yh(t.headers)},o=await this.prepareSendMessagesRequest?.({api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:Yh(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"content-type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw await Ey({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new vh({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await d_(this.body),n=await d_(this.headers),r=await d_(this.credentials),i={...Yh(n),...Yh(e.headers)},a=await this.prepareReconnectToStreamRequest?.({api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api;if(o==null){if(e.chatId===`.`||e.chatId===`..`)throw new $_({parameter:`chatId`,value:e.chatId,message:`Chat IDs must not be "." or ".." when using the default reconnect URL.`});o=Oy(this.api,`/${encodeURIComponent(e.chatId)}/stream`)}let s=a?.headers===void 0?i:Yh(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw await Ey({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new vh({message:`The response body is empty.`});return this.processResponseStream(l.body)}},Ay=class extends ky{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return u_({stream:e,schema:Sv}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},jy=class{get id(){return this._id??=this.generateId()}constructor({generateId:e=Zh,id:t,transport:n=new Ay,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u,experimental_queue:d=!1}){this.queuedMessagesFallback=[],this.queuedMessageOptions=new Map,this.isQueuePaused=!1,this.pendingAutomaticDecisions=[],this.pendingMessagePreparations=new Set,this.interruptedMessageIds=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.resumableStreamState=void 0,this.jobExecutor=new sy,this.activeStopCount=0,this.stopGeneration=0,this.experimental_removeQueuedMessage=e=>{this.queuedMessageOptions.delete(e),this.setQueuedMessages(this.experimental_queuedMessages.filter(t=>t.id!==e))},this.experimental_sendQueuedMessageNow=async e=>{let t=this.experimental_queuedMessages.find(t=>t.id===e);if(t==null)return;this.setQueuedMessages([t,...this.experimental_queuedMessages.filter(t=>t.id!==e)]);let n=this.stopGeneration+1;await this.stop(),n===this.stopGeneration&&await this.resumeQueue({skipWaitForUser:!0,options:this.queuedMessageOptions.get(e)})},this.sendMessage=async(e,t)=>{if(e==null){let e=this.pendingApprovalMessageId;if(e==null){e=this.lastMessage?.id;for(let t=this.state.messages.length-1;t>=0;t--){let n=this.state.messages[t];if(n.role===`assistant`&&n.parts.some(e=>kv(e)&&e.state===`approval-responded`)){e=n.id;break}}}let n=e!=null&&e===this.pendingApprovalMessageId?this.state.messages.findIndex(t=>t.id===e):-1;await this.makeRequestForToolApproval({messageId:e,messageIndex:n,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await Dy(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(this.queueEnabled&&e.messageId==null&&(this.isRequestInProgress()||this.isWaitingForUser()||this.experimental_queuedMessages.length>0)){let r={...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata};t!=null&&this.queuedMessageOptions.set(r.id,t),this.setQueuedMessages([...this.experimental_queuedMessages,r]),await this.resumeQueue({skipWaitForUser:this.isQueuePaused,options:t});return}if(e.messageId!=null){await this.clearQueueForHistoryChange();let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw new $_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new $_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...n,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});this.isQueuePaused=!1,await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{await this.clearQueueForHistoryChange();let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw new $_({parameter:`messageId`,value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this[`~resumeStreamIfDisconnected`]=async({shouldResume:e=()=>!0}={})=>{let t=this.activeResponse;this.resumableStreamState==null&&t!=null&&(await t.completionPromise,this.resumableStreamState!==t.state)||this.resumableStreamState!=null&&e()&&await this.resumeStream()},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.stopGeneration,a=this.state.messages,o=r=>kv(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r,s=a.findIndex(t=>t.parts.some(t=>kv(t)&&t.state===`approval-requested`&&t.approval.id===e));if(s!==-1){let e=a[s];this.state.replaceMessage(s,{...e,parts:e.parts.map(o)}),this.pendingApprovalMessageId=e.id}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),s!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(a[s].id);if(e){this.runAutomaticRequest(()=>{let e=s===-1?this.lastMessage?.id:a[s].id;return this.makeRequestForToolApproval({messageId:e,messageIndex:s,...r})},e);return}}this.settleQueue({stopGeneration:i})}),this.addToolOutput=async({state:e,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.stopGeneration,o=this.state.messages,s=i=>{if(!kv(i)||i.toolCallId!==t)return i;let{approval:a,...o}=i,s=a?.approved===!0?{approval:{...a,approved:a.approved}}:{};return e===`output-error`?{...o,...s,state:e,input:i.input,output:void 0,errorText:r}:{...o,...s,state:`output-available`,input:i.input,output:n,errorText:void 0}},c=o.findIndex(e=>e.parts.some(e=>kv(e)&&e.toolCallId===t));if(c!==-1){let e=o[c];this.state.replaceMessage(c,{...e,parts:e.parts.map(s)})}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),c!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(o[c].id);if(e){this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:o[c].id,...i}),e);return}}this.settleQueue({stopGeneration:a})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.activeStopCount++,this.stopGeneration++,this.deferredApprovalSend=void 0;try{let e=this.activeResumeRequest,t=this.activeResponse;for(let e of this.pendingMessagePreparations)e.abort();e?.abortController.abort(),t?.abortController.abort(),await Promise.all([e?.completionPromise,t?.completionPromise]),await this.jobExecutor.waitForIdle(),this.isQueuePaused=!0}finally{this.activeStopCount--}},this.dispose=async()=>{await this.stop(),this.transport.close?.()},this._id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u,this.queueEnabled=d}get status(){return this.state.status}setStatus({status:e,error:t}){if(this.status===e){this.error!==t&&(this.state.error=t);return}this.state.status=e,this.state.error=t}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}get experimental_queuedMessages(){return this.state.experimental_queuedMessages??this.queuedMessagesFallback}setQueuedMessages(e){`experimental_queuedMessages`in this.state?this.state.experimental_queuedMessages=e:this.queuedMessagesFallback=e}async resumeQueue({skipWaitForUser:e,options:t}){if(this.isQueuePaused=!1,this.hasUnsentApprovalResponse()){if(!this.isRequestInProgress()){await this.sendMessage(void 0,t);return}this.deferredApprovalSend={options:t}}await this.settleQueue({skipWaitForUser:e})}async clearQueueForHistoryChange(){this.queueEnabled&&(this.queuedMessageOptions.clear(),this.setQueuedMessages([]),this.deferredApprovalSend=void 0,this.isRequestInProgress()&&await this.stop())}isRequestInProgress(){return this.pendingAutomaticDecisions.includes(this.stopGeneration)||this.activeResponse!=null||this.status===`submitted`||this.status===`streaming`}isWaitingForUser(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>kv(e)&&(e.state===`approval-requested`||e.state===`approval-responded`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}hasUnsentApprovalResponse(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>kv(e)&&e.state===`approval-responded`)&&!e.parts.some(e=>kv(e)&&(e.state===`approval-requested`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}async settleQueue({stopGeneration:e=this.stopGeneration,skipWaitForUser:t=!1}={}){if(this.isQueuePaused||this.isRequestInProgress()||this.activeStopCount>0||e!==this.stopGeneration)return;let n=this.deferredApprovalSend;if(this.deferredApprovalSend=void 0,n!=null&&this.hasUnsentApprovalResponse()){await this.sendMessage(void 0,n.options);return}let[r,...i]=this.experimental_queuedMessages;if(r==null||!t&&this.isWaitingForUser())return;let a=this.queuedMessageOptions.get(r.id);this.queuedMessageOptions.delete(r.id),this.setQueuedMessages(i),this.state.pushMessage(r),await this.makeRequest({trigger:`submit-message`,...a})}set messages(e){this.state.messages=e}async shouldSendAutomatically(e=this.lastMessage?.id){let t=e=>e!=null&&this.interruptedMessageIds.has(e);if(!this.sendAutomaticallyWhen||t(e)||t(this.lastMessage?.id))return!1;let n=this.stopGeneration;this.pendingAutomaticDecisions.push(n);let r;try{r=await this.sendAutomaticallyWhen({messages:this.state.messages})}finally{this.pendingAutomaticDecisions.splice(this.pendingAutomaticDecisions.indexOf(n),1)}return r&&!t(e)&&!t(this.lastMessage?.id)}async runAutomaticRequest(e,t){let n=this.stopGeneration,r=this.activeStopCount>0;return!(t??await this.shouldSendAutomatically())||r||n!==this.stopGeneration||this.activeStopCount>0?!1:(await e(),!0)}async makeRequestForToolApproval({messageId:e,messageIndex:t,...n}){this.deferredApprovalSend=void 0;let r=e!=null&&e===this.pendingApprovalMessageId;r&&(this.pendingApprovalMessageId=void 0),await this.makeRequest({trigger:`submit-message`,messageId:e,...n}),r&&this.status===`error`&&this.pendingApprovalMessageId==null&&(this.pendingApprovalMessageId=this.state.messages[t]?.id??e)}async makeRequest(e){let t=Fv();try{await this.makeRequestImpl({...e,completionPromise:t.promise})}finally{t.resolve()}}async makeRequestImpl({trigger:e,metadata:t,headers:n,body:r,messageId:i,completionPromise:a}){e!==`resume-stream`&&(this.resumableStreamState=void 0);let o=new AbortController,s=e===`resume-stream`?{abortController:o,completionPromise:a}:void 0;s&&(this.activeResumeRequest?.abortController.abort(),this.activeResumeRequest=s);let c=()=>s==null||this.activeResumeRequest===s,l=()=>{this.activeResumeRequest===s&&(this.activeResumeRequest=void 0)},u;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:o.signal,metadata:t,headers:n,body:r});if(o.signal.aborted||!c()){await e?.cancel().catch(()=>{}),c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(e==null){this.setStatus({status:`ready`}),this.resumableStreamState=void 0,l();return}u=e}catch(e){if(o.signal.aborted||e.name===`AbortError`){c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(!c())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),l();return}this.setStatus({status:`submitted`,error:void 0});let d=this.lastMessage,f=e===`submit-message`&&i!=null?this.state.messages.findIndex(e=>e.id===i):this.state.messages.length-1,p=f===-1?d:this.state.messages[f],m=p?.id,h=e===`resume-stream`&&p?.role===`assistant`&&p.parts.some(e=>kv(e)&&(e.state===`input-streaming`||e.state===`input-available`&&e.providerExecuted||e.state===`approval-responded`))?this.state.snapshot(p):void 0,g=f!==-1&&f<this.state.messages.length-1&&p?.role===`assistant`,_=!1,v=!1,y=!1,b;try{let s={state:e===`resume-stream`&&this.resumableStreamState!=null?this.resumableStreamState:Mv({lastMessage:e===`resume-stream`?h:e===`regenerate-message`?void 0:this.state.snapshot(p),messageId:this.generateId()}),abortController:o,completionPromise:a};b=s,s.abortController.signal.addEventListener(`abort`,()=>{_=!0}),this.activeResponse=s;let l;if(l=e===`resume-stream`?u:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:s.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await Pv({stream:Nv({stream:l,resetStateOnMessageIdChange:e===`resume-stream`,resetStateOnFirstMessageStart:e===`resume-stream`&&this.transport.resumeStreamIsReplay,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>s.abortController.signal.aborted?Promise.resolve():e({state:s.state,write:({updateStatus:e=!0}={})=>{if(s.abortController.signal.aborted)return;e&&this.setStatus({status:`streaming`});let t=this.state.messages.findLastIndex(e=>e.id===s.state.message.id);if(t!==-1)this.state.replaceMessage(t,s.state.message);else if(g){let e=this.state.messages.findLastIndex(e=>e.id===m);e===-1?this.state.pushMessage(s.state.message):this.state.replaceMessage(e,s.state.message)}else this.state.pushMessage(s.state.message)}})),onError:e=>{throw e}}),abortSignal:s.abortController.signal,onError:e=>{throw e}}),_)return c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0)),null;c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0))}catch(e){if(_||e.name===`AbortError`)return _=!0,c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0)),null;if(!c())return null;if(y=!0,e instanceof TypeError){let t=e.message.toLowerCase();v=t.includes(`fetch`)||t.includes(`network`)||t===`load failed`}v?this.resumableStreamState=b?.state:this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{if(b){let{message:e,finishReason:t}=b.state;t===`interrupted`?this.interruptedMessageIds.add(e.id):!_&&!y&&this.interruptedMessageIds.delete(e.id),this.onFinish?.({message:b.state.message,messages:this.state.messages,isAbort:_,isDisconnect:v,isError:y,finishReason:b.state.finishReason})}}finally{(_||y||b?.state.finishReason===`interrupted`)&&(this.isQueuePaused=!0),this.activeResponse===b&&(this.activeResponse=void 0),l()}}if(!_&&!y&&b?.state.finishReason!==`interrupted`){let e=this.stopGeneration;await this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r}))||await this.settleQueue({stopGeneration:e})}}};function My({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(kv);return r.filter(e=>e.state===`approval-responded`).length>0&&r.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`||e.state===`output-denied`||e.state===`approval-responded`)}function Ny({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1),i=r.filter(kv).filter(e=>!e.providerExecuted),a=r.reduce((e,t,n)=>kv(t)&&!t.providerExecuted?n:e,-1);return i.length>0&&!r.slice(a+1).some(e=>e.type===`text`&&e.state!==`done`)&&i.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`)}var Py=n(a(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1);function Fy(e,t){return t==null?e:(0,Py.default)(e,t)}function Iy(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var Ly=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e=[]){this.#t=`ready`,this.#n=void 0,this.#r=[],this.#i=new Set,this.#a=new Set,this.#o=new Set,this.#s=new Set,this.pushMessage=e=>{this.#e=this.#e.concat(e),this.#c()},this.popMessage=()=>{this.#e=this.#e.slice(0,-1),this.#c()},this.replaceMessage=(e,t)=>{this.#e=[...this.#e.slice(0,e),this.snapshot(t),...this.#e.slice(e+1)],this.#c()},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=Iy(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?Fy(e,t):e;return this.#i.add(n),()=>{this.#i.delete(n)}},this[`~registerStatusCallback`]=e=>(this.#o.add(e),()=>{this.#o.delete(e)}),this[`~registerErrorCallback`]=e=>(this.#s.add(e),()=>{this.#s.delete(e)}),this[`~registerQueuedMessagesCallback`]=e=>(this.#a.add(e),()=>{this.#a.delete(e)}),this.#c=()=>{this.#i.forEach(e=>e())},this.#l=()=>{this.#o.forEach(e=>e())},this.#u=()=>{this.#s.forEach(e=>e())},this.#e=e}get status(){return this.#t}set status(e){this.#t=e,this.#l()}get error(){return this.#n}set error(e){this.#n=e,this.#u()}get experimental_queuedMessages(){return this.#r}set experimental_queuedMessages(e){this.#r=e,this.#a.forEach(e=>e())}get messages(){return this.#e}set messages(e){this.#e=[...e],this.#c()}#c;#l;#u},Ry=class extends jy{#e;constructor({messages:e,...t}){let n=new Ly(e);super({...t,state:n}),this[`~registerMessagesCallback`]=(e,t)=>this.#e[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>this.#e[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>this.#e[`~registerErrorCallback`](e),this[`~registerQueuedMessagesCallback`]=e=>this.#e[`~registerQueuedMessagesCallback`](e),this.#e=n}},zy=new WeakMap;function By({chat:e,state:t}){if(document.visibilityState!==`visible`||t.pendingVisibilityResume!=null)return;let n=()=>zy.get(e)===t&&t.registrations.size>0,r=()=>{t.pendingVisibilityResume=void 0};t.pendingVisibilityResume=e[`~resumeStreamIfDisconnected`]({shouldResume:()=>n()&&document.visibilityState===`visible`}).then(r,r)}function Vy({chat:e,registration:t}){let n=zy.get(e);if(n==null){let t={registrations:new Set};if(zy.set(e,t),n=t,typeof document<`u`){let n=()=>By({chat:e,state:t});document.addEventListener(`visibilitychange`,n),t.cleanupVisibilityListener=()=>{document.removeEventListener(`visibilitychange`,n)}}}let{registrations:r}=n,i=r.size===0;return r.add(t),i&&e.status!==`submitted`&&e.status!==`streaming`&&e.resumeStream(),()=>{r.delete(t),r.size===0&&(n.cleanupVisibilityListener?.(),zy.delete(e))}}function Hy(e){return{chat:e,messages:e.messages,status:e.status,error:e.error,experimental_queuedMessages:e.experimental_queuedMessages}}function Uy(e,t){return e.chat===t.chat&&e.messages===t.messages&&e.status===t.status&&e.error===t.error&&e.experimental_queuedMessages===t.experimental_queuedMessages}function Wy({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,R.useRef)({}),o=(0,R.useRef)({});`chat`in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let s,c=()=>o.current.transport??(s??=new Ay),l={...r,transport:{get resumeStreamIsReplay(){return c().resumeStreamIsReplay},sendMessages:e=>c().sendMessages(e),reconnectToStream:e=>c().reconnectToStream(e)},onToolCall:e=>o.current.onToolCall?.(e),onData:e=>o.current.onData?.(e),onFinish:e=>o.current.onFinish?.(e),onError:e=>o.current.onError?.(e),sendAutomaticallyWhen:e=>o.current.sendAutomaticallyWhen?.(e)??!1},{chat:u,isExternallyManaged:d}=(0,R.useMemo)(()=>({chat:`chat`in r?r.chat:new Ry(l),isExternallyManaged:`chat`in r}),[`chat`in r?r.chat:r.id]);(0,R.useEffect)(()=>{if(!d)return()=>{u.stop()}},[u,d]);let[f,p]=(0,R.useState)(()=>Hy(u));f.chat!==u&&p(Hy(u)),(0,R.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=Hy(u);p(e=>e.chat!==u||Uy(e,t)?e:t)},n=[u[`~registerMessagesCallback`](t,i),u[`~registerStatusCallback`](t),u[`~registerErrorCallback`](t),u[`~registerQueuedMessagesCallback`](t)],r=Hy(u);return p(e=>Uy(e,r)?e:r),()=>{e=!1,n.forEach(e=>e())}},[u,i]);let{messages:m,status:h,error:g,experimental_queuedMessages:_}=f,v=(0,R.useCallback)(e=>{typeof e==`function`&&(e=e(u.messages)),u.messages=e},[u]);return(0,R.useEffect)(()=>{if(n)return Vy({chat:u,registration:a.current})},[n,u]),{get id(){return u.id},messages:m,setMessages:v,sendMessage:u.sendMessage,regenerate:u.regenerate,clearError:u.clearError,stop:u.stop,error:g,resumeStream:u.resumeStream,status:h,addToolResult:u.addToolOutput,addToolOutput:u.addToolOutput,addToolApprovalResponse:u.addToolApprovalResponse,experimental_queuedMessages:_,experimental_removeQueuedMessage:u.experimental_removeQueuedMessage,experimental_sendQueuedMessageNow:u.experimental_sendQueuedMessageNow}}var Gy=a(((e,t)=>{(function(n,r){typeof i==`function`&&typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(function(){return r()}):n.pluralize=r()})(e,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:!e.hasOwnProperty(i)&&l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),Ky=a(((e,t)=>{function n(e){return e=String(e),e&&e.toLowerCase()}n.isLowercase=function(e){return e&&!/[A-Z]+/.test(e)},t.exports=n})),qy=a(((e,t)=>{function n(e){return e=String(e),e&&e.toUpperCase()}n.isUppercase=function(e){return e&&!/[a-z]+/.test(e)},t.exports=n})),Jy=a(((e,t)=>{var n=Ky(),r=qy(),i={from:/[\-_:\.\s]([a-zA-Z])([a-zA-Z]*)/g,to:function(e,t,n,i,a){return t.length,r(t)+n}};function a(e){return a.isCamelcase(e)||(e=String(e).replace(/^[\-_:\.\s]/,``),!e)?e:(r.isUppercase(e)&&(e=n(e)),n(e[0])+e.replace(i.from,i.to).slice(1).replace(/^([A-Z]+)([A-Z])/,function(e,t,r){return n(t)+r}))}a.isCamelcase=function(e){return e&&/^[a-zA-Z]+$/.test(e)&&n(e[0])===e[0]},t.exports=a})),Yy=a(((e,t)=>{var n=qy();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Xy=a(((e,t)=>{var n=Ky(),r=qy(),i=`_`,a={from:/([A-Z]+)/g,to:function(e,t,a,o){var s=a===0?``:i,c=t.length;if(c===1)return s+n(t);var l=o.slice(a+t.length);return r.isUppercase(t)&&l[0]===i?s+n(t):s+(n(t.substr(0,c-1))+i+n(t[c-1]))}};function o(e){return o.isSnakecase(e)||(e=String(e).replace(/[\-.:\s]/g,i),!e)?e:(r.isUppercase(e)&&(e=n(e)),e.replace(a.from,a.to).replace(/_+/g,`_`))}o.isSnakecase=function(e){return e&&/^[a-z_]+$/.test(e)},t.exports=o})),Zy=a(((e,t)=>{var n=qy(),r=Xy();function i(e){return i.isConstcase(e)?e:n(r(e))}i.isConstcase=function(e){return e&&/^[A-Z_]+$/.test(e)},t.exports=i})),Qy=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,``)}t.exports=r})),$y=a(((e,t)=>{var n=Ky();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),eb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`.`)}t.exports=r})),tb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`:`)}t.exports=r})),nb=a(((e,t)=>{var n=Jy(),r=Yy();function i(e){return r(n(e))}t.exports=i})),rb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`/`)}t.exports=r})),ib=a(((e,t)=>{function n(e){return String(e).trim()}t.exports=n})),ab=a(((e,t)=>{Ky();var n=ib(),r=Xy(),i=Yy(),a=` `;function o(e){return e=String(e).replace(/^[\-_\.\s]/g,a),e&&i(r(n(e)).replace(/_/g,a))}t.exports=o})),ob=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,` `)}t.exports=r})),sb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`-`)}t.exports=r})),cb=a(((e,t)=>{var n=Xy(),r=Ky(),i=ib(),a=Yy(),o=`a,the,and,or,not,but,for,of`.split(`,`);function s(e){return n(e).split(/_/g).map(i).map(function(e){return~o.indexOf(e)?r(e):a(e)}).join(` `)}t.exports=s})),lb=a(((e,t)=>{var n=Jy(),r=Yy(),i=Zy(),a=Qy(),o=$y(),s=eb(),c=tb(),l=Ky(),u=nb(),d=rb(),f=ab(),p=Xy(),m=ob(),h=sb(),g=cb(),_=ib(),v=qy();e.camelcase=n,e.capitalcase=r,e.constcase=i,e.cramcase=a,e.decapitalcase=o,e.dotcase=s,e.enumcase=c,e.lowercase=l,e.pascalcase=u,e.pathcase=d,e.sentencecase=f,e.snakecase=p,e.spacecase=m,e.spinalcase=h,e.titlecase=g,e.trimcase=_,e.uppercase=v,t.exports={camelcase:n,capitalcase:r,constcase:i,cramcase:a,decapitalcase:o,dotcase:s,enumcase:c,lowercase:l,pascalcase:u,pathcase:d,sentencecase:f,snakecase:p,spacecase:m,spinalcase:h,titlecase:g,trimcase:_,uppercase:v}}));Gy(),lb();function ub(e){return typeof e==`object`&&!!e&&`name`in e&&(`data`in e||`codec`in e)&&typeof e.name==`string`}function db(e){return fb(e,new WeakSet)}function fb(e,t){return typeof e==`object`?e===null||t.has(e)?!0:(t.add(e),Array.isArray(e)?e.every(e=>fb(e,t)):e instanceof Promise?!1:Symbol.asyncIterator in e||Symbol.iterator in e?!0:ub(e)?fb(e.data,t):Object.values(e).every(e=>fb(e,t))):typeof e!=`bigint`&&typeof e!=`symbol`}function pb(e){return!(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Promise||Symbol.asyncIterator in e||Symbol.iterator in e||ub(e))}function mb(e){return e.type===`message`}function hb(e){if(ub(e)){if(mb(e))throw Error(`Message fragments are not supported by serialized fragment conversion`);if(!e.codec)throw Error(`Fragment "${e.name}" is missing codec`);return e.codec.encode()}return Array.isArray(e)?e.map(e=>hb(e)):pb(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,hb(t)])):e}function gb(e,t){return{name:`term`,data:{name:e,definition:t},codec:{encode(){return{type:`term`,name:e,definition:t}},decode(){return{name:e,definition:t}}}}}function _b(e){return{name:`hint`,data:e,codec:{encode(){return{type:`hint`,text:e}},decode(){return e}}}}function vb(e){return{name:`guardrail`,data:{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}},codec:{encode(){return{type:`guardrail`,rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}},decode(){return{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}}}}}function yb(e){return{name:`explain`,data:{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}},codec:{encode(){return{type:`explain`,concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}},decode(){return{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}}}}}function bb(e){return{name:`example`,data:{question:e.question,answer:e.answer,...e.note&&{note:e.note}},codec:{encode(){return{type:`example`,question:e.question,answer:e.answer,...e.note&&{note:e.note}}},decode(){return{question:e.question,answer:e.answer,...e.note&&{note:e.note}}}}}}function xb(e){return{name:`clarification`,data:{when:e.when,ask:e.ask,reason:e.reason},codec:{encode(){return{type:`clarification`,when:e.when,ask:e.ask,reason:e.reason}},decode(){return{when:e.when,ask:e.ask,reason:e.reason}}}}}function Sb(e){return{name:`workflow`,data:{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}},codec:{encode(){return{type:`workflow`,task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}},decode(){return{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}}}}}function Cb(e){return{name:`quirk`,data:{issue:e.issue,workaround:e.workaround},codec:{encode(){return{type:`quirk`,issue:e.issue,workaround:e.workaround}},decode(){return{issue:e.issue,workaround:e.workaround}}}}}function wb(e){return{name:`styleGuide`,data:{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}},codec:{encode(){return{type:`styleGuide`,prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}},decode(){return{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}}}}}function Tb(e){return{name:`analogy`,data:{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}},codec:{encode(){return{type:`analogy`,concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}},decode(){return{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}}}}}function Eb(e){return{name:`glossary`,data:Object.entries(e).map(([e,t])=>({term:e,expression:t})),codec:{encode(){return{type:`glossary`,entries:e}},decode(){return Object.entries(e).map(([e,t])=>({term:e,expression:t}))}}}}function Db(e){return{name:`role`,data:e,codec:{encode(){return{type:`role`,content:e}},decode(){return e}}}}function Ob(e){return{name:`principle`,data:{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`principle`,title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies.map(e=>hb(e))}}},decode(){return{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}}}}}}function kb(e){return{name:`policy`,data:{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`policy`,rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies.map(e=>hb(e))}}},decode(){return{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}}}}}}function Ab(e){return{name:`identity`,data:{...e.name&&{name:e.name},...e.role&&{role:e.role}},codec:{encode(){return{type:`identity`,...e.name&&{name:e.name},...e.role&&{role:e.role}}},decode(){return{...e.name&&{name:e.name},...e.role&&{role:e.role}}}}}}function jb(e){return{name:`persona`,data:{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}},codec:{encode(){return{type:`persona`,name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}},decode(){return{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}}}}}function Mb(e,t){return{name:`alias`,data:{term:e,meaning:t},codec:{encode(){return{type:`alias`,term:e,meaning:t}},decode(){return{term:e,meaning:t}}}}}function Nb(e,t){return{name:`preference`,data:{aspect:e,value:t},codec:{encode(){return{type:`preference`,aspect:e,value:t}},decode(){return{aspect:e,value:t}}}}}function Pb(e,t){return{name:`correction`,data:{subject:e,clarification:t},codec:{encode(){return{type:`correction`,subject:e,clarification:t}},decode(){return{subject:e,clarification:t}}}}}function Fb(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function Ib(e,t){if(Fb(e))return yee(e,t);if(Array.isArray(e))return e.map(e=>Ib(e,t));if(pb(e))return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Ib(n,t)]));if(!db(e))throw Error(`Unsupported serialized value of type ${typeof e}`);return e}function Lb(e,t){return{toFragment:(n,r)=>{let i=e.safeParse(n);if(!i.success)throw Error(`Invalid serialized ${n.type} fragment: ${At(i.error)}`);return t(i.data,r)}}}var Rb=Zt(pn()).optional(),zb={term:Lb(F({name:L(),definition:L()}),e=>gb(e.name,e.definition)),hint:Lb(F({text:L()}),e=>_b(e.text)),guardrail:Lb(F({rule:L(),reason:L().optional(),action:L().optional()}),e=>vb({rule:e.rule,reason:e.reason,action:e.action})),explain:Lb(F({concept:L(),explanation:L(),therefore:L().optional()}),e=>yb({concept:e.concept,explanation:e.explanation,therefore:e.therefore})),example:Lb(F({question:L(),answer:L(),note:L().optional()}),e=>bb({question:e.question,answer:e.answer,note:e.note})),clarification:Lb(F({when:L(),ask:L(),reason:L()}),e=>xb({when:e.when,ask:e.ask,reason:e.reason})),workflow:Lb(F({task:L(),steps:Zt(L()),triggers:Zt(L()).optional(),notes:L().optional()}),e=>Sb({task:e.task,steps:e.steps,triggers:e.triggers,notes:e.notes})),quirk:Lb(F({issue:L(),workaround:L()}),e=>Cb({issue:e.issue,workaround:e.workaround})),styleGuide:Lb(F({prefer:L(),never:L().optional(),always:L().optional()}),e=>wb({prefer:e.prefer,never:e.never,always:e.always})),analogy:Lb(F({concepts:Zt(L()),relationship:L(),insight:L().optional(),therefore:L().optional(),pitfall:L().optional()}),e=>Tb({concepts:e.concepts,relationship:e.relationship,insight:e.insight,therefore:e.therefore,pitfall:e.pitfall})),glossary:Lb(F({entries:C(L(),L())}),e=>Eb(e.entries)),role:Lb(F({content:L()}),e=>Db(e.content)),principle:Lb(F({title:L(),description:L(),policies:Rb}),(e,t)=>Ob({title:e.title,description:e.description,policies:e.policies?.map(e=>Ib(e,t))})),policy:Lb(F({rule:L(),before:L().optional(),reason:L().optional(),policies:Rb}),(e,t)=>kb({rule:e.rule,before:e.before,reason:e.reason,policies:e.policies?.map(e=>Ib(e,t))})),identity:Lb(F({name:L().optional(),role:L().optional()}),e=>Ab({name:e.name,role:e.role})),persona:Lb(F({name:L(),role:L().optional(),objective:L().optional(),tone:L().optional()}),e=>jb({name:e.name,role:e.role,objective:e.objective,tone:e.tone})),alias:Lb(F({term:L(),meaning:L()}),e=>Mb(e.term,e.meaning)),preference:Lb(F({aspect:L(),value:L()}),e=>Nb(e.aspect,e.value)),correction:Lb(F({subject:L(),clarification:L()}),e=>Pb(e.subject,e.clarification))};function _ee(e){return Object.hasOwn(zb,e)}var vee=new Set([`user`,`assistant`,`message`]);function yee(e,t){if(vee.has(e.type))throw Error(`Message fragments are not supported by serialized fragment conversion`);let n=t?.registry?.[e.type]??(_ee(e.type)?zb[e.type]:void 0);if(!n)throw Error(`Unsupported serialized fragment type: ${e.type}`);return n.toFragment(e,t)}function bee(e){let t=e?.reminders;return Array.isArray(t)?t.filter(e=>$h(e)&&typeof e.partIndex==`number`&&typeof e.start==`number`&&typeof e.end==`number`):[]}function xee(e,t){if(t.length===0)return e;let n=t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start);if(n.length===0)return e;let r=0,i=``;for(let t of n){if(t.start<r){t.end>r&&(r=t.end);continue}i+=e.slice(r,t.start),r=t.end}return i+=e.slice(r),i.trimEnd()}function See(e){if(Bb(e))return Vb(e);let t=bee($h(e.metadata)?e.metadata:void 0),n=new Map;for(let e of t){let t=n.get(e.partIndex)??[];t.push({start:e.start,end:e.end}),n.set(e.partIndex,t)}let r=e.parts.flatMap((e,t)=>{let r={...e},i=n.get(t);if(r.type!==`text`||i===void 0)return[r];let a=xee(r.text,i);return a.length===0?[]:[{...r,text:a}]}),i={...e,parts:r};if($h(e.metadata)){let t={...e.metadata};delete t.reminders,Object.keys(t).length>0?i.metadata=t:delete i.metadata}return i}function Bb(e){let t=e.metadata;if(!$h(t))return!1;let n=t.synthetic;return $h(n)?n.source===`reminder`:!1}function Vb(e){let t={...e,parts:e.parts.filter(e=>e.type!==`text`)};if($h(e.metadata)){let n={...e.metadata};delete n.synthetic,Object.keys(n).length>0?t.metadata=n:delete t.metadata}return t}var Hb=(0,R.createContext)({});function Ub(e){let t=(0,R.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Wb=typeof window<`u`?R.useLayoutEffect:R.useEffect,Gb=(0,R.createContext)(null);function Kb(e,t){e.indexOf(t)===-1&&e.push(t)}function qb(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Jb=(e,t,n)=>n>t?t:n<e?e:n,Yb={},Xb=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Zb=e=>typeof e==`object`&&!!e,Qb=e=>/^0[^.\s]+$/u.test(e);function $b(e){let t;return()=>(t===void 0&&(t=e()),t)}var ex=e=>e,tx=(...e)=>e.reduce((e,t)=>n=>t(e(n))),nx=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},rx=class{constructor(){this.subscriptions=[]}add(e){return Kb(this.subscriptions,e),()=>qb(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},ix=e=>e*1e3,ax=e=>e/1e3,ox=(e,t)=>t?1e3/t*e:0,sx=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,cx=1e-7,lx=12;function ux(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=sx(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>cx&&++s<lx);return o}function dx(e,t,n,r){if(e===t&&n===r)return ex;let i=t=>ux(t,0,1,e,n);return e=>e===0||e===1?e:sx(i(e),t,r)}var fx=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,px=e=>t=>1-e(1-t),mx=dx(.33,1.53,.69,.99),hx=px(mx),gx=fx(hx),_x=e=>e>=1?1:(e*=2)<1?.5*hx(e):.5*(2-2**(-10*(e-1))),vx=e=>1-Math.sin(Math.acos(e)),yx=px(vx),bx=fx(vx),xx=dx(.42,0,1,1),Sx=dx(0,0,.58,1),Cx=dx(.42,0,.58,1),wx=e=>Array.isArray(e)&&typeof e[0]!=`number`,Tx=e=>Array.isArray(e)&&typeof e[0]==`number`,Ex={linear:ex,easeIn:xx,easeInOut:Cx,easeOut:Sx,circIn:vx,circInOut:bx,circOut:yx,backIn:hx,backInOut:gx,backOut:mx,anticipate:_x},Dx=e=>typeof e==`string`,Ox=e=>{if(Tx(e)){e.length;let[t,n,r,i]=e;return dx(t,n,r,i)}else if(Dx(e))return Ex[e],`${e}`,Ex[e];return e},kx=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function Ax(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var jx=40;function Mx(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=kx.reduce((e,t)=>(e[t]=Ax(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Yb.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,jx),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:kx.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<kx.length;t++)o[kx[t]].cancel(e)},state:i,steps:o}}var{schedule:Nx,cancel:Px,state:Fx,steps:Ix}=Mx(typeof requestAnimationFrame<`u`?requestAnimationFrame:ex,!0),Lx;function Rx(){Lx=void 0}var zx={now:()=>(Lx===void 0&&zx.set(Fx.isProcessing||Yb.useManualTiming?Fx.timestamp:performance.now()),Lx),set:e=>{Lx=e,queueMicrotask(Rx)}},Bx=e=>t=>typeof t==`string`&&t.startsWith(e),Vx=Bx(`--`),Hx=Bx(`var(--`),Ux=e=>Hx(e)?Wx.test(e.split(`/*`)[0].trim()):!1,Wx=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Gx(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Kx={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},qx={...Kx,transform:e=>Jb(0,1,e)},Jx={...Kx,default:1},Yx=e=>Math.round(e*1e5)/1e5,Xx=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Zx(e){return e==null}var Qx=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,$x=(e,t)=>n=>!!(typeof n==`string`&&Qx.test(n)&&n.startsWith(e)||t&&!Zx(n)&&Object.prototype.hasOwnProperty.call(n,t)),eS=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Xx);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},tS=e=>Jb(0,255,e),nS={...Kx,transform:e=>Math.round(tS(e))},rS={test:$x(`rgb`,`red`),parse:eS(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+nS.transform(e)+`, `+nS.transform(t)+`, `+nS.transform(n)+`, `+Yx(qx.transform(r))+`)`};function iS(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var aS={test:$x(`#`),parse:iS,transform:rS.transform},oS=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),sS=oS(`deg`),cS=oS(`%`),W=oS(`px`),lS=oS(`vh`),uS=oS(`vw`),dS={...cS,parse:e=>cS.parse(e)/100,transform:e=>cS.transform(e*100)},fS={test:$x(`hsl`,`hue`),parse:eS(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+cS.transform(Yx(t))+`, `+cS.transform(Yx(n))+`, `+Yx(qx.transform(r))+`)`},pS={test:e=>rS.test(e)||aS.test(e)||fS.test(e),parse:e=>rS.test(e)?rS.parse(e):fS.test(e)?fS.parse(e):aS.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?rS.transform(e):fS.transform(e),getAnimatableNone:e=>{let t=pS.parse(e);return t.alpha=0,pS.transform(t)}},mS=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function hS(e){return isNaN(e)&&typeof e==`string`&&(e.match(Xx)?.length||0)+(e.match(mS)?.length||0)>0}var gS=`number`,_S=`color`,vS=`var`,yS=`var(`,bS="${}",xS=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function SS(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(xS,e=>(pS.test(e)?(r.color.push(a),i.push(_S),n.push(pS.parse(e))):e.startsWith(yS)?(r.var.push(a),i.push(vS),n.push(e)):(r.number.push(a),i.push(gS),n.push(parseFloat(e))),++a,bS)).split(bS),indexes:r,types:i}}function CS(e){return SS(e).values}function wS({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===gS?i+=Yx(r[a]):e===_S?i+=pS.transform(r[a]):i+=r[a]}return i}}function TS(e){return wS(SS(e))}var ES=e=>typeof e==`number`?0:pS.test(e)?pS.getAnimatableNone(e):e,DS=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:ES(e);function OS(e){let t=SS(e);return wS(t)(t.values.map((e,n)=>DS(e,t.split[n])))}var kS={test:hS,parse:CS,createTransformer:TS,getAnimatableNone:OS};function AS(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function jS({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=AS(s,r,e+1/3),a=AS(s,r,e),o=AS(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function MS(e,t){return n=>n>0?t:e}var NS=(e,t,n)=>e+(t-e)*n,PS=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},FS=[aS,rS,fS],IS=e=>FS.find(t=>t.test(e));function LS(e){let t=IS(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===fS&&(n=jS(n)),n}var RS=(e,t)=>{let n=LS(e),r=LS(t);if(!n||!r)return MS(e,t);let i={...n};return e=>(i.red=PS(n.red,r.red,e),i.green=PS(n.green,r.green,e),i.blue=PS(n.blue,r.blue,e),i.alpha=NS(n.alpha,r.alpha,e),rS.transform(i))},zS=new Set([`none`,`hidden`]);function BS(e,t){return zS.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function VS(e,t){return n=>NS(e,t,n)}function HS(e){return typeof e==`number`?VS:typeof e==`string`?Ux(e)?MS:pS.test(e)?RS:KS:Array.isArray(e)?US:typeof e==`object`?pS.test(e)?RS:WS:MS}function US(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>HS(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function WS(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=HS(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function GS(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var KS=(e,t)=>{let n=kS.createTransformer(t),r=SS(e),i=SS(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?zS.has(e)&&!i.values.length||zS.has(t)&&!r.values.length?BS(e,t):tx(US(GS(r,i),i.values),n):(`${e}${t}`,MS(e,t))};function qS(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?NS(e,t,n):HS(e)(e,t)}var JS=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Nx.update(t,e),stop:()=>Px(t),now:()=>Fx.isProcessing?Fx.timestamp:zx.now()}},YS=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},XS=2e4;function ZS(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function QS(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(ZS(r),XS);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ax(i)}}var $S={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function eC(e,t){return e*Math.sqrt(1-t*t)}var tC=12;function nC(e,t,n){let r=n;for(let n=1;n<tC;n++)r-=e(r)/t(r);return r}var rC=.001;function iC({duration:e=$S.duration,bounce:t=$S.bounce,velocity:n=$S.velocity,mass:r=$S.mass}){let i,a;$S.maxDuration;let o=1-t;o=Jb($S.minDamping,$S.maxDamping,o),e=Jb($S.minDuration,$S.maxDuration,ax(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=eC(t,o),c=Math.exp(-i);return rC-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=eC(t**2,o);return(-i(t)+rC>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=nC(i,a,s);if(e=ix(e),isNaN(c))return{stiffness:$S.stiffness,damping:$S.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var aC=[`duration`,`bounce`],oC=[`stiffness`,`damping`,`mass`];function sC(e,t){return t.some(t=>e[t]!==void 0)}function cC(e){let t={velocity:$S.velocity,stiffness:$S.stiffness,damping:$S.damping,mass:$S.mass,isResolvedFromDuration:!1,...e};if(!sC(e,oC)&&sC(e,aC))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Jb(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:$S.mass,stiffness:i,damping:a}}else{let n=iC({...e,velocity:0});t={...t,...n,mass:$S.mass},t.isResolvedFromDuration=!0}return t}function lC(e=$S.visualDuration,t=$S.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=cC({...n,velocity:-ax(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ax(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?$S.restSpeed.granular:$S.restSpeed.default,i||=v?$S.restDelta.granular:$S.restDelta.default;let y,b,x,S,C,w;if(h<1)x=eC(_,h),S=(m+h*_*g)/x,y=e=>{let t=Math.exp(-h*_*e);return o-t*(S*Math.sin(x*e)+g*Math.cos(x*e))},C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>ix(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=ix(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=ix(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(ZS(T),XS),t=YS(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}lC.applyToOptions=e=>{let t=QS(e,100,lC);return e.ease=t.ease,e.duration=ix(t.duration),e.type=`keyframes`,e};var uC=5;function dC(e,t,n){let r=Math.max(t-uC,0);return ox(n-e(r),t-r)}function fC({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=lC({keyframes:[f.value,m(f.value)],velocity:dC(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function pC(e,t,n){let r=[],i=n||Yb.mix||qS,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=tx(Array.isArray(t)?t[n]||ex:t,a)),r.push(a)}return r}function mC(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=pC(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=nx(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Jb(e[0],e[a-1],t)):l}function hC(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=nx(0,t,r);e.push(NS(n,1,i))}}function gC(e){let t=[0];return hC(t,e.length-1),t}function _C(e,t){return e.map(e=>e*t)}function vC(e,t){return e.map(()=>t||Cx).splice(0,e.length-1)}function yC({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=wx(r)?r.map(Ox):Ox(r),a={done:!1,value:t[0]},o=mC(_C(n&&n.length===t.length?n:gC(t),e),t,{ease:Array.isArray(i)?i:vC(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var bC=e=>e!==null;function xC(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(bC),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var SC={decay:fC,inertia:fC,tween:yC,keyframes:yC,spring:lC};function CC(e){typeof e.type==`string`&&(e.type=SC[e.type])}var wC=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},TC=e=>e/100,EC=class extends wC{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==zx.now()&&this.tick(zx.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;CC(e);let{type:t=yC,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||yC;s!==yC&&typeof o[0]!=`number`&&(this.mixKeyframes=tx(TC,qS(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=ZS(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Jb(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==fC&&(b.value=xC(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ax(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ax(e)}get time(){return ax(this.currentTime)}set time(e){e=ix(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return dC(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(zx.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ax(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=JS,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(zx.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function DC(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var OC=e=>e*180/Math.PI,kC=e=>jC(OC(Math.atan2(e[1],e[0]))),AC={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:kC,rotateZ:kC,skewX:e=>OC(Math.atan(e[1])),skewY:e=>OC(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},jC=e=>(e%=360,e<0&&(e+=360),e),MC=kC,NC=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),PC=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),FC={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:NC,scaleY:PC,scale:e=>(NC(e)+PC(e))/2,rotateX:e=>jC(OC(Math.atan2(e[6],e[5]))),rotateY:e=>jC(OC(Math.atan2(-e[2],e[0]))),rotateZ:MC,rotate:MC,skewX:e=>OC(Math.atan(e[4])),skewY:e=>OC(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function IC(e){return+!!e.includes(`scale`)}function LC(e,t){if(!e||e===`none`)return IC(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=FC,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=AC,i=t}if(!i)return IC(t);let a=r[t],o=i[1].split(`,`).map(zC);return typeof a==`function`?a(o):o[a]}var RC=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return LC(n,t)};function zC(e){return parseFloat(e.trim())}var BC=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],VC=new Set([...BC,`pathRotation`]),HC=e=>e===Kx||e===W,UC=new Set([`x`,`y`,`z`]),WC=BC.filter(e=>!UC.has(e));function GC(e){let t=[];return WC.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var KC={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>LC(t,`x`),y:(e,{transform:t})=>LC(t,`y`)};KC.translateX=KC.x,KC.translateY=KC.y;var qC=new Set,JC=!1,YC=!1,XC=!1;function ZC(){if(YC){let e=Array.from(qC).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=GC(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}YC=!1,JC=!1,qC.forEach(e=>e.complete(XC)),qC.clear()}function QC(){qC.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(YC=!0)})}function $C(){XC=!0,QC(),ZC(),XC=!1}var ew=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(qC.add(this),JC||(JC=!0,Nx.read(QC),Nx.resolveKeyframes(ZC))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}DC(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),qC.delete(this)}cancel(){this.state===`scheduled`&&(qC.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},tw=e=>e.startsWith(`--`);function nw(e,t,n){tw(t)?e.style.setProperty(t,n):e.style[t]=n}var rw={};function iw(e,t){let n=$b(e);return()=>rw[t]??n()}var aw=iw(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),ow=iw(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),sw=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,cw={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:sw([0,.65,.55,1]),circOut:sw([.55,0,1,.45]),backIn:sw([.31,.01,.66,-.59]),backOut:sw([.33,1.53,.69,.99])};function lw(e,t){if(e)return typeof e==`function`?ow()?YS(e,t):`ease-out`:Tx(e)?sw(e):Array.isArray(e)?e.map(e=>lw(e,t)||cw.easeOut):cw[e]}function uw(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=lw(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function dw(e){return typeof e==`function`&&`applyToOptions`in e}function fw({type:e,...t}){return dw(e)&&ow()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var pw=class extends wC{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=fw(e);this.animation=uw(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=xC(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),nw(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ax(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ax(e)}get time(){return ax(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ix(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&aw()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),ex):r(this)}},mw={anticipate:_x,backInOut:gx,circInOut:bx};function hw(e){return e in mw}function gw(e){typeof e.ease==`string`&&hw(e.ease)&&(e.ease=mw[e.ease])}var _w=10,vw=class extends pw{constructor(e){gw(e),CC(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new EC({...a,autoplay:!1}),s=Math.max(_w,zx.now()-this.startTime),c=Jb(0,_w,s-_w),l=o.sample(s).value,{name:u}=this.options;i&&u&&nw(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},yw=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(kS.test(e)||e===`0`)&&!e.startsWith(`url(`));function bw(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function xw(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=yw(i,t),s=yw(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:bw(e)||(n===`spring`||dw(n))&&r}function Sw(e){e.duration=0,e.type=`keyframes`}var Cw=new Set([`opacity`,`clipPath`,`filter`,`transform`]),ww=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Tw(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ww.test(e[t]))return!0;return!1}var Ew=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Dw=$b(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Ow(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Dw()&&n&&(Cw.has(n)||Ew.has(n)&&Tw(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var kw=40,Aw=class extends wC{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=zx.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||ew;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=zx.now();let u=!0;xw(e,i,a,o)||(u=!1,(Yb.instantAnimations||!s)&&l?.(xC(e,n,t)),e[0]=e[e.length-1],Sw(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>kw?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Ow(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new vw({...d,element:p})}catch{m=new EC(d)}else m=new EC(d);m.finished.then(()=>{this.notifyFinished()}).catch(ex),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),$C()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function jw(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Mw=30,Nw=e=>!isNaN(parseFloat(e)),Pw={current:void 0},Fw=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=zx.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=zx.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Nw(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new rx);let n=this.events[e].add(t);return e===`change`?()=>{n(),Nx.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Pw.current&&Pw.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=zx.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Mw)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Mw);return ox(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Iw(e,t){return new Fw(e,t)}function Lw(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Rw(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Lw(n,e)}var zw={type:`spring`,stiffness:500,damping:25,restSpeed:10},Bw=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Vw={type:`keyframes`,duration:.8},Hw={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Uw=(e,{keyframes:t})=>t.length>2?Vw:VC.has(e)?e.startsWith(`scale`)?Bw(t[1]):zw:Hw,Ww=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Gw(e){for(let t in e)if(!Ww.has(t))return!0;return!1}var Kw=(e,t,n,r={},i,a)=>o=>{let s=Rw(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=ix(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Gw(s)||Object.assign(u,Uw(e,u)),u.duration&&=ix(u.duration),u.repeatDelay&&=ix(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Sw(u),u.delay===0&&(d=!0)),(Yb.instantAnimations||Yb.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,Sw(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=xC(u.keyframes,s);if(e!==void 0){Nx.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new EC(u):new Aw(u)},qw=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Jw(e){let t=qw.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Yw(e,t,n=1){`${e}`;let[r,i]=Jw(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Xb(e)?parseFloat(e):e}return Ux(i)?Yw(i,t,n+1):i}function Xw(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Zw(e,t,n,r){if(typeof t==`function`){let[i,a]=Xw(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Xw(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Qw(e,t,n){let r=e.getProps();return Zw(r,t,n===void 0?r.custom:n,e)}var $w=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...BC]),eT=e=>Array.isArray(e);function tT(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Iw(n))}function nT(e){return eT(e)?e[e.length-1]||0:e}function rT(e,t){let{transitionEnd:n={},transition:r={},...i}=Qw(e,t)||{};i={...i,...n};for(let t in i)tT(e,t,nT(i[t]))}var iT=e=>!!(e&&e.getVelocity);function aT(e){return!!(iT(e)&&e.add)}function oT(e,t){let n=e.getValue(`willChange`);if(aT(n))return n.add(t);if(!n&&Yb.WillChange){let n=new Yb.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function sT(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var cT=`data-`+sT(`framerAppearId`);function lT(e){return e.props[cT]}function uT({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function dT(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Lw(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&uT(f,t))continue;let o={delay:n,...Rw(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Nx.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=lT(e);if(n){let e=window.MotionHandoffAnimation(n,t,Nx);e!==null&&(o.startTime=e,p=!0)}}oT(e,t);let m=l??e.shouldReduceMotion;r.start(Kw(t,r,i,m&&$w.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Nx.update(()=>{o&&rT(e,o)});d.length?Promise.all(d).then(t):t()}return d}function fT(e,t,n={}){let r=Qw(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(dT(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return pT(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function pT(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(fT(c,t,{...o,delay:n+(typeof r==`function`?0:r)+jw(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function mT(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>fT(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=fT(e,t,n);else{let i=typeof t==`function`?Qw(e,t,n.custom):t;r=Promise.all(dT(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var hT={test:e=>e===`auto`,parse:e=>e},gT=e=>t=>t.test(e),_T=[Kx,W,cS,sS,uS,lS,hT],vT=e=>_T.find(gT(e));function yT(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Qb(e)}var bT=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function xT(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Xx)||[];if(!r)return e;let i=n.replace(r,``),a=+!!bT.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var ST=/\b([a-z-]*)\(.*?\)/gu,CT={...kS,getAnimatableNone:e=>{let t=e.match(ST);return t?t.map(xT).join(` `):e}},wT={...kS,getAnimatableNone:e=>{let t=kS.parse(e);return kS.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},TT={...Kx,transform:Math.round},ET={borderWidth:W,borderTopWidth:W,borderRightWidth:W,borderBottomWidth:W,borderLeftWidth:W,borderRadius:W,borderTopLeftRadius:W,borderTopRightRadius:W,borderBottomRightRadius:W,borderBottomLeftRadius:W,width:W,maxWidth:W,height:W,maxHeight:W,top:W,right:W,bottom:W,left:W,inset:W,insetBlock:W,insetBlockStart:W,insetBlockEnd:W,insetInline:W,insetInlineStart:W,insetInlineEnd:W,padding:W,paddingTop:W,paddingRight:W,paddingBottom:W,paddingLeft:W,paddingBlock:W,paddingBlockStart:W,paddingBlockEnd:W,paddingInline:W,paddingInlineStart:W,paddingInlineEnd:W,margin:W,marginTop:W,marginRight:W,marginBottom:W,marginLeft:W,marginBlock:W,marginBlockStart:W,marginBlockEnd:W,marginInline:W,marginInlineStart:W,marginInlineEnd:W,fontSize:W,backgroundPositionX:W,backgroundPositionY:W,rotate:sS,pathRotation:sS,rotateX:sS,rotateY:sS,rotateZ:sS,scale:Jx,scaleX:Jx,scaleY:Jx,scaleZ:Jx,skew:sS,skewX:sS,skewY:sS,distance:W,translateX:W,translateY:W,translateZ:W,x:W,y:W,z:W,perspective:W,transformPerspective:W,opacity:qx,originX:dS,originY:dS,originZ:W,zIndex:TT,fillOpacity:qx,strokeOpacity:qx,numOctaves:TT},DT={...ET,color:pS,backgroundColor:pS,outlineColor:pS,fill:pS,stroke:pS,borderColor:pS,borderTopColor:pS,borderRightColor:pS,borderBottomColor:pS,borderLeftColor:pS,filter:CT,WebkitFilter:CT,mask:wT,WebkitMask:wT},OT=e=>DT[e],kT=new Set([CT,wT]);function AT(e,t){let n=OT(e);return kT.has(n)||(n=kS),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var jT=new Set([`auto`,`none`,`0`]);function MT(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!jT.has(t)&&SS(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=AT(n,i)}var NT=class extends ew{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Ux(r))){let i=Yw(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!$w.has(n)||e.length!==2)return;let[r,i]=e,a=vT(r),o=vT(i);if(Gx(r)!==Gx(i)&&KC[n]){this.needsMeasurement=!0;return}if(a!==o)if(HC(a)&&HC(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else KC[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||yT(e[t]))&&n.push(t);n.length&&MT(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=KC[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=KC[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},PT=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function FT(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var IT=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function LT(e){return Zb(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:RT,cancel:Cee}=Mx(queueMicrotask,!1),zT={x:!1,y:!1};function BT(){return zT.x||zT.y}function VT(e){return e===`x`||e===`y`?zT[e]?null:(zT[e]=!0,()=>{zT[e]=!1}):zT.x||zT.y?null:(zT.x=zT.y=!0,()=>{zT.x=zT.y=!1})}function HT(e,t){let n=FT(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function UT(e){return!(e.pointerType===`touch`||BT())}function WT(e,t,n={}){let[r,i,a]=HT(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!UT(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var GT=(e,t)=>t?e===t||GT(e,t.parentElement):!1,KT=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,qT=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function JT(e){return qT.has(e.tagName)||e.isContentEditable===!0}var YT=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function XT(e){return YT.has(e.tagName)||e.isContentEditable===!0}var ZT=new WeakSet;function QT(e){return t=>{t.key===`Enter`&&e(t)}}function $T(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var eE=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=QT(()=>{if(ZT.has(n))return;$T(n,`down`);let e=QT(()=>{$T(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>$T(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function tE(e){return KT(e)&&!BT()}var nE=new WeakSet;function rE(e,t,n={}){let[r,i,a]=HT(e,n),o=e=>{let r=e.currentTarget;if(!tE(e)||nE.has(e))return;ZT.add(r),n.stopPropagation&&nE.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),ZT.has(r)&&ZT.delete(r),tE(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||GT(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),LT(e)&&(e.addEventListener(`focus`,e=>eE(e,i)),!JT(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function iE(e){return Zb(e)&&`ownerSVGElement`in e}var aE=new WeakMap,oE,sE=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:iE(r)&&`getBBox`in r?r.getBBox()[t]:r[n],cE=sE(`inline`,`width`,`offsetWidth`),lE=sE(`block`,`height`,`offsetHeight`);function uE({target:e,borderBoxSize:t}){aE.get(e)?.forEach(n=>{n(e,{get width(){return cE(e,t)},get height(){return lE(e,t)}})})}function dE(e){e.forEach(uE)}function fE(){typeof ResizeObserver>`u`||(oE=new ResizeObserver(dE))}function pE(e,t){oE||fE();let n=FT(e);return n.forEach(e=>{let n=aE.get(e);n||(n=new Set,aE.set(e,n)),n.add(t),oE?.observe(e)}),()=>{n.forEach(e=>{let n=aE.get(e);n?.delete(t),n?.size||oE?.unobserve(e)})}}var mE=new Set,hE;function gE(){hE=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};mE.forEach(t=>t(e))},window.addEventListener(`resize`,hE)}function _E(e){return mE.add(e),hE||gE(),()=>{mE.delete(e),!mE.size&&typeof hE==`function`&&(window.removeEventListener(`resize`,hE),hE=void 0)}}function vE(e,t){return typeof e==`function`?_E(e):pE(e,t)}var yE={value:null,addProjectionMetrics:null};function bE(e){return iE(e)&&e.tagName===`svg`}var xE=[..._T,pS,kS],SE=e=>xE.find(gT(e)),CE=()=>({translate:0,scale:1,origin:0,originPoint:0}),wE=()=>({x:CE(),y:CE()}),TE=()=>({min:0,max:0}),EE=()=>({x:TE(),y:TE()}),DE=new WeakMap;function OE(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function kE(e){return typeof e==`string`||Array.isArray(e)}var AE=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],jE=[`initial`,...AE];function ME(e){return OE(e.animate)||jE.some(t=>kE(e[t]))}function NE(e){return!!(ME(e)||e.variants)}function PE(e,t,n){for(let r in t){let i=t[r],a=n[r];if(iT(i))e.addValue(r,i);else if(iT(a))e.addValue(r,Iw(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Iw(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var FE={current:null},IE={current:!1},LE=typeof window<`u`;function RE(){if(IE.current=!0,LE)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>FE.current=e.matches;e.addEventListener(`change`,t),t()}else FE.current=!1}var zE=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],BE={};function VE(e){BE=e}function HE(){return BE}var UE=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ew,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=zx.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Nx.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=ME(t),this.isVariantNode=NE(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&iT(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,DE.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(IE.current||RE(),this.shouldReduceMotion=FE.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Px(this.notifyUpdate),Px(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&Cw.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new pw({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:ix(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=VC.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Nx.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in BE){let t=BE[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):EE()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<zE.length;t++){let n=zE[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=PE(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Iw(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Xb(n)||Qb(n))?n=parseFloat(n):!SE(n)&&kS.test(t)&&(n=AT(e,t)),this.setBaseTarget(e,iT(n)?n.get():n)),iT(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Zw(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!iT(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new rx),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){RT.render(this.render)}},WE=class extends UE{constructor(){super(...arguments),this.KeyframeResolver=NT}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;iT(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},GE=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function KE({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function qE({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function JE(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function YE(e){return e===void 0||e===1}function XE({scale:e,scaleX:t,scaleY:n}){return!YE(e)||!YE(t)||!YE(n)}function ZE(e){return XE(e)||QE(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function QE(e){return $E(e.x)||$E(e.y)}function $E(e){return e&&e!==`0%`}function eD(e,t,n){return n+t*(e-n)}function tD(e,t,n,r,i){return i!==void 0&&(e=eD(e,i,r)),eD(e,n,r)+t}function nD(e,t=0,n=1,r,i){e.min=tD(e.min,t,n,r,i),e.max=tD(e.max,t,n,r,i)}function rD(e,{x:t,y:n}){nD(e.x,t.translate,t.scale,t.originPoint),nD(e.y,n.translate,n.scale,n.originPoint)}var iD=.999999999999,aD=1.0000000000001;function oD(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(sD(e.x,-a.scroll.offset.x),sD(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,rD(e,o)),r&&ZE(a.latestValues)&&uD(e,a.latestValues,a.layout?.layoutBox))}t.x<aD&&t.x>iD&&(t.x=1),t.y<aD&&t.y>iD&&(t.y=1)}function sD(e,t){e.min+=t,e.max+=t}function cD(e,t,n,r,i=.5){nD(e,t,n,NS(e.min,e.max,i),r)}function lD(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function uD(e,t,n){let r=n??e;cD(e.x,lD(t.x,r.x),t.scaleX,t.scale,t.originX),cD(e.y,lD(t.y,r.y),t.scaleY,t.scale,t.originY)}function dD(e,t){return KE(JE(e.getBoundingClientRect(),t))}function fD(e,t,n){let r=dD(e,n),{scroll:i}=t;return i&&(sD(r.x,i.offset.x),sD(r.y,i.offset.y)),r}var pD={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},mD=BC.length;function hD(e,t,n){let r=``,i=!0;for(let a=0;a<mD;a++){let o=BC[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=IT(s,ET[o]);if(!c){i=!1;let t=pD[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${IT(a,ET.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function gD(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(VC.has(e)){o=!0;continue}else if(Vx(e)){i[e]=n;continue}else{let t=IT(n,ET[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=hD(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function _D(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function vD(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var yD={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(W.test(e))e=parseFloat(e);else return e;return`${vD(e,t.target.x)}% ${vD(e,t.target.y)}%`}},bD={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=kS.parse(e);if(i.length>5)return r;let a=kS.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=NS(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},xD={borderRadius:{...yD,applyTo:[...PT]},borderTopLeftRadius:yD,borderTopRightRadius:yD,borderBottomLeftRadius:yD,borderBottomRightRadius:yD,boxShadow:bD};function SD(e,{layout:t,layoutId:n}){return VC.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!xD[e]||e===`opacity`)}function CD(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(iT(r[t])||i&&iT(i[t])||SD(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function wD(e){return window.getComputedStyle(e)}var TD=class extends WE{constructor(){super(...arguments),this.type=`html`,this.renderInstance=_D}readValueFromInstance(e,t){if(VC.has(t))return this.projection?.isProjecting?IC(t):RC(e,t);{let n=wD(e),r=(Vx(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return dD(e,t)}build(e,t,n){gD(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return CD(e,t,n)}},ED={offset:`stroke-dashoffset`,array:`stroke-dasharray`},DD={offset:`strokeDashoffset`,array:`strokeDasharray`};function OD(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?ED:DD;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var kD=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function AD(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(gD(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of kD)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&OD(d,i,a,o,!1)}var jD=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),MD=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function ND(e,t,n,r){_D(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(jD.has(n)?n:sT(n),t.attrs[n])}function PD(e,t,n){let r=CD(e,t,n);for(let n in e)if(iT(e[n])||iT(t[n])){let t=BC.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var FD=class extends WE{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=EE}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(VC.has(t)){let e=OT(t);return e&&e.default||0}return t=jD.has(t)?t:sT(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return PD(e,t,n)}build(e,t,n){AD(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){ND(e,t,n,r)}mount(e){this.isSVGTag=MD(e.tagName),super.mount(e)}},ID=jE.length;function LD(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&LD(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<ID;n++){let r=jE[n],i=e.props[r];(kE(i)||i===!1)&&(t[r]=i)}return t}function RD(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var zD=[...AE].reverse(),BD=AE.length;function VD(e){return t=>Promise.all(t.map(({animation:t,options:n})=>mT(e,t,n)))}function HD(e){let t=VD(e),n=GD(),r=!0,i=!1,a=t=>(n,r)=>{let i=Qw(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=LD(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<BD;t++){let p=zD[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=kE(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||OE(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=UD(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=eT(t)&&eT(n)?!RD(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Qw(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=jw(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Qw(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=GD(),i=!0}}}function UD(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!RD(t,e):!1}function WD(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function GD(){return{animate:WD(!0),whileInView:WD(),whileHover:WD(),whileTap:WD(),whileDrag:WD(),whileFocus:WD(),exit:WD()}}function KD(e,t){e.min=t.min,e.max=t.max}function qD(e,t){KD(e.x,t.x),KD(e.y,t.y)}function JD(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var YD=.9999,XD=1.0001,ZD=-.01,QD=.01;function $D(e){return e.max-e.min}function eO(e,t,n){return Math.abs(e-t)<=n}function tO(e,t,n,r=.5){e.origin=r,e.originPoint=NS(t.min,t.max,e.origin),e.scale=$D(n)/$D(t),e.translate=NS(n.min,n.max,e.origin)-e.originPoint,(e.scale>=YD&&e.scale<=XD||isNaN(e.scale))&&(e.scale=1),(e.translate>=ZD&&e.translate<=QD||isNaN(e.translate))&&(e.translate=0)}function nO(e,t,n,r){tO(e.x,t.x,n.x,r?r.originX:void 0),tO(e.y,t.y,n.y,r?r.originY:void 0)}function rO(e,t,n,r=0){e.min=(r?NS(n.min,n.max,r):n.min)+t.min,e.max=e.min+$D(t)}function iO(e,t,n,r){rO(e.x,t.x,n.x,r?.x),rO(e.y,t.y,n.y,r?.y)}function aO(e,t,n,r=0){let i=r?NS(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+$D(t)}function oO(e,t,n,r){aO(e.x,t.x,n.x,r?.x),aO(e.y,t.y,n.y,r?.y)}function sO(e,t,n,r,i){return e-=t,e=eD(e,1/n,r),i!==void 0&&(e=eD(e,1/i,r)),e}function cO(e,t=0,n=1,r=.5,i,a=e,o=e){if(cS.test(t)&&(t=parseFloat(t),t=NS(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=NS(a.min,a.max,r);e===a&&(s-=t),e.min=sO(e.min,t,n,s,i),e.max=sO(e.max,t,n,s,i)}function lO(e,t,[n,r,i],a,o){cO(e,t[n],t[r],t[i],t.scale,a,o)}var uO=[`x`,`scaleX`,`originX`],dO=[`y`,`scaleY`,`originY`];function fO(e,t,n,r){lO(e.x,t,uO,n?n.x:void 0,r?r.x:void 0),lO(e.y,t,dO,n?n.y:void 0,r?r.y:void 0)}function pO(e){return e.translate===0&&e.scale===1}function mO(e){return pO(e.x)&&pO(e.y)}function hO(e,t){return e.min===t.min&&e.max===t.max}function gO(e,t){return hO(e.x,t.x)&&hO(e.y,t.y)}function _O(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function vO(e,t){return _O(e.x,t.x)&&_O(e.y,t.y)}function yO(e){return $D(e.x)/$D(e.y)}function bO(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function xO(e){return[e(`x`),e(`y`)]}function SO(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var CO=PT.length,wO=e=>typeof e==`string`?parseFloat(e):e,TO=e=>typeof e==`number`||W.test(e);function EO(e,t,n,r,i,a){i?(e.opacity=NS(0,n.opacity??1,OO(r)),e.opacityExit=NS(t.opacity??1,0,kO(r))):a&&(e.opacity=NS(t.opacity??1,n.opacity??1,r));for(let i=0;i<CO;i++){let a=PT[i],o=DO(t,a),s=DO(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||TO(o)===TO(s)?(e[a]=Math.max(NS(wO(o),wO(s),r),0),(cS.test(s)||cS.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=NS(t.rotate||0,n.rotate||0,r))}function DO(e,t){return e[t]===void 0?e.borderRadius:e[t]}var OO=AO(0,.5,yx),kO=AO(.5,.95,ex);function AO(e,t,n){return r=>r<e?0:r>t?1:n(nx(e,t,r))}function jO(e,t,n){let r=iT(e)?e:Iw(e);return r.start(Kw(``,r,t,n)),r.animation}function MO(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var NO=(e,t)=>e.depth-t.depth,PO=class{constructor(){this.children=[],this.isDirty=!1}add(e){Kb(this.children,e),this.isDirty=!0}remove(e){qb(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(NO),this.isDirty=!1,this.children.forEach(e)}};function FO(e,t){let n=zx.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Px(r),e(a-t))};return Nx.setup(r,!0),()=>Px(r)}function IO(e){return iT(e)?e.get():e}var LO=class{constructor(){this.members=[]}add(e){Kb(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(qb(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(qb(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},RO={hasAnimatedSinceResize:!0,hasEverUpdated:!1},zO={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},BO=[``,`X`,`Y`,`Z`],VO=1e3,HO=0;function UO(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function WO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=lT(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Nx,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&WO(r)}function GO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=HO++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,yE.value&&(zO.nodes=zO.calculatedTargetDeltas=zO.calculatedProjections=0),this.nodes.forEach(JO),this.nodes.forEach(rk),this.nodes.forEach(ik),this.nodes.forEach(YO),yE.addProjectionMetrics&&yE.addProjectionMetrics(zO)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new PO)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new rx),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=iE(t)&&!bE(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Nx.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=FO(i,250),RO.hasAnimatedSinceResize&&(RO.hasAnimatedSinceResize=!1,this.nodes.forEach(nk)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||dk,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!vO(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Rw(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||nk(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Px(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ak),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&WO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(QO),this.nodes.forEach(ZO);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach($O);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ek),this.nodes.forEach(tk),this.nodes.forEach(KO),this.nodes.forEach(qO)):this.nodes.forEach($O),this.clearAllSnapshots();let e=zx.now();Fx.delta=Jb(0,1e3/60,e-Fx.timestamp),Fx.timestamp=e,Fx.isProcessing=!0,Ix.update.process(Fx),Ix.preRender.process(Fx),Ix.render.process(Fx),Fx.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,RT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(XO),this.sharedNodes.forEach(ok)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Nx.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Nx.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!$D(this.snapshot.measuredBox.x)&&!$D(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=EE(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!mO(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||ZE(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),hk(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return EE();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(_k))){let{scroll:e}=this.root;e&&(sD(t.x,e.offset.x),sD(t.y,e.offset.y))}return t}removeElementScroll(e){let t=EE();if(qD(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&qD(t,e),sD(t.x,i.offset.x),sD(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||EE();qD(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(sD(r.x,-n.scroll.offset.x),sD(r.y,-n.scroll.offset.y)),ZE(n.latestValues)&&uD(r,n.latestValues,n.layout?.layoutBox)}return ZE(this.latestValues)&&uD(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=EE();qD(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!ZE(n.latestValues))continue;let r;n.instance&&(XE(n.latestValues)&&n.updateSnapshot(),r=EE(),qD(r,n.measurePageBox())),fO(t,n.latestValues,n.snapshot?.layoutBox,r)}return ZE(this.latestValues)&&fO(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Fx.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Fx.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=EE(),this.targetWithTransforms=EE()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),iO(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):qD(this.target,this.layout.layoutBox),rD(this.target,this.targetDelta)):qD(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),yE.value&&zO.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||XE(this.parent.latestValues)||QE(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=EE(),this.relativeTargetOrigin=EE(),oO(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),qD(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Fx.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;qD(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;oD(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=EE());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(JD(this.prevProjectionDelta.x,this.projectionDelta.x),JD(this.prevProjectionDelta.y,this.projectionDelta.y)),nO(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!bO(this.projectionDelta.x,this.prevProjectionDelta.x)||!bO(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),yE.value&&zO.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=wE(),this.projectionDelta=wE(),this.projectionDeltaWithTransform=wE()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=wE();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=EE(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(uk));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=NS(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=NS(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(sk(o.x,e.x,n),sk(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(oO(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),lk(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&gO(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=EE(),qD(f,this.relativeTarget)),c&&(this.animationValues=a,EO(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Px(this.pendingAnimation),void 0),this.pendingAnimation=Nx.update(()=>{RO.hasAnimatedSinceResize=!0,this.motionValue||=Iw(0),this.motionValue.jump(0,!1),this.currentAnimation=jO(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(VO),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&gk(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||EE();let t=$D(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=$D(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}qD(t,n),uD(t,i),nO(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new LO),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&UO(`z`,e,r,this.animationValues);for(let t=0;t<BO.length;t++)UO(`rotate${BO[t]}`,e,r,this.animationValues),UO(`skew${BO[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=IO(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=IO(t?.pointerEvents)||``),this.hasProjected&&!ZE(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=SO(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in xD){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=xD[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?IO(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(ZO),this.root.sharedNodes.clear()}}}function KO(e){e.updateLayout()}function qO(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)xO(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=$D(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;KD(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else gk(i,t.layoutBox,n)&&xO(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=$D(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=wE();nO(o,n,t.layoutBox);let s=wE();a?nO(s,e.applyTransform(r,!0),t.measuredBox):nO(s,n,t.layoutBox);let c=!mO(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=EE();oO(s,t.layoutBox,i.layoutBox,o);let c=EE();oO(c,n,a.layoutBox,o),vO(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function JO(e){yE.value&&zO.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function YO(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function XO(e){e.clearSnapshot()}function ZO(e){e.clearMeasurements()}function QO(e){e.isLayoutDirty=!0,e.updateLayout()}function $O(e){e.isLayoutDirty=!1}function ek(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function tk(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function nk(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function rk(e){e.resolveTargetDelta()}function ik(e){e.calcProjection()}function ak(e){e.resetSkewAndRotation()}function ok(e){e.removeLeadSnapshot()}function sk(e,t,n){e.translate=NS(t.translate,0,n),e.scale=NS(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ck(e,t,n,r){e.min=NS(t.min,n.min,r),e.max=NS(t.max,n.max,r)}function lk(e,t,n,r){ck(e.x,t.x,n.x,r),ck(e.y,t.y,n.y,r)}function uk(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var dk={duration:.45,ease:[.4,0,.1,1]},fk=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),pk=fk(`applewebkit/`)&&!fk(`chrome/`)?Math.round:ex;function mk(e){e.min=pk(e.min),e.max=pk(e.max)}function hk(e){mk(e.x),mk(e.y)}function gk(e,t,n){return e===`position`||e===`preserve-aspect`&&!eO(yO(t),yO(n),.2)}function _k(e){return e!==e.root&&e.scroll?.wasRoot}var vk=GO({attachResizeListener:(e,t)=>MO(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),yk={current:void 0},bk=GO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!yk.current){let e=new vk({});e.mount(window),e.setOptions({layoutScroll:!0}),yk.current=e}return yk.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),xk=(0,R.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Sk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Ck(...e){return t=>{let n=!1,r=e.map(e=>{let r=Sk(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Sk(e[t],null)}}}}function wk(...e){return R.useCallback(Ck(...e),e)}var Tk=class extends R.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(LT(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=LT(e)&&e.offsetWidth||0,r=LT(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Ek({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,R.useId)(),s=(0,R.useRef)(null),c=(0,R.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,R.useContext)(xk),u=wk(s,e.props?.ref??e?.ref);return(0,R.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
170
|
+
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Cg(e,t){let n={type:`object`,additionalProperties:Gg(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=gg(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=ag(e.keyType._def,t);return{...n,propertyNames:i}}return n}function mee(e,t){return t.mapStrategy===`record`?Cg(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Gg(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||ig(),Gg(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||ig()],minItems:2,maxItems:2}}}function wg(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function Tg(){return{not:ig()}}function Eg(){return{type:`null`}}var Dg={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Og(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Dg&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Dg[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return kg(e,t)}var kg=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Gg(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Ag(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Dg[e.innerType._def.typeName],`null`]};let n=Gg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function jg(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function Mg(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Pg(a),s=Gg(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=Ng(e,t);return a!==void 0&&(n.additionalProperties=a),n}function Ng(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Gg(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Pg(e){try{return e.isOptional()}catch{return!0}}var Fg=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Gg(e.innerType._def,t);let n=Gg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:ig()},n]}:ig()},Ig=(e,t)=>{if(t.pipeStrategy===`input`)return Gg(e.in._def,t);if(t.pipeStrategy===`output`)return Gg(e.out._def,t);let n=Gg(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Gg(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Lg(e,t){return Gg(e.type._def,t)}function Rg(e,t){let n={type:`array`,uniqueItems:!0,items:Gg(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function zg(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Gg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Gg(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Gg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Bg(){return{not:ig()}}function Vg(){return ig()}var Hg=(e,t)=>Gg(e.innerType._def,t),Ug=(e,t,n)=>{switch(t){case`ZodString`:return gg(e,n);case`ZodNumber`:return jg(e);case`ZodObject`:return Mg(e,n);case`ZodBigInt`:return dee(e);case`ZodBoolean`:return fee();case`ZodDate`:return og(e,n);case`ZodUndefined`:return Bg();case`ZodNull`:return Eg();case`ZodArray`:return uee(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return Og(e,n);case`ZodIntersection`:return fg(e,n);case`ZodTuple`:return zg(e,n);case`ZodRecord`:return Cg(e,n);case`ZodLiteral`:return pg(e);case`ZodEnum`:return ug(e);case`ZodNativeEnum`:return wg(e);case`ZodNullable`:return Ag(e,n);case`ZodOptional`:return Fg(e,n);case`ZodMap`:return mee(e,n);case`ZodSet`:return Rg(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Lg(e,n);case`ZodNaN`:case`ZodNever`:return Tg();case`ZodEffects`:return lg(e,n);case`ZodAny`:return ig();case`ZodUnknown`:return Vg();case`ZodDefault`:return cg(e,n);case`ZodBranded`:return ag(e,n);case`ZodReadonly`:return Hg(e,n);case`ZodCatch`:return pee(e,n);case`ZodPipeline`:return Ig(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},Wg=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function Gg(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==cee)return i}if(r&&!n){let e=Kg(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Ug(e,e.typeName,t),o=typeof a==`function`?Gg(a(),t):a;if(o&&qg(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Kg=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Wg(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),ig()):t.$refStrategy===`seen`?ig():void 0}},qg=(e,t,n)=>(e.description&&(n.description=e.description),n),Jg=e=>{let t=lee(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Yg=(e,t)=>{let n=Jg(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Gg(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??ig()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Gg(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??ig(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},Xg=Symbol.for(`vercel.ai.schema`);function Zg(e){let t;return()=>(t??=e(),t)}function Qg(e,{validate:t}={}){return{[Xg]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function $g(e){return typeof e==`object`&&!!e&&Xg in e&&e[Xg]===!0&&`jsonSchema`in e&&`validate`in e}function e_(e){return e==null?Qg({type:`object`,properties:{},additionalProperties:!1}):$g(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?o_(e):t_(e):e()}function t_(e){return Qg(()=>{if(!n_(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return tg(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return n.issues===void 0&&`value`in n?{success:!0,value:n.value}:{success:!1,error:new jh({value:t,cause:n.issues})}}})}function n_(e){return e[`~standard`].jsonSchema!=null}function r_(e,t){let n=t?.useReferences??!1;return Qg(()=>Yg(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function i_(e,t){Lt().localeError||Lt(pe());let n=t?.useReferences??!1;return Qg(()=>tg(Le(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await Oe(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function a_(e){return`_zod`in e}function o_(e,t){return a_(e)?i_(e,t):r_(e,t)}async function s_({value:e,schema:t,context:n}){let r=await c_({value:e,schema:t,context:n});if(!r.success)throw jh.wrap({value:e,cause:r.error,context:n});return r.value}async function c_({value:e,schema:t,context:n}){let r=e_(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:jh.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:jh.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function l_({text:e,schema:t}){try{let n=see(e);return t==null?{success:!0,value:n,rawValue:n}:await c_({value:n,schema:t})}catch(t){return{success:!1,error:Dh.isInstance(t)?t:new Dh({text:e,cause:t}),rawValue:void 0}}}function u_({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Wh).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await l_({text:e,schema:t}))}}))}async function d_(e){return typeof e==`function`&&(e=e()),e}new TextDecoder;var f_=tr(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);Qn.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){nt(this,`with`,e)},parse(e,t){return Ln(this,e,t,{callee:this.parse})},parseAsync(e,t){return wn(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return on(this,e,t)},safeParseAsync(e,t){return tn(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return lr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),p_=tr(`ZodMiniString`,(e,t)=>{Bt.init(e,t),f_.init(e,t)});function m_(e){return ve(p_,e)}var h_=tr(`ZodMiniNumber`,(e,t)=>{kn.init(e,t),f_.init(e,t)});function g_(e){return oe(h_,e)}var __=tr(`ZodMiniNumberFormat`,(e,t)=>{Wn.init(e,t),h_.init(e,t)});function v_(e){return xe(__,e)}var y_=tr(`ZodMiniBoolean`,(e,t)=>{gt.init(e,t),f_.init(e,t)});function b_(e){return te(y_,e)}var x_=tr(`ZodMiniUnknown`,(e,t)=>{Xt.init(e,t),f_.init(e,t)});function S_(){return Rn(x_)}var C_=tr(`ZodMiniNever`,(e,t)=>{Xn.init(e,t),f_.init(e,t)});function w_(e){return _(C_,e)}var T_=tr(`ZodMiniArray`,(e,t)=>{vt.init(e,t),f_.init(e,t)});function E_(e,t){return new T_({type:`array`,element:e,...ar(t)})}var D_=tr(`ZodMiniObject`,(e,t)=>{fn.init(e,t),f_.init(e,t),S(e,`shape`,e=>e._zod.def.shape,!1)});function O_(e,t){return new D_({type:`object`,shape:e??{},...ar(t)})}function k_(e,t){return new D_({type:`object`,shape:e,catchall:S_(),...ar(t)})}function A_(e,t){return Qe(e,t)}var j_=tr(`ZodMiniUnion`,(e,t)=>{Ht.init(e,t),f_.init(e,t)});function M_(e,t){return new j_({type:`union`,options:e,...ar(t)})}var N_=tr(`ZodMiniDiscriminatedUnion`,(e,t)=>{Ve.init(e,t),f_.init(e,t)});function P_(e,t,n){return new N_({type:`union`,options:t,discriminator:e,...ar(n)})}var F_=tr(`ZodMiniRecord`,(e,t)=>{Kn.init(e,t),f_.init(e,t)});function I_(e,t,n){return!t||!t._zod?new F_({type:`record`,keyType:m_(),valueType:e,...ar(t)}):new F_({type:`record`,keyType:e,valueType:t,...ar(n)})}var L_=tr(`ZodMiniEnum`,(e,t)=>{u.init(e,t),f_.init(e,t),e.options=[...e._zod.values]});function R_(e,t){return new L_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ar(t)})}var z_=tr(`ZodMiniLiteral`,(e,t)=>{qt.init(e,t),f_.init(e,t)});function B_(e,t){return new z_({type:`literal`,values:Array.isArray(e)?e:[e],...ar(t)})}var V_=tr(`ZodMiniTransform`,(e,t)=>{yn.init(e,t),f_.init(e,t)});function H_(e){return new V_({type:`transform`,transform:e})}var U_=tr(`ZodMiniOptional`,(e,t)=>{Mt.init(e,t),f_.init(e,t)});function W_(e){return new U_({type:`optional`,innerType:e})}var G_=tr(`ZodMiniPipe`,(e,t)=>{Mn.init(e,t),f_.init(e,t)});function K_(e,t){return new G_({type:`pipe`,in:e,out:t})}var q_=tr(`ZodMiniCustom`,(e,t)=>{St.init(e,t),f_.init(e,t)});function J_(e,t){return le(q_,e??(()=>!0),t)}function Y_(e,t={}){return pt(q_,e,t)}var X_=`AI_InvalidArgumentError`,Z_=`vercel.ai.error.${X_}`,Q_=Symbol.for(Z_),$_=class extends uh{constructor({parameter:e,value:t,message:n}){super({name:X_,message:`Invalid argument for parameter ${e}: ${n}`}),this[Q_]=!0,this.parameter=e,this.value=t}static isInstance(e){return uh.hasMarker(e,Z_)}},ev=new Map([[`generateObject`,`AISDK_DEP_GENERATE_OBJECT`],[`streamObject`,`AISDK_DEP_STREAM_OBJECT`],[`experimental_generateSpeech`,`AISDK_DEP_EXPERIMENTAL_GENERATE_SPEECH`],[`experimental_transcribe`,`AISDK_DEP_EXPERIMENTAL_TRANSCRIBE`],[`"image" content part`,`AISDK_DEP_IMAGE_CONTENT_PART`],[`"tool-result" content of type "file-data"`,`AISDK_DEP_TOOL_RESULT_FILE_DATA`],[`"tool-result" content of type "file-url"`,`AISDK_DEP_TOOL_RESULT_FILE_URL`],[`"tool-result" content of type "file-id"`,`AISDK_DEP_TOOL_RESULT_FILE_ID`],[`"tool-result" content of type "file-reference"`,`AISDK_DEP_TOOL_RESULT_FILE_REFERENCE`],[`"tool-result" content of type "image-data"`,`AISDK_DEP_TOOL_RESULT_IMAGE_DATA`],[`"tool-result" content of type "image-url"`,`AISDK_DEP_TOOL_RESULT_IMAGE_URL`],[`"tool-result" content of type "image-file-id"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_ID`],[`"tool-result" content of type "image-file-reference"`,`AISDK_DEP_TOOL_RESULT_IMAGE_FILE_REFERENCE`],[`rawInput in output-error UI message parts`,`AISDK_DEP_UI_MESSAGE_RAW_INPUT`]]);function tv(e){return e.replace(/[^a-zA-Z0-9]/g,e=>`_${e.charCodeAt(0).toString(16).toUpperCase().padStart(4,`0`)}`)}function nv({setting:e,provider:t}){return t==null?ev.get(e)??`AISDK_DEP_SETTING_${tv(e)}`:`AISDK_DEP_PROVIDER_${tv(t)}__${tv(e)}`}function rv({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var iv=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,av=!1,ov=new Set;function sv({message:e,type:t,code:n}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,n==null?{type:t}:{type:t,code:n}):console.warn(n==null?e:`[${n}] ${e}`)}var cv=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}av||(av=!0,sv({message:iv,type:`Warning`}));for(let t of e.warnings){let n=t.type===`deprecated`?nv({setting:t.setting,provider:e.provider}):void 0;if(n!=null){if(ov.has(n))continue;ov.add(n)}sv({message:rv({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`,code:n})}}};function lv(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=lv(a,i):n[r]=i}return n}function uv(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function dv(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(typeof e!=`object`&&typeof t!=`object`)return e===t;if(e.constructor!==t.constructor)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!dv(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!dv(e[i],t[i]))return!1;return!0}new TextEncoder,new TextEncoder;var fv=`AI_UIMessageStreamError`,pv=`vercel.ai.error.${fv}`,mv=Symbol.for(pv),hv=class extends uh{constructor({chunkType:e,chunkId:t,message:n}){super({name:fv,message:n}),this[mv]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return uh.hasMarker(e,pv)}};function gv(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);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`);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`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`)}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`)}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`)}break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;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`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function _v(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await l_({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await l_({text:gv(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}Xh({prefix:`steer`,size:24}),Xh({prefix:`aitxt`,size:24}),Xh({prefix:`call`,size:24}),TransformStream;var V={NEVER:pr,array:E_,boolean:b_,custom:J_,discriminatedUnion:P_,enum:R_,extend:A_,int:v_,literal:B_,looseObject:k_,maximum:Ge,minLength:mr,never:w_,nonnegative:ct,number:g_,object:O_,optional:W_,pipe:K_,positive:rt,record:I_,refine:Y_,safeParse:on,startsWith:re,string:m_,transform:H_,union:M_,unknown:S_},H={array:Zt,boolean:Dt,custom:$n,discriminatedUnion:ur,instanceof:bn,lazy:or,literal:Ye,null:nn,number:nr,object:F,record:C,string:L,union:p,unknown:pn},vv=H.lazy(()=>H.union([H.null(),H.string(),H.number(),H.boolean(),H.record(H.string(),vv.optional()),H.array(vv)])),U=H.record(H.string(),H.record(H.string(),vv.optional()));function yv(e){return V.object({source:V.discriminatedUnion(`sourceType`,[V.object({type:V.literal(`source`),sourceType:V.literal(`url`),id:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(e)}),V.object({type:V.literal(`source`),sourceType:V.literal(`document`),id:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(e)})]),startIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),endIndex:V.optional(V.number().check(V.int()).check(V.nonnegative())),citedText:V.optional(V.string())})}var bv=yv(U),xv=V.record(V.string(),V.optional(vv)),Sv=Zg(()=>o_(V.union([V.looseObject({type:V.literal(`text-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`text-end`),id:V.string(),citations:V.optional(V.array(bv)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`error`),errorText:V.string()}),V.looseObject({type:V.literal(`tool-input-start`),toolCallId:V.string(),toolName:V.string(),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-delta`),toolCallId:V.string(),inputTextDelta:V.string()}),V.looseObject({type:V.literal(`tool-input-available`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-input-error`),toolCallId:V.string(),toolName:V.string(),input:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),errorText:V.string(),title:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-request`),approvalId:V.string(),toolCallId:V.string(),approvalDescriptor:V.optional(V.unknown()),inputSchemaInput:V.optional(V.unknown()),reason:V.optional(V.string()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string())}),V.looseObject({type:V.literal(`tool-approval-response`),approvalId:V.string(),approved:V.boolean(),reason:V.optional(V.string()),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`tool-output-available`),toolCallId:V.string(),output:V.unknown(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean()),preliminary:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-error`),toolCallId:V.string(),errorText:V.string(),providerExecuted:V.optional(V.boolean()),providerMetadata:V.optional(U),toolMetadata:V.optional(xv),dynamic:V.optional(V.boolean())}),V.looseObject({type:V.literal(`tool-output-denied`),toolCallId:V.string()}),V.looseObject({type:V.literal(`reasoning-start`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-delta`),id:V.string(),delta:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-end`),id:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`custom`),kind:V.pipe(V.string(),V.transform(e=>e)),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`reasoning-file`),url:V.string(),mediaType:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`steering-message`),id:V.string(),parts:V.array(V.union([V.looseObject({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(U)}),V.looseObject({type:V.literal(`file`),mediaType:V.string(),url:V.string(),filename:V.optional(V.string()),providerReference:V.optional(V.record(V.string(),V.string())),providerMetadata:V.optional(U)})]))}),V.looseObject({type:V.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:V.optional(V.string()),data:V.unknown(),transient:V.optional(V.boolean())}),V.looseObject({type:V.literal(`start-step`)}),V.looseObject({type:V.literal(`finish-step`)}),V.looseObject({type:V.literal(`reset-step`)}),V.looseObject({type:V.literal(`start`),messageId:V.optional(V.string()),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`finish`),finishReason:V.optional(V.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`interrupted`,`other`])),messageMetadata:V.optional(V.unknown())}),V.looseObject({type:V.literal(`abort`),reason:V.optional(V.string())}),V.looseObject({type:V.literal(`message-metadata`),messageMetadata:V.unknown()})])));function Cv(e){return e.type.startsWith(`data-`)}function wv(){return Object.create(null)}function Tv(e){return e.type===`text`}function Ev(e){return e.type===`reasoning`}function Dv(e){return e.type.startsWith(`tool-`)}function Ov(e){return e.type===`dynamic-tool`}function kv(e){return Dv(e)||Ov(e)}function Av(e){return e.type.split(`-`).slice(1).join(`-`)}function jv(e){return Ov(e)?e.toolName:Av(e)}function Mv({lastMessage:e,messageId:t}){let n=e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},r=wv(),i=n.parts.findLastIndex(e=>e.type===`step-start`),a=0;for(let e of n.parts.slice(i+1)){if(!kv(e))continue;let t=a;Dv(e)&&a++,e.state===`input-streaming`&&(r[e.toolCallId]={text:e.rawInput??``,inputEncoding:e.inputEncoding,index:t,toolName:e.type===`dynamic-tool`?e.toolName:Av(e),dynamic:e.type===`dynamic-tool`,title:e.title,toolMetadata:e.toolMetadata})}return{message:n,activeTextParts:wv(),activeReasoningParts:wv(),partialToolCalls:r}}function Nv({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o,resetStateOnMessageIdChange:s=!1,resetStateOnFirstMessageStart:c=!1}){let l=!0;return e.pipeThrough(new TransformStream({async transform(e,u){await r(async({state:r,write:d})=>{function f(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function p(){return f().filter(kv)}function m(e){let t=p().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(kv(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new hv({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function h(e){let t=r.message.parts.filter(kv).find(t=>t.approval?.id===e);if(t==null)throw new hv({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function g(e,t){let n=t??f().find(t=>Dv(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.type=`tool-${e.toolName}`,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}function _(e,t){let n=t??f().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,i.inputEncoding==null?delete a.inputEncoding:a.inputEncoding=i.inputEncoding,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null)if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,...i.inputEncoding==null?{}:{inputEncoding:i.inputEncoding},output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:i.providerMetadata}:{}})}async function v(e){if(e!=null){let n=r.message.metadata==null?e:lv(r.message.metadata,e);t!=null&&await s_({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),d();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new hv({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new hv({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,e.citations!=null&&(t.citations=e.citations),t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],d();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),d();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),d();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new hv({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new hv({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],d();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),d();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),d();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),d();break;case`tool-input-start`:{let t=f().filter(Dv);r.partialToolCalls[e.toolCallId]={text:``,inputEncoding:e.inputEncoding,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),d();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new hv({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let n=t.inputEncoding===`text`?t.text:(await _v(t.text)).value;t.dynamic?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}):g({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,inputEncoding:t.inputEncoding,input:n,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}),d();break}case`tool-input-available`:e.dynamic?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),d(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=f().filter(kv).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?_({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):g({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),d();break}case`tool-approval-request`:{let t=m(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...Object.prototype.hasOwnProperty.call(e,`inputSchemaInput`)?{inputSchemaInput:e.inputSchemaInput}:{},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},d();break}case`tool-approval-response`:{let t=h(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),d();break}case`tool-output-denied`:{let t=m(e.toolCallId);t.state=`output-denied`,d();break}case`tool-output-available`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Av(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`tool-output-error`:{let t=m(e.toolCallId);t.type===`dynamic-tool`?_({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):g({toolCallId:e.toolCallId,toolName:Av(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case`steering-message`:r.message.parts.push({type:`steering-message`,id:e.id,parts:e.parts}),d();break;case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=f();r.activeTextParts=wv(),r.activeReasoningParts=wv(),r.partialToolCalls=wv(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),d());break}case`start`:{let t=c&&l||s&&e.messageId!=null&&e.messageId!==r.message.id;l=!1,t&&Object.assign(r,Mv({lastMessage:void 0,messageId:e.messageId??r.message.id}),{finishReason:void 0}),e.messageId!=null&&(r.message.id=e.messageId),await v(e.messageMetadata),(t||e.messageId!=null||e.messageMetadata!=null)&&d({updateStatus:!1});break}case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`message-metadata`:await v(e.messageMetadata),e.messageMetadata!=null&&d();break;case`error`:i?.(Error(e.errorText));break;default:if(Cv(e)){let t=n?.[e.type.slice(5)];if(t!=null){let n=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=n>=0?n:r.message.parts.length;await s_({value:e.data,schema:t,context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let i=e;if(i.transient){o?.(i);break}let a=i.id==null?void 0:r.message.parts.find(e=>i.type===e.type&&i.id===e.id);a==null?r.message.parts.push(i):a.data=i.data,o?.(i),d()}}u.enqueue(e)})}}))}async function Pv({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function Fv(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}Xh({prefix:`aitxt`,size:24}),Xh({prefix:`call`,size:24}),Xh({prefix:`aitxt`,size:24}),Xh({prefix:`call`,size:24});function Iv(e){return e.dynamic=!1,e}var Lv={type:`deprecated`,setting:`rawInput in output-error UI message parts`,message:`Use the "input" field instead. The "rawInput" field will be removed in the next major version.`};function Rv(e){e.some(e=>e.parts.some(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&(e.type===`dynamic-tool`||e.type.startsWith(`tool-`))&&`state`in e&&e.state===`output-error`&&Object.prototype.hasOwnProperty.call(e,`rawInput`)&&`rawInput`in e&&e.rawInput!==void 0))&&cv({warnings:[Lv]})}var zv=Symbol(`invalid`);function Bv(e){let t=[],n=Vv(e,t,new Set);return n===zv?{success:!1,path:t}:{success:!0,value:n}}function Vv(e,t,n){switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:zv;case`object`:{if(e===null)return e;if(n.has(e))return zv;n.add(e);let r=Array.isArray(e)?Hv(e,t,n):Uv(e,t,n);return n.delete(e),r}default:return zv}}function Hv(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];t.push(i);let o=Vv(a,t,n);if(o===zv)return zv;t.pop(),r==null?o!==a&&(r=e.slice(0,i),r.push(o)):r.push(o)}return r??e}function Uv(e,t,n){if(!Gv(e)||Kv(e))return zv;let r=Object.keys(e),i;for(let a=0;a<r.length;a++){let o=r[a];if(o===`__proto__`){i??=Wv(e,r,a);continue}let s=e[o],c=s;if(s!==void 0){if(t.push(o),c=Vv(s,t,n),c===zv)return zv;t.pop()}i==null?c!==s&&(i=Wv(e,r,a),i[o]=c):i[o]=c}return i??e}function Wv(e,t,n){let r={};for(let i=0;i<n;i++)r[t[i]]=e[t[i]];return r}function Gv(e){let t=e.constructor;if(typeof t!=`function`)return!0;let n=t.prototype;return typeof n==`object`&&!!n&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)}function Kv(e){let t=Object.getOwnPropertySymbols(e);for(let n=0;n<t.length;n++)if(Object.prototype.propertyIsEnumerable.call(e,t[n]))return!0;return!1}var qv=V.pipe(V.unknown(),V.transform((e,t)=>{let n=Bv(e);return n.success?n.value:(t.issues.push({code:`custom`,message:`Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.`,input:e,path:n.path}),V.NEVER)})),Jv=V.custom(),Yv=V.pipe(qv,V.record(V.string(),Jv)),Xv=V.pipe(qv,V.record(V.string(),V.record(V.string(),Jv))),Zv=V.record(V.string(),V.string()),Qv=yv(Xv);function $v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function ey(e){let{type:t,...n}=e;return Iv({...n,type:`dynamic-tool`,toolName:t.slice(5)})}function ty(e){return e.approval!=null&&Object.prototype.hasOwnProperty.call(e.approval,`inputSchemaInput`)?{value:e.approval.inputSchemaInput}:void 0}function ny(e){return V.pipe(V.array(V.unknown()),V.transform((t,n)=>{let r=[];for(let[i,a]of t.entries()){let t=V.safeParse(e(a),a);if(!t.success){for(let e of t.error.issues)n.issues.push({...e,path:[i,...e.path]});return V.NEVER}r.push(t.data)}return r}))}var ry=Zg(()=>{let e=V.object({id:V.string(),approved:V.optional(V.never()),descriptor:V.optional(V.unknown()),requestReason:V.optional(V.string()),reason:V.optional(V.never()),isAutomatic:V.optional(V.boolean()),signature:V.optional(V.string()),inputSchemaInput:V.optional(V.unknown())}),t=V.extend(e,{approved:V.boolean(),reason:V.optional(V.string())}),n=V.extend(t,{approved:V.literal(!0)}),r=V.extend(t,{approved:V.literal(!1)}),i=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(Zv),providerMetadata:V.optional(Xv)})]),a=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),citations:V.optional(ny(()=>Qv)),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`reasoning`),id:V.optional(V.string()),text:V.string(),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`custom`),kind:V.string(),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(Zv),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`reasoning-file`),mediaType:V.string(),url:V.string(),providerMetadata:V.optional(Xv)}),V.object({type:V.literal(`steering-message`),id:V.string(),parts:ny(()=>i)}),V.object({type:V.literal(`step-start`)})],{error:e=>e.code===`invalid_union`?`Invalid UI message part type. Expected a known part type (for example "text" or "dynamic-tool") or a type starting with "data-" or "tool-".`:void 0}),o=V.object({type:V.string().check(V.startsWith(`data-`)),id:V.optional(V.string()),data:V.unknown()}),s=V.discriminatedUnion(`state`,[V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-streaming`),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Xv),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:V.optional(V.never())}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:e}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:t}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-error`),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),approval:V.optional(n)}),V.object({type:V.literal(`dynamic-tool`),dynamic:V.optional(V.literal(!1)),toolName:V.string(),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-denied`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:r})]),c=V.discriminatedUnion(`state`,[V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-streaming`),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Xv),input:V.optional(V.unknown()),rawInput:V.optional(V.string()),inputEncoding:V.optional(V.enum([`json`,`text`])),output:V.optional(V.never()),errorText:V.optional(V.never()),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`input-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:V.optional(V.never())}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-requested`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:e}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`approval-responded`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:t}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),preliminary:V.optional(V.boolean()),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-error`),providerExecuted:V.optional(V.boolean()),input:V.optional(V.unknown()),rawInput:V.optional(V.unknown()),output:V.optional(V.never()),errorText:V.string(),callProviderMetadata:V.optional(Xv),resultProviderMetadata:V.optional(Xv),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(Yv),state:V.literal(`output-denied`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.optional(V.never()),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Xv),approval:r})]),l=V.object({id:V.string(),role:V.enum([`system`,`user`,`assistant`]),metadata:V.optional(V.unknown()),parts:ny(e=>{let t=e?.type;if(typeof t==`string`){if(t.startsWith(`data-`))return o;if(t.startsWith(`tool-`))return c;if(t===`dynamic-tool`)return s}return a})}).check(e=>{let t=e.value;t.role!==`assistant`&&t.parts.length===0&&e.issues.push({continue:!0,origin:`array`,code:`too_small`,minimum:1,inclusive:!0,input:t.parts,path:[`parts`],message:`Message must contain at least one part`})});return o_(ny(()=>l).check(V.minLength(1,`Messages array must not be empty`)))});async function iy({messages:e,metadataSchema:t,dataSchemas:n,tools:r,experimental_refineToolInput:i},{convertMissingTerminalToolsToDynamic:a}){try{if(e==null)return{success:!1,error:new $_({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let o=await s_({value:e,schema:ry});if(Rv(o),t)for(let[e,n]of o.entries())n.metadata=await s_({value:n.metadata,schema:t,context:{field:`messages[${e}].metadata`,entityId:n.id}});let s=r!=null||a;if(n||s)for(let[e,t]of o.entries())for(let[o,c]of t.parts.entries()){if(n&&c.type.startsWith(`data-`)){let t=c,r=t.type.slice(5),i=n[r];if(!i)return{success:!1,error:new jh({value:t.data,cause:`No data schema found for data part ${r}`,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})};t.data=await s_({value:t.data,schema:i,context:{field:`messages[${e}].parts[${o}].data`,entityName:r,entityId:t.id}})}if(s&&c.type.startsWith(`tool-`)){let n=c,s=n.type.slice(5),l=r==null?void 0:uv(r,s),u=n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`;if(!l&&u){(r!=null||a)&&(t.parts[o]=ey(n));continue}if(!l)return{success:!1,error:new jh({value:n.input,cause:`No tool schema found for tool part ${s}`,context:{field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId}})};let d={field:`messages[${e}].parts[${o}].input`,entityName:s,entityId:n.toolCallId},f=ty(n),p=f==null?n.input:f.value,m=!1;if(n.state!==`input-streaming`&&(n.state!==`output-error`||f!=null||n.input!==void 0)){let e=await c_({value:p,schema:l.inputSchema,context:d}),t;if(!e.success)t=e.error;else if(f!=null)try{let r=uv(i,s);dv(r==null?e.value:await r(e.value),n.input)||(t=new jh({value:n.input,cause:`Tool input does not match the output reconstructed from inputSchemaInput.`,context:d}))}catch(e){t=new jh({value:p,cause:e,context:d})}if(t!=null)if(n.state===`output-error`||n.state===`output-available`&&$v(n.input))m=!0;else throw t}n.state===`output-available`&&l.outputSchema&&await s_({value:n.output,schema:l.outputSchema,context:{field:`messages[${e}].parts[${o}].output`,entityName:s,entityId:n.toolCallId}}),m&&(t.parts[o]=ey(n))}}return{success:!0,data:o}}catch(e){return{success:!1,error:e}}}async function ay(e){return iy(e,{convertMissingTerminalToolsToDynamic:!1})}async function oy(e){let t=await ay(e);if(!t.success)throw t.error;return t.data}Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24}),new TextEncoder,Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24}),Xh({prefix:`aiobj`,size:24});var{atob:hee}=globalThis,sy=class{constructor(){this.queue=[],this.isProcessing=!1,this.idleWaiters=[]}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;this.queue.length>0;)await this.queue[0](),this.queue.shift()}finally{this.isProcessing=!1;for(let e of this.idleWaiters.splice(0))e()}}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}async waitForIdle(){!this.isProcessing&&this.queue.length===0||await new Promise(e=>{this.idleWaiters.push(e)})}};Xh({prefix:`aiobj`,size:24}),Xh({prefix:`call`,size:24});var cy=H.union([H.string(),H.custom(qh,{message:`Must be a Uint8Array`}),H.custom(Jh,{message:`Must be an ArrayBuffer`}),H.custom(Qh,{message:`Must be a Buffer`})]),ly=H.record(H.string(),H.string()),uy=H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),dy=H.object({type:H.literal(`image`),image:H.union([cy,H.instanceof(URL),ly]),mediaType:H.string().optional(),providerOptions:U.optional()}),fy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:cy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)}),H.object({type:H.literal(`reference`),reference:ly}),H.object({type:H.literal(`text`),text:H.string()})]),py=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:cy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)})]),my=H.object({type:H.literal(`file`),data:H.union([fy,cy,H.instanceof(URL),ly]),filename:H.string().optional(),mediaType:H.string(),providerOptions:U.optional()}),hy=H.object({type:H.literal(`reasoning`),text:H.string(),providerOptions:U.optional()}),gy=H.object({type:H.literal(`custom`),kind:H.string().transform(e=>e),providerOptions:U.optional()}),_y=H.object({type:H.literal(`reasoning-file`),data:H.union([py,cy,H.instanceof(URL)]),mediaType:H.string(),providerOptions:U.optional()}),vy=H.object({type:H.literal(`tool-call`),toolCallId:H.string(),toolName:H.string(),input:H.unknown(),providerOptions:U.optional(),providerExecuted:H.boolean().optional()}),gee=H.discriminatedUnion(`type`,[H.object({type:H.literal(`text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`json`),value:vv,providerOptions:U.optional()}),H.object({type:H.literal(`execution-denied`),reason:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`error-text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`error-json`),value:vv,providerOptions:U.optional()}),H.object({type:H.literal(`content`),value:H.array(H.union([H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`file`),data:fy,mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-data`),data:H.string(),mediaType:H.string(),filename:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-url`),url:H.string(),mediaType:H.string().optional(),providerOptions:U.optional()}),H.object({type:H.literal(`file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`image-data`),data:H.string(),mediaType:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-url`),url:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-id`),fileId:H.union([H.string(),H.record(H.string(),H.string())]),providerOptions:U.optional()}),H.object({type:H.literal(`image-file-reference`),providerReference:H.record(H.string(),H.string()),providerOptions:U.optional()}),H.object({type:H.literal(`custom`),providerOptions:U.optional()})]))})]),yy=H.object({type:H.literal(`tool-result`),toolCallId:H.string(),toolName:H.string(),output:gee,providerOptions:U.optional()}),by=H.object({type:H.literal(`tool-approval-request`),approvalId:H.string(),toolCallId:H.string(),reason:H.string().optional(),isAutomatic:H.boolean().optional(),signature:H.string().optional(),inputSchemaInput:H.unknown().optional()}),xy=H.object({type:H.literal(`tool-approval-response`),approvalId:H.string(),approved:H.boolean(),reason:H.string().optional()}),Sy=H.object({role:H.literal(`system`),content:H.string(),providerOptions:U.optional()}),Cy=H.object({role:H.literal(`user`),content:H.union([H.string(),H.array(H.union([uy,dy,my]))]),providerOptions:U.optional()}),wy=H.object({role:H.literal(`assistant`),content:H.union([H.string(),H.array(H.union([uy,gy,my,hy,_y,vy,yy,by]))]),providerOptions:U.optional()}),Ty=H.object({role:H.literal(`tool`),content:H.array(H.union([yy,xy])),providerOptions:U.optional()});H.union([Sy,Cy,wy,Ty]),V.object({token:V.string().check(V.refine(e=>e.trim().length>0)),url:V.string().check(V.refine(e=>{try{let t=new URL(e);return(t.protocol===`ws:`||t.protocol===`wss:`)&&t.hostname!==``}catch{return!1}})),expiresAt:V.optional(V.number().check(V.positive()).check(V.maximum(2**53-1))),tools:V.optional(V.array(V.object({type:V.literal(`function`),name:V.string().check(V.minLength(1)),description:V.optional(V.string()),parameters:V.record(V.string(),V.unknown())})))}),Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24}),Xh({prefix:`call`,size:24});async function Ey({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new mh({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function Dy(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Fh({functionality:`FileList`,message:`FileList is not supported in the current environment`});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}function Oy(e,t){let n=e.search(/[?#]/),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r.endsWith(`/`)&&t.startsWith(`/`)?r.slice(0,-1):r}${t}${i}`}var ky=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await d_(this.body),r=await d_(this.headers),i=await d_(this.credentials),a={...Yh(r),...Yh(t.headers)},o=await this.prepareSendMessagesRequest?.({api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:Yh(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"content-type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw await Ey({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new vh({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await d_(this.body),n=await d_(this.headers),r=await d_(this.credentials),i={...Yh(n),...Yh(e.headers)},a=await this.prepareReconnectToStreamRequest?.({api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api;if(o==null){if(e.chatId===`.`||e.chatId===`..`)throw new $_({parameter:`chatId`,value:e.chatId,message:`Chat IDs must not be "." or ".." when using the default reconnect URL.`});o=Oy(this.api,`/${encodeURIComponent(e.chatId)}/stream`)}let s=a?.headers===void 0?i:Yh(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw await Ey({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new vh({message:`The response body is empty.`});return this.processResponseStream(l.body)}},Ay=class extends ky{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return u_({stream:e,schema:Sv}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},jy=class{get id(){return this._id??=this.generateId()}constructor({generateId:e=Zh,id:t,transport:n=new Ay,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u,experimental_queue:d=!1}){this.queuedMessagesFallback=[],this.queuedMessageOptions=new Map,this.isQueuePaused=!1,this.pendingAutomaticDecisions=[],this.pendingMessagePreparations=new Set,this.interruptedMessageIds=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.resumableStreamState=void 0,this.jobExecutor=new sy,this.activeStopCount=0,this.stopGeneration=0,this.experimental_removeQueuedMessage=e=>{this.queuedMessageOptions.delete(e),this.setQueuedMessages(this.experimental_queuedMessages.filter(t=>t.id!==e))},this.experimental_sendQueuedMessageNow=async e=>{let t=this.experimental_queuedMessages.find(t=>t.id===e);if(t==null)return;this.setQueuedMessages([t,...this.experimental_queuedMessages.filter(t=>t.id!==e)]);let n=this.stopGeneration+1;await this.stop(),n===this.stopGeneration&&await this.resumeQueue({skipWaitForUser:!0,options:this.queuedMessageOptions.get(e)})},this.sendMessage=async(e,t)=>{if(e==null){let e=this.pendingApprovalMessageId;if(e==null){e=this.lastMessage?.id;for(let t=this.state.messages.length-1;t>=0;t--){let n=this.state.messages[t];if(n.role===`assistant`&&n.parts.some(e=>kv(e)&&e.state===`approval-responded`)){e=n.id;break}}}let n=e!=null&&e===this.pendingApprovalMessageId?this.state.messages.findIndex(t=>t.id===e):-1;await this.makeRequestForToolApproval({messageId:e,messageIndex:n,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await Dy(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(this.queueEnabled&&e.messageId==null&&(this.isRequestInProgress()||this.isWaitingForUser()||this.experimental_queuedMessages.length>0)){let r={...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata};t!=null&&this.queuedMessageOptions.set(r.id,t),this.setQueuedMessages([...this.experimental_queuedMessages,r]),await this.resumeQueue({skipWaitForUser:this.isQueuePaused,options:t});return}if(e.messageId!=null){await this.clearQueueForHistoryChange();let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw new $_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new $_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...n,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});this.isQueuePaused=!1,await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{await this.clearQueueForHistoryChange();let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw new $_({parameter:`messageId`,value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this[`~resumeStreamIfDisconnected`]=async({shouldResume:e=()=>!0}={})=>{let t=this.activeResponse;this.resumableStreamState==null&&t!=null&&(await t.completionPromise,this.resumableStreamState!==t.state)||this.resumableStreamState!=null&&e()&&await this.resumeStream()},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.stopGeneration,a=this.state.messages,o=r=>kv(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r,s=a.findIndex(t=>t.parts.some(t=>kv(t)&&t.state===`approval-requested`&&t.approval.id===e));if(s!==-1){let e=a[s];this.state.replaceMessage(s,{...e,parts:e.parts.map(o)}),this.pendingApprovalMessageId=e.id}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),s!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(a[s].id);if(e){this.runAutomaticRequest(()=>{let e=s===-1?this.lastMessage?.id:a[s].id;return this.makeRequestForToolApproval({messageId:e,messageIndex:s,...r})},e);return}}this.settleQueue({stopGeneration:i})}),this.addToolOutput=async({state:e,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.stopGeneration,o=this.state.messages,s=i=>{if(!kv(i)||i.toolCallId!==t)return i;let{approval:a,...o}=i,s=a?.approved===!0?{approval:{...a,approved:a.approved}}:{};return e===`output-error`?{...o,...s,state:e,input:i.input,output:void 0,errorText:r}:{...o,...s,state:`output-available`,input:i.input,output:n,errorText:void 0}},c=o.findIndex(e=>e.parts.some(e=>kv(e)&&e.toolCallId===t));if(c!==-1){let e=o[c];this.state.replaceMessage(c,{...e,parts:e.parts.map(s)})}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),c!==-1&&this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically(o[c].id);if(e){this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:o[c].id,...i}),e);return}}this.settleQueue({stopGeneration:a})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.activeStopCount++,this.stopGeneration++,this.deferredApprovalSend=void 0;try{let e=this.activeResumeRequest,t=this.activeResponse;for(let e of this.pendingMessagePreparations)e.abort();e?.abortController.abort(),t?.abortController.abort(),await Promise.all([e?.completionPromise,t?.completionPromise]),await this.jobExecutor.waitForIdle(),this.isQueuePaused=!0}finally{this.activeStopCount--}},this.dispose=async()=>{await this.stop(),this.transport.close?.()},this._id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u,this.queueEnabled=d}get status(){return this.state.status}setStatus({status:e,error:t}){if(this.status===e){this.error!==t&&(this.state.error=t);return}this.state.status=e,this.state.error=t}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}get experimental_queuedMessages(){return this.state.experimental_queuedMessages??this.queuedMessagesFallback}setQueuedMessages(e){`experimental_queuedMessages`in this.state?this.state.experimental_queuedMessages=e:this.queuedMessagesFallback=e}async resumeQueue({skipWaitForUser:e,options:t}){if(this.isQueuePaused=!1,this.hasUnsentApprovalResponse()){if(!this.isRequestInProgress()){await this.sendMessage(void 0,t);return}this.deferredApprovalSend={options:t}}await this.settleQueue({skipWaitForUser:e})}async clearQueueForHistoryChange(){this.queueEnabled&&(this.queuedMessageOptions.clear(),this.setQueuedMessages([]),this.deferredApprovalSend=void 0,this.isRequestInProgress()&&await this.stop())}isRequestInProgress(){return this.pendingAutomaticDecisions.includes(this.stopGeneration)||this.activeResponse!=null||this.status===`submitted`||this.status===`streaming`}isWaitingForUser(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>kv(e)&&(e.state===`approval-requested`||e.state===`approval-responded`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}hasUnsentApprovalResponse(){let e=this.lastMessage;return e?.role===`assistant`&&e.parts.some(e=>kv(e)&&e.state===`approval-responded`)&&!e.parts.some(e=>kv(e)&&(e.state===`approval-requested`||!e.providerExecuted&&(e.state===`input-streaming`||e.state===`input-available`)))}async settleQueue({stopGeneration:e=this.stopGeneration,skipWaitForUser:t=!1}={}){if(this.isQueuePaused||this.isRequestInProgress()||this.activeStopCount>0||e!==this.stopGeneration)return;let n=this.deferredApprovalSend;if(this.deferredApprovalSend=void 0,n!=null&&this.hasUnsentApprovalResponse()){await this.sendMessage(void 0,n.options);return}let[r,...i]=this.experimental_queuedMessages;if(r==null||!t&&this.isWaitingForUser())return;let a=this.queuedMessageOptions.get(r.id);this.queuedMessageOptions.delete(r.id),this.setQueuedMessages(i),this.state.pushMessage(r),await this.makeRequest({trigger:`submit-message`,...a})}set messages(e){this.state.messages=e}async shouldSendAutomatically(e=this.lastMessage?.id){let t=e=>e!=null&&this.interruptedMessageIds.has(e);if(!this.sendAutomaticallyWhen||t(e)||t(this.lastMessage?.id))return!1;let n=this.stopGeneration;this.pendingAutomaticDecisions.push(n);let r;try{r=await this.sendAutomaticallyWhen({messages:this.state.messages})}finally{this.pendingAutomaticDecisions.splice(this.pendingAutomaticDecisions.indexOf(n),1)}return r&&!t(e)&&!t(this.lastMessage?.id)}async runAutomaticRequest(e,t){let n=this.stopGeneration,r=this.activeStopCount>0;return!(t??await this.shouldSendAutomatically())||r||n!==this.stopGeneration||this.activeStopCount>0?!1:(await e(),!0)}async makeRequestForToolApproval({messageId:e,messageIndex:t,...n}){this.deferredApprovalSend=void 0;let r=e!=null&&e===this.pendingApprovalMessageId;r&&(this.pendingApprovalMessageId=void 0),await this.makeRequest({trigger:`submit-message`,messageId:e,...n}),r&&this.status===`error`&&this.pendingApprovalMessageId==null&&(this.pendingApprovalMessageId=this.state.messages[t]?.id??e)}async makeRequest(e){let t=Fv();try{await this.makeRequestImpl({...e,completionPromise:t.promise})}finally{t.resolve()}}async makeRequestImpl({trigger:e,metadata:t,headers:n,body:r,messageId:i,completionPromise:a}){e!==`resume-stream`&&(this.resumableStreamState=void 0);let o=new AbortController,s=e===`resume-stream`?{abortController:o,completionPromise:a}:void 0;s&&(this.activeResumeRequest?.abortController.abort(),this.activeResumeRequest=s);let c=()=>s==null||this.activeResumeRequest===s,l=()=>{this.activeResumeRequest===s&&(this.activeResumeRequest=void 0)},u;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:o.signal,metadata:t,headers:n,body:r});if(o.signal.aborted||!c()){await e?.cancel().catch(()=>{}),c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(e==null){this.setStatus({status:`ready`}),this.resumableStreamState=void 0,l();return}u=e}catch(e){if(o.signal.aborted||e.name===`AbortError`){c()&&(this.setStatus({status:`ready`}),this.resumableStreamState=void 0),l();return}if(!c())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),l();return}this.setStatus({status:`submitted`,error:void 0});let d=this.lastMessage,f=e===`submit-message`&&i!=null?this.state.messages.findIndex(e=>e.id===i):this.state.messages.length-1,p=f===-1?d:this.state.messages[f],m=p?.id,h=e===`resume-stream`&&p?.role===`assistant`&&p.parts.some(e=>kv(e)&&(e.state===`input-streaming`||e.state===`input-available`&&e.providerExecuted||e.state===`approval-responded`))?this.state.snapshot(p):void 0,g=f!==-1&&f<this.state.messages.length-1&&p?.role===`assistant`,_=!1,v=!1,y=!1,b;try{let s={state:e===`resume-stream`&&this.resumableStreamState!=null?this.resumableStreamState:Mv({lastMessage:e===`resume-stream`?h:e===`regenerate-message`?void 0:this.state.snapshot(p),messageId:this.generateId()}),abortController:o,completionPromise:a};b=s,s.abortController.signal.addEventListener(`abort`,()=>{_=!0}),this.activeResponse=s;let l;if(l=e===`resume-stream`?u:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:s.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await Pv({stream:Nv({stream:l,resetStateOnMessageIdChange:e===`resume-stream`,resetStateOnFirstMessageStart:e===`resume-stream`&&this.transport.resumeStreamIsReplay,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>s.abortController.signal.aborted?Promise.resolve():e({state:s.state,write:({updateStatus:e=!0}={})=>{if(s.abortController.signal.aborted)return;e&&this.setStatus({status:`streaming`});let t=this.state.messages.findLastIndex(e=>e.id===s.state.message.id);if(t!==-1)this.state.replaceMessage(t,s.state.message);else if(g){let e=this.state.messages.findLastIndex(e=>e.id===m);e===-1?this.state.pushMessage(s.state.message):this.state.replaceMessage(e,s.state.message)}else this.state.pushMessage(s.state.message)}})),onError:e=>{throw e}}),abortSignal:s.abortController.signal,onError:e=>{throw e}}),_)return c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0)),null;c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===s.state&&(this.resumableStreamState=void 0))}catch(e){if(_||e.name===`AbortError`)return _=!0,c()&&(this.setStatus({status:`ready`}),this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0)),null;if(!c())return null;if(y=!0,e instanceof TypeError){let t=e.message.toLowerCase();v=t.includes(`fetch`)||t.includes(`network`)||t===`load failed`}v?this.resumableStreamState=b?.state:this.resumableStreamState===b?.state&&(this.resumableStreamState=void 0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{if(b){let{message:e,finishReason:t}=b.state;t===`interrupted`?this.interruptedMessageIds.add(e.id):!_&&!y&&this.interruptedMessageIds.delete(e.id),this.onFinish?.({message:b.state.message,messages:this.state.messages,isAbort:_,isDisconnect:v,isError:y,finishReason:b.state.finishReason})}}finally{(_||y||b?.state.finishReason===`interrupted`)&&(this.isQueuePaused=!0),this.activeResponse===b&&(this.activeResponse=void 0),l()}}if(!_&&!y&&b?.state.finishReason!==`interrupted`){let e=this.stopGeneration;await this.runAutomaticRequest(()=>this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r}))||await this.settleQueue({stopGeneration:e})}}};function My({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(kv);return r.filter(e=>e.state===`approval-responded`).length>0&&r.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`||e.state===`output-denied`||e.state===`approval-responded`)}function Ny({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1),i=r.filter(kv).filter(e=>!e.providerExecuted),a=r.reduce((e,t,n)=>kv(t)&&!t.providerExecuted?n:e,-1);return i.length>0&&!r.slice(a+1).some(e=>e.type===`text`&&e.state!==`done`)&&i.every(e=>e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`)}var Py=n(a(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1);function Fy(e,t){return t==null?e:(0,Py.default)(e,t)}function Iy(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var Ly=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e=[]){this.#t=`ready`,this.#n=void 0,this.#r=[],this.#i=new Set,this.#a=new Set,this.#o=new Set,this.#s=new Set,this.pushMessage=e=>{this.#e=this.#e.concat(e),this.#c()},this.popMessage=()=>{this.#e=this.#e.slice(0,-1),this.#c()},this.replaceMessage=(e,t)=>{this.#e=[...this.#e.slice(0,e),this.snapshot(t),...this.#e.slice(e+1)],this.#c()},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=Iy(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?Fy(e,t):e;return this.#i.add(n),()=>{this.#i.delete(n)}},this[`~registerStatusCallback`]=e=>(this.#o.add(e),()=>{this.#o.delete(e)}),this[`~registerErrorCallback`]=e=>(this.#s.add(e),()=>{this.#s.delete(e)}),this[`~registerQueuedMessagesCallback`]=e=>(this.#a.add(e),()=>{this.#a.delete(e)}),this.#c=()=>{this.#i.forEach(e=>e())},this.#l=()=>{this.#o.forEach(e=>e())},this.#u=()=>{this.#s.forEach(e=>e())},this.#e=e}get status(){return this.#t}set status(e){this.#t=e,this.#l()}get error(){return this.#n}set error(e){this.#n=e,this.#u()}get experimental_queuedMessages(){return this.#r}set experimental_queuedMessages(e){this.#r=e,this.#a.forEach(e=>e())}get messages(){return this.#e}set messages(e){this.#e=[...e],this.#c()}#c;#l;#u},Ry=class extends jy{#e;constructor({messages:e,...t}){let n=new Ly(e);super({...t,state:n}),this[`~registerMessagesCallback`]=(e,t)=>this.#e[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>this.#e[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>this.#e[`~registerErrorCallback`](e),this[`~registerQueuedMessagesCallback`]=e=>this.#e[`~registerQueuedMessagesCallback`](e),this.#e=n}},zy=new WeakMap;function By({chat:e,state:t}){if(document.visibilityState!==`visible`||t.pendingVisibilityResume!=null)return;let n=()=>zy.get(e)===t&&t.registrations.size>0,r=()=>{t.pendingVisibilityResume=void 0};t.pendingVisibilityResume=e[`~resumeStreamIfDisconnected`]({shouldResume:()=>n()&&document.visibilityState===`visible`}).then(r,r)}function Vy({chat:e,registration:t}){let n=zy.get(e);if(n==null){let t={registrations:new Set};if(zy.set(e,t),n=t,typeof document<`u`){let n=()=>By({chat:e,state:t});document.addEventListener(`visibilitychange`,n),t.cleanupVisibilityListener=()=>{document.removeEventListener(`visibilitychange`,n)}}}let{registrations:r}=n,i=r.size===0;return r.add(t),i&&e.status!==`submitted`&&e.status!==`streaming`&&e.resumeStream(),()=>{r.delete(t),r.size===0&&(n.cleanupVisibilityListener?.(),zy.delete(e))}}function Hy(e){return{chat:e,messages:e.messages,status:e.status,error:e.error,experimental_queuedMessages:e.experimental_queuedMessages}}function Uy(e,t){return e.chat===t.chat&&e.messages===t.messages&&e.status===t.status&&e.error===t.error&&e.experimental_queuedMessages===t.experimental_queuedMessages}function Wy({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,R.useRef)({}),o=(0,R.useRef)({});`chat`in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let s,c=()=>o.current.transport??(s??=new Ay),l={...r,transport:{get resumeStreamIsReplay(){return c().resumeStreamIsReplay},sendMessages:e=>c().sendMessages(e),reconnectToStream:e=>c().reconnectToStream(e)},onToolCall:e=>o.current.onToolCall?.(e),onData:e=>o.current.onData?.(e),onFinish:e=>o.current.onFinish?.(e),onError:e=>o.current.onError?.(e),sendAutomaticallyWhen:e=>o.current.sendAutomaticallyWhen?.(e)??!1},{chat:u,isExternallyManaged:d}=(0,R.useMemo)(()=>({chat:`chat`in r?r.chat:new Ry(l),isExternallyManaged:`chat`in r}),[`chat`in r?r.chat:r.id]);(0,R.useEffect)(()=>{if(!d)return()=>{u.stop()}},[u,d]);let[f,p]=(0,R.useState)(()=>Hy(u));f.chat!==u&&p(Hy(u)),(0,R.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=Hy(u);p(e=>e.chat!==u||Uy(e,t)?e:t)},n=[u[`~registerMessagesCallback`](t,i),u[`~registerStatusCallback`](t),u[`~registerErrorCallback`](t),u[`~registerQueuedMessagesCallback`](t)],r=Hy(u);return p(e=>Uy(e,r)?e:r),()=>{e=!1,n.forEach(e=>e())}},[u,i]);let{messages:m,status:h,error:g,experimental_queuedMessages:_}=f,v=(0,R.useCallback)(e=>{typeof e==`function`&&(e=e(u.messages)),u.messages=e},[u]);return(0,R.useEffect)(()=>{if(n)return Vy({chat:u,registration:a.current})},[n,u]),{get id(){return u.id},messages:m,setMessages:v,sendMessage:u.sendMessage,regenerate:u.regenerate,clearError:u.clearError,stop:u.stop,error:g,resumeStream:u.resumeStream,status:h,addToolResult:u.addToolOutput,addToolOutput:u.addToolOutput,addToolApprovalResponse:u.addToolApprovalResponse,experimental_queuedMessages:_,experimental_removeQueuedMessage:u.experimental_removeQueuedMessage,experimental_sendQueuedMessageNow:u.experimental_sendQueuedMessageNow}}var Gy=a(((e,t)=>{(function(n,r){typeof i==`function`&&typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(function(){return r()}):n.pluralize=r()})(e,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:!e.hasOwnProperty(i)&&l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),Ky=a(((e,t)=>{function n(e){return e=String(e),e&&e.toLowerCase()}n.isLowercase=function(e){return e&&!/[A-Z]+/.test(e)},t.exports=n})),qy=a(((e,t)=>{function n(e){return e=String(e),e&&e.toUpperCase()}n.isUppercase=function(e){return e&&!/[a-z]+/.test(e)},t.exports=n})),Jy=a(((e,t)=>{var n=Ky(),r=qy(),i={from:/[\-_:\.\s]([a-zA-Z])([a-zA-Z]*)/g,to:function(e,t,n,i,a){return t.length,r(t)+n}};function a(e){return a.isCamelcase(e)||(e=String(e).replace(/^[\-_:\.\s]/,``),!e)?e:(r.isUppercase(e)&&(e=n(e)),n(e[0])+e.replace(i.from,i.to).slice(1).replace(/^([A-Z]+)([A-Z])/,function(e,t,r){return n(t)+r}))}a.isCamelcase=function(e){return e&&/^[a-zA-Z]+$/.test(e)&&n(e[0])===e[0]},t.exports=a})),Yy=a(((e,t)=>{var n=qy();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Xy=a(((e,t)=>{var n=Ky(),r=qy(),i=`_`,a={from:/([A-Z]+)/g,to:function(e,t,a,o){var s=a===0?``:i,c=t.length;if(c===1)return s+n(t);var l=o.slice(a+t.length);return r.isUppercase(t)&&l[0]===i?s+n(t):s+(n(t.substr(0,c-1))+i+n(t[c-1]))}};function o(e){return o.isSnakecase(e)||(e=String(e).replace(/[\-.:\s]/g,i),!e)?e:(r.isUppercase(e)&&(e=n(e)),e.replace(a.from,a.to).replace(/_+/g,`_`))}o.isSnakecase=function(e){return e&&/^[a-z_]+$/.test(e)},t.exports=o})),Zy=a(((e,t)=>{var n=qy(),r=Xy();function i(e){return i.isConstcase(e)?e:n(r(e))}i.isConstcase=function(e){return e&&/^[A-Z_]+$/.test(e)},t.exports=i})),Qy=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,``)}t.exports=r})),$y=a(((e,t)=>{var n=Ky();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),eb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`.`)}t.exports=r})),tb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`:`)}t.exports=r})),nb=a(((e,t)=>{var n=Jy(),r=Yy();function i(e){return r(n(e))}t.exports=i})),rb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`/`)}t.exports=r})),ib=a(((e,t)=>{function n(e){return String(e).trim()}t.exports=n})),ab=a(((e,t)=>{Ky();var n=ib(),r=Xy(),i=Yy(),a=` `;function o(e){return e=String(e).replace(/^[\-_\.\s]/g,a),e&&i(r(n(e)).replace(/_/g,a))}t.exports=o})),ob=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,` `)}t.exports=r})),sb=a(((e,t)=>{var n=Xy();function r(e){return n(e).replace(/_/g,`-`)}t.exports=r})),cb=a(((e,t)=>{var n=Xy(),r=Ky(),i=ib(),a=Yy(),o=`a,the,and,or,not,but,for,of`.split(`,`);function s(e){return n(e).split(/_/g).map(i).map(function(e){return~o.indexOf(e)?r(e):a(e)}).join(` `)}t.exports=s})),lb=a(((e,t)=>{var n=Jy(),r=Yy(),i=Zy(),a=Qy(),o=$y(),s=eb(),c=tb(),l=Ky(),u=nb(),d=rb(),f=ab(),p=Xy(),m=ob(),h=sb(),g=cb(),_=ib(),v=qy();e.camelcase=n,e.capitalcase=r,e.constcase=i,e.cramcase=a,e.decapitalcase=o,e.dotcase=s,e.enumcase=c,e.lowercase=l,e.pascalcase=u,e.pathcase=d,e.sentencecase=f,e.snakecase=p,e.spacecase=m,e.spinalcase=h,e.titlecase=g,e.trimcase=_,e.uppercase=v,t.exports={camelcase:n,capitalcase:r,constcase:i,cramcase:a,decapitalcase:o,dotcase:s,enumcase:c,lowercase:l,pascalcase:u,pathcase:d,sentencecase:f,snakecase:p,spacecase:m,spinalcase:h,titlecase:g,trimcase:_,uppercase:v}}));Gy(),lb();function ub(e){return typeof e==`object`&&!!e&&`name`in e&&(`data`in e||`codec`in e)&&typeof e.name==`string`}function db(e){return fb(e,new WeakSet)}function fb(e,t){return typeof e==`object`?e===null||t.has(e)?!0:(t.add(e),Array.isArray(e)?e.every(e=>fb(e,t)):e instanceof Promise?!1:Symbol.asyncIterator in e||Symbol.iterator in e?!0:ub(e)?fb(e.data,t):Object.values(e).every(e=>fb(e,t))):typeof e!=`bigint`&&typeof e!=`symbol`}function pb(e){return!(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Promise||Symbol.asyncIterator in e||Symbol.iterator in e||ub(e))}function mb(e){return e.type===`message`}function hb(e){if(ub(e)){if(mb(e))throw Error(`Message fragments are not supported by serialized fragment conversion`);if(!e.codec)throw Error(`Fragment "${e.name}" is missing codec`);return e.codec.encode()}return Array.isArray(e)?e.map(e=>hb(e)):pb(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,hb(t)])):e}function gb(e,t){return{name:`term`,data:{name:e,definition:t},codec:{encode(){return{type:`term`,name:e,definition:t}},decode(){return{name:e,definition:t}}}}}function _b(e){return{name:`hint`,data:e,codec:{encode(){return{type:`hint`,text:e}},decode(){return e}}}}function vb(e){return{name:`guardrail`,data:{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}},codec:{encode(){return{type:`guardrail`,rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}},decode(){return{rule:e.rule,...e.reason&&{reason:e.reason},...e.action&&{action:e.action}}}}}}function yb(e){return{name:`explain`,data:{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}},codec:{encode(){return{type:`explain`,concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}},decode(){return{concept:e.concept,explanation:e.explanation,...e.therefore&&{therefore:e.therefore}}}}}}function bb(e){return{name:`example`,data:{question:e.question,answer:e.answer,...e.note&&{note:e.note}},codec:{encode(){return{type:`example`,question:e.question,answer:e.answer,...e.note&&{note:e.note}}},decode(){return{question:e.question,answer:e.answer,...e.note&&{note:e.note}}}}}}function xb(e){return{name:`clarification`,data:{when:e.when,ask:e.ask,reason:e.reason},codec:{encode(){return{type:`clarification`,when:e.when,ask:e.ask,reason:e.reason}},decode(){return{when:e.when,ask:e.ask,reason:e.reason}}}}}function Sb(e){return{name:`workflow`,data:{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}},codec:{encode(){return{type:`workflow`,task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}},decode(){return{task:e.task,steps:e.steps,...e.triggers?.length&&{triggers:e.triggers},...e.notes&&{notes:e.notes}}}}}}function Cb(e){return{name:`quirk`,data:{issue:e.issue,workaround:e.workaround},codec:{encode(){return{type:`quirk`,issue:e.issue,workaround:e.workaround}},decode(){return{issue:e.issue,workaround:e.workaround}}}}}function wb(e){return{name:`styleGuide`,data:{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}},codec:{encode(){return{type:`styleGuide`,prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}},decode(){return{prefer:e.prefer,...e.never&&{never:e.never},...e.always&&{always:e.always}}}}}}function Tb(e){return{name:`analogy`,data:{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}},codec:{encode(){return{type:`analogy`,concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}},decode(){return{concepts:e.concepts,relationship:e.relationship,...e.insight&&{insight:e.insight},...e.therefore&&{therefore:e.therefore},...e.pitfall&&{pitfall:e.pitfall}}}}}}function Eb(e){return{name:`glossary`,data:Object.entries(e).map(([e,t])=>({term:e,expression:t})),codec:{encode(){return{type:`glossary`,entries:e}},decode(){return Object.entries(e).map(([e,t])=>({term:e,expression:t}))}}}}function Db(e){return{name:`role`,data:e,codec:{encode(){return{type:`role`,content:e}},decode(){return e}}}}function Ob(e){return{name:`principle`,data:{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`principle`,title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies.map(e=>hb(e))}}},decode(){return{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}}}}}}function kb(e){return{name:`policy`,data:{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}},codec:{encode(){return{type:`policy`,rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies.map(e=>hb(e))}}},decode(){return{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}}}}}}function Ab(e){return{name:`identity`,data:{...e.name&&{name:e.name},...e.role&&{role:e.role}},codec:{encode(){return{type:`identity`,...e.name&&{name:e.name},...e.role&&{role:e.role}}},decode(){return{...e.name&&{name:e.name},...e.role&&{role:e.role}}}}}}function jb(e){return{name:`persona`,data:{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}},codec:{encode(){return{type:`persona`,name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}},decode(){return{name:e.name,...e.role&&{role:e.role},...e.objective&&{objective:e.objective},...e.tone&&{tone:e.tone}}}}}}function Mb(e,t){return{name:`alias`,data:{term:e,meaning:t},codec:{encode(){return{type:`alias`,term:e,meaning:t}},decode(){return{term:e,meaning:t}}}}}function Nb(e,t){return{name:`preference`,data:{aspect:e,value:t},codec:{encode(){return{type:`preference`,aspect:e,value:t}},decode(){return{aspect:e,value:t}}}}}function Pb(e,t){return{name:`correction`,data:{subject:e,clarification:t},codec:{encode(){return{type:`correction`,subject:e,clarification:t}},decode(){return{subject:e,clarification:t}}}}}function Fb(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function Ib(e,t){if(Fb(e))return yee(e,t);if(Array.isArray(e))return e.map(e=>Ib(e,t));if(pb(e))return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Ib(n,t)]));if(!db(e))throw Error(`Unsupported serialized value of type ${typeof e}`);return e}function Lb(e,t){return{toFragment:(n,r)=>{let i=e.safeParse(n);if(!i.success)throw Error(`Invalid serialized ${n.type} fragment: ${At(i.error)}`);return t(i.data,r)}}}var Rb=Zt(pn()).optional(),zb={term:Lb(F({name:L(),definition:L()}),e=>gb(e.name,e.definition)),hint:Lb(F({text:L()}),e=>_b(e.text)),guardrail:Lb(F({rule:L(),reason:L().optional(),action:L().optional()}),e=>vb({rule:e.rule,reason:e.reason,action:e.action})),explain:Lb(F({concept:L(),explanation:L(),therefore:L().optional()}),e=>yb({concept:e.concept,explanation:e.explanation,therefore:e.therefore})),example:Lb(F({question:L(),answer:L(),note:L().optional()}),e=>bb({question:e.question,answer:e.answer,note:e.note})),clarification:Lb(F({when:L(),ask:L(),reason:L()}),e=>xb({when:e.when,ask:e.ask,reason:e.reason})),workflow:Lb(F({task:L(),steps:Zt(L()),triggers:Zt(L()).optional(),notes:L().optional()}),e=>Sb({task:e.task,steps:e.steps,triggers:e.triggers,notes:e.notes})),quirk:Lb(F({issue:L(),workaround:L()}),e=>Cb({issue:e.issue,workaround:e.workaround})),styleGuide:Lb(F({prefer:L(),never:L().optional(),always:L().optional()}),e=>wb({prefer:e.prefer,never:e.never,always:e.always})),analogy:Lb(F({concepts:Zt(L()),relationship:L(),insight:L().optional(),therefore:L().optional(),pitfall:L().optional()}),e=>Tb({concepts:e.concepts,relationship:e.relationship,insight:e.insight,therefore:e.therefore,pitfall:e.pitfall})),glossary:Lb(F({entries:C(L(),L())}),e=>Eb(e.entries)),role:Lb(F({content:L()}),e=>Db(e.content)),principle:Lb(F({title:L(),description:L(),policies:Rb}),(e,t)=>Ob({title:e.title,description:e.description,policies:e.policies?.map(e=>Ib(e,t))})),policy:Lb(F({rule:L(),before:L().optional(),reason:L().optional(),policies:Rb}),(e,t)=>kb({rule:e.rule,before:e.before,reason:e.reason,policies:e.policies?.map(e=>Ib(e,t))})),identity:Lb(F({name:L().optional(),role:L().optional()}),e=>Ab({name:e.name,role:e.role})),persona:Lb(F({name:L(),role:L().optional(),objective:L().optional(),tone:L().optional()}),e=>jb({name:e.name,role:e.role,objective:e.objective,tone:e.tone})),alias:Lb(F({term:L(),meaning:L()}),e=>Mb(e.term,e.meaning)),preference:Lb(F({aspect:L(),value:L()}),e=>Nb(e.aspect,e.value)),correction:Lb(F({subject:L(),clarification:L()}),e=>Pb(e.subject,e.clarification))};function _ee(e){return Object.hasOwn(zb,e)}var vee=new Set([`user`,`assistant`,`message`]);function yee(e,t){if(vee.has(e.type))throw Error(`Message fragments are not supported by serialized fragment conversion`);let n=t?.registry?.[e.type]??(_ee(e.type)?zb[e.type]:void 0);if(!n)throw Error(`Unsupported serialized fragment type: ${e.type}`);return n.toFragment(e,t)}function bee(e){let t=e?.reminders;return Array.isArray(t)?t.filter(e=>$h(e)&&typeof e.partIndex==`number`&&typeof e.start==`number`&&typeof e.end==`number`):[]}function xee(e,t){if(t.length===0)return e;let n=t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start);if(n.length===0)return e;let r=0,i=``;for(let t of n){if(t.start<r){t.end>r&&(r=t.end);continue}i+=e.slice(r,t.start),r=t.end}return i+=e.slice(r),i.trimEnd()}function See(e){if(Bb(e))return Vb(e);let t=bee($h(e.metadata)?e.metadata:void 0),n=new Map;for(let e of t){let t=n.get(e.partIndex)??[];t.push({start:e.start,end:e.end}),n.set(e.partIndex,t)}let r=e.parts.flatMap((e,t)=>{let r={...e},i=n.get(t);if(r.type!==`text`||i===void 0)return[r];let a=xee(r.text,i);return a.length===0?[]:[{...r,text:a}]}),i={...e,parts:r};if($h(e.metadata)){let t={...e.metadata};delete t.reminders,Object.keys(t).length>0?i.metadata=t:delete i.metadata}return i}function Bb(e){let t=e.metadata;if(!$h(t))return!1;let n=t.synthetic;return $h(n)?n.source===`reminder`:!1}function Vb(e){let t={...e,parts:e.parts.filter(e=>e.type!==`text`)};if($h(e.metadata)){let n={...e.metadata};delete n.synthetic,Object.keys(n).length>0?t.metadata=n:delete t.metadata}return t}var Hb=(0,R.createContext)({});function Ub(e){let t=(0,R.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Wb=typeof window<`u`?R.useLayoutEffect:R.useEffect,Gb=(0,R.createContext)(null);function Kb(e,t){e.indexOf(t)===-1&&e.push(t)}function qb(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Jb=(e,t,n)=>n>t?t:n<e?e:n,Yb={},Xb=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Zb=e=>typeof e==`object`&&!!e,Qb=e=>/^0[^.\s]+$/u.test(e);function $b(e){let t;return()=>(t===void 0&&(t=e()),t)}var ex=e=>e,tx=(...e)=>e.reduce((e,t)=>n=>t(e(n))),nx=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},rx=class{constructor(){this.subscriptions=[]}add(e){return Kb(this.subscriptions,e),()=>qb(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},ix=e=>e*1e3,ax=e=>e/1e3,ox=(e,t)=>t?1e3/t*e:0,sx=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,cx=1e-7,lx=12;function ux(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=sx(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>cx&&++s<lx);return o}function dx(e,t,n,r){if(e===t&&n===r)return ex;let i=t=>ux(t,0,1,e,n);return e=>e===0||e===1?e:sx(i(e),t,r)}var fx=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,px=e=>t=>1-e(1-t),mx=dx(.33,1.53,.69,.99),hx=px(mx),gx=fx(hx),_x=e=>e>=1?1:(e*=2)<1?.5*hx(e):.5*(2-2**(-10*(e-1))),vx=e=>1-Math.sin(Math.acos(e)),yx=px(vx),bx=fx(vx),xx=dx(.42,0,1,1),Sx=dx(0,0,.58,1),Cx=dx(.42,0,.58,1),wx=e=>Array.isArray(e)&&typeof e[0]!=`number`,Tx=e=>Array.isArray(e)&&typeof e[0]==`number`,Ex={linear:ex,easeIn:xx,easeInOut:Cx,easeOut:Sx,circIn:vx,circInOut:bx,circOut:yx,backIn:hx,backInOut:gx,backOut:mx,anticipate:_x},Dx=e=>typeof e==`string`,Ox=e=>{if(Tx(e)){e.length;let[t,n,r,i]=e;return dx(t,n,r,i)}else if(Dx(e))return Ex[e],`${e}`,Ex[e];return e},kx=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function Ax(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var jx=40;function Mx(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=kx.reduce((e,t)=>(e[t]=Ax(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Yb.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,jx),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:kx.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<kx.length;t++)o[kx[t]].cancel(e)},state:i,steps:o}}var{schedule:Nx,cancel:Px,state:Fx,steps:Ix}=Mx(typeof requestAnimationFrame<`u`?requestAnimationFrame:ex,!0),Lx;function Rx(){Lx=void 0}var zx={now:()=>(Lx===void 0&&zx.set(Fx.isProcessing||Yb.useManualTiming?Fx.timestamp:performance.now()),Lx),set:e=>{Lx=e,queueMicrotask(Rx)}},Bx=e=>t=>typeof t==`string`&&t.startsWith(e),Vx=Bx(`--`),Hx=Bx(`var(--`),Ux=e=>Hx(e)?Wx.test(e.split(`/*`)[0].trim()):!1,Wx=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Gx(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Kx={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},qx={...Kx,transform:e=>Jb(0,1,e)},Jx={...Kx,default:1},Yx=e=>Math.round(e*1e5)/1e5,Xx=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Zx(e){return e==null}var Qx=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,$x=(e,t)=>n=>!!(typeof n==`string`&&Qx.test(n)&&n.startsWith(e)||t&&!Zx(n)&&Object.prototype.hasOwnProperty.call(n,t)),eS=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Xx);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},tS=e=>Jb(0,255,e),nS={...Kx,transform:e=>Math.round(tS(e))},rS={test:$x(`rgb`,`red`),parse:eS(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+nS.transform(e)+`, `+nS.transform(t)+`, `+nS.transform(n)+`, `+Yx(qx.transform(r))+`)`};function iS(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var aS={test:$x(`#`),parse:iS,transform:rS.transform},oS=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),sS=oS(`deg`),cS=oS(`%`),W=oS(`px`),lS=oS(`vh`),uS=oS(`vw`),dS={...cS,parse:e=>cS.parse(e)/100,transform:e=>cS.transform(e*100)},fS={test:$x(`hsl`,`hue`),parse:eS(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+cS.transform(Yx(t))+`, `+cS.transform(Yx(n))+`, `+Yx(qx.transform(r))+`)`},pS={test:e=>rS.test(e)||aS.test(e)||fS.test(e),parse:e=>rS.test(e)?rS.parse(e):fS.test(e)?fS.parse(e):aS.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?rS.transform(e):fS.transform(e),getAnimatableNone:e=>{let t=pS.parse(e);return t.alpha=0,pS.transform(t)}},mS=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function hS(e){return isNaN(e)&&typeof e==`string`&&(e.match(Xx)?.length||0)+(e.match(mS)?.length||0)>0}var gS=`number`,_S=`color`,vS=`var`,yS=`var(`,bS="${}",xS=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function SS(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(xS,e=>(pS.test(e)?(r.color.push(a),i.push(_S),n.push(pS.parse(e))):e.startsWith(yS)?(r.var.push(a),i.push(vS),n.push(e)):(r.number.push(a),i.push(gS),n.push(parseFloat(e))),++a,bS)).split(bS),indexes:r,types:i}}function CS(e){return SS(e).values}function wS({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===gS?i+=Yx(r[a]):e===_S?i+=pS.transform(r[a]):i+=r[a]}return i}}function TS(e){return wS(SS(e))}var ES=e=>typeof e==`number`?0:pS.test(e)?pS.getAnimatableNone(e):e,DS=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:ES(e);function OS(e){let t=SS(e);return wS(t)(t.values.map((e,n)=>DS(e,t.split[n])))}var kS={test:hS,parse:CS,createTransformer:TS,getAnimatableNone:OS};function AS(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function jS({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=AS(s,r,e+1/3),a=AS(s,r,e),o=AS(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function MS(e,t){return n=>n>0?t:e}var NS=(e,t,n)=>e+(t-e)*n,PS=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},FS=[aS,rS,fS],IS=e=>FS.find(t=>t.test(e));function LS(e){let t=IS(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===fS&&(n=jS(n)),n}var RS=(e,t)=>{let n=LS(e),r=LS(t);if(!n||!r)return MS(e,t);let i={...n};return e=>(i.red=PS(n.red,r.red,e),i.green=PS(n.green,r.green,e),i.blue=PS(n.blue,r.blue,e),i.alpha=NS(n.alpha,r.alpha,e),rS.transform(i))},zS=new Set([`none`,`hidden`]);function BS(e,t){return zS.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function VS(e,t){return n=>NS(e,t,n)}function HS(e){return typeof e==`number`?VS:typeof e==`string`?Ux(e)?MS:pS.test(e)?RS:KS:Array.isArray(e)?US:typeof e==`object`?pS.test(e)?RS:WS:MS}function US(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>HS(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function WS(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=HS(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function GS(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var KS=(e,t)=>{let n=kS.createTransformer(t),r=SS(e),i=SS(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?zS.has(e)&&!i.values.length||zS.has(t)&&!r.values.length?BS(e,t):tx(US(GS(r,i),i.values),n):(`${e}${t}`,MS(e,t))};function qS(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?NS(e,t,n):HS(e)(e,t)}var JS=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Nx.update(t,e),stop:()=>Px(t),now:()=>Fx.isProcessing?Fx.timestamp:zx.now()}},YS=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},XS=2e4;function ZS(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function QS(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(ZS(r),XS);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ax(i)}}var $S={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function eC(e,t){return e*Math.sqrt(1-t*t)}var tC=12;function nC(e,t,n){let r=n;for(let n=1;n<tC;n++)r-=e(r)/t(r);return r}var rC=.001;function iC({duration:e=$S.duration,bounce:t=$S.bounce,velocity:n=$S.velocity,mass:r=$S.mass}){let i,a;$S.maxDuration;let o=1-t;o=Jb($S.minDamping,$S.maxDamping,o),e=Jb($S.minDuration,$S.maxDuration,ax(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=eC(t,o),c=Math.exp(-i);return rC-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=eC(t**2,o);return(-i(t)+rC>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=nC(i,a,s);if(e=ix(e),isNaN(c))return{stiffness:$S.stiffness,damping:$S.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var aC=[`duration`,`bounce`],oC=[`stiffness`,`damping`,`mass`];function sC(e,t){return t.some(t=>e[t]!==void 0)}function cC(e){let t={velocity:$S.velocity,stiffness:$S.stiffness,damping:$S.damping,mass:$S.mass,isResolvedFromDuration:!1,...e};if(!sC(e,oC)&&sC(e,aC))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Jb(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:$S.mass,stiffness:i,damping:a}}else{let n=iC({...e,velocity:0});t={...t,...n,mass:$S.mass},t.isResolvedFromDuration=!0}return t}function lC(e=$S.visualDuration,t=$S.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=cC({...n,velocity:-ax(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ax(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?$S.restSpeed.granular:$S.restSpeed.default,i||=v?$S.restDelta.granular:$S.restDelta.default;let y,b,x,S,C,w;if(h<1)x=eC(_,h),S=(m+h*_*g)/x,y=e=>{let t=Math.exp(-h*_*e);return o-t*(S*Math.sin(x*e)+g*Math.cos(x*e))},C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>ix(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=ix(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=ix(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(ZS(T),XS),t=YS(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}lC.applyToOptions=e=>{let t=QS(e,100,lC);return e.ease=t.ease,e.duration=ix(t.duration),e.type=`keyframes`,e};var uC=5;function dC(e,t,n){let r=Math.max(t-uC,0);return ox(n-e(r),t-r)}function fC({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=lC({keyframes:[f.value,m(f.value)],velocity:dC(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function pC(e,t,n){let r=[],i=n||Yb.mix||qS,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=tx(Array.isArray(t)?t[n]||ex:t,a)),r.push(a)}return r}function mC(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=pC(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=nx(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Jb(e[0],e[a-1],t)):l}function hC(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=nx(0,t,r);e.push(NS(n,1,i))}}function gC(e){let t=[0];return hC(t,e.length-1),t}function _C(e,t){return e.map(e=>e*t)}function vC(e,t){return e.map(()=>t||Cx).splice(0,e.length-1)}function yC({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=wx(r)?r.map(Ox):Ox(r),a={done:!1,value:t[0]},o=mC(_C(n&&n.length===t.length?n:gC(t),e),t,{ease:Array.isArray(i)?i:vC(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var bC=e=>e!==null;function xC(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(bC),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var SC={decay:fC,inertia:fC,tween:yC,keyframes:yC,spring:lC};function CC(e){typeof e.type==`string`&&(e.type=SC[e.type])}var wC=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},TC=e=>e/100,EC=class extends wC{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==zx.now()&&this.tick(zx.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;CC(e);let{type:t=yC,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||yC;s!==yC&&typeof o[0]!=`number`&&(this.mixKeyframes=tx(TC,qS(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=ZS(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Jb(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==fC&&(b.value=xC(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ax(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ax(e)}get time(){return ax(this.currentTime)}set time(e){e=ix(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return dC(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(zx.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ax(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=JS,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(zx.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function DC(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var OC=e=>e*180/Math.PI,kC=e=>jC(OC(Math.atan2(e[1],e[0]))),AC={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:kC,rotateZ:kC,skewX:e=>OC(Math.atan(e[1])),skewY:e=>OC(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},jC=e=>(e%=360,e<0&&(e+=360),e),MC=kC,NC=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),PC=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),FC={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:NC,scaleY:PC,scale:e=>(NC(e)+PC(e))/2,rotateX:e=>jC(OC(Math.atan2(e[6],e[5]))),rotateY:e=>jC(OC(Math.atan2(-e[2],e[0]))),rotateZ:MC,rotate:MC,skewX:e=>OC(Math.atan(e[4])),skewY:e=>OC(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function IC(e){return+!!e.includes(`scale`)}function LC(e,t){if(!e||e===`none`)return IC(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=FC,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=AC,i=t}if(!i)return IC(t);let a=r[t],o=i[1].split(`,`).map(zC);return typeof a==`function`?a(o):o[a]}var RC=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return LC(n,t)};function zC(e){return parseFloat(e.trim())}var BC=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],VC=new Set([...BC,`pathRotation`]),HC=e=>e===Kx||e===W,UC=new Set([`x`,`y`,`z`]),WC=BC.filter(e=>!UC.has(e));function GC(e){let t=[];return WC.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var KC={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>LC(t,`x`),y:(e,{transform:t})=>LC(t,`y`)};KC.translateX=KC.x,KC.translateY=KC.y;var qC=new Set,JC=!1,YC=!1,XC=!1;function ZC(){if(YC){let e=Array.from(qC).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=GC(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}YC=!1,JC=!1,qC.forEach(e=>e.complete(XC)),qC.clear()}function QC(){qC.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(YC=!0)})}function $C(){XC=!0,QC(),ZC(),XC=!1}var ew=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(qC.add(this),JC||(JC=!0,Nx.read(QC),Nx.resolveKeyframes(ZC))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}DC(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),qC.delete(this)}cancel(){this.state===`scheduled`&&(qC.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},tw=e=>e.startsWith(`--`);function nw(e,t,n){tw(t)?e.style.setProperty(t,n):e.style[t]=n}var rw={};function iw(e,t){let n=$b(e);return()=>rw[t]??n()}var aw=iw(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),ow=iw(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),sw=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,cw={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:sw([0,.65,.55,1]),circOut:sw([.55,0,1,.45]),backIn:sw([.31,.01,.66,-.59]),backOut:sw([.33,1.53,.69,.99])};function lw(e,t){if(e)return typeof e==`function`?ow()?YS(e,t):`ease-out`:Tx(e)?sw(e):Array.isArray(e)?e.map(e=>lw(e,t)||cw.easeOut):cw[e]}function uw(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=lw(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function dw(e){return typeof e==`function`&&`applyToOptions`in e}function fw({type:e,...t}){return dw(e)&&ow()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var pw=class extends wC{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=fw(e);this.animation=uw(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=xC(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),nw(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ax(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ax(e)}get time(){return ax(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ix(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&aw()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),ex):r(this)}},mw={anticipate:_x,backInOut:gx,circInOut:bx};function hw(e){return e in mw}function gw(e){typeof e.ease==`string`&&hw(e.ease)&&(e.ease=mw[e.ease])}var _w=10,vw=class extends pw{constructor(e){gw(e),CC(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new EC({...a,autoplay:!1}),s=Math.max(_w,zx.now()-this.startTime),c=Jb(0,_w,s-_w),l=o.sample(s).value,{name:u}=this.options;i&&u&&nw(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},yw=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(kS.test(e)||e===`0`)&&!e.startsWith(`url(`));function bw(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function xw(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=yw(i,t),s=yw(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:bw(e)||(n===`spring`||dw(n))&&r}function Sw(e){e.duration=0,e.type=`keyframes`}var Cw=new Set([`opacity`,`clipPath`,`filter`,`transform`]),ww=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Tw(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ww.test(e[t]))return!0;return!1}var Ew=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Dw=$b(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Ow(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Dw()&&n&&(Cw.has(n)||Ew.has(n)&&Tw(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var kw=40,Aw=class extends wC{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=zx.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||ew;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=zx.now();let u=!0;xw(e,i,a,o)||(u=!1,(Yb.instantAnimations||!s)&&l?.(xC(e,n,t)),e[0]=e[e.length-1],Sw(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>kw?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Ow(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new vw({...d,element:p})}catch{m=new EC(d)}else m=new EC(d);m.finished.then(()=>{this.notifyFinished()}).catch(ex),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),$C()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function jw(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Mw=30,Nw=e=>!isNaN(parseFloat(e)),Pw={current:void 0},Fw=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=zx.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=zx.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Nw(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new rx);let n=this.events[e].add(t);return e===`change`?()=>{n(),Nx.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Pw.current&&Pw.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=zx.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Mw)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Mw);return ox(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Iw(e,t){return new Fw(e,t)}function Lw(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Rw(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Lw(n,e)}var zw={type:`spring`,stiffness:500,damping:25,restSpeed:10},Bw=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Vw={type:`keyframes`,duration:.8},Hw={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Uw=(e,{keyframes:t})=>t.length>2?Vw:VC.has(e)?e.startsWith(`scale`)?Bw(t[1]):zw:Hw,Ww=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Gw(e){for(let t in e)if(!Ww.has(t))return!0;return!1}var Kw=(e,t,n,r={},i,a)=>o=>{let s=Rw(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=ix(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Gw(s)||Object.assign(u,Uw(e,u)),u.duration&&=ix(u.duration),u.repeatDelay&&=ix(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Sw(u),u.delay===0&&(d=!0)),(Yb.instantAnimations||Yb.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,Sw(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=xC(u.keyframes,s);if(e!==void 0){Nx.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new EC(u):new Aw(u)},qw=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Jw(e){let t=qw.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Yw(e,t,n=1){`${e}`;let[r,i]=Jw(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Xb(e)?parseFloat(e):e}return Ux(i)?Yw(i,t,n+1):i}function Xw(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Zw(e,t,n,r){if(typeof t==`function`){let[i,a]=Xw(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Xw(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Qw(e,t,n){let r=e.getProps();return Zw(r,t,n===void 0?r.custom:n,e)}var $w=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...BC]),eT=e=>Array.isArray(e);function tT(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Iw(n))}function nT(e){return eT(e)?e[e.length-1]||0:e}function rT(e,t){let{transitionEnd:n={},transition:r={},...i}=Qw(e,t)||{};i={...i,...n};for(let t in i)tT(e,t,nT(i[t]))}var iT=e=>!!(e&&e.getVelocity);function aT(e){return!!(iT(e)&&e.add)}function oT(e,t){let n=e.getValue(`willChange`);if(aT(n))return n.add(t);if(!n&&Yb.WillChange){let n=new Yb.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function sT(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var cT=`data-`+sT(`framerAppearId`);function lT(e){return e.props[cT]}function uT({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function dT(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Lw(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&uT(f,t))continue;let o={delay:n,...Rw(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Nx.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=lT(e);if(n){let e=window.MotionHandoffAnimation(n,t,Nx);e!==null&&(o.startTime=e,p=!0)}}oT(e,t);let m=l??e.shouldReduceMotion;r.start(Kw(t,r,i,m&&$w.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Nx.update(()=>{o&&rT(e,o)});d.length?Promise.all(d).then(t):t()}return d}function fT(e,t,n={}){let r=Qw(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(dT(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return pT(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function pT(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(fT(c,t,{...o,delay:n+(typeof r==`function`?0:r)+jw(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function mT(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>fT(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=fT(e,t,n);else{let i=typeof t==`function`?Qw(e,t,n.custom):t;r=Promise.all(dT(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var hT={test:e=>e===`auto`,parse:e=>e},gT=e=>t=>t.test(e),_T=[Kx,W,cS,sS,uS,lS,hT],vT=e=>_T.find(gT(e));function yT(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Qb(e)}var bT=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function xT(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Xx)||[];if(!r)return e;let i=n.replace(r,``),a=+!!bT.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var ST=/\b([a-z-]*)\(.*?\)/gu,CT={...kS,getAnimatableNone:e=>{let t=e.match(ST);return t?t.map(xT).join(` `):e}},wT={...kS,getAnimatableNone:e=>{let t=kS.parse(e);return kS.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},TT={...Kx,transform:Math.round},ET={borderWidth:W,borderTopWidth:W,borderRightWidth:W,borderBottomWidth:W,borderLeftWidth:W,borderRadius:W,borderTopLeftRadius:W,borderTopRightRadius:W,borderBottomRightRadius:W,borderBottomLeftRadius:W,width:W,maxWidth:W,height:W,maxHeight:W,top:W,right:W,bottom:W,left:W,inset:W,insetBlock:W,insetBlockStart:W,insetBlockEnd:W,insetInline:W,insetInlineStart:W,insetInlineEnd:W,padding:W,paddingTop:W,paddingRight:W,paddingBottom:W,paddingLeft:W,paddingBlock:W,paddingBlockStart:W,paddingBlockEnd:W,paddingInline:W,paddingInlineStart:W,paddingInlineEnd:W,margin:W,marginTop:W,marginRight:W,marginBottom:W,marginLeft:W,marginBlock:W,marginBlockStart:W,marginBlockEnd:W,marginInline:W,marginInlineStart:W,marginInlineEnd:W,fontSize:W,backgroundPositionX:W,backgroundPositionY:W,rotate:sS,pathRotation:sS,rotateX:sS,rotateY:sS,rotateZ:sS,scale:Jx,scaleX:Jx,scaleY:Jx,scaleZ:Jx,skew:sS,skewX:sS,skewY:sS,distance:W,translateX:W,translateY:W,translateZ:W,x:W,y:W,z:W,perspective:W,transformPerspective:W,opacity:qx,originX:dS,originY:dS,originZ:W,zIndex:TT,fillOpacity:qx,strokeOpacity:qx,numOctaves:TT},DT={...ET,color:pS,backgroundColor:pS,outlineColor:pS,fill:pS,stroke:pS,borderColor:pS,borderTopColor:pS,borderRightColor:pS,borderBottomColor:pS,borderLeftColor:pS,filter:CT,WebkitFilter:CT,mask:wT,WebkitMask:wT},OT=e=>DT[e],kT=new Set([CT,wT]);function AT(e,t){let n=OT(e);return kT.has(n)||(n=kS),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var jT=new Set([`auto`,`none`,`0`]);function MT(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!jT.has(t)&&SS(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=AT(n,i)}var NT=class extends ew{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Ux(r))){let i=Yw(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!$w.has(n)||e.length!==2)return;let[r,i]=e,a=vT(r),o=vT(i);if(Gx(r)!==Gx(i)&&KC[n]){this.needsMeasurement=!0;return}if(a!==o)if(HC(a)&&HC(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else KC[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||yT(e[t]))&&n.push(t);n.length&&MT(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=KC[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=KC[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},PT=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function FT(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var IT=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function LT(e){return Zb(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:RT,cancel:Cee}=Mx(queueMicrotask,!1),zT={x:!1,y:!1};function BT(){return zT.x||zT.y}function VT(e){return e===`x`||e===`y`?zT[e]?null:(zT[e]=!0,()=>{zT[e]=!1}):zT.x||zT.y?null:(zT.x=zT.y=!0,()=>{zT.x=zT.y=!1})}function HT(e,t){let n=FT(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function UT(e){return!(e.pointerType===`touch`||BT())}function WT(e,t,n={}){let[r,i,a]=HT(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!UT(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var GT=(e,t)=>t?e===t||GT(e,t.parentElement):!1,KT=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,qT=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function JT(e){return qT.has(e.tagName)||e.isContentEditable===!0}var YT=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function XT(e){return YT.has(e.tagName)||e.isContentEditable===!0}var ZT=new WeakSet;function QT(e){return t=>{t.key===`Enter`&&e(t)}}function $T(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var eE=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=QT(()=>{if(ZT.has(n))return;$T(n,`down`);let e=QT(()=>{$T(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>$T(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function tE(e){return KT(e)&&!BT()}var nE=new WeakSet;function rE(e,t,n={}){let[r,i,a]=HT(e,n),o=e=>{let r=e.currentTarget;if(!tE(e)||nE.has(e))return;ZT.add(r),n.stopPropagation&&nE.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),ZT.has(r)&&ZT.delete(r),tE(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||GT(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),LT(e)&&(e.addEventListener(`focus`,e=>eE(e,i)),!JT(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function iE(e){return Zb(e)&&`ownerSVGElement`in e}var aE=new WeakMap,oE,sE=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:iE(r)&&`getBBox`in r?r.getBBox()[t]:r[n],cE=sE(`inline`,`width`,`offsetWidth`),lE=sE(`block`,`height`,`offsetHeight`);function uE({target:e,borderBoxSize:t}){aE.get(e)?.forEach(n=>{n(e,{get width(){return cE(e,t)},get height(){return lE(e,t)}})})}function dE(e){e.forEach(uE)}function fE(){typeof ResizeObserver>`u`||(oE=new ResizeObserver(dE))}function pE(e,t){oE||fE();let n=FT(e);return n.forEach(e=>{let n=aE.get(e);n||(n=new Set,aE.set(e,n)),n.add(t),oE?.observe(e)}),()=>{n.forEach(e=>{let n=aE.get(e);n?.delete(t),n?.size||oE?.unobserve(e)})}}var mE=new Set,hE;function gE(){hE=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};mE.forEach(t=>t(e))},window.addEventListener(`resize`,hE)}function _E(e){return mE.add(e),hE||gE(),()=>{mE.delete(e),!mE.size&&typeof hE==`function`&&(window.removeEventListener(`resize`,hE),hE=void 0)}}function vE(e,t){return typeof e==`function`?_E(e):pE(e,t)}var yE={value:null,addProjectionMetrics:null};function bE(e){return iE(e)&&e.tagName===`svg`}var xE=[..._T,pS,kS],SE=e=>xE.find(gT(e)),CE=()=>({translate:0,scale:1,origin:0,originPoint:0}),wE=()=>({x:CE(),y:CE()}),TE=()=>({min:0,max:0}),EE=()=>({x:TE(),y:TE()}),DE=new WeakMap;function OE(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function kE(e){return typeof e==`string`||Array.isArray(e)}var AE=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],jE=[`initial`,...AE];function ME(e){return OE(e.animate)||jE.some(t=>kE(e[t]))}function NE(e){return!!(ME(e)||e.variants)}function PE(e,t,n){for(let r in t){let i=t[r],a=n[r];if(iT(i))e.addValue(r,i);else if(iT(a))e.addValue(r,Iw(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Iw(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var FE={current:null},IE={current:!1},LE=typeof window<`u`;function RE(){if(IE.current=!0,LE)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>FE.current=e.matches;e.addEventListener(`change`,t),t()}else FE.current=!1}var zE=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],BE={};function VE(e){BE=e}function HE(){return BE}var UE=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ew,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=zx.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Nx.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=ME(t),this.isVariantNode=NE(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&iT(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,DE.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(IE.current||RE(),this.shouldReduceMotion=FE.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Px(this.notifyUpdate),Px(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&Cw.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new pw({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:ix(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=VC.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Nx.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in BE){let t=BE[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):EE()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<zE.length;t++){let n=zE[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=PE(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Iw(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Xb(n)||Qb(n))?n=parseFloat(n):!SE(n)&&kS.test(t)&&(n=AT(e,t)),this.setBaseTarget(e,iT(n)?n.get():n)),iT(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Zw(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!iT(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new rx),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){RT.render(this.render)}},WE=class extends UE{constructor(){super(...arguments),this.KeyframeResolver=NT}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;iT(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},GE=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function KE({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function qE({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function JE(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function YE(e){return e===void 0||e===1}function XE({scale:e,scaleX:t,scaleY:n}){return!YE(e)||!YE(t)||!YE(n)}function ZE(e){return XE(e)||QE(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function QE(e){return $E(e.x)||$E(e.y)}function $E(e){return e&&e!==`0%`}function eD(e,t,n){return n+t*(e-n)}function tD(e,t,n,r,i){return i!==void 0&&(e=eD(e,i,r)),eD(e,n,r)+t}function nD(e,t=0,n=1,r,i){e.min=tD(e.min,t,n,r,i),e.max=tD(e.max,t,n,r,i)}function rD(e,{x:t,y:n}){nD(e.x,t.translate,t.scale,t.originPoint),nD(e.y,n.translate,n.scale,n.originPoint)}var iD=.999999999999,aD=1.0000000000001;function oD(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(sD(e.x,-a.scroll.offset.x),sD(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,rD(e,o)),r&&ZE(a.latestValues)&&uD(e,a.latestValues,a.layout?.layoutBox))}t.x<aD&&t.x>iD&&(t.x=1),t.y<aD&&t.y>iD&&(t.y=1)}function sD(e,t){e.min+=t,e.max+=t}function cD(e,t,n,r,i=.5){nD(e,t,n,NS(e.min,e.max,i),r)}function lD(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function uD(e,t,n){let r=n??e;cD(e.x,lD(t.x,r.x),t.scaleX,t.scale,t.originX),cD(e.y,lD(t.y,r.y),t.scaleY,t.scale,t.originY)}function dD(e,t){return KE(JE(e.getBoundingClientRect(),t))}function fD(e,t,n){let r=dD(e,n),{scroll:i}=t;return i&&(sD(r.x,i.offset.x),sD(r.y,i.offset.y)),r}var pD={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},mD=BC.length;function hD(e,t,n){let r=``,i=!0;for(let a=0;a<mD;a++){let o=BC[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=IT(s,ET[o]);if(!c){i=!1;let t=pD[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${IT(a,ET.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function gD(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(VC.has(e)){o=!0;continue}else if(Vx(e)){i[e]=n;continue}else{let t=IT(n,ET[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=hD(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function _D(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function vD(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var yD={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(W.test(e))e=parseFloat(e);else return e;return`${vD(e,t.target.x)}% ${vD(e,t.target.y)}%`}},bD={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=kS.parse(e);if(i.length>5)return r;let a=kS.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=NS(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},xD={borderRadius:{...yD,applyTo:[...PT]},borderTopLeftRadius:yD,borderTopRightRadius:yD,borderBottomLeftRadius:yD,borderBottomRightRadius:yD,boxShadow:bD};function SD(e,{layout:t,layoutId:n}){return VC.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!xD[e]||e===`opacity`)}function CD(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(iT(r[t])||i&&iT(i[t])||SD(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function wD(e){return window.getComputedStyle(e)}var TD=class extends WE{constructor(){super(...arguments),this.type=`html`,this.renderInstance=_D}readValueFromInstance(e,t){if(VC.has(t))return this.projection?.isProjecting?IC(t):RC(e,t);{let n=wD(e),r=(Vx(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return dD(e,t)}build(e,t,n){gD(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return CD(e,t,n)}},ED={offset:`stroke-dashoffset`,array:`stroke-dasharray`},DD={offset:`strokeDashoffset`,array:`strokeDasharray`};function OD(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?ED:DD;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var kD=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function AD(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(gD(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of kD)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&OD(d,i,a,o,!1)}var jD=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),MD=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function ND(e,t,n,r){_D(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(jD.has(n)?n:sT(n),t.attrs[n])}function PD(e,t,n){let r=CD(e,t,n);for(let n in e)if(iT(e[n])||iT(t[n])){let t=BC.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var FD=class extends WE{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=EE}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(VC.has(t)){let e=OT(t);return e&&e.default||0}return t=jD.has(t)?t:sT(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return PD(e,t,n)}build(e,t,n){AD(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){ND(e,t,n,r)}mount(e){this.isSVGTag=MD(e.tagName),super.mount(e)}},ID=jE.length;function LD(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&LD(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<ID;n++){let r=jE[n],i=e.props[r];(kE(i)||i===!1)&&(t[r]=i)}return t}function RD(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var zD=[...AE].reverse(),BD=AE.length;function VD(e){return t=>Promise.all(t.map(({animation:t,options:n})=>mT(e,t,n)))}function HD(e){let t=VD(e),n=GD(),r=!0,i=!1,a=t=>(n,r)=>{let i=Qw(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=LD(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<BD;t++){let p=zD[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=kE(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||OE(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=UD(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=eT(t)&&eT(n)?!RD(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Qw(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=jw(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Qw(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=GD(),i=!0}}}function UD(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!RD(t,e):!1}function WD(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function GD(){return{animate:WD(!0),whileInView:WD(),whileHover:WD(),whileTap:WD(),whileDrag:WD(),whileFocus:WD(),exit:WD()}}function KD(e,t){e.min=t.min,e.max=t.max}function qD(e,t){KD(e.x,t.x),KD(e.y,t.y)}function JD(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var YD=.9999,XD=1.0001,ZD=-.01,QD=.01;function $D(e){return e.max-e.min}function eO(e,t,n){return Math.abs(e-t)<=n}function tO(e,t,n,r=.5){e.origin=r,e.originPoint=NS(t.min,t.max,e.origin),e.scale=$D(n)/$D(t),e.translate=NS(n.min,n.max,e.origin)-e.originPoint,(e.scale>=YD&&e.scale<=XD||isNaN(e.scale))&&(e.scale=1),(e.translate>=ZD&&e.translate<=QD||isNaN(e.translate))&&(e.translate=0)}function nO(e,t,n,r){tO(e.x,t.x,n.x,r?r.originX:void 0),tO(e.y,t.y,n.y,r?r.originY:void 0)}function rO(e,t,n,r=0){e.min=(r?NS(n.min,n.max,r):n.min)+t.min,e.max=e.min+$D(t)}function iO(e,t,n,r){rO(e.x,t.x,n.x,r?.x),rO(e.y,t.y,n.y,r?.y)}function aO(e,t,n,r=0){let i=r?NS(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+$D(t)}function oO(e,t,n,r){aO(e.x,t.x,n.x,r?.x),aO(e.y,t.y,n.y,r?.y)}function sO(e,t,n,r,i){return e-=t,e=eD(e,1/n,r),i!==void 0&&(e=eD(e,1/i,r)),e}function cO(e,t=0,n=1,r=.5,i,a=e,o=e){if(cS.test(t)&&(t=parseFloat(t),t=NS(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=NS(a.min,a.max,r);e===a&&(s-=t),e.min=sO(e.min,t,n,s,i),e.max=sO(e.max,t,n,s,i)}function lO(e,t,[n,r,i],a,o){cO(e,t[n],t[r],t[i],t.scale,a,o)}var uO=[`x`,`scaleX`,`originX`],dO=[`y`,`scaleY`,`originY`];function fO(e,t,n,r){lO(e.x,t,uO,n?n.x:void 0,r?r.x:void 0),lO(e.y,t,dO,n?n.y:void 0,r?r.y:void 0)}function pO(e){return e.translate===0&&e.scale===1}function mO(e){return pO(e.x)&&pO(e.y)}function hO(e,t){return e.min===t.min&&e.max===t.max}function gO(e,t){return hO(e.x,t.x)&&hO(e.y,t.y)}function _O(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function vO(e,t){return _O(e.x,t.x)&&_O(e.y,t.y)}function yO(e){return $D(e.x)/$D(e.y)}function bO(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function xO(e){return[e(`x`),e(`y`)]}function SO(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var CO=PT.length,wO=e=>typeof e==`string`?parseFloat(e):e,TO=e=>typeof e==`number`||W.test(e);function EO(e,t,n,r,i,a){i?(e.opacity=NS(0,n.opacity??1,OO(r)),e.opacityExit=NS(t.opacity??1,0,kO(r))):a&&(e.opacity=NS(t.opacity??1,n.opacity??1,r));for(let i=0;i<CO;i++){let a=PT[i],o=DO(t,a),s=DO(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||TO(o)===TO(s)?(e[a]=Math.max(NS(wO(o),wO(s),r),0),(cS.test(s)||cS.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=NS(t.rotate||0,n.rotate||0,r))}function DO(e,t){return e[t]===void 0?e.borderRadius:e[t]}var OO=AO(0,.5,yx),kO=AO(.5,.95,ex);function AO(e,t,n){return r=>r<e?0:r>t?1:n(nx(e,t,r))}function jO(e,t,n){let r=iT(e)?e:Iw(e);return r.start(Kw(``,r,t,n)),r.animation}function MO(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var NO=(e,t)=>e.depth-t.depth,PO=class{constructor(){this.children=[],this.isDirty=!1}add(e){Kb(this.children,e),this.isDirty=!0}remove(e){qb(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(NO),this.isDirty=!1,this.children.forEach(e)}};function FO(e,t){let n=zx.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Px(r),e(a-t))};return Nx.setup(r,!0),()=>Px(r)}function IO(e){return iT(e)?e.get():e}var LO=class{constructor(){this.members=[]}add(e){Kb(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(qb(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(qb(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},RO={hasAnimatedSinceResize:!0,hasEverUpdated:!1},zO={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},BO=[``,`X`,`Y`,`Z`],VO=1e3,HO=0;function UO(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function WO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=lT(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Nx,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&WO(r)}function GO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=HO++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,yE.value&&(zO.nodes=zO.calculatedTargetDeltas=zO.calculatedProjections=0),this.nodes.forEach(JO),this.nodes.forEach(rk),this.nodes.forEach(ik),this.nodes.forEach(YO),yE.addProjectionMetrics&&yE.addProjectionMetrics(zO)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new PO)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new rx),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=iE(t)&&!bE(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Nx.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=FO(i,250),RO.hasAnimatedSinceResize&&(RO.hasAnimatedSinceResize=!1,this.nodes.forEach(nk)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||dk,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!vO(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Rw(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||nk(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Px(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ak),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&WO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(QO),this.nodes.forEach(ZO);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach($O);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ek),this.nodes.forEach(tk),this.nodes.forEach(KO),this.nodes.forEach(qO)):this.nodes.forEach($O),this.clearAllSnapshots();let e=zx.now();Fx.delta=Jb(0,1e3/60,e-Fx.timestamp),Fx.timestamp=e,Fx.isProcessing=!0,Ix.update.process(Fx),Ix.preRender.process(Fx),Ix.render.process(Fx),Fx.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,RT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(XO),this.sharedNodes.forEach(ok)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Nx.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Nx.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!$D(this.snapshot.measuredBox.x)&&!$D(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=EE(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!mO(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||ZE(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),hk(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return EE();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(_k))){let{scroll:e}=this.root;e&&(sD(t.x,e.offset.x),sD(t.y,e.offset.y))}return t}removeElementScroll(e){let t=EE();if(qD(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&qD(t,e),sD(t.x,i.offset.x),sD(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||EE();qD(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(sD(r.x,-n.scroll.offset.x),sD(r.y,-n.scroll.offset.y)),ZE(n.latestValues)&&uD(r,n.latestValues,n.layout?.layoutBox)}return ZE(this.latestValues)&&uD(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=EE();qD(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!ZE(n.latestValues))continue;let r;n.instance&&(XE(n.latestValues)&&n.updateSnapshot(),r=EE(),qD(r,n.measurePageBox())),fO(t,n.latestValues,n.snapshot?.layoutBox,r)}return ZE(this.latestValues)&&fO(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Fx.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Fx.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=EE(),this.targetWithTransforms=EE()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),iO(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):qD(this.target,this.layout.layoutBox),rD(this.target,this.targetDelta)):qD(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),yE.value&&zO.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||XE(this.parent.latestValues)||QE(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=EE(),this.relativeTargetOrigin=EE(),oO(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),qD(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Fx.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;qD(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;oD(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=EE());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(JD(this.prevProjectionDelta.x,this.projectionDelta.x),JD(this.prevProjectionDelta.y,this.projectionDelta.y)),nO(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!bO(this.projectionDelta.x,this.prevProjectionDelta.x)||!bO(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),yE.value&&zO.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=wE(),this.projectionDelta=wE(),this.projectionDeltaWithTransform=wE()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=wE();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=EE(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!!(c&&!u&&this.options.crossfade===!0&&!this.path.some(uk));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=NS(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=NS(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(sk(o.x,e.x,n),sk(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(oO(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),lk(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&gO(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=EE(),qD(f,this.relativeTarget)),c&&(this.animationValues=a,EO(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Px(this.pendingAnimation),void 0),this.pendingAnimation=Nx.update(()=>{RO.hasAnimatedSinceResize=!0,this.motionValue||=Iw(0),this.motionValue.jump(0,!1),this.currentAnimation=jO(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(VO),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&gk(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||EE();let t=$D(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=$D(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}qD(t,n),uD(t,i),nO(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new LO),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&UO(`z`,e,r,this.animationValues);for(let t=0;t<BO.length;t++)UO(`rotate${BO[t]}`,e,r,this.animationValues),UO(`skew${BO[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=IO(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=IO(t?.pointerEvents)||``),this.hasProjected&&!ZE(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=SO(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in xD){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=xD[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?IO(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(ZO),this.root.sharedNodes.clear()}}}function KO(e){e.updateLayout()}function qO(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)xO(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=$D(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;KD(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else gk(i,t.layoutBox,n)&&xO(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=$D(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=wE();nO(o,n,t.layoutBox);let s=wE();a?nO(s,e.applyTransform(r,!0),t.measuredBox):nO(s,n,t.layoutBox);let c=!mO(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=EE();oO(s,t.layoutBox,i.layoutBox,o);let c=EE();oO(c,n,a.layoutBox,o),vO(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function JO(e){yE.value&&zO.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function YO(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function XO(e){e.clearSnapshot()}function ZO(e){e.clearMeasurements()}function QO(e){e.isLayoutDirty=!0,e.updateLayout()}function $O(e){e.isLayoutDirty=!1}function ek(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function tk(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function nk(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function rk(e){e.resolveTargetDelta()}function ik(e){e.calcProjection()}function ak(e){e.resetSkewAndRotation()}function ok(e){e.removeLeadSnapshot()}function sk(e,t,n){e.translate=NS(t.translate,0,n),e.scale=NS(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ck(e,t,n,r){e.min=NS(t.min,n.min,r),e.max=NS(t.max,n.max,r)}function lk(e,t,n,r){ck(e.x,t.x,n.x,r),ck(e.y,t.y,n.y,r)}function uk(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var dk={duration:.45,ease:[.4,0,.1,1]},fk=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),pk=fk(`applewebkit/`)&&!fk(`chrome/`)?Math.round:ex;function mk(e){e.min=pk(e.min),e.max=pk(e.max)}function hk(e){mk(e.x),mk(e.y)}function gk(e,t,n){return e===`position`||e===`preserve-aspect`&&!eO(yO(t),yO(n),.2)}function _k(e){return e!==e.root&&e.scroll?.wasRoot}var vk=GO({attachResizeListener:(e,t)=>MO(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),yk={current:void 0},bk=GO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!yk.current){let e=new vk({});e.mount(window),e.setOptions({layoutScroll:!0}),yk.current=e}return yk.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),xk=(0,R.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Sk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Ck(...e){return t=>{let n=!1,r=e.map(e=>{let r=Sk(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Sk(e[t],null)}}}}function wk(...e){return R.useCallback(Ck(...e),e)}var Tk=class extends R.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(LT(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=LT(e)&&e.offsetWidth||0,r=LT(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Ek({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,R.useId)(),s=(0,R.useRef)(null),c=(0,R.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,R.useContext)(xk),u=wk(s,e.props?.ref??e?.ref);return(0,R.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
171
171
|
[data-motion-pop-id="${o}"] {
|
|
172
172
|
position: absolute !important;
|
|
173
173
|
width: ${e}px !important;
|
|
@@ -175,12 +175,12 @@ ${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.t
|
|
|
175
175
|
${_}px !important;
|
|
176
176
|
${v}px !important;
|
|
177
177
|
}
|
|
178
|
-
`),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,z.jsx)(Tk,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:R.cloneElement(e,{ref:u})})}var Dk=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=Ub(Ok),d=(0,R.useId)(),f=(0,R.useRef)(n),p=(0,R.useRef)(r);Wb(()=>{f.current=n,p.current=r});let m=!0,h=(0,R.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,R.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),R.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,z.jsx)(Ek,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,z.jsx)(Gb.Provider,{value:h,children:e})};function Ok(){return new Map}function kk(e=!0){let t=(0,R.useContext)(Gb);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,R.useId)();(0,R.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,R.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Ak=e=>e.key||``;function jk(e){let t=[];return R.Children.forEach(e,e=>{(0,R.isValidElement)(e)&&t.push(e)}),t}var Mk=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=kk(o),f=(0,R.useMemo)(()=>jk(e),[e]),p=o&&!u?[]:f.map(Ak),m=(0,R.useRef)(!0),h=(0,R.useRef)(f),g=Ub(()=>new Map),_=(0,R.useRef)(new Set),[v,y]=(0,R.useState)(f),[b,x]=(0,R.useState)(f);Wb(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=Ak(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=Ak(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(jk(e)),y(f),null}let{forceRender:C}=(0,R.useContext)(Hb);return(0,z.jsx)(z.Fragment,{children:b.map(e=>{let v=Ak(e),y=o&&!u?!1:f===b||p.includes(v);return(0,z.jsx)(Dk,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},Nk=(0,R.createContext)({strict:!1}),Pk={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Fk=!1;function Ik(){if(Fk)return;let e={};for(let t in Pk)e[t]={isEnabled:e=>Pk[t].some(t=>!!e[t])};VE(e),Fk=!0}function Lk(){return Ik(),HE()}function Rk(e){let t=Lk();for(let n in e)t[n]={...t[n],...e[n]};VE(t)}var zk=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Bk(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||zk.has(e)}var Vk=t({default:()=>Hk}),Hk,Uk=s((()=>{throw Hk={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Wk=e=>!Bk(e);function Gk(e){typeof e==`function`&&(Wk=t=>t.startsWith(`on`)?!Bk(t):e(t))}try{Gk((Uk(),l(Vk)).default)}catch{}function Kk(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||iT(e[i])||(Wk(i)||n===!0&&Bk(i)||!t&&!Bk(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var qk=(0,R.createContext)({});function Jk(e,t){if(ME(e)){let{initial:t,animate:n}=e;return{initial:t===!1||kE(t)?t:void 0,animate:kE(n)?n:void 0}}return e.inherit===!1?{}:t}function Yk(e){let{initial:t,animate:n}=Jk(e,(0,R.useContext)(qk));return(0,R.useMemo)(()=>({initial:t,animate:n}),[Xk(t),Xk(n)])}function Xk(e){return Array.isArray(e)?e.join(` `):e}var Zk=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Qk(e,t,n){for(let r in t)!iT(t[r])&&!SD(r,n)&&(e[r]=t[r])}function $k({transformTemplate:e},t){return(0,R.useMemo)(()=>{let n=Zk();return gD(n,t,e),Object.assign({},n.vars,n.style)},[t])}function eA(e,t){let n=e.style||{},r={};return Qk(r,n,e),Object.assign(r,$k(e,t)),r}function tA(e,t){let n={},r=eA(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var nA=()=>({...Zk(),attrs:{}});function rA(e,t,n,r){let i=(0,R.useMemo)(()=>{let n=nA();return AD(n,t,MD(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Qk(t,e.style,e),i.style={...t,...i.style}}return i}var iA=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function aA(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(iA.indexOf(e)>-1||/[A-Z]/u.test(e))}function oA(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??aA(e)?rA:tA)(t,r,i,e),c=Kk(t,typeof e==`string`,a),l=e===R.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,R.useMemo)(()=>iT(u)?u.get():u,[u]);return(0,R.createElement)(e,{...l,children:d})}function sA({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:cA(n,r,i,e),renderState:t()}}function cA(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=IO(a[e]);let{initial:o,animate:s}=e,c=ME(e),l=NE(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!OE(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Zw(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var lA=e=>(t,n)=>{let r=(0,R.useContext)(qk),i=(0,R.useContext)(Gb),a=()=>sA(e,t,r,i);return n?a():Ub(a)},uA=lA({scrapeMotionValuesFromProps:CD,createRenderState:Zk}),dA=lA({scrapeMotionValuesFromProps:PD,createRenderState:nA}),fA=Symbol.for(`motionComponentSymbol`);function pA(e,t,n){let r=(0,R.useRef)(n);(0,R.useInsertionEffect)(()=>{r.current=n});let i=(0,R.useRef)(null);return(0,R.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var mA=(0,R.createContext)({});function hA(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function gA(e,t,n,r,i,a){let{visualElement:o}=(0,R.useContext)(qk),s=(0,R.useContext)(Nk),c=(0,R.useContext)(Gb),l=(0,R.useContext)(xk),u=l.reducedMotion,d=l.skipAnimations,f=(0,R.useRef)(null),p=(0,R.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,R.useContext)(mA);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&_A(f.current,n,i,h);let g=(0,R.useRef)(!1);(0,R.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[cT],v=(0,R.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Wb(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,R.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function _A(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:vA(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&hA(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function vA(e){if(e)return e.options.allowProjection===!1?vA(e.parent):e.projection}function yA(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Rk(r);let a=n?n===`svg`:aA(e),o=a?dA:uA;function s(n,s){let c,l={...(0,R.useContext)(xk),...n,layoutId:bA(n)},{isStatic:u}=l,d=Yk(n),f=o(n,u);if(!u&&typeof window<`u`){xA(l,r);let t=SA(l);c=t.MeasureLayout,d.visualElement=gA(e,f,l,i,t.ProjectionNode,a)}return(0,z.jsxs)(qk.Provider,{value:d,children:[c&&d.visualElement?(0,z.jsx)(c,{visualElement:d.visualElement,...l}):null,oA(e,n,pA(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,R.forwardRef)(s);return c[fA]=e,c}function bA({layoutId:e}){let t=(0,R.useContext)(Hb).id;return t&&e!==void 0?t+`-`+e:e}function xA(e,t){(0,R.useContext)(Nk).strict}function SA(e){let{drag:t,layout:n}=Lk();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function CA(e,t){if(typeof Proxy>`u`)return yA;let n=new Map,r=(n,r)=>yA(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,yA(a,void 0,e,t)),n.get(a))})}var wA=(e,t)=>t.isSVG??aA(e)?new FD(t):new TD(t,{allowProjection:e!==R.Fragment}),TA=class extends GE{constructor(e){super(e),e.animationState||=HD(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();OE(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},EA=0,DA={animation:{Feature:TA},exit:{Feature:class extends GE{constructor(){super(...arguments),this.id=EA++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=Qw(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function OA(e){return{point:{x:e.pageX,y:e.pageY}}}var kA=e=>t=>KT(t)&&e(t,OA(t));function AA(e,t,n,r){return MO(e,t,kA(n),r)}var jA=({current:e})=>e?e.ownerDocument.defaultView:null,MA=(e,t)=>Math.abs(e-t);function NA(e,t){let n=MA(e.x,t.x),r=MA(e.y,t.y);return Math.sqrt(n**2+r**2)}var PA=new Set([`auto`,`scroll`]),FA=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=IA(this.lastRawMoveEventInfo,this.transformPagePoint));let e=RA(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=NA(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Fx;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=IA(t,this.transformPagePoint),Nx.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=RA(e.type===`pointercancel`?this.lastMoveEventInfo:IA(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!KT(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=IA(OA(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Fx;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,RA(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=tx(AA(this.contextWindow,`pointermove`,this.handlePointerMove,d),AA(this.contextWindow,`pointerup`,this.handlePointerUp,d),AA(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(PA.has(e.overflowX)||PA.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Nx.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Px(this.updatePoint)}};function IA(e,t){return t?{point:t(e.point)}:e}function LA(e,t){return{x:e.x-t.x,y:e.y-t.y}}function RA({point:e},t){return{point:e,delta:LA(e,zA(t)),offset:LA(e,wee(t)),velocity:Tee(t,.1)}}function wee(e){return e[0]}function zA(e){return e[e.length-1]}function Tee(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=zA(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>ix(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>ix(t)*2&&(r=e[1]);let a=ax(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Eee(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?NS(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?NS(n,e,r.max):Math.min(e,n)),e}function BA(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Dee(e,{top:t,left:n,bottom:r,right:i}){return{x:BA(e.x,n,i),y:BA(e.y,t,r)}}function VA(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Oee(e,t){return{x:VA(e.x,t.x),y:VA(e.y,t.y)}}function kee(e,t){let n=.5,r=$D(e),i=$D(t);return i>r?n=nx(t.min,t.max-r,e.min):r>i&&(n=nx(e.min,e.max-i,t.min)),Jb(0,1,n)}function Aee(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var HA=.35;function jee(e=HA){return e===!1?e=0:e===!0&&(e=HA),{x:UA(e,`left`,`right`),y:UA(e,`top`,`bottom`)}}function UA(e,t,n){return{min:WA(e,t),max:WA(e,n)}}function WA(e,t){return typeof e==`number`?e:e[t]||0}var Mee=new WeakMap,Nee=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=EE(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(OA(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=VT(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),xO(e=>{let t=this.getAxisMotionValue(e).get()||0;if(cS.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=$D(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Nx.update(()=>i(e,t),!1,!0),oT(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Fee(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&Nx.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new FA(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:jA(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&Nx.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!KA(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Eee(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&hA(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Dee(n.layoutBox,e):this.constraints=!1,this.elastic=jee(t),r!==this.constraints&&!hA(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&xO(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Aee(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!hA(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=fD(n,r.root,this.visualElement.getTransformPagePoint()),a=Oee(r.layout.layoutBox,i);if(t){let e=t(qE(a));this.hasMutatedConstraints=!!e,e&&(a=KE(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=xO(o=>{if(!KA(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return oT(this.visualElement,e),n.start(Kw(e,n,0,t,this.visualElement,!1))}stopAnimation(){xO(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){xO(t=>{let{drag:n}=this.getProps();if(!KA(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-NS(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!hA(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};xO(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=kee({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),xO(t=>{if(!KA(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(NS(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Mee.set(this.visualElement,this);let e=this.visualElement.current,t=AA(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&XT(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();hA(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Pee(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Nx.read(r);let o=MO(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(xO(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=HA,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function GA(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Pee(e,t,n){let r=vE(e,GA(n)),i=vE(t,GA(n));return()=>{r(),i()}}function KA(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Fee(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var qA=class extends GE{constructor(e){super(e),this.removeGroupControls=ex,this.removeListeners=ex,this.controls=new Nee(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ex}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},JA=e=>(t,n)=>{e&&Nx.update(()=>e(t,n),!1,!0)},YA=class extends GE{constructor(){super(...arguments),this.removePointerDownListener=ex}onPointerDown(e){this.session=new FA(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:jA(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:JA(e),onStart:JA(t),onMove:JA(n),onEnd:(e,t)=>{delete this.session,r&&Nx.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=AA(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},XA=!1,ZA=class extends R.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),XA&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),RO.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),XA=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Nx.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),RT.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;XA=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function QA(e){let[t,n]=kk(),r=(0,R.useContext)(Hb);return(0,z.jsx)(ZA,{...e,layoutGroup:r,switchLayoutGroup:(0,R.useContext)(mA),isPresent:t,safeToRemove:n})}var $A={pan:{Feature:YA},drag:{Feature:qA,ProjectionNode:bk,MeasureLayout:QA}};function ej(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Nx.postRender(()=>i(t,OA(t)))}var tj=class extends GE{mount(){let{current:e}=this.node;e&&(this.unmount=WT(e,(e,t)=>(ej(this.node,t,`Start`),e=>ej(this.node,e,`End`))))}unmount(){}},nj=class extends GE{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=tx(MO(this.node.current,`focus`,()=>this.onFocus()),MO(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function rj(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Nx.postRender(()=>i(t,OA(t)))}var ij=class extends GE{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=rE(e,(e,t)=>(rj(this.node,t,`Start`),(e,{success:t})=>rj(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},aj=new WeakMap,oj=new WeakMap,sj=e=>{let t=aj.get(e.target);t&&t(e)},cj=e=>{e.forEach(sj)};function lj({root:e,...t}){let n=e||document;oj.has(n)||oj.set(n,{});let r=oj.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(cj,{root:e,...t})),r[i]}function uj(e,t,n){let r=lj(t);return aj.set(e,n),r.observe(e),()=>{aj.delete(e),r.unobserve(e)}}var dj={some:0,all:1},fj=class extends GE{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:dj[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=uj(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(pj(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function pj({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var mj={inView:{Feature:fj},tap:{Feature:ij},focus:{Feature:nj},hover:{Feature:tj}},hj={layout:{ProjectionNode:bk,MeasureLayout:QA}},gj=CA({...DA,...mj,...$A,...hj},wA);function _j(){!IE.current&&RE();let[e]=(0,R.useState)(FE.current);return e}function vj(e){e.values.forEach(e=>e.stop())}function yj(e,t){[...t].reverse().forEach(n=>{let r=e.getVariant(n);r&&rT(e,r),e.variantChildren&&e.variantChildren.forEach(e=>{yj(e,t)})})}function bj(e,t){if(Array.isArray(t))return yj(e,t);if(typeof t==`string`)return yj(e,[t]);rT(e,t)}function xj(){let e=new Set,t={subscribe(t){return e.add(t),()=>void e.delete(t)},start(t,n){let r=[];return e.forEach(e=>{r.push(mT(e,t,{transitionOverride:n}))}),Promise.all(r)},set(t){return e.forEach(e=>{bj(e,t)})},stop(){e.forEach(e=>{vj(e)})},mount(){return()=>{t.stop()}}};return t}function Sj(){let e=Ub(xj);return Wb(e.mount,[]),e}var Cj=Sj,G=jt(),wj=gj,Tj={damping:.7,stiffness:.05,mass:1.25},Ej=70,Dj=1e3/60,Oj=350,kj=!1;globalThis.document?.addEventListener(`mousedown`,()=>{kj=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{kj=!1}),globalThis.document?.addEventListener(`click`,()=>{kj=!1});var Aj=(e={})=>{let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(e.initial!==!1),[a,o]=(0,R.useState)(!1),s=(0,R.useRef)(null);s.current=e;let c=(0,R.useCallback)(()=>{if(!kj)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,R.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,R.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,R.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Ej}}},[]),f=(0,R.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Nj(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/Dj;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Nj(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,R.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,R.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,R.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=jj(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=jj(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=Nj(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:Oj})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function jj(e,t){let n=(0,R.useCallback)(t=>(n.current=t,e(t)),t);return n}var Mj=new Map;function Nj(...e){let t={...Tj},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return Mj.has(r)||Mj.set(r,Object.freeze(t)),n?`instant`:Mj.get(r)}var Pj=new Set([`name`,`id`,`aria-describedby`,`aria-labelledby`]);function Fj(e){let t=new Set;for(let{name:n}of e){if(t.has(n))return n;t.add(n)}}function Ij(e){let t=e.allowedAttributes.filter(e=>Pj.has(e));if(t.length>0)throw Error(`Interactive element <${e.name}> declares reserved attribute(s) ${t.join(`, `)}. The markdown sanitizer rewrites these to "user-content-<value>" (DOM-clobbering protection), so the component would receive a mangled value. Use a domain attribute instead (e.g. "param").`)}var Lj=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,Rj=L().min(1).max(64).regex(Lj).refine(e=>!Pj.has(e),{error:`Attribute is reserved: the markdown sanitizer rewrites it to "user-content-<value>". Use a domain attribute instead (e.g. "param").`}),zj=Me({name:L().min(1).max(64).regex(Lj),description:L().max(512).optional(),allowedAttributes:Zt(Rj).max(20)});Zt(zj).max(100).superRefine((e,t)=>{let n=Fj(e);n!==void 0&&t.addIssue({code:`custom`,message:`Duplicate element name "${n}": a catalog must map each tag to exactly one element.`})}).optional();function Bj(e){let{name:t,allowedAttributes:n,description:r}=e;return{name:t,allowedAttributes:n,description:r}}function Vj(e){for(let t of e){let e=zj.safeParse(Bj(t));if(!e.success)throw Error(`Interactive element <${t.name}> is invalid:
|
|
178
|
+
`),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,z.jsx)(Tk,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:R.cloneElement(e,{ref:u})})}var Dk=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=Ub(Ok),d=(0,R.useId)(),f=(0,R.useRef)(n),p=(0,R.useRef)(r);Wb(()=>{f.current=n,p.current=r});let m=!0,h=(0,R.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,R.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),R.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,z.jsx)(Ek,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,z.jsx)(Gb.Provider,{value:h,children:e})};function Ok(){return new Map}function kk(e=!0){let t=(0,R.useContext)(Gb);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,R.useId)();(0,R.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,R.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Ak=e=>e.key||``;function jk(e){let t=[];return R.Children.forEach(e,e=>{(0,R.isValidElement)(e)&&t.push(e)}),t}var Mk=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=kk(o),f=(0,R.useMemo)(()=>jk(e),[e]),p=o&&!u?[]:f.map(Ak),m=(0,R.useRef)(!0),h=(0,R.useRef)(f),g=Ub(()=>new Map),_=(0,R.useRef)(new Set),[v,y]=(0,R.useState)(f),[b,x]=(0,R.useState)(f);Wb(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=Ak(b[e]);p.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,p.length,p.join(`-`)]);let S=[];if(f!==v){let e=[...f];for(let t=0;t<b.length;t++){let n=b[t],r=Ak(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(jk(e)),y(f),null}let{forceRender:C}=(0,R.useContext)(Hb);return(0,z.jsx)(z.Fragment,{children:b.map(e=>{let v=Ak(e),y=o&&!u?!1:f===b||p.includes(v);return(0,z.jsx)(Dk,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(_.current.has(v))return;if(g.has(v))_.current.add(v),g.set(v,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),x(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},v)})})},Nk=(0,R.createContext)({strict:!1}),Pk={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Fk=!1;function Ik(){if(Fk)return;let e={};for(let t in Pk)e[t]={isEnabled:e=>Pk[t].some(t=>!!e[t])};VE(e),Fk=!0}function Lk(){return Ik(),HE()}function Rk(e){let t=Lk();for(let n in e)t[n]={...t[n],...e[n]};VE(t)}var zk=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Bk(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||zk.has(e)}var Vk=t({default:()=>Hk}),Hk,Uk=s((()=>{throw Hk={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Wk=e=>!Bk(e);function Gk(e){typeof e==`function`&&(Wk=t=>t.startsWith(`on`)?!Bk(t):e(t))}try{Gk((Uk(),l(Vk)).default)}catch{}function Kk(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||iT(e[i])||(Wk(i)||n===!0&&Bk(i)||!t&&!Bk(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var qk=(0,R.createContext)({});function Jk(e,t){if(ME(e)){let{initial:t,animate:n}=e;return{initial:t===!1||kE(t)?t:void 0,animate:kE(n)?n:void 0}}return e.inherit===!1?{}:t}function Yk(e){let{initial:t,animate:n}=Jk(e,(0,R.useContext)(qk));return(0,R.useMemo)(()=>({initial:t,animate:n}),[Xk(t),Xk(n)])}function Xk(e){return Array.isArray(e)?e.join(` `):e}var Zk=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Qk(e,t,n){for(let r in t)!iT(t[r])&&!SD(r,n)&&(e[r]=t[r])}function $k({transformTemplate:e},t){return(0,R.useMemo)(()=>{let n=Zk();return gD(n,t,e),Object.assign({},n.vars,n.style)},[t])}function eA(e,t){let n=e.style||{},r={};return Qk(r,n,e),Object.assign(r,$k(e,t)),r}function tA(e,t){let n={},r=eA(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var nA=()=>({...Zk(),attrs:{}});function rA(e,t,n,r){let i=(0,R.useMemo)(()=>{let n=nA();return AD(n,t,MD(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Qk(t,e.style,e),i.style={...t,...i.style}}return i}var iA=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function aA(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(iA.indexOf(e)>-1||/[A-Z]/u.test(e))}function oA(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??aA(e)?rA:tA)(t,r,i,e),c=Kk(t,typeof e==`string`,a),l=e===R.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,R.useMemo)(()=>iT(u)?u.get():u,[u]);return(0,R.createElement)(e,{...l,children:d})}function sA({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:cA(n,r,i,e),renderState:t()}}function cA(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=IO(a[e]);let{initial:o,animate:s}=e,c=ME(e),l=NE(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!OE(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Zw(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var lA=e=>(t,n)=>{let r=(0,R.useContext)(qk),i=(0,R.useContext)(Gb),a=()=>sA(e,t,r,i);return n?a():Ub(a)},uA=lA({scrapeMotionValuesFromProps:CD,createRenderState:Zk}),dA=lA({scrapeMotionValuesFromProps:PD,createRenderState:nA}),fA=Symbol.for(`motionComponentSymbol`);function pA(e,t,n){let r=(0,R.useRef)(n);(0,R.useInsertionEffect)(()=>{r.current=n});let i=(0,R.useRef)(null);return(0,R.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n)},[t])}var mA=(0,R.createContext)({});function hA(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function gA(e,t,n,r,i,a){let{visualElement:o}=(0,R.useContext)(qk),s=(0,R.useContext)(Nk),c=(0,R.useContext)(Gb),l=(0,R.useContext)(xk),u=l.reducedMotion,d=l.skipAnimations,f=(0,R.useRef)(null),p=(0,R.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,R.useContext)(mA);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&_A(f.current,n,i,h);let g=(0,R.useRef)(!1);(0,R.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[cT],v=(0,R.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Wb(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,R.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function _A(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:vA(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&hA(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function vA(e){if(e)return e.options.allowProjection===!1?vA(e.parent):e.projection}function yA(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Rk(r);let a=n?n===`svg`:aA(e),o=a?dA:uA;function s(n,s){let c,l={...(0,R.useContext)(xk),...n,layoutId:bA(n)},{isStatic:u}=l,d=Yk(n),f=o(n,u);if(!u&&typeof window<`u`){xA(l,r);let t=SA(l);c=t.MeasureLayout,d.visualElement=gA(e,f,l,i,t.ProjectionNode,a)}return(0,z.jsxs)(qk.Provider,{value:d,children:[c&&d.visualElement?(0,z.jsx)(c,{visualElement:d.visualElement,...l}):null,oA(e,n,pA(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,R.forwardRef)(s);return c[fA]=e,c}function bA({layoutId:e}){let t=(0,R.useContext)(Hb).id;return t&&e!==void 0?t+`-`+e:e}function xA(e,t){(0,R.useContext)(Nk).strict}function SA(e){let{drag:t,layout:n}=Lk();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function CA(e,t){if(typeof Proxy>`u`)return yA;let n=new Map,r=(n,r)=>yA(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,yA(a,void 0,e,t)),n.get(a))})}var wA=(e,t)=>t.isSVG??aA(e)?new FD(t):new TD(t,{allowProjection:e!==R.Fragment}),TA=class extends GE{constructor(e){super(e),e.animationState||=HD(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();OE(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},EA=0,DA={animation:{Feature:TA},exit:{Feature:class extends GE{constructor(){super(...arguments),this.id=EA++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=Qw(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function OA(e){return{point:{x:e.pageX,y:e.pageY}}}var kA=e=>t=>KT(t)&&e(t,OA(t));function AA(e,t,n,r){return MO(e,t,kA(n),r)}var jA=({current:e})=>e?e.ownerDocument.defaultView:null,MA=(e,t)=>Math.abs(e-t);function NA(e,t){let n=MA(e.x,t.x),r=MA(e.y,t.y);return Math.sqrt(n**2+r**2)}var PA=new Set([`auto`,`scroll`]),FA=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=IA(this.lastRawMoveEventInfo,this.transformPagePoint));let e=RA(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=NA(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Fx;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=IA(t,this.transformPagePoint),Nx.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=RA(e.type===`pointercancel`?this.lastMoveEventInfo:IA(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!KT(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=IA(OA(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Fx;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,RA(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=tx(AA(this.contextWindow,`pointermove`,this.handlePointerMove,d),AA(this.contextWindow,`pointerup`,this.handlePointerUp,d),AA(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(PA.has(e.overflowX)||PA.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Nx.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Px(this.updatePoint)}};function IA(e,t){return t?{point:t(e.point)}:e}function LA(e,t){return{x:e.x-t.x,y:e.y-t.y}}function RA({point:e},t){return{point:e,delta:LA(e,BA(t)),offset:LA(e,zA(t)),velocity:wee(t,.1)}}function zA(e){return e[0]}function BA(e){return e[e.length-1]}function wee(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=BA(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>ix(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>ix(t)*2&&(r=e[1]);let a=ax(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Tee(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?NS(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?NS(n,e,r.max):Math.min(e,n)),e}function VA(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Eee(e,{top:t,left:n,bottom:r,right:i}){return{x:VA(e.x,n,i),y:VA(e.y,t,r)}}function HA(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Dee(e,t){return{x:HA(e.x,t.x),y:HA(e.y,t.y)}}function Oee(e,t){let n=.5,r=$D(e),i=$D(t);return i>r?n=nx(t.min,t.max-r,e.min):r>i&&(n=nx(e.min,e.max-i,t.min)),Jb(0,1,n)}function kee(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var UA=.35;function Aee(e=UA){return e===!1?e=0:e===!0&&(e=UA),{x:WA(e,`left`,`right`),y:WA(e,`top`,`bottom`)}}function WA(e,t,n){return{min:GA(e,t),max:GA(e,n)}}function GA(e,t){return typeof e==`number`?e:e[t]||0}var jee=new WeakMap,Mee=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=EE(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(OA(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=VT(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),xO(e=>{let t=this.getAxisMotionValue(e).get()||0;if(cS.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=$D(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Nx.update(()=>i(e,t),!1,!0),oT(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Pee(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&Nx.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new FA(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:jA(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&Nx.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!qA(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Tee(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&hA(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Eee(n.layoutBox,e):this.constraints=!1,this.elastic=Aee(t),r!==this.constraints&&!hA(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&xO(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=kee(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!hA(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=fD(n,r.root,this.visualElement.getTransformPagePoint()),a=Dee(r.layout.layoutBox,i);if(t){let e=t(qE(a));this.hasMutatedConstraints=!!e,e&&(a=KE(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=xO(o=>{if(!qA(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return oT(this.visualElement,e),n.start(Kw(e,n,0,t,this.visualElement,!1))}stopAnimation(){xO(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){xO(t=>{let{drag:n}=this.getProps();if(!qA(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-NS(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!hA(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};xO(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Oee({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),xO(t=>{if(!qA(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(NS(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;jee.set(this.visualElement,this);let e=this.visualElement.current,t=AA(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&XT(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();hA(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Nee(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Nx.read(r);let o=MO(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(xO(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=UA,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function KA(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Nee(e,t,n){let r=vE(e,KA(n)),i=vE(t,KA(n));return()=>{r(),i()}}function qA(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Pee(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Fee=class extends GE{constructor(e){super(e),this.removeGroupControls=ex,this.removeListeners=ex,this.controls=new Mee(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ex}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},JA=e=>(t,n)=>{e&&Nx.update(()=>e(t,n),!1,!0)},YA=class extends GE{constructor(){super(...arguments),this.removePointerDownListener=ex}onPointerDown(e){this.session=new FA(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:jA(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:JA(e),onStart:JA(t),onMove:JA(n),onEnd:(e,t)=>{delete this.session,r&&Nx.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=AA(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},XA=!1,ZA=class extends R.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),XA&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),RO.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),XA=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Nx.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),RT.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;XA=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function QA(e){let[t,n]=kk(),r=(0,R.useContext)(Hb);return(0,z.jsx)(ZA,{...e,layoutGroup:r,switchLayoutGroup:(0,R.useContext)(mA),isPresent:t,safeToRemove:n})}var $A={pan:{Feature:YA},drag:{Feature:Fee,ProjectionNode:bk,MeasureLayout:QA}};function ej(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Nx.postRender(()=>i(t,OA(t)))}var tj=class extends GE{mount(){let{current:e}=this.node;e&&(this.unmount=WT(e,(e,t)=>(ej(this.node,t,`Start`),e=>ej(this.node,e,`End`))))}unmount(){}},nj=class extends GE{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=tx(MO(this.node.current,`focus`,()=>this.onFocus()),MO(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function rj(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Nx.postRender(()=>i(t,OA(t)))}var ij=class extends GE{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=rE(e,(e,t)=>(rj(this.node,t,`Start`),(e,{success:t})=>rj(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},aj=new WeakMap,oj=new WeakMap,sj=e=>{let t=aj.get(e.target);t&&t(e)},cj=e=>{e.forEach(sj)};function lj({root:e,...t}){let n=e||document;oj.has(n)||oj.set(n,{});let r=oj.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(cj,{root:e,...t})),r[i]}function uj(e,t,n){let r=lj(t);return aj.set(e,n),r.observe(e),()=>{aj.delete(e),r.unobserve(e)}}var dj={some:0,all:1},fj=class extends GE{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:dj[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=uj(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(pj(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function pj({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var mj={inView:{Feature:fj},tap:{Feature:ij},focus:{Feature:nj},hover:{Feature:tj}},hj={layout:{ProjectionNode:bk,MeasureLayout:QA}},gj=CA({...DA,...mj,...$A,...hj},wA);function _j(){!IE.current&&RE();let[e]=(0,R.useState)(FE.current);return e}function vj(e){e.values.forEach(e=>e.stop())}function yj(e,t){[...t].reverse().forEach(n=>{let r=e.getVariant(n);r&&rT(e,r),e.variantChildren&&e.variantChildren.forEach(e=>{yj(e,t)})})}function bj(e,t){if(Array.isArray(t))return yj(e,t);if(typeof t==`string`)return yj(e,[t]);rT(e,t)}function xj(){let e=new Set,t={subscribe(t){return e.add(t),()=>void e.delete(t)},start(t,n){let r=[];return e.forEach(e=>{r.push(mT(e,t,{transitionOverride:n}))}),Promise.all(r)},set(t){return e.forEach(e=>{bj(e,t)})},stop(){e.forEach(e=>{vj(e)})},mount(){return()=>{t.stop()}}};return t}function Sj(){let e=Ub(xj);return Wb(e.mount,[]),e}var Cj=Sj,G=jt(),wj=gj,Tj={damping:.7,stiffness:.05,mass:1.25},Ej=70,Dj=1e3/60,Oj=350,kj=!1;globalThis.document?.addEventListener(`mousedown`,()=>{kj=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{kj=!1}),globalThis.document?.addEventListener(`click`,()=>{kj=!1});var Aj=(e={})=>{let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(e.initial!==!1),[a,o]=(0,R.useState)(!1),s=(0,R.useRef)(null);s.current=e;let c=(0,R.useCallback)(()=>{if(!kj)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,R.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,R.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,R.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Ej}}},[]),f=(0,R.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Nj(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/Dj;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Nj(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,R.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,R.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,R.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=jj(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=jj(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=Nj(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:Oj})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function jj(e,t){let n=(0,R.useCallback)(t=>(n.current=t,e(t)),t);return n}var Mj=new Map;function Nj(...e){let t={...Tj},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return Mj.has(r)||Mj.set(r,Object.freeze(t)),n?`instant`:Mj.get(r)}var Pj=new Set([`name`,`id`,`aria-describedby`,`aria-labelledby`]);function Fj(e){let t=new Set;for(let{name:n}of e){if(t.has(n))return n;t.add(n)}}function Ij(e){let t=e.allowedAttributes.filter(e=>Pj.has(e));if(t.length>0)throw Error(`Interactive element <${e.name}> declares reserved attribute(s) ${t.join(`, `)}. The markdown sanitizer rewrites these to "user-content-<value>" (DOM-clobbering protection), so the component would receive a mangled value. Use a domain attribute instead (e.g. "param").`)}var Lj=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,Rj=L().min(1).max(64).regex(Lj).refine(e=>!Pj.has(e),{error:`Attribute is reserved: the markdown sanitizer rewrites it to "user-content-<value>". Use a domain attribute instead (e.g. "param").`}),zj=Me({name:L().min(1).max(64).regex(Lj),description:L().max(512).optional(),allowedAttributes:Zt(Rj).max(20)});Zt(zj).max(100).superRefine((e,t)=>{let n=Fj(e);n!==void 0&&t.addIssue({code:`custom`,message:`Duplicate element name "${n}": a catalog must map each tag to exactly one element.`})}).optional();function Bj(e){let{name:t,allowedAttributes:n,description:r}=e;return{name:t,allowedAttributes:n,description:r}}function Vj(e){for(let t of e){let e=zj.safeParse(Bj(t));if(!e.success)throw Error(`Interactive element <${t.name}> is invalid:
|
|
179
179
|
${At(e.error)}`)}let t=Fj(e);if(t!==void 0)throw Error(`Duplicate element name <${t}>: a catalog must map each tag to exactly one element.`);return[...e]}var Hj={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function Uj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function Wj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function Gj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function Kj(e){return Gj(e)||Uj(e)}var qj=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function Jj(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?Kj:u===`decimal`?Uj:Wj;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&Tl.includes(y)&&(_=y,v=xr(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&xr(y);e&&(_=y,v=e)}let S=1+l-o,C=``;if(!(!x&&n.nonTerminated===!1))if(!y)u!==`named`&&h(4,S);else if(u===`named`){if(x&&!v)h(5,1);else if(_!==y&&(l=c+_.length,S=1+l-c,x=!1),!x){let t=_?1:3;if(n.attribute){let n=e.charCodeAt(l);n===61?(h(t,S),v=``):Kj(n)?v=``:h(t,S)}else h(t,S)}C=v}else{x||h(2,S);let e=Number.parseInt(y,u===`hexadecimal`?16:10);if(Yj(e))h(7,S),C=`�`;else if(e in Hj)h(6,S),C=Hj[e];else{let t=``;Xj(e)&&h(6,S),e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10|55296),e=56320|e&1023),C=t+String.fromCharCode(e)}}if(C){g(),f=m(),a=l-1,d+=l-o+1,i.push(C);let t=m();t.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,C,{start:f,end:t},e.slice(o-1,l)),f=t}else y=e.slice(o-1,l),s+=y,d+=y.length,a=l-1}else p===10&&(u++,o++,d=0),Number.isNaN(p)?g():(s+=String.fromCharCode(p),d++);return i.join(``);function m(){return{line:u,column:d,offset:a+((c?c.offset:0)||0)}}function h(e,t){let r;n.warning&&(r=m(),r.column+=t,r.offset+=t,n.warning.call(n.warningContext||void 0,qj[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function Yj(e){return e>=55296&&e<=57343||e>1114111}function Xj(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}var Zj={}.hasOwnProperty,Qj={},$j={},eM=/^[^\t\n\r "#'.<=>`}]+$/,tM=/^[^\t\n\r "'<=>`}]+$/;function nM(e){let t=e||Qj;return{canContainEols:[`textDirective`],enter:{directiveContainer:iM,directiveContainerAttributes:fM,directiveContainerLabel:lM,directiveLeaf:aM,directiveLeafAttributes:fM,directiveText:oM,directiveTextAttributes:fM},exit:{directiveContainer:CM,directiveContainerAttributeClass:pM,directiveContainerAttributeClassValue:gM,directiveContainerAttributeId:pM,directiveContainerAttributeIdValue:hM,directiveContainerAttributeName:vM,directiveContainerAttributeValue:_M,directiveContainerAttributeValueLiteral:mM,directiveContainerAttributes:yM,directiveContainerLabel:uM,directiveContainerName:cM,directiveContainerSequence:n,directiveLeaf:CM,directiveLeafAttributeClass:pM,directiveLeafAttributeClassValue:gM,directiveLeafAttributeId:pM,directiveLeafAttributeIdValue:hM,directiveLeafAttributeName:vM,directiveLeafAttributeValue:_M,directiveLeafAttributeValueLiteral:mM,directiveLeafAttributes:yM,directiveLeafLabel:dM,directiveLeafName:cM,directiveLeafSequence:n,directiveText:CM,directiveTextAttributeClass:pM,directiveTextAttributeClassValue:gM,directiveTextAttributeId:pM,directiveTextAttributeIdValue:hM,directiveTextAttributeName:vM,directiveTextAttributeValue:_M,directiveTextAttributeValueLiteral:mM,directiveTextAttributes:yM,directiveTextLabel:dM,directiveTextMarker:n,directiveTextName:cM}};function n(e){if(!t.verbose)return;let n=this.stack[this.stack.length-1];n.type===`containerDirective`||n.type===`leafDirective`||n.type;let r={start:SM(e.start),end:SM(e.end)};n.data&&n.data.position?(n.type,n.data.position.closing=r):n.data={position:{opening:r}}}}function rM(e){let t=e||$j;if(t.quote!==`"`&&t.quote!==`'`&&t.quote!==null&&t.quote!==void 0)throw Error("Invalid quote `"+t.quote+"`, expected `'` or `\"`");return n.peek=wM,{handlers:{containerDirective:n,leafDirective:n,textDirective:n},unsafe:[{character:`\r`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{character:`
|
|
180
180
|
`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{after:`[^\\s\\p{P}\\p{S}]`,before:`[^:]`,character:`:`,inConstruct:[`phrasing`],unicode:!0},{afterNode:`textDirective`,character:`:`,inConstruct:[`phrasing`]},{atBreak:!0,before:`:+`,character:`:`}]};function n(e,t,n,i){let a=n.createTracker(i),o=n.enter(e.type),s;if(e.type===`containerDirective`){let t=(e.children||[])[0],r=EM(t)?e.children.slice(1):e.children;if(r&&r.length>0){let t=a.current();s=n.containerFlow({...e,children:r},{now:{line:t.now.line+1,column:1+t.lineShift},lineShift:t.lineShift})}}let c=DM(e,s?OM(s):0),l=a.move(c+(e.name||``)),u=r(e,n),d=i.after.charCodeAt(0),f;if(e.type===`containerDirective`){let t=(e.children||[])[0];f=EM(t)?t:void 0}else f=e;if(f&&f.children&&f.children.length>0){let t=n.enter(`label`),r=`${e.type}Label`,i=n.enter(r);l+=a.move(`[`),l+=a.move(n.containerPhrasing(f,{...a.current(),before:l,after:`]`})),l+=a.move(`]`),i(),t()}else!u&&(d===45||d===58||d===95||!(kr(d)||br(d)))&&(l+=a.move(`[]`));return l+=a.move(u||(d===123?`{}`:``)),e.type===`containerDirective`&&(s&&(l+=a.move(`
|
|
181
181
|
`+s)),l+=a.move(`
|
|
182
182
|
`+c)),o(),l}function r(e,n){let r=e.attributes||{},a=[],o,s,c,l;for(l in r)if(Zj.call(r,l)&&r[l]!==void 0&&r[l]!==null){let u=TM(String(r[l]));if(l===`id`)c=t.preferShortcut!==!1&&eM.test(u)?`#`+u:i(`id`,u,e,n);else if(l===`class`){let r=u.split(/[\t\n\r ]+/),a=[],c=[];for(let e of r)(t.preferShortcut!==!1&&eM.test(e)?c:a).push(e);o=a.length>0?i(`class`,a.join(` `),e,n):``,s=c.length>0?`.`+c.join(`.`):``}else a.push(i(l,u,e,n))}return o&&a.unshift(o),s&&a.unshift(s),c&&a.unshift(c),a.length>0?`{`+a.join(` `)+`}`:``}function i(e,n,r,i){if(t.collapseEmptyAttributes!==!1&&!n)return e;if(t.preferUnquoted&&tM.test(n))return e+`=`+n;let a=t.quote||i.options.quote||`"`,o=a===`"`?`'`:`"`,s=t.quoteSmart&&zr(n,a)>zr(n,o)?o:a,c=r.type===`textDirective`?[s]:[s,`
|
|
183
|
-
`,`\r`];return e+`=`+s+Il(n,{subset:c})+s}}function iM(e){sM.call(this,`containerDirective`,e)}function aM(e){sM.call(this,`leafDirective`,e)}function oM(e){sM.call(this,`textDirective`,e)}function sM(e,t){this.enter({type:e,name:``,attributes:{},children:[]},t)}function cM(e){let t=this.stack[this.stack.length-1];t.type===`containerDirective`||t.type===`leafDirective`||t.type,t.name=this.sliceSerialize(e),bM(t,e)}function lM(e){this.enter({type:`paragraph`,data:{directiveLabel:!0},children:[]},e)}function uM(e){this.exit(e);let t=this.stack[this.stack.length-1];t.type,bM(t,e)}function dM(e){let t=this.stack[this.stack.length-1];t.type===`leafDirective`||t.type,bM(t,e)}function fM(){let e=this.stack[this.stack.length-1];e.type===`containerDirective`||e.type===`leafDirective`||e.type,e.data&&e.data.position&&(this.data.directiveAttributePositions={}),this.data.directiveAttributes=[],this.buffer()}function pM(e){let t=this.data.directiveAttributePositions;if(t){let n=this.data.directiveAttributes,r=n[n.length-1];t[r[0]]={start:SM(e.start),end:SM(e.end)}}}function mM(e){xM(this,e)}function hM(e){this.data.directiveAttributes.push([`id`,Jj(this.sliceSerialize(e),{attribute:!0})])}function gM(e){this.data.directiveAttributes.push([`class`,Jj(this.sliceSerialize(e),{attribute:!0})])}function _M(e){let t=this.data.directiveAttributes,n=t[t.length-1];n[1]=Jj(this.sliceSerialize(e),{attribute:!0}),xM(this,e)}function vM(e){let t=this.data.directiveAttributes,n=this.sliceSerialize(e);t.push([n,``]);let r=this.data.directiveAttributePositions;r&&(r[n]={start:SM(e.start),end:SM(e.end)})}function yM(e){let t=this.data.directiveAttributes,n={};for(let e of t)e[0]===`class`&&n.class?n.class+=` `+e[1]:n[e[0]]=e[1];let r=this.data.directiveAttributePositions;this.data.directiveAttributePositions=void 0,this.data.directiveAttributes=void 0,this.resume();let i=this.stack[this.stack.length-1];i.type===`containerDirective`||i.type===`leafDirective`||i.type,i.attributes=n,r&&(i.data&&i.data.position,i.data.position.attributes=r),bM(i,e)}function bM(e,t){if(e.data&&e.data.position){let{opening:n}=e.data.position;n.end=SM(t.end)}}function xM(e,t){let n=e.data.directiveAttributePositions;if(n){let r=e.data.directiveAttributes,i=n[r[r.length-1][0]];i.end=SM(t.end)}}function SM(e){return{line:e.line,column:e.column,offset:e.offset}}function CM(e){this.exit(e)}function wM(){return`:`}function TM(e){let t=[],n=0,r=e.indexOf(`&`);for(;r!==-1;){let i=e.charCodeAt(r+1);(i===35||qr(i))&&(t.push(e.slice(n,r),`&`),n=r+1),r=e.indexOf(`&`,r+1)}return t.push(e.slice(n)),t.join(``)}function EM(e){return!!(e&&e.type===`paragraph`&&e.data&&e.data.directiveLabel)}function DM(e,t){let n=0;return n=e.type===`containerDirective`?Math.max(3,t+1):e.type===`leafDirective`?2:1,`:`.repeat(n)}function OM(e){let t=0,n=0;for(;n<e.length;){let r=0,i=e.charCodeAt(n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;i===58;)r++,i=e.charCodeAt(++n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;!(i===10||i===13||Number.isNaN(i));)r=0,i=e.charCodeAt(++n);r>t&&(t=r),n++}return t}function kM(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h,g;return _;function _(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),v}function v(t){return t===35?(h=o,y(t)):t===46?(h=s,y(t)):m&&Jr(t)?Lr(e,v,`whitespace`)(t):!m&&Nr(t)?Rr(e,v)(t):t===null||Yr(t)||br(t)||kr(t)&&t!==45&&t!==95?O(t):(e.enter(a),e.enter(c),e.consume(t),S)}function y(t){let n=h+`Marker`;return e.enter(a),e.enter(h),e.enter(n),e.consume(t),e.exit(n),b}function b(t){if(t===null||t===34||t===35||t===39||t===46||t===60||t===61||t===62||t===96||t===125||Nr(t))return n(t);let r=h+`Value`;return e.enter(r),e.consume(t),x}function x(t){if(t===null||t===34||t===39||t===60||t===61||t===62||t===96)return n(t);if(t===35||t===46||t===125||Nr(t)){let n=h+`Value`;return e.exit(n),e.exit(h),e.exit(a),v(t)}return e.consume(t),x}function S(t){return t===null||Yr(t)||br(t)||kr(t)&&t!==45&&t!==46&&t!==58&&t!==95?(e.exit(c),m&&Jr(t)?Lr(e,C,`whitespace`)(t):!m&&Nr(t)?Rr(e,C)(t):C(t)):(e.consume(t),S)}function C(t){return t===61?(e.enter(l),e.consume(t),e.exit(l),w):(e.exit(a),v(t))}function w(t){return t===null||t===60||t===61||t===62||t===96||t===125||m&&Yr(t)?n(t):t===34||t===39?(e.enter(u),e.enter(f),e.consume(t),e.exit(f),g=t,E):m&&Jr(t)?Lr(e,w,`whitespace`)(t):!m&&Nr(t)?Rr(e,w)(t):(e.enter(d),e.enter(p),e.consume(t),g=void 0,T)}function T(t){return t===null||t===34||t===39||t===60||t===61||t===62||t===96?n(t):t===125||Nr(t)?(e.exit(p),e.exit(d),e.exit(a),v(t)):(e.consume(t),T)}function E(t){return t===g?(e.enter(f),e.consume(t),e.exit(f),e.exit(u),e.exit(a),te):(e.enter(d),D(t))}function D(t){return t===g?(e.exit(d),E(t)):t===null?n(t):Yr(t)?m?n(t):Rr(e,D)(t):(e.enter(p),e.consume(t),ee)}function ee(t){return t===g||t===null||Yr(t)?(e.exit(p),D(t)):(e.consume(t),ee)}function te(e){return e===125||Nr(e)?v(e):O(e)}function O(a){return a===125?(e.enter(i),e.consume(a),e.exit(i),e.exit(r),t):n(a)}}function AM(e,t,n,r,i,a,o){let s=0,c=0,l;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),d}function d(n){return n===93?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),f(n))}function f(t){if(t===93&&!c)return h(t);let n=e.enter(`chunkText`,{_contentTypeTextTrailing:!0,contentType:`text`,previous:l});return l&&(l.next=n),l=n,p(t)}function p(t){return t===null||s>999||t===91&&++c>32?n(t):t===93&&!c--?(e.exit(`chunkText`),h(t)):Yr(t)?o?n(t):(e.consume(t),e.exit(`chunkText`),f):(e.consume(t),t===92?m:p)}function m(t){return t===91||t===92||t===93?(e.consume(t),s++,p):p(t)}function h(n){return e.exit(a),e.enter(i),e.consume(n),e.exit(i),e.exit(r),t}}function jM(e,t,n,r){let i=this;return a;function a(t){return t===null||Yr(t)||kr(t)||br(t)?n(t):(e.enter(r),e.consume(t),o)}function o(a){return a===null||Yr(a)||br(a)||kr(a)&&a!==45&&a!==95?(e.exit(r),i.previous===45||i.previous===95?n(a):t(a)):(e.consume(a),o)}}var MM={tokenize:IM,concrete:!0},NM={tokenize:LM,partial:!0},PM={tokenize:RM,partial:!0},FM={tokenize:zM,partial:!0};function IM(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,s;return c;function c(t){return e.enter(`directiveContainer`),e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),l(t)}function l(t){return t===58?(e.consume(t),o++,l):o<3?n(t):(e.exit(`directiveContainerSequence`),jM.call(r,e,u,n,`directiveContainerName`)(t))}function u(t){return t===91?e.attempt(NM,d,d)(t):d(t)}function d(t){return t===123?e.attempt(PM,f,f)(t):f(t)}function f(t){return Lr(e,p,`whitespace`)(t)}function p(i){return e.exit(`directiveContainerFence`),i===null?C(i):Yr(i)?r.interrupt?t(i):e.attempt(FM,m,C)(i):n(i)}function m(t){return t===null?C(t):Yr(t)?e.check(FM,y,C)(t):(e.enter(`directiveContainerContent`),h(t))}function h(t){return e.attempt({tokenize:w,partial:!0},S,a?Lr(e,g,`linePrefix`,a+1):g)(t)}function g(t){return t===null?S(t):Yr(t)?e.check(FM,v,S)(t):v(t)}function _(t){if(t===null){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}return Yr(t)?e.check(FM,b,x)(t):(e.consume(t),_)}function v(t){let n=e.enter(`chunkDocument`,{contentType:`document`,previous:s});return s&&(s.next=n),s=n,_(t)}function y(t){return e.enter(`directiveContainerContent`),h(t)}function b(t){e.consume(t);let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,h}function x(t){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}function S(t){return e.exit(`directiveContainerContent`),C(t)}function C(n){return e.exit(`directiveContainer`),t(n)}function w(e,t,n){let i=0;return Lr(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),s(t)}function s(t){return t===58?(e.consume(t),i++,s):i<o?n(t):(e.exit(`directiveContainerSequence`),Lr(e,c,`whitespace`)(t))}function c(r){return r===null||Yr(r)?(e.exit(`directiveContainerFence`),t(r)):n(r)}}}function LM(e,t,n){return AM(e,t,n,`directiveContainerLabel`,`directiveContainerLabelMarker`,`directiveContainerLabelString`,!0)}function RM(e,t,n){return kM(e,t,n,`directiveContainerAttributes`,`directiveContainerAttributesMarker`,`directiveContainerAttribute`,`directiveContainerAttributeId`,`directiveContainerAttributeClass`,`directiveContainerAttributeName`,`directiveContainerAttributeInitializerMarker`,`directiveContainerAttributeValueLiteral`,`directiveContainerAttributeValue`,`directiveContainerAttributeValueMarker`,`directiveContainerAttributeValueData`,!0)}function zM(e,t,n){let r=this;return i;function i(t){return 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 BM={tokenize:UM},VM={tokenize:WM,partial:!0},HM={tokenize:GM,partial:!0};function UM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveLeaf`),e.enter(`directiveLeafSequence`),e.consume(t),a}function a(t){return t===58?(e.consume(t),e.exit(`directiveLeafSequence`),jM.call(r,e,o,n,`directiveLeafName`)):n(t)}function o(t){return t===91?e.attempt(VM,s,s)(t):s(t)}function s(t){return t===123?e.attempt(HM,c,c)(t):c(t)}function c(t){return Lr(e,l,`whitespace`)(t)}function l(r){return r===null||Yr(r)?(e.exit(`directiveLeaf`),t(r)):n(r)}}function WM(e,t,n){return AM(e,t,n,`directiveLeafLabel`,`directiveLeafLabelMarker`,`directiveLeafLabelString`,!0)}function GM(e,t,n){return kM(e,t,n,`directiveLeafAttributes`,`directiveLeafAttributesMarker`,`directiveLeafAttribute`,`directiveLeafAttributeId`,`directiveLeafAttributeClass`,`directiveLeafAttributeName`,`directiveLeafAttributeInitializerMarker`,`directiveLeafAttributeValueLiteral`,`directiveLeafAttributeValue`,`directiveLeafAttributeValueMarker`,`directiveLeafAttributeValueData`,!0)}var KM={tokenize:XM,previous:YM},qM={tokenize:ZM,partial:!0},JM={tokenize:QM,partial:!0};function YM(e){return e!==58||this.events[this.events.length-1][1].type===`characterEscape`}function XM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveText`),e.enter(`directiveTextMarker`),e.consume(t),e.exit(`directiveTextMarker`),jM.call(r,e,a,n,`directiveTextName`)}function a(t){return t===58?n(t):t===91?e.attempt(qM,o,o)(t):o(t)}function o(t){return t===123?e.attempt(JM,s,s)(t):s(t)}function s(n){return e.exit(`directiveText`),t(n)}}function ZM(e,t,n){return AM(e,t,n,`directiveTextLabel`,`directiveTextLabelMarker`,`directiveTextLabelString`)}function QM(e,t,n){return kM(e,t,n,`directiveTextAttributes`,`directiveTextAttributesMarker`,`directiveTextAttribute`,`directiveTextAttributeId`,`directiveTextAttributeClass`,`directiveTextAttributeName`,`directiveTextAttributeInitializerMarker`,`directiveTextAttributeValueLiteral`,`directiveTextAttributeValue`,`directiveTextAttributeValueMarker`,`directiveTextAttributeValueData`)}function $M(){return{text:{58:KM},flow:{58:[MM,BM]}}}function eN(){let e=this.data(),t=e.micromarkExtensions||=[],n=e.fromMarkdownExtensions||=[],r=e.toMarkdownExtensions||=[];t.push($M()),n.push(nM()),r.push(rM())}var tN=/```([^\r\n`]*)\r?\n?([\s\S]*?)```|`([^`\r\n]+)`/g,nN=/\$\[[^\]\r\n]+\]|\$[A-Za-z0-9][\w.-]*/g,rN=`skill://`,iN=`mention://`;function aN(e,t){return`[${fN(e,`[]`)}](${fN(t,`()`)})`}function oN(e){let t=[],n=0;for(let r of e.matchAll(tN)){let i=r.index;i>n&&t.push(...sN(e.slice(n,i),n));let a=r[0],o=i+a.length,s=r[2];s===void 0?t.push({kind:`inline-code`,source:a,start:i,end:o,value:r[3]??``}):t.push({kind:`code-block`,source:a,start:i,end:o,language:r[1]??``,value:s}),n=o}return n<e.length&&t.push(...sN(e.slice(n),n)),t}function sN(e,t){let n=[],r=dN(e),i=0;for(let a of r)a.start>i&&n.push(...lN(e.slice(i,a.start),t+i)),n.push(cN(a,e,t)),i=a.end;return i<e.length&&n.push(...lN(e.slice(i),t+i)),n}function cN(e,t,n){let r=n+e.start,i=n+e.end,a=t.slice(e.start,e.end);if(e.href.startsWith(iN)){let t=e.href.slice(10);if(t)return{kind:`mention`,source:a,start:r,end:i,label:e.label,href:e.href,name:t}}if(e.label.startsWith(`$`)&&e.href.startsWith(rN)){let t=e.label.slice(1),n=e.href.slice(8);if(t&&n)return{kind:`skill-link`,source:a,start:r,end:i,label:e.label,href:e.href,name:t,skillId:n}}return{kind:`link`,source:a,start:r,end:i,label:e.label,href:e.href}}function lN(e,t){let n=[],r=0;for(let i of e.matchAll(nN)){let a=i.index,o=e[a-1];if(o&&/[\w$]/.test(o))continue;a>r&&n.push(uN(e.slice(r,a),t+r));let s=i[0],c=t+a;n.push({kind:`standalone-skill`,source:s,start:c,end:c+s.length,name:s.startsWith(`$[`)?s.slice(2,-1):s.slice(1)}),r=a+s.length}return r<e.length&&n.push(uN(e.slice(r),t+r)),n}function uN(e,t){return{kind:`text`,source:e,start:t,end:t+e.length,value:e}}function dN(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!==`[`)continue;let r=pN(e,n+1,`]`);if(!r||e[r.end+1]!==`(`)continue;let i=mN(e,r.end+2);i&&(t.push({label:r.value,href:i.value,start:n,end:i.end+1}),n=i.end)}return t}function fN(e,t){let n=``;for(let r of e)n+=r===`\\`||t.includes(r)?`\\${r}`:r;return n}function pN(e,t,n){let r=``;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){r+=e[i+1],i+=1;continue}if(t===n)return{value:r,end:i};r+=t}return null}function mN(e,t){let n=``,r=0;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){n+=e[i+1],i+=1;continue}if(t===`(`){r+=1,n+=t;continue}if(t===`)`){if(r===0)return{value:n,end:i};--r,n+=t;continue}n+=t}return null}var hN=Cn(),gN=Object.defineProperty,_N=(e,t)=>{let n={};for(var r in e)gN(n,r,{get:e[r],enumerable:!0});return t||gN(n,Symbol.toStringTag,{value:`Module`}),n};function vN(e){this.content=e}vN.prototype={constructor:vN,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new vN(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new vN(n)},addToStart:function(e,t){return new vN([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new vN(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new vN(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=vN.from(e),e.size?new vN(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=vN.from(e),e.size?new vN(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=vN.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},vN.from=function(e){if(e instanceof vN)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new vN(t)};function yN(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&SN(e.charCodeAt(r-1))&&xN(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=yN(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function bN(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&SN(e.charCodeAt(i-1))&&xN(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=bN(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function xN(e){return e>=56320&&e<57344}function SN(e){return e>=55296&&e<56320}var K=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return yN(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return bN(this,e,t,n)}findIndex(e){if(e==0)return wN(0,e);if(e==this.size)return wN(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?wN(t+1,i):wN(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};K.empty=new K([],0);var CN={index:0,offset:0};function wN(e,t){return CN.index=e,CN.offset=t,CN}function TN(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!TN(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!TN(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var EN=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&TN(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};EN.none=[];var DN=class extends Error{},q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=kN(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ON(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(K.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};q.empty=new q(K.empty,0,0);function ON(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ON(a.content,t-i-1,n-i-1)))}function kN(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=kN(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function AN(e,t,n){if(n.openStart>e.depth)throw new DN(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new DN(`Inconsistent open depths`);return jN(e,t,n,0)}function jN(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=jN(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return IN(a,RN(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return IN(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=zN(n,e);return IN(a,LN(e,i,o,t,r))}}function MN(e,t){if(!t.type.compatibleContent(e.type))throw new DN(`Cannot join `+t.type.name+` onto `+e.type.name)}function NN(e,t,n){let r=e.node(n);return MN(r,t.node(n)),r}function PN(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function FN(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(PN(e.nodeAfter,r),a++));for(let e=a;e<o;e++)PN(i.child(e),r);t&&t.depth==n&&t.textOffset&&PN(t.nodeBefore,r)}function IN(e,t){if(!e.type.validContent(t))throw new DN(`Invalid content for node `+e.type.name);return e.copy(t)}function LN(e,t,n,r,i){let a=e.depth>i&&NN(e,t,i+1),o=r.depth>i&&NN(n,r,i+1),s=[];return FN(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(MN(a,o),PN(IN(a,LN(e,t,n,r,i+1)),s)):(a&&PN(IN(a,RN(e,t,i+1)),s),FN(t,n,i,s),o&&PN(IN(o,RN(n,r,i+1)),s)),FN(r,null,i,s),new K(s)}function RN(e,t,n){let r=[];return FN(null,e,n,r),e.depth>n&&PN(IN(NN(e,t,n+1),RN(e,t,n+1)),r),FN(t,null,n,r),new K(r)}function zN(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(K.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var BN=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return EN.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new WN(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=UN.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else UN.set(t,r=new VN);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%HN,i}},VN=class{constructor(){this.elts=[],this.i=0}},HN=12,UN=new WeakMap,WN=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},GN=Object.create(null),KN=class e{constructor(e,t,n,r=EN.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||K.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&TN(this.attrs,t||e.defaultAttrs||GN)&&EN.sameSet(this.marks,n||EN.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return AN(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return BN.resolveCached(this,e)}resolveNoCache(e){return BN.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),JN(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=K.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=EN.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!EN.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=K.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};KN.prototype.text=void 0;var qN=class e extends KN{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):JN(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function JN(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var YN=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new XN(t,n);if(r.next==null)return e.empty;let i=ZN(r);r.next&&r.err(`Unexpected trailing text`);let a=sP(iP(i));return cP(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return K.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
183
|
+
`,`\r`];return e+`=`+s+Il(n,{subset:c})+s}}function iM(e){sM.call(this,`containerDirective`,e)}function aM(e){sM.call(this,`leafDirective`,e)}function oM(e){sM.call(this,`textDirective`,e)}function sM(e,t){this.enter({type:e,name:``,attributes:{},children:[]},t)}function cM(e){let t=this.stack[this.stack.length-1];t.type===`containerDirective`||t.type===`leafDirective`||t.type,t.name=this.sliceSerialize(e),bM(t,e)}function lM(e){this.enter({type:`paragraph`,data:{directiveLabel:!0},children:[]},e)}function uM(e){this.exit(e);let t=this.stack[this.stack.length-1];t.type,bM(t,e)}function dM(e){let t=this.stack[this.stack.length-1];t.type===`leafDirective`||t.type,bM(t,e)}function fM(){let e=this.stack[this.stack.length-1];e.type===`containerDirective`||e.type===`leafDirective`||e.type,e.data&&e.data.position&&(this.data.directiveAttributePositions={}),this.data.directiveAttributes=[],this.buffer()}function pM(e){let t=this.data.directiveAttributePositions;if(t){let n=this.data.directiveAttributes,r=n[n.length-1];t[r[0]]={start:SM(e.start),end:SM(e.end)}}}function mM(e){xM(this,e)}function hM(e){this.data.directiveAttributes.push([`id`,Jj(this.sliceSerialize(e),{attribute:!0})])}function gM(e){this.data.directiveAttributes.push([`class`,Jj(this.sliceSerialize(e),{attribute:!0})])}function _M(e){let t=this.data.directiveAttributes,n=t[t.length-1];n[1]=Jj(this.sliceSerialize(e),{attribute:!0}),xM(this,e)}function vM(e){let t=this.data.directiveAttributes,n=this.sliceSerialize(e);t.push([n,``]);let r=this.data.directiveAttributePositions;r&&(r[n]={start:SM(e.start),end:SM(e.end)})}function yM(e){let t=this.data.directiveAttributes,n={};for(let e of t)e[0]===`class`&&n.class?n.class+=` `+e[1]:n[e[0]]=e[1];let r=this.data.directiveAttributePositions;this.data.directiveAttributePositions=void 0,this.data.directiveAttributes=void 0,this.resume();let i=this.stack[this.stack.length-1];i.type===`containerDirective`||i.type===`leafDirective`||i.type,i.attributes=n,r&&(i.data&&i.data.position,i.data.position.attributes=r),bM(i,e)}function bM(e,t){if(e.data&&e.data.position){let{opening:n}=e.data.position;n.end=SM(t.end)}}function xM(e,t){let n=e.data.directiveAttributePositions;if(n){let r=e.data.directiveAttributes,i=n[r[r.length-1][0]];i.end=SM(t.end)}}function SM(e){return{line:e.line,column:e.column,offset:e.offset}}function CM(e){this.exit(e)}function wM(){return`:`}function TM(e){let t=[],n=0,r=e.indexOf(`&`);for(;r!==-1;){let i=e.charCodeAt(r+1);(i===35||qr(i))&&(t.push(e.slice(n,r),`&`),n=r+1),r=e.indexOf(`&`,r+1)}return t.push(e.slice(n)),t.join(``)}function EM(e){return!!(e&&e.type===`paragraph`&&e.data&&e.data.directiveLabel)}function DM(e,t){let n=0;return n=e.type===`containerDirective`?Math.max(3,t+1):e.type===`leafDirective`?2:1,`:`.repeat(n)}function OM(e){let t=0,n=0;for(;n<e.length;){let r=0,i=e.charCodeAt(n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;i===58;)r++,i=e.charCodeAt(++n);for(;i===9||i===32;)i=e.charCodeAt(++n);for(;!(i===10||i===13||Number.isNaN(i));)r=0,i=e.charCodeAt(++n);r>t&&(t=r),n++}return t}function kM(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h,g;return _;function _(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),v}function v(t){return t===35?(h=o,y(t)):t===46?(h=s,y(t)):m&&Jr(t)?Lr(e,v,`whitespace`)(t):!m&&Nr(t)?Rr(e,v)(t):t===null||Yr(t)||br(t)||kr(t)&&t!==45&&t!==95?k(t):(e.enter(a),e.enter(c),e.consume(t),S)}function y(t){let n=h+`Marker`;return e.enter(a),e.enter(h),e.enter(n),e.consume(t),e.exit(n),b}function b(t){if(t===null||t===34||t===35||t===39||t===46||t===60||t===61||t===62||t===96||t===125||Nr(t))return n(t);let r=h+`Value`;return e.enter(r),e.consume(t),x}function x(t){if(t===null||t===34||t===39||t===60||t===61||t===62||t===96)return n(t);if(t===35||t===46||t===125||Nr(t)){let n=h+`Value`;return e.exit(n),e.exit(h),e.exit(a),v(t)}return e.consume(t),x}function S(t){return t===null||Yr(t)||br(t)||kr(t)&&t!==45&&t!==46&&t!==58&&t!==95?(e.exit(c),m&&Jr(t)?Lr(e,C,`whitespace`)(t):!m&&Nr(t)?Rr(e,C)(t):C(t)):(e.consume(t),S)}function C(t){return t===61?(e.enter(l),e.consume(t),e.exit(l),w):(e.exit(a),v(t))}function w(t){return t===null||t===60||t===61||t===62||t===96||t===125||m&&Yr(t)?n(t):t===34||t===39?(e.enter(u),e.enter(f),e.consume(t),e.exit(f),g=t,E):m&&Jr(t)?Lr(e,w,`whitespace`)(t):!m&&Nr(t)?Rr(e,w)(t):(e.enter(d),e.enter(p),e.consume(t),g=void 0,T)}function T(t){return t===null||t===34||t===39||t===60||t===61||t===62||t===96?n(t):t===125||Nr(t)?(e.exit(p),e.exit(d),e.exit(a),v(t)):(e.consume(t),T)}function E(t){return t===g?(e.enter(f),e.consume(t),e.exit(f),e.exit(u),e.exit(a),ee):(e.enter(d),D(t))}function D(t){return t===g?(e.exit(d),E(t)):t===null?n(t):Yr(t)?m?n(t):Rr(e,D)(t):(e.enter(p),e.consume(t),O)}function O(t){return t===g||t===null||Yr(t)?(e.exit(p),D(t)):(e.consume(t),O)}function ee(e){return e===125||Nr(e)?v(e):k(e)}function k(a){return a===125?(e.enter(i),e.consume(a),e.exit(i),e.exit(r),t):n(a)}}function AM(e,t,n,r,i,a,o){let s=0,c=0,l;return u;function u(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),d}function d(n){return n===93?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),f(n))}function f(t){if(t===93&&!c)return h(t);let n=e.enter(`chunkText`,{_contentTypeTextTrailing:!0,contentType:`text`,previous:l});return l&&(l.next=n),l=n,p(t)}function p(t){return t===null||s>999||t===91&&++c>32?n(t):t===93&&!c--?(e.exit(`chunkText`),h(t)):Yr(t)?o?n(t):(e.consume(t),e.exit(`chunkText`),f):(e.consume(t),t===92?m:p)}function m(t){return t===91||t===92||t===93?(e.consume(t),s++,p):p(t)}function h(n){return e.exit(a),e.enter(i),e.consume(n),e.exit(i),e.exit(r),t}}function jM(e,t,n,r){let i=this;return a;function a(t){return t===null||Yr(t)||kr(t)||br(t)?n(t):(e.enter(r),e.consume(t),o)}function o(a){return a===null||Yr(a)||br(a)||kr(a)&&a!==45&&a!==95?(e.exit(r),i.previous===45||i.previous===95?n(a):t(a)):(e.consume(a),o)}}var MM={tokenize:IM,concrete:!0},NM={tokenize:LM,partial:!0},PM={tokenize:RM,partial:!0},FM={tokenize:zM,partial:!0};function IM(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,s;return c;function c(t){return e.enter(`directiveContainer`),e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),l(t)}function l(t){return t===58?(e.consume(t),o++,l):o<3?n(t):(e.exit(`directiveContainerSequence`),jM.call(r,e,u,n,`directiveContainerName`)(t))}function u(t){return t===91?e.attempt(NM,d,d)(t):d(t)}function d(t){return t===123?e.attempt(PM,f,f)(t):f(t)}function f(t){return Lr(e,p,`whitespace`)(t)}function p(i){return e.exit(`directiveContainerFence`),i===null?C(i):Yr(i)?r.interrupt?t(i):e.attempt(FM,m,C)(i):n(i)}function m(t){return t===null?C(t):Yr(t)?e.check(FM,y,C)(t):(e.enter(`directiveContainerContent`),h(t))}function h(t){return e.attempt({tokenize:w,partial:!0},S,a?Lr(e,g,`linePrefix`,a+1):g)(t)}function g(t){return t===null?S(t):Yr(t)?e.check(FM,v,S)(t):v(t)}function _(t){if(t===null){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}return Yr(t)?e.check(FM,b,x)(t):(e.consume(t),_)}function v(t){let n=e.enter(`chunkDocument`,{contentType:`document`,previous:s});return s&&(s.next=n),s=n,_(t)}function y(t){return e.enter(`directiveContainerContent`),h(t)}function b(t){e.consume(t);let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,h}function x(t){let n=e.exit(`chunkDocument`);return r.parser.lazy[n.start.line]=!1,S(t)}function S(t){return e.exit(`directiveContainerContent`),C(t)}function C(n){return e.exit(`directiveContainer`),t(n)}function w(e,t,n){let i=0;return Lr(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`directiveContainerFence`),e.enter(`directiveContainerSequence`),s(t)}function s(t){return t===58?(e.consume(t),i++,s):i<o?n(t):(e.exit(`directiveContainerSequence`),Lr(e,c,`whitespace`)(t))}function c(r){return r===null||Yr(r)?(e.exit(`directiveContainerFence`),t(r)):n(r)}}}function LM(e,t,n){return AM(e,t,n,`directiveContainerLabel`,`directiveContainerLabelMarker`,`directiveContainerLabelString`,!0)}function RM(e,t,n){return kM(e,t,n,`directiveContainerAttributes`,`directiveContainerAttributesMarker`,`directiveContainerAttribute`,`directiveContainerAttributeId`,`directiveContainerAttributeClass`,`directiveContainerAttributeName`,`directiveContainerAttributeInitializerMarker`,`directiveContainerAttributeValueLiteral`,`directiveContainerAttributeValue`,`directiveContainerAttributeValueMarker`,`directiveContainerAttributeValueData`,!0)}function zM(e,t,n){let r=this;return i;function i(t){return 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 BM={tokenize:UM},VM={tokenize:WM,partial:!0},HM={tokenize:GM,partial:!0};function UM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveLeaf`),e.enter(`directiveLeafSequence`),e.consume(t),a}function a(t){return t===58?(e.consume(t),e.exit(`directiveLeafSequence`),jM.call(r,e,o,n,`directiveLeafName`)):n(t)}function o(t){return t===91?e.attempt(VM,s,s)(t):s(t)}function s(t){return t===123?e.attempt(HM,c,c)(t):c(t)}function c(t){return Lr(e,l,`whitespace`)(t)}function l(r){return r===null||Yr(r)?(e.exit(`directiveLeaf`),t(r)):n(r)}}function WM(e,t,n){return AM(e,t,n,`directiveLeafLabel`,`directiveLeafLabelMarker`,`directiveLeafLabelString`,!0)}function GM(e,t,n){return kM(e,t,n,`directiveLeafAttributes`,`directiveLeafAttributesMarker`,`directiveLeafAttribute`,`directiveLeafAttributeId`,`directiveLeafAttributeClass`,`directiveLeafAttributeName`,`directiveLeafAttributeInitializerMarker`,`directiveLeafAttributeValueLiteral`,`directiveLeafAttributeValue`,`directiveLeafAttributeValueMarker`,`directiveLeafAttributeValueData`,!0)}var KM={tokenize:XM,previous:YM},qM={tokenize:ZM,partial:!0},JM={tokenize:QM,partial:!0};function YM(e){return e!==58||this.events[this.events.length-1][1].type===`characterEscape`}function XM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveText`),e.enter(`directiveTextMarker`),e.consume(t),e.exit(`directiveTextMarker`),jM.call(r,e,a,n,`directiveTextName`)}function a(t){return t===58?n(t):t===91?e.attempt(qM,o,o)(t):o(t)}function o(t){return t===123?e.attempt(JM,s,s)(t):s(t)}function s(n){return e.exit(`directiveText`),t(n)}}function ZM(e,t,n){return AM(e,t,n,`directiveTextLabel`,`directiveTextLabelMarker`,`directiveTextLabelString`)}function QM(e,t,n){return kM(e,t,n,`directiveTextAttributes`,`directiveTextAttributesMarker`,`directiveTextAttribute`,`directiveTextAttributeId`,`directiveTextAttributeClass`,`directiveTextAttributeName`,`directiveTextAttributeInitializerMarker`,`directiveTextAttributeValueLiteral`,`directiveTextAttributeValue`,`directiveTextAttributeValueMarker`,`directiveTextAttributeValueData`)}function $M(){return{text:{58:KM},flow:{58:[MM,BM]}}}function eN(){let e=this.data(),t=e.micromarkExtensions||=[],n=e.fromMarkdownExtensions||=[],r=e.toMarkdownExtensions||=[];t.push($M()),n.push(nM()),r.push(rM())}var tN=/```([^\r\n`]*)\r?\n?([\s\S]*?)```|`([^`\r\n]+)`/g,nN=/\$\[[^\]\r\n]+\]|\$[A-Za-z0-9][\w.-]*/g,rN=`skill://`,iN=`mention://`;function aN(e,t){return`[${fN(e,`[]`)}](${fN(t,`()`)})`}function oN(e){let t=[],n=0;for(let r of e.matchAll(tN)){let i=r.index;i>n&&t.push(...sN(e.slice(n,i),n));let a=r[0],o=i+a.length,s=r[2];s===void 0?t.push({kind:`inline-code`,source:a,start:i,end:o,value:r[3]??``}):t.push({kind:`code-block`,source:a,start:i,end:o,language:r[1]??``,value:s}),n=o}return n<e.length&&t.push(...sN(e.slice(n),n)),t}function sN(e,t){let n=[],r=dN(e),i=0;for(let a of r)a.start>i&&n.push(...lN(e.slice(i,a.start),t+i)),n.push(cN(a,e,t)),i=a.end;return i<e.length&&n.push(...lN(e.slice(i),t+i)),n}function cN(e,t,n){let r=n+e.start,i=n+e.end,a=t.slice(e.start,e.end);if(e.href.startsWith(iN)){let t=e.href.slice(10);if(t)return{kind:`mention`,source:a,start:r,end:i,label:e.label,href:e.href,name:t}}if(e.label.startsWith(`$`)&&e.href.startsWith(rN)){let t=e.label.slice(1),n=e.href.slice(8);if(t&&n)return{kind:`skill-link`,source:a,start:r,end:i,label:e.label,href:e.href,name:t,skillId:n}}return{kind:`link`,source:a,start:r,end:i,label:e.label,href:e.href}}function lN(e,t){let n=[],r=0;for(let i of e.matchAll(nN)){let a=i.index,o=e[a-1];if(o&&/[\w$]/.test(o))continue;a>r&&n.push(uN(e.slice(r,a),t+r));let s=i[0],c=t+a;n.push({kind:`standalone-skill`,source:s,start:c,end:c+s.length,name:s.startsWith(`$[`)?s.slice(2,-1):s.slice(1)}),r=a+s.length}return r<e.length&&n.push(uN(e.slice(r),t+r)),n}function uN(e,t){return{kind:`text`,source:e,start:t,end:t+e.length,value:e}}function dN(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!==`[`)continue;let r=pN(e,n+1,`]`);if(!r||e[r.end+1]!==`(`)continue;let i=mN(e,r.end+2);i&&(t.push({label:r.value,href:i.value,start:n,end:i.end+1}),n=i.end)}return t}function fN(e,t){let n=``;for(let r of e)n+=r===`\\`||t.includes(r)?`\\${r}`:r;return n}function pN(e,t,n){let r=``;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){r+=e[i+1],i+=1;continue}if(t===n)return{value:r,end:i};r+=t}return null}function mN(e,t){let n=``,r=0;for(let i=t;i<e.length;i+=1){let t=e[i];if(t===`\\`&&i+1<e.length){n+=e[i+1],i+=1;continue}if(t===`(`){r+=1,n+=t;continue}if(t===`)`){if(r===0)return{value:n,end:i};--r,n+=t;continue}n+=t}return null}var hN=Cn(),gN=Object.defineProperty,_N=(e,t)=>{let n={};for(var r in e)gN(n,r,{get:e[r],enumerable:!0});return t||gN(n,Symbol.toStringTag,{value:`Module`}),n};function vN(e){this.content=e}vN.prototype={constructor:vN,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new vN(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new vN(n)},addToStart:function(e,t){return new vN([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new vN(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new vN(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=vN.from(e),e.size?new vN(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=vN.from(e),e.size?new vN(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=vN.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},vN.from=function(e){if(e instanceof vN)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new vN(t)};function yN(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&SN(e.charCodeAt(r-1))&&xN(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=yN(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function bN(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&SN(e.charCodeAt(i-1))&&xN(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=bN(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function xN(e){return e>=56320&&e<57344}function SN(e){return e>=55296&&e<56320}var K=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return yN(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return bN(this,e,t,n)}findIndex(e){if(e==0)return wN(0,e);if(e==this.size)return wN(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?wN(t+1,i):wN(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};K.empty=new K([],0);var CN={index:0,offset:0};function wN(e,t){return CN.index=e,CN.offset=t,CN}function TN(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!TN(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!TN(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var EN=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&TN(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};EN.none=[];var DN=class extends Error{},q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=kN(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ON(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(K.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};q.empty=new q(K.empty,0,0);function ON(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ON(a.content,t-i-1,n-i-1)))}function kN(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=kN(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function AN(e,t,n){if(n.openStart>e.depth)throw new DN(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new DN(`Inconsistent open depths`);return jN(e,t,n,0)}function jN(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=jN(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return IN(a,RN(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return IN(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=zN(n,e);return IN(a,LN(e,i,o,t,r))}}function MN(e,t){if(!t.type.compatibleContent(e.type))throw new DN(`Cannot join `+t.type.name+` onto `+e.type.name)}function NN(e,t,n){let r=e.node(n);return MN(r,t.node(n)),r}function PN(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function FN(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(PN(e.nodeAfter,r),a++));for(let e=a;e<o;e++)PN(i.child(e),r);t&&t.depth==n&&t.textOffset&&PN(t.nodeBefore,r)}function IN(e,t){if(!e.type.validContent(t))throw new DN(`Invalid content for node `+e.type.name);return e.copy(t)}function LN(e,t,n,r,i){let a=e.depth>i&&NN(e,t,i+1),o=r.depth>i&&NN(n,r,i+1),s=[];return FN(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(MN(a,o),PN(IN(a,LN(e,t,n,r,i+1)),s)):(a&&PN(IN(a,RN(e,t,i+1)),s),FN(t,n,i,s),o&&PN(IN(o,RN(n,r,i+1)),s)),FN(r,null,i,s),new K(s)}function RN(e,t,n){let r=[];return FN(null,e,n,r),e.depth>n&&PN(IN(NN(e,t,n+1),RN(e,t,n+1)),r),FN(t,null,n,r),new K(r)}function zN(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(K.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var BN=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return EN.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new WN(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=UN.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else UN.set(t,r=new VN);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%HN,i}},VN=class{constructor(){this.elts=[],this.i=0}},HN=12,UN=new WeakMap,WN=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},GN=Object.create(null),KN=class e{constructor(e,t,n,r=EN.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||K.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&TN(this.attrs,t||e.defaultAttrs||GN)&&EN.sameSet(this.marks,n||EN.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return AN(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return BN.resolveCached(this,e)}resolveNoCache(e){return BN.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),JN(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=K.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=EN.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!EN.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=K.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};KN.prototype.text=void 0;var qN=class e extends KN{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):JN(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function JN(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var YN=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new XN(t,n);if(r.next==null)return e.empty;let i=ZN(r);r.next&&r.err(`Unexpected trailing text`);let a=sP(iP(i));return cP(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return K.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
184
184
|
`)}};YN.empty=new YN(!0);var XN=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ZN(e){let t=[];do t.push(QN(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function QN(e){let t=[];do t.push($N(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function $N(e){let t=rP(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=tP(e,t);else break;return t}function eP(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function tP(e,t){let n=eP(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:eP(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function nP(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function rP(e){if(e.eat(`(`)){let t=ZN(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=nP(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function iP(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function aP(e,t){return t-e}function oP(e,t){let n=[];return r(t),n.sort(aP);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function sP(e){let t=Object.create(null);return n(oP(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);oP(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new YN(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(aP);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function cP(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function lP(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function uP(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function dP(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function fP(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new hP(e,r,t[r]);return n}var pP=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=fP(e,n.attrs),this.defaultAttrs=lP(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==YN.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:uP(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new KN(this,this.computeAttrs(e),K.from(t),EN.setFrom(n))}createChecked(e=null,t,n){return t=K.from(t),this.checkContent(t),new KN(this,this.computeAttrs(e),t,EN.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=K.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(K.empty,!0);return i?new KN(this,e,t.append(i),EN.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){dP(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:EN.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function mP(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var hP=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?mP(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},gP=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=fP(e,r.attrs),this.excluded=null;let i=lP(this.attrs);this.instance=i?new EN(this,i):null}create(e=null){return!e&&this.instance?this.instance:new EN(this,uP(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){dP(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},_P=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=vN.from(e.nodes),t.marks=vN.from(e.marks||{}),this.nodes=pP.compile(this.spec.nodes,this),this.marks=gP.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=YN.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?vP(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:vP(this,n.split(` `))}this.nodeFromJSON=e=>KN.fromJSON(this,e),this.markFromJSON=e=>EN.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof pP))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new qN(n,n.defaultAttrs,e,EN.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function vP(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function yP(e){return e.tag!=null}function bP(e){return e.style!=null}var xP=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(yP(e))this.tags.push(e);else if(bP(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new AP(this,t,!1);return n.addAll(e,EN.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new AP(this,t,!0);return n.addAll(e,EN.none,t.from,t.to),q.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(MP(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=NP(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=NP(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},SP={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},CP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wP={ol:!0,ul:!0},TP=1,EP=2,DP=4;function OP(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?TP:0)|(t===`full`?EP:0)}var kP=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=EN.none,this.match=i||(a&DP?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(K.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&TP)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=K.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(K.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!SP.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},AP=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=OP(null,t.preserveWhitespace,0)|(n?DP:0);i=r?new kP(r.type,r.attrs,EN.none,!0,t.topMatch||r.type.contentMatch,a):n?new kP(null,null,EN.none,!0,null,a):new kP(e.schema.topNodeType,null,EN.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&EP?`full`:this.localPreserveWS||(r.options&TP)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
185
185
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;wP.hasOwnProperty(a)&&this.parser.normalizeLists&&jP(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:CP.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(SP.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
186
186
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=EN.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):PP(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=OP(e,i,a.options);a.options&DP&&a.content.length==0&&(o|=DP);let s=EN.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):PP(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new kP(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=TP);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function jP(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&wP.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function MP(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function NP(e){let t={};for(let n in e)t[n]=e[n];return t}function PP(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var FP=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=LP(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return LP(t).createTextNode(e.text);let{dom:n,contentDOM:r}=VP(LP(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&VP(LP(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:VP(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=IP(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return IP(e.marks)}};function IP(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function LP(e){return e.document||window.document}var RP=new WeakMap;function zP(e){let t=RP.get(e);return t===void 0&&RP.set(e,t=BP(e)),t}function BP(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function VP(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=zP(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=VP(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var HP=65535,UP=2**16;function WP(e,t){return e+t*UP}function GP(e){return e&HP}function KP(e){return(e-(e&HP))/UP}var qP=1,JP=2,YP=4,XP=8,ZP=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&XP)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&YP)>0}},QP=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=GP(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+KP(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:WP(o/3,e-s),f=e==s?JP:e==u?qP:YP;return(t<0?e!=s:e!=u)&&(f|=XP),new ZP(a,f,d)}r+=l-c}return n?e+r:new ZP(e+r,0,null)}touches(e,t){let n=0,r=GP(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};QP.empty=new QP([]);var $P=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new ZP(e,r,null)}},eF=Object.create(null),tF=class{getMap(){return QP.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=eF[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in eF)throw RangeError(`Duplicate use of step JSON ID `+e);return eF[e]=t,t.prototype.jsonID=e,t}},nF=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof DN)return e.fail(t.message);throw t}}};function rF(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(rF(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return K.fromArray(r)}var iF=class e extends tF{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new q(rF(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return nF.fromReplace(e,this.from,this.to,i)}invert(){return new aF(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};tF.jsonID(`addMark`,iF);var aF=class e extends tF{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new q(rF(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return nF.fromReplace(e,this.from,this.to,n)}invert(){return new iF(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};tF.jsonID(`removeMark`,aF);var oF=class e extends tF{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nF.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return nF.fromReplace(e,this.pos,this.pos+1,new q(K.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new sF(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};tF.jsonID(`addNodeMark`,oF);var sF=class e extends tF{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nF.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return nF.fromReplace(e,this.pos,this.pos+1,new q(K.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new oF(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};tF.jsonID(`removeNodeMark`,sF);var cF=class e extends tF{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&uF(e,this.from,this.to)?nF.fail(`Structure replace would overwrite content`):nF.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new QP([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?q.empty:new q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?q.empty:new q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,q.fromJSON(t,n.slice),!!n.structure)}};cF.MAP_BIAS=1,tF.jsonID(`replace`,cF);var lF=class e extends tF{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(uF(e,this.from,this.gapFrom)||uF(e,this.gapTo,this.to)))return nF.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return nF.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?nF.fromReplace(e,this.from,this.to,n):nF.fail(`Content does not fit in gap`)}getMap(){return new QP([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,q.fromJSON(t,n.slice),n.insert,!!n.structure)}};tF.jsonID(`replaceAround`,lF);function uF(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function dF(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new aF(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new iF(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function fF(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof gP){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new aF(t.from,t.to,t.style)))}function pF(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new cF(s,l,q.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new aF(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new q(K.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new cF(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(K.empty,!0);e.replace(s,s,new q(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function mF(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function hF(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!mF(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function gF(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=K.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=K.from(r.node(e).copy(u)),d++):c--;let f=K.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=K.from(i.node(e).copy(f)),p++):l++;e.step(new lF(c,l,o,s,new q(u.append(f),d,p),u.size-d,!0))}function _F(e,t,n=null,r=e){let i=yF(e,t),a=i&&bF(r,t);return a?i.map(vF).concat({type:t,attrs:n}).concat(a.map(vF)):null}function vF(e){return{type:e,attrs:null}}function yF(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function bF(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function xF(e,t,n){let r=K.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=K.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new lF(i,a,i,a,new q(r,0,0),n.length,!0))}function SF(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&TF(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&wF(e,t,n,a),pF(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new lF(c,l,c+1,l-1,new q(K.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&CF(e,t,n,a),!1}})}function CF(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function wF(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -191,7 +191,7 @@ ${At(e.error)}`)}let t=Fj(e);if(t!==void 0)throw Error(`Duplicate element name <
|
|
|
191
191
|
`),slice:t}}function zz(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new q(K.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
192
192
|
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=FP.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=Zz(n),YL&&Qz(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||xP.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Bz.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=$z(Kz(s,+u[1],+u[2]),u[4]);else if(s=q.maxOpen(Vz(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=Kz(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Bz=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Vz(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&Uz(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Wz(a[a.length-1],i.length));let n=Hz(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return K.from(a)}return e}function Hz(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,K.from(e));return e}function Uz(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Uz(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(K.from(Hz(n,e,i+1))))}}function Wz(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Wz(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(K.empty,!0);return e.copy(n.append(r))}function Gz(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=Gz(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(K.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Kz(e,t,n){return t<e.openStart&&(e=new q(Gz(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new q(Gz(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var qz={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function Jz(){return document.implementation.createHTMLDocument(`title`)}var Yz=null;function Xz(e){let t=window.trustedTypes;if(!t)return e;if(!Yz){if(Yz=t.defaultPolicy)try{return Yz.createHTML(e)}catch{}Yz=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return Yz.createHTML(e)}function Zz(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Jz(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&qz[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=Xz(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function Qz(e){let t=e.querySelectorAll(HL?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function $z(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{t.checkAttrs(r[e+1])}catch{break}i=K.from(t.create(r[e+1],i)),a++,o++}return new q(i,a,o)}var eB={},tB={},nB={touchstart:!0,touchmove:!0},rB=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function iB(e){for(let t in eB){let n=eB[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{lB(e,t)&&!cB(e,t)&&(e.editable||!(t.type in tB))&&n(e,t)},nB[t]?{passive:!0}:void 0)}WL&&e.dom.addEventListener(`input`,()=>null),sB(e)}function aB(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function oB(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function sB(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>cB(e,t))})}function cB(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function lB(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function uB(e,t){!cB(e,t)&&eB[t.type]&&(e.editable||!(t.type in tB))&&eB[t.type](e,t)}tB.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!DB(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(JL&&HL&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),GL&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,kL(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Lz(e,n)?n.preventDefault():aB(e,`key`)},tB.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},tB.keypress=(e,t)=>{let n=t;if(DB(e)||!n.charCode||n.ctrlKey&&!n.altKey||KL&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Y)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function dB(e){return{left:e.clientX,top:e.clientY}}function fB(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function pB(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function mB(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function hB(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&X.isSelectable(r)?(mB(e,new X(n),`pointer`),!0):!1}function gB(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof X&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(X.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(mB(e,X.create(e.state.doc,i),`pointer`),!0)}function _B(e,t,n,r,i){return pB(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?gB(e,n):hB(e,n))}function vB(e,t,n,r){return pB(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function yB(e,t,n,r){return pB(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||bB(e,n,r)}function bB(e,t,n){if(n.button!=0)return!1;let r=xB(e,t,!0),i=e.state.doc;return r?(mB(e,r,`pointer`),r instanceof Y&&i.eq(e.state.doc)&&(e.input.mouseDown=new EB(e,r)),!0):!1}function xB(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?Y.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return Y.create(r,a+1,a+1+t.content.size);if(n&&X.isSelectable(t))return X.create(r,a)}return null}function SB(e){return NB(e)}var CB=KL?`metaKey`:`ctrlKey`;eB.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=SB(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&fB(n,e.input.lastClick)&&!n[CB]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(dB(n));o&&(a==`singleClick`?e.input.mouseDown=new TB(e,o,n,!!r):(a==`doubleClick`?vB:yB)(e,o.pos,o.inside,n)?n.preventDefault():aB(e,`pointer`))};var wB=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},TB=class extends wB{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[CB],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof X&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&BL&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),aB(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||oz(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(dB(e))),this.updateAllowDefault(e),this.allowDefault||!t?aB(this.view,`pointer`):_B(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||WL&&this.mightDrag&&!this.mightDrag.node.isAtom||HL&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(mB(this.view,J.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):aB(this.view,`pointer`)}move(e){this.updateAllowDefault(e),aB(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},EB=class extends wB{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),aB(this.view,`pointer`);let t=this.view.posAtCoords(dB(e)),n=t&&xB(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from<i.from?[i.to,n.from]:[i.from,n.to];mB(this.view,Y.create(r,a,o),`pointer`)}};eB.touchstart=e=>{e.input.lastTouch=Date.now(),SB(e),aB(e,`pointer`)},eB.touchmove=e=>{e.input.lastTouch=Date.now(),aB(e,`pointer`)},eB.contextmenu=e=>SB(e);function DB(e,t){return e.composing?!0:WL&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var OB=JL?5e3:-1;tB.compositionstart=tB.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Y&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||HL&&qL&&kB(e)))e.markCursor=e.state.storedMarks||n.marks(),NB(e,!0),e.markCursor=null;else if(NB(e,!t.selection.empty),BL&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}AB(e,OB)};function kB(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}tB.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,AB(e,20))};function AB(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>NB(e),t))}function jB(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function MB(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=wL(t.focusNode,t.focusOffset),r=TL(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function NB(e,t=!1){if(!(JL&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),jB(e),t||e.docView&&e.docView.dirty){let n=iz(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function PB(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var FB=RL&&zL<15||GL&&XL<604;eB.copy=tB.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=FB?null:n.clipboardData,{dom:o,text:s}=Rz(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):PB(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function IB(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function LB(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?RB(e,r.value,null,i,t):RB(e,r.textContent,r.innerHTML,i,t)},50)}function RB(e,t,n,r,i){let a=zz(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||q.empty)))return!0;if(!a)return!1;let o=IB(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function zB(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}tB.paste=(e,t)=>{let n=t;if(e.composing&&!JL)return;let r=FB?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&RB(e,zB(r),r.getData(`text/html`),i,n)?n.preventDefault():LB(e,n)};var BB=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},VB=KL?`altKey`:`ctrlKey`;function HB(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[VB]:!n}eB.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(dB(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof X?i.to-1:i.to))){if(r&&r.mightDrag)o=X.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=X.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Rz(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!HL||UL>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(FB?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,FB||n.dataTransfer.setData(`text/plain`,c),e.dragging=new BB(l,HB(e,n),o)},eB.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},tB.dragover=tB.dragenter=(e,t)=>t.preventDefault(),tB.drop=(e,t)=>{try{UB(e,t,e.dragging)}finally{e.dragging=null}};function UB(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(dB(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=zz(e,zB(t.dataTransfer),FB?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&HB(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||q.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?FF(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&X.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new X(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(hz(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}eB.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&oz(e)},20))},eB.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},eB.beforeinput=(e,t)=>{if(JL&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,kL(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in tB)eB[e]=tB[e];function WB(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var GB=class e{constructor(e,t){this.toDOM=e,this.spec=t||XB,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new JB(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&WB(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},KB=class e{constructor(e,t){this.attrs=e,this.spec=t||XB}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new JB(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&WB(this.attrs,t.attrs)&&WB(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},qB=class e{constructor(e,t){this.attrs=e,this.spec=t||XB}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new JB(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&WB(this.attrs,t.attrs)&&WB(this.spec,t.spec)}destroy(){}},JB=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new GB(n,r))}static inline(t,n,r,i){return new e(t,n,new KB(r,i))}static node(t,n,r,i){return new e(t,n,new qB(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof KB}get widget(){return this.type instanceof GB}},YB=[],XB={},ZB=class e{constructor(e,t){this.local=e.length?e:YB,this.children=t.length?t:YB}static create(e,t){return t.length?aV(t,e,0,XB):QB}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==QB||e.maps.length==0?this:this.mapInner(e,t,0,0,n||XB)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?eV(this.children,o||[],t,n,r,i,a):o?new e(o.sort(oV),YB):QB}add(t,n){return n.length?this==QB?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=rV(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,aV(s,e,o+1,XB)),a+=3}});let o=tV(a?iV(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(oV):this.local,i||this.children)}remove(e){return e.length==0||this==QB?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==QB?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):QB}forChild(t,n){if(this==QB)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof KB){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(oV),YB);return r?new $B([t,r]):t}return r||QB}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return sV(this.localsInner(e))}localsInner(e){if(this==QB)return YB;if(e.inlineContent||!this.local.some(KB.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof KB||t.push(this.local[e]);return t}forEachSet(e){e(this)}};ZB.empty=new ZB([],[]),ZB.removeOverlap=sV;var QB=ZB.empty,$B=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,XB));return e.from(r)}forChild(t,n){if(n.isLeaf)return ZB.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=QB&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?sV(n?t:t.sort(oV)):YB}static from(t){switch(t.length){case 0:return QB;case 1:return t[0];default:return new e(t.every(e=>e instanceof ZB)?t:t.reduce((e,t)=>e.concat(t instanceof ZB?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function eV(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==QB?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=aV(nV(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new ZB(t.sort(oV),s)}function tV(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new JB(i.from+t,i.to+t,i.type))}return n}function nV(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function rV(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function iV(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function aV(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=rV(e,t,o+n);if(s){a=!0;let e=aV(s,t,n+o+1,r);e!=QB&&i.push(o,o+t.nodeSize,e)}});let o=tV(a?iV(e):e,-n).sort(oV);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new ZB(o,i):QB}function oV(e,t){return e.from-t.from||e.to-t.to}function sV(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),cV(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),cV(t,i,r.copy(a.from,r.to)));break}}}return t}function cV(e,t,n){for(;t<e.length&&oV(n,e[t])>0;)t++;e.splice(t,0,n)}function lV(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=QB&&t.push(r)}),e.cursorWrapper&&t.push(ZB.create(e.state.doc,[e.cursorWrapper.deco])),$B.from(t)}var uV={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},dV=RL&&zL<=11,fV=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},pV=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new fV,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);RL&&zL<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():WL&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),dV&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,uV)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(gz(this.view)){if(this.suppressingSelectionUpdates)return oz(this.view);if(RL&&zL<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&bL(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=gL(n))t.add(n);for(let r=e.anchorNode;r;r=gL(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&gz(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||HL&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(BL&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||yV(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&OL(n)&&(c=iz(e))&&c.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,oz(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),gV(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,bV(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||oz(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(RL&&zL<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?hL(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?hL(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},mV=new WeakMap,hV=!1;function gV(e){if(!mV.has(e)&&(mV.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=BL,hV)return;console.warn(`ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.`),hV=!0}}function _V(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return bL(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function vV(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return _V(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?_V(e,n):null}function yV(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function bV(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function xV(e,t,n,r){let{node:i,fromOffset:a,toOffset:o,from:s,to:c}=e.docView.parseRange(t,n),l=e.domSelectionRange(),u,d=l.anchorNode;if(d&&e.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:l.anchorOffset}],OL(l)||u.push({node:l.focusNode,offset:l.focusOffset})),HL&&e.input.lastKeyCode===8)for(let e=o;e>a;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||xP.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:SV(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var SV=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(WL&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(t.parentNode.lastChild==t||WL&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},CV=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function wV(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=iz(e,t);if(n&&!e.state.selection.eq(n)){if(HL&&JL&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,kL(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=xV(e,t,n,i),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=kV(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(GL&&e.input.lastIOSEnter>Date.now()-225||JL)&&i.some(e=>e.nodeType==1&&!CV.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,kL(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Y&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=TV(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof Y&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),RL&&zL<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((GL&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,kL(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&DV(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,kL(8,`Backspace`)))){JL&&HL&&e.domObserver.suppressSelectionUpdates();return}HL&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),JL&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,kL(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=TV(e,n.doc,l.sel);t&&!(HL&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||RL&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){RL&&zL<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>oz(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=EV(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function TV(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:hz(e,t.resolve(n.anchor),t.resolve(n.head))}function EV(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(K.from(l).eq(e))return{mark:s,type:o}}function DV(e,t,n,r,i){if(n-t<=i.pos-r.pos||OV(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(OV(a,!0,!0));return!o.parent.isTextblock||o.pos>n||OV(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function OV(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function kV(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c<a&&o<s){let e=r<=a&&r>=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l<a){let e=r<=a&&r>=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var AV=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new rB,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(LV),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=NV(this),MV(this),this.nodeViews=FV(this),this.docView=RR(this.state.doc,jV(this),lV(this),this.dom,this),this.domObserver=new pV(this,(e,t,n,r)=>wV(this,e,t,n,r)),this.domObserver.start(),iB(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&sB(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(LV),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(jB(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=FV(this);IV(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&sB(this),this.editable=NV(this),MV(this);let o=lV(this),s=jV(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&tR(this);if(i){this.domObserver.stop();let t=l&&(RL||HL)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&PV(n.selection,e.selection);if(l){let n=HL?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=MB(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=RR(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&vz(this)&&i.delaySelUpdate())?oz(this,t):(pz(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&rR(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof X){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&eR(this,t.getBoundingClientRect(),e)}else eR(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new BB(e.slice,e.move,r<0?void 0:X.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(RL){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&oR(this.dom),oz(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return mR(this,e)}coordsAtPos(e,t=1){return vR(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return OR(this,t||this.state,e)}pasteHTML(e,t){return RB(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return RB(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Rz(this,e)}destroy(){this.docView&&(oB(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],lV(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,yL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return uB(this,e)}domSelectionRange(){let e=this.domSelection();return e?WL&&this.root.nodeType===11&&AL(this.dom.ownerDocument)==this.dom&&vV(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};AV.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function jV(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[JB.node(0,e.state.doc.content.size,t)]}function MV(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:JB.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function NV(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function PV(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function FV(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function IV(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function LV(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var RV={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},zV={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},BV=typeof navigator<`u`&&/Mac/.test(navigator.platform),VV=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),HV=0;HV<10;HV++)RV[48+HV]=RV[96+HV]=String(HV);for(var HV=1;HV<=24;HV++)RV[HV+111]=`F`+HV;for(var HV=65;HV<=90;HV++)RV[HV]=String.fromCharCode(HV+32),zV[HV]=String.fromCharCode(HV);for(var UV in RV)zV.hasOwnProperty(UV)||(zV[UV]=RV[UV]);function WV(e){var t=!(BV&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||VV&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?zV:RV)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var GV=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),KV=typeof navigator<`u`&&/Win/.test(navigator.platform);function qV(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))GV?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function JV(e){let t=Object.create(null);for(let n in e)t[qV(n)]=e[n];return t}function YV(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function XV(e){return new xI({props:{handleKeyDown:ZV(e)}})}function ZV(e){let t=JV(e);return function(e,n){let r=WV(n),i,a=t[YV(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[YV(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(KV&&n.ctrlKey&&n.altKey)&&(i=RV[n.keyCode])&&i!=r){let r=t[YV(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}function QV(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var $V=class e{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}static createFakeChain(){let e=new Proxy({},{get:(t,n)=>{if(n!==`then`)return n===`run`?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(e,t)=>{if(t!==`then`)return t===`chain`?e.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:QV({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},eH=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),tH=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),nH=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=hF(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},rH=e=>t=>e(t),iH=()=>({state:e,dispatch:t})=>WI(e,t),aH=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new Y(r.doc.resolve(Math.max(o-1,0)))),!0},oH=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function sH(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var cH=e=>({tr:t,state:n,dispatch:r})=>{let i=sH(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},lH=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},uH=e=>e.content?/^text(\*|\+)/.test(e.content):!1,dH=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;return uH(r)?n===`left`?e.start()-1:e.end()+1:e.pos},fH=(e,t,n)=>({from:dH(e,n,`left`),to:dH(t,n,`right`)}),pH=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,i=n.steps.length;r.forEach(t=>{let r=n.mapping.slice(i),{from:a,to:o}=fH(n.doc.resolve(r.map(t.$from.pos)),n.doc.resolve(r.map(t.$to.pos)),e.schema);n.deleteRange(a,o)}),n.selection.empty||n.setSelection(Y.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),t(n)}return!0},mH=()=>({commands:e})=>e.keyboardShortcut(`Enter`),hH=()=>({state:e,dispatch:t})=>UI(e,t);function gH(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function _H(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:gH(t[r])?t[r].test(e[r]):t[r]===e[r])}function vH(e,t,n={}){return e.find(e=>e.type===t&&_H(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function yH(e,t,n={}){return!!vH(e,t,n)}function bH(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!vH([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&yH([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&yH([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function xH(e,t){if(typeof e==`string`){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var SH=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=xH(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=bH(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=Y.create(o,e.from,e.to);n.setSelection(t)}}return!0},CH=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function wH(e){return e instanceof Y}function TH(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function EH(e,t=null){if(!t)return null;let n=J.atStart(e),r=J.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?Y.create(e,TH(0,i,a),TH(e.content.size,i,a)):Y.create(e,TH(t,i,a),TH(t,i,a))}function DH(){return[`Android`].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function OH(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function kH(){return typeof navigator<`u`&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var AH=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(OH()||DH())&&r.dom.focus(),kH()&&!OH()&&!DH()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!wH(n.state.selection))return o(),!0;let s=EH(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},jH=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),MH=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),NH=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&NH(r)}return e};function PH(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return NH(n)}function FH(e){return typeof e?.nodesBetween==`function`}function IH(e,t,n){if(FH(e))return e;let r=typeof e==`object`&&!!e;n={slice:!0,parseOptions:{},...n};let i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return K.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),IH(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new _P({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?xP.fromSchema(a).parseSlice(PH(e),n.parseOptions):xP.fromSchema(a).parse(PH(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=xP.fromSchema(t);return n.slice?r.parseSlice(PH(e),n.parseOptions).content:r.parse(PH(e),n.parseOptions)}return IH(``,t,n)}function LH(e){return!(`type`in e)}function RH(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof cF||i instanceof lF))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(J.near(e.doc.resolve(o),n))}var zH=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{IH(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=IH(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0,f=LH(i)?i.content:[i];if(f.forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let p;if(u)p=Array.isArray(t)?t.map(e=>e.text||``).join(``):FH(t)?f.map(e=>e.text??``).join(``):typeof t==`object`&&t&&t.text?t.text:t,r.insertText(p,c,l);else{p=K.from(f);let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,i=t.isText||t.isTextblock,a=t.content.size>0;n&&i&&a&&d&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&RH(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:p}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:p})}return!0};function BH(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var VH=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{pos:i,attrs:a,content:o,updateSelection:s=!0}=e,c;c=typeof i==`number`?t.doc.resolve(i):i||t.selection.$from;let l=BH(c.parent.contentMatchAt(c.index()));if(!l)return!1;let u=Object.keys(l.spec.attrs||{}),d=a?Object.fromEntries(Object.entries(a).filter(([e])=>u.includes(e))):{},f;if(o){let e=IH(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&RH(t,t.steps.length-1,-1)),!0):!1},HH=()=>({state:e,dispatch:t})=>RI(e,t),UH=()=>({state:e,dispatch:t})=>zI(e,t),WH=()=>({state:e,dispatch:t})=>DI(e,t),GH=()=>({state:e,dispatch:t})=>FI(e,t),KH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=MF(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},qH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=MF(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},JH=()=>({state:e,dispatch:t})=>OI(e,t),YH=()=>({state:e,dispatch:t})=>kI(e,t);function XH(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function ZH(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e+=1){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))OH()||XH()?o=!0:i=!0;else throw Error(`Unrecognized modifier name: ${n}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var QH=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=ZH(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function $H(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?sH(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>!o||o.name===e.node.type.name).filter(e=>_H(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var eU=(e,t={})=>({state:n,dispatch:r})=>$H(n,sH(e,n.schema),t)?BI(n,r):!1,tU=()=>({state:e,dispatch:t})=>GI(e,t),nU=e=>({state:t,dispatch:n})=>dL(sH(e,t.schema))(t,n),rU=()=>({state:e,dispatch:t})=>VI(e,t);function iU(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function aU(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var oU=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=iU(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=sH(e,r.schema)),s===`mark`&&(o=xH(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,aU(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(aU(a.attrs,t))))})})}),c},sU=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),cU=()=>({tr:e,dispatch:t})=>{if(t){let t=new sI(e.doc);e.setSelection(t)}return!0},lU=()=>({state:e,dispatch:t})=>MI(e,t),uU=()=>({state:e,dispatch:t})=>II(e,t),dU=()=>({state:e,dispatch:t})=>JI(e,t),fU=()=>({state:e,dispatch:t})=>eL(e,t),pU=()=>({state:e,dispatch:t})=>$I(e,t);function mU(e,t,n={},r={}){return IH(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var hU=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=mU(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=LH(s)?s.content:[s];a.replaceWith(0,c.content.size,e).setMeta(`preventUpdate`,!n)}return!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function gU(e,t){let n=xH(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function _U(e,t){let n=new eI(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function vU(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function yU(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function bU(e){return t=>yU(t.$from,e)}function Z(e,t,n){return e.config[t]===void 0&&e.parent?Z(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?Z(e.parent,t,n):null}):e.config[t]}function xU(e){return e.map(e=>{let t=Z(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...xU(t())]:e}).flat(10)}function SU(e,t){let n=FP.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function CU(e){return typeof e==`function`}function wU(e,t=void 0,...n){return CU(e)?t?e.bind(t)(...n):e(...n):e}function TU(e={}){return Object.keys(e).length===0&&e.constructor===Object}function EU(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function DU(e){let t=[],{nodeExtensions:n,markExtensions:r}=EU(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=Z(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=Z(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function OU(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s<o;s+=1){let o=e[s];if(o===`'`&&!i){r=!r,n+=o;continue}if(o===`"`&&!r){i=!i,n+=o;continue}if(!r&&!i){if(o===`(`){a+=1,n+=o;continue}if(o===`)`&&a>0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}return n&&t.push(n),t}function kU(e){let t=[],n=OU(e||``),r=n.length;for(let e=0;e<r;e+=1){let r=n[e],i=r.indexOf(`:`);if(i===-1)continue;let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();a&&o&&t.push([a,o])}return t}function AU(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(e===`__proto__`){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return}if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...kU(n[e]),...kU(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function jU(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>AU(e,t),{})}function MU(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function NU(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):MU(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function PU(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&TU(t)?!1:t!=null))}function FU(e){var t,n;let r={};return!(!(e==null||(t=e.attribute)==null)&&t.isRequired)&&`default`in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function IU(e,t){let n=DU(e),{nodeExtensions:r,markExtensions:i}=EU(e);return new _P({topNode:r.find(e=>Z(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=PU({...e.reduce((e,t)=>{let n=Z(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:wU(Z(r,`content`,a)),marks:wU(Z(r,`marks`,a)),group:wU(Z(r,`group`,a)),inline:wU(Z(r,`inline`,a)),atom:wU(Z(r,`atom`,a)),selectable:wU(Z(r,`selectable`,a)),draggable:wU(Z(r,`draggable`,a)),code:wU(Z(r,`code`,a)),whitespace:wU(Z(r,`whitespace`,a)),linebreakReplacement:wU(Z(r,`linebreakReplacement`,a)),defining:wU(Z(r,`defining`,a)),isolating:wU(Z(r,`isolating`,a)),attrs:Object.fromEntries(i.map(FU))}),s=wU(Z(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>NU(e,i)));let c=Z(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:jU(e,i)}));let l=Z(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=PU({...e.reduce((e,t)=>{let n=Z(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:wU(Z(r,`inclusive`,a)),excludes:wU(Z(r,`excludes`,a)),group:wU(Z(r,`group`,a)),spanning:wU(Z(r,`spanning`,a)),code:wU(Z(r,`code`,a)),attrs:Object.fromEntries(i.map(FU))}),s=wU(Z(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>NU(e,i)));let c=Z(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:jU(e,i)})),[r.name,o]}))})}function LU(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function RU(e){return e.sort((e,t)=>{let n=Z(e,`priority`)||100,r=Z(t,`priority`)||100;return n>r?-1:+(n<r)})}function zU(e){let t=RU(xU(e)),n=LU(t.map(e=>e.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function BU(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
|
|
193
193
|
|
|
194
|
-
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function VU(e,t){return BU(e,{from:0,to:e.content.size},t)}function HU(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function UU(e,t){let n=sH(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function WU(e,t){let n=iU(typeof t==`string`?t:t.name,e.schema);return n===`node`?UU(e,t):n===`mark`?gU(e,t):{}}function GU(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function KU(e){let t=GU(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function qU(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),KU(r)}function JU(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=bH(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var YU=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},XU=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function ZU(e,t){return t.nodes[e]||t.marks[e]||null}function QU(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var $U=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function eW(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?xH(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>_H(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>_H(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function tW(e,t,n={}){if(!t)return $H(e,null,n)||eW(e,null,n);let r=iU(t,e.schema);return r===`node`?$H(e,t,n):r===`mark`&&eW(e,t,n)}var nW=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=bU(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},rW=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function iW(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function aW(e,t){let{nodeExtensions:n}=EU(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=wU(Z(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function oW(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(oW(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function sW(e){return e instanceof X}var cW=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function lW(e,t){let n=t.mapping.mapResult(e.position);return{position:new cW(n.pos),mapResult:n}}function uW(e){return new cW(e)}function dW(e,t,n){let{selection:r}=t,i=null;if(wH(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var fW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=xH(e,r.schema);if(i)if(o){let e=gU(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return dW(r,n,c)},pW=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),mW=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=sH(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>nL(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>nL(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},hW=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=TH(e,0,n.content.size),i=X.create(n,r);t.setSelection(i)}return!0},gW=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},_W=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Y.atStart(n).from,o=Y.atEnd(n).to,s=TH(r,a,o),c=TH(i,a,o),l=Y.create(n,s,c);t.setSelection(l)}return!0},vW=e=>({state:t,dispatch:n})=>mL(sH(e,t.schema))(t,n);function yW(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var bW=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=QU(l,s.node().type.name,s.node().attrs);if(a instanceof X&&a.node.isBlock)return!s.parentOffset||!DF(o,s.pos)?!1:(r&&(e&&yW(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:BH(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=DF(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&DF(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof Y&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&yW(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},xW=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=sH(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=K.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=K.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...QU(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(K.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new q(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(Y.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...QU(d,u.type.name,u.attrs),...t},m={...QU(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!DF(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function SW(e){return!e||e===`1`?null:e}function CW(e,t){return SW(e)===SW(t)}var wW=(e,t)=>{let n=bU(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&kF(e.doc,n.pos))||!CW(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},TW=(e,t)=>{let n=bU(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&kF(e.doc,r))||!CW(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function EW(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return Y.between(r,i)}var DW=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=sH(e,o.schema),m=sH(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=bU(e=>aW(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,C=o.doc.content.content,w=C.length===1?C[0]:null,T=S&&w&&aW(w.type.name,d)?{node:w,pos:0,depth:0}:null,E=x??T,D=!!x&&y.depth>=1&&y.depth-x.depth<=1,ee=!!T;if((D||ee)&&E){if(E.node.type===p)return S&&ee?c().command(({tr:e,dispatch:t})=>{let n=EW(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(aW(E.node.type.name,d)&&p.validContent(E.node.content))return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>wW(a,p)).command(()=>TW(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>wW(a,p)).command(()=>TW(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>wW(a,p)).command(()=>TW(a,p)).run()},OW=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=xH(e,r.schema);return eW(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},kW=(e,t,n={})=>({state:r,commands:i})=>{let a=sH(e,r.schema),o=sH(t,r.schema),s=$H(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},AW=(e,t={})=>({state:n,commands:r})=>{let i=sH(e,n.schema);return $H(n,i,t)?r.lift(i):r.wrapIn(i,t)},jW=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},MW=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},NW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=xH(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=bH(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},PW=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},FW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=iU(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=sH(e,r.schema)),s===`mark`&&(o=xH(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r<s&&a&&a===e.type&&(c=!0,f=Math.max(r,s),p=Math.min(r+e.nodeSize,l),u=r,d=e),r>=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},IW=new wI(`__tiptap_decorations__`),LW=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(IW,{type:`force`,name:e}),!0),RW=(e,t={})=>({state:n,dispatch:r})=>tL(sH(e,n.schema),t)(n,r),zW=(e,t={})=>({state:n,dispatch:r})=>cL(sH(e,n.schema),t)(n,r),BW=_N({blur:()=>eH,clearContent:()=>tH,clearNodes:()=>nH,command:()=>rH,createParagraphNear:()=>iH,cut:()=>aH,deleteCurrentNode:()=>oH,deleteNode:()=>cH,deleteRange:()=>lH,deleteSelection:()=>pH,enter:()=>mH,exitCode:()=>hH,extendMarkRange:()=>SH,first:()=>CH,focus:()=>AH,forEach:()=>jH,insertContent:()=>MH,insertContentAt:()=>zH,insertDefaultBlock:()=>VH,joinBackward:()=>WH,joinDown:()=>UH,joinForward:()=>GH,joinItemBackward:()=>KH,joinItemForward:()=>qH,joinTextblockBackward:()=>JH,joinTextblockForward:()=>YH,joinUp:()=>HH,keyboardShortcut:()=>QH,lift:()=>eU,liftEmptyBlock:()=>tU,liftListItem:()=>nU,newlineInCode:()=>rU,resetAttributes:()=>oU,scrollIntoView:()=>sU,selectAll:()=>cU,selectNodeBackward:()=>lU,selectNodeForward:()=>uU,selectParentNode:()=>dU,selectTextblockEnd:()=>fU,selectTextblockStart:()=>pU,setContent:()=>hU,setMark:()=>fW,setMeta:()=>pW,setNode:()=>mW,setNodeSelection:()=>hW,setTextDirection:()=>gW,setTextSelection:()=>_W,sinkListItem:()=>vW,splitBlock:()=>bW,splitListItem:()=>xW,toggleList:()=>DW,toggleMark:()=>OW,toggleNode:()=>kW,toggleWrap:()=>AW,undoInputRule:()=>jW,unsetAllMarks:()=>MW,unsetMark:()=>NW,unsetTextDirection:()=>PW,updateAttributes:()=>FW,updateDecorations:()=>LW,wrapIn:()=>RW,wrapInList:()=>zW}),VW=new WeakMap;function HW(e,t){VW.set(e,(VW.get(e)??0)+1);try{return t()}finally{let t=(VW.get(e)??1)-1;t>0?VW.set(e,t):VW.delete(e)}}function UW(e){return VW.has(e)}var WW=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},GW=typeof process<`u`&&!1;function KW(e){return e.kind===`widget`}function qW(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&KW(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function JW(e,t,n){let{decorations:r,widgetKeys:i}=qW(t,n);return{set:ZB.create(e,r),widgetKeys:i}}function YW({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n||e===n&&n===r}function XW({decorations:e,from:t,to:n,docSize:r,extensionName:i,warnedExtensions:a}){return e.filter(e=>YW({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function ZW(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function QW(e){let t=new Map,n=new Map;for(let r of e.find()){let e=ZW(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function $W(e){return e.jsonID===`attr`}function eG(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||$W(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function tG(e,t){let n=null,r=0,i=0;for(let a=0;a<e.childCount&&!(i>t.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function nG(e,t){if(e.steps.some(e=>!eG(e)))return{type:`full`};let n=qU(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!$W(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=tG(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function rG(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function iG(e,t,n){let r=t.decorationSetsByExtension[e]??ZB.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:rG(r,n.mapping,n.doc,i),widgetKeys:i}}function aG(e,t){let n=Object.values(t).flatMap(e=>e.find());return ZB.create(e,n)}function oG(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function sG(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function cG(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var lG=new Set,uG=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=IW.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>sG(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return IW.getState(this.editor.state)?.widgetKeys??lG}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new xI({key:IW,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:oG(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(IW),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return HW(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!cG(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=iG(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:oG(u)}}},props:{decorations(e){return IW.getState(e)?.mergedDecorationSet??ZB.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=nG(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??ZB.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=rG(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>YW({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=ZW(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=qW(XW({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return JW(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!GW)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=QW(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:aG(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):aG(n.doc,r)}};function dG(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof X){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function fG(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function pG(e){return typeof e==`number`}function mG(e){return Object.prototype.toString.call(e).slice(8,-1)}function hG(e){return mG(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function gG(e,t,n){let r=e.split(`
|
|
194
|
+
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function VU(e,t){return BU(e,{from:0,to:e.content.size},t)}function HU(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function UU(e,t){let n=sH(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function WU(e,t){let n=iU(typeof t==`string`?t:t.name,e.schema);return n===`node`?UU(e,t):n===`mark`?gU(e,t):{}}function GU(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function KU(e){let t=GU(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function qU(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),KU(r)}function JU(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=bH(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var YU=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},XU=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function ZU(e,t){return t.nodes[e]||t.marks[e]||null}function QU(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var $U=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function eW(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?xH(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>_H(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>_H(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function tW(e,t,n={}){if(!t)return $H(e,null,n)||eW(e,null,n);let r=iU(t,e.schema);return r===`node`?$H(e,t,n):r===`mark`&&eW(e,t,n)}var nW=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=bU(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},rW=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function iW(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function aW(e,t){let{nodeExtensions:n}=EU(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=wU(Z(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function oW(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(oW(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function sW(e){return e instanceof X}var cW=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function lW(e,t){let n=t.mapping.mapResult(e.position);return{position:new cW(n.pos),mapResult:n}}function uW(e){return new cW(e)}function dW(e,t,n){let{selection:r}=t,i=null;if(wH(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var fW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=xH(e,r.schema);if(i)if(o){let e=gU(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return dW(r,n,c)},pW=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),mW=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=sH(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>nL(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>nL(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},hW=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=TH(e,0,n.content.size),i=X.create(n,r);t.setSelection(i)}return!0},gW=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},_W=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Y.atStart(n).from,o=Y.atEnd(n).to,s=TH(r,a,o),c=TH(i,a,o),l=Y.create(n,s,c);t.setSelection(l)}return!0},vW=e=>({state:t,dispatch:n})=>mL(sH(e,t.schema))(t,n);function yW(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var bW=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=QU(l,s.node().type.name,s.node().attrs);if(a instanceof X&&a.node.isBlock)return!s.parentOffset||!DF(o,s.pos)?!1:(r&&(e&&yW(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:BH(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=DF(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&DF(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof Y&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&yW(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},xW=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=sH(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=K.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=K.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...QU(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(K.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new q(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(Y.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...QU(d,u.type.name,u.attrs),...t},m={...QU(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!DF(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function SW(e){return!e||e===`1`?null:e}function CW(e,t){return SW(e)===SW(t)}var wW=(e,t)=>{let n=bU(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&kF(e.doc,n.pos))||!CW(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},TW=(e,t)=>{let n=bU(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&kF(e.doc,r))||!CW(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function EW(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return Y.between(r,i)}var DW=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=sH(e,o.schema),m=sH(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=bU(e=>aW(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,C=o.doc.content.content,w=C.length===1?C[0]:null,T=S&&w&&aW(w.type.name,d)?{node:w,pos:0,depth:0}:null,E=x??T,D=!!x&&y.depth>=1&&y.depth-x.depth<=1,O=!!T;if((D||O)&&E){if(E.node.type===p)return S&&O?c().command(({tr:e,dispatch:t})=>{let n=EW(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(aW(E.node.type.name,d)&&p.validContent(E.node.content))return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>wW(a,p)).command(()=>TW(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>wW(a,p)).command(()=>TW(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>wW(a,p)).command(()=>TW(a,p)).run()},OW=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=xH(e,r.schema);return eW(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},kW=(e,t,n={})=>({state:r,commands:i})=>{let a=sH(e,r.schema),o=sH(t,r.schema),s=$H(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},AW=(e,t={})=>({state:n,commands:r})=>{let i=sH(e,n.schema);return $H(n,i,t)?r.lift(i):r.wrapIn(i,t)},jW=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},MW=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},NW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=xH(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=bH(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},PW=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},FW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=iU(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=sH(e,r.schema)),s===`mark`&&(o=xH(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r<s&&a&&a===e.type&&(c=!0,f=Math.max(r,s),p=Math.min(r+e.nodeSize,l),u=r,d=e),r>=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},IW=new wI(`__tiptap_decorations__`),LW=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(IW,{type:`force`,name:e}),!0),RW=(e,t={})=>({state:n,dispatch:r})=>tL(sH(e,n.schema),t)(n,r),zW=(e,t={})=>({state:n,dispatch:r})=>cL(sH(e,n.schema),t)(n,r),BW=_N({blur:()=>eH,clearContent:()=>tH,clearNodes:()=>nH,command:()=>rH,createParagraphNear:()=>iH,cut:()=>aH,deleteCurrentNode:()=>oH,deleteNode:()=>cH,deleteRange:()=>lH,deleteSelection:()=>pH,enter:()=>mH,exitCode:()=>hH,extendMarkRange:()=>SH,first:()=>CH,focus:()=>AH,forEach:()=>jH,insertContent:()=>MH,insertContentAt:()=>zH,insertDefaultBlock:()=>VH,joinBackward:()=>WH,joinDown:()=>UH,joinForward:()=>GH,joinItemBackward:()=>KH,joinItemForward:()=>qH,joinTextblockBackward:()=>JH,joinTextblockForward:()=>YH,joinUp:()=>HH,keyboardShortcut:()=>QH,lift:()=>eU,liftEmptyBlock:()=>tU,liftListItem:()=>nU,newlineInCode:()=>rU,resetAttributes:()=>oU,scrollIntoView:()=>sU,selectAll:()=>cU,selectNodeBackward:()=>lU,selectNodeForward:()=>uU,selectParentNode:()=>dU,selectTextblockEnd:()=>fU,selectTextblockStart:()=>pU,setContent:()=>hU,setMark:()=>fW,setMeta:()=>pW,setNode:()=>mW,setNodeSelection:()=>hW,setTextDirection:()=>gW,setTextSelection:()=>_W,sinkListItem:()=>vW,splitBlock:()=>bW,splitListItem:()=>xW,toggleList:()=>DW,toggleMark:()=>OW,toggleNode:()=>kW,toggleWrap:()=>AW,undoInputRule:()=>jW,unsetAllMarks:()=>MW,unsetMark:()=>NW,unsetTextDirection:()=>PW,updateAttributes:()=>FW,updateDecorations:()=>LW,wrapIn:()=>RW,wrapInList:()=>zW}),VW=new WeakMap;function HW(e,t){VW.set(e,(VW.get(e)??0)+1);try{return t()}finally{let t=(VW.get(e)??1)-1;t>0?VW.set(e,t):VW.delete(e)}}function UW(e){return VW.has(e)}var WW=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},GW=typeof process<`u`&&!1;function KW(e){return e.kind===`widget`}function qW(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&KW(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function JW(e,t,n){let{decorations:r,widgetKeys:i}=qW(t,n);return{set:ZB.create(e,r),widgetKeys:i}}function YW({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n||e===n&&n===r}function XW({decorations:e,from:t,to:n,docSize:r,extensionName:i,warnedExtensions:a}){return e.filter(e=>YW({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function ZW(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function QW(e){let t=new Map,n=new Map;for(let r of e.find()){let e=ZW(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function $W(e){return e.jsonID===`attr`}function eG(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||$W(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function tG(e,t){let n=null,r=0,i=0;for(let a=0;a<e.childCount&&!(i>t.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function nG(e,t){if(e.steps.some(e=>!eG(e)))return{type:`full`};let n=qU(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!$W(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=tG(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function rG(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function iG(e,t,n){let r=t.decorationSetsByExtension[e]??ZB.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:rG(r,n.mapping,n.doc,i),widgetKeys:i}}function aG(e,t){let n=Object.values(t).flatMap(e=>e.find());return ZB.create(e,n)}function oG(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function sG(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function cG(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var lG=new Set,uG=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=IW.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>sG(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return IW.getState(this.editor.state)?.widgetKeys??lG}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new xI({key:IW,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:oG(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(IW),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return HW(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!cG(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=iG(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:oG(u)}}},props:{decorations(e){return IW.getState(e)?.mergedDecorationSet??ZB.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=nG(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??ZB.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=rG(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>YW({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=ZW(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=qW(XW({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return JW(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!GW)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=QW(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:aG(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):aG(n.doc,r)}};function dG(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof X){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function fG(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function pG(e){return typeof e==`number`}function mG(e){return Object.prototype.toString.call(e).slice(8,-1)}function hG(e){return mG(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function gG(e,t,n){let r=e.split(`
|
|
195
195
|
`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o<r.length;){let e=r[o],u=e.match(t.itemPattern);if(!u){if(i.length>0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}else return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;o<r.length;){var c;let e=r[o];if(e.trim()===``){var l;let t=r.slice(o+1).findIndex(e=>e.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}else break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=g.map(e=>e.slice(f+s)).join(`
|
|
196
196
|
`);e.trim()&&(h=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a}}function _G(e,t,n,r){if(!e||!Array.isArray(e.content))return``;let i=typeof n==`function`?n(r):n,[a,...o]=e.content,s=`${i}${t.renderChildren([a])}`;return o&&o.length>0&&o.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=r.split(`
|
|
197
197
|
`).map(e=>e?t.indent(e):t.indent(``)).join(`
|
|
@@ -323,20 +323,20 @@ img.ProseMirror-separator {
|
|
|
323
323
|
`:e.type.name===`composerMention`||e.type.name===`composerAtom`?f2(e):null}function d2(e,t,n){if(n<=t)return null;let r=e.state.doc.slice(t,n),i={text:e.state.doc.textBetween(t,n,`
|
|
324
324
|
`,f2),slice:r.toJSON()};return e.chain().focus().deleteRange({from:t,to:n}).run(),i}function f2(e){return e.type.name===`composerMention`?String(e.attrs.label??``)||`${String(e.attrs.trigger??``)}${String(e.attrs.value??``)}`:e.type.name===`composerAtom`?String(e.attrs.label??``):``}function p2(e,t){let{selection:n}=e.state;if(typeof t==`string`){if(!n.empty){e.chain().focus().deleteSelection().insertContent(t).run();return}e.chain().focus().insertContent(t).run();return}let r=q.fromJSON(e.state.schema,t.slice);e.view.dispatch(e.state.tr.replaceSelection(r).scrollIntoView()),e.view.focus()}function m2(e,t){let{selection:n}=e.state;if(!n.empty)return!1;let r=n.$from,i=t===`Backspace`?r.nodeBefore:r.nodeAfter;if(!i||!h2(i))return!1;let a=t===`Backspace`?n.from-i.nodeSize:n.from,o=t===`Backspace`?n.from:n.from+i.nodeSize;return e.chain().focus().deleteRange({from:a,to:o}).run(),!0}function h2(e){return e.isAtom&&(e.type.name===`composerMention`||e.type.name===`composerAtom`)}function g2(e){try{return e.state.doc.textBetween(0,e.state.selection.from,`
|
|
325
325
|
`,``).length}catch{return 0}}function _2(e){return e.state.selection.empty&&g2(e)===0}function v2(e,t){return p$(e.persistedPrompt,t)?`ParseSlash`:e.action}function y2(e){return e.key===`ArrowUp`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`p`}function b2(e){return e.key===`ArrowDown`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`n`}function x2(e){let t=new Map;for(let n of e)t.set(`${n.kind}:${n.range.start}:${n.range.end}:${n.label}`,n);return z$([...t.values()])}function S2(e){return e.replace(/\r\n?/g,`
|
|
326
|
-
`)}function C2(e){return e.startsWith(`file://`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||/^[A-Za-z]:[\\/]/.test(e)}function w2(e){let t=e.trim();if(!t.startsWith(`file://`))return t;let n=URL.parse(t);if(!n)return t;try{return decodeURIComponent(n.pathname)}catch{return n.pathname}}function T2(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??e}function E2(e){return/[\\/]$/.test(e)}function D2(e){return e.split(/\r?\n/).map(e=>e.trim()).find(e=>e&&!e.startsWith(`#`))??``}function O2(e){let t=D2(e);return t?t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim()??t:``}function k2(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function A2(e){return $$(e.trim())}function j2(e){let t=(0,G.c)(3),n=e.draftKey??``,r;return t[0]!==e||t[1]!==n?(r=(0,z.jsx)(N2,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}function M2(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function N2({initialDraft:e,draftKey:t,disabled:n=!1,isTaskRunning:r=!1,queueSubmissions:i=!1,hasInteracted:a=!1,maxExpandedTextChars:o,editorAriaLabel:s=`Rich prompt composer`,className:c,children:l,dictation:u,validateSubmission:d,onSubmit:f,onStateChange:p}){let m=un(),h=B1(l),g=(0,R.useRef)({signature:V1(h),slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers}),_=V1(h);_!==g.current.signature&&(g.current={signature:_,slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers});let{slashCommands:v,mentionCandidates:y,commandTriggers:b,mentionTriggers:x}=g.current,S=(0,R.useMemo)(()=>({commandTriggers:b,mentionTriggers:x}),[b,x]),C=(0,R.useRef)(x);C.current=x;let[w]=(0,R.useState)(()=>{if(e)return e;if(t===void 0)return;let n=k1(t);return n?Z$({source:n,slashCommands:v,mentionCandidates:y}):void 0}),T=(0,R.useRef)(w?.remoteImages??[]),E=(0,R.useRef)(b0({state:w,slashCommands:v,mentionCandidates:y,triggers:S})),D=(0,R.useRef)(0),ee=(0,R.useRef)(!0);(0,R.useEffect)(()=>(ee.current=!0,()=>{ee.current=!1}),[]);let[te,O]=(0,R.useState)(T.current),[ne,k]=(0,R.useState)(null),[re,A]=(0,R.useState)(()=>T0(E.current,T.current,v,r,i,0)),j=(0,R.useRef)(re),ie=(0,R.useRef)(te),M=(0,R.useRef)(ne),ae=(0,R.useRef)(null),oe=(0,R.useRef)(null),se=(0,R.useRef)(void 0),N=(0,R.useRef)(null),ce=(0,R.useRef)(null),le=(0,R.useRef)(null),ue=(0,R.useEffectEvent)((e,t)=>{p?.(e,t)}),de=(0,R.useRef)(d),fe=(0,R.useRef)(f),pe=(0,R.useRef)(new Map),me=(0,R.useRef)(()=>null),he=(0,R.useRef)(()=>void 0),ge=(0,R.useRef)(()=>void 0),_e=(0,R.useRef)(()=>!1),[ve,ye]=(0,R.useState)(``),be=(0,R.useRef)(ve);be.current=ve;let P=fq({extensions:(0,R.useMemo)(()=>f0({getPlaceholder:()=>be.current,getMentionTrigger:()=>C.current[0]??`@`,getRemoteImageCount:()=>ie.current.length,attachImageFile:e=>me.current(e)}),[]),content:E.current,editable:!n,editorProps:{attributes:{"data-slot":`composer-editor`,role:`textbox`,"aria-label":s,"aria-placeholder":ve,"aria-disabled":n?`true`:`false`,dir:`auto`,spellcheck:`false`},handleKeyDown(e,t){return _e.current(t)}},immediatelyRender:!1,onUpdate({editor:e}){he.current(e),ge.current(e)},onSelectionUpdate({editor:e}){he.current(e),ge.current(e)}}),xe=(0,R.useMemo)(()=>ne?K1(ne,v,y,a):[],[ne,a,y,v]),Se=(0,R.useMemo)(()=>_$(re,v,b),[b,re,v]);(0,R.useEffect)(()=>{j.current=re},[re]),(0,R.useEffect)(()=>{ie.current=te},[te]),(0,R.useEffect)(()=>{M.current=ne},[ne]),(0,R.useEffect)(()=>{re.shortcutsOpen&&(ne||re.reverseSearch!==null||!g$(re))&&A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)},[ne,re]),(0,R.useEffect)(()=>{de.current=d},[d]),(0,R.useEffect)(()=>{fe.current=f},[f]),(0,R.useEffect)(()=>{P&&(P.setEditable(!n),n&&k(null))},[n,P]),(0,R.useEffect)(()=>{ue(re,Se),t!==void 0&&(Se?A1(t,J$(re,Se.persistedPrompt)):D.current===0&&A1(t,null))},[re,t,Se]),(0,R.useEffect)(()=>{A(e=>e.isTaskRunning===r&&e.queueSubmissions===i?e:{...e,isTaskRunning:r,queueSubmissions:i})},[r,i]),he.current=e=>{if(n)return;let t=T0(e.getJSON(),ie.current,v,r,i,g2(e)),a=oe.current,o=se.current;oe.current=null,se.current=void 0,A(e=>{let n=o===void 0?N.current:o;N.current=n;let r=e.shortcutsOpen&&g$(t);return{...t,error:e.error,history:e.history,historyCursor:n,killBuffer:e.killBuffer,reverseSearch:e.reverseSearch,shortcutsOpen:r,selectedRemoteImageId:a}})},ge.current=e=>{if(n){k(null);return}let t=L0(e,S);if(!t){k(null);return}if(b.includes(t.trigger)){let e={trigger:t.trigger,query:t.query,selectedIndex:0},n=K1(e,v,y,a);k(t=>n.length===0?null:{...e,selectedIndex:t?.trigger===e.trigger?Math.min(t.selectedIndex,n.length-1):0});return}k(e=>{let n=t.trigger,r={trigger:n,query:t.query,selectedIndex:e?.trigger===n?e.selectedIndex:0},i=K1(r,v,y,a);return{...r,selectedIndex:e?.trigger===n?Math.min(e.selectedIndex,Math.max(i.length-1,0)):0}})};function Ce(e){P?.commands.setContent(e),P&&(he.current(P),ge.current(P))}function we(e){if(n||!P)return;let t=L0(P,S),r=[{type:`text`,text:`${e.trigger}${e.value}`,marks:[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]},{type:`text`,text:` `}];t&&t.trigger===e.trigger?P.chain().focus().deleteRange({from:t.from,to:t.to}).insertContent(r).run():P.chain().focus().insertContent(r).run(),k(null)}function Te({index:e=M.current?.selectedIndex??0}={}){let t=M.current;if(n||!P||!t)return;let r=K1(t,v,y,a),i=r[e]??r[0];if(!i)return;if(!i.atomic){we(i);return}let o=L0(P,S),s=o?.trigger===t.trigger,c=P.chain().focus();s&&o&&c.deleteRange({from:o.from,to:o.to}),c.insertContent([N0(i),{type:`text`,text:` `}]).run(),k(null)}function Ee(){if(n||!P)return;P.commands.focus();let e=b[0];e&&k(t=>t?.trigger===e?null:{trigger:e,query:``,selectedIndex:0})}function De(e){return g$(e)&&e.reverseSearch===null&&M.current===null}function Oe(){n||A(e=>De(e)&&!e.shortcutsOpen?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function ke(){A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)}function Ae(){n||A(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:De(e)?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function je(e){n||!P||!e||P.chain().focus().insertContent(e).run()}function Me(e){if(V$(e)===null)return A(t=>({...t,error:`Only image, video, or audio files can be attached: ${e.name||`unnamed file`}`,shortcutsOpen:!1})),k(null),null;let t=crypto.randomUUID();return pe.current.set(t,e),t}function Ne(e,t){let n=Me(t);if(n===null)return;let r=Ge(),i=r.remoteImages.length+r.imageAttachments.length+1,a=V$(t)??`image`;e.chain().focus().insertContent([I0(n,U$(a,i),a),{type:`text`,text:` `}]).run()}function Pe(e){if(!(n||!P))for(let t of e)Ne(P,t)}function Fe(e){n||!P||(pe.current.delete(e),Ce(Y0(Z0(P.getJSON(),e),ie.current.length)))}function Ie(e){if(n||!P)return;let t=[...ie.current,{id:g1(`remote-image`,e,m.Date.now()),url:e}];ie.current=t,O(t),Ce(Y0(P.getJSON(),t.length))}function Le(e){return n||!P?!1:y0(P.view,e,ie.current.length,x[0]??`@`,Me)}function Re(e){if(n)return;let t=ie.current[e]??j.current.remoteImages[e];t&&(oe.current=t.id,A(e=>({...e,selectedRemoteImageId:t.id,shortcutsOpen:!1})))}function ze(){n||(oe.current=null,A(e=>e.selectedRemoteImageId?{...e,selectedRemoteImageId:null,shortcutsOpen:!1}:e))}function Be(e){return j.current.selectedRemoteImageId?e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`Escape`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`?(ze(),k(null),!0):e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(ze(),!0):!1:!1}function Ve(e){if(n)return e.preventDefault(),!0;if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`)return e.preventDefault(),ze(),k(null),P?.commands.selectAll(),!0;let t=Ge(),r=j.current.selectedRemoteImageId;if(!M.current&&e.key===`ArrowUp`){let n=G$({...t,selectedRemoteImageId:r},r);if(n!==null)return e.preventDefault(),Re(Math.max(0,n-1)),!0;if((P&&_2(P)||t.cursor===0)&&t.remoteImages.length>0)return e.preventDefault(),Re(t.remoteImages.length-1),!0}if(!M.current&&r&&e.key===`ArrowDown`){e.preventDefault();let n=G$({...t,selectedRemoteImageId:r},r);return n!==null&&n+1<t.remoteImages.length?Re(n+1):ze(),!0}return!M.current&&r&&(e.key===`Backspace`||e.key===`Delete`)?(e.preventDefault(),He(r),!0):(Be(e),!1)}function He(e){if(n||!P)return;let t=Ge(),r=t.remoteImages.findIndex(t=>t.id===e),i=t.remoteImages.filter(t=>t.id!==e),a=r===-1?null:i[r]??i[r-1]??null;oe.current=a?.id??null,ie.current=i,O(i),Ce(Y0(P.getJSON(),i.length)),A(e=>({...e,remoteImages:i,selectedRemoteImageId:a?.id??null,shortcutsOpen:!1}))}function Ue(e){if(n||!P)return;let t=$0(P.getJSON(),K$(e));P.chain().focus().insertContent(F0({kind:`paste`,label:t,detail:`${K$(e)} chars`,content:e})).run()}function We(e,t=e,r){n||P?.chain().focus().insertContent(F0({kind:`rich-link`,label:t,detail:e,href:e,metadata:r})).run()}function Ge(){return P?{...T0(P.getJSON(),ie.current,v,r,i,g2(P)),error:j.current.error,history:j.current.history,historyCursor:N.current??j.current.historyCursor,killBuffer:j.current.killBuffer,reverseSearch:j.current.reverseSearch,shortcutsOpen:j.current.shortcutsOpen,selectedRemoteImageId:j.current.selectedRemoteImageId}:j.current}function Ke(e){let t=de.current?.(e);return t?(A(e=>({...e,error:t,shortcutsOpen:!1})),k(null),!0):!1}function qe(e){let t=Ge(),n=t.text.slice(0,t.cursor);je(n&&!/\s$/.test(n)?` ${e}`:e)}function Je(){ct?.endWithSend()||Ye()}function Ye(){if(n)return;let e=Ge(),r=P?.getJSON()??A0(),i=e.isTaskRunning||e.queueSubmissions,a=i?null:C$(e.text,v,b);if(a){A(e=>({...e,error:`Unrecognized command: /${a}`,shortcutsOpen:!1})),k(null);return}let s=_$(e,v,b),c=s??{mode:`submitted`,prompt:``,persistedPrompt:``,historyPrompt:``,action:`Plain`,command:void 0,args:void 0,items:[],elements:[],payloadElements:[],mentionBindings:[]},l=v$(c,o);if(l){A(e=>({...e,error:l,shortcutsOpen:!1})),k(null);return}let u=new Map,d=[];for(let t of e.imageAttachments){let e=pe.current.get(t.id);if(!e){A(e=>({...e,error:`Attached image is no longer available: ${t.placeholder}`,shortcutsOpen:!1})),k(null);return}u.set(t.id,e),d.push({type:t.media,placeholder:t.placeholder,file:e})}let f=[...c.items.filter(e=>e.type===`remote_image`),...d,...c.items.filter(e=>e.type!==`remote_image`)],p={id:crypto.randomUUID(),at:new Date(m.Date.now()).toLocaleTimeString(),mode:i?`queued`:c.mode,prompt:c.prompt,persistedPrompt:c.persistedPrompt,action:i?v2(c,b):c.action,command:c.command,args:c.args,items:f};if(Ke(p))return;for(let e of u.keys())pe.current.delete(e);let h=J$(e,c.persistedPrompt),g=fe.current?.(p,{editableSource:h});M2(g)&&(D.current+=1,g.then(()=>{t!==void 0&&A1(t,null)}).catch(e=>{for(let[e,t]of u)pe.current.set(e,t);t!==void 0&&A1(t,h),ee.current&&(Ce(r),P?.commands.focus(`end`),A(t=>({...t,error:e instanceof Error?e.message:`Could not send prompt`})))}).finally(()=>{--D.current}));let _=s?Y$(e,c.historyPrompt):e.history;N.current=null,ie.current=[],O([]),k(null),Ce(A0()),A(e=>({...e,text:``,cursor:0,elements:[],mentionBindings:[],imageAttachments:[],remoteImages:[],pendingPastes:[],selectedRemoteImageId:null,error:null,shortcutsOpen:!1,history:_,historyCursor:null}))}function Xe(){if(n)return;let e=j.current.history,t=j.current.killBuffer;N.current=null,le.current=null,pe.current.clear(),ie.current=T.current,O(T.current),k(null),Ce(E.current),P?.commands.focus(`end`),A(n=>({...n,history:e,historyCursor:null,killBuffer:t,reverseSearch:null,selectedRemoteImageId:null,error:null,shortcutsOpen:!1}))}function Ze(e){if(n||!P||j.current.history.length===0)return;let t=j.current,r=N.current??t.historyCursor;if(e>0&&r===0&&ce.current){F(ce.current,null),ce.current=null;return}let i=r===null?e<0?0:t.history.length-1:h1(r+e,t.history.length);r===null&&(ce.current=q$(Ge()));let a=t.history[i];Qe(a,i)}function Qe(e,t){F(Z$({source:e,slashCommands:v,mentionCandidates:y}),t)}function F(e,t){let n=e.remoteImages??[];ie.current=n,j.current={...j.current,historyCursor:t,shortcutsOpen:!1},N.current=t,se.current=t,O(n),Ce(b0({state:e,slashCommands:v,mentionCandidates:y,triggers:S})),P?.commands.focus(`end`),A(e=>({...e,historyCursor:t,shortcutsOpen:!1}))}function $e(){n||(k(null),N.current=null,le.current=Ge(),A(e=>({...e,reverseSearch:``,historyCursor:null,shortcutsOpen:!1})))}function et(e){if(n){e.preventDefault();return}if(e.preventDefault(),e.key===`Escape`){it(null),le.current=null;return}if(e.key===`Enter`){le.current=null,A(e=>({...e,reverseSearch:null,shortcutsOpen:!1}));return}if(e.key===`Backspace`){tt(e=>e.slice(0,-1));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){nt(1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`){nt(-1);return}e.key.length===1&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&tt(t=>`${t}${e.key}`)}function tt(e){if(n)return;let t=j.current,r=e(t.reverseSearch??``),i=d1(t.history,r,null);if(!P||!i){it(r);return}rt(i.entry,i.index,r)}function nt(e){if(n||!P)return;let t=j.current,r=t.reverseSearch??``,i=d1(t.history,r,t.historyCursor,e);i&&rt(i.entry,i.index,r)}function rt(e,t,n){let r=P;if(!r)return;let i=Z$({source:e,slashCommands:v,mentionCandidates:y}),a=i.remoteImages??[];ie.current=a,O(a),Ce(b0({state:i,slashCommands:v,mentionCandidates:y,triggers:S})),r.commands.focus(`end`),A(e=>({...e,historyCursor:t,reverseSearch:n,selectedRemoteImageId:null,shortcutsOpen:!1}))}function it(e){if(n)return;let t=le.current;if(!t||!P){A(t=>({...t,reverseSearch:e,shortcutsOpen:!1}));return}let r={...t,history:j.current.history,killBuffer:j.current.killBuffer,reverseSearch:e,historyCursor:null,selectedRemoteImageId:null,shortcutsOpen:!1};N.current=null,ie.current=r.remoteImages,O(r.remoteImages),Ce(b0({state:r,slashCommands:v,mentionCandidates:y,triggers:S})),P.commands.focus(`end`),A(r)}_e.current=n?e=>(e.preventDefault(),!0):Ve,me.current=Me;function at(e){if(!(e.target instanceof Element)||!e.target.closest(`[data-slot="composer-editor"]`))return;if(n){e.preventDefault();return}if(!P||Ve(e))return;if(j.current.reverseSearch!==null){et(e);return}if(j.current.shortcutsOpen&&e.key===`Escape`){e.preventDefault(),ke();return}if(e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&De(Ge())){e.preventDefault(),Ae();return}if(r4(e)){e.preventDefault(),P.chain().focus().setHardBreak().run(),N.current=null,k(null);return}if(M.current){if(y2(e)||b2(e)){e.preventDefault(),st(y2(e)?-1:1);return}if(e.key===`Tab`){e.preventDefault(),Te();return}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),xe.length===0){k(null),Je();return}Te();return}if(e.key===`Escape`){e.preventDefault(),k(null);return}}if(i4(e)){let t=i2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text}))),N.current=null;return}let t=a4(e);if(t!==null){e.preventDefault(),o2(P,t),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`e`){e.preventDefault(),a2(P),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){let t=n2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`u`){let t=r2(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`y`&&j.current.killBuffer){e.preventDefault(),p2(P,ae.current??j.current.killBuffer);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){e.preventDefault(),$e();return}if((e.key===`Backspace`||e.key===`Delete`)&&s4(P)){e.preventDefault(),N.current=null,k(null);return}if((e.key===`Backspace`||e.key===`Delete`)&&m2(P,e.key)){e.preventDefault(),N.current=null;return}if((e.key===`Backspace`||e.key===`Delete`||e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey)&&(N.current=null),e.key===`Enter`&&!e.shiftKey&&!e.altKey){e.preventDefault(),Je();return}let r=o4(e);if(r!==null&&!M.current){let t=Ge();if(e.key===`ArrowUp`&&(_2(P)||t.cursor===0)&&t.remoteImages.length>0){e.preventDefault(),Re(t.remoteImages.length-1);return}f1(t.text,t.cursor,r)&&(e.preventDefault(),Ze(r))}}function ot(e){if(n){e.preventDefault();return}e.target instanceof Element&&e.target.closest(`[data-slot="composer-editor"]`)&&ze()}function st(e){n||k(t=>{if(!t)return t;let n=K1(t,v,y,a).length;return n===0?t:{...t,selectedIndex:h1(t.selectedIndex+e,n)}})}let ct=d0({dictation:u,disabled:n,insertTranscript:qe,submitDraft:Ye});return(0,z.jsx)(GQ,{value:{state:re,disabled:n,commandTriggers:b,activePopup:ne,suggestions:xe,attachedImages:pe.current,setEditorPlaceholder:ye,actions:{acceptSuggestion:Te,toggleSlashMenu:Ee,insertText:je,attachImageFiles:Pe,removeImageAttachment:Fe,addRemoteImage:Ie,handleDrop:Le,insertPaste:Ue,insertRichLink:We,openShortcuts:Oe,closeShortcuts:ke,toggleShortcuts:Ae,submit:Je,reset:Xe},meta:{editor:P}},children:(0,z.jsx)(J1,{value:ct?.api??null,children:(0,z.jsx)(`section`,{"data-slot":`composer`,className:I(`border-border bg-card relative border font-[inherit]`,c),children:(0,z.jsxs)(`div`,{onKeyDownCapture:at,onMouseDownCapture:ot,children:[l,h.hasLayoutChildren?null:(0,z.jsx)(P2,{})]})})})})}function P2(){let e=(0,G.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(V2,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsxs)(z.Fragment,{children:[t,(0,z.jsxs)(F2,{children:[(0,z.jsx)(L2,{}),(0,z.jsx)(JQ,{}),(0,z.jsx)(z2,{}),(0,z.jsx)(B2,{})]}),(0,z.jsx)(G2,{}),(0,z.jsx)(J2,{})]}),e[1]=n):n=e[1],n}function F2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function I2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex flex-wrap items-center gap-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function L2(e){let t=(0,G.c)(14),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=KQ(`Composer.RemoteImages`);if(i.remoteImages.length===0)return null;let a;t[3]===n?a=t[4]:(a=I(`border-border space-y-1 border-b pb-2 text-sm`,n),t[3]=n,t[4]=a);let o;if(t[5]!==i.remoteImages||t[6]!==i.selectedRemoteImageId){let e;t[8]===i.selectedRemoteImageId?e=t[9]:(e=(e,t)=>(0,z.jsxs)(`div`,{className:I(`flex h-6 items-center gap-2 rounded-sm px-2`,i.selectedRemoteImageId===e.id?`bg-primary text-primary-foreground`:`text-sky-500`),children:[(0,z.jsxs)(`span`,{className:`shrink-0`,children:[`[Image #`,t+1,`]`]}),(0,z.jsx)(`span`,{className:`truncate text-xs opacity-70`,children:e.url})]},e.id),t[8]=i.selectedRemoteImageId,t[9]=e),o=i.remoteImages.map(e),t[5]=i.remoteImages,t[6]=i.selectedRemoteImageId,t[7]=o}else o=t[7];let s;return t[10]!==r||t[11]!==a||t[12]!==o?(s=(0,z.jsx)(`div`,{className:a,...r,children:o}),t[10]=r,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function R2(e){e.dataTransfer.types.includes(`Files`)&&e.preventDefault()}function z2(e){let t=(0,G.c)(29),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,onDragEnter:r,onDragOver:i,onDrop:a,placeholder:s,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?`Type a message or / for commands`:s,{disabled:l,meta:u,actions:d,setEditorPlaceholder:f}=KQ(`Composer.Editor`),p,m;t[7]!==c||t[8]!==f?(p=()=>{f(c)},m=[c,f],t[7]=c,t[8]=f,t[9]=p,t[10]=m):(p=t[9],m=t[10]),(0,R.useLayoutEffect)(p,m);let h=l?``:void 0,g;t[11]===r?g=t[12]:(g=e=>{r?.(e),R2(e)},t[11]=r,t[12]=g);let _;t[13]===i?_=t[14]:(_=e=>{i?.(e),R2(e)},t[13]=i,t[14]=_);let v;t[15]!==d||t[16]!==a?(v=e=>{a?.(e),!e.defaultPrevented&&d.handleDrop(e.dataTransfer)&&e.preventDefault()},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y;t[18]===u.editor?y=t[19]:(y=(0,z.jsx)(aq,{editor:u.editor}),t[18]=u.editor,t[19]=y);let b;return t[20]!==n||t[21]!==l||t[22]!==o||t[23]!==h||t[24]!==g||t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,z.jsx)(`div`,{"data-slot":`composer-frame`,className:n,"aria-disabled":l,"data-disabled":h,onDragEnter:g,onDragOver:_,onDrop:v,...o,children:y}),t[20]=n,t[21]=l,t[22]=o,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function B2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=KQ(`Composer.Error`);if(!i.error)return null;let a;t[3]===n?a=t[4]:(a=I(`border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==i.error||t[7]!==a?(o=(0,z.jsx)(`div`,{role:`alert`,className:a,...r,children:i.error}),t[5]=r,t[6]=i.error,t[7]=a,t[8]=o):o=t[8],o}function V2(e){let t=(0,G.c)(25),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,suggestions:a,actions:o}=KQ(`Composer.Popup`),{acceptSuggestion:s}=o;if(!i)return null;let c;t[3]===a?c=t[4]:(c=a.some(H2),t[3]=a,t[4]=c);let l=c,u;t[5]===n?u=t[6]:(u=I(`border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg`,n),t[5]=n,t[6]=u);let d;if(t[7]!==s||t[8]!==i||t[9]!==a||t[10]!==l){let e;t[12]!==s||t[13]!==i||t[14]!==l?(e=(e,t)=>(0,z.jsx)(U2,{selected:t===i.selectedIndex,icon:l?e.icon:null,token:m$(e),takesArgs:e.supportsArgs===!0,description:e.detail,onMouseDown:()=>s({index:t})},`item:${e.id}`),t[12]=s,t[13]=i,t[14]=l,t[15]=e):e=t[15],d=a.map(e),t[7]=s,t[8]=i,t[9]=a,t[10]=l,t[11]=d}else d=t[11];let f;t[16]===a.length?f=t[17]:(f=a.length===0?(0,z.jsx)(`div`,{className:`text-muted-foreground px-2 py-1 text-[13px] leading-4`,children:`no matches`}):null,t[16]=a.length,t[17]=f);let p;t[18]!==d||t[19]!==f?(p=(0,z.jsxs)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto p-1`,role:`listbox`,"aria-label":`Suggestions`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;return t[21]!==r||t[22]!==u||t[23]!==p?(m=(0,z.jsx)(`div`,{className:u,...r,children:p}),t[21]=r,t[22]=u,t[23]=p,t[24]=m):m=t[24],m}function H2(e){return e.icon}function U2(e){let t=(0,G.c)(23),{selected:n,icon:r,token:i,takesArgs:a,description:o,onMouseDown:s}=e,c=(0,R.useRef)(null),l,u;t[0]===n?(l=t[1],u=t[2]):(l=()=>{n&&c.current?.scrollIntoView({block:`nearest`})},u=[n],t[0]=n,t[1]=l,t[2]=u),(0,R.useEffect)(l,u);let d=n?`bg-accent text-foreground`:`text-foreground/80 hover:bg-accent/60`,f;t[3]===d?f=t[4]:(f=I(`flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0`,d),t[3]=d,t[4]=f);let p;t[5]===s?p=t[6]:(p=e=>{e.preventDefault(),s()},t[5]=s,t[6]=p);let m;t[7]===r?m=t[8]:(m=r===null?null:(0,z.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:r}),t[7]=r,t[8]=m);let h;t[9]===i?h=t[10]:(h=(0,z.jsx)(`span`,{className:`truncate`,children:i}),t[9]=i,t[10]=h);let g;t[11]===a?g=t[12]:(g=a?(0,z.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`args`}):null,t[11]=a,t[12]=g);let _;t[13]===o?_=t[14]:(_=(0,z.jsx)(`span`,{className:`text-muted-foreground truncate`,children:o}),t[13]=o,t[14]=_);let v;return t[15]!==n||t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,z.jsxs)(`button`,{ref:c,type:`button`,role:`option`,"aria-selected":n,className:f,onMouseDown:p,children:[m,h,g,_]}),t[15]=n,t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var W2=[{title:`Send`,items:[[`Enter`,`send or queue`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`]]},{title:`Edit`,items:[[`Ctrl K`,`kill to end`],[`Ctrl U`,`kill to start`],[`Ctrl W`,`kill word`],[`Ctrl Y`,`yank`]]},{title:`Navigate`,items:[[`Ctrl P/N`,`history`],[`Ctrl R`,`reverse search`],[`Ctrl E`,`line end`],[`Alt B/F`,`word move`]]}];function G2(e){let t=(0,G.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,actions:a}=KQ(`Composer.Shortcuts`),{closeShortcuts:o}=a;if(!i.shortcutsOpen||!g$(i))return null;let s;t[3]===n?s=t[4]:(s=I(`border-border bg-popover border-t px-3 py-3 text-xs`,n),t[3]=n,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(`div`,{className:`text-foreground font-medium`,children:`Keyboard shortcuts`}),t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[c,(0,z.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1`,onClick:o,children:`close`})]}),t[6]=o,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:W2.map(K2)}),t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==s||t[11]!==l?(d=(0,z.jsxs)(`div`,{role:`dialog`,"aria-label":`Keyboard shortcuts`,className:s,...r,children:[l,u]}),t[9]=r,t[10]=s,t[11]=l,t[12]=d):d=t[12],d}function K2(e){return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:e.title}),(0,z.jsx)(`div`,{className:`space-y-1`,children:e.items.map(q2)})]},e.title)}function q2(e){let[t,n]=e;return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),(0,z.jsx)(`span`,{className:`text-muted-foreground text-right`,children:n})]},`${t}-${n}`)}function J2(e){let t=(0,G.c)(29),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,state:a}=KQ(`Composer.Footer`);if(a.reverseSearch!==null){let e;t[3]===n?e=t[4]:(e=I(`border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]`,n),t[3]=n,t[4]=e);let i,o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:`Ctrl R`}),o=(0,z.jsx)(`span`,{children:`reverse-i-search:`}),t[5]=i,t[6]=o):(i=t[5],o=t[6]);let s=a.reverseSearch||`_`,c;t[7]===s?c=t[8]:(c=(0,z.jsx)(`span`,{className:`text-foreground`,children:s}),t[7]=s,t[8]=c);let l,u,d,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`span`,{children:`Ctrl R previous`}),u=(0,z.jsx)(`span`,{children:`Ctrl S next`}),d=(0,z.jsx)(`span`,{children:`Enter accept`}),f=(0,z.jsx)(`span`,{children:`Esc cancel`}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):(l=t[9],u=t[10],d=t[11],f=t[12]);let p;return t[13]!==r||t[14]!==e||t[15]!==c?(p=(0,z.jsxs)(`div`,{className:e,...r,children:[i,o,c,l,u,d,f]}),t[13]=r,t[14]=e,t[15]=c,t[16]=p):p=t[16],p}let o;t[17]!==i||t[18]!==a.isTaskRunning||t[19]!==a.queueSubmissions?(o=i?[[`Enter`,`insert`],[`Tab`,`insert`],[`Esc`,`dismiss`]]:[[`Enter`,a.isTaskRunning||a.queueSubmissions?`queue`:`send`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`],[`Ctrl J/M`,`newline`],[`Ctrl P/N`,`history`],[`Ctrl E`,`line end`],[`Ctrl K`,`kill`],[`Ctrl U`,`kill back`],[`Ctrl W`,`word kill`],[`Alt B/F`,`word move`],[`Ctrl Y`,`yank`]],t[17]=i,t[18]=a.isTaskRunning,t[19]=a.queueSubmissions,t[20]=o):o=t[20];let s=o,c;t[21]===n?c=t[22]:(c=I(`border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]`,n),t[21]=n,t[22]=c);let l;t[23]===s?l=t[24]:(l=s.map(Y2),t[23]=s,t[24]=l);let u;return t[25]!==r||t[26]!==c||t[27]!==l?(u=(0,z.jsx)(`div`,{className:c,...r,children:l}),t[25]=r,t[26]=c,t[27]=l,t[28]=u):u=t[28],u}function Y2(e){let[t,n]=e;return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),n]},`${t}-${n}`)}function X2(e){let t=(0,G.c)(19),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({accept:i,multiple:a,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`image/*,video/*,audio/*`:i,s=a===void 0||a,{actions:c,disabled:l}=KQ(`Composer.AttachFiles`),u=(0,R.useRef)(null),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>u.current?.click(),t[5]=d):d=t[5];let f;t[6]!==n||t[7]!==r?(f=(0,z.jsx)(n4,{action:d,disabled:n,...r}),t[6]=n,t[7]=r,t[8]=f):f=t[8];let p=l||n,m;t[9]===c?m=t[10]:(m=e=>{let t=e.currentTarget;t.files&&c.attachImageFiles(t.files),t.value=``},t[9]=c,t[10]=m);let h;t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==m?(h=(0,z.jsx)(`input`,{ref:u,type:`file`,accept:o,multiple:s,"aria-label":`Attach media files`,hidden:!0,disabled:p,onChange:m}),t[11]=o,t[12]=s,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==f||t[17]!==h?(g=(0,z.jsxs)(z.Fragment,{children:[f,h]}),t[16]=f,t[17]=h,t[18]=g):g=t[18],g}function Z2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({url:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=KQ(`Composer.AddRemoteImage`),a;t[3]!==i||t[4]!==r?(a=()=>i.addRemoteImage(r),t[3]=i,t[4]=r,t[5]=a):a=t[5];let o;return t[6]!==n||t[7]!==a?(o=(0,z.jsx)(n4,{action:a,...n}),t[6]=n,t[7]=a,t[8]=o):o=t[8],o}function Q2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({content:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=KQ(`Composer.InsertPaste`),a;t[3]!==i||t[4]!==n?(a=()=>i.insertPaste(n),t[3]=i,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==a?(o=(0,z.jsx)(n4,{action:a,...r}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function $2(e){let t=(0,G.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({href:n,label:r,metadata:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{actions:o}=KQ(`Composer.InsertRichLink`),s;t[5]!==o||t[6]!==n||t[7]!==r||t[8]!==i?(s=()=>o.insertRichLink(n,r,i),t[5]=o,t[6]=n,t[7]=r,t[8]=i,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,z.jsx)(n4,{action:s,...a}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function e4(e){let t=(0,G.c)(3),{actions:n}=KQ(`Composer.Submit`),r;return t[0]!==n.submit||t[1]!==e?(r=(0,z.jsx)(n4,{action:n.submit,...e}),t[0]=n.submit,t[1]=e,t[2]=r):r=t[2],r}function t4(e){let t=(0,G.c)(3),{actions:n}=KQ(`Composer.Reset`),r;return t[0]!==n.reset||t[1]!==e?(r=(0,z.jsx)(n4,{action:n.reset,...e}),t[0]=n.reset,t[1]=e,t[2]=r):r=t[2],r}function n4(e){let t=(0,G.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({action:n,onClick:i,disabled:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{disabled:o}=KQ(`Composer.ActionTrigger`),s=o||r,c;t[5]!==n||t[6]!==i?(c=e=>{i?.(e),e.defaultPrevented||n()},t[5]=n,t[6]=i,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==s||t[10]!==c?(l=(0,z.jsx)(y,{...a,disabled:s,onClick:c}),t[8]=a,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function r4(e){if(e.metaKey)return!1;if(e.key===`Enter`)return e.altKey&&!e.ctrlKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&(t===`j`||t===`m`)}function i4(e){if(e.metaKey)return!1;if(e.key===`Backspace`)return e.ctrlKey||e.altKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&t===`w`||e.ctrlKey&&e.altKey&&t===`h`}function a4(e){if(e.metaKey||e.shiftKey)return null;if(e.key===`ArrowLeft`&&(e.altKey||e.ctrlKey))return-1;if(e.key===`ArrowRight`&&(e.altKey||e.ctrlKey))return 1;if(!e.altKey||e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`b`?-1:t===`f`?1:null}function o4(e){if(e.key===`ArrowUp`)return-1;if(e.key===`ArrowDown`)return 1;if(e.metaKey||e.altKey||e.shiftKey||!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`p`?-1:t===`n`?1:null}function s4(e){let{doc:t,selection:n}=e.state;return n.empty||n.from>1||n.to<t.content.size-1?!1:(e.commands.setContent(A0(),{emitUpdate:!0}),e.commands.focus(`start`),e.commands.setTextSelection(1),!0)}var c4={Root:j2,Trigger:L1,Command:R1,Mention:z1,Content:F2,Toolbar:I2,RemoteImages:L2,Attachments:JQ,Editor:z2,Error:B2,Popup:V2,Shortcuts:G2,Footer:J2,AttachFiles:X2,AddRemoteImage:Z2,InsertPaste:Q2,InsertRichLink:$2,Dictate:$1,CancelDictation:e0,Submit:e4,Reset:t4};(0,R.createContext)(null);function l4(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();for(let e of r.querySelectorAll(`[data-persisted-source]`)){let t=e.getAttribute(`data-persisted-source`);t!==null&&e.replaceWith(t)}return r.textContent??``}function u4(e){let t=(0,G.c)(6),{text:n}=e,r,i;if(t[0]!==n){let e=oN(n);r=p4,i=e.map(d4),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a;return t[3]!==r||t[4]!==i?(a=(0,z.jsx)(`span`,{onCopy:r,children:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a}function d4(e){switch(e.kind){case`text`:return e.value;case`inline-code`:return(0,z.jsx)(`code`,{"data-persisted-source":e.source,className:`bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]`,children:e.value},e.start);case`code-block`:return(0,z.jsx)(`span`,{"data-persisted-source":e.source,className:`bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2`,children:(0,z.jsx)(`code`,{className:`font-mono text-[0.9em]`,children:e.value})},e.start);case`skill-link`:return(0,z.jsx)(f4,{name:e.name,source:e.source,skillId:e.skillId,title:e.href},e.start);case`standalone-skill`:return(0,z.jsx)(f4,{name:e.name,source:e.source},e.start);case`mention`:return(0,z.jsx)(`span`,{"data-token":`mention`,"data-persisted-source":e.source,className:`bg-foreground/10 rounded-sm px-0.5 font-medium`,children:e.label},e.start);case`link`:return/^(?:https?:|mailto:)/.test(e.href)?(0,z.jsx)(`a`,{href:e.href,"data-persisted-source":e.source,className:`text-primary underline underline-offset-2`,target:`_blank`,rel:`noreferrer`,children:e.label},e.start):e.source}}function f4(e){let t=(0,G.c)(9),{name:n,source:r,skillId:i,title:a}=e,o=i?void 0:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(vi,{"aria-hidden":`true`,className:`size-3.5 self-center`}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,z.jsx)(`span`,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==c||t[7]!==a?(l=(0,z.jsxs)(`span`,{"data-skill-id":i,"data-skill-name":o,"data-persisted-source":r,title:a,className:`text-primary inline-flex items-baseline gap-1`,children:[s,c]}),t[3]=i,t[4]=r,t[5]=o,t[6]=c,t[7]=a,t[8]=l):l=t[8],l}function p4(e){let t=l4(e.currentTarget,window.getSelection());t!==null&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())}var m4=typeof global==`object`&&global&&global.Object===Object&&global,h4=typeof self==`object`&&self&&self.Object===Object&&self,g4=m4||h4||Function(`return this`)(),_4=g4.Symbol,v4=Object.prototype,y4=v4.hasOwnProperty,b4=v4.toString,x4=_4?_4.toStringTag:void 0;function S4(e){var t=y4.call(e,x4),n=e[x4];try{e[x4]=void 0;var r=!0}catch{}var i=b4.call(e);return r&&(t?e[x4]=n:delete e[x4]),i}var C4=Object.prototype.toString;function w4(e){return C4.call(e)}var T4=`[object Null]`,E4=`[object Undefined]`,D4=_4?_4.toStringTag:void 0;function O4(e){return e==null?e===void 0?E4:T4:D4&&D4 in Object(e)?S4(e):w4(e)}function k4(e){return typeof e==`object`&&!!e}var A4=`[object Symbol]`;function j4(e){return typeof e==`symbol`||k4(e)&&O4(e)==A4}function M4(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var N4=Array.isArray,P4=1/0,F4=_4?_4.prototype:void 0,I4=F4?F4.toString:void 0;function L4(e){if(typeof e==`string`)return e;if(N4(e))return M4(e,L4)+``;if(j4(e))return I4?I4.call(e):``;var t=e+``;return t==`0`&&1/e==-P4?`-0`:t}function R4(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var z4=`[object AsyncFunction]`,B4=`[object Function]`,V4=`[object GeneratorFunction]`,H4=`[object Proxy]`;function U4(e){if(!R4(e))return!1;var t=O4(e);return t==B4||t==V4||t==z4||t==H4}var W4=g4[`__core-js_shared__`],G4=function(){var e=/[^.]+$/.exec(W4&&W4.keys&&W4.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function K4(e){return!!G4&&G4 in e}var q4=Function.prototype.toString;function J4(e){if(e!=null){try{return q4.call(e)}catch{}try{return e+``}catch{}}return``}var Y4=/[\\^$.*+?()[\]{}|]/g,X4=/^\[object .+?Constructor\]$/,Z4=Function.prototype,Q4=Object.prototype,$4=Z4.toString,e3=Q4.hasOwnProperty,t3=RegExp(`^`+$4.call(e3).replace(Y4,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function n3(e){return!R4(e)||K4(e)?!1:(U4(e)?t3:X4).test(J4(e))}function r3(e,t){return e?.[t]}function i3(e,t){var n=r3(e,t);return n3(n)?n:void 0}function a3(e,t){return e===t||e!==e&&t!==t}var o3=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s3=/^\w*$/;function c3(e,t){if(N4(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||j4(e)?!0:s3.test(e)||!o3.test(e)||t!=null&&e in Object(t)}var l3=i3(Object,`create`);function u3(){this.__data__=l3?l3(null):{},this.size=0}function d3(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var f3=`__lodash_hash_undefined__`,p3=Object.prototype.hasOwnProperty;function m3(e){var t=this.__data__;if(l3){var n=t[e];return n===f3?void 0:n}return p3.call(t,e)?t[e]:void 0}var h3=Object.prototype.hasOwnProperty;function g3(e){var t=this.__data__;return l3?t[e]!==void 0:h3.call(t,e)}var _3=`__lodash_hash_undefined__`;function v3(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=l3&&t===void 0?_3:t,this}function y3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}y3.prototype.clear=u3,y3.prototype.delete=d3,y3.prototype.get=m3,y3.prototype.has=g3,y3.prototype.set=v3;function b3(){this.__data__=[],this.size=0}function x3(e,t){for(var n=e.length;n--;)if(a3(e[n][0],t))return n;return-1}var S3=Array.prototype.splice;function C3(e){var t=this.__data__,n=x3(t,e);return n<0?!1:(n==t.length-1?t.pop():S3.call(t,n,1),--this.size,!0)}function w3(e){var t=this.__data__,n=x3(t,e);return n<0?void 0:t[n][1]}function T3(e){return x3(this.__data__,e)>-1}function E3(e,t){var n=this.__data__,r=x3(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function D3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}D3.prototype.clear=b3,D3.prototype.delete=C3,D3.prototype.get=w3,D3.prototype.has=T3,D3.prototype.set=E3;var O3=i3(g4,`Map`);function k3(){this.size=0,this.__data__={hash:new y3,map:new(O3||D3),string:new y3}}function A3(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function j3(e,t){var n=e.__data__;return A3(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function M3(e){var t=j3(this,e).delete(e);return this.size-=+!!t,t}function N3(e){return j3(this,e).get(e)}function P3(e){return j3(this,e).has(e)}function F3(e,t){var n=j3(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function I3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}I3.prototype.clear=k3,I3.prototype.delete=M3,I3.prototype.get=N3,I3.prototype.has=P3,I3.prototype.set=F3;var L3=`Expected a function`;function R3(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(L3);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(R3.Cache||I3),n}R3.Cache=I3;var z3=500;function B3(e){var t=R3(e,function(e){return n.size===z3&&n.clear(),e}),n=t.cache;return t}var V3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,H3=/\\(\\)?/g,U3=B3(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(V3,function(e,n,r,i){t.push(r?i.replace(H3,`$1`):n||e)}),t});function W3(e){return e==null?``:L4(e)}function G3(e,t){return N4(e)?e:c3(e,t)?[e]:U3(W3(e))}var K3=1/0;function q3(e){if(typeof e==`string`||j4(e))return e;var t=e+``;return t==`0`&&1/e==-K3?`-0`:t}function J3(e,t){t=G3(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[q3(t[n++])];return n&&n==r?e:void 0}function Y3(e,t,n){var r=e==null?void 0:J3(e,t);return r===void 0?n:r}function X3(e){if(!e)return{};let t={...e};return delete t.whenNullish,delete t.locale,t}function Z3(e,t){return e==null||Number.isNaN(e)?t?.whenNullish??`—`:new Intl.NumberFormat(t?.locale??`en-US`,X3(t)).format(e)}var Q3=Z3;function $3(e,t){return Z3(e,{notation:`compact`,maximumFractionDigits:1,...t})}var e6=`pending-chat-prefill`;function t6(){try{let e=sessionStorage.getItem(e6);return e?JSON.parse(e):null}catch{return sessionStorage.removeItem(e6),null}}function n6(e){sessionStorage.setItem(e6,JSON.stringify(e))}function r6(){sessionStorage.removeItem(e6)}function i6(e){let t=$h(e.metadata)?e.metadata.persistedPrompt:void 0;if(typeof t!=`string`)throw Error(`Message ${e.id} has no persistedPrompt: send it with useAgent().submit.`);return t}var a6=class{chat;uploadFile;submissions=new sy;onResetChat;constructor(e){this.chat=e.chat,this.uploadFile=e.uploadFile,this.onResetChat=e.onResetChat}bind(e){this.chat=e}initialize(e){let t=new AbortController;return queueMicrotask(()=>{t.signal.aborted||this.consumePrefill(e)}),()=>t.abort()}submit(e){this.chat.clearError();let{files:t=[],...n}=e,r=this.chat.id;return this.submissions.run(async()=>{if(t.length===0){this.assertCurrentChat(r),this.send(n);return}let e=await this.uploadFiles(r,t);this.assertCurrentChat(r),this.send({...n,metadata:{...n.metadata,uploads:e}})})}async uploadFiles(e,t){return Promise.all(t.map(t=>this.uploadFile(e,t)))}assertCurrentChat(e){if(this.chat.id!==e)throw Error(`The chat changed before the submission was sent.`)}send({prompt:e,persistedPrompt:t,metadata:n}){this.chat.sendMessage({role:`user`,parts:[{type:`text`,text:e}],metadata:{...n,persistedPrompt:t}})}clearChat(){for(let{id:e}of this.chat.experimental_queuedMessages)this.chat.experimental_removeQueuedMessage(e);this.chat.setMessages([])}setChat(e){this.chat.setMessages(e)}stop(){this.chat.stop()}resetChat(e){let t=crypto.randomUUID();e&&n6({prompt:e,targetChatId:t}),this.onResetChat(t)}consumePrefill(e){let t=t6();!t||t.targetChatId!==e||(r6(),this.submit({prompt:t.prompt,persistedPrompt:t.prompt}))}getTriggeringUserMessage(e){let{messages:t}=this.chat,n=t.findIndex(t=>t.role===`assistant`&&t.parts.some(t=>`toolCallId`in t&&t.toolCallId===e));if(n<=0)return null;let r=t[n-1];return r?.role===`user`?r:null}getLastUserMessageId(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t].id;return null}getLastAssistantMessage(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}get hasSubmitted(){return this.chat.messages.length>0}};async function o6(e,t,n){let r=t?.[n.toolName];n.toolName.startsWith(`render`)&&r?.static===!1&&r.requiresUserInput!==!0&&await e.addToolOutput({toolCallId:n.toolCallId,tool:n.toolName,output:`rendered`,state:`output-available`})}function s6(e){let t=Wy({id:e.chatId,messages:e.initialMessages,transport:e.transport,throttle:50,experimental_queue:!0,resume:e.resume,onData:e.onData,onFinish:e.onFinish,sendAutomaticallyWhen:c6,onToolCall(n){let{toolCall:r}=n;o6(t,e.registry,r)}});return t}function c6(e){return Ny(e)||My(e)}function l6(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(u6,{...e}),t[0]=e,t[1]=n),n}function u6(e){let t=(0,G.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={initial:`smooth`},t[0]=n):n=t[0];let{scrollRef:r,contentRef:i}=Aj(n),{hasSubmitted:a}=w6(),o;t[1]===e.className?o=t[2]:(o=I(`@container mx-auto h-full w-full overflow-y-auto`,e.className),t[1]=e.className,t[2]=o);let s=a?`min-h-full`:`h-full justify-center`,c;t[3]===s?c=t[4]:(c=I(`relative mx-auto flex w-full flex-col`,s),t[3]=s,t[4]=c);let l;t[5]!==i||t[6]!==e.children||t[7]!==c?(l=(0,z.jsx)(`div`,{ref:i,"data-slot":`content`,className:c,children:e.children}),t[5]=i,t[6]=e.children,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==r||t[10]!==o||t[11]!==l?(u=(0,z.jsx)(`div`,{id:`agent`,"data-slot":`agent`,className:o,ref:r,children:l}),t[9]=r,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}function d6(e){let t=(0,G.c)(12),{hasSubmitted:n}=w6(),r;t[0]!==n||t[1]!==e.className?(r=I(n?I(`bg-background sticky top-0 z-10 shrink-0 space-y-1 backdrop-blur-md`,e.className):`relative flex justify-center py-4`),t[0]=n,t[1]=e.className,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={layout:{type:`tween`,ease:[.4,0,.2,1],duration:.4}},t[3]=i):i=t[3];let a=n?`text-left`:`space-y-3 text-center`,o;t[4]===a?o=t[5]:(o=I(a),t[4]=a,t[5]=o);let s;t[6]!==e.children||t[7]!==o?(s=(0,z.jsx)(`div`,{className:o,children:e.children}),t[6]=e.children,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==r||t[10]!==s?(c=(0,z.jsx)(wj.div,{layout:!0,className:r,transition:i,children:s}),t[9]=r,t[10]=s,t[11]=c):c=t[11],c}d6.displayName=`AgentHeader.Root`;function f6(e){let t=(0,G.c)(6),{hasSubmitted:n}=w6(),r;t[0]!==n||t[1]!==e.children||t[2]!==e.icon?(r=!n&&(0,z.jsx)(wj.div,{exit:{opacity:0},transition:{duration:.2},children:(0,z.jsxs)(`h1`,{className:`flex items-center justify-center gap-2 text-2xl font-medium tracking-tight`,children:[e.icon,e.children??`How can I help today?`]})},`agent-header-initial`),t[0]=n,t[1]=e.children,t[2]=e.icon,t[3]=r):r=t[3];let i;return t[4]===r?i=t[5]:(i=(0,z.jsx)(Mk,{mode:`sync`,children:r}),t[4]=r,t[5]=i),i}f6.displayName=`AgentHeader.Hero`;function p6(e){let t=(0,G.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,z.jsx)(wj.h2,{layout:`position`,className:`text-muted-foreground text-sm font-medium`,children:e.children}),t[0]=e.children,t[1]=n),n}p6.displayName=`AgentHeader.Title`;function m6(e){let t=(0,G.c)(5),{hasSubmitted:n}=w6(),r;t[0]!==n||t[1]!==e.children?(r=n&&!!e.children&&(0,z.jsx)(wj.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:`text-muted-foreground text-sm`,children:e.children}),t[0]=n,t[1]=e.children,t[2]=r):r=t[2];let i;return t[3]===r?i=t[4]:(i=(0,z.jsx)(Mk,{children:r}),t[3]=r,t[4]=i),i}m6.displayName=`AgentHeader.Description`;var h6={Root:d6,Hero:f6,Title:p6,Description:m6},g6=(0,R.createContext)(void 0),_6=(0,R.createContext)(`ready`),v6=(0,R.createContext)(void 0),y6=(0,R.createContext)(null),b6=(0,R.createContext)(void 0);function x6({chatId:e,children:t,skipInitialView:n,debugMode:r,registry:i,initialMessages:a,transport:o,resume:s,onData:c,onFinish:l,onResetChat:u}){let d=s6({chatId:e,transport:o,registry:i,initialMessages:a,resume:s,onData:c,onFinish:l}),[f,p]=(0,R.useState)(r),m=(0,R.useCallback)(()=>p(e=>!e),[]),h=(0,R.useRef)(u);(0,R.useEffect)(()=>{h.current=u},[u]);let g=(0,R.useCallback)(e=>{h.current(e)},[]),[_]=(0,R.useState)(()=>new a6({chat:d,uploadFile:o.uploadFile.bind(o),onResetChat:g}));_.bind(d),(0,R.useEffect)(()=>_.initialize(e),[_,e]);let v=(0,R.useMemo)(()=>({clearChat:()=>_.clearChat(),resetChat:e=>_.resetChat(e),submit:e=>_.submit(e),setChat:e=>_.setChat(e),getTriggeringUserMessage:e=>_.getTriggeringUserMessage(e),getLastUserMessageId:()=>_.getLastUserMessageId(),stop:()=>_.stop()}),[_]),y=(0,R.useMemo)(()=>({chatId:e,registry:i,debugMode:f,toggleDebugMode:m,...v}),[e,i,f,m,v]),b=(0,R.useMemo)(()=>d,[d.id,d.messages,d.status,d.error,d.experimental_queuedMessages]),x=!!n||d.messages.length>0,S=(0,R.useMemo)(()=>({hasSubmitted:x}),[x]);return(0,z.jsx)(y6,{value:_,children:(0,z.jsx)(g6,{value:y,children:(0,z.jsx)(_6,{value:d.status,children:(0,z.jsx)(v6,{value:b,children:(0,z.jsx)(b6,{value:S,children:t})})})})})}function S6(){let e=(0,R.use)(g6);if(e===void 0)throw Error(`useAgent must be used within an AgentProvider`);return e}function C6(){return{status:(0,R.use)(_6)}}function w6(){let e=(0,R.use)(b6);if(e===void 0)throw Error(`useAgentMeta must be used within an AgentProvider`);return e}function T6(){let e=(0,R.use)(v6);if(e===void 0)throw Error(`useAgentMessages must be used within an AgentProvider`);return e}function E6(e,t){return t.map((t,n)=>({citation:t,order:n,at:t.endIndex??e.length})).sort((e,t)=>e.at-t.at||e.order-t.order)}function D6(e){return(e??[]).filter(e=>e.source.sourceType===`url`)}function O6(e){let t=new Set(e.parts.flatMap(e=>e.type===`text`?D6(e.citations).map(({source:e})=>e.url):[])),n=new Map,r=(e,t)=>{n.has(e)||n.set(e,{url:e,title:t})};for(let n of e.parts){if(n.type===`text`)for(let{citation:e}of E6(n.text,D6(n.citations)))r(e.source.url,e.source.title);n.type===`source-url`&&!t.has(n.url)&&r(n.url,n.title)}return[...n.values()]}function k6(e,t){let n=e.findIndex(e=>e.url===t);return n===-1?null:n+1}function A6(e,t){return t===`streaming`||t===`submitted`?!1:e===`input-streaming`||e===`input-available`}function j6(e,t){return A6(e.state,t)}function M6(e){return Object.entries(e).reduce((e,[t,n])=>(n.static||(e[t]={inputSchema:Le(n.inputSchema,{io:`input`,unrepresentable:`any`}),description:n.description}),e),{})}function N6(e){let t=(0,G.c)(12),{children:n,as:r,className:i,dir:a,duration:o,enabled:s}=e,c=r===void 0?`p`:r,l=s===void 0||s,u=l&&`shimmer`,d;t[0]!==i||t[1]!==u?(d=I(u,i),t[0]=i,t[1]=u,t[2]=d):d=t[2];let f;t[3]!==o||t[4]!==l?(f=l&&o!==void 0?{animationDuration:`${o}s`}:void 0,t[3]=o,t[4]=l,t[5]=f):f=t[5];let p;return t[6]!==c||t[7]!==n||t[8]!==a||t[9]!==d||t[10]!==f?(p=(0,z.jsx)(c,{dir:a,className:d,style:f,children:n}),t[6]=c,t[7]=n,t[8]=a,t[9]=d,t[10]=f,t[11]=p):p=t[11],p}function P6(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`size-3.5 shrink-0 transition-transform group-data-[panel-open]:rotate-90`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(Ct,{"aria-hidden":!0,className:r}),t[2]=r,t[3]=i),i}function F6(e){return I(`group hover:bg-muted/30 flex min-h-7 w-full gap-2 rounded-sm py-1 text-left transition-colors`,e)}(0,R.createContext)(null);var I6=(0,R.createContext)(void 0),L6=(0,R.createContext)(void 0);function R6(){let e=(0,R.use)(I6);if(!e)throw Error(`useMessagesContext must be used within <Messages>`);return e}function z6(){let e=(0,R.use)(I6),{status:t}=C6();return e?.status??t}function B6(){let e=(0,R.use)(L6);if(!e)throw Error(`useMessageItem must be used within <Messages.Item>`);return e}var V6=(0,R.createContext)({locale:`en`,dir:`ltr`,messages:{"citation.source":({index:e},{format:t})=>`Source ${t(e)}`,"citation.open":`Open the source`,"message.copy":`Copy message`,"message.copied":`Copied`,"message.regenerate":`Regenerate response`,"message.copyDebugJson":`Copy debug JSON`,"steps.working":`Working...`,"steps.reasoning":({detail:e})=>e?`Reasoning ${e}`:`Reasoning`,"steps.reasoned":({detail:e})=>e?`Reasoned ${e}`:`Reasoned`,"steps.call":({call:e,status:t})=>({complete:`Called ${e}`,error:`Failed ${e}`,aborted:`Cancelled ${e}`})[t],"steps.tools":({count:e,status:t},{plural:n})=>({complete:n(e,{one:`Ran # tool`,other:`Ran # tools`}),error:n(e,{one:`Ran # tool with issues`,other:`Ran # tools with issues`}),aborted:n(e,{one:`Cancelled after running # tool`,other:`Cancelled after running # tools`})})[t],"steps.unnamedTool":`Tool`,"steps.unknownStep":`Step`}});function H6(){let{locale:e,messages:t}=(0,R.use)(V6),n=new Intl.PluralRules(e),r=new Intl.NumberFormat(e),i={format:e=>r.format(e),plural:(e,t)=>(t[n.select(e)]??t.other).replaceAll(`#`,r.format(e))};return(e,n)=>{let r=t[e];return typeof r==`string`?r:r(n,i)}}function U6(e){let t=(0,G.c)(27),{source:n,index:r,children:i}=e,a=H6(),o=URL.parse(n.url)?.hostname??n.url,s;t[0]!==r||t[1]!==a?(s=a(`citation.source`,{index:r}),t[0]=r,t[1]=a,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==s?(c=(0,z.jsx)(Io,{openOnHover:!0,"aria-label":s,className:`text-primary bg-primary/10 hover:bg-primary/20 focus-visible:ring-ring focus-visible:ring-offset-background inline-block rounded px-1 font-mono text-[10px] leading-tight transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none`,children:r}),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l=n.title??o,u=n.title??o,d;t[6]!==l||t[7]!==u?(d=(0,z.jsx)(zo,{dir:`auto`,title:l,className:`truncate`,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==o||t[10]!==n.title?(f=n.title?(0,z.jsx)(Bo,{dir:`auto`,title:o,className:`truncate`,children:o}):null,t[9]=o,t[10]=n.title,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,z.jsxs)(Ro,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m=n.url,h;t[15]===a?h=t[16]:(h=a(`citation.open`),t[15]=a,t[16]=h);let g;t[17]!==n.url||t[18]!==h?(g=(0,z.jsx)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline`,children:h}),t[17]=n.url,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==i||t[21]!==g||t[22]!==p?(_=(0,z.jsxs)(Lo,{className:`w-72 gap-2 text-sm`,children:[p,i,g]}),t[20]=i,t[21]=g,t[22]=p,t[23]=_):_=t[23];let v;return t[24]!==_||t[25]!==c?(v=(0,z.jsx)(`sup`,{className:`ml-0.5 inline-block`,children:(0,z.jsxs)(Fo,{children:[c,_]})}),t[24]=_,t[25]=c,t[26]=v):v=t[26],v}function W6(e){let t=(0,G.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=I(`border-border bg-background relative min-w-0 gap-0 overflow-visible rounded-md border py-0 text-sm/normal ring-0`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,z.jsx)($i,{ref:i,"data-slot":`table-panel`,size:`default`,className:a,...r}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}W6.displayName=`TablePanel.Root`;function G6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border flex items-center justify-between gap-4 border-b px-4 py-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ea,{"data-slot":`table-panel-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function K6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{"data-slot":`table-panel-heading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function q6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-base font-medium text-balance wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ta,{"data-slot":`table-panel-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function J6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-muted-foreground text-xs text-pretty wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(na,{"data-slot":`table-panel-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Y6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex shrink-0 items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ra,{"data-slot":`table-panel-actions`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function X6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0 flex-1 overflow-auto rounded-b-[inherit] p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ia,{"data-slot":`table-panel-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Z6=Object.assign(W6,{Header:G6,Heading:K6,Title:q6,Description:J6,Actions:Y6,Content:X6}),Q6=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>/g,$6=/\b([\w-]+)="((?:\\.|[^"])*)"/g;function e8(e){return e.replace(Q6,e=>e.replace($6,(e,t,n)=>`${t}="${n.replace(/\\"/g,`"`)}"`))}function t8(e,t){if(typeof e!=`string`)return e;let n=e8(c8(e,i8(t))).replace(/<(\w[\w-]*)((?:\s+[\w-]+="[^"]*")+)\s*(\/?>)/g,(e,t,n,r)=>`<${t}${n.replace(/\s+/g,` `)}${r}`);return n=n.replace(/\/>(\s*)</g,(e,t,n,r)=>!t.includes(`
|
|
327
|
-
`)&&
|
|
326
|
+
`)}function C2(e){return e.startsWith(`file://`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||/^[A-Za-z]:[\\/]/.test(e)}function w2(e){let t=e.trim();if(!t.startsWith(`file://`))return t;let n=URL.parse(t);if(!n)return t;try{return decodeURIComponent(n.pathname)}catch{return n.pathname}}function T2(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??e}function E2(e){return/[\\/]$/.test(e)}function D2(e){return e.split(/\r?\n/).map(e=>e.trim()).find(e=>e&&!e.startsWith(`#`))??``}function O2(e){let t=D2(e);return t?t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim()??t:``}function k2(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function A2(e){return $$(e.trim())}function j2(e){let t=(0,G.c)(3),n=e.draftKey??``,r;return t[0]!==e||t[1]!==n?(r=(0,z.jsx)(N2,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}function M2(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function N2({initialDraft:e,draftKey:t,disabled:n=!1,isTaskRunning:r=!1,queueSubmissions:i=!1,hasInteracted:a=!1,maxExpandedTextChars:o,editorAriaLabel:s=`Rich prompt composer`,className:c,children:l,dictation:u,validateSubmission:d,onSubmit:f,onStateChange:p}){let m=un(),h=B1(l),g=(0,R.useRef)({signature:V1(h),slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers}),_=V1(h);_!==g.current.signature&&(g.current={signature:_,slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers});let{slashCommands:v,mentionCandidates:y,commandTriggers:b,mentionTriggers:x}=g.current,S=(0,R.useMemo)(()=>({commandTriggers:b,mentionTriggers:x}),[b,x]),C=(0,R.useRef)(x);C.current=x;let[w]=(0,R.useState)(()=>{if(e)return e;if(t===void 0)return;let n=k1(t);return n?Z$({source:n,slashCommands:v,mentionCandidates:y}):void 0}),T=(0,R.useRef)(w?.remoteImages??[]),E=(0,R.useRef)(b0({state:w,slashCommands:v,mentionCandidates:y,triggers:S})),D=(0,R.useRef)(0),O=(0,R.useRef)(!0);(0,R.useEffect)(()=>(O.current=!0,()=>{O.current=!1}),[]);let[ee,k]=(0,R.useState)(T.current),[te,A]=(0,R.useState)(null),[ne,j]=(0,R.useState)(()=>T0(E.current,T.current,v,r,i,0)),re=(0,R.useRef)(ne),ie=(0,R.useRef)(ee),M=(0,R.useRef)(te),ae=(0,R.useRef)(null),oe=(0,R.useRef)(null),se=(0,R.useRef)(void 0),N=(0,R.useRef)(null),ce=(0,R.useRef)(null),le=(0,R.useRef)(null),ue=(0,R.useEffectEvent)((e,t)=>{p?.(e,t)}),de=(0,R.useRef)(d),fe=(0,R.useRef)(f),pe=(0,R.useRef)(new Map),me=(0,R.useRef)(()=>null),he=(0,R.useRef)(()=>void 0),ge=(0,R.useRef)(()=>void 0),_e=(0,R.useRef)(()=>!1),[ve,ye]=(0,R.useState)(``),be=(0,R.useRef)(ve);be.current=ve;let P=fq({extensions:(0,R.useMemo)(()=>f0({getPlaceholder:()=>be.current,getMentionTrigger:()=>C.current[0]??`@`,getRemoteImageCount:()=>ie.current.length,attachImageFile:e=>me.current(e)}),[]),content:E.current,editable:!n,editorProps:{attributes:{"data-slot":`composer-editor`,role:`textbox`,"aria-label":s,"aria-placeholder":ve,"aria-disabled":n?`true`:`false`,dir:`auto`,spellcheck:`false`},handleKeyDown(e,t){return _e.current(t)}},immediatelyRender:!1,onUpdate({editor:e}){he.current(e),ge.current(e)},onSelectionUpdate({editor:e}){he.current(e),ge.current(e)}}),xe=(0,R.useMemo)(()=>te?K1(te,v,y,a):[],[te,a,y,v]),Se=(0,R.useMemo)(()=>_$(ne,v,b),[b,ne,v]);(0,R.useEffect)(()=>{re.current=ne},[ne]),(0,R.useEffect)(()=>{ie.current=ee},[ee]),(0,R.useEffect)(()=>{M.current=te},[te]),(0,R.useEffect)(()=>{ne.shortcutsOpen&&(te||ne.reverseSearch!==null||!g$(ne))&&j(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)},[te,ne]),(0,R.useEffect)(()=>{de.current=d},[d]),(0,R.useEffect)(()=>{fe.current=f},[f]),(0,R.useEffect)(()=>{P&&(P.setEditable(!n),n&&A(null))},[n,P]),(0,R.useEffect)(()=>{ue(ne,Se),t!==void 0&&(Se?A1(t,J$(ne,Se.persistedPrompt)):D.current===0&&A1(t,null))},[ne,t,Se]),(0,R.useEffect)(()=>{j(e=>e.isTaskRunning===r&&e.queueSubmissions===i?e:{...e,isTaskRunning:r,queueSubmissions:i})},[r,i]),he.current=e=>{if(n)return;let t=T0(e.getJSON(),ie.current,v,r,i,g2(e)),a=oe.current,o=se.current;oe.current=null,se.current=void 0,j(e=>{let n=o===void 0?N.current:o;N.current=n;let r=e.shortcutsOpen&&g$(t);return{...t,error:e.error,history:e.history,historyCursor:n,killBuffer:e.killBuffer,reverseSearch:e.reverseSearch,shortcutsOpen:r,selectedRemoteImageId:a}})},ge.current=e=>{if(n){A(null);return}let t=L0(e,S);if(!t){A(null);return}if(b.includes(t.trigger)){let e={trigger:t.trigger,query:t.query,selectedIndex:0},n=K1(e,v,y,a);A(t=>n.length===0?null:{...e,selectedIndex:t?.trigger===e.trigger?Math.min(t.selectedIndex,n.length-1):0});return}A(e=>{let n=t.trigger,r={trigger:n,query:t.query,selectedIndex:e?.trigger===n?e.selectedIndex:0},i=K1(r,v,y,a);return{...r,selectedIndex:e?.trigger===n?Math.min(e.selectedIndex,Math.max(i.length-1,0)):0}})};function Ce(e){P?.commands.setContent(e),P&&(he.current(P),ge.current(P))}function we(e){if(n||!P)return;let t=L0(P,S),r=[{type:`text`,text:`${e.trigger}${e.value}`,marks:[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]},{type:`text`,text:` `}];t&&t.trigger===e.trigger?P.chain().focus().deleteRange({from:t.from,to:t.to}).insertContent(r).run():P.chain().focus().insertContent(r).run(),A(null)}function Te({index:e=M.current?.selectedIndex??0}={}){let t=M.current;if(n||!P||!t)return;let r=K1(t,v,y,a),i=r[e]??r[0];if(!i)return;if(!i.atomic){we(i);return}let o=L0(P,S),s=o?.trigger===t.trigger,c=P.chain().focus();s&&o&&c.deleteRange({from:o.from,to:o.to}),c.insertContent([N0(i),{type:`text`,text:` `}]).run(),A(null)}function Ee(){if(n||!P)return;P.commands.focus();let e=b[0];e&&A(t=>t?.trigger===e?null:{trigger:e,query:``,selectedIndex:0})}function De(e){return g$(e)&&e.reverseSearch===null&&M.current===null}function Oe(){n||j(e=>De(e)&&!e.shortcutsOpen?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function ke(){j(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:e)}function Ae(){n||j(e=>e.shortcutsOpen?{...e,shortcutsOpen:!1}:De(e)?{...e,shortcutsOpen:!0,selectedRemoteImageId:null,error:null}:e)}function je(e){n||!P||!e||P.chain().focus().insertContent(e).run()}function Me(e){if(V$(e)===null)return j(t=>({...t,error:`Only image, video, or audio files can be attached: ${e.name||`unnamed file`}`,shortcutsOpen:!1})),A(null),null;let t=crypto.randomUUID();return pe.current.set(t,e),t}function Ne(e,t){let n=Me(t);if(n===null)return;let r=Ge(),i=r.remoteImages.length+r.imageAttachments.length+1,a=V$(t)??`image`;e.chain().focus().insertContent([I0(n,U$(a,i),a),{type:`text`,text:` `}]).run()}function Pe(e){if(!(n||!P))for(let t of e)Ne(P,t)}function Fe(e){n||!P||(pe.current.delete(e),Ce(Y0(Z0(P.getJSON(),e),ie.current.length)))}function Ie(e){if(n||!P)return;let t=[...ie.current,{id:g1(`remote-image`,e,m.Date.now()),url:e}];ie.current=t,k(t),Ce(Y0(P.getJSON(),t.length))}function Le(e){return n||!P?!1:y0(P.view,e,ie.current.length,x[0]??`@`,Me)}function Re(e){if(n)return;let t=ie.current[e]??re.current.remoteImages[e];t&&(oe.current=t.id,j(e=>({...e,selectedRemoteImageId:t.id,shortcutsOpen:!1})))}function ze(){n||(oe.current=null,j(e=>e.selectedRemoteImageId?{...e,selectedRemoteImageId:null,shortcutsOpen:!1}:e))}function Be(e){return re.current.selectedRemoteImageId?e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`Escape`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`?(ze(),A(null),!0):e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey?(ze(),!0):!1:!1}function Ve(e){if(n)return e.preventDefault(),!0;if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`a`)return e.preventDefault(),ze(),A(null),P?.commands.selectAll(),!0;let t=Ge(),r=re.current.selectedRemoteImageId;if(!M.current&&e.key===`ArrowUp`){let n=G$({...t,selectedRemoteImageId:r},r);if(n!==null)return e.preventDefault(),Re(Math.max(0,n-1)),!0;if((P&&_2(P)||t.cursor===0)&&t.remoteImages.length>0)return e.preventDefault(),Re(t.remoteImages.length-1),!0}if(!M.current&&r&&e.key===`ArrowDown`){e.preventDefault();let n=G$({...t,selectedRemoteImageId:r},r);return n!==null&&n+1<t.remoteImages.length?Re(n+1):ze(),!0}return!M.current&&r&&(e.key===`Backspace`||e.key===`Delete`)?(e.preventDefault(),He(r),!0):(Be(e),!1)}function He(e){if(n||!P)return;let t=Ge(),r=t.remoteImages.findIndex(t=>t.id===e),i=t.remoteImages.filter(t=>t.id!==e),a=r===-1?null:i[r]??i[r-1]??null;oe.current=a?.id??null,ie.current=i,k(i),Ce(Y0(P.getJSON(),i.length)),j(e=>({...e,remoteImages:i,selectedRemoteImageId:a?.id??null,shortcutsOpen:!1}))}function Ue(e){if(n||!P)return;let t=$0(P.getJSON(),K$(e));P.chain().focus().insertContent(F0({kind:`paste`,label:t,detail:`${K$(e)} chars`,content:e})).run()}function We(e,t=e,r){n||P?.chain().focus().insertContent(F0({kind:`rich-link`,label:t,detail:e,href:e,metadata:r})).run()}function Ge(){return P?{...T0(P.getJSON(),ie.current,v,r,i,g2(P)),error:re.current.error,history:re.current.history,historyCursor:N.current??re.current.historyCursor,killBuffer:re.current.killBuffer,reverseSearch:re.current.reverseSearch,shortcutsOpen:re.current.shortcutsOpen,selectedRemoteImageId:re.current.selectedRemoteImageId}:re.current}function Ke(e){let t=de.current?.(e);return t?(j(e=>({...e,error:t,shortcutsOpen:!1})),A(null),!0):!1}function qe(e){let t=Ge(),n=t.text.slice(0,t.cursor);je(n&&!/\s$/.test(n)?` ${e}`:e)}function Je(){ct?.endWithSend()||Ye()}function Ye(){if(n)return;let e=Ge(),r=P?.getJSON()??A0(),i=e.isTaskRunning||e.queueSubmissions,a=i?null:C$(e.text,v,b);if(a){j(e=>({...e,error:`Unrecognized command: /${a}`,shortcutsOpen:!1})),A(null);return}let s=_$(e,v,b),c=s??{mode:`submitted`,prompt:``,persistedPrompt:``,historyPrompt:``,action:`Plain`,command:void 0,args:void 0,items:[],elements:[],payloadElements:[],mentionBindings:[]},l=v$(c,o);if(l){j(e=>({...e,error:l,shortcutsOpen:!1})),A(null);return}let u=new Map,d=[];for(let t of e.imageAttachments){let e=pe.current.get(t.id);if(!e){j(e=>({...e,error:`Attached image is no longer available: ${t.placeholder}`,shortcutsOpen:!1})),A(null);return}u.set(t.id,e),d.push({type:t.media,placeholder:t.placeholder,file:e})}let f=[...c.items.filter(e=>e.type===`remote_image`),...d,...c.items.filter(e=>e.type!==`remote_image`)],p={id:crypto.randomUUID(),at:new Date(m.Date.now()).toLocaleTimeString(),mode:i?`queued`:c.mode,prompt:c.prompt,persistedPrompt:c.persistedPrompt,action:i?v2(c,b):c.action,command:c.command,args:c.args,items:f};if(Ke(p))return;for(let e of u.keys())pe.current.delete(e);let h=J$(e,c.persistedPrompt),g=fe.current?.(p,{editableSource:h});M2(g)&&(D.current+=1,g.then(()=>{t!==void 0&&A1(t,null)}).catch(e=>{for(let[e,t]of u)pe.current.set(e,t);t!==void 0&&A1(t,h),O.current&&(Ce(r),P?.commands.focus(`end`),j(t=>({...t,error:e instanceof Error?e.message:`Could not send prompt`})))}).finally(()=>{--D.current}));let _=s?Y$(e,c.historyPrompt):e.history;N.current=null,ie.current=[],k([]),A(null),Ce(A0()),j(e=>({...e,text:``,cursor:0,elements:[],mentionBindings:[],imageAttachments:[],remoteImages:[],pendingPastes:[],selectedRemoteImageId:null,error:null,shortcutsOpen:!1,history:_,historyCursor:null}))}function Xe(){if(n)return;let e=re.current.history,t=re.current.killBuffer;N.current=null,le.current=null,pe.current.clear(),ie.current=T.current,k(T.current),A(null),Ce(E.current),P?.commands.focus(`end`),j(n=>({...n,history:e,historyCursor:null,killBuffer:t,reverseSearch:null,selectedRemoteImageId:null,error:null,shortcutsOpen:!1}))}function Ze(e){if(n||!P||re.current.history.length===0)return;let t=re.current,r=N.current??t.historyCursor;if(e>0&&r===0&&ce.current){F(ce.current,null),ce.current=null;return}let i=r===null?e<0?0:t.history.length-1:h1(r+e,t.history.length);r===null&&(ce.current=q$(Ge()));let a=t.history[i];Qe(a,i)}function Qe(e,t){F(Z$({source:e,slashCommands:v,mentionCandidates:y}),t)}function F(e,t){let n=e.remoteImages??[];ie.current=n,re.current={...re.current,historyCursor:t,shortcutsOpen:!1},N.current=t,se.current=t,k(n),Ce(b0({state:e,slashCommands:v,mentionCandidates:y,triggers:S})),P?.commands.focus(`end`),j(e=>({...e,historyCursor:t,shortcutsOpen:!1}))}function $e(){n||(A(null),N.current=null,le.current=Ge(),j(e=>({...e,reverseSearch:``,historyCursor:null,shortcutsOpen:!1})))}function et(e){if(n){e.preventDefault();return}if(e.preventDefault(),e.key===`Escape`){it(null),le.current=null;return}if(e.key===`Enter`){le.current=null,j(e=>({...e,reverseSearch:null,shortcutsOpen:!1}));return}if(e.key===`Backspace`){tt(e=>e.slice(0,-1));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){nt(1);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`){nt(-1);return}e.key.length===1&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&tt(t=>`${t}${e.key}`)}function tt(e){if(n)return;let t=re.current,r=e(t.reverseSearch??``),i=d1(t.history,r,null);if(!P||!i){it(r);return}rt(i.entry,i.index,r)}function nt(e){if(n||!P)return;let t=re.current,r=t.reverseSearch??``,i=d1(t.history,r,t.historyCursor,e);i&&rt(i.entry,i.index,r)}function rt(e,t,n){let r=P;if(!r)return;let i=Z$({source:e,slashCommands:v,mentionCandidates:y}),a=i.remoteImages??[];ie.current=a,k(a),Ce(b0({state:i,slashCommands:v,mentionCandidates:y,triggers:S})),r.commands.focus(`end`),j(e=>({...e,historyCursor:t,reverseSearch:n,selectedRemoteImageId:null,shortcutsOpen:!1}))}function it(e){if(n)return;let t=le.current;if(!t||!P){j(t=>({...t,reverseSearch:e,shortcutsOpen:!1}));return}let r={...t,history:re.current.history,killBuffer:re.current.killBuffer,reverseSearch:e,historyCursor:null,selectedRemoteImageId:null,shortcutsOpen:!1};N.current=null,ie.current=r.remoteImages,k(r.remoteImages),Ce(b0({state:r,slashCommands:v,mentionCandidates:y,triggers:S})),P.commands.focus(`end`),j(r)}_e.current=n?e=>(e.preventDefault(),!0):Ve,me.current=Me;function at(e){if(!(e.target instanceof Element)||!e.target.closest(`[data-slot="composer-editor"]`))return;if(n){e.preventDefault();return}if(!P||Ve(e))return;if(re.current.reverseSearch!==null){et(e);return}if(re.current.shortcutsOpen&&e.key===`Escape`){e.preventDefault(),ke();return}if(e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&De(Ge())){e.preventDefault(),Ae();return}if(r4(e)){e.preventDefault(),P.chain().focus().setHardBreak().run(),N.current=null,A(null);return}if(M.current){if(y2(e)||b2(e)){e.preventDefault(),st(y2(e)?-1:1);return}if(e.key===`Tab`){e.preventDefault(),Te();return}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),xe.length===0){A(null),Je();return}Te();return}if(e.key===`Escape`){e.preventDefault(),A(null);return}}if(i4(e)){let t=i2(P);t&&(e.preventDefault(),ae.current=t,j(e=>({...e,killBuffer:t.text}))),N.current=null;return}let t=a4(e);if(t!==null){e.preventDefault(),o2(P,t),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`e`){e.preventDefault(),a2(P),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){let t=n2(P);t&&(e.preventDefault(),ae.current=t,j(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`u`){let t=r2(P);t&&(e.preventDefault(),ae.current=t,j(e=>({...e,killBuffer:t.text})));return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`y`&&re.current.killBuffer){e.preventDefault(),p2(P,ae.current??re.current.killBuffer);return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`r`){e.preventDefault(),$e();return}if((e.key===`Backspace`||e.key===`Delete`)&&s4(P)){e.preventDefault(),N.current=null,A(null);return}if((e.key===`Backspace`||e.key===`Delete`)&&m2(P,e.key)){e.preventDefault(),N.current=null;return}if((e.key===`Backspace`||e.key===`Delete`||e.key.length===1&&!e.metaKey&&!e.ctrlKey&&!e.altKey)&&(N.current=null),e.key===`Enter`&&!e.shiftKey&&!e.altKey){e.preventDefault(),Je();return}let r=o4(e);if(r!==null&&!M.current){let t=Ge();if(e.key===`ArrowUp`&&(_2(P)||t.cursor===0)&&t.remoteImages.length>0){e.preventDefault(),Re(t.remoteImages.length-1);return}f1(t.text,t.cursor,r)&&(e.preventDefault(),Ze(r))}}function ot(e){if(n){e.preventDefault();return}e.target instanceof Element&&e.target.closest(`[data-slot="composer-editor"]`)&&ze()}function st(e){n||A(t=>{if(!t)return t;let n=K1(t,v,y,a).length;return n===0?t:{...t,selectedIndex:h1(t.selectedIndex+e,n)}})}let ct=d0({dictation:u,disabled:n,insertTranscript:qe,submitDraft:Ye});return(0,z.jsx)(GQ,{value:{state:ne,disabled:n,commandTriggers:b,activePopup:te,suggestions:xe,attachedImages:pe.current,setEditorPlaceholder:ye,actions:{acceptSuggestion:Te,toggleSlashMenu:Ee,insertText:je,attachImageFiles:Pe,removeImageAttachment:Fe,addRemoteImage:Ie,handleDrop:Le,insertPaste:Ue,insertRichLink:We,openShortcuts:Oe,closeShortcuts:ke,toggleShortcuts:Ae,submit:Je,reset:Xe},meta:{editor:P}},children:(0,z.jsx)(J1,{value:ct?.api??null,children:(0,z.jsx)(`section`,{"data-slot":`composer`,className:I(`border-border bg-card relative border font-[inherit]`,c),children:(0,z.jsxs)(`div`,{onKeyDownCapture:at,onMouseDownCapture:ot,children:[l,h.hasLayoutChildren?null:(0,z.jsx)(P2,{})]})})})})}function P2(){let e=(0,G.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(V2,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsxs)(z.Fragment,{children:[t,(0,z.jsxs)(F2,{children:[(0,z.jsx)(L2,{}),(0,z.jsx)(JQ,{}),(0,z.jsx)(z2,{}),(0,z.jsx)(B2,{})]}),(0,z.jsx)(G2,{}),(0,z.jsx)(J2,{})]}),e[1]=n):n=e[1],n}function F2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function I2(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex flex-wrap items-center gap-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function L2(e){let t=(0,G.c)(14),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=KQ(`Composer.RemoteImages`);if(i.remoteImages.length===0)return null;let a;t[3]===n?a=t[4]:(a=I(`border-border space-y-1 border-b pb-2 text-sm`,n),t[3]=n,t[4]=a);let o;if(t[5]!==i.remoteImages||t[6]!==i.selectedRemoteImageId){let e;t[8]===i.selectedRemoteImageId?e=t[9]:(e=(e,t)=>(0,z.jsxs)(`div`,{className:I(`flex h-6 items-center gap-2 rounded-sm px-2`,i.selectedRemoteImageId===e.id?`bg-primary text-primary-foreground`:`text-sky-500`),children:[(0,z.jsxs)(`span`,{className:`shrink-0`,children:[`[Image #`,t+1,`]`]}),(0,z.jsx)(`span`,{className:`truncate text-xs opacity-70`,children:e.url})]},e.id),t[8]=i.selectedRemoteImageId,t[9]=e),o=i.remoteImages.map(e),t[5]=i.remoteImages,t[6]=i.selectedRemoteImageId,t[7]=o}else o=t[7];let s;return t[10]!==r||t[11]!==a||t[12]!==o?(s=(0,z.jsx)(`div`,{className:a,...r,children:o}),t[10]=r,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function R2(e){e.dataTransfer.types.includes(`Files`)&&e.preventDefault()}function z2(e){let t=(0,G.c)(29),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,onDragEnter:r,onDragOver:i,onDrop:a,placeholder:s,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?`Type a message or / for commands`:s,{disabled:l,meta:u,actions:d,setEditorPlaceholder:f}=KQ(`Composer.Editor`),p,m;t[7]!==c||t[8]!==f?(p=()=>{f(c)},m=[c,f],t[7]=c,t[8]=f,t[9]=p,t[10]=m):(p=t[9],m=t[10]),(0,R.useLayoutEffect)(p,m);let h=l?``:void 0,g;t[11]===r?g=t[12]:(g=e=>{r?.(e),R2(e)},t[11]=r,t[12]=g);let _;t[13]===i?_=t[14]:(_=e=>{i?.(e),R2(e)},t[13]=i,t[14]=_);let v;t[15]!==d||t[16]!==a?(v=e=>{a?.(e),!e.defaultPrevented&&d.handleDrop(e.dataTransfer)&&e.preventDefault()},t[15]=d,t[16]=a,t[17]=v):v=t[17];let y;t[18]===u.editor?y=t[19]:(y=(0,z.jsx)(aq,{editor:u.editor}),t[18]=u.editor,t[19]=y);let b;return t[20]!==n||t[21]!==l||t[22]!==o||t[23]!==h||t[24]!==g||t[25]!==_||t[26]!==v||t[27]!==y?(b=(0,z.jsx)(`div`,{"data-slot":`composer-frame`,className:n,"aria-disabled":l,"data-disabled":h,onDragEnter:g,onDragOver:_,onDrop:v,...o,children:y}),t[20]=n,t[21]=l,t[22]=o,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function B2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i}=KQ(`Composer.Error`);if(!i.error)return null;let a;t[3]===n?a=t[4]:(a=I(`border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs`,n),t[3]=n,t[4]=a);let o;return t[5]!==r||t[6]!==i.error||t[7]!==a?(o=(0,z.jsx)(`div`,{role:`alert`,className:a,...r,children:i.error}),t[5]=r,t[6]=i.error,t[7]=a,t[8]=o):o=t[8],o}function V2(e){let t=(0,G.c)(25),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,suggestions:a,actions:o}=KQ(`Composer.Popup`),{acceptSuggestion:s}=o;if(!i)return null;let c;t[3]===a?c=t[4]:(c=a.some(H2),t[3]=a,t[4]=c);let l=c,u;t[5]===n?u=t[6]:(u=I(`border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg`,n),t[5]=n,t[6]=u);let d;if(t[7]!==s||t[8]!==i||t[9]!==a||t[10]!==l){let e;t[12]!==s||t[13]!==i||t[14]!==l?(e=(e,t)=>(0,z.jsx)(U2,{selected:t===i.selectedIndex,icon:l?e.icon:null,token:m$(e),takesArgs:e.supportsArgs===!0,description:e.detail,onMouseDown:()=>s({index:t})},`item:${e.id}`),t[12]=s,t[13]=i,t[14]=l,t[15]=e):e=t[15],d=a.map(e),t[7]=s,t[8]=i,t[9]=a,t[10]=l,t[11]=d}else d=t[11];let f;t[16]===a.length?f=t[17]:(f=a.length===0?(0,z.jsx)(`div`,{className:`text-muted-foreground px-2 py-1 text-[13px] leading-4`,children:`no matches`}):null,t[16]=a.length,t[17]=f);let p;t[18]!==d||t[19]!==f?(p=(0,z.jsxs)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto p-1`,role:`listbox`,"aria-label":`Suggestions`,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;return t[21]!==r||t[22]!==u||t[23]!==p?(m=(0,z.jsx)(`div`,{className:u,...r,children:p}),t[21]=r,t[22]=u,t[23]=p,t[24]=m):m=t[24],m}function H2(e){return e.icon}function U2(e){let t=(0,G.c)(23),{selected:n,icon:r,token:i,takesArgs:a,description:o,onMouseDown:s}=e,c=(0,R.useRef)(null),l,u;t[0]===n?(l=t[1],u=t[2]):(l=()=>{n&&c.current?.scrollIntoView({block:`nearest`})},u=[n],t[0]=n,t[1]=l,t[2]=u),(0,R.useEffect)(l,u);let d=n?`bg-accent text-foreground`:`text-foreground/80 hover:bg-accent/60`,f;t[3]===d?f=t[4]:(f=I(`flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0`,d),t[3]=d,t[4]=f);let p;t[5]===s?p=t[6]:(p=e=>{e.preventDefault(),s()},t[5]=s,t[6]=p);let m;t[7]===r?m=t[8]:(m=r===null?null:(0,z.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:r}),t[7]=r,t[8]=m);let h;t[9]===i?h=t[10]:(h=(0,z.jsx)(`span`,{className:`truncate`,children:i}),t[9]=i,t[10]=h);let g;t[11]===a?g=t[12]:(g=a?(0,z.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`args`}):null,t[11]=a,t[12]=g);let _;t[13]===o?_=t[14]:(_=(0,z.jsx)(`span`,{className:`text-muted-foreground truncate`,children:o}),t[13]=o,t[14]=_);let v;return t[15]!==n||t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g||t[21]!==_?(v=(0,z.jsxs)(`button`,{ref:c,type:`button`,role:`option`,"aria-selected":n,className:f,onMouseDown:p,children:[m,h,g,_]}),t[15]=n,t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_,t[22]=v):v=t[22],v}var W2=[{title:`Send`,items:[[`Enter`,`send or queue`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`]]},{title:`Edit`,items:[[`Ctrl K`,`kill to end`],[`Ctrl U`,`kill to start`],[`Ctrl W`,`kill word`],[`Ctrl Y`,`yank`]]},{title:`Navigate`,items:[[`Ctrl P/N`,`history`],[`Ctrl R`,`reverse search`],[`Ctrl E`,`line end`],[`Alt B/F`,`word move`]]}];function G2(e){let t=(0,G.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{state:i,actions:a}=KQ(`Composer.Shortcuts`),{closeShortcuts:o}=a;if(!i.shortcutsOpen||!g$(i))return null;let s;t[3]===n?s=t[4]:(s=I(`border-border bg-popover border-t px-3 py-3 text-xs`,n),t[3]=n,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(`div`,{className:`text-foreground font-medium`,children:`Keyboard shortcuts`}),t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[c,(0,z.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1`,onClick:o,children:`close`})]}),t[6]=o,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:W2.map(K2)}),t[8]=u):u=t[8];let d;return t[9]!==r||t[10]!==s||t[11]!==l?(d=(0,z.jsxs)(`div`,{role:`dialog`,"aria-label":`Keyboard shortcuts`,className:s,...r,children:[l,u]}),t[9]=r,t[10]=s,t[11]=l,t[12]=d):d=t[12],d}function K2(e){return(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground text-[11px]`,children:e.title}),(0,z.jsx)(`div`,{className:`space-y-1`,children:e.items.map(q2)})]},e.title)}function q2(e){let[t,n]=e;return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),(0,z.jsx)(`span`,{className:`text-muted-foreground text-right`,children:n})]},`${t}-${n}`)}function J2(e){let t=(0,G.c)(29),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{activePopup:i,state:a}=KQ(`Composer.Footer`);if(a.reverseSearch!==null){let e;t[3]===n?e=t[4]:(e=I(`border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]`,n),t[3]=n,t[4]=e);let i,o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:`Ctrl R`}),o=(0,z.jsx)(`span`,{children:`reverse-i-search:`}),t[5]=i,t[6]=o):(i=t[5],o=t[6]);let s=a.reverseSearch||`_`,c;t[7]===s?c=t[8]:(c=(0,z.jsx)(`span`,{className:`text-foreground`,children:s}),t[7]=s,t[8]=c);let l,u,d,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`span`,{children:`Ctrl R previous`}),u=(0,z.jsx)(`span`,{children:`Ctrl S next`}),d=(0,z.jsx)(`span`,{children:`Enter accept`}),f=(0,z.jsx)(`span`,{children:`Esc cancel`}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):(l=t[9],u=t[10],d=t[11],f=t[12]);let p;return t[13]!==r||t[14]!==e||t[15]!==c?(p=(0,z.jsxs)(`div`,{className:e,...r,children:[i,o,c,l,u,d,f]}),t[13]=r,t[14]=e,t[15]=c,t[16]=p):p=t[16],p}let o;t[17]!==i||t[18]!==a.isTaskRunning||t[19]!==a.queueSubmissions?(o=i?[[`Enter`,`insert`],[`Tab`,`insert`],[`Esc`,`dismiss`]]:[[`Enter`,a.isTaskRunning||a.queueSubmissions?`queue`:`send`],[`Shift Enter`,`newline`],[`Alt Enter`,`newline`],[`Ctrl J/M`,`newline`],[`Ctrl P/N`,`history`],[`Ctrl E`,`line end`],[`Ctrl K`,`kill`],[`Ctrl U`,`kill back`],[`Ctrl W`,`word kill`],[`Alt B/F`,`word move`],[`Ctrl Y`,`yank`]],t[17]=i,t[18]=a.isTaskRunning,t[19]=a.queueSubmissions,t[20]=o):o=t[20];let s=o,c;t[21]===n?c=t[22]:(c=I(`border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]`,n),t[21]=n,t[22]=c);let l;t[23]===s?l=t[24]:(l=s.map(Y2),t[23]=s,t[24]=l);let u;return t[25]!==r||t[26]!==c||t[27]!==l?(u=(0,z.jsx)(`div`,{className:c,...r,children:l}),t[25]=r,t[26]=c,t[27]=l,t[28]=u):u=t[28],u}function Y2(e){let[t,n]=e;return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(`kbd`,{className:`border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]`,children:t}),n]},`${t}-${n}`)}function X2(e){let t=(0,G.c)(19),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({accept:i,multiple:a,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`image/*,video/*,audio/*`:i,s=a===void 0||a,{actions:c,disabled:l}=KQ(`Composer.AttachFiles`),u=(0,R.useRef)(null),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>u.current?.click(),t[5]=d):d=t[5];let f;t[6]!==n||t[7]!==r?(f=(0,z.jsx)(n4,{action:d,disabled:n,...r}),t[6]=n,t[7]=r,t[8]=f):f=t[8];let p=l||n,m;t[9]===c?m=t[10]:(m=e=>{let t=e.currentTarget;t.files&&c.attachImageFiles(t.files),t.value=``},t[9]=c,t[10]=m);let h;t[11]!==o||t[12]!==s||t[13]!==p||t[14]!==m?(h=(0,z.jsx)(`input`,{ref:u,type:`file`,accept:o,multiple:s,"aria-label":`Attach media files`,hidden:!0,disabled:p,onChange:m}),t[11]=o,t[12]=s,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==f||t[17]!==h?(g=(0,z.jsxs)(z.Fragment,{children:[f,h]}),t[16]=f,t[17]=h,t[18]=g):g=t[18],g}function Z2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({url:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=KQ(`Composer.AddRemoteImage`),a;t[3]!==i||t[4]!==r?(a=()=>i.addRemoteImage(r),t[3]=i,t[4]=r,t[5]=a):a=t[5];let o;return t[6]!==n||t[7]!==a?(o=(0,z.jsx)(n4,{action:a,...n}),t[6]=n,t[7]=a,t[8]=o):o=t[8],o}function Q2(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({content:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{actions:i}=KQ(`Composer.InsertPaste`),a;t[3]!==i||t[4]!==n?(a=()=>i.insertPaste(n),t[3]=i,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==a?(o=(0,z.jsx)(n4,{action:a,...r}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function $2(e){let t=(0,G.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({href:n,label:r,metadata:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{actions:o}=KQ(`Composer.InsertRichLink`),s;t[5]!==o||t[6]!==n||t[7]!==r||t[8]!==i?(s=()=>o.insertRichLink(n,r,i),t[5]=o,t[6]=n,t[7]=r,t[8]=i,t[9]=s):s=t[9];let c;return t[10]!==a||t[11]!==s?(c=(0,z.jsx)(n4,{action:s,...a}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function e4(e){let t=(0,G.c)(3),{actions:n}=KQ(`Composer.Submit`),r;return t[0]!==n.submit||t[1]!==e?(r=(0,z.jsx)(n4,{action:n.submit,...e}),t[0]=n.submit,t[1]=e,t[2]=r):r=t[2],r}function t4(e){let t=(0,G.c)(3),{actions:n}=KQ(`Composer.Reset`),r;return t[0]!==n.reset||t[1]!==e?(r=(0,z.jsx)(n4,{action:n.reset,...e}),t[0]=n.reset,t[1]=e,t[2]=r):r=t[2],r}function n4(e){let t=(0,G.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({action:n,onClick:i,disabled:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{disabled:o}=KQ(`Composer.ActionTrigger`),s=o||r,c;t[5]!==n||t[6]!==i?(c=e=>{i?.(e),e.defaultPrevented||n()},t[5]=n,t[6]=i,t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==s||t[10]!==c?(l=(0,z.jsx)(y,{...a,disabled:s,onClick:c}),t[8]=a,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function r4(e){if(e.metaKey)return!1;if(e.key===`Enter`)return e.altKey&&!e.ctrlKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&(t===`j`||t===`m`)}function i4(e){if(e.metaKey)return!1;if(e.key===`Backspace`)return e.ctrlKey||e.altKey;let t=e.key.toLowerCase();return e.ctrlKey&&!e.altKey&&t===`w`||e.ctrlKey&&e.altKey&&t===`h`}function a4(e){if(e.metaKey||e.shiftKey)return null;if(e.key===`ArrowLeft`&&(e.altKey||e.ctrlKey))return-1;if(e.key===`ArrowRight`&&(e.altKey||e.ctrlKey))return 1;if(!e.altKey||e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`b`?-1:t===`f`?1:null}function o4(e){if(e.key===`ArrowUp`)return-1;if(e.key===`ArrowDown`)return 1;if(e.metaKey||e.altKey||e.shiftKey||!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`p`?-1:t===`n`?1:null}function s4(e){let{doc:t,selection:n}=e.state;return n.empty||n.from>1||n.to<t.content.size-1?!1:(e.commands.setContent(A0(),{emitUpdate:!0}),e.commands.focus(`start`),e.commands.setTextSelection(1),!0)}var c4={Root:j2,Trigger:L1,Command:R1,Mention:z1,Content:F2,Toolbar:I2,RemoteImages:L2,Attachments:JQ,Editor:z2,Error:B2,Popup:V2,Shortcuts:G2,Footer:J2,AttachFiles:X2,AddRemoteImage:Z2,InsertPaste:Q2,InsertRichLink:$2,Dictate:$1,CancelDictation:e0,Submit:e4,Reset:t4};(0,R.createContext)(null);function l4(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return null;let r=n.cloneContents();for(let e of r.querySelectorAll(`[data-persisted-source]`)){let t=e.getAttribute(`data-persisted-source`);t!==null&&e.replaceWith(t)}return r.textContent??``}function u4(e){let t=(0,G.c)(6),{text:n}=e,r,i;if(t[0]!==n){let e=oN(n);r=p4,i=e.map(d4),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a;return t[3]!==r||t[4]!==i?(a=(0,z.jsx)(`span`,{onCopy:r,children:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a}function d4(e){switch(e.kind){case`text`:return e.value;case`inline-code`:return(0,z.jsx)(`code`,{"data-persisted-source":e.source,className:`bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]`,children:e.value},e.start);case`code-block`:return(0,z.jsx)(`span`,{"data-persisted-source":e.source,className:`bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2`,children:(0,z.jsx)(`code`,{className:`font-mono text-[0.9em]`,children:e.value})},e.start);case`skill-link`:return(0,z.jsx)(f4,{name:e.name,source:e.source,skillId:e.skillId,title:e.href},e.start);case`standalone-skill`:return(0,z.jsx)(f4,{name:e.name,source:e.source},e.start);case`mention`:return(0,z.jsx)(`span`,{"data-token":`mention`,"data-persisted-source":e.source,className:`bg-foreground/10 rounded-sm px-0.5 font-medium`,children:e.label},e.start);case`link`:return/^(?:https?:|mailto:)/.test(e.href)?(0,z.jsx)(`a`,{href:e.href,"data-persisted-source":e.source,className:`text-primary underline underline-offset-2`,target:`_blank`,rel:`noreferrer`,children:e.label},e.start):e.source}}function f4(e){let t=(0,G.c)(9),{name:n,source:r,skillId:i,title:a}=e,o=i?void 0:n,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(vi,{"aria-hidden":`true`,className:`size-3.5 self-center`}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,z.jsx)(`span`,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==r||t[5]!==o||t[6]!==c||t[7]!==a?(l=(0,z.jsxs)(`span`,{"data-skill-id":i,"data-skill-name":o,"data-persisted-source":r,title:a,className:`text-primary inline-flex items-baseline gap-1`,children:[s,c]}),t[3]=i,t[4]=r,t[5]=o,t[6]=c,t[7]=a,t[8]=l):l=t[8],l}function p4(e){let t=l4(e.currentTarget,window.getSelection());t!==null&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())}var m4=typeof global==`object`&&global&&global.Object===Object&&global,h4=typeof self==`object`&&self&&self.Object===Object&&self,g4=m4||h4||Function(`return this`)(),_4=g4.Symbol,v4=Object.prototype,y4=v4.hasOwnProperty,b4=v4.toString,x4=_4?_4.toStringTag:void 0;function S4(e){var t=y4.call(e,x4),n=e[x4];try{e[x4]=void 0;var r=!0}catch{}var i=b4.call(e);return r&&(t?e[x4]=n:delete e[x4]),i}var C4=Object.prototype.toString;function w4(e){return C4.call(e)}var T4=`[object Null]`,E4=`[object Undefined]`,D4=_4?_4.toStringTag:void 0;function O4(e){return e==null?e===void 0?E4:T4:D4&&D4 in Object(e)?S4(e):w4(e)}function k4(e){return typeof e==`object`&&!!e}var A4=`[object Symbol]`;function j4(e){return typeof e==`symbol`||k4(e)&&O4(e)==A4}function M4(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var N4=Array.isArray,P4=1/0,F4=_4?_4.prototype:void 0,I4=F4?F4.toString:void 0;function L4(e){if(typeof e==`string`)return e;if(N4(e))return M4(e,L4)+``;if(j4(e))return I4?I4.call(e):``;var t=e+``;return t==`0`&&1/e==-P4?`-0`:t}function R4(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var z4=`[object AsyncFunction]`,B4=`[object Function]`,V4=`[object GeneratorFunction]`,H4=`[object Proxy]`;function U4(e){if(!R4(e))return!1;var t=O4(e);return t==B4||t==V4||t==z4||t==H4}var W4=g4[`__core-js_shared__`],G4=function(){var e=/[^.]+$/.exec(W4&&W4.keys&&W4.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function K4(e){return!!G4&&G4 in e}var q4=Function.prototype.toString;function J4(e){if(e!=null){try{return q4.call(e)}catch{}try{return e+``}catch{}}return``}var Y4=/[\\^$.*+?()[\]{}|]/g,X4=/^\[object .+?Constructor\]$/,Z4=Function.prototype,Q4=Object.prototype,$4=Z4.toString,e3=Q4.hasOwnProperty,t3=RegExp(`^`+$4.call(e3).replace(Y4,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function n3(e){return!R4(e)||K4(e)?!1:(U4(e)?t3:X4).test(J4(e))}function r3(e,t){return e?.[t]}function i3(e,t){var n=r3(e,t);return n3(n)?n:void 0}function a3(e,t){return e===t||e!==e&&t!==t}var o3=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s3=/^\w*$/;function c3(e,t){if(N4(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||j4(e)?!0:s3.test(e)||!o3.test(e)||t!=null&&e in Object(t)}var l3=i3(Object,`create`);function u3(){this.__data__=l3?l3(null):{},this.size=0}function d3(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var f3=`__lodash_hash_undefined__`,p3=Object.prototype.hasOwnProperty;function m3(e){var t=this.__data__;if(l3){var n=t[e];return n===f3?void 0:n}return p3.call(t,e)?t[e]:void 0}var h3=Object.prototype.hasOwnProperty;function g3(e){var t=this.__data__;return l3?t[e]!==void 0:h3.call(t,e)}var _3=`__lodash_hash_undefined__`;function v3(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=l3&&t===void 0?_3:t,this}function y3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}y3.prototype.clear=u3,y3.prototype.delete=d3,y3.prototype.get=m3,y3.prototype.has=g3,y3.prototype.set=v3;function b3(){this.__data__=[],this.size=0}function x3(e,t){for(var n=e.length;n--;)if(a3(e[n][0],t))return n;return-1}var S3=Array.prototype.splice;function C3(e){var t=this.__data__,n=x3(t,e);return n<0?!1:(n==t.length-1?t.pop():S3.call(t,n,1),--this.size,!0)}function w3(e){var t=this.__data__,n=x3(t,e);return n<0?void 0:t[n][1]}function T3(e){return x3(this.__data__,e)>-1}function E3(e,t){var n=this.__data__,r=x3(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function D3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}D3.prototype.clear=b3,D3.prototype.delete=C3,D3.prototype.get=w3,D3.prototype.has=T3,D3.prototype.set=E3;var O3=i3(g4,`Map`);function k3(){this.size=0,this.__data__={hash:new y3,map:new(O3||D3),string:new y3}}function A3(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function j3(e,t){var n=e.__data__;return A3(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function M3(e){var t=j3(this,e).delete(e);return this.size-=+!!t,t}function N3(e){return j3(this,e).get(e)}function P3(e){return j3(this,e).has(e)}function F3(e,t){var n=j3(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function I3(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}I3.prototype.clear=k3,I3.prototype.delete=M3,I3.prototype.get=N3,I3.prototype.has=P3,I3.prototype.set=F3;var L3=`Expected a function`;function R3(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(L3);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(R3.Cache||I3),n}R3.Cache=I3;var z3=500;function B3(e){var t=R3(e,function(e){return n.size===z3&&n.clear(),e}),n=t.cache;return t}var V3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,H3=/\\(\\)?/g,U3=B3(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(V3,function(e,n,r,i){t.push(r?i.replace(H3,`$1`):n||e)}),t});function W3(e){return e==null?``:L4(e)}function G3(e,t){return N4(e)?e:c3(e,t)?[e]:U3(W3(e))}var K3=1/0;function q3(e){if(typeof e==`string`||j4(e))return e;var t=e+``;return t==`0`&&1/e==-K3?`-0`:t}function J3(e,t){t=G3(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[q3(t[n++])];return n&&n==r?e:void 0}function Y3(e,t,n){var r=e==null?void 0:J3(e,t);return r===void 0?n:r}function X3(e){if(!e)return{};let t={...e};return delete t.whenNullish,delete t.locale,t}function Z3(e,t){return e==null||Number.isNaN(e)?t?.whenNullish??`—`:new Intl.NumberFormat(t?.locale??`en-US`,X3(t)).format(e)}var Q3=Z3;function $3(e,t){return Z3(e,{notation:`compact`,maximumFractionDigits:1,...t})}var e6=`pending-chat-prefill`;function t6(){try{let e=sessionStorage.getItem(e6);return e?JSON.parse(e):null}catch{return sessionStorage.removeItem(e6),null}}function n6(e){sessionStorage.setItem(e6,JSON.stringify(e))}function r6(){sessionStorage.removeItem(e6)}function i6(e){let t=$h(e.metadata)?e.metadata.persistedPrompt:void 0;if(typeof t!=`string`)throw Error(`Message ${e.id} has no persistedPrompt: send it with useAgent().submit.`);return t}var a6=class{chat;uploadFile;submissions=new sy;onResetChat;constructor(e){this.chat=e.chat,this.uploadFile=e.uploadFile,this.onResetChat=e.onResetChat}bind(e){this.chat=e}initialize(e){let t=new AbortController;return queueMicrotask(()=>{t.signal.aborted||this.consumePrefill(e)}),()=>t.abort()}submit(e){this.chat.clearError();let{files:t=[],...n}=e,r=this.chat.id;return this.submissions.run(async()=>{if(t.length===0){this.assertCurrentChat(r),this.send(n);return}let e=await this.uploadFiles(r,t);this.assertCurrentChat(r),this.send({...n,metadata:{...n.metadata,uploads:e}})})}async uploadFiles(e,t){return Promise.all(t.map(t=>this.uploadFile(e,t)))}assertCurrentChat(e){if(this.chat.id!==e)throw Error(`The chat changed before the submission was sent.`)}send({prompt:e,persistedPrompt:t,metadata:n}){this.chat.sendMessage({role:`user`,parts:[{type:`text`,text:e}],metadata:{...n,persistedPrompt:t}})}clearChat(){for(let{id:e}of this.chat.experimental_queuedMessages)this.chat.experimental_removeQueuedMessage(e);this.chat.setMessages([])}setChat(e){this.chat.setMessages(e)}stop(){this.chat.stop()}resetChat(e){let t=crypto.randomUUID();e&&n6({prompt:e,targetChatId:t}),this.onResetChat(t)}consumePrefill(e){let t=t6();!t||t.targetChatId!==e||(r6(),this.submit({prompt:t.prompt,persistedPrompt:t.prompt}))}getTriggeringUserMessage(e){let{messages:t}=this.chat,n=t.findIndex(t=>t.role===`assistant`&&t.parts.some(t=>`toolCallId`in t&&t.toolCallId===e));if(n<=0)return null;let r=t[n-1];return r?.role===`user`?r:null}getLastUserMessageId(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`)return e[t].id;return null}getLastAssistantMessage(){let{messages:e}=this.chat;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}get hasSubmitted(){return this.chat.messages.length>0}},o6=(0,R.createContext)({locale:`en`,dir:`ltr`,messages:{"citation.source":({index:e},{format:t})=>`Source ${t(e)}`,"citation.open":`Open the source`,"message.copy":`Copy message`,"message.copied":`Copied`,"message.regenerate":`Regenerate response`,"message.copyDebugJson":`Copy debug JSON`,"steps.working":`Working...`,"steps.reasoning":({detail:e})=>e?`Reasoning ${e}`:`Reasoning`,"steps.reasoned":({detail:e})=>e?`Reasoned ${e}`:`Reasoned`,"steps.call":({call:e,status:t})=>({complete:`Called ${e}`,error:`Failed ${e}`,aborted:`Cancelled ${e}`})[t],"steps.tools":({count:e,status:t},{plural:n})=>({complete:n(e,{one:`Ran # tool`,other:`Ran # tools`}),error:n(e,{one:`Ran # tool with issues`,other:`Ran # tools with issues`}),aborted:n(e,{one:`Cancelled after running # tool`,other:`Cancelled after running # tools`})})[t],"steps.unnamedTool":`Tool`,"steps.unknownStep":`Step`,"steps.thinking":`Thinking...`,"steps.cancelledByUser":`Cancelled by user`,"chat.greeting":`How can I help today?`,"chat.retry":`Try Again`,"status.loading":`Loading`,"composer.attachFiles":`Attach files`,"composer.commandMenu":`Toggle command menu`,"composer.send":`Send prompt`,"composer.stop":`Stop streaming`,"dictation.start":`Start dictation`,"dictation.starting":`Starting dictation`,"dictation.stop":`Stop dictation`,"dictation.transcribing":`Transcribing…`,"dictation.cancel":`Cancel dictation`,"dictation.cancelTranscription":`Cancel transcription`,"dictation.unsupported":`Dictation is not available in this browser`,"dictation.blocked":`Allow microphone access in your browser settings to use dictation`,"dictation.permissionDenied":`Allow microphone access to use dictation`,"dictation.noMicrophone":`Connect a microphone to use dictation`,"dictation.microphoneInUse":`Close other apps using the microphone`,"dictation.interrupted":`Recording interrupted`,"dictation.transcriptionFailed":`Unable to transcribe audio`,"queue.remove":`Remove queued message`,"message.attachments":`Attached files`,"message.reminders":({count:e},{plural:t})=>t(e,{one:`# reminder attached`,other:`# reminders attached`}),"message.usage":({input:e,output:t,total:n,cached:r})=>[`↑ ${e}`,`↓ ${t}`,...n===void 0?[]:[`· ${n} tokens`],...r===void 0?[]:[`(${r} cached)`]].join(` `),"attachment.image":`Attached image`,"attachment.untitled":`Untitled`,"attachment.file":`File:`,"attachment.download":`Download`,"approval.request":({tool:e})=>`${e} approval`,"approval.approve":`Approve`,"approval.deny":`Deny`,"snapshot.copy":`Copy snapshot`,"snapshot.copying":`Copying snapshot`,"snapshot.copiedImage":`Copied snapshot`,"snapshot.copiedText":`Copied text`,"snapshot.clipboardUnavailable":`Clipboard access is not available here.`,"snapshot.imageUnsupported":`Image copy is not supported in this browser.`,"snapshot.copyFailed":`Copy failed. Please try again.`,"response.renderFailed":({error:e})=>`Failed to render content: ${e}`,"tool.executing":({tool:e})=>`Executing ${e}`,"tool.state":({state:e})=>({"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`})[e],"tool.parameters":`Parameters`,"tool.result":`Result`,"tool.error":`Error`,"tool.renderFailed":`Failed to render tool`,"tool.details":`View details`,"tool.askToFix":`Ask AI to fix this`,"indexing.running":`Indexing`,"indexing.done":`Schema indexed`,"indexing.failed":`Failed`,"indexing.adapters":({count:e},{plural:t})=>t(e,{one:`# adapter`,other:`# adapters`}),"indexing.cacheHit":`cache hit`,"indexing.refreshed":`refreshed`,"indexing.queued":`queued`,markdown:{}}});function s6(){return(0,R.use)(o6).messages.markdown}function c6(){let{locale:e,messages:t}=(0,R.use)(o6),n=new Intl.PluralRules(e),r=new Intl.NumberFormat(e),i={format:e=>r.format(e),plural:(e,t)=>(t[n.select(e)]??t.other).replaceAll(`#`,r.format(e))};return(e,n)=>{let r=t[e];return typeof r==`string`?r:r(n,i)}}async function l6(e,t,n){let r=t?.[n.toolName];n.toolName.startsWith(`render`)&&r?.static===!1&&r.requiresUserInput!==!0&&await e.addToolOutput({toolCallId:n.toolCallId,tool:n.toolName,output:`rendered`,state:`output-available`})}function u6(e){let t=Wy({id:e.chatId,messages:e.initialMessages,transport:e.transport,throttle:50,experimental_queue:!0,resume:e.resume,onData:e.onData,onFinish:e.onFinish,sendAutomaticallyWhen:d6,onToolCall(n){let{toolCall:r}=n;l6(t,e.registry,r)}});return t}function d6(e){return Ny(e)||My(e)}function f6(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(p6,{...e}),t[0]=e,t[1]=n),n}function p6(e){let t=(0,G.c)(13),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={initial:`smooth`},t[0]=n):n=t[0];let{scrollRef:r,contentRef:i}=Aj(n),{hasSubmitted:a}=D6(),o;t[1]===e.className?o=t[2]:(o=I(`@container mx-auto h-full w-full overflow-y-auto`,e.className),t[1]=e.className,t[2]=o);let s=a?`min-h-full`:`h-full justify-center`,c;t[3]===s?c=t[4]:(c=I(`relative mx-auto flex w-full flex-col`,s),t[3]=s,t[4]=c);let l;t[5]!==i||t[6]!==e.children||t[7]!==c?(l=(0,z.jsx)(`div`,{ref:i,"data-slot":`content`,className:c,children:e.children}),t[5]=i,t[6]=e.children,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==r||t[10]!==o||t[11]!==l?(u=(0,z.jsx)(`div`,{id:`agent`,"data-slot":`agent`,className:o,ref:r,children:l}),t[9]=r,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}function m6(e){let t=(0,G.c)(12),{hasSubmitted:n}=D6(),r;t[0]!==n||t[1]!==e.className?(r=I(n?I(`bg-background sticky top-0 z-10 shrink-0 space-y-1 backdrop-blur-md`,e.className):`relative flex justify-center py-4`),t[0]=n,t[1]=e.className,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i={layout:{type:`tween`,ease:[.4,0,.2,1],duration:.4}},t[3]=i):i=t[3];let a=n?`text-left`:`space-y-3 text-center`,o;t[4]===a?o=t[5]:(o=I(a),t[4]=a,t[5]=o);let s;t[6]!==e.children||t[7]!==o?(s=(0,z.jsx)(`div`,{className:o,children:e.children}),t[6]=e.children,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==r||t[10]!==s?(c=(0,z.jsx)(wj.div,{layout:!0,className:r,transition:i,children:s}),t[9]=r,t[10]=s,t[11]=c):c=t[11],c}m6.displayName=`AgentHeader.Root`;function h6(e){let t=(0,G.c)(7),{hasSubmitted:n}=D6(),r=c6(),i;t[0]!==n||t[1]!==e.children||t[2]!==e.icon||t[3]!==r?(i=!n&&(0,z.jsx)(wj.div,{exit:{opacity:0},transition:{duration:.2},children:(0,z.jsxs)(`h1`,{className:`flex items-center justify-center gap-2 text-2xl font-medium tracking-tight`,children:[e.icon,e.children??r(`chat.greeting`)]})},`agent-header-initial`),t[0]=n,t[1]=e.children,t[2]=e.icon,t[3]=r,t[4]=i):i=t[4];let a;return t[5]===i?a=t[6]:(a=(0,z.jsx)(Mk,{mode:`sync`,children:i}),t[5]=i,t[6]=a),a}h6.displayName=`AgentHeader.Hero`;function g6(e){let t=(0,G.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,z.jsx)(wj.h2,{layout:`position`,className:`text-muted-foreground text-sm font-medium`,children:e.children}),t[0]=e.children,t[1]=n),n}g6.displayName=`AgentHeader.Title`;function _6(e){let t=(0,G.c)(5),{hasSubmitted:n}=D6(),r;t[0]!==n||t[1]!==e.children?(r=n&&!!e.children&&(0,z.jsx)(wj.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25},className:`text-muted-foreground text-sm`,children:e.children}),t[0]=n,t[1]=e.children,t[2]=r):r=t[2];let i;return t[3]===r?i=t[4]:(i=(0,z.jsx)(Mk,{children:r}),t[3]=r,t[4]=i),i}_6.displayName=`AgentHeader.Description`;var v6={Root:m6,Hero:h6,Title:g6,Description:_6},y6=(0,R.createContext)(void 0),b6=(0,R.createContext)(`ready`),x6=(0,R.createContext)(void 0),S6=(0,R.createContext)(null),C6=(0,R.createContext)(void 0);function w6({chatId:e,children:t,skipInitialView:n,debugMode:r,registry:i,initialMessages:a,transport:o,resume:s,onData:c,onFinish:l,onResetChat:u}){let d=u6({chatId:e,transport:o,registry:i,initialMessages:a,resume:s,onData:c,onFinish:l}),[f,p]=(0,R.useState)(r),m=(0,R.useCallback)(()=>p(e=>!e),[]),h=(0,R.useRef)(u);(0,R.useEffect)(()=>{h.current=u},[u]);let g=(0,R.useCallback)(e=>{h.current(e)},[]),[_]=(0,R.useState)(()=>new a6({chat:d,uploadFile:o.uploadFile.bind(o),onResetChat:g}));_.bind(d),(0,R.useEffect)(()=>_.initialize(e),[_,e]);let v=(0,R.useMemo)(()=>({clearChat:()=>_.clearChat(),resetChat:e=>_.resetChat(e),submit:e=>_.submit(e),setChat:e=>_.setChat(e),getTriggeringUserMessage:e=>_.getTriggeringUserMessage(e),getLastUserMessageId:()=>_.getLastUserMessageId(),stop:()=>_.stop()}),[_]),y=(0,R.useMemo)(()=>({chatId:e,registry:i,debugMode:f,toggleDebugMode:m,...v}),[e,i,f,m,v]),b=(0,R.useMemo)(()=>d,[d.id,d.messages,d.status,d.error,d.experimental_queuedMessages]),x=!!n||d.messages.length>0,S=(0,R.useMemo)(()=>({hasSubmitted:x}),[x]);return(0,z.jsx)(S6,{value:_,children:(0,z.jsx)(y6,{value:y,children:(0,z.jsx)(b6,{value:d.status,children:(0,z.jsx)(x6,{value:b,children:(0,z.jsx)(C6,{value:S,children:t})})})})})}function T6(){let e=(0,R.use)(y6);if(e===void 0)throw Error(`useAgent must be used within an AgentProvider`);return e}function E6(){return{status:(0,R.use)(b6)}}function D6(){let e=(0,R.use)(C6);if(e===void 0)throw Error(`useAgentMeta must be used within an AgentProvider`);return e}function O6(){let e=(0,R.use)(x6);if(e===void 0)throw Error(`useAgentMessages must be used within an AgentProvider`);return e}function k6(e,t){return t.map((t,n)=>({citation:t,order:n,at:t.endIndex??e.length})).sort((e,t)=>e.at-t.at||e.order-t.order)}function A6(e){return(e??[]).filter(e=>e.source.sourceType===`url`)}function j6(e){let t=new Set(e.parts.flatMap(e=>e.type===`text`?A6(e.citations).map(({source:e})=>e.url):[])),n=new Map,r=(e,t)=>{n.has(e)||n.set(e,{url:e,title:t})};for(let n of e.parts){if(n.type===`text`)for(let{citation:e}of k6(n.text,A6(n.citations)))r(e.source.url,e.source.title);n.type===`source-url`&&!t.has(n.url)&&r(n.url,n.title)}return[...n.values()]}function M6(e,t){let n=e.findIndex(e=>e.url===t);return n===-1?null:n+1}function N6(e,t){return t===`streaming`||t===`submitted`?!1:e===`input-streaming`||e===`input-available`}function P6(e,t){return N6(e.state,t)}function F6(e){return Object.entries(e).reduce((e,[t,n])=>(n.static||(e[t]={inputSchema:Le(n.inputSchema,{io:`input`,unrepresentable:`any`}),description:n.description}),e),{})}function I6(e){let t=(0,G.c)(12),{children:n,as:r,className:i,dir:a,duration:o,enabled:s}=e,c=r===void 0?`p`:r,l=s===void 0||s,u=l&&`shimmer`,d;t[0]!==i||t[1]!==u?(d=I(u,i),t[0]=i,t[1]=u,t[2]=d):d=t[2];let f;t[3]!==o||t[4]!==l?(f=l&&o!==void 0?{animationDuration:`${o}s`}:void 0,t[3]=o,t[4]=l,t[5]=f):f=t[5];let p;return t[6]!==c||t[7]!==n||t[8]!==a||t[9]!==d||t[10]!==f?(p=(0,z.jsx)(c,{dir:a,className:d,style:f,children:n}),t[6]=c,t[7]=n,t[8]=a,t[9]=d,t[10]=f,t[11]=p):p=t[11],p}function L6(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`size-3.5 shrink-0 transition-transform group-data-[panel-open]:rotate-90`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(Ct,{"aria-hidden":!0,className:r}),t[2]=r,t[3]=i),i}function R6(e){return I(`group hover:bg-muted/30 flex min-h-7 w-full gap-2 rounded-sm py-1 text-left transition-colors`,e)}(0,R.createContext)(null);var z6=(0,R.createContext)(void 0),B6=(0,R.createContext)(void 0);function V6(){let e=(0,R.use)(z6);if(!e)throw Error(`useMessagesContext must be used within <Messages>`);return e}function H6(){let e=(0,R.use)(z6),{status:t}=E6();return e?.status??t}function U6(){let e=(0,R.use)(B6);if(!e)throw Error(`useMessageItem must be used within <Messages.Item>`);return e}function W6(e){let t=(0,G.c)(27),{source:n,index:r,children:i}=e,a=c6(),o=URL.parse(n.url)?.hostname??n.url,s;t[0]!==r||t[1]!==a?(s=a(`citation.source`,{index:r}),t[0]=r,t[1]=a,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==s?(c=(0,z.jsx)(Io,{openOnHover:!0,"aria-label":s,className:`text-primary bg-primary/10 hover:bg-primary/20 focus-visible:ring-ring focus-visible:ring-offset-background inline-block rounded px-1 font-mono text-[10px] leading-tight transition-colors focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none`,children:r}),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l=n.title??o,u=n.title??o,d;t[6]!==l||t[7]!==u?(d=(0,z.jsx)(zo,{dir:`auto`,title:l,className:`truncate`,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==o||t[10]!==n.title?(f=n.title?(0,z.jsx)(Bo,{dir:`auto`,title:o,className:`truncate`,children:o}):null,t[9]=o,t[10]=n.title,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,z.jsxs)(Ro,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m=n.url,h;t[15]===a?h=t[16]:(h=a(`citation.open`),t[15]=a,t[16]=h);let g;t[17]!==n.url||t[18]!==h?(g=(0,z.jsx)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline`,children:h}),t[17]=n.url,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==i||t[21]!==g||t[22]!==p?(_=(0,z.jsxs)(Lo,{className:`w-72 gap-2 text-sm`,children:[p,i,g]}),t[20]=i,t[21]=g,t[22]=p,t[23]=_):_=t[23];let v;return t[24]!==_||t[25]!==c?(v=(0,z.jsx)(`sup`,{className:`ml-0.5 inline-block`,children:(0,z.jsxs)(Fo,{children:[c,_]})}),t[24]=_,t[25]=c,t[26]=v):v=t[26],v}function G6(e){let t=(0,G.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({ref:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=I(`border-border bg-background relative min-w-0 gap-0 overflow-visible rounded-md border py-0 text-sm/normal ring-0`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,z.jsx)($i,{ref:i,"data-slot":`table-panel`,size:`default`,className:a,...r}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}G6.displayName=`TablePanel.Root`;function K6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border flex items-center justify-between gap-4 border-b px-4 py-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ea,{"data-slot":`table-panel-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function q6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{"data-slot":`table-panel-heading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function J6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-base font-medium text-balance wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ta,{"data-slot":`table-panel-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Y6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`text-muted-foreground text-xs text-pretty wrap-anywhere`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(na,{"data-slot":`table-panel-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function X6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex shrink-0 items-center gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ra,{"data-slot":`table-panel-actions`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Z6(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`min-w-0 flex-1 overflow-auto rounded-b-[inherit] p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(ia,{"data-slot":`table-panel-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Q6=Object.assign(G6,{Header:K6,Heading:q6,Title:J6,Description:Y6,Actions:X6,Content:Z6}),$6=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>/g,e8=/\b([\w-]+)="((?:\\.|[^"])*)"/g;function t8(e){return e.replace($6,e=>e.replace(e8,(e,t,n)=>`${t}="${n.replace(/\\"/g,`"`)}"`))}function n8(e,t){if(typeof e!=`string`)return e;let n=t8(l8(e,a8(t))).replace(/<(\w[\w-]*)((?:\s+[\w-]+="[^"]*")+)\s*(\/?>)/g,(e,t,n,r)=>`<${t}${n.replace(/\s+/g,` `)}${r}`);return n=n.replace(/\/>(\s*)</g,(e,t,n,r)=>!t.includes(`
|
|
327
|
+
`)&&i8(r,n)?e:`/>
|
|
328
328
|
|
|
329
|
-
<`),
|
|
329
|
+
<`),u8(n,t)}var r8=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>|<\/[\w-]+\s*>/g;function i8(e,t){let n=e.lastIndexOf(`
|
|
330
330
|
`,t-1)+1,r=e.indexOf(`
|
|
331
|
-
`,t);return e.slice(n,r<0?e.length:r).replace(
|
|
331
|
+
`,t);return e.slice(n,r<0?e.length:r).replace(r8,``).trim()!==``}function a8(e){let t=e?.length?new Set(e):null;return t?e=>t.has(e):e=>e.includes(`-`)}var o8=/<([\w-]+)((?:\s+[\w-]+=(?:[“”][^“”]*[“”]|[‘’][^‘’]*[‘’]|"[^"]*"|'[^']*'))+)\s*(\/?>)/g,s8=/([\w-]+)=(?:[“”]([^“”]*)[“”]|[‘’]([^‘’]*)[‘’])/g;function c8(e){return e.replace(s8,(e,t,n,r)=>`${t}="${(n??r??``).replace(/"/g,`"`)}"`)}function l8(e,t){return e.replace(o8,(e,n,r,i)=>t(n)?`<${n}${c8(r)}${i}`:e)}function u8(e,t,n=!1){let r=a8(t),i=``,a=0;for(;a<e.length;){if(e[a]!==`<`||e[a+1]===`/`){i+=e[a++];continue}let o=a+1;for(;o<e.length&&/[\w-]/.test(e[o]);)o++;let s=e.slice(a+1,o);if(!s||!r(s)){i+=e[a++];continue}let c=d8(e,a);if(c<0){i+=e[a++];continue}if(e[c-1]===`/`){let t=e.slice(a,c+1);n?i+=`<div>`+t+`</div>`:i8(e,a)?i+=`<span>`+t.slice(0,-2).trimEnd()+`></`+s+`></span>`:(i+=t.slice(0,-2).trimEnd()+`></`+s+`>`,e[c+1]===`
|
|
332
332
|
`&&c+2<e.length&&e[c+2]!==`
|
|
333
333
|
`&&(i+=`
|
|
334
|
-
`)),a=c+1;continue}let l=
|
|
334
|
+
`)),a=c+1;continue}let l=f8(e,c+1,s);if(!l){if(n){let n=e.slice(a,c+1),r=u8(e.slice(c+1),t,!0);return i+=`<div>`+n+r+`</`+s+`></div>`,i}i+=e.slice(a,c+1),a=c+1;continue}let u=e.slice(a,c+1),d=e.slice(c+1,l.start),f=e.slice(l.start,l.end),p=u8(d,t,!0);if(n)i+=`<div>`+u+p+f+`</div>`;else{let t=p.includes(`
|
|
335
335
|
`)?`
|
|
336
|
-
`:``;i=
|
|
336
|
+
`:``;i=p8(i)+`<div>`+t+u+p+f+t+`</div>`,e[l.end]===`
|
|
337
337
|
`&&l.end+1<e.length&&e[l.end+1]!==`
|
|
338
338
|
`&&(i+=`
|
|
339
|
-
`)}a=l.end}return i}function
|
|
339
|
+
`)}a=l.end}return i}function d8(e,t){let n=t+1;for(;n<e.length;){if(e[n]===`"`)for(n++;n<e.length&&e[n]!==`"`;)n++;else if(e[n]===`>`)return n;n++}return-1}function f8(e,t,n){let r=1,i=t,a=`<`+n,o=`</`+n;for(;i<e.length;){let t=e.indexOf(`<`,i);if(t<0)return null;if(e.startsWith(o,t)&&!/[\w-]/.test(e[t+o.length]||``)){if(r--,r===0){let n=d8(e,t);return n<0?null:{start:t,end:n+1}}let n=e.indexOf(`>`,t+o.length);i=n<0?t+1:n+1}else if(e.startsWith(a,t)&&!/[\w-]/.test(e[t+a.length]||``)){let n=d8(e,t);n>=0&&e[n-1]!==`/`&&r++,i=n<0?t+1:n+1}else if(/[a-zA-Z/]/.test(e[t+1]||``)){let n=d8(e,t);i=n<0?t+1:n+1}else i=t+1}return null}function p8(e){return e.length===0?`
|
|
340
340
|
|
|
341
341
|
`:e.endsWith(`
|
|
342
342
|
|
|
@@ -344,15 +344,15 @@ img.ProseMirror-separator {
|
|
|
344
344
|
`)?e+`
|
|
345
345
|
`:e+`
|
|
346
346
|
|
|
347
|
-
`}var p8=`response-table-panel`,m8=[`title`,`description`],h8=I(qe({variant:`ghost`,size:`icon-sm`})),g8=Ir().use(Wr).use(Hr).use(eN),_8=e=>{let t=Pr(e),n=b8(e);if(n.length===0)return t;let r=0,i=t.map(e=>{let t={start:r,end:r+e.length};return r=t.end,t}),a=new Set;for(let e of n){let t=!1;for(let[n,r]of i.entries())r.start<e.end&&r.end>e.start&&(t&&a.add(n),t=!0)}return t.reduce((e,t,n)=>(a.has(n)&&e.length>0?e[e.length-1]+=t:e.push(t),e),[])};function v8(e){return e?.type===`leafDirective`&&`name`in e&&e.name===`table`}function y8(e,t){if(t===void 0)return;let n=e[t-1];return v8(n)?n:void 0}function b8(e){let t=[];return Ar(g8.parse(e),`table`,(e,n,r)=>{if(!r)return;let i=y8(r.children,n)?.position?.start.offset,a=e.position?.end.offset;i!==void 0&&a!==void 0&&t.push({start:i,end:a})}),t}function x8(e,t){return e.attributes?.[t]?.trim()||void 0}function S8(e){let t=g8.parse(e),n=!1;if(Ar(t,`leafDirective`,(e,t,r)=>{let i=t===void 0?void 0:r?.children[t+1];if(e.name!==`table`||i?.type!==`table`)return;n=!0;let a=[x8(e,`title`),x8(e,`description`)].filter(Boolean).join(` `);e.children=a?[{type:`text`,value:a}]:[]}),n)return Ur(jr(t,{includeHtml:!1}))}function C8(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(Fr,{...e}),t[0]=e,t[1]=n),n}function w8(e){function t(t){let n=(0,G.c)(6),r;n[0]!==t.content||n[1]!==t.dir?(r=S8(t.content)??t.dir,n[0]=t.content,n[1]=t.dir,n[2]=r):r=n[2];let i=r,a;return n[3]!==i||n[4]!==t?(a=(0,z.jsx)(e,{...t,dir:i}),n[3]=i,n[4]=t,n[5]=a):a=n[5],a}return t.displayName=`DirectionAwareTableBlock`,t}function T8(e,t){let n=t&&x8(t,`title`),r=t&&x8(t,`description`),i={...n?{title:n}:{},...r?{description:r}:{}};return{type:`tablePanel`,data:{hName:p8,...Object.keys(i).length>0?{hProperties:i}:{}},children:[e]}}function E8(){return e=>{Ar(e,`table`,(e,t,n)=>{if(t===void 0||!n)return;let r=y8(n.children,t),i=r?t-1:t,a=r?2:1;return n.children.splice(i,a,T8(e,r)),[Sr,i+1]})}}var D8=[...Object.values(Vr),eN,E8],O8=R.createContext({actions:null,controls:!0});function k8(e,t){if(e===!1)return!1;if(e===!0||e===void 0)return!0;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1}function A8(e){return e===!1?!1:e===!0||e===void 0?{table:!1}:{...e,table:!1}}function j8(e){let t=(0,G.c)(21),{children:n,className:r,title:i,description:a}=e,{actions:o,controls:s}=R.use(O8),c;t[0]===s?c=t[1]:(c=k8(s,`copy`),t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=k8(s,`download`),t[2]=s,t[3]=u);let d=u,f=!!(i||a),p=!!(l||d||o);if(!n)return null;let m;t[4]===r?m=t[5]:(m=I(`my-4`,r),t[4]=r,t[5]=m);let h;t[6]!==o||t[7]!==a||t[8]!==p||t[9]!==f||t[10]!==l||t[11]!==d||t[12]!==i?(h=(f||p)&&(0,z.jsxs)(Z6.Header,{className:I(!f&&`justify-end`),children:[f&&(0,z.jsxs)(Z6.Heading,{children:[i&&(0,z.jsx)(Z6.Title,{children:i}),a&&(0,z.jsx)(Z6.Description,{className:I(i&&`mt-1`),children:a})]}),p&&(0,z.jsxs)(Z6.Actions,{"data-copy-exclude":`assistant-snapshot`,children:[l&&(0,z.jsx)(Gr,{className:h8}),d&&(0,z.jsx)(Mr,{className:h8}),o]})]}),t[6]=o,t[7]=a,t[8]=p,t[9]=f,t[10]=l,t[11]=d,t[12]=i,t[13]=h):h=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=I(`overflow-hidden`,`[&>[data-streamdown=table-wrapper]]:m-0 [&>[data-streamdown=table-wrapper]]:gap-0 [&>[data-streamdown=table-wrapper]]:rounded-none [&>[data-streamdown=table-wrapper]]:border-0 [&>[data-streamdown=table-wrapper]]:bg-transparent [&>[data-streamdown=table-wrapper]]:p-0`,`[&>[data-streamdown=table-wrapper]>div:last-child]:rounded-none [&>[data-streamdown=table-wrapper]>div:last-child]:border-0`,`[&_[data-streamdown=table]]:tabular-nums`,`[&_[data-streamdown=table-header]]:bg-muted/30`,`[&_[data-streamdown=table-header-cell]]:text-muted-foreground [&_[data-streamdown=table-header-cell]]:text-xs [&_[data-streamdown=table-header-cell]]:font-medium`,`[&_[data-streamdown=table-cell]]:py-2`,`[&_[data-streamdown=table-row]]:hover:bg-muted/30`),t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=(0,z.jsx)(Z6.Content,{className:g,children:n}),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==h||t[19]!==_?(v=(0,z.jsxs)(Z6,{"data-streamdown":`table-wrapper`,className:m,children:[h,_]}),t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function M8(e){let t=(0,G.c)(43),n,r,i,a,o,s,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10]):({allowedTags:r,BlockComponent:n,children:i,components:a,controls:o,dir:s,mode:c,remarkPlugins:u,tableActions:d,...l}=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,t[8]=l,t[9]=u,t[10]=d);let f;bb0:{if(!u){f=D8;break bb0}let e;t[11]===u?e=t[12]:(e=[...u,eN,E8],t[11]=u,t[12]=e),f=e}let p=f,m;t[13]===r?m=t[14]:(m={...r,[p8]:m8},t[13]=r,t[14]=m);let h=m,g;t[15]===a?g=t[16]:(g={...a,[p8]:j8},t[15]=a,t[16]=g);let _=g,v;t[17]!==o||t[18]!==d?(v={actions:d,controls:o},t[17]=o,t[18]=d,t[19]=v):v=t[19];let y=v,b;bb1:{if(s!==`auto`||c===`static`){b=n;break bb1}let e=n??C8,r;t[20]===e?r=t[21]:(r=w8(e),t[20]=e,t[21]=r),b=r}let x=b,S;bb2:{if(s!==`auto`||c!==`static`||typeof i!=`string`){S=s;break bb2}let e;t[22]!==i||t[23]!==s?(e=S8(i)??s,t[22]=i,t[23]=s,t[24]=e):e=t[24],S=e}let C=S,w;t[25]===o?w=t[26]:(w=A8(o),t[25]=o,t[26]=w);let T;t[27]!==i||t[28]!==h?(T=t8(i,Object.keys(h)),t[27]=i,t[28]=h,t[29]=T):T=t[29];let E;t[30]!==c||t[31]!==l||t[32]!==C||t[33]!==w||t[34]!==T||t[35]!==h||t[36]!==x||t[37]!==_||t[38]!==p?(E=(0,z.jsx)(Kr,{allowedTags:h,BlockComponent:x,components:_,controls:w,dir:C,mode:c,parseMarkdownIntoBlocksFn:_8,remarkPlugins:p,...l,children:T}),t[30]=c,t[31]=l,t[32]=C,t[33]=w,t[34]=T,t[35]=h,t[36]=x,t[37]=_,t[38]=p,t[39]=E):E=t[39];let D;return t[40]!==E||t[41]!==y?(D=(0,z.jsx)(O8,{value:y,children:E}),t[40]=E,t[41]=y,t[42]=D):D=t[42],D}var N8=class extends R.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?this.props.fallback||(0,z.jsxs)(`div`,{className:`text-destructive p-2 text-sm`,children:[`Failed to render content: `,this.state.error?.message]}):this.props.children}},P8=(0,R.memo)(e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex size-full flex-col gap-2 space-y-0 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(N8,{children:(0,z.jsx)(M8,{className:i,dir:`auto`,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a});P8.displayName=`Response`;function F8(e){let t=(0,G.c)(9),n=e===void 0?2e3:e,r=un(),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(null),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>()=>{o.current&&r.clearTimeout(o.current)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,R.useEffect)(s,c);let l;t[3]!==r||t[4]!==n?(l=async e=>{await navigator.clipboard.writeText(e),a(!0),o.current&&r.clearTimeout(o.current),o.current=r.setTimeout(()=>a(!1),n)},t[3]=r,t[4]=n,t[5]=l):l=t[5];let u=l,d;return t[6]!==i||t[7]!==u?(d=[i,u],t[6]=i,t[7]=u,t[8]=d):d=t[8],d}var I8=(0,R.createContext)({code:``}),L8=e=>{let t=(0,G.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({code:r,language:i,showLineNumbers:o,wrap:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o!==void 0&&o,l=s!==void 0&&s,u=sh(r,i),d;t[7]===r?d=t[8]:(d={code:r},t[7]=r,t[8]=d);let f;t[9]===u?f=t[10]:(f=u.map(z8),t[9]=u,t[10]=f);let p;t[11]!==c||t[12]!==f||t[13]!==l?(p=(0,z.jsx)(Ea,{lineNumbers:c,wrap:l,children:f}),t[11]=c,t[12]=f,t[13]=l,t[14]=p):p=t[14];let m;t[15]===n?m=t[16]:(m=!!n&&(0,z.jsx)(Ta,{children:n}),t[15]=n,t[16]=m);let h;t[17]!==a||t[18]!==p||t[19]!==m?(h=(0,z.jsxs)(wa,{size:`sm`,...a,children:[p,m]}),t[17]=a,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==d||t[22]!==h?(g=(0,z.jsx)(I8,{value:d,children:h}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g},R8=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=F8(n),{code:c}=(0,R.use)(I8),l=async()=>{if(typeof window>`u`||!navigator.clipboard.writeText){t?.(Error(`Clipboard API not available`));return}try{await s(c),e?.()}catch(e){t?.(e instanceof Error?e:Error(String(e)))}},u=o?d:ii;return(0,z.jsx)(Ce,{className:I(`shrink-0`,i),onClick:()=>void l(),size:`icon-xs`,variant:`ghost`,...a,children:r??(0,z.jsx)(u,{})})};function z8(e,t){return(0,z.jsx)(Oa,{children:e},t)}var B8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`not-prose mb-4 w-full rounded-md border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Ia,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},V8=e=>(0,z.jsxs)(re,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,z.jsx)(yt,{className:`size-4`}),"input-available":(0,z.jsx)(ni,{className:`size-4 animate-pulse`}),"approval-requested":(0,z.jsx)(ni,{className:`size-4 text-yellow-600`}),"approval-responded":(0,z.jsx)(Zr,{className:`size-4 text-blue-600`}),"output-available":(0,z.jsx)(Zr,{className:`size-4 text-green-600`}),"output-error":(0,z.jsx)(ei,{className:`size-4 text-red-600`}),"output-denied":(0,z.jsx)(ei,{className:`size-4 text-orange-600`})}[e],{"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`}[e]]}),H8=e=>{let t=(0,G.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,title:a,part:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=I(`group flex w-full items-center justify-between gap-4 p-3`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Oi,{className:`text-muted-foreground size-4`}),t[7]=s):s=t[7];let c;t[8]!==r||t[9]!==a?(c=a??jv(r),t[8]=r,t[9]=a,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:c}),t[11]=c,t[12]=l);let u;t[13]===r.state?u=t[14]:(u=V8(r.state),t[13]=r.state,t[14]=u);let d;t[15]!==l||t[16]!==u?(d=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,l,u]}),t[15]=l,t[16]=u,t[17]=d):d=t[17];let f;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(He,{className:`text-muted-foreground size-4 transition-transform group-data-[panel-open]:rotate-180`}),t[18]=f):f=t[18];let p;return t[19]!==i||t[20]!==o||t[21]!==d?(p=(0,z.jsxs)(La,{className:o,...i,children:[d,f]}),t[19]=i,t[20]=o,t[21]=d,t[22]=p):p=t[22],p},U8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`data-closed:fade-out-0 data-closed:slide-out-to-top-2 data-open:slide-in-from-top-2 text-popover-foreground data-closed:animate-out data-open:animate-in outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Ra,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},W8=e=>{let t=(0,G.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,input:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=I(`space-y-2 overflow-hidden p-4`,n),t[4]=n,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:`Parameters`}),t[6]=o):o=t[6];let s;t[7]===r?s=t[8]:(s=JSON.stringify(r,null,2),t[7]=r,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,z.jsx)(`div`,{className:`bg-muted/50 rounded-md`,children:(0,z.jsx)(L8,{code:s,language:`json`})}),t[9]=s,t[10]=c);let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,z.jsxs)(`div`,{className:a,...i,children:[o,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l},G8=e=>{let t=(0,G.c)(24),n,r,i,a;if(t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,output:i,errorText:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a),!(i||r))return null;let o;t[5]===n?o=t[6]:(o=I(`space-y-2 p-4`,n),t[5]=n,t[6]=o);let s=r?`Error`:`Result`,c;t[7]===s?c=t[8]:(c=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:s}),t[7]=s,t[8]=c);let l=r?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`,u;t[9]===l?u=t[10]:(u=I(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,l),t[9]=l,t[10]=u);let d;t[11]===r?d=t[12]:(d=r&&(0,z.jsx)(`div`,{children:r}),t[11]=r,t[12]=d);let f;t[13]===i?f=t[14]:(f=K8(i),t[13]=i,t[14]=f);let p;t[15]!==u||t[16]!==d||t[17]!==f?(p=(0,z.jsxs)(`div`,{className:u,children:[d,f]}),t[15]=u,t[16]=d,t[17]=f,t[18]=p):p=t[18];let m;return t[19]!==a||t[20]!==o||t[21]!==c||t[22]!==p?(m=(0,z.jsxs)(`div`,{className:o,...a,children:[c,p]}),t[19]=a,t[20]=o,t[21]=c,t[22]=p,t[23]=m):m=t[23],m};function K8(e){return typeof e==`string`?(0,z.jsx)(L8,{code:e,language:`json`}):(0,R.isValidElement)(e)?(0,z.jsx)(`div`,{children:e}):typeof e==`object`?(0,z.jsx)(L8,{code:JSON.stringify(e,null,2),language:`json`}):typeof e==`number`||typeof e==`bigint`?(0,z.jsx)(`div`,{children:e}):(0,z.jsx)(`div`,{})}function q8(e){let t=(0,G.c)(20),{part:n}=e,r;t[0]===n?r=t[1]:(r=jv(n),t[0]=n,t[1]=r);let i=`Executing ${r}`,a;t[2]!==n||t[3]!==i?(a=(0,z.jsx)(H8,{title:i,part:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===n.input?o=t[6]:(o=(0,z.jsx)(W8,{input:n.input}),t[5]=n.input,t[6]=o);let s;t[7]===n.output?s=t[8]:(s=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[7]=n.output,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,z.jsx)(P8,{className:`break-all`,children:s}),t[9]=s,t[10]=c);let l;t[11]!==n.errorText||t[12]!==c?(l=(0,z.jsx)(G8,{output:c,errorText:n.errorText}),t[11]=n.errorText,t[12]=c,t[13]=l):l=t[13];let u;t[14]!==o||t[15]!==l?(u=(0,z.jsxs)(U8,{children:[o,l]}),t[14]=o,t[15]=l,t[16]=u):u=t[16];let d;return t[17]!==a||t[18]!==u?(d=(0,z.jsxs)(B8,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[17]=a,t[18]=u,t[19]=d):d=t[19],d}function J8(e){let t=(0,G.c)(18),{part:n}=e,r=`Executing ${n.toolName}`,i;t[0]!==n||t[1]!==r?(i=(0,z.jsx)(H8,{title:r,part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n.input?a=t[4]:(a=(0,z.jsx)(W8,{input:n.input}),t[3]=n.input,t[4]=a);let o;t[5]===n.output?o=t[6]:(o=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[5]=n.output,t[6]=o);let s;t[7]===o?s=t[8]:(s=(0,z.jsx)(P8,{className:`break-all`,children:o}),t[7]=o,t[8]=s);let c;t[9]!==n.errorText||t[10]!==s?(c=(0,z.jsx)(G8,{output:s,errorText:n.errorText}),t[9]=n.errorText,t[10]=s,t[11]=c):c=t[11];let l;t[12]!==a||t[13]!==c?(l=(0,z.jsxs)(U8,{children:[a,c]}),t[12]=a,t[13]=c,t[14]=l):l=t[14];let u;return t[15]!==i||t[16]!==l?(u=(0,z.jsxs)(B8,{"data-copy-exclude":`assistant-snapshot`,children:[i,l]}),t[15]=i,t[16]=l,t[17]=u):u=t[17],u}var Y8=(0,R.createContext)(!1),X8=/<\/?[a-z][\w]*-[\w-]*(?:\s+[^\s"'>/=]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*\/?>/gi,Z8=/(```[\s\S]*?```|`[^`\n]+`)/;function Q8(e){return e.split(Z8).map((e,t)=>t%2==1?e:e.replace(X8,`\0`).replace(/ \0(?= )/g,``).replaceAll(`\0`,``)).join(``)}function $8(e){let t=O6(e),n=e.parts.filter(Tv).map(e=>Q8(E6(e.text,D6(e.citations)).reverse().reduce((e,{at:n,citation:r})=>`${e.slice(0,n)}[${k6(t,r.source.url)}]${e.slice(n)}`,e.text))).join(`
|
|
347
|
+
`}var m8=`response-table-panel`,h8=[`title`,`description`],g8=I(qe({variant:`ghost`,size:`icon-sm`})),_8=Ir().use(Wr).use(Hr).use(eN),v8=e=>{let t=Pr(e),n=x8(e);if(n.length===0)return t;let r=0,i=t.map(e=>{let t={start:r,end:r+e.length};return r=t.end,t}),a=new Set;for(let e of n){let t=!1;for(let[n,r]of i.entries())r.start<e.end&&r.end>e.start&&(t&&a.add(n),t=!0)}return t.reduce((e,t,n)=>(a.has(n)&&e.length>0?e[e.length-1]+=t:e.push(t),e),[])};function y8(e){return e?.type===`leafDirective`&&`name`in e&&e.name===`table`}function b8(e,t){if(t===void 0)return;let n=e[t-1];return y8(n)?n:void 0}function x8(e){let t=[];return Ar(_8.parse(e),`table`,(e,n,r)=>{if(!r)return;let i=b8(r.children,n)?.position?.start.offset,a=e.position?.end.offset;i!==void 0&&a!==void 0&&t.push({start:i,end:a})}),t}function S8(e,t){return e.attributes?.[t]?.trim()||void 0}function C8(e){let t=_8.parse(e),n=!1;if(Ar(t,`leafDirective`,(e,t,r)=>{let i=t===void 0?void 0:r?.children[t+1];if(e.name!==`table`||i?.type!==`table`)return;n=!0;let a=[S8(e,`title`),S8(e,`description`)].filter(Boolean).join(` `);e.children=a?[{type:`text`,value:a}]:[]}),n)return Ur(jr(t,{includeHtml:!1}))}function w8(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(Fr,{...e}),t[0]=e,t[1]=n),n}function T8(e){function t(t){let n=(0,G.c)(6),r;n[0]!==t.content||n[1]!==t.dir?(r=C8(t.content)??t.dir,n[0]=t.content,n[1]=t.dir,n[2]=r):r=n[2];let i=r,a;return n[3]!==i||n[4]!==t?(a=(0,z.jsx)(e,{...t,dir:i}),n[3]=i,n[4]=t,n[5]=a):a=n[5],a}return t.displayName=`DirectionAwareTableBlock`,t}function E8(e,t){let n=t&&S8(t,`title`),r=t&&S8(t,`description`),i={...n?{title:n}:{},...r?{description:r}:{}};return{type:`tablePanel`,data:{hName:m8,...Object.keys(i).length>0?{hProperties:i}:{}},children:[e]}}function D8(){return e=>{Ar(e,`table`,(e,t,n)=>{if(t===void 0||!n)return;let r=b8(n.children,t),i=r?t-1:t,a=r?2:1;return n.children.splice(i,a,E8(e,r)),[Sr,i+1]})}}var O8=[...Object.values(Vr),eN,D8],k8=R.createContext({actions:null,controls:!0});function A8(e,t){if(e===!1)return!1;if(e===!0||e===void 0)return!0;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1}function j8(e){return e===!1?!1:e===!0||e===void 0?{table:!1}:{...e,table:!1}}function M8(e){let t=(0,G.c)(21),{children:n,className:r,title:i,description:a}=e,{actions:o,controls:s}=R.use(k8),c;t[0]===s?c=t[1]:(c=A8(s,`copy`),t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=A8(s,`download`),t[2]=s,t[3]=u);let d=u,f=!!(i||a),p=!!(l||d||o);if(!n)return null;let m;t[4]===r?m=t[5]:(m=I(`my-4`,r),t[4]=r,t[5]=m);let h;t[6]!==o||t[7]!==a||t[8]!==p||t[9]!==f||t[10]!==l||t[11]!==d||t[12]!==i?(h=(f||p)&&(0,z.jsxs)(Q6.Header,{className:I(!f&&`justify-end`),children:[f&&(0,z.jsxs)(Q6.Heading,{children:[i&&(0,z.jsx)(Q6.Title,{children:i}),a&&(0,z.jsx)(Q6.Description,{className:I(i&&`mt-1`),children:a})]}),p&&(0,z.jsxs)(Q6.Actions,{"data-copy-exclude":`assistant-snapshot`,children:[l&&(0,z.jsx)(Gr,{className:g8}),d&&(0,z.jsx)(Mr,{className:g8}),o]})]}),t[6]=o,t[7]=a,t[8]=p,t[9]=f,t[10]=l,t[11]=d,t[12]=i,t[13]=h):h=t[13];let g;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(g=I(`overflow-hidden`,`[&>[data-streamdown=table-wrapper]]:m-0 [&>[data-streamdown=table-wrapper]]:gap-0 [&>[data-streamdown=table-wrapper]]:rounded-none [&>[data-streamdown=table-wrapper]]:border-0 [&>[data-streamdown=table-wrapper]]:bg-transparent [&>[data-streamdown=table-wrapper]]:p-0`,`[&>[data-streamdown=table-wrapper]>div:last-child]:rounded-none [&>[data-streamdown=table-wrapper]>div:last-child]:border-0`,`[&_[data-streamdown=table]]:tabular-nums`,`[&_[data-streamdown=table-header]]:bg-muted/30`,`[&_[data-streamdown=table-header-cell]]:text-muted-foreground [&_[data-streamdown=table-header-cell]]:text-xs [&_[data-streamdown=table-header-cell]]:font-medium`,`[&_[data-streamdown=table-cell]]:py-2`,`[&_[data-streamdown=table-row]]:hover:bg-muted/30`),t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=(0,z.jsx)(Q6.Content,{className:g,children:n}),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==h||t[19]!==_?(v=(0,z.jsxs)(Q6,{"data-streamdown":`table-wrapper`,className:m,children:[h,_]}),t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function N8(e){let t=(0,G.c)(48),n,r,i,a,o,s,c,l,u,d,f;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11]):({allowedTags:r,BlockComponent:n,children:i,components:a,controls:o,dir:s,mode:c,remarkPlugins:u,tableActions:d,translations:f,...l}=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,t[8]=l,t[9]=u,t[10]=d,t[11]=f);let p=s6(),m;bb0:{if(!u){m=O8;break bb0}let e;t[12]===u?e=t[13]:(e=[...u,eN,D8],t[12]=u,t[13]=e),m=e}let h=m,g;t[14]===r?g=t[15]:(g={...r,[m8]:h8},t[14]=r,t[15]=g);let _=g,v;t[16]===a?v=t[17]:(v={...a,[m8]:M8},t[16]=a,t[17]=v);let y=v,b;t[18]!==o||t[19]!==d?(b={actions:d,controls:o},t[18]=o,t[19]=d,t[20]=b):b=t[20];let x=b,S;bb1:{if(s!==`auto`||c===`static`){S=n;break bb1}let e=n??w8,r;t[21]===e?r=t[22]:(r=T8(e),t[21]=e,t[22]=r),S=r}let C=S,w;bb2:{if(s!==`auto`||c!==`static`||typeof i!=`string`){w=s;break bb2}let e;t[23]!==i||t[24]!==s?(e=C8(i)??s,t[23]=i,t[24]=s,t[25]=e):e=t[25],w=e}let T=w,E;t[26]===o?E=t[27]:(E=j8(o),t[26]=o,t[27]=E);let D;t[28]!==p||t[29]!==f?(D={...p,...f},t[28]=p,t[29]=f,t[30]=D):D=t[30];let O;t[31]!==i||t[32]!==_?(O=n8(i,Object.keys(_)),t[31]=i,t[32]=_,t[33]=O):O=t[33];let ee;t[34]!==c||t[35]!==l||t[36]!==T||t[37]!==E||t[38]!==D||t[39]!==O||t[40]!==_||t[41]!==C||t[42]!==y||t[43]!==h?(ee=(0,z.jsx)(Kr,{allowedTags:_,BlockComponent:C,components:y,controls:E,dir:T,mode:c,parseMarkdownIntoBlocksFn:v8,remarkPlugins:h,translations:D,...l,children:O}),t[34]=c,t[35]=l,t[36]=T,t[37]=E,t[38]=D,t[39]=O,t[40]=_,t[41]=C,t[42]=y,t[43]=h,t[44]=ee):ee=t[44];let k;return t[45]!==ee||t[46]!==x?(k=(0,z.jsx)(k8,{value:x,children:ee}),t[45]=ee,t[46]=x,t[47]=k):k=t[47],k}var P8=class extends R.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?this.props.fallback||(0,z.jsx)(F8,{error:this.state.error?.message??``}):this.props.children}};function F8(e){let t=(0,G.c)(5),{error:n}=e,r=c6(),i;t[0]!==n||t[1]!==r?(i=r(`response.renderFailed`,{error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,z.jsx)(`div`,{className:`text-destructive p-2 text-sm`,children:i}),t[3]=i,t[4]=a),a}var I8=(0,R.memo)(e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`flex size-full flex-col gap-2 space-y-0 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(P8,{children:(0,z.jsx)(N8,{className:i,dir:`auto`,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a});I8.displayName=`Response`;function L8(e){let t=(0,G.c)(9),n=e===void 0?2e3:e,r=un(),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(null),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>()=>{o.current&&r.clearTimeout(o.current)},c=[r],t[0]=r,t[1]=s,t[2]=c),(0,R.useEffect)(s,c);let l;t[3]!==r||t[4]!==n?(l=async e=>{await navigator.clipboard.writeText(e),a(!0),o.current&&r.clearTimeout(o.current),o.current=r.setTimeout(()=>a(!1),n)},t[3]=r,t[4]=n,t[5]=l):l=t[5];let u=l,d;return t[6]!==i||t[7]!==u?(d=[i,u],t[6]=i,t[7]=u,t[8]=d):d=t[8],d}var R8=(0,R.createContext)({code:``}),z8=e=>{let t=(0,G.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({code:r,language:i,showLineNumbers:o,wrap:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o!==void 0&&o,l=s!==void 0&&s,u=sh(r,i),d;t[7]===r?d=t[8]:(d={code:r},t[7]=r,t[8]=d);let f;t[9]===u?f=t[10]:(f=u.map(V8),t[9]=u,t[10]=f);let p;t[11]!==c||t[12]!==f||t[13]!==l?(p=(0,z.jsx)(Ea,{lineNumbers:c,wrap:l,children:f}),t[11]=c,t[12]=f,t[13]=l,t[14]=p):p=t[14];let m;t[15]===n?m=t[16]:(m=!!n&&(0,z.jsx)(Ta,{children:n}),t[15]=n,t[16]=m);let h;t[17]!==a||t[18]!==p||t[19]!==m?(h=(0,z.jsxs)(wa,{size:`sm`,...a,children:[p,m]}),t[17]=a,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==d||t[22]!==h?(g=(0,z.jsx)(R8,{value:d,children:h}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g},B8=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=L8(n),{code:c}=(0,R.use)(R8),l=async()=>{if(typeof window>`u`||!navigator.clipboard.writeText){t?.(Error(`Clipboard API not available`));return}try{await s(c),e?.()}catch(e){t?.(e instanceof Error?e:Error(String(e)))}},u=o?d:ii;return(0,z.jsx)(Ce,{className:I(`shrink-0`,i),onClick:()=>void l(),size:`icon-xs`,variant:`ghost`,...a,children:r??(0,z.jsx)(u,{})})};function V8(e,t){return(0,z.jsx)(Oa,{children:e},t)}var H8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`not-prose mb-4 w-full rounded-md border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Ia,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};function U8(e){let t=(0,G.c)(7),{status:n}=e,r=c6(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={"input-streaming":(0,z.jsx)(yt,{className:`size-4`}),"input-available":(0,z.jsx)(ni,{className:`size-4 animate-pulse`}),"approval-requested":(0,z.jsx)(ni,{className:`size-4 text-yellow-600`}),"approval-responded":(0,z.jsx)(Zr,{className:`size-4 text-blue-600`}),"output-available":(0,z.jsx)(Zr,{className:`size-4 text-green-600`}),"output-error":(0,z.jsx)(ei,{className:`size-4 text-red-600`}),"output-denied":(0,z.jsx)(ei,{className:`size-4 text-orange-600`})},t[0]=i):i=t[0];let a=i[n],o;t[1]!==n||t[2]!==r?(o=r(`tool.state`,{state:n}),t[1]=n,t[2]=r,t[3]=o):o=t[3];let s;return t[4]!==a||t[5]!==o?(s=(0,z.jsxs)(ne,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s}var W8=e=>{let t=(0,G.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,title:a,part:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===n?o=t[6]:(o=I(`group flex w-full items-center justify-between gap-4 p-3`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Oi,{className:`text-muted-foreground size-4`}),t[7]=s):s=t[7];let c;t[8]!==r||t[9]!==a?(c=a??jv(r),t[8]=r,t[9]=a,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:c}),t[11]=c,t[12]=l);let u;t[13]===r.state?u=t[14]:(u=(0,z.jsx)(U8,{status:r.state}),t[13]=r.state,t[14]=u);let d;t[15]!==l||t[16]!==u?(d=(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s,l,u]}),t[15]=l,t[16]=u,t[17]=d):d=t[17];let f;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(He,{className:`text-muted-foreground size-4 transition-transform group-data-[panel-open]:rotate-180`}),t[18]=f):f=t[18];let p;return t[19]!==i||t[20]!==o||t[21]!==d?(p=(0,z.jsxs)(La,{className:o,...i,children:[d,f]}),t[19]=i,t[20]=o,t[21]=d,t[22]=p):p=t[22],p},G8=e=>{let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`data-closed:fade-out-0 data-closed:slide-out-to-top-2 data-open:slide-in-from-top-2 text-popover-foreground data-closed:animate-out data-open:animate-in outline-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(Ra,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a},K8=e=>{let t=(0,G.c)(19),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,input:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=c6(),o;t[4]===n?o=t[5]:(o=I(`space-y-2 overflow-hidden p-4`,n),t[4]=n,t[5]=o);let s;t[6]===a?s=t[7]:(s=a(`tool.parameters`),t[6]=a,t[7]=s);let c;t[8]===s?c=t[9]:(c=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:s}),t[8]=s,t[9]=c);let l;t[10]===r?l=t[11]:(l=JSON.stringify(r,null,2),t[10]=r,t[11]=l);let u;t[12]===l?u=t[13]:(u=(0,z.jsx)(`div`,{className:`bg-muted/50 rounded-md`,children:(0,z.jsx)(z8,{code:l,language:`json`})}),t[12]=l,t[13]=u);let d;return t[14]!==i||t[15]!==o||t[16]!==c||t[17]!==u?(d=(0,z.jsxs)(`div`,{className:o,...i,children:[c,u]}),t[14]=i,t[15]=o,t[16]=c,t[17]=u,t[18]=d):d=t[18],d},q8=e=>{let t=(0,G.c)(27),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,output:i,errorText:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=c6();if(!(i||r))return null;let s;t[5]===n?s=t[6]:(s=I(`space-y-2 p-4`,n),t[5]=n,t[6]=s);let c=r?`tool.error`:`tool.result`,l;t[7]!==o||t[8]!==c?(l=o(c),t[7]=o,t[8]=c,t[9]=l):l=t[9];let u;t[10]===l?u=t[11]:(u=(0,z.jsx)(`h4`,{className:`text-muted-foreground text-xs font-medium tracking-wide uppercase`,children:l}),t[10]=l,t[11]=u);let d=r?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`,f;t[12]===d?f=t[13]:(f=I(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,d),t[12]=d,t[13]=f);let p;t[14]===r?p=t[15]:(p=r&&(0,z.jsx)(`div`,{children:r}),t[14]=r,t[15]=p);let m;t[16]===i?m=t[17]:(m=J8(i),t[16]=i,t[17]=m);let h;t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,z.jsxs)(`div`,{className:f,children:[p,m]}),t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;return t[22]!==a||t[23]!==s||t[24]!==u||t[25]!==h?(g=(0,z.jsxs)(`div`,{className:s,...a,children:[u,h]}),t[22]=a,t[23]=s,t[24]=u,t[25]=h,t[26]=g):g=t[26],g};function J8(e){return typeof e==`string`?(0,z.jsx)(z8,{code:e,language:`json`}):(0,R.isValidElement)(e)?(0,z.jsx)(`div`,{children:e}):typeof e==`object`?(0,z.jsx)(z8,{code:JSON.stringify(e,null,2),language:`json`}):typeof e==`number`||typeof e==`bigint`?(0,z.jsx)(`div`,{children:e}):(0,z.jsx)(`div`,{})}function Y8(e){let t=(0,G.c)(21),{part:n}=e,r=c6(),i;t[0]!==n||t[1]!==r?(i=r(`tool.executing`,{tool:jv(n)}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]!==n||t[4]!==i?(a=(0,z.jsx)(W8,{title:i,part:n}),t[3]=n,t[4]=i,t[5]=a):a=t[5];let o;t[6]===n.input?o=t[7]:(o=(0,z.jsx)(K8,{input:n.input}),t[6]=n.input,t[7]=o);let s;t[8]===n.output?s=t[9]:(s=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[8]=n.output,t[9]=s);let c;t[10]===s?c=t[11]:(c=(0,z.jsx)(I8,{className:`break-all`,children:s}),t[10]=s,t[11]=c);let l;t[12]!==n.errorText||t[13]!==c?(l=(0,z.jsx)(q8,{output:c,errorText:n.errorText}),t[12]=n.errorText,t[13]=c,t[14]=l):l=t[14];let u;t[15]!==o||t[16]!==l?(u=(0,z.jsxs)(G8,{children:[o,l]}),t[15]=o,t[16]=l,t[17]=u):u=t[17];let d;return t[18]!==a||t[19]!==u?(d=(0,z.jsxs)(H8,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[18]=a,t[19]=u,t[20]=d):d=t[20],d}function X8(e){let t=(0,G.c)(21),{part:n}=e,r=c6(),i;t[0]!==n.toolName||t[1]!==r?(i=r(`tool.executing`,{tool:n.toolName}),t[0]=n.toolName,t[1]=r,t[2]=i):i=t[2];let a;t[3]!==n||t[4]!==i?(a=(0,z.jsx)(W8,{title:i,part:n}),t[3]=n,t[4]=i,t[5]=a):a=t[5];let o;t[6]===n.input?o=t[7]:(o=(0,z.jsx)(K8,{input:n.input}),t[6]=n.input,t[7]=o);let s;t[8]===n.output?s=t[9]:(s=typeof n.output==`string`?n.output:JSON.stringify(n.output,null,2),t[8]=n.output,t[9]=s);let c;t[10]===s?c=t[11]:(c=(0,z.jsx)(I8,{className:`break-all`,children:s}),t[10]=s,t[11]=c);let l;t[12]!==n.errorText||t[13]!==c?(l=(0,z.jsx)(q8,{output:c,errorText:n.errorText}),t[12]=n.errorText,t[13]=c,t[14]=l):l=t[14];let u;t[15]!==o||t[16]!==l?(u=(0,z.jsxs)(G8,{children:[o,l]}),t[15]=o,t[16]=l,t[17]=u):u=t[17];let d;return t[18]!==a||t[19]!==u?(d=(0,z.jsxs)(H8,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[18]=a,t[19]=u,t[20]=d):d=t[20],d}var Z8=(0,R.createContext)(!1),Q8=/<\/?[a-z][\w]*-[\w-]*(?:\s+[^\s"'>/=]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*\/?>/gi,$8=/(```[\s\S]*?```|`[^`\n]+`)/;function e5(e){return e.split($8).map((e,t)=>t%2==1?e:e.replace(Q8,`\0`).replace(/ \0(?= )/g,``).replaceAll(`\0`,``)).join(``)}function t5(e){let t=j6(e),n=e.parts.filter(Tv).map(e=>e5(k6(e.text,A6(e.citations)).reverse().reduce((e,{at:n,citation:r})=>`${e.slice(0,n)}[${M6(t,r.source.url)}]${e.slice(n)}`,e.text))).join(`
|
|
348
348
|
`);return t.length===0?n:`${n}\n\n${t.map(({url:e,title:t},n)=>`[${n+1}] ${t?`${t} — `:``}${e}`).join(`
|
|
349
|
-
`)}`}function e5(){return(0,R.use)(Y8)}function t5(e){return kv(e)&&e.toolMetadata?.kind===`subagent`}function n5(e,t){let n=Av(e);return{toolKey:n,toolEntry:t?.[n]}}function r5(e,t){return e?.static===!1&&!!e?.requiresUserInput&&t===`input-available`}var i5=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.del.dfn.em.i.ins.kbd.mark.q.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`));function a5(e){if(!R.isValidElement(e))return!1;let t=typeof e.type==`string`?e.type:e.props.node?.tagName;return t===void 0||!i5.has(t)}function o5(e){let t=(0,G.c)(6),{children:n,dir:r}=e,i=R.Children.toArray(n);if(!i.some(a5)){let e;return t[0]!==n||t[1]!==r?(e=(0,z.jsx)(`p`,{dir:r,children:n}),t[0]=n,t[1]=r,t[2]=e):e=t[2],e}if(i.every(a5))return n;let a;return t[3]!==n||t[4]!==r?(a=(0,z.jsx)(`div`,{dir:r,children:n}),t[3]=n,t[4]=r,t[5]=a):a=t[5],a}var s5={p:({children:e,dir:t})=>(0,z.jsx)(o5,{dir:t,children:e})};function c5(e){let t={...s5},n={};for(let r of e)Ij(r),t[r.name]=r.component,n[r.name]=r.allowedAttributes;return{components:t,allowedTags:n}}function l5(e){let t=(0,G.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({elements:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n??[],t[3]=n,t[4]=i);let a;t[5]===i?a=t[6]:(a=c5(i),t[5]=i,t[6]=a);let o=a,s;return t[7]!==r||t[8]!==o?(s=(0,z.jsx)(P8,{...o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function u5(e){let t=(0,G.c)(22),{part:n}=e,{addToolApprovalResponse:r}=T6();if(n.state!==`approval-requested`)return null;let i;t[0]===n?i=t[1]:(i=n.title??Av(n),t[0]=n,t[1]=i);let a=i,o=`${a} approval`,s;t[2]===a?s=t[3]:(s=(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:a}),t[2]=a,t[3]=s);let c;t[4]===n.approval.requestReason?c=t[5]:(c=n.approval.requestReason&&(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.approval.requestReason}),t[4]=n.approval.requestReason,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,z.jsxs)(`div`,{className:`space-y-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.approval.id?(u=(0,z.jsx)(Ce,{type:`button`,variant:`destructive`,onClick:()=>void r({id:n.approval.id,approved:!1}),children:`Deny`}),t[9]=r,t[10]=n.approval.id,t[11]=u):u=t[11];let d;t[12]!==r||t[13]!==n.approval.id?(d=(0,z.jsx)(Ce,{type:`button`,onClick:()=>void r({id:n.approval.id,approved:!0}),children:`Approve`}),t[12]=r,t[13]=n.approval.id,t[14]=d):d=t[14];let f;t[15]!==u||t[16]!==d?(f=(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17];let p;return t[18]!==o||t[19]!==l||t[20]!==f?(p=(0,z.jsxs)(`div`,{"aria-label":o,className:`border-border bg-muted/30 space-y-3 rounded-lg border p-3`,"data-copy-exclude":`assistant-snapshot`,role:`group`,children:[l,f]}),t[18]=o,t[19]=l,t[20]=f,t[21]=p):p=t[21],p}function d5(e){let t=(0,G.c)(25),{part:n}=e,{registry:r}=S6();if(n.input===void 0){let e;return t[0]!==n.errorText||t[1]!==n.output||t[2]!==n.state?(e=n.state===`output-error`?(0,z.jsx)(G8,{output:n.output,errorText:n.errorText}):(0,z.jsx)(fi,{className:`size-4 animate-spin`}),t[0]=n.errorText,t[1]=n.output,t[2]=n.state,t[3]=e):e=t[3],e}let i;t[4]===n?i=t[5]:(i=(0,z.jsx)(u5,{part:n}),t[4]=n,t[5]=i);let a=i;if(!r)return a;let o;t[6]!==n||t[7]!==r?(o=n5(n,r),t[6]=n,t[7]=r,t[8]=o):o=t[8];let{toolEntry:s}=o;if(s){let e=s.component,i;t[9]!==n||t[10]!==r.progress?(i=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[9]=n,t[10]=r.progress,t[11]=i):i=t[11];let o;t[12]!==e||t[13]!==n?(o=(0,z.jsx)(e,{part:n}),t[12]=e,t[13]=n,t[14]=o):o=t[14];let c;return t[15]!==a||t[16]!==i||t[17]!==o?(c=(0,z.jsxs)(`div`,{className:`space-y-2`,children:[i,o,a]}),t[15]=a,t[16]=i,t[17]=o,t[18]=c):c=t[18],c}else{let e;t[19]!==n||t[20]!==r.progress?(e=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[19]=n,t[20]=r.progress,t[21]=e):e=t[21];let i;return t[22]!==a||t[23]!==e?(i=(0,z.jsxs)(z.Fragment,{children:[e,a]}),t[22]=a,t[23]=e,t[24]=i):i=t[24],i}}var f5={animation:`slideUp`};function p5(e){let t=(0,G.c)(3),{filename:n,url:r}=e,i=n??`Attached image`,a;return t[0]!==i||t[1]!==r?(a=(0,z.jsx)(`img`,{src:r,alt:i,className:`max-h-64 rounded-md border object-contain`}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function m5(e){let t=(0,G.c)(16),{filename:n,mediaType:r,url:i}=e,a=n||`Untitled`,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=i?.startsWith(`data:`)?null:i&&r.startsWith(`video/`)?(0,z.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:i,"aria-label":a,className:`max-h-96 w-full rounded-md bg-black`,children:(0,z.jsx)(`track`,{kind:`captions`})}):i&&r.startsWith(`audio/`)?(0,z.jsx)(`audio`,{controls:!0,preload:`metadata`,src:i,"aria-label":a,className:`w-full`,children:(0,z.jsx)(`track`,{kind:`captions`})}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s=o,c=s?`mt-2`:void 0,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`strong`,{children:`File:`}),t[4]=l):l=t[4];let u;t[5]!==n||t[6]!==i?(u=i?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(`a`,{href:i,download:n,className:`underline`,children:`Download`})]}):null,t[5]=n,t[6]=i,t[7]=u):u=t[7];let d;t[8]!==r||t[9]!==a||t[10]!==c||t[11]!==u?(d=(0,z.jsxs)(`div`,{className:c,children:[l,` `,a,` (`,r,`)`,u]}),t[8]=r,t[9]=a,t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==s||t[14]!==d?(f=(0,z.jsxs)(Ji,{className:`bg-muted/30 block w-full rounded-md p-3 text-sm text-inherit`,children:[s,d]}),t[13]=s,t[14]=d,t[15]=f):f=t[15],f}function h5(e){let t=(0,G.c)(4),{filename:n,mediaType:r,url:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=r.split(`/`)[0]===`image`?(0,z.jsx)(p5,{filename:n,url:i}):(0,z.jsx)(m5,{filename:n,mediaType:r,url:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}var g5=`genai-citation`;function _5(e,t){return E6(e,t).reverse().reduce((e,{at:t,order:n})=>`${e.slice(0,t)}<${g5} citation="${n}" />${e.slice(t)}`,e)}var v5=(0,R.createContext)(null);function y5(e){let t=(0,G.c)(16),n=(0,R.use)(v5),r=n?.citations[Number(e.citation)];if(!n||!r)return null;let i;t[0]!==r.source.url||t[1]!==n.sources?(i=k6(n.sources,r.source.url),t[0]=r.source.url,t[1]=n.sources,t[2]=i):i=t[2];let a=i;if(a===null)return null;if(n.HostCitation){let e;return t[3]!==r||t[4]!==n.HostCitation||t[5]!==a?(e=(0,z.jsx)(n.HostCitation,{citation:r,index:a}),t[3]=r,t[4]=n.HostCitation,t[5]=a,t[6]=e):e=t[6],e}let o;t[7]!==r.source.title||t[8]!==r.source.url?(o={url:r.source.url,title:r.source.title},t[7]=r.source.title,t[8]=r.source.url,t[9]=o):o=t[9];let s;t[10]===r.citedText?s=t[11]:(s=r.citedText?(0,z.jsx)(`blockquote`,{dir:`auto`,children:r.citedText}):null,t[10]=r.citedText,t[11]=s);let c;return t[12]!==a||t[13]!==o||t[14]!==s?(c=(0,z.jsx)(U6,{source:o,index:a,children:s}),t[12]=a,t[13]=o,t[14]=s,t[15]=c):c=t[15],c}var b5={name:g5,allowedAttributes:[`citation`],component:y5};function x5(e){let t=(0,G.c)(27),{text:n,citations:r,elements:i,className:a}=e,{status:o}=C6(),s=e5(),{citation:c}=R6(),{message:l}=B6(),u;t[0]===r?u=t[1]:(u=D6(r),t[0]=r,t[1]=u);let d=u,f;t[2]===l?f=t[3]:(f=O6(l),t[2]=l,t[3]=f);let p;t[4]!==c||t[5]!==f||t[6]!==d?(p={citations:d,sources:f,HostCitation:c},t[4]=c,t[5]=f,t[6]=d,t[7]=p):p=t[7];let m=p,h=d.length>0,g;t[8]!==i||t[9]!==h?(g=h?[...i??[],b5]:i,t[8]=i,t[9]=h,t[10]=g):g=t[10];let _=g,v;t[11]===a?v=t[12]:(v=I(`text-sm`,a),t[11]=a,t[12]=v);let y=!s&&o===`streaming`,b;t[13]!==h||t[14]!==n||t[15]!==d?(b=h?_5(n,d):n,t[13]=h,t[14]=n,t[15]=d,t[16]=b):b=t[16];let x;t[17]!==y||t[18]!==b||t[19]!==_?(x=(0,z.jsx)(l5,{elements:_,animated:f5,isAnimating:y,children:b}),t[17]=y,t[18]=b,t[19]=_,t[20]=x):x=t[20];let S;t[21]!==v||t[22]!==x?(S=(0,z.jsx)(`div`,{className:v,children:x}),t[21]=v,t[22]=x,t[23]=S):S=t[23];let C;return t[24]!==m||t[25]!==S?(C=(0,z.jsx)(v5,{value:m,children:S}),t[24]=m,t[25]=S,t[26]=C):C=t[26],C}function S5(e){let t=(0,G.c)(8),{part:n}=e,r=C5(),i;t[0]!==n||t[1]!==r?(i=r&&(0,z.jsx)(q8,{part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=(0,z.jsx)(d5,{part:n}),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,z.jsxs)(z.Fragment,{children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function C5(){let{debugMode:e}=S6(),t=e5();return!!e&&!t}function w5(e){return!!e&&e!==`output-available`}function T5(e){let t=(0,G.c)(5),{label:n,part:r,state:i}=e,a=e5(),o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=!a&&!!n.actions&&!!r&&!w5(i),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function E5(e){let t=(0,G.c)(20),{label:n,part:r}=e,i=n.icon,a=n.actions,o;t[0]!==n||t[1]!==r?(o={label:n,part:r,state:r.state},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=T5(o),c;t[3]!==i||t[4]!==n.isError?(c=i&&(0,z.jsx)(i,{className:I(`size-3.5`,n.isError?`text-destructive`:`text-muted-foreground`)}),t[3]=i,t[4]=n.isError,t[5]=c):c=t[5];let l;t[6]!==n.kind||t[7]!==n.name||t[8]!==n.text?(l=n.kind===`sentence`?(0,z.jsx)(`span`,{dir:`auto`,className:`text-start`,children:n.text}):(0,z.jsx)(`span`,{className:`font-mono`,children:n.name}),t[6]=n.kind,t[7]=n.name,t[8]=n.text,t[9]=l):l=t[9];let u;t[10]!==c||t[11]!==l?(u=(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==a||t[14]!==r||t[15]!==s?(d=s&&a&&(0,z.jsx)(a,{part:r}),t[13]=a,t[14]=r,t[15]=s,t[16]=d):d=t[16];let f;return t[17]!==u||t[18]!==d?(f=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-1.5 text-xs`,children:[u,d]}),t[17]=u,t[18]=d,t[19]=f):f=t[19],f}function D5(e){let t=(0,G.c)(3),{name:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,z.jsxs)(`span`,{"data-slot":`tool-arg`,children:[n,`: "`,r,`"`]}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function O5(e){let t=(0,G.c)(24),{label:n,state:r,part:i,children:a}=e,o=n.actions,s;t[0]!==n||t[1]!==i||t[2]!==r?(s={label:n,part:i,state:r},t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c=T5(s),l=n.kind===`sentence`,u;t[4]!==a||t[5]!==l||t[6]!==n.args||t[7]!==n.name||t[8]!==n.text?(u=l?(0,z.jsx)(`span`,{dir:`auto`,className:`text-muted-foreground min-w-0 truncate text-start text-xs`,children:n.text}):(0,z.jsxs)(`span`,{className:`text-muted-foreground min-w-0 truncate font-mono text-xs [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:mr-1 [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:content-[',']`,children:[n.name,`(`,a,n.args?Object.entries(n.args).map(k5):`...`,`)`]}),t[4]=a,t[5]=l,t[6]=n.args,t[7]=n.name,t[8]=n.text,t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==i||t[12]!==c?(d=c&&o&&i&&(0,z.jsx)(`span`,{className:`shrink-0`,children:(0,z.jsx)(o,{part:i})}),t[10]=o,t[11]=i,t[12]=c,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==l||t[18]!==n.detail||t[19]!==n.isError?(p=n.detail&&(0,z.jsx)(`span`,{dir:l?`auto`:void 0,className:I(`line-clamp-3 text-start leading-relaxed whitespace-pre-wrap`,l?`text-xs`:`font-mono text-[10px]`,n.isError?`text-destructive/80`:`text-muted-foreground`),children:n.detail}),t[17]=l,t[18]=n.detail,t[19]=n.isError,t[20]=p):p=t[20];let m;return t[21]!==f||t[22]!==p?(m=(0,z.jsxs)(`span`,{className:`mb-2 flex flex-col gap-1`,children:[f,p]}),t[21]=f,t[22]=p,t[23]=m):m=t[23],m}function k5(e){let[t,n]=e;return(0,z.jsx)(D5,{name:t,value:n},t)}function A5(e){return e.type===`text`&&e.providerMetadata?.openai?.phase===`commentary`}function j5(e){let t=(0,G.c)(9),{segment:n,elements:r,className:i}=e,a;if(t[0]!==i||t[1]!==r||t[2]!==n.parts){let e;t[4]!==i||t[5]!==r?(e=e=>{let{part:t,idx:n}=e;return t.type===`text`?(0,z.jsx)(x5,{text:t.text,citations:t.citations,elements:r,className:i},`${n}-text`):null},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.parts.map(e),t[0]=i,t[1]=r,t[2]=n.parts,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,z.jsx)(z.Fragment,{children:a}),t[7]=a,t[8]=o),o}function M5(e){let t=(0,G.c)(4),{segment:n}=e,{part:r}=n;if(r.type!==`file`)return null;let i;return t[0]!==r.filename||t[1]!==r.mediaType||t[2]!==r.url?(i=(0,z.jsx)(h5,{filename:r.filename,mediaType:r.mediaType,url:r.url}),t[0]=r.filename,t[1]=r.mediaType,t[2]=r.url,t[3]=i):i=t[3],i}function N5(e){let t=(0,G.c)(9),{segment:n}=e,{message:r}=B6(),i;t[0]===r?i=t[1]:(i=O6(r),t[0]=r,t[1]=i);let a=i,o;if(t[2]!==n.parts||t[3]!==a){let e;t[5]===a?e=t[6]:(e=e=>{let{part:t,idx:n}=e;if(t.type!==`source-url`)return null;let r=k6(a,t.url);return r===null?null:(0,z.jsx)(U6,{source:{url:t.url,title:t.title},index:r},`source-${n}`)},t[5]=a,t[6]=e),o=n.parts.map(e),t[2]=n.parts,t[3]=a,t[4]=o}else o=t[4];let s;return t[7]===o?s=t[8]:(s=(0,z.jsx)(`span`,{children:o}),t[7]=o,t[8]=s),s}function P5(e){let t=(0,G.c)(3),{segment:n}=e,r=z6();if(e5())return null;let{part:i}=n;if(i.type!==`reasoning`)return null;let a=r===`streaming`,o;return t[0]!==i.text||t[1]!==a?(o=(0,z.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,z.jsx)(P8,{animated:f5,isAnimating:a,children:i.text})}),t[0]=i.text,t[1]=a,t[2]=o):o=t[2],o}function F5(e){let t=(0,G.c)(2),{segment:n}=e;if(!C5())return null;let{part:r}=n;if(r.type!==`dynamic-tool`)return null;let i;return t[0]===r?i=t[1]:(i=(0,z.jsx)(J8,{part:r}),t[0]=r,t[1]=i),i}var I5=(0,R.createContext)(null),L5=(0,R.createContext)(null);function R5(){let e=(0,R.use)(I5);if(!e)throw Error(`Segment.Tool* parts must be rendered within Segment.Tool`);return e}function z5(e){let t=(0,G.c)(29),{segment:n,children:r}=e,i=S6(),a=z6(),{part:o}=n;if(!Dv(o))return null;let s,c,l,u;t[0]!==i.registry||t[1]!==a||t[2]!==o?({toolEntry:u}=n5(o,i.registry),c=r5(u,o.state),s=!c&&j6(o,a),l=u?.label?.(o),t[0]=i.registry,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l,t[6]=u):(s=t[3],c=t[4],l=t[5],u=t[6]);let d=l,f;t[7]!==s||t[8]!==d||t[9]!==o?(f=s?{...d??{name:Av(o)},isError:!0,detail:`Cancelled by user`}:d,t[7]=s,t[8]=d,t[9]=o,t[10]=f):f=t[10];let p=f,m=u?.static===!1&&!!u?.requiresUserInput&&!c,h;t[11]!==s||t[12]!==c||t[13]!==m||t[14]!==p||t[15]!==o?(h={part:o,label:p,aborted:s,activeClientInput:c,defaultOpen:m},t[11]=s,t[12]=c,t[13]=m,t[14]=p,t[15]=o,t[16]=h):h=t[16];let g;t[17]!==s||t[18]!==p||t[19]!==o.state?(g={label:p,state:o.state,aborted:s},t[17]=s,t[18]=p,t[19]=o.state,t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=r??(0,z.jsx)(V5,{}),t[21]=r,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,z.jsx)(L5,{value:g,children:_}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let y;return t[26]!==h||t[27]!==v?(y=(0,z.jsx)(I5,{value:h,children:v}),t[26]=h,t[27]=v,t[28]=y):y=t[28],y}function B5(){let e=(0,G.c)(2),{part:t,activeClientInput:n}=R5();if(n)return null;let r;return e[0]===t?r=e[1]:(r=(0,z.jsx)(S5,{part:t}),e[0]=t,e[1]=r),r}function V5(e){let t=(0,G.c)(9),{children:n}=e,{part:r,label:i,defaultOpen:a}=R5();if(!i){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(B5,{})}),t[0]=e):e=t[0],e}let o;t[1]!==n||t[2]!==i||t[3]!==r?(o=(0,z.jsx)(La,{className:`cursor-pointer`,children:(0,z.jsx)(O5,{label:i,state:r.state,part:r,children:n})}),t[1]=n,t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Ra,{className:`mb-2`,children:(0,z.jsx)(B5,{})}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,z.jsxs)(Ia,{defaultOpen:a,className:`flex min-w-0 flex-1 flex-col`,children:[o,s]}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}var H5={Text:j5,File:M5,Source:N5,Reasoning:P5,DynamicTool:F5,Tool:z5,ToolDisclosure:V5,ToolContent:B5};function U5(e){return Dv(e)?`tool`:e.type===`dynamic-tool`?`dynamic-tool`:e.type===`reasoning`&&`text`in e&&e.text?`reasoning`:null}function W5(e,t){return e.kind===`text`||e.kind===`file`||e.kind===`source`?!1:e.kind===`reasoning`||e.kind!==`dynamic-tool`||!!t}function G5(e,t,n){let r=e[t+1];return!!r&&W5(r,n)}function K5(e){let t=[],n=new Set(e.flatMap(e=>e.type===`text`?D6(e.citations).map(({source:e})=>e.url):[]));for(let r=0;r<e.length;r++){let i=e[r],a=U5(i);if(a)t.push({kind:a,part:i,idx:r});else if(i.type===`text`){let e=t[t.length-1];e&&e.kind===`text`?e.parts.push({part:i,idx:r}):t.push({kind:`text`,parts:[{part:i,idx:r}]})}else if(i.type===`file`)t.push({kind:`file`,part:i,idx:r});else if(i.type===`source-url`&&!n.has(i.url)){let e=t[t.length-1];e&&e.kind===`source`?e.parts.push({part:i,idx:r}):t.push({kind:`source`,parts:[{part:i,idx:r}]})}}return t}function q5(e,t){return e.kind===`text`||e.kind===`source`?e.parts[0]?.idx??t:e.idx}(0,R.memo)(function(e){let t=(0,G.c)(8),{segment:n}=e;if(n.kind===`tool`){let e;return t[0]===n?e=t[1]:(e=(0,z.jsx)(H5.Tool,{segment:n}),t[0]=n,t[1]=e),e}if(n.kind===`reasoning`){let e;return t[2]===n?e=t[3]:(e=(0,z.jsx)(H5.Reasoning,{segment:n}),t[2]=n,t[3]=e),e}if(n.kind===`text`){let e;return t[4]===n?e=t[5]:(e=(0,z.jsx)(H5.Text,{segment:n,className:`text-xs`}),t[4]=n,t[5]=e),e}if(n.kind===`file`){let e;return t[6]===n?e=t[7]:(e=(0,z.jsx)(H5.File,{segment:n}),t[6]=n,t[7]=e),e}return null},J5);function J5(e,t){return e.complete&&t.complete&&e.cacheKey===t.cacheKey}function Y5(e){let t=(0,G.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:r,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={scale:.94},t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=I(`group text-muted-foreground hover:text-foreground relative rounded-lg p-2 transition-colors`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(`span`,{className:`bg-primary/10 absolute inset-0 rounded-lg opacity-0 transition-opacity group-hover:opacity-100`}),t[7]=s):s=t[7];let c;return t[8]!==r||t[9]!==i||t[10]!==o?(c=(0,z.jsxs)(wj.button,{type:`button`,whileTap:a,className:o,...i,children:[r,s]}),t[8]=r,t[9]=i,t[10]=o,t[11]=c):c=t[11],c}function X5(){let{index:e}=B6(),{messages:t}=R6(),n=z6();return!(e===t.length-1&&(n===`submitted`||n===`streaming`||n===`error`))}function Z5(e){let t=(0,G.c)(5),{className:n,children:r}=e;if(!X5()||R.Children.toArray(r).length===0)return null;let i;t[0]===n?i=t[1]:(i=I(`mt-1 flex items-center gap-0.5`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Q5(e){let t=(0,G.c)(15),{className:n}=e,{message:r}=B6(),[i,a]=F8(),o=H6(),s=i?`message.copied`:`message.copy`,c;t[0]!==o||t[1]!==s?(c=o(s),t[0]=o,t[1]=s,t[2]=c):c=t[2];let l;t[3]===n?l=t[4]:(l=I(`p-1.5`,n),t[3]=n,t[4]=l);let u;t[5]!==a||t[6]!==r?(u=()=>void a($8(r)),t[5]=a,t[6]=r,t[7]=u):u=t[7];let f;t[8]===i?f=t[9]:(f=(0,z.jsx)(i?d:ii,{className:`size-3.5`}),t[8]=i,t[9]=f);let p;return t[10]!==c||t[11]!==l||t[12]!==u||t[13]!==f?(p=(0,z.jsx)(Y5,{"aria-label":c,className:l,onClick:u,icon:f}),t[10]=c,t[11]=l,t[12]=u,t[13]=f,t[14]=p):p=t[14],p}function $5(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),{regenerate:i}=T6(),a=H6(),o;t[0]===a?o=t[1]:(o=a(`message.regenerate`),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=I(`p-1.5`,n),t[2]=n,t[3]=s);let c;t[4]!==r.id||t[5]!==i?(c=()=>void i({messageId:r.id}),t[4]=r.id,t[5]=i,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(wi,{className:`size-3.5`}),t[7]=l):l=t[7];let u;return t[8]!==o||t[9]!==s||t[10]!==c?(u=(0,z.jsx)(Y5,{"aria-label":o,className:s,onClick:c,icon:l}),t[8]=o,t[9]=s,t[10]=c,t[11]=u):u=t[11],u}function e7(e){let t=(0,G.c)(15),{className:n}=e,{message:r}=B6(),[i,a]=F8(),o=H6(),s=i?`message.copied`:`message.copyDebugJson`,c;t[0]!==o||t[1]!==s?(c=o(s),t[0]=o,t[1]=s,t[2]=c):c=t[2];let l;t[3]===n?l=t[4]:(l=I(`p-1.5`,n),t[3]=n,t[4]=l);let u;t[5]!==a||t[6]!==r?(u=()=>void a(JSON.stringify(r,null,2)),t[5]=a,t[6]=r,t[7]=u):u=t[7];let f;t[8]===i?f=t[9]:(f=(0,z.jsx)(i?d:Gt,{className:`size-3.5`}),t[8]=i,t[9]=f);let p;return t[10]!==c||t[11]!==l||t[12]!==u||t[13]!==f?(p=(0,z.jsx)(Y5,{"aria-label":c,className:l,onClick:u,icon:f}),t[10]=c,t[11]=l,t[12]=u,t[13]=f,t[14]=p):p=t[14],p}function t7(e){let t=(0,G.c)(7),{onTryAgain:n,error:r}=e,i=r instanceof Error?r.message:`An error occurred. Please try again.`,a;t[0]===i?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-destructive text-sm`,children:(0,z.jsx)(P8,{mode:`static`,children:i})}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,z.jsx)(Ce,{type:`button`,onClick:n,size:`sm`,variant:`outline`,children:`Try Again`}),t[2]=n,t[3]=o);let s;return t[4]!==a||t[5]!==o?(s=(0,z.jsx)(`div`,{className:`mt-3 flex justify-start`,children:(0,z.jsxs)(`div`,{className:`max-w-[80%] space-y-2`,children:[a,o]})}),t[4]=a,t[5]=o,t[6]=s):s=t[6],s}function n7(e){let t=(0,G.c)(3),{error:n,onRetry:r}=e;if(!n||!r)return null;let i;return t[0]!==n||t[1]!==r?(i=(0,z.jsx)(t7,{onTryAgain:r,error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function r7(e){let t=(0,G.c)(15),{messages:n,className:r,elements:i,citation:a,status:o,children:s}=e,c;t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==o?(c={messages:n,elements:i,citation:a,status:o},t[0]=a,t[1]=i,t[2]=n,t[3]=o,t[4]=c):c=t[4];let l=c,u;t[5]===r?u=t[6]:(u=I(`flex h-full flex-col`,r),t[5]=r,t[6]=u);let d;t[7]===s?d=t[8]:(d=(0,z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:s}),t[7]=s,t[8]=d);let f;t[9]!==u||t[10]!==d?(f=(0,z.jsx)(`div`,{className:u,children:d}),t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==f||t[13]!==l?(p=(0,z.jsx)(I6,{value:l,children:f}),t[12]=f,t[13]=l,t[14]=p):p=t[14],p}function i7(e){let t=(0,G.c)(5),{className:n,children:r}=e,i;t[0]===n?i=t[1]:(i=I(`flex flex-col gap-4`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function a7(e){let t=(0,G.c)(9),{message:n,index:r,className:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o={message:n,index:r},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]!==a||t[4]!==i?(c=(0,z.jsx)(`div`,{className:i,children:a}),t[3]=a,t[4]=i,t[5]=c):c=t[5];let l;return t[6]!==c||t[7]!==s?(l=(0,z.jsx)(L6,{value:s,children:c}),t[6]=c,t[7]=s,t[8]=l):l=t[8],l}function o7(){let e=(0,G.c)(5),{registry:t}=S6(),n=T6().messages,r;if(e[0]!==n||e[1]!==t){bb0:{if(!t){r=null;break bb0}let i=n.findLast(s7);if(!i){r=null;break bb0}let a;e[3]===t?a=e[4]:(a=e=>{if(!Dv(e)||e.state!==`input-available`)return[];let n=t[Av(e)];return!n||n.static!==!1||!n.requiresUserInput?[]:[{part:e,entry:n}]},e[3]=t,e[4]=a),r=i.parts.flatMap(a).at(0)??null}e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function s7(e){let{role:t}=e;return t===`assistant`}function c7(e){let t=(0,G.c)(10),{children:n,className:r}=e,i=o7(),a=i?.entry.component,o=i?`hidden`:`visible`,s;t[0]!==n||t[1]!==o?(s=(0,z.jsx)(R.Activity,{mode:o,children:n}),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==a||t[4]!==i||t[5]!==r?(c=i&&a?(0,z.jsx)(`div`,{className:I(`sticky bottom-0 mt-auto`,r),children:(0,z.jsx)(a,{part:i.part},i.part.toolCallId)}):null,t[3]=a,t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;return t[7]!==s||t[8]!==c?(l=(0,z.jsxs)(z.Fragment,{children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function l7(e,t){if(e===`error`||e===`ready`||!t)return null;if(t.role!==`assistant`)return`Thinking...`;for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(Tv(n)&&A5(n)&&n.text)return n.text}for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(Ev(n)&&n.text)return n.text;if(kv(n)){let e=n.input;if($h(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return n.toolCallId}if(Tv(n)&&n.text)return``}return`Thinking...`}function u7(e){let t=(0,G.c)(5),{isLast:n}=e,r=n!==void 0&&n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`span`,{className:`bg-muted-foreground/50 z-10 mt-1 size-2 shrink-0 rounded-full`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[1]=r,t[2]=a);let o;return t[3]===a?o=t[4]:(o=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex size-3.5 h-full flex-col items-center`,children:[i,a]}),t[3]=a,t[4]=o),o}function d7(e){let t=(0,G.c)(6),{marker:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=I(`relative z-0 flex gap-3 pl-5`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==n||t[4]!==a?(o=(0,z.jsxs)(`div`,{className:a,children:[n,r]}),t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function f7(){let e=(0,G.c)(6),t=z6(),{messages:n}=R6(),r=o7(),i=n[n.length-1],a;e[0]!==t||e[1]!==i?(a=l7(t,i),e[0]=t,e[1]=i,e[2]=a):a=e[2];let o=a;if(!o||r)return null;let s;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(u7,{isLast:!0}),e[3]=s):s=e[3];let c;return e[4]===o?c=e[5]:(c=(0,z.jsx)(d7,{className:`mt-2`,marker:s,children:(0,z.jsx)(`span`,{role:`status`,children:(0,z.jsx)(N6,{as:`span`,className:`text-muted-foreground line-clamp-2 font-mono text-xs`,children:o})})}),e[4]=o,e[5]=c),c}var p7=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`totalTokens`],m7={inputTokens:[[`inputTokens`],[`raw`,`prompt_tokens`]],outputTokens:[[`outputTokens`],[`raw`,`completion_tokens`]],reasoningTokens:[[`reasoningTokens`],[`outputTokenDetails`,`reasoningTokens`],[`raw`,`completion_tokens_details`,`reasoning_tokens`]],cachedInputTokens:[[`inputTokenDetails`,`cacheReadTokens`],[`cachedInputTokens`],[`inputTokenDetails`,`cachedTokens`],[`raw`,`prompt_tokens_details`,`cached_tokens`]],totalTokens:[[`totalTokens`],[`raw`,`total_tokens`]]};function h7(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}return null}function g7(e){if(!e||typeof e!=`object`)return null;let t={inputTokens:null,outputTokens:null,reasoningTokens:null,cachedInputTokens:null,totalTokens:null};for(let n of p7)for(let r of m7[n]){let i=h7(Y3(e,r));if(i!==null){t[n]=i;break}}return p7.some(e=>t[e]!==null)?t:null}function _7(e){return $h(e)?g7(e.totalUsage??e.usage):null}function v7(e){let t=[`↑ ${$3(e.inputTokens)}`,`↓ ${$3(e.outputTokens)}`];return e.totalTokens!==null&&t.push(`· ${Q3(e.totalTokens)} tokens`),e.cachedInputTokens!==null&&e.cachedInputTokens>0&&t.push(`(${$3(e.cachedInputTokens)} cached)`),t.join(` `)}var y7=`x-upload-filename`,b7=Me({path:L().startsWith(`/`),name:L().min(1),mediaType:Nn([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/heic`,`image/heif`,`video/mp4`,`video/quicktime`,`audio/mpeg`,`audio/mp4`,`audio/wav`]),size:Nt().nonnegative(),url:Te()}),x7=class extends Ay{sessionsApi;request;constructor({api:e,fetch:t=(e,t)=>globalThis.fetch(e,t),tools:n={},elements:r=[]}){let i=T7(e),a=r.map(Bj);super({api:i,fetch:async(e,n)=>{let r=await t(e,n);if((n?.method??`GET`).toUpperCase()!==`POST`||!r.ok)return r;let i=await r.json();if(!E7(i))throw Error(`Zukhruf returned an invalid accepted-turn response`);let a=T7(String(e)),o=decodeURIComponent(a.slice(a.lastIndexOf(`/`)+1));if(i.sessionId!==o)throw Error(`Zukhruf returned a different session ID`);let s=n?.signal;return s?.addEventListener(`abort`,()=>{t(`${a}/cancel`,{method:`POST`})},{once:!0}),t(`${a}/stream`,{headers:{accept:`text/event-stream`},method:`GET`,signal:s})},prepareSendMessagesRequest:({id:e,messages:t,trigger:r})=>{let o=t[t.length-1];if(!o)throw Error(`A message is required`);return{api:S7(i,e),body:{sessionId:e,message:o,trigger:r,...Object.keys(n).length>0?{tools:n}:{},...a.length>0?{elements:a}:{}}}},prepareReconnectToStreamRequest:({headers:e,id:t})=>({api:`${S7(i,t)}/stream`,headers:e})}),this.sessionsApi=i,this.request=t}async uploadFile(e,t){let n=await this.request(`${S7(this.sessionsApi,e)}/uploads`,{method:`POST`,headers:{"content-type":t.type,[y7]:encodeURIComponent(t.name)},body:t});if(!n.ok)throw Error(await C7(n,t));let r=b7.safeParse(await n.json());if(!r.success)throw Error(`Zukhruf returned an invalid upload response`);return r.data}};function S7(e,t){return`${e}/${encodeURIComponent(t)}`}async function C7(e,t){let n=`Uploading ${t.name} failed with HTTP ${e.status}`,r=w7(await e.json().catch(e=>{if(e instanceof SyntaxError)return null;throw e}));return r?`${n}: ${r}`:n}function w7(e){if(typeof e!=`object`||!e)return null;let t=`cause`in e&&typeof e.cause==`object`&&e.cause!==null?e.cause:null;return[t&&`code`in t&&typeof t.code==`string`?t.code:null,t&&`detail`in t&&typeof t.detail==`string`?t.detail:`error`in e&&typeof e.error==`string`?e.error:null].filter(e=>e!==null).join(` — `)||null}function T7(e){return e.replace(/\/$/,``)}function E7(e){return typeof e==`object`&&!!e&&`ok`in e&&e.ok===!0&&`sessionId`in e&&typeof e.sessionId==`string`&&`turnId`in e&&typeof e.turnId==`string`}function D7(e){let t=(0,G.c)(24),{label:n,open:r,onOpenChange:i,children:a,className:o,triggerClassName:s,contentClassName:c,chevronClassName:l}=e,u;t[0]===s?u=t[1]:(u=I(`flex items-center font-mono`,s),t[0]=s,t[1]=u);let d;t[2]===u?d=t[3]:(d=(0,z.jsx)(`button`,{type:`button`,className:u}),t[2]=u,t[3]=d);let f=r&&`rotate-180`,p;t[4]!==l||t[5]!==f?(p=I(`size-4 transition-transform`,l,f),t[4]=l,t[5]=f,t[6]=p):p=t[6];let m;t[7]===p?m=t[8]:(m=(0,z.jsx)(He,{className:p}),t[7]=p,t[8]=m);let h;t[9]===n?h=t[10]:(h=(0,z.jsx)(`span`,{children:n}),t[9]=n,t[10]=h);let g;t[11]!==d||t[12]!==m||t[13]!==h?(g=(0,z.jsxs)(La,{render:d,children:[m,h]}),t[11]=d,t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==c?(_=(0,z.jsx)(Ra,{className:c,children:a}),t[15]=a,t[16]=c,t[17]=_):_=t[17];let v;return t[18]!==o||t[19]!==i||t[20]!==r||t[21]!==g||t[22]!==_?(v=(0,z.jsxs)(Ia,{open:r,onOpenChange:i,className:o,children:[g,_]}),t[18]=o,t[19]=i,t[20]=r,t[21]=g,t[22]=_,t[23]=v):v=t[23],v}function O7(e){let t=(0,G.c)(7),{metadata:n}=e;if(!n)return null;let r,i,a;if(t[0]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let e=_7(n);if(!e){a=null;break bb0}r=`text-muted-foreground mt-2 text-xs tabular-nums opacity-60`,i=v7(e)}t[0]=n,t[1]=r,t[2]=i,t[3]=a}else r=t[1],i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o;return t[4]!==r||t[5]!==i?(o=(0,z.jsx)(`div`,{className:r,children:i}),t[4]=r,t[5]=i,t[6]=o):o=t[6],o}function k7(e,t){return $h(e.metadata)?e.metadata[t]:void 0}function A7(e){let t=k7(e,`reminders`);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.text==`string`&&t.text.trim().length>0}):[]}function j7(e){let t=k7(e,`uploads`);return Array.isArray(t)?t.flatMap(e=>{let t=b7.safeParse(e);return t.success?[t.data]:[]}):[]}function M7(e){let t=(0,G.c)(7),{text:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(N7),t[0]=a):a=t[0];let o=!r&&`line-clamp-3`,s;t[1]===o?s=t[2]:(s=I(`hover:text-foreground w-full cursor-pointer text-left whitespace-pre-wrap`,o),t[1]=o,t[2]=s);let c;return t[3]!==r||t[4]!==s||t[5]!==n?(c=(0,z.jsx)(`li`,{children:(0,z.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":r,className:s,children:n})}),t[3]=r,t[4]=s,t[5]=n,t[6]=c):c=t[6],c}function N7(e){return!e}function P7(e){let t=(0,G.c)(8),{reminders:n}=e,[r,i]=(0,R.useState)(!1);if(n.length===0)return null;let a=`${n.length} reminder${n.length===1?``:`s`} attached`,o;t[0]===n?o=t[1]:(o=n.map(F7),t[0]=n,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,z.jsx)(`ul`,{className:`border-ink-12 text-muted-foreground space-y-1 border-l pl-3 text-xs`,children:o}),t[2]=o,t[3]=s);let c;return t[4]!==a||t[5]!==r||t[6]!==s?(c=(0,z.jsx)(D7,{label:a,open:r,onOpenChange:i,className:`mt-1`,triggerClassName:`text-muted-foreground hover:text-foreground gap-1.5 text-xs`,contentClassName:`mt-1.5`,chevronClassName:`size-3.5`,children:s}),t[4]=a,t[5]=r,t[6]=s,t[7]=c):c=t[7],c}function F7(e){return(0,z.jsx)(M7,{text:e.text},e.id)}function I7(e){let t=(0,G.c)(19),{upload:n}=e;if(n.mediaType.startsWith(`video/`)){let e;t[0]!==n.name||t[1]!==n.url?(e=(0,z.jsx)(`video`,{src:n.url,"aria-label":n.name,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`}),t[0]=n.name,t[1]=n.url,t[2]=e):e=t[2];let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-2xl text-white drop-shadow`,children:`▶`}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==n.name?(i=(0,z.jsxs)(Xi,{variant:`image`,className:`size-36 rounded-2xl`,title:n.name,children:[e,r]}),t[4]=e,t[5]=n.name,t[6]=i):i=t[6],i}if(n.mediaType.startsWith(`audio/`)){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-2xl`,children:`♪`}),t[7]=e):e=t[7];let r;t[8]===n.name?r=t[9]:(r=(0,z.jsx)(`span`,{className:`text-foreground w-full truncate text-center`,children:n.name}),t[8]=n.name,t[9]=r);let i;t[10]===n.mediaType?i=t[11]:(i=(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:n.mediaType}),t[10]=n.mediaType,t[11]=i);let a;return t[12]!==r||t[13]!==i||t[14]!==n.name?(a=(0,z.jsxs)(Xi,{variant:`icon`,className:`h-36 w-48 flex-col gap-1 rounded-2xl px-3 text-xs`,title:n.name,"aria-label":n.name,children:[e,r,i]}),t[12]=r,t[13]=i,t[14]=n.name,t[15]=a):a=t[15],a}let r;return t[16]!==n.name||t[17]!==n.url?(r=(0,z.jsx)(Xi,{variant:`image`,className:`size-36 rounded-2xl`,children:(0,z.jsx)(`img`,{src:n.url,alt:n.name})}),t[16]=n.name,t[17]=n.url,t[18]=r):r=t[18],r}function L7(e){let t=(0,G.c)(13),{message:n}=e,r,i,a,o,s,c;if(t[0]!==n){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=j7(n);if(e.length===0){c=null;break bb0}r=Zi,i=`list`,a=`Attached files`,o=`max-w-full gap-2 py-0`,s=e.map(R7)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;return t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==s?(l=(0,z.jsx)(r,{role:i,"aria-label":a,className:o,children:s}),t[7]=r,t[8]=i,t[9]=a,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function R7(e){return(0,z.jsx)(`div`,{role:`listitem`,"data-slot":`attachment`,children:(0,z.jsx)(I7,{upload:e})},e.path)}function z7(e){let t=(0,G.c)(10),{body:n,reminders:r,metadata:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`div`,{className:`flex-1 space-y-3`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,z.jsx)(P7,{reminders:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i!==void 0&&(0,z.jsx)(O7,{metadata:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,z.jsxs)(`div`,{className:`bg-secondary flex max-w-[80%] flex-col gap-3 rounded-lg p-3`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function B7(e){let t=(0,G.c)(28),{message:n}=e;k7(n,`reminders`);let r;t[0]===n?r=t[1]:(r=See(n),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=A7(n),t[2]=n,t[3]=i);let a;t[4]!==r||t[5]!==i?(a={message:r,reminders:i},t[4]=r,t[5]=i,t[6]=a):a=t[6];let{message:o,reminders:s}=a,c;if(t[7]!==n){let e=k7(n,`alias`);c=typeof e==`string`&&e.trim().length>0?e:void 0,t[7]=n,t[8]=c}else c=t[8];let l=c;if(l){let e;t[9]===l?e=t[10]:(e=(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:l}),t[9]=l,t[10]=e);let n;return t[11]!==s||t[12]!==e?(n=(0,z.jsx)(z7,{reminders:s,body:e}),t[11]=s,t[12]=e,t[13]=n):n=t[13],n}let u;t[14]===o?u=t[15]:(u=(0,z.jsx)(L7,{message:o}),t[14]=o,t[15]=u);let d=o.metadata,f;if(t[16]!==o.id||t[17]!==o.parts){let e;t[19]===o.id?e=t[20]:(e=(e,t)=>e.type===`text`?(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:(0,z.jsx)(u4,{text:e.text})},`${o.id}-${t}-text`):null,t[19]=o.id,t[20]=e),f=o.parts.map(e),t[16]=o.id,t[17]=o.parts,t[18]=f}else f=t[18];let p;t[21]!==o.metadata||t[22]!==s||t[23]!==f?(p=(0,z.jsx)(z7,{reminders:s,metadata:d,body:f}),t[21]=o.metadata,t[22]=s,t[23]=f,t[24]=p):p=t[24];let m;return t[25]!==u||t[26]!==p?(m=(0,z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-3`,children:[u,p]}),t[25]=u,t[26]=p,t[27]=m):m=t[27],m}var V7=(0,R.memo)(function(e){let t=(0,G.c)(7),{className:n}=e,{message:r}=B6(),i;t[0]===n?i=t[1]:(i=I(`flex justify-end`,n),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,z.jsx)(B7,{message:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o});function H7(e){return e.kind===`tool`?!t5(e.part):e.kind===`dynamic-tool`||e.kind===`reasoning`}function U7(e,t){return e.kind===`tool`?!0:e.kind===`reasoning`||e.kind===`dynamic-tool`?!!t:!1}function W7(e){return e.kind===`text`&&e.parts.some(({part:e})=>e.type===`text`&&!A5(e))}function G7(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!H7(i)){n.push({kind:`segment`,segment:i,segmentIndex:r});continue}let a=[],o=r;for(;r<e.length&&H7(e[r]);){let n=e[r];U7(n,t)&&a.push({segment:n}),r++}r--,a.length>0&&n.push({kind:`group`,items:a,hasLaterText:e.slice(r+1).some(e=>W7(e)),firstIndex:o})}return n}function K7(e){if(e.kind!==`tool`&&e.kind!==`dynamic-tool`)return;let{part:t}=e;return kv(t)?t.state:void 0}function q7({groupStatus:e,labelCount:t}){return e===`running`?{title:`text-info`,detail:`text-info/80`,chevron:`text-info`}:e===`aborted`?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:e===`error`?t===1?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:{title:`text-warning`,detail:`text-warning/80`,chevron:`text-warning`}:{title:`text-muted-foreground`,detail:`text-muted-foreground`,chevron:`text-muted-foreground`}}function J7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y7(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-3).trimEnd()}...`}function X7(e){if(typeof e==`string`)return Y7(e,48);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`${e.length} items`}function Z7(e){if(!J7(e))return;let t=[`command`,`query`,`path`,`file`,`table`,`metric`,`dimension`,`checks`],n=[...t.filter(t=>t in e).map(t=>[t,e[t]]),...Object.entries(e).filter(([e])=>!t.includes(e))],r={};for(let[e,t]of n){let n=X7(t);if(n&&(r[e]=n,Object.keys(r).length>=2))break}return Object.keys(r).length>0?r:void 0}function Q7(e){if(J7(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim().length>0)return Y7(n)}}function $7(e){if(e.kind!==`reasoning`)return;let{part:t}=e;if(t.type===`reasoning`)return Y7(t.text,96)}function e9(e,t,n){if(e.kind===`reasoning`)return{form:`call`,kind:`reasoning`,name:`reasoning`,detail:$7(e)};if(e.kind===`dynamic-tool`&&e.part.type===`dynamic-tool`){let t=e.part;return{form:`call`,kind:`dynamic-tool`,name:t.toolName||n(`steps.unnamedTool`),args:Z7(t.input),detail:Q7(t.input)}}if(e.kind===`tool`&&Dv(e.part)){let n=e.part,{toolEntry:r,toolKey:i}=n5(n,t),a=r?.label?.(n);return a?.kind===`sentence`?{form:`sentence`,kind:`tool`,text:a.text,detail:a.detail,isError:a.isError}:{form:`call`,kind:`tool`,name:a?.name??i,args:a?.args??Z7(n.input),detail:a?.detail??Q7(n.input),isError:a?.isError}}return{form:`call`,kind:`tool`,name:n(`steps.unknownStep`)}}function t9(e){if(!e)return;let t=Object.entries(e).filter(e=>typeof e[1]==`string`&&e[1].trim().length>0);if(t.length!==0)return t.slice(0,2).map(([e,t])=>`${e}: ${Y7(t,36)}`).join(`, `)}function n9(e){let t=t9(e.args);return t?`${e.name}(${t})`:e.name}function r9(e){return e===`output-available`||e===`output-error`||e===`output-denied`}function i9(e){return!!e&&!r9(e)}function a9(e,t){return A6(e,t)}function o9({items:e,labels:t,status:n,hasLaterText:r}){return e.some(({segment:e})=>a9(K7(e),n))?`aborted`:!r&&(n===`streaming`||n===`submitted`)?`running`:t.some(e=>e.isError)||e.some(({segment:e})=>{let t=K7(e);return t===`output-error`||t===`output-denied`})?`error`:e.some(({segment:e})=>i9(K7(e)))||!r&&t.every(e=>e.kind===`reasoning`)&&(n===`streaming`||n===`submitted`)?`running`:`complete`}function s9(e){return e.filter(e=>e.kind!==`reasoning`).length}function c9(e){let t=e.findLast(e=>e.kind!==`reasoning`);return t?.form===`sentence`?t:void 0}function l9(e,t,n,r){let i=e.length===1?e[0]:void 0;return t===`running`?r||(i?.kind===`reasoning`?n(`steps.reasoning`,{detail:i.detail}):e.every(e=>e.kind===`reasoning`)?n(`steps.reasoning`,{detail:void 0}):n(`steps.working`)):i?.form===`call`?i.kind===`reasoning`&&t===`complete`?n(`steps.reasoned`,{detail:i.detail}):n(`steps.call`,{call:n9(i),status:t}):e.every(e=>e.kind===`reasoning`)?n(`steps.reasoned`,{detail:void 0}):n(`steps.tools`,{count:s9(e),status:t})}function u9(e,t){if(t!==`running`){if(e.length===1){let t=e[0];return t.kind===`reasoning`?void 0:t.detail}return Array.from(new Set([...e].sort((e,t)=>e.kind===`reasoning`&&t.kind!==`reasoning`?1:e.kind!==`reasoning`&&t.kind===`reasoning`?-1:0).map(e=>e.form===`sentence`?e.text:e.name))).slice(0,3).join(`, `)||void 0}}function d9(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].segment;if(r.kind===`dynamic-tool`&&r.part.type===`dynamic-tool`){let e=Q7(r.part.input);if(e)return e}if(r.kind===`tool`&&Dv(r.part)){let e=Q7(r.part.input);if(e)return e}r.kind===`reasoning`&&(t??=$7(r))}return t}function f9(e,t){return!e||e.role!==`assistant`?!1:G7(K5(e.parts),t).some(e=>e.kind===`group`&&!e.hasLaterText)}function p9(){let e=(0,G.c)(8),{message:t}=B6(),{debugMode:n}=S6(),r;e[0]===t.parts?r=e[1]:(r=K5(t.parts),e[0]=t.parts,e[1]=r);let i=r,a;if(e[2]!==n||e[3]!==t.id||e[4]!==i){let r;e[6]===t.id?r=e[7]:(r=e=>e.kind===`group`?{...e,key:`${t.id}-${e.firstIndex}-group-${e.hasLaterText?`past`:`current`}`}:{...e,key:`${t.id}-${q5(e.segment,e.segmentIndex)}-${e.segment.kind}`},e[6]=t.id,e[7]=r),a=G7(i,n).map(r),e[2]=n,e[3]=t.id,e[4]=i,e[5]=a}else a=e[5];return a}var m9=(0,R.createContext)(null);function h9(){let e=(0,R.use)(m9);if(!e)throw Error(`CompactTrajectory group parts must be rendered within CompactTrajectory.Group`);return e}function g9(e){let t=(0,G.c)(23),{group:n,children:r}=e,{registry:i}=S6(),{message:a}=B6(),o=z6(),s=H6(),[c,l]=(0,R.useState)(!n.hasLaterText),u,d,f;if(t[0]!==n.hasLaterText||t[1]!==n.items||t[2]!==i||t[3]!==o||t[4]!==s){let e;t[8]!==i||t[9]!==s?(e=e=>{let{segment:t}=e;return e9(t,i,s)},t[8]=i,t[9]=s,t[10]=e):e=t[10],d=n.items.map(e),u=o9({items:n.items,labels:d,status:o,hasLaterText:n.hasLaterText}),f=q7({groupStatus:u,labelCount:d.length}),t[0]=n.hasLaterText,t[1]=n.items,t[2]=i,t[3]=o,t[4]=s,t[5]=u,t[6]=d,t[7]=f}else u=t[5],d=t[6],f=t[7];let p=f,m;t[11]!==n.items||t[12]!==u||t[13]!==d||t[14]!==a.id||t[15]!==p?(m={items:n.items,labels:d,groupStatus:u,tone:p,messageId:a.id},t[11]=n.items,t[12]=u,t[13]=d,t[14]=a.id,t[15]=p,t[16]=m):m=t[16];let h;t[17]!==r||t[18]!==c?(h=(0,z.jsx)(Ia,{open:c,onOpenChange:l,className:`my-2 min-w-0`,children:r}),t[17]=r,t[18]=c,t[19]=h):h=t[19];let g;return t[20]!==m||t[21]!==h?(g=(0,z.jsx)(m9,{value:m,children:h}),t[20]=m,t[21]=h,t[22]=g):g=t[22],g}function _9(e){let t=(0,G.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`button`,{type:`button`,className:F6(`items-start`)}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,z.jsx)(La,{render:r,children:(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-start text-sm`,children:n})}),t[1]=n,t[2]=i),i}function v9(){let e=(0,G.c)(21),{items:t,labels:n,groupStatus:r,tone:i}=h9(),a=H6(),o;e[0]===n?o=e[1]:(o=c9(n),e[0]=n,e[1]=o);let s=o;if(s){let t=s9(n)-1,a=t>0?t:void 0,o;return e[2]!==r||e[3]!==s.detail||e[4]!==s.text||e[5]!==a||e[6]!==i?(o={title:s.text,more:a,detail:s.detail,isSentence:!0,tone:i,groupStatus:r},e[2]=r,e[3]=s.detail,e[4]=s.text,e[5]=a,e[6]=i,e[7]=o):o=e[7],o}let c;e[8]!==r||e[9]!==t||e[10]!==n||e[11]!==a?(c=l9(n,r,a,d9(t)),e[8]=r,e[9]=t,e[10]=n,e[11]=a,e[12]=c):c=e[12];let l=c,u;e[13]!==r||e[14]!==n?(u=u9(n,r),e[13]=r,e[14]=n,e[15]=u):u=e[15];let d=u,f;return e[16]!==d||e[17]!==r||e[18]!==l||e[19]!==i?(f={title:l,more:void 0,detail:d,isSentence:!1,tone:i,groupStatus:r},e[16]=d,e[17]=r,e[18]=l,e[19]=i,e[20]=f):f=e[20],f}function y9(e){let t=(0,G.c)(14),{title:n,suffix:r,children:i}=e,a=v9(),{tone:o,groupStatus:s}=a,c=n===void 0,l=n??a.title,u=r?`${l} · ${r}`:l,d=c?a.more:void 0,f=s===`running`?`text-info`:o.title,p=c&&a.isSentence?`auto`:void 0,m=s===`running`,h;t[0]===f?h=t[1]:(h=I(`max-w-full min-w-0 truncate`,f),t[0]=f,t[1]=h);let g;t[2]!==p||t[3]!==m||t[4]!==h||t[5]!==u?(g=(0,z.jsx)(N6,{as:`span`,dir:p,enabled:m,className:h,children:u}),t[2]=p,t[3]=m,t[4]=h,t[5]=u,t[6]=g):g=t[6];let _;t[7]!==d||t[8]!==f?(_=d!==void 0&&(0,z.jsxs)(`span`,{dir:`ltr`,className:I(`shrink-0 tabular-nums`,f),children:[`+`,d]}),t[7]=d,t[8]=f,t[9]=_):_=t[9];let v;return t[10]!==i||t[11]!==g||t[12]!==_?(v=(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[g,_,i]}),t[10]=i,t[11]=g,t[12]=_,t[13]=v):v=t[13],v}function b9(){let e=(0,G.c)(2),{tone:t}=h9(),n;return e[0]===t.chevron?n=e[1]:(n=(0,z.jsx)(P6,{className:t.chevron}),e[0]=t.chevron,e[1]=n),n}function x9(e){let t=(0,G.c)(6),{detail:n}=e,{title:r,detail:i,isSentence:a,tone:o}=v9();if(n===null)return null;let s=n??i;if(!s||s===r)return null;let c=n===void 0&&a?`auto`:void 0,l;t[0]===o.detail?l=t[1]:(l=I(`block truncate text-start text-xs`,o.detail),t[0]=o.detail,t[1]=l);let u;return t[2]!==s||t[3]!==c||t[4]!==l?(u=(0,z.jsx)(`span`,{dir:c,className:l,children:s}),t[2]=s,t[3]=c,t[4]=l,t[5]=u):u=t[5],u}function S9(e){let t=(0,G.c)(14),{children:n}=e,{items:r,messageId:i,groupStatus:a}=h9(),o=a===`running`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={initial:`instant`,resize:`instant`},t[0]=s):s=t[0];let{scrollRef:c,contentRef:l}=Aj(s),u=o?c:void 0,d=o&&`max-h-64 overflow-y-auto`,f;t[1]===d?f=t[2]:(f=I(`mt-2`,d),t[1]=d,t[2]=f);let p=o?l:void 0,m;t[3]!==n||t[4]!==r||t[5]!==i?(m=n??r.map((e,t)=>{let{segment:n}=e,r=`${i}-${q5(n,t)}-${n.kind}`;return n.kind===`tool`?(0,z.jsx)(H5.Tool,{segment:n},r):n.kind===`reasoning`?(0,z.jsx)(H5.Reasoning,{segment:n},r):n.kind===`dynamic-tool`?(0,z.jsx)(H5.DynamicTool,{segment:n},r):null}),t[3]=n,t[4]=r,t[5]=i,t[6]=m):m=t[6];let h;t[7]!==p||t[8]!==m?(h=(0,z.jsx)(`div`,{ref:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;return t[10]!==u||t[11]!==f||t[12]!==h?(g=(0,z.jsx)(Ra,{ref:u,className:f,children:h}),t[10]=u,t[11]=f,t[12]=h,t[13]=g):g=t[13],g}function Iee(e){let t=(0,G.c)(19),{item:n,textClassName:r}=e,i=r===void 0?`my-4`:r,{elements:a}=R6(),{segment:o}=n;if(o.kind===`text`){let e;t[0]===o.parts?e=t[1]:(e=o.parts.filter(Lee),t[0]=o.parts,t[1]=e);let n=e;if(n.length===0)return null;let r;t[2]!==o||t[3]!==n?(r={...o,parts:n},t[2]=o,t[3]=n,t[4]=r):r=t[4];let s;return t[5]!==a||t[6]!==r||t[7]!==i?(s=(0,z.jsx)(H5.Text,{segment:r,elements:a,className:i}),t[5]=a,t[6]=r,t[7]=i,t[8]=s):s=t[8],s}if(o.kind===`file`){let e;return t[9]===o?e=t[10]:(e=(0,z.jsx)(H5.File,{segment:o}),t[9]=o,t[10]=e),e}if(o.kind===`source`){let e;return t[11]===o?e=t[12]:(e=(0,z.jsx)(H5.Source,{segment:o}),t[11]=o,t[12]=e),e}if(o.kind===`tool`){let e;return t[13]===o?e=t[14]:(e=(0,z.jsx)(H5.Tool,{segment:o}),t[13]=o,t[14]=e),e}if(o.kind===`reasoning`){let e;return t[15]===o?e=t[16]:(e=(0,z.jsx)(H5.Reasoning,{segment:o}),t[15]=o,t[16]=e),e}if(o.kind===`dynamic-tool`){let e;return t[17]===o?e=t[18]:(e=(0,z.jsx)(H5.DynamicTool,{segment:o}),t[17]=o,t[18]=e),e}return null}function Lee(e){let{part:t}=e;return!A5(t)}function Ree(){let e=(0,G.c)(1),t=z6(),{messages:n}=R6(),{debugMode:r}=S6(),i=n[n.length-1];if(t!==`ready`&&t!==`error`&&f9(i,r))return null;let a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(f7,{}),e[0]=a):a=e[0],a}var C9={Root:r7,List:i7,Item:a7,UserBubble:V7,AssistantContent:(0,R.memo)(function(e){let t=(0,G.c)(5),{className:n}=e,r=p9(),i;t[0]===r?i=t[1]:(i=r.map(zee),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}),Actions:Z5,CopyAction:Q5,RegenerateAction:$5,CopyDebugJsonAction:e7,Thinking:Ree,Error:n7};function zee(e){return e.kind===`group`?(0,z.jsxs)(g9,{group:e,children:[(0,z.jsxs)(_9,{children:[(0,z.jsx)(y9,{children:(0,z.jsx)(b9,{})}),(0,z.jsx)(x9,{})]}),(0,z.jsx)(S9,{})]},e.key):(0,z.jsx)(Iee,{item:e},e.key)}function Bee(e){let t=(0,G.c)(8),{message:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`text-destructive/90 bg-destructive/10 flex items-start gap-2 rounded-md px-3 py-2 text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(_t,{className:`text-destructive mt-0.5 size-4 shrink-0`}),t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=(0,z.jsx)(`span`,{children:n}),t[3]=n,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s=(0,z.jsxs)(`div`,{className:i,children:[a,o]}),t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function Vee(e){let t=(0,G.c)(9),{name:n,args:r}=e,i;t[0]===r?i=t[1]:(i=r?Object.values(r)[0]:void 0,t[0]=r,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=(0,z.jsx)(`span`,{className:`ms-2 font-mono`,children:n}),t[2]=n,t[3]=o);let s;t[4]===a?s=t[5]:(s=a&&(0,z.jsxs)(`span`,{className:`truncate`,children:[`(`,a,`)`]}),t[4]=a,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,z.jsxs)(z.Fragment,{children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Hee(e){let t=(0,G.c)(15),{part:n}=e,r=S6(),i,a;if(t[0]!==r.registry||t[1]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let{toolEntry:e}=n5(n,r.registry);if(e&&r5(e,n.state)){let t=e.label?.(n);if(!t){a=null;break bb0}let r=t.icon;a=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center text-xs`,children:[r&&(0,z.jsx)(r,{className:`size-3.5`}),t.kind===`sentence`?(0,z.jsx)(`span`,{dir:`auto`,className:`ms-2 truncate text-start`,children:t.text}):(0,z.jsx)(Vee,{name:t.name,args:t.args})]});break bb0}i=e?.label?.(n)}t[0]=r.registry,t[1]=n,t[2]=i,t[3]=a}else i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o=i,s;t[4]!==o||t[5]!==n?(s=o&&(0,z.jsx)(E5,{label:o,part:n}),t[4]=o,t[5]=n,t[6]=s):s=t[6];let c;t[7]===o?c=t[8]:(c=o?.isError&&o.detail&&(0,z.jsx)(Bee,{message:o.detail}),t[7]=o,t[8]=c);let l;t[9]===n?l=t[10]:(l=(0,z.jsx)(S5,{part:n}),t[9]=n,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,z.jsxs)(z.Fragment,{children:[s,c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function Uee(e){let t=(0,G.c)(5),{part:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===n.text?a=t[1]:(a=(0,z.jsx)(P8,{mode:`static`,children:n.text}),t[0]=n.text,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:`bg-muted/30 prose max-w-auto prose-sm text-muted-foreground border-border mb-4 w-full min-w-full rounded-lg p-3`,children:(0,z.jsx)(D7,{label:`Reasoning`,open:r,onOpenChange:i,className:`text-xs`,triggerClassName:`w-full gap-x-2 text-sm hover:opacity-80`,contentClassName:`mt-2`,children:a})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function Wee(e){let t=(0,G.c)(16),{part:n}=e,{elements:r}=R6(),i=C5();if(n.type===`text`){if(A5(n))return null;let e;return t[0]!==r||t[1]!==n.citations||t[2]!==n.text?(e=(0,z.jsx)(x5,{text:n.text,citations:n.citations,elements:r}),t[0]=r,t[1]=n.citations,t[2]=n.text,t[3]=e):e=t[3],e}if(n.type===`dynamic-tool`){let e;return t[4]!==i||t[5]!==n?(e=i?(0,z.jsx)(J8,{part:n}):null,t[4]=i,t[5]=n,t[6]=e):e=t[6],e}if(Dv(n)){let e;return t[7]===n?e=t[8]:(e=(0,z.jsx)(Hee,{part:n}),t[7]=n,t[8]=e),e}if(n.type===`reasoning`&&n.text){let e;return t[9]!==i||t[10]!==n?(e=i?(0,z.jsx)(Uee,{part:n}):null,t[9]=i,t[10]=n,t[11]=e):e=t[11],e}if(n.type===`file`){let e;return t[12]!==n.filename||t[13]!==n.mediaType||t[14]!==n.url?(e=(0,z.jsx)(h5,{filename:n.filename,mediaType:n.mediaType,url:n.url}),t[12]=n.filename,t[13]=n.mediaType,t[14]=n.url,t[15]=e):e=t[15],e}return null}(0,R.memo)(function(e){let t=(0,G.c)(10),{className:n}=e,{message:r}=B6(),i;t[0]===n?i=t[1]:(i=I(`flex-1 space-y-3`,n),t[0]=n,t[1]=i);let a;if(t[2]!==r.id||t[3]!==r.parts){let e;t[5]===r.id?e=t[6]:(e=(e,t)=>(0,z.jsx)(Wee,{part:e},`${r.id}-${t}`),t[5]=r.id,t[6]=e),a=r.parts.map(e),t[2]=r.id,t[3]=r.parts,t[4]=a}else a=t[4];let o;return t[7]!==i||t[8]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o});var Gee={braille:{frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},pulse:{frames:[`⠁`,`⠉`,`⠋`,`⠛`,`⠟`,`⠿`,`⡿`,`⣿`,`⡿`,`⠿`,`⠟`,`⠛`,`⠋`,`⠉`,`⠁`,`⠀`],interval:80},clock:{frames:[`⠁`,`⠈`,`⠐`,`⠠`,`⢀`,`⡀`,`⠄`,`⠂`],interval:100},limerence:{frames:[`⠁`,`⠃`,`⠇`,`⡇`,`⣇`,`⣇`,`⣆`,`⣄`,`⣀`,`⢀`,`⠀`],interval:100}};function Kee(e){let t=(0,G.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`braille`:i,o=un(),{frames:s,interval:c}=Gee[a],[l,u]=(0,R.useState)(0),d,f;t[4]!==o||t[5]!==s.length||t[6]!==c?(d=()=>{if(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=o.setInterval(()=>{u(e=>(e+1)%s.length)},c);return()=>o.clearInterval(e)},f=[o,s.length,c],t[4]=o,t[5]=s.length,t[6]=c,t[7]=d,t[8]=f):(d=t[7],f=t[8]),(0,R.useEffect)(d,f);let p;t[9]===n?p=t[10]:(p=I(`inline-block`,n),t[9]=n,t[10]=p);let m=s[l],h;return t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,z.jsx)(`span`,{role:`status`,"aria-label":`Loading`,className:p,...r,children:m}),t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function qee(e){let t=(0,G.c)(11),{Icon:n,isLast:r,isLoading:i,aborted:a,state:o,isError:s}=e,c;t[0]!==n||t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==o?(c=i?(0,z.jsx)(Kee,{className:`text-muted-foreground z-10 shrink-0 text-sm`}):a?(0,z.jsx)(Yn,{className:`text-destructive z-10 size-3.5 shrink-0`}):(0,z.jsx)(n,{className:I(`z-10 size-3.5 shrink-0`,o===`output-error`||s?`text-destructive`:`text-muted-foreground`)}),t[0]=n,t[1]=a,t[2]=s,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[6]=r,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex h-full flex-col items-center`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function Jee(e){let t=(0,G.c)(15),{isLast:n,label:r,state:i,aborted:a,children:o}=e,s=(0,R.use)(L5),c=r??s?.label,l=i??s?.state,u=a??s?.aborted??!1,d=c?.icon,f=!!l&&!u&&l!==`output-available`&&l!==`output-error`,p;t[0]!==d||t[1]!==u||t[2]!==c?.isError||t[3]!==l||t[4]!==n||t[5]!==f?(p=d?(0,z.jsx)(qee,{Icon:d,isLast:n,isLoading:f,aborted:u,state:l,isError:c?.isError??!1}):(0,z.jsx)(u7,{isLast:n}),t[0]=d,t[1]=u,t[2]=c?.isError,t[3]=l,t[4]=n,t[5]=f,t[6]=p):p=t[6];let m=p,h=n?``:`pb-3.5`,g;t[7]===h?g=t[8]:(g=I(`min-w-0 flex-1`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,z.jsx)(`div`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;return t[12]!==m||t[13]!==_?(v=(0,z.jsx)(d7,{marker:m,children:_}),t[12]=m,t[13]=_,t[14]=v):v=t[14],v}function Yee(e){let t=(0,G.c)(10),{label:n,state:r,part:i,defaultOpen:a,children:o}=e,s=a!==void 0&&a,c;t[0]!==n||t[1]!==i||t[2]!==r?(c=(0,z.jsx)(La,{className:`cursor-pointer`,children:(0,z.jsx)(O5,{label:n,state:r,part:i})}),t[0]=n,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,z.jsx)(Ra,{children:o}),t[4]=o,t[5]=l);let u;return t[6]!==s||t[7]!==c||t[8]!==l?(u=(0,z.jsxs)(Ia,{defaultOpen:s,className:`flex min-w-0 flex-1 flex-col`,children:[c,l]}),t[6]=s,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}var w9={Item:Jee,Disclosure:Yee};(0,R.memo)(function(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=B6(),{elements:i}=R6(),{debugMode:a}=S6(),o=C5(),s=e5(),c;t[0]===r.parts?c=t[1]:(c=K5(r.parts),t[0]=r.parts,t[1]=c);let l=c,u;t[2]!==a||t[3]!==i||t[4]!==s||t[5]!==r.id||t[6]!==l||t[7]!==o?(u=l.map((e,t)=>{let n=`${r.id}-${q5(e,t)}-${e.kind}`;if(e.kind===`text`)return(0,z.jsx)(H5.Text,{segment:e,elements:i,className:`my-4`},n);if(e.kind===`file`)return(0,z.jsx)(H5.File,{segment:e},n);if(e.kind===`source`)return(0,z.jsx)(H5.Source,{segment:e},n);if(e.kind===`dynamic-tool`){if(!o)return null;let r=!G5(l,t,!0);return(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(H5.DynamicTool,{segment:e})},n)}if(e.kind===`reasoning`){if(s||e.part.type!==`reasoning`)return null;let r=!G5(l,t,a),i={name:`Reasoning`,icon:ci,args:{text:[...e.part.text].slice(0,60).join(``)}};return(0,z.jsx)(w9.Item,{isLast:r,label:i,children:(0,z.jsx)(w9.Disclosure,{label:i,children:(0,z.jsx)(H5.Reasoning,{segment:e})})},n)}if(e.kind===`tool`){let r=!G5(l,t,a);return(0,z.jsx)(H5.Tool,{segment:e,children:(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(H5.ToolDisclosure,{})})},n)}return null}),t[2]=a,t[3]=i,t[4]=s,t[5]=r.id,t[6]=l,t[7]=o,t[8]=u):u=t[8];let d;return t[9]!==n||t[10]!==u?(d=(0,z.jsx)(`div`,{className:n,children:u}),t[9]=n,t[10]=u,t[11]=d):d=t[11],d});function Xee(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{hasSubmitted:i}=w6(),a;t[3]===n?a=t[4]:(a=I(`bg-background sticky bottom-0 rounded-t-2xl border-0 **:data-[slot=composer-editor]:!min-h-15`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==r||t[7]!==a?(o=(0,z.jsx)(c4.Root,{hasInteracted:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Zee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border bg-card focus-within:border-primary/80 focus-within:ring-primary/15 relative rounded-2xl border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-1 px-3.5 pt-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Content,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $ee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`!min-h-15 !rounded-none !border-0 !bg-transparent !shadow-none **:data-[slot=composer-editor]:!p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Editor,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ete(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`pb-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Attachments,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tte(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`p-1.5 pt-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Toolbar,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nte(e){let t=(0,G.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsx)(Y5,{icon:(0,z.jsx)(bi,{className:`size-4`})}),t[0]=n):n=t[0];let r;return t[1]===e?r=t[2]:(r=(0,z.jsx)(c4.AttachFiles,{"aria-label":`Attach files`,render:n,...e}),t[1]=e,t[2]=r),r}function rte(){let e=(0,G.c)(6),{actions:t,meta:n}=qQ(`ChatComposer.CommandButton`),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(Si,{className:`size-4`}),e[0]=r):r=e[0];let i=n.activePopup?.trigger===`/`,a;e[1]===t?a=e[2]:(a=e=>{e.stopPropagation(),t.toggleSlashMenu()},e[1]=t,e[2]=a);let o;return e[3]!==i||e[4]!==a?(o=(0,z.jsx)(Y5,{"data-command-button":!0,icon:r,"aria-label":`Toggle command menu`,"aria-expanded":i,onClick:a}),e[3]=i,e[4]=a,e[5]=o):o=e[5],o}function ite(e){switch(e){case`permission-denied`:return`Allow microphone access to use dictation`;case`no-microphone`:return`Connect a microphone to use dictation`;case`microphone-in-use`:return`Close other apps using the microphone`;case`interrupted`:return`Recording interrupted`;case`transcription-failed`:return`Unable to transcribe audio`}}function ate(e){switch(e.status){case`unavailable`:return e.reason===`blocked`?`Allow microphone access in your browser settings to use dictation`:`Dictation is not available in this browser`;case`idle`:return`Start dictation`;case`starting`:return`Starting dictation`;case`recording`:return`Stop dictation`;case`finishing`:return`Transcribing…`;case`failed`:return ite(e.error.code)}}function ote(e){switch(e.status){case`recording`:return(0,z.jsx)(Ei,{className:`size-4 fill-current`});case`starting`:case`finishing`:return(0,z.jsx)(me,{className:`size-4 animate-spin`});case`unavailable`:case`idle`:case`failed`:return(0,z.jsx)(mi,{className:`size-4`})}}function ste(){let e=(0,G.c)(20),{status:t}=C6(),{state:n}=Y1(`ChatComposer.Dictate`),r;e[0]===n?r=e[1]:(r=ate(n),e[0]=n,e[1]=r);let i=r,a=n.status===`starting`||n.status===`recording`||n.status===`finishing`,o=t===`streaming`||t===`submitted`,s;e[2]===n?s=e[3]:(s=ote(n),e[2]=n,e[3]=s);let c;e[4]!==i||e[5]!==s?(c=(0,z.jsx)(Y5,{icon:s,"aria-label":i,title:i}),e[4]=i,e[5]=s,e[6]=c):c=e[6];let l;e[7]!==o||e[8]!==c?(l=(0,z.jsx)(c4.Dictate,{disabled:o,render:c}),e[7]=o,e[8]=c,e[9]=l):l=e[9];let u;e[10]!==a||e[11]!==n.status?(u=a?(0,z.jsx)(c4.CancelDictation,{render:(0,z.jsx)(Y5,{icon:(0,z.jsx)(ye,{className:`size-4`}),"aria-label":n.status===`finishing`?`Cancel transcription`:`Cancel dictation`})}):null,e[10]=a,e[11]=n.status,e[12]=u):u=e[12];let d;e[13]!==i||e[14]!==n.status?(d=n.status===`failed`?(0,z.jsx)(`span`,{role:`status`,className:`text-destructive max-w-48 truncate text-xs`,children:i}):null,e[13]=i,e[14]=n.status,e[15]=d):d=e[15];let f;return e[16]!==l||e[17]!==u||e[18]!==d?(f=(0,z.jsxs)(z.Fragment,{children:[l,u,d]}),e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}var T9={Provider:Xee,Root:Zee,Popup:c4.Popup,Content:Qee,Attachments:ete,Editor:$ee,Error:c4.Error,Toolbar:tte,CommandButton:rte,AttachFiles:nte,Dictate:ste};function cte(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`border-border flex flex-col border-b px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function lte(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`flex items-center gap-2 px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function ute(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`text-muted-foreground size-3.5 shrink-0`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(ui,{className:r}),t[2]=r,t[3]=i),i}function dte(e){let t=(0,G.c)(7),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`min-w-0 flex-1 truncate text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=typeof n==`string`?(0,z.jsx)(u4,{text:n}):n,t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`span`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function fte(e){let t=(0,G.c)(6),{onClick:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`text-muted-foreground hover:text-foreground shrink-0 rounded p-1 transition-colors`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(zn,{className:`size-3.5`}),t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==i?(o=(0,z.jsx)(`button`,{type:`button`,onClick:n,className:i,"aria-label":`Remove queued message`,children:a}),t[3]=n,t[4]=i,t[5]=o):o=t[5],o}var E9={Root:cte,Item:lte,Icon:ute,Text:dte,Remove:fte},pte={normal:{d:`m5 12 7-7 7 7`,translateY:0},animate:{d:`m5 12 7-7 7 7`,translateY:[0,3,0],transition:{duration:.4}}},mte={normal:{d:`M12 19V5`},animate:{d:[`M12 19V5`,`M12 19V10`,`M12 19V5`],transition:{duration:.4}}},D9=e=>{let t=(0,G.c)(30),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({ref:o,onMouseEnter:r,onMouseLeave:i,className:n,size:s,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?20:s,l=Cj(),u=(0,R.useRef)(!1),d;t[7]===l?d=t[8]:(d=()=>(u.current=!0,{startAnimation:()=>l.start(`animate`),stopAnimation:()=>l.start(`normal`)}),t[7]=l,t[8]=d),(0,R.useImperativeHandle)(o,d);let f;t[9]!==l||t[10]!==r?(f=e=>{u.current?r?.(e):l.start(`animate`)},t[9]=l,t[10]=r,t[11]=f):f=t[11];let p=f,m;t[12]!==l||t[13]!==i?(m=e=>{u.current?i?.(e):l.start(`normal`)},t[12]=l,t[13]=i,t[14]=m):m=t[14];let h=m,g;t[15]===n?g=t[16]:(g=I(n),t[15]=n,t[16]=g);let _,v;t[17]===l?(_=t[18],v=t[19]):(_=(0,z.jsx)(wj.path,{animate:l,d:`m5 12 7-7 7 7`,variants:pte}),v=(0,z.jsx)(wj.path,{animate:l,d:`M12 19V5`,variants:mte}),t[17]=l,t[18]=_,t[19]=v);let y;t[20]!==c||t[21]!==_||t[22]!==v?(y=(0,z.jsxs)(`svg`,{fill:`none`,height:c,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:c,xmlns:`http://www.w3.org/2000/svg`,children:[_,v]}),t[20]=c,t[21]=_,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==p||t[25]!==h||t[26]!==a||t[27]!==g||t[28]!==y?(b=(0,z.jsx)(`div`,{className:g,onMouseEnter:p,onMouseLeave:h,...a,children:y}),t[24]=p,t[25]=h,t[26]=a,t[27]=g,t[28]=y,t[29]=b):b=t[29],b};D9.displayName=`ArrowUpIcon`;var hte={duration:.15,ease:[0,0,.2,1]},gte={duration:.12,ease:[0,0,.2,1]};function O9(e){let t=(0,G.c)(40),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({variant:a,className:n,disabled:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=_j(),s=a===`stop`,c;t[5]===o?c=t[6]:(c=!o&&{opacity:0,scale:.9},t[5]=o,t[6]=c);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l={opacity:1,scale:1},t[7]=l):l=t[7];let u;t[8]===o?u=t[9]:(u=o?void 0:{opacity:0,scale:.9},t[8]=o,t[9]=u);let d;t[10]!==r||t[11]!==o?(d=r||o?void 0:{scale:1.04},t[10]=r,t[11]=o,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==o?(f=r||o?void 0:{scale:.96},t[13]=r,t[14]=o,t[15]=f):f=t[15];let p=s?`Stop streaming`:`Send prompt`,m;t[16]===n?m=t[17]:(m=I(`relative flex size-8 items-center justify-center rounded-full`,`bg-primary text-primary-foreground`,`transition-opacity hover:opacity-90 active:opacity-80`,`disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:opacity-35`,`focus-visible:outline-[1.5px] focus-visible:outline-offset-[2.5px] focus-visible:outline-current`,n),t[16]=n,t[17]=m);let h=s?`stop`:`send`,g;t[18]===o?g=t[19]:(g=!o&&{opacity:0,scale:.7},t[18]=o,t[19]=g);let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_={opacity:1,scale:1},t[20]=_):_=t[20];let v;t[21]===o?v=t[22]:(v=o?void 0:{opacity:0,scale:.7},t[21]=o,t[22]=v);let y;t[23]===s?y=t[24]:(y=(0,z.jsx)(s?yte:vte,{}),t[23]=s,t[24]=y);let b;t[25]!==v||t[26]!==y||t[27]!==h||t[28]!==g?(b=(0,z.jsx)(Mk,{initial:!1,children:(0,z.jsx)(wj.span,{initial:g,animate:_,exit:v,transition:gte,className:`absolute flex items-center justify-center`,children:y},h)}),t[25]=v,t[26]=y,t[27]=h,t[28]=g,t[29]=b):b=t[29];let x;return t[30]!==r||t[31]!==i||t[32]!==c||t[33]!==b||t[34]!==u||t[35]!==d||t[36]!==f||t[37]!==p||t[38]!==m?(x=(0,z.jsx)(wj.button,{initial:c,animate:l,exit:u,transition:hte,whileHover:d,whileTap:f,"aria-label":p,...i,disabled:r,className:m,children:b}),t[30]=r,t[31]=i,t[32]=c,t[33]=b,t[34]=u,t[35]=d,t[36]=f,t[37]=p,t[38]=m,t[39]=x):x=t[39],x}function _te(e){let t=(0,G.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,z.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:n}),t[0]=n,t[1]=r),r}function vte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(D9,{}),e[0]=t):t=e[0],t}function yte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(_te,{children:(0,z.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`1.5`})}),e[0]=t):t=e[0],t}function bte(e){let t=(0,G.c)(25),{title:n,detail:r,detailLabel:i,part:a,error:o}=e,s=n===void 0?`Failed to render tool`:n,c=i===void 0?`View details`:i,l=T6(),u;t[0]===o.issues?u=t[1]:(u=o.issues.map(xte).join(`
|
|
350
|
-
`),t[0]=o.issues,t[1]=u);let d=u,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(_t,{className:`size-5`}),t[2]=f):f=t[2];let p;t[3]===s?p=t[4]:(p=(0,z.jsx)(ea,{children:(0,z.jsxs)(ta,{className:`text-destructive flex items-center gap-2`,children:[f,s]})}),t[3]=s,t[4]=p);let m,h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(_t,{className:`size-4`}),h=(0,z.jsx)(_r,{children:`Error`}),t[5]=m,t[6]=h):(m=t[5],h=t[6]);let g;t[7]===d?g=t[8]:(g=(0,z.jsxs)(we,{variant:`destructive`,children:[m,h,(0,z.jsx)(Je,{children:d})]}),t[7]=d,t[8]=g);let _;t[9]!==r||t[10]!==c?(_=r&&(0,z.jsxs)(`details`,{className:`text-sm`,children:[(0,z.jsx)(`summary`,{className:`text-muted-foreground hover:text-foreground cursor-pointer`,children:c}),(0,z.jsx)(`pre`,{className:`bg-muted mt-2 max-h-48 overflow-auto rounded-md p-3 text-xs`,children:(0,z.jsx)(`code`,{children:r})})]}),t[9]=r,t[10]=c,t[11]=_):_=t[11];let v;t[12]!==g||t[13]!==_?(v=(0,z.jsxs)(ia,{className:`space-y-4`,children:[g,_]}),t[12]=g,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==l||t[16]!==a?(y=()=>{let e=[`The model tried to call the tool "${jv(a)}" with the following inputs:`,JSON.stringify(a.input),`Please fix the inputs.`];l.addToolOutput({toolCallId:a.toolCallId,tool:jv(a),output:e,state:`output-available`})},t[15]=l,t[16]=a,t[17]=y):y=t[17];let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,z.jsx)(wi,{className:`size-4`}),t[18]=b):b=t[18];let x;t[19]===y?x=t[20]:(x=(0,z.jsx)(aa,{children:(0,z.jsxs)(Ce,{variant:`outline`,onClick:y,className:`gap-2`,children:[b,`Ask AI to fix this`]})}),t[19]=y,t[20]=x);let S;return t[21]!==v||t[22]!==x||t[23]!==p?(S=(0,z.jsxs)($i,{className:`border-destructive/50 bg-destructive/5`,children:[p,v,x]}),t[21]=v,t[22]=x,t[23]=p,t[24]=S):S=t[24],S}function xte(e){return`${e.path.join(`.`)}: ${e.message}`}(0,R.createContext)(``);function Ste({question:e}){let{submit:t}=S6();return typeof e!=`string`||e===``?null:(0,z.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground my-1 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-sm transition-colors`,onClick:()=>void t({prompt:e,persistedPrompt:e}),children:[(0,z.jsx)(oi,{className:`size-3.5`}),e]})}var k9=Vj([{name:`followup`,description:`Suggest a follow-up question the user is likely to ask next. Renders as a clickable chip that sends the question as the next message. Example: <followup question="How do I undo this?" />`,allowedAttributes:[`question`],component:Ste}]),Cte=F({label:L().describe(`Display text for the option`),value:L().optional().describe(`Machine value; defaults to label`),description:L().optional().describe(`Helper text for the option`)}),A9=D(e=>typeof e==`object`&&e&&`questions`in e&&Array.isArray(e.questions)?{...e,questions:e.questions.map(e=>typeof e==`object`&&e?{...e,type:`choice`}:e)}:e,F({questions:Zt(F({type:Ye(`choice`).describe(`Selection from predefined options`),question:L().describe(`The question text displayed to the user`),header:L().optional().describe(`Short context label`),multiSelect:Dt().default(!1).describe(`Whether multiple options can be selected`),options:Zt(Cte).min(1).describe(`Available choices`)})).min(1).describe(`Questions to present as a wizard`)})),j9=F({label:L(),value:L()}),wte=F({answers:Zt(F({type:L(),question:L(),freeText:L().optional(),notes:L().optional(),choice:j9.optional(),choices:Zt(j9).optional(),multiSelect:Dt().optional(),answer:L().optional()}))});function M9(e){if(e.multiSelect){if(e.selectedMulti.length===0&&!e.customText.trim())return`Pick at least one option or add your own answer.`}else{if(!e.selected&&!e.isOther)return`Select an option or add your own answer.`;if(e.isOther&&!e.customText.trim())return`Add your custom answer for the "Other" option.`}return null}function Tte(e){return{type:`choice`,multiSelect:e.multiSelect??!1,selected:null,selectedMulti:[],isOther:!1,customText:``,notes:``}}function N9(e){return e.options.filter(e=>(e.value??e.label).toLowerCase()!==`other`&&e.label.toLowerCase()!==`other`).map(e=>({label:e.label,value:e.value??e.label,description:e.description}))}function Ete(e,t,n){let r=e=>{let t=n.find(t=>t.value===e);return t?{label:t.label,value:t.value}:{label:e,value:e}},i=t.notes.trim()||void 0,a=t.customText.trim()||void 0;if(t.multiSelect){let n=t.selectedMulti.map(r);return a&&n.push({label:`Other`,value:a}),{type:`choice`,question:e.question,multiSelect:!0,choices:n,freeText:a,notes:i}}return{type:`choice`,question:e.question,multiSelect:!1,choice:t.isOther?{label:`Other`,value:a??``}:r(t.selected??``),freeText:t.isOther?a:void 0,notes:i}}function P9({checked:e,children:t,disabled:n}){return(0,z.jsx)(`div`,{className:I(`border-border/60 relative flex items-start gap-2 rounded-lg border px-3 py-1.5 transition-all duration-150`,!n&&`hover:bg-muted/40`,e&&`border-primary/50 bg-primary/5`,n&&`opacity-60`),children:t})}function F9({htmlFor:e,label:t,description:n}){return(0,z.jsxs)(Fn,{htmlFor:e,className:`min-w-0 flex-1 cursor-pointer flex-col items-start gap-0`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n?(0,z.jsx)(`p`,{className:`text-muted-foreground text-xs leading-relaxed text-pretty`,children:n}):null]})}function Dte({id:e,value:t,label:n,description:r,checked:i,disabled:a}){return(0,z.jsxs)(P9,{checked:i,disabled:a,children:[(0,z.jsx)(Ho,{id:e,value:t,disabled:a,className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:n,description:r})]})}function Ote({id:e,label:t,description:n,checked:r,disabled:i,onCheckedChange:a}){return(0,z.jsxs)(P9,{checked:r,disabled:i,children:[(0,z.jsx)(Sa,{id:e,checked:r,disabled:i,onCheckedChange:e=>a(e===!0),className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:t,description:n})]})}function kte({id:e,checked:t,disabled:n,customText:r,onCustomTextChange:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:t,disabled:n,children:[(0,z.jsx)(Ho,{ref:a,id:e,value:`other`,disabled:n,className:`mt-0.5`}),(0,z.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Type your answer...`,disabled:n,onFocus:()=>{t||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function Ate({hasCustom:e,disabled:t,customText:n,onCustomTextChange:r,onClear:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:e,disabled:t,children:[(0,z.jsx)(Sa,{ref:a,checked:e,disabled:t,onCheckedChange:e=>{e||i()},className:`mt-0.5`}),(0,z.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Type your answer...`,disabled:t,onFocus:()=>{e||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function jte({value:e,onChange:t,disabled:n}){return(0,z.jsx)(`div`,{className:`mt-2.5 border-t border-dashed pt-2.5`,children:(0,z.jsx)(et,{value:e,onChange:e=>t(e.target.value),placeholder:`Add notes (optional)...`,disabled:n,rows:2,className:`resize-none text-sm`})})}function Mte({value:e,onChange:t,options:n,disabled:r,fieldId:i}){if(e.multiSelect){let a=e.customText.trim().length>0,o=(n,r)=>{let i=new Set(e.selectedMulti);r?i.add(n):i.delete(n),t({...e,selectedMulti:[...i]})};return(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[n.map(t=>(0,z.jsx)(Ote,{id:`${i}-multi-${t.value}`,label:t.label,description:t.description,checked:e.selectedMulti.includes(t.value),disabled:r,onCheckedChange:e=>o(t.value,e)},t.value)),(0,z.jsx)(Ate,{hasCustom:a,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n}),onClear:()=>t({...e,customText:``})})]})}return(0,z.jsxs)(Vo,{value:e.isOther?`other`:e.selected??``,onValueChange:n=>t(n===`other`?{...e,selected:null,isOther:!0}:{...e,selected:n,isOther:!1,customText:``}),children:[n.map(t=>(0,z.jsx)(Dte,{id:`${i}-single-${t.value}`,value:t.value,label:t.label,description:t.description,checked:!e.isOther&&e.selected===t.value,disabled:r},t.value)),(0,z.jsx)(kte,{id:`${i}-single-other`,checked:e.isOther,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n})})]})}function Nte({current:e,total:t}){return t<=1?null:(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:t},(t,n)=>(0,z.jsx)(`div`,{className:I(`h-1 w-3 rounded-full transition-colors duration-200`,n<=e?`bg-primary`:`bg-muted`)},n))})}function Pte({onBack:e,onNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}){return o?null:(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-dashed px-3 py-1.5`,children:[(0,z.jsx)(`div`,{className:`w-16`,children:n?null:(0,z.jsx)(`button`,{type:`button`,onClick:e,disabled:a,className:`text-muted-foreground hover:text-foreground text-xs transition-colors disabled:opacity-50`,children:`← Back`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Nte,{current:s,total:c}),c>1?(0,z.jsxs)(`span`,{className:`text-muted-foreground text-[11px] tabular-nums`,children:[s+1,`/`,c]}):null]}),(0,z.jsx)(`div`,{className:`flex w-16 justify-end`,children:(0,z.jsxs)(Ce,{type:`button`,size:`sm`,onClick:t,disabled:!i||a,children:[a?(0,z.jsx)(Uo,{}):null,a?`Sending...`:r?`Submit`:`Next`]})})]})}function Fte({question:e}){return(0,z.jsxs)(`div`,{className:`px-3 pt-2.5 pb-2`,children:[(0,z.jsxs)(`div`,{className:`text-muted-foreground mb-2 flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(Ct,{className:`size-3`}),(0,z.jsx)(`span`,{children:e.header??`Clarification`})]}),(0,z.jsx)(Qi,{className:`mb-2`}),(0,z.jsx)(`p`,{className:`text-sm font-medium text-pretty`,children:e.question})]})}function Ite({question:e,answer:t,options:n,onChange:r,disabled:i,fieldId:a}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Mte,{value:t,onChange:r,options:n,disabled:i,fieldId:a}),(0,z.jsx)(jte,{value:t.notes,onChange:e=>r({...t,notes:e}),disabled:i})]})}function Lte({question:e,answer:t,options:n}){let r=t.multiSelect?[...t.selectedMulti.map(e=>n.find(t=>t.value===e)?.label??e),...t.customText.trim()?[`Other: ${t.customText.trim()}`]:[]].join(`, `):t.isOther?`Other: ${t.customText.trim()}`:n.find(e=>e.value===t.selected)?.label??t.selected??``,i=t.notes.trim()||void 0;return(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:r}),i?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,i]}):null]})}function Rte(e){return e.type===`free_form`?e.answer??``:e.multiSelect&&e.choices?e.choices.map(({label:e,value:t})=>e===`Other`?`Other: ${t}`:e).join(`, `):e.freeText?`Other: ${e.freeText}`:e.choice?.label??``}function zte({answers:e}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Qi,{}),e.map((e,t)=>(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:Rte(e)}),e.notes?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,e.notes]}):null]},t))]})}function Bte({questions:e,answers:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Qi,{}),e.map((e,n)=>(0,z.jsx)(Lte,{question:e,answer:t[n],options:N9(e)},n))]})}var I9=(0,R.createContext)(void 0);function L9(){let e=(0,R.use)(I9);if(!e)throw Error(`useWizard must be used within <ClarificationWizard.Root>`);return e}function Vte({questions:e,onSubmit:t,disabled:n,fieldId:r,children:i}){let[a,o]=(0,R.useState)(0),[s,c]=(0,R.useState)(()=>e.map(Tte)),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(!1),h=e[a],g=s[a],_=a===0,v=a===e.length-1,y={questions:e,currentStep:a,currentQuestion:h,currentAnswer:g,options:N9(h),answers:s,updateAnswer:e=>{c(t=>{let n=[...t];return n[a]=e,n}),u(null)},handleBack:()=>{_||(o(e=>e-1),u(null))},handleNext:async()=>{let n=M9(g);if(n){u(n);return}if(!v){o(e=>e+1),u(null);return}for(let t=0;t<e.length;t++){let e=M9(s[t]);if(e){o(t),u(e);return}}f(!0);try{await t(e.map((e,t)=>Ete(e,s[t],N9(e)))),m(!0)}catch(e){u(e instanceof Error?e.message:`Failed to send your answers.`)}finally{f(!1)}},error:l,isFirst:_,isLast:v,canProceed:!n&&!p,isSubmitting:d,isSubmitted:p,disabled:n,fieldId:r,totalSteps:e.length};return(0,z.jsx)(I9,{value:y,children:i})}function Hte(){let{currentQuestion:e,isSubmitted:t}=L9();return t?null:(0,z.jsx)(Fte,{question:e})}function Ute(){let{currentQuestion:e,currentAnswer:t,options:n,updateAnswer:r,disabled:i,isSubmitting:a,isSubmitted:o,fieldId:s,currentStep:c}=L9();return o?null:(0,z.jsx)(Ite,{question:e,answer:t,options:n,onChange:r,disabled:i||a,fieldId:`${s}-step-${c}`})}function Wte(){let{error:e,isSubmitted:t}=L9();return t||!e?null:(0,z.jsx)(`p`,{className:`text-destructive text-xs`,role:`alert`,children:e})}function Gte(){let{handleBack:e,handleNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}=L9();return(0,z.jsx)(Pte,{onBack:e,onNext:()=>void t(),isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c})}function Kte({children:e,className:t}){let{isSubmitted:n}=L9();return n?null:(0,z.jsx)(`div`,{className:t,children:e})}function qte(){let{questions:e,answers:t,isSubmitted:n}=L9();return n?(0,z.jsx)(Bte,{questions:e,answers:t}):null}var R9={Root:Vte,Header:Hte,Content:Kte,Field:Ute,Error:Wte,Navigation:Gte,Submitted:qte};function Jte({part:e}){let t=T6(),[n,r]=(0,R.useState)(!1),i=(0,R.useId)();if(e.state===`output-available`){let t=wte.safeParse(e.output);return t.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 mb-2 rounded-lg border border-dashed`),children:(0,z.jsx)(zte,{answers:t.data.answers})}):null}if(e.state!==`input-available`)return null;let a=A9.safeParse(e.input);return a.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 rounded-lg border border-dashed`,`animate-in fade-in-0 duration-200`),children:(0,z.jsxs)(R9.Root,{questions:a.data.questions,onSubmit:async n=>{await t.addToolOutput({toolCallId:e.toolCallId,tool:jv(e),output:{answers:n},state:`output-available`}),r(!0)},disabled:n,fieldId:i,children:[(0,z.jsx)(R9.Submitted,{}),(0,z.jsx)(R9.Header,{}),(0,z.jsxs)(R9.Content,{className:`space-y-2 px-3 pb-2`,children:[(0,z.jsx)(R9.Field,{}),(0,z.jsx)(R9.Error,{})]}),(0,z.jsx)(R9.Navigation,{})]})}):(0,z.jsx)(bte,{error:a.error,title:`Failed to render clarification`,detail:JSON.stringify(e.input,null,2),detailLabel:`View input`,part:e})}var Yte={component:Jte,label:e=>{let t=e.state===`input-available`||e.state===`output-available`?A9.safeParse(e.input):void 0,n=t?.success?t.data.questions[0]:void 0;return{name:`AskUserQuestion`,icon:eee,args:n?{question:n.header??n.question}:void 0}},requiresUserInput:!0,static:!1,inputSchema:A9,description:`Tool to collect information from the user via a multi-step wizard. Use when you need to clarify requirements, gather preferences, or resolve ambiguity before proceeding.
|
|
349
|
+
`)}`}function n5(){return(0,R.use)(Z8)}function r5(e){return kv(e)&&e.toolMetadata?.kind===`subagent`}function i5(e,t){let n=Av(e);return{toolKey:n,toolEntry:t?.[n]}}function a5(e,t){return e?.static===!1&&!!e?.requiresUserInput&&t===`input-available`}var o5=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.del.dfn.em.i.ins.kbd.mark.q.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`));function s5(e){if(!R.isValidElement(e))return!1;let t=typeof e.type==`string`?e.type:e.props.node?.tagName;return t===void 0||!o5.has(t)}function c5(e){let t=(0,G.c)(6),{children:n,dir:r}=e,i=R.Children.toArray(n);if(!i.some(s5)){let e;return t[0]!==n||t[1]!==r?(e=(0,z.jsx)(`p`,{dir:r,children:n}),t[0]=n,t[1]=r,t[2]=e):e=t[2],e}if(i.every(s5))return n;let a;return t[3]!==n||t[4]!==r?(a=(0,z.jsx)(`div`,{dir:r,children:n}),t[3]=n,t[4]=r,t[5]=a):a=t[5],a}var l5={p:({children:e,dir:t})=>(0,z.jsx)(c5,{dir:t,children:e})};function u5(e){let t={...l5},n={};for(let r of e)Ij(r),t[r.name]=r.component,n[r.name]=r.allowedAttributes;return{components:t,allowedTags:n}}function d5(e){let t=(0,G.c)(10),n,r;t[0]===e?(n=t[1],r=t[2]):({elements:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=n??[],t[3]=n,t[4]=i);let a;t[5]===i?a=t[6]:(a=u5(i),t[5]=i,t[6]=a);let o=a,s;return t[7]!==r||t[8]!==o?(s=(0,z.jsx)(I8,{...o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function f5(e){let t=(0,G.c)(34),{part:n}=e,{addToolApprovalResponse:r}=O6(),i=c6();if(n.state!==`approval-requested`)return null;let a,o;t[0]!==n||t[1]!==i?(a=n.title??Av(n),o=i(`approval.request`,{tool:a}),t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s;t[4]===a?s=t[5]:(s=(0,z.jsx)(`p`,{className:`text-sm font-medium`,children:a}),t[4]=a,t[5]=s);let c;t[6]===n.approval.requestReason?c=t[7]:(c=n.approval.requestReason&&(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n.approval.requestReason}),t[6]=n.approval.requestReason,t[7]=c);let l;t[8]!==s||t[9]!==c?(l=(0,z.jsxs)(`div`,{className:`space-y-1`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==n.approval.id?(u=()=>void r({id:n.approval.id,approved:!1}),t[11]=r,t[12]=n.approval.id,t[13]=u):u=t[13];let d;t[14]===i?d=t[15]:(d=i(`approval.deny`),t[14]=i,t[15]=d);let f;t[16]!==u||t[17]!==d?(f=(0,z.jsx)(Ce,{type:`button`,variant:`destructive`,onClick:u,children:d}),t[16]=u,t[17]=d,t[18]=f):f=t[18];let p;t[19]!==r||t[20]!==n.approval.id?(p=()=>void r({id:n.approval.id,approved:!0}),t[19]=r,t[20]=n.approval.id,t[21]=p):p=t[21];let m;t[22]===i?m=t[23]:(m=i(`approval.approve`),t[22]=i,t[23]=m);let h;t[24]!==p||t[25]!==m?(h=(0,z.jsx)(Ce,{type:`button`,onClick:p,children:m}),t[24]=p,t[25]=m,t[26]=h):h=t[26];let g;t[27]!==h||t[28]!==f?(g=(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[f,h]}),t[27]=h,t[28]=f,t[29]=g):g=t[29];let _;return t[30]!==o||t[31]!==g||t[32]!==l?(_=(0,z.jsxs)(`div`,{"aria-label":o,className:`border-border bg-muted/30 space-y-3 rounded-lg border p-3`,"data-copy-exclude":`assistant-snapshot`,role:`group`,children:[l,g]}),t[30]=o,t[31]=g,t[32]=l,t[33]=_):_=t[33],_}function p5(e){let t=(0,G.c)(25),{part:n}=e,{registry:r}=T6();if(n.input===void 0){let e;return t[0]!==n.errorText||t[1]!==n.output||t[2]!==n.state?(e=n.state===`output-error`?(0,z.jsx)(q8,{output:n.output,errorText:n.errorText}):(0,z.jsx)(fi,{className:`size-4 animate-spin`}),t[0]=n.errorText,t[1]=n.output,t[2]=n.state,t[3]=e):e=t[3],e}let i;t[4]===n?i=t[5]:(i=(0,z.jsx)(f5,{part:n}),t[4]=n,t[5]=i);let a=i;if(!r)return a;let o;t[6]!==n||t[7]!==r?(o=i5(n,r),t[6]=n,t[7]=r,t[8]=o):o=t[8];let{toolEntry:s}=o;if(s){let e=s.component,i;t[9]!==n||t[10]!==r.progress?(i=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[9]=n,t[10]=r.progress,t[11]=i):i=t[11];let o;t[12]!==e||t[13]!==n?(o=(0,z.jsx)(e,{part:n}),t[12]=e,t[13]=n,t[14]=o):o=t[14];let c;return t[15]!==a||t[16]!==i||t[17]!==o?(c=(0,z.jsxs)(`div`,{className:`space-y-2`,children:[i,o,a]}),t[15]=a,t[16]=i,t[17]=o,t[18]=c):c=t[18],c}else{let e;t[19]!==n||t[20]!==r.progress?(e=r.progress&&(0,z.jsx)(r.progress.component,{part:n}),t[19]=n,t[20]=r.progress,t[21]=e):e=t[21];let i;return t[22]!==a||t[23]!==e?(i=(0,z.jsxs)(z.Fragment,{children:[e,a]}),t[22]=a,t[23]=e,t[24]=i):i=t[24],i}}var m5={animation:`slideUp`};function h5(e){let t=(0,G.c)(6),{filename:n,url:r}=e,i=c6(),a;t[0]!==n||t[1]!==i?(a=n??i(`attachment.image`),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o;return t[3]!==a||t[4]!==r?(o=(0,z.jsx)(`img`,{src:r,alt:a,className:`max-h-64 rounded-md border object-contain`}),t[3]=a,t[4]=r,t[5]=o):o=t[5],o}function g5(e){let t=(0,G.c)(24),{filename:n,mediaType:r,url:i}=e,a=c6(),o;t[0]!==n||t[1]!==a?(o=n||a(`attachment.untitled`),t[0]=n,t[1]=a,t[2]=o):o=t[2];let s=o,c;t[3]!==r||t[4]!==s||t[5]!==i?(c=i?.startsWith(`data:`)?null:i&&r.startsWith(`video/`)?(0,z.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:i,"aria-label":s,className:`max-h-96 w-full rounded-md bg-black`,children:(0,z.jsx)(`track`,{kind:`captions`})}):i&&r.startsWith(`audio/`)?(0,z.jsx)(`audio`,{controls:!0,preload:`metadata`,src:i,"aria-label":s,className:`w-full`,children:(0,z.jsx)(`track`,{kind:`captions`})}):null,t[3]=r,t[4]=s,t[5]=i,t[6]=c):c=t[6];let l=c,u=l?`mt-2`:void 0,d;t[7]===a?d=t[8]:(d=a(`attachment.file`),t[7]=a,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,z.jsx)(`strong`,{children:d}),t[9]=d,t[10]=f);let p;t[11]!==n||t[12]!==a||t[13]!==i?(p=i?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsx)(`a`,{href:i,download:n,className:`underline`,children:a(`attachment.download`)})]}):null,t[11]=n,t[12]=a,t[13]=i,t[14]=p):p=t[14];let m;t[15]!==r||t[16]!==s||t[17]!==u||t[18]!==f||t[19]!==p?(m=(0,z.jsxs)(`div`,{className:u,children:[f,` `,s,` (`,r,`)`,p]}),t[15]=r,t[16]=s,t[17]=u,t[18]=f,t[19]=p,t[20]=m):m=t[20];let h;return t[21]!==l||t[22]!==m?(h=(0,z.jsxs)(Ji,{className:`bg-muted/30 block w-full rounded-md p-3 text-sm text-inherit`,children:[l,m]}),t[21]=l,t[22]=m,t[23]=h):h=t[23],h}function _5(e){let t=(0,G.c)(4),{filename:n,mediaType:r,url:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=r.split(`/`)[0]===`image`?(0,z.jsx)(h5,{filename:n,url:i}):(0,z.jsx)(g5,{filename:n,mediaType:r,url:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}var v5=`genai-citation`;function y5(e,t){return k6(e,t).reverse().reduce((e,{at:t,order:n})=>`${e.slice(0,t)}<${v5} citation="${n}" />${e.slice(t)}`,e)}var b5=(0,R.createContext)(null);function x5(e){let t=(0,G.c)(16),n=(0,R.use)(b5),r=n?.citations[Number(e.citation)];if(!n||!r)return null;let i;t[0]!==r.source.url||t[1]!==n.sources?(i=M6(n.sources,r.source.url),t[0]=r.source.url,t[1]=n.sources,t[2]=i):i=t[2];let a=i;if(a===null)return null;if(n.HostCitation){let e;return t[3]!==r||t[4]!==n.HostCitation||t[5]!==a?(e=(0,z.jsx)(n.HostCitation,{citation:r,index:a}),t[3]=r,t[4]=n.HostCitation,t[5]=a,t[6]=e):e=t[6],e}let o;t[7]!==r.source.title||t[8]!==r.source.url?(o={url:r.source.url,title:r.source.title},t[7]=r.source.title,t[8]=r.source.url,t[9]=o):o=t[9];let s;t[10]===r.citedText?s=t[11]:(s=r.citedText?(0,z.jsx)(`blockquote`,{dir:`auto`,children:r.citedText}):null,t[10]=r.citedText,t[11]=s);let c;return t[12]!==a||t[13]!==o||t[14]!==s?(c=(0,z.jsx)(W6,{source:o,index:a,children:s}),t[12]=a,t[13]=o,t[14]=s,t[15]=c):c=t[15],c}var S5={name:v5,allowedAttributes:[`citation`],component:x5};function C5(e){let t=(0,G.c)(27),{text:n,citations:r,elements:i,className:a}=e,{status:o}=E6(),s=n5(),{citation:c}=V6(),{message:l}=U6(),u;t[0]===r?u=t[1]:(u=A6(r),t[0]=r,t[1]=u);let d=u,f;t[2]===l?f=t[3]:(f=j6(l),t[2]=l,t[3]=f);let p;t[4]!==c||t[5]!==f||t[6]!==d?(p={citations:d,sources:f,HostCitation:c},t[4]=c,t[5]=f,t[6]=d,t[7]=p):p=t[7];let m=p,h=d.length>0,g;t[8]!==i||t[9]!==h?(g=h?[...i??[],S5]:i,t[8]=i,t[9]=h,t[10]=g):g=t[10];let _=g,v;t[11]===a?v=t[12]:(v=I(`text-sm`,a),t[11]=a,t[12]=v);let y=!s&&o===`streaming`,b;t[13]!==h||t[14]!==n||t[15]!==d?(b=h?y5(n,d):n,t[13]=h,t[14]=n,t[15]=d,t[16]=b):b=t[16];let x;t[17]!==y||t[18]!==b||t[19]!==_?(x=(0,z.jsx)(d5,{elements:_,animated:m5,isAnimating:y,children:b}),t[17]=y,t[18]=b,t[19]=_,t[20]=x):x=t[20];let S;t[21]!==v||t[22]!==x?(S=(0,z.jsx)(`div`,{className:v,children:x}),t[21]=v,t[22]=x,t[23]=S):S=t[23];let C;return t[24]!==m||t[25]!==S?(C=(0,z.jsx)(b5,{value:m,children:S}),t[24]=m,t[25]=S,t[26]=C):C=t[26],C}function w5(e){let t=(0,G.c)(8),{part:n}=e,r=T5(),i;t[0]!==n||t[1]!==r?(i=r&&(0,z.jsx)(Y8,{part:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=(0,z.jsx)(p5,{part:n}),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,z.jsxs)(z.Fragment,{children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function T5(){let{debugMode:e}=T6(),t=n5();return!!e&&!t}function E5(e){return!!e&&e!==`output-available`}function D5(e){let t=(0,G.c)(5),{label:n,part:r,state:i}=e,a=n5(),o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=!a&&!!n.actions&&!!r&&!E5(i),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function O5(e){let t=(0,G.c)(20),{label:n,part:r}=e,i=n.icon,a=n.actions,o;t[0]!==n||t[1]!==r?(o={label:n,part:r,state:r.state},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=D5(o),c;t[3]!==i||t[4]!==n.isError?(c=i&&(0,z.jsx)(i,{className:I(`size-3.5`,n.isError?`text-destructive`:`text-muted-foreground`)}),t[3]=i,t[4]=n.isError,t[5]=c):c=t[5];let l;t[6]!==n.kind||t[7]!==n.name||t[8]!==n.text?(l=n.kind===`sentence`?(0,z.jsx)(`span`,{dir:`auto`,className:`text-start`,children:n.text}):(0,z.jsx)(`span`,{className:`font-mono`,children:n.name}),t[6]=n.kind,t[7]=n.name,t[8]=n.text,t[9]=l):l=t[9];let u;t[10]!==c||t[11]!==l?(u=(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==a||t[14]!==r||t[15]!==s?(d=s&&a&&(0,z.jsx)(a,{part:r}),t[13]=a,t[14]=r,t[15]=s,t[16]=d):d=t[16];let f;return t[17]!==u||t[18]!==d?(f=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-1.5 text-xs`,children:[u,d]}),t[17]=u,t[18]=d,t[19]=f):f=t[19],f}function k5(e){let t=(0,G.c)(3),{name:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,z.jsxs)(`span`,{"data-slot":`tool-arg`,children:[n,`: "`,r,`"`]}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function A5(e){let t=(0,G.c)(24),{label:n,state:r,part:i,children:a}=e,o=n.actions,s;t[0]!==n||t[1]!==i||t[2]!==r?(s={label:n,part:i,state:r},t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c=D5(s),l=n.kind===`sentence`,u;t[4]!==a||t[5]!==l||t[6]!==n.args||t[7]!==n.name||t[8]!==n.text?(u=l?(0,z.jsx)(`span`,{dir:`auto`,className:`text-muted-foreground min-w-0 truncate text-start text-xs`,children:n.text}):(0,z.jsxs)(`span`,{className:`text-muted-foreground min-w-0 truncate font-mono text-xs [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:mr-1 [&>[data-slot=tool-arg]+[data-slot=tool-arg]]:before:content-[',']`,children:[n.name,`(`,a,n.args?Object.entries(n.args).map(j5):`...`,`)`]}),t[4]=a,t[5]=l,t[6]=n.args,t[7]=n.name,t[8]=n.text,t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==i||t[12]!==c?(d=c&&o&&i&&(0,z.jsx)(`span`,{className:`shrink-0`,children:(0,z.jsx)(o,{part:i})}),t[10]=o,t[11]=i,t[12]=c,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==l||t[18]!==n.detail||t[19]!==n.isError?(p=n.detail&&(0,z.jsx)(`span`,{dir:l?`auto`:void 0,className:I(`line-clamp-3 text-start leading-relaxed whitespace-pre-wrap`,l?`text-xs`:`font-mono text-[10px]`,n.isError?`text-destructive/80`:`text-muted-foreground`),children:n.detail}),t[17]=l,t[18]=n.detail,t[19]=n.isError,t[20]=p):p=t[20];let m;return t[21]!==f||t[22]!==p?(m=(0,z.jsxs)(`span`,{className:`mb-2 flex flex-col gap-1`,children:[f,p]}),t[21]=f,t[22]=p,t[23]=m):m=t[23],m}function j5(e){let[t,n]=e;return(0,z.jsx)(k5,{name:t,value:n},t)}function M5(e){return e.type===`text`&&e.providerMetadata?.openai?.phase===`commentary`}function N5(e){let t=(0,G.c)(9),{segment:n,elements:r,className:i}=e,a;if(t[0]!==i||t[1]!==r||t[2]!==n.parts){let e;t[4]!==i||t[5]!==r?(e=e=>{let{part:t,idx:n}=e;return t.type===`text`?(0,z.jsx)(C5,{text:t.text,citations:t.citations,elements:r,className:i},`${n}-text`):null},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.parts.map(e),t[0]=i,t[1]=r,t[2]=n.parts,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,z.jsx)(z.Fragment,{children:a}),t[7]=a,t[8]=o),o}function P5(e){let t=(0,G.c)(4),{segment:n}=e,{part:r}=n;if(r.type!==`file`)return null;let i;return t[0]!==r.filename||t[1]!==r.mediaType||t[2]!==r.url?(i=(0,z.jsx)(_5,{filename:r.filename,mediaType:r.mediaType,url:r.url}),t[0]=r.filename,t[1]=r.mediaType,t[2]=r.url,t[3]=i):i=t[3],i}function F5(e){let t=(0,G.c)(9),{segment:n}=e,{message:r}=U6(),i;t[0]===r?i=t[1]:(i=j6(r),t[0]=r,t[1]=i);let a=i,o;if(t[2]!==n.parts||t[3]!==a){let e;t[5]===a?e=t[6]:(e=e=>{let{part:t,idx:n}=e;if(t.type!==`source-url`)return null;let r=M6(a,t.url);return r===null?null:(0,z.jsx)(W6,{source:{url:t.url,title:t.title},index:r},`source-${n}`)},t[5]=a,t[6]=e),o=n.parts.map(e),t[2]=n.parts,t[3]=a,t[4]=o}else o=t[4];let s;return t[7]===o?s=t[8]:(s=(0,z.jsx)(`span`,{children:o}),t[7]=o,t[8]=s),s}function I5(e){let t=(0,G.c)(3),{segment:n}=e,r=H6();if(n5())return null;let{part:i}=n;if(i.type!==`reasoning`)return null;let a=r===`streaming`,o;return t[0]!==i.text||t[1]!==a?(o=(0,z.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:(0,z.jsx)(I8,{animated:m5,isAnimating:a,children:i.text})}),t[0]=i.text,t[1]=a,t[2]=o):o=t[2],o}function L5(e){let t=(0,G.c)(2),{segment:n}=e;if(!T5())return null;let{part:r}=n;if(r.type!==`dynamic-tool`)return null;let i;return t[0]===r?i=t[1]:(i=(0,z.jsx)(X8,{part:r}),t[0]=r,t[1]=i),i}var R5=(0,R.createContext)(null),z5=(0,R.createContext)(null);function B5(){let e=(0,R.use)(R5);if(!e)throw Error(`Segment.Tool* parts must be rendered within Segment.Tool`);return e}function V5(e){let t=(0,G.c)(30),{segment:n,children:r}=e,i=T6(),a=H6(),o=c6(),{part:s}=n;if(!Dv(s))return null;let c,l,u,d;t[0]!==i.registry||t[1]!==a||t[2]!==s?({toolEntry:d}=i5(s,i.registry),l=a5(d,s.state),c=!l&&P6(s,a),u=d?.label?.(s),t[0]=i.registry,t[1]=a,t[2]=s,t[3]=c,t[4]=l,t[5]=u,t[6]=d):(c=t[3],l=t[4],u=t[5],d=t[6]);let f=u,p;t[7]!==c||t[8]!==f||t[9]!==o||t[10]!==s?(p=c?{...f??{name:Av(s)},isError:!0,detail:o(`steps.cancelledByUser`)}:f,t[7]=c,t[8]=f,t[9]=o,t[10]=s,t[11]=p):p=t[11];let m=p,h=d?.static===!1&&!!d?.requiresUserInput&&!l,g;t[12]!==c||t[13]!==l||t[14]!==h||t[15]!==m||t[16]!==s?(g={part:s,label:m,aborted:c,activeClientInput:l,defaultOpen:h},t[12]=c,t[13]=l,t[14]=h,t[15]=m,t[16]=s,t[17]=g):g=t[17];let _;t[18]!==c||t[19]!==m||t[20]!==s.state?(_={label:m,state:s.state,aborted:c},t[18]=c,t[19]=m,t[20]=s.state,t[21]=_):_=t[21];let v;t[22]===r?v=t[23]:(v=r??(0,z.jsx)(U5,{}),t[22]=r,t[23]=v);let y;t[24]!==_||t[25]!==v?(y=(0,z.jsx)(z5,{value:_,children:v}),t[24]=_,t[25]=v,t[26]=y):y=t[26];let b;return t[27]!==g||t[28]!==y?(b=(0,z.jsx)(R5,{value:g,children:y}),t[27]=g,t[28]=y,t[29]=b):b=t[29],b}function H5(){let e=(0,G.c)(2),{part:t,activeClientInput:n}=B5();if(n)return null;let r;return e[0]===t?r=e[1]:(r=(0,z.jsx)(w5,{part:t}),e[0]=t,e[1]=r),r}function U5(e){let t=(0,G.c)(9),{children:n}=e,{part:r,label:i,defaultOpen:a}=B5();if(!i){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(H5,{})}),t[0]=e):e=t[0],e}let o;t[1]!==n||t[2]!==i||t[3]!==r?(o=(0,z.jsx)(La,{className:`cursor-pointer`,children:(0,z.jsx)(A5,{label:i,state:r.state,part:r,children:n})}),t[1]=n,t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Ra,{className:`mb-2`,children:(0,z.jsx)(H5,{})}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,z.jsxs)(Ia,{defaultOpen:a,className:`flex min-w-0 flex-1 flex-col`,children:[o,s]}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}var W5={Text:N5,File:P5,Source:F5,Reasoning:I5,DynamicTool:L5,Tool:V5,ToolDisclosure:U5,ToolContent:H5};function G5(e){return Dv(e)?`tool`:e.type===`dynamic-tool`?`dynamic-tool`:e.type===`reasoning`&&`text`in e&&e.text?`reasoning`:null}function K5(e,t){return e.kind===`text`||e.kind===`file`||e.kind===`source`?!1:e.kind===`reasoning`||e.kind!==`dynamic-tool`||!!t}function q5(e,t,n){let r=e[t+1];return!!r&&K5(r,n)}function J5(e){let t=[],n=new Set(e.flatMap(e=>e.type===`text`?A6(e.citations).map(({source:e})=>e.url):[]));for(let r=0;r<e.length;r++){let i=e[r],a=G5(i);if(a)t.push({kind:a,part:i,idx:r});else if(i.type===`text`){let e=t[t.length-1];e&&e.kind===`text`?e.parts.push({part:i,idx:r}):t.push({kind:`text`,parts:[{part:i,idx:r}]})}else if(i.type===`file`)t.push({kind:`file`,part:i,idx:r});else if(i.type===`source-url`&&!n.has(i.url)){let e=t[t.length-1];e&&e.kind===`source`?e.parts.push({part:i,idx:r}):t.push({kind:`source`,parts:[{part:i,idx:r}]})}}return t}function Y5(e,t){return e.kind===`text`||e.kind===`source`?e.parts[0]?.idx??t:e.idx}(0,R.memo)(function(e){let t=(0,G.c)(8),{segment:n}=e;if(n.kind===`tool`){let e;return t[0]===n?e=t[1]:(e=(0,z.jsx)(W5.Tool,{segment:n}),t[0]=n,t[1]=e),e}if(n.kind===`reasoning`){let e;return t[2]===n?e=t[3]:(e=(0,z.jsx)(W5.Reasoning,{segment:n}),t[2]=n,t[3]=e),e}if(n.kind===`text`){let e;return t[4]===n?e=t[5]:(e=(0,z.jsx)(W5.Text,{segment:n,className:`text-xs`}),t[4]=n,t[5]=e),e}if(n.kind===`file`){let e;return t[6]===n?e=t[7]:(e=(0,z.jsx)(W5.File,{segment:n}),t[6]=n,t[7]=e),e}return null},X5);function X5(e,t){return e.complete&&t.complete&&e.cacheKey===t.cacheKey}function Z5(e){let t=(0,G.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({icon:r,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a={scale:.94},t[4]=a):a=t[4];let o;t[5]===n?o=t[6]:(o=I(`group text-muted-foreground hover:text-foreground relative rounded-lg p-2 transition-colors`,n),t[5]=n,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(`span`,{className:`bg-primary/10 absolute inset-0 rounded-lg opacity-0 transition-opacity group-hover:opacity-100`}),t[7]=s):s=t[7];let c;return t[8]!==r||t[9]!==i||t[10]!==o?(c=(0,z.jsxs)(wj.button,{type:`button`,whileTap:a,className:o,...i,children:[r,s]}),t[8]=r,t[9]=i,t[10]=o,t[11]=c):c=t[11],c}function Q5(){let{index:e}=U6(),{messages:t}=V6(),n=H6();return!(e===t.length-1&&(n===`submitted`||n===`streaming`||n===`error`))}function $5(e){let t=(0,G.c)(5),{className:n,children:r}=e;if(!Q5()||R.Children.toArray(r).length===0)return null;let i;t[0]===n?i=t[1]:(i=I(`mt-1 flex items-center gap-0.5`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function e7(e){let t=(0,G.c)(15),{className:n}=e,{message:r}=U6(),[i,a]=L8(),o=c6(),s=i?`message.copied`:`message.copy`,c;t[0]!==o||t[1]!==s?(c=o(s),t[0]=o,t[1]=s,t[2]=c):c=t[2];let l;t[3]===n?l=t[4]:(l=I(`p-1.5`,n),t[3]=n,t[4]=l);let u;t[5]!==a||t[6]!==r?(u=()=>void a(t5(r)),t[5]=a,t[6]=r,t[7]=u):u=t[7];let f;t[8]===i?f=t[9]:(f=(0,z.jsx)(i?d:ii,{className:`size-3.5`}),t[8]=i,t[9]=f);let p;return t[10]!==c||t[11]!==l||t[12]!==u||t[13]!==f?(p=(0,z.jsx)(Z5,{"aria-label":c,className:l,onClick:u,icon:f}),t[10]=c,t[11]=l,t[12]=u,t[13]=f,t[14]=p):p=t[14],p}function t7(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=U6(),{regenerate:i}=O6(),a=c6(),o;t[0]===a?o=t[1]:(o=a(`message.regenerate`),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=I(`p-1.5`,n),t[2]=n,t[3]=s);let c;t[4]!==r.id||t[5]!==i?(c=()=>void i({messageId:r.id}),t[4]=r.id,t[5]=i,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(wi,{className:`size-3.5`}),t[7]=l):l=t[7];let u;return t[8]!==o||t[9]!==s||t[10]!==c?(u=(0,z.jsx)(Z5,{"aria-label":o,className:s,onClick:c,icon:l}),t[8]=o,t[9]=s,t[10]=c,t[11]=u):u=t[11],u}function n7(e){let t=(0,G.c)(15),{className:n}=e,{message:r}=U6(),[i,a]=L8(),o=c6(),s=i?`message.copied`:`message.copyDebugJson`,c;t[0]!==o||t[1]!==s?(c=o(s),t[0]=o,t[1]=s,t[2]=c):c=t[2];let l;t[3]===n?l=t[4]:(l=I(`p-1.5`,n),t[3]=n,t[4]=l);let u;t[5]!==a||t[6]!==r?(u=()=>void a(JSON.stringify(r,null,2)),t[5]=a,t[6]=r,t[7]=u):u=t[7];let f;t[8]===i?f=t[9]:(f=(0,z.jsx)(i?d:Gt,{className:`size-3.5`}),t[8]=i,t[9]=f);let p;return t[10]!==c||t[11]!==l||t[12]!==u||t[13]!==f?(p=(0,z.jsx)(Z5,{"aria-label":c,className:l,onClick:u,icon:f}),t[10]=c,t[11]=l,t[12]=u,t[13]=f,t[14]=p):p=t[14],p}function r7(e){let t=(0,G.c)(10),{onTryAgain:n,error:r}=e,i=c6(),a;t[0]===r.message?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-destructive text-sm`,children:(0,z.jsx)(I8,{mode:`static`,children:r.message})}),t[0]=r.message,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`chat.retry`),t[2]=i,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,z.jsx)(Ce,{type:`button`,onClick:n,size:`sm`,variant:`outline`,children:o}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,z.jsx)(`div`,{className:`mt-3 flex justify-start`,children:(0,z.jsxs)(`div`,{className:`max-w-[80%] space-y-2`,children:[a,s]})}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function i7(e){let t=(0,G.c)(3),{error:n,onRetry:r}=e;if(!n||!r)return null;let i;return t[0]!==n||t[1]!==r?(i=(0,z.jsx)(r7,{onTryAgain:r,error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function a7(e){let t=(0,G.c)(15),{messages:n,className:r,elements:i,citation:a,status:o,children:s}=e,c;t[0]!==a||t[1]!==i||t[2]!==n||t[3]!==o?(c={messages:n,elements:i,citation:a,status:o},t[0]=a,t[1]=i,t[2]=n,t[3]=o,t[4]=c):c=t[4];let l=c,u;t[5]===r?u=t[6]:(u=I(`flex h-full flex-col`,r),t[5]=r,t[6]=u);let d;t[7]===s?d=t[8]:(d=(0,z.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:s}),t[7]=s,t[8]=d);let f;t[9]!==u||t[10]!==d?(f=(0,z.jsx)(`div`,{className:u,children:d}),t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==f||t[13]!==l?(p=(0,z.jsx)(z6,{value:l,children:f}),t[12]=f,t[13]=l,t[14]=p):p=t[14],p}function o7(e){let t=(0,G.c)(5),{className:n,children:r}=e,i;t[0]===n?i=t[1]:(i=I(`flex flex-col gap-4`,n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function s7(e){let t=(0,G.c)(9),{message:n,index:r,className:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o={message:n,index:r},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]!==a||t[4]!==i?(c=(0,z.jsx)(`div`,{className:i,children:a}),t[3]=a,t[4]=i,t[5]=c):c=t[5];let l;return t[6]!==c||t[7]!==s?(l=(0,z.jsx)(B6,{value:s,children:c}),t[6]=c,t[7]=s,t[8]=l):l=t[8],l}function c7(){let e=(0,G.c)(5),{registry:t}=T6(),n=O6().messages,r;if(e[0]!==n||e[1]!==t){bb0:{if(!t){r=null;break bb0}let i=n.findLast(l7);if(!i){r=null;break bb0}let a;e[3]===t?a=e[4]:(a=e=>{if(!Dv(e)||e.state!==`input-available`)return[];let n=t[Av(e)];return!n||n.static!==!1||!n.requiresUserInput?[]:[{part:e,entry:n}]},e[3]=t,e[4]=a),r=i.parts.flatMap(a).at(0)??null}e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function l7(e){let{role:t}=e;return t===`assistant`}function u7(e){let t=(0,G.c)(10),{children:n,className:r}=e,i=c7(),a=i?.entry.component,o=i?`hidden`:`visible`,s;t[0]!==n||t[1]!==o?(s=(0,z.jsx)(R.Activity,{mode:o,children:n}),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==a||t[4]!==i||t[5]!==r?(c=i&&a?(0,z.jsx)(`div`,{className:I(`sticky bottom-0 mt-auto`,r),children:(0,z.jsx)(a,{part:i.part},i.part.toolCallId)}):null,t[3]=a,t[4]=i,t[5]=r,t[6]=c):c=t[6];let l;return t[7]!==s||t[8]!==c?(l=(0,z.jsxs)(z.Fragment,{children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function d7(e,t,n){if(e===`error`||e===`ready`||!t)return null;if(t.role!==`assistant`)return n;for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(Tv(n)&&M5(n)&&n.text)return n.text}for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(Ev(n)&&n.text)return n.text;if(kv(n)){let e=n.input;if($h(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return n.toolCallId}if(Tv(n)&&n.text)return``}return n}function f7(e){let t=(0,G.c)(5),{isLast:n}=e,r=n!==void 0&&n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(`span`,{className:`bg-muted-foreground/50 z-10 mt-1 size-2 shrink-0 rounded-full`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[1]=r,t[2]=a);let o;return t[3]===a?o=t[4]:(o=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex size-3.5 h-full flex-col items-center`,children:[i,a]}),t[3]=a,t[4]=o),o}function p7(e){let t=(0,G.c)(6),{marker:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=I(`relative z-0 flex gap-3 pl-5`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==n||t[4]!==a?(o=(0,z.jsxs)(`div`,{className:a,children:[n,r]}),t[2]=r,t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function m7(){let e=(0,G.c)(7),t=H6(),{messages:n}=V6(),r=c7(),i=c6(),a=n[n.length-1],o;e[0]!==t||e[1]!==i||e[2]!==a?(o=d7(t,a,i(`steps.thinking`)),e[0]=t,e[1]=i,e[2]=a,e[3]=o):o=e[3];let s=o;if(!s||r)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,z.jsx)(f7,{isLast:!0}),e[4]=c):c=e[4];let l;return e[5]===s?l=e[6]:(l=(0,z.jsx)(p7,{className:`mt-2`,marker:c,children:(0,z.jsx)(`span`,{role:`status`,children:(0,z.jsx)(I6,{as:`span`,className:`text-muted-foreground line-clamp-2 font-mono text-xs`,children:s})})}),e[5]=s,e[6]=l),l}var h7=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`totalTokens`],g7={inputTokens:[[`inputTokens`],[`raw`,`prompt_tokens`]],outputTokens:[[`outputTokens`],[`raw`,`completion_tokens`]],reasoningTokens:[[`reasoningTokens`],[`outputTokenDetails`,`reasoningTokens`],[`raw`,`completion_tokens_details`,`reasoning_tokens`]],cachedInputTokens:[[`inputTokenDetails`,`cacheReadTokens`],[`cachedInputTokens`],[`inputTokenDetails`,`cachedTokens`],[`raw`,`prompt_tokens_details`,`cached_tokens`]],totalTokens:[[`totalTokens`],[`raw`,`total_tokens`]]};function _7(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}return null}function v7(e){if(!e||typeof e!=`object`)return null;let t={inputTokens:null,outputTokens:null,reasoningTokens:null,cachedInputTokens:null,totalTokens:null};for(let n of h7)for(let r of g7[n]){let i=_7(Y3(e,r));if(i!==null){t[n]=i;break}}return h7.some(e=>t[e]!==null)?t:null}function y7(e){return $h(e)?v7(e.totalUsage??e.usage):null}function b7(e){return{input:$3(e.inputTokens),output:$3(e.outputTokens),total:e.totalTokens===null?void 0:Q3(e.totalTokens),cached:e.cachedInputTokens!==null&&e.cachedInputTokens>0?$3(e.cachedInputTokens):void 0}}var x7=`x-upload-filename`,S7=Me({path:L().startsWith(`/`),name:L().min(1),mediaType:Nn([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/heic`,`image/heif`,`video/mp4`,`video/quicktime`,`audio/mpeg`,`audio/mp4`,`audio/wav`]),size:Nt().nonnegative(),url:Te()}),C7=class extends Ay{sessionsApi;request;constructor({api:e,fetch:t=(e,t)=>globalThis.fetch(e,t),tools:n={},elements:r=[]}){let i=D7(e),a=r.map(Bj);super({api:i,fetch:async(e,n)=>{let r=await t(e,n);if((n?.method??`GET`).toUpperCase()!==`POST`||!r.ok)return r;let i=await r.json();if(!O7(i))throw Error(`Zukhruf returned an invalid accepted-turn response`);let a=D7(String(e)),o=decodeURIComponent(a.slice(a.lastIndexOf(`/`)+1));if(i.sessionId!==o)throw Error(`Zukhruf returned a different session ID`);let s=n?.signal;return s?.addEventListener(`abort`,()=>{t(`${a}/cancel`,{method:`POST`})},{once:!0}),t(`${a}/stream`,{headers:{accept:`text/event-stream`},method:`GET`,signal:s})},prepareSendMessagesRequest:({id:e,messages:t,trigger:r})=>{let o=t[t.length-1];if(!o)throw Error(`A message is required`);return{api:w7(i,e),body:{sessionId:e,message:o,trigger:r,...Object.keys(n).length>0?{tools:n}:{},...a.length>0?{elements:a}:{}}}},prepareReconnectToStreamRequest:({headers:e,id:t})=>({api:`${w7(i,t)}/stream`,headers:e})}),this.sessionsApi=i,this.request=t}async uploadFile(e,t){let n=await this.request(`${w7(this.sessionsApi,e)}/uploads`,{method:`POST`,headers:{"content-type":t.type,[x7]:encodeURIComponent(t.name)},body:t});if(!n.ok)throw Error(await T7(n,t));let r=S7.safeParse(await n.json());if(!r.success)throw Error(`Zukhruf returned an invalid upload response`);return r.data}};function w7(e,t){return`${e}/${encodeURIComponent(t)}`}async function T7(e,t){let n=`Uploading ${t.name} failed with HTTP ${e.status}`,r=E7(await e.json().catch(e=>{if(e instanceof SyntaxError)return null;throw e}));return r?`${n}: ${r}`:n}function E7(e){if(typeof e!=`object`||!e)return null;let t=`cause`in e&&typeof e.cause==`object`&&e.cause!==null?e.cause:null;return[t&&`code`in t&&typeof t.code==`string`?t.code:null,t&&`detail`in t&&typeof t.detail==`string`?t.detail:`error`in e&&typeof e.error==`string`?e.error:null].filter(e=>e!==null).join(` — `)||null}function D7(e){return e.replace(/\/$/,``)}function O7(e){return typeof e==`object`&&!!e&&`ok`in e&&e.ok===!0&&`sessionId`in e&&typeof e.sessionId==`string`&&`turnId`in e&&typeof e.turnId==`string`}function k7(e){let t=(0,G.c)(24),{label:n,open:r,onOpenChange:i,children:a,className:o,triggerClassName:s,contentClassName:c,chevronClassName:l}=e,u;t[0]===s?u=t[1]:(u=I(`flex items-center font-mono`,s),t[0]=s,t[1]=u);let d;t[2]===u?d=t[3]:(d=(0,z.jsx)(`button`,{type:`button`,className:u}),t[2]=u,t[3]=d);let f=r&&`rotate-180`,p;t[4]!==l||t[5]!==f?(p=I(`size-4 transition-transform`,l,f),t[4]=l,t[5]=f,t[6]=p):p=t[6];let m;t[7]===p?m=t[8]:(m=(0,z.jsx)(He,{className:p}),t[7]=p,t[8]=m);let h;t[9]===n?h=t[10]:(h=(0,z.jsx)(`span`,{children:n}),t[9]=n,t[10]=h);let g;t[11]!==d||t[12]!==m||t[13]!==h?(g=(0,z.jsxs)(La,{render:d,children:[m,h]}),t[11]=d,t[12]=m,t[13]=h,t[14]=g):g=t[14];let _;t[15]!==a||t[16]!==c?(_=(0,z.jsx)(Ra,{className:c,children:a}),t[15]=a,t[16]=c,t[17]=_):_=t[17];let v;return t[18]!==o||t[19]!==i||t[20]!==r||t[21]!==g||t[22]!==_?(v=(0,z.jsxs)(Ia,{open:r,onOpenChange:i,className:o,children:[g,_]}),t[18]=o,t[19]=i,t[20]=r,t[21]=g,t[22]=_,t[23]=v):v=t[23],v}function A7(e){let t=(0,G.c)(8),{metadata:n}=e,r=c6();if(!n)return null;let i,a,o;if(t[0]!==n||t[1]!==r){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=y7(n);if(!e){o=null;break bb0}i=`text-muted-foreground mt-2 text-xs tabular-nums opacity-60`,a=r(`message.usage`,b7(e))}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o}else i=t[2],a=t[3],o=t[4];if(o!==Symbol.for(`react.early_return_sentinel`))return o;let s;return t[5]!==i||t[6]!==a?(s=(0,z.jsx)(`div`,{className:i,children:a}),t[5]=i,t[6]=a,t[7]=s):s=t[7],s}function j7(e,t){return $h(e.metadata)?e.metadata[t]:void 0}function M7(e){let t=j7(e,`reminders`);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.text==`string`&&t.text.trim().length>0}):[]}function N7(e){let t=j7(e,`uploads`);return Array.isArray(t)?t.flatMap(e=>{let t=S7.safeParse(e);return t.success?[t.data]:[]}):[]}function P7(e){let t=(0,G.c)(7),{text:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(F7),t[0]=a):a=t[0];let o=!r&&`line-clamp-3`,s;t[1]===o?s=t[2]:(s=I(`hover:text-foreground w-full cursor-pointer text-left whitespace-pre-wrap`,o),t[1]=o,t[2]=s);let c;return t[3]!==r||t[4]!==s||t[5]!==n?(c=(0,z.jsx)(`li`,{children:(0,z.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":r,className:s,children:n})}),t[3]=r,t[4]=s,t[5]=n,t[6]=c):c=t[6],c}function F7(e){return!e}function I7(e){let t=(0,G.c)(11),{reminders:n}=e,[r,i]=(0,R.useState)(!1),a=c6();if(n.length===0)return null;let o;t[0]!==n.length||t[1]!==a?(o=a(`message.reminders`,{count:n.length}),t[0]=n.length,t[1]=a,t[2]=o):o=t[2];let s=o,c;t[3]===n?c=t[4]:(c=n.map(L7),t[3]=n,t[4]=c);let l;t[5]===c?l=t[6]:(l=(0,z.jsx)(`ul`,{className:`border-ink-12 text-muted-foreground space-y-1 border-l pl-3 text-xs`,children:c}),t[5]=c,t[6]=l);let u;return t[7]!==s||t[8]!==r||t[9]!==l?(u=(0,z.jsx)(k7,{label:s,open:r,onOpenChange:i,className:`mt-1`,triggerClassName:`text-muted-foreground hover:text-foreground gap-1.5 text-xs`,contentClassName:`mt-1.5`,chevronClassName:`size-3.5`,children:l}),t[7]=s,t[8]=r,t[9]=l,t[10]=u):u=t[10],u}function L7(e){return(0,z.jsx)(P7,{text:e.text},e.id)}function R7(e){let t=(0,G.c)(19),{upload:n}=e;if(n.mediaType.startsWith(`video/`)){let e;t[0]!==n.name||t[1]!==n.url?(e=(0,z.jsx)(`video`,{src:n.url,"aria-label":n.name,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`}),t[0]=n.name,t[1]=n.url,t[2]=e):e=t[2];let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-2xl text-white drop-shadow`,children:`▶`}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==n.name?(i=(0,z.jsxs)(Xi,{variant:`image`,className:`size-36 rounded-2xl`,title:n.name,children:[e,r]}),t[4]=e,t[5]=n.name,t[6]=i):i=t[6],i}if(n.mediaType.startsWith(`audio/`)){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-2xl`,children:`♪`}),t[7]=e):e=t[7];let r;t[8]===n.name?r=t[9]:(r=(0,z.jsx)(`span`,{className:`text-foreground w-full truncate text-center`,children:n.name}),t[8]=n.name,t[9]=r);let i;t[10]===n.mediaType?i=t[11]:(i=(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:n.mediaType}),t[10]=n.mediaType,t[11]=i);let a;return t[12]!==r||t[13]!==i||t[14]!==n.name?(a=(0,z.jsxs)(Xi,{variant:`icon`,className:`h-36 w-48 flex-col gap-1 rounded-2xl px-3 text-xs`,title:n.name,"aria-label":n.name,children:[e,r,i]}),t[12]=r,t[13]=i,t[14]=n.name,t[15]=a):a=t[15],a}let r;return t[16]!==n.name||t[17]!==n.url?(r=(0,z.jsx)(Xi,{variant:`image`,className:`size-36 rounded-2xl`,children:(0,z.jsx)(`img`,{src:n.url,alt:n.name})}),t[16]=n.name,t[17]=n.url,t[18]=r):r=t[18],r}function z7(e){let t=(0,G.c)(6),{message:n}=e,r=N7(n),i=c6();if(r.length===0)return null;let a=Zi,o;t[0]===i?o=t[1]:(o=i(`message.attachments`),t[0]=i,t[1]=o);let s=r.map(B7),c;return t[2]!==a||t[3]!==o||t[4]!==s?(c=(0,z.jsx)(a,{role:`list`,"aria-label":o,className:`max-w-full gap-2 py-0`,children:s}),t[2]=a,t[3]=o,t[4]=s,t[5]=c):c=t[5],c}function B7(e){return(0,z.jsx)(`div`,{role:`listitem`,"data-slot":`attachment`,children:(0,z.jsx)(R7,{upload:e})},e.path)}function V7(e){let t=(0,G.c)(10),{body:n,reminders:r,metadata:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`div`,{className:`flex-1 space-y-3`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,z.jsx)(I7,{reminders:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i!==void 0&&(0,z.jsx)(A7,{metadata:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,z.jsxs)(`div`,{className:`bg-secondary flex max-w-[80%] flex-col gap-3 rounded-lg p-3`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function H7(e){let t=(0,G.c)(28),{message:n}=e;j7(n,`reminders`);let r;t[0]===n?r=t[1]:(r=See(n),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=M7(n),t[2]=n,t[3]=i);let a;t[4]!==r||t[5]!==i?(a={message:r,reminders:i},t[4]=r,t[5]=i,t[6]=a):a=t[6];let{message:o,reminders:s}=a,c;if(t[7]!==n){let e=j7(n,`alias`);c=typeof e==`string`&&e.trim().length>0?e:void 0,t[7]=n,t[8]=c}else c=t[8];let l=c;if(l){let e;t[9]===l?e=t[10]:(e=(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:l}),t[9]=l,t[10]=e);let n;return t[11]!==s||t[12]!==e?(n=(0,z.jsx)(V7,{reminders:s,body:e}),t[11]=s,t[12]=e,t[13]=n):n=t[13],n}let u;t[14]===o?u=t[15]:(u=(0,z.jsx)(z7,{message:o}),t[14]=o,t[15]=u);let d=o.metadata,f;if(t[16]!==o.id||t[17]!==o.parts){let e;t[19]===o.id?e=t[20]:(e=(e,t)=>e.type===`text`?(0,z.jsx)(`div`,{dir:`auto`,className:`text-sm whitespace-pre-wrap`,children:(0,z.jsx)(u4,{text:e.text})},`${o.id}-${t}-text`):null,t[19]=o.id,t[20]=e),f=o.parts.map(e),t[16]=o.id,t[17]=o.parts,t[18]=f}else f=t[18];let p;t[21]!==o.metadata||t[22]!==s||t[23]!==f?(p=(0,z.jsx)(V7,{reminders:s,metadata:d,body:f}),t[21]=o.metadata,t[22]=s,t[23]=f,t[24]=p):p=t[24];let m;return t[25]!==u||t[26]!==p?(m=(0,z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-3`,children:[u,p]}),t[25]=u,t[26]=p,t[27]=m):m=t[27],m}var U7=(0,R.memo)(function(e){let t=(0,G.c)(7),{className:n}=e,{message:r}=U6(),i;t[0]===n?i=t[1]:(i=I(`flex justify-end`,n),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,z.jsx)(H7,{message:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o});function W7(e){return e.kind===`tool`?!r5(e.part):e.kind===`dynamic-tool`||e.kind===`reasoning`}function G7(e,t){return e.kind===`tool`?!0:e.kind===`reasoning`||e.kind===`dynamic-tool`?!!t:!1}function K7(e){return e.kind===`text`&&e.parts.some(({part:e})=>e.type===`text`&&!M5(e))}function q7(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!W7(i)){n.push({kind:`segment`,segment:i,segmentIndex:r});continue}let a=[],o=r;for(;r<e.length&&W7(e[r]);){let n=e[r];G7(n,t)&&a.push({segment:n}),r++}r--,a.length>0&&n.push({kind:`group`,items:a,hasLaterText:e.slice(r+1).some(e=>K7(e)),firstIndex:o})}return n}function J7(e){if(e.kind!==`tool`&&e.kind!==`dynamic-tool`)return;let{part:t}=e;return kv(t)?t.state:void 0}function Y7({groupStatus:e,labelCount:t}){return e===`running`?{title:`text-info`,detail:`text-info/80`,chevron:`text-info`}:e===`aborted`?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:e===`error`?t===1?{title:`text-destructive`,detail:`text-destructive/80`,chevron:`text-destructive`}:{title:`text-warning`,detail:`text-warning/80`,chevron:`text-warning`}:{title:`text-muted-foreground`,detail:`text-muted-foreground`,chevron:`text-muted-foreground`}}function X7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z7(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-3).trimEnd()}...`}function Q7(e){if(typeof e==`string`)return Z7(e,48);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`${e.length} items`}function $7(e){if(!X7(e))return;let t=[`command`,`query`,`path`,`file`,`table`,`metric`,`dimension`,`checks`],n=[...t.filter(t=>t in e).map(t=>[t,e[t]]),...Object.entries(e).filter(([e])=>!t.includes(e))],r={};for(let[e,t]of n){let n=Q7(t);if(n&&(r[e]=n,Object.keys(r).length>=2))break}return Object.keys(r).length>0?r:void 0}function e9(e){if(X7(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim().length>0)return Z7(n)}}function t9(e){if(e.kind!==`reasoning`)return;let{part:t}=e;if(t.type===`reasoning`)return Z7(t.text,96)}function n9(e,t,n){if(e.kind===`reasoning`)return{form:`call`,kind:`reasoning`,name:`reasoning`,detail:t9(e)};if(e.kind===`dynamic-tool`&&e.part.type===`dynamic-tool`){let t=e.part;return{form:`call`,kind:`dynamic-tool`,name:t.toolName||n(`steps.unnamedTool`),args:$7(t.input),detail:e9(t.input)}}if(e.kind===`tool`&&Dv(e.part)){let n=e.part,{toolEntry:r,toolKey:i}=i5(n,t),a=r?.label?.(n);return a?.kind===`sentence`?{form:`sentence`,kind:`tool`,text:a.text,detail:a.detail,isError:a.isError}:{form:`call`,kind:`tool`,name:a?.name??i,args:a?.args??$7(n.input),detail:a?.detail??e9(n.input),isError:a?.isError}}return{form:`call`,kind:`tool`,name:n(`steps.unknownStep`)}}function r9(e){if(!e)return;let t=Object.entries(e).filter(e=>typeof e[1]==`string`&&e[1].trim().length>0);if(t.length!==0)return t.slice(0,2).map(([e,t])=>`${e}: ${Z7(t,36)}`).join(`, `)}function i9(e){let t=r9(e.args);return t?`${e.name}(${t})`:e.name}function a9(e){return e===`output-available`||e===`output-error`||e===`output-denied`}function o9(e){return!!e&&!a9(e)}function s9(e,t){return N6(e,t)}function c9({items:e,labels:t,status:n,hasLaterText:r}){return e.some(({segment:e})=>s9(J7(e),n))?`aborted`:!r&&(n===`streaming`||n===`submitted`)?`running`:t.some(e=>e.isError)||e.some(({segment:e})=>{let t=J7(e);return t===`output-error`||t===`output-denied`})?`error`:e.some(({segment:e})=>o9(J7(e)))||!r&&t.every(e=>e.kind===`reasoning`)&&(n===`streaming`||n===`submitted`)?`running`:`complete`}function l9(e){return e.filter(e=>e.kind!==`reasoning`).length}function u9(e){let t=e.findLast(e=>e.kind!==`reasoning`);return t?.form===`sentence`?t:void 0}function d9(e,t,n,r){let i=e.length===1?e[0]:void 0;return t===`running`?r||(i?.kind===`reasoning`?n(`steps.reasoning`,{detail:i.detail}):e.every(e=>e.kind===`reasoning`)?n(`steps.reasoning`,{detail:void 0}):n(`steps.working`)):i?.form===`call`?i.kind===`reasoning`&&t===`complete`?n(`steps.reasoned`,{detail:i.detail}):n(`steps.call`,{call:i9(i),status:t}):e.every(e=>e.kind===`reasoning`)?n(`steps.reasoned`,{detail:void 0}):n(`steps.tools`,{count:l9(e),status:t})}function f9(e,t){if(t!==`running`){if(e.length===1){let t=e[0];return t.kind===`reasoning`?void 0:t.detail}return Array.from(new Set([...e].sort((e,t)=>e.kind===`reasoning`&&t.kind!==`reasoning`?1:e.kind!==`reasoning`&&t.kind===`reasoning`?-1:0).map(e=>e.form===`sentence`?e.text:e.name))).slice(0,3).join(`, `)||void 0}}function p9(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].segment;if(r.kind===`dynamic-tool`&&r.part.type===`dynamic-tool`){let e=e9(r.part.input);if(e)return e}if(r.kind===`tool`&&Dv(r.part)){let e=e9(r.part.input);if(e)return e}r.kind===`reasoning`&&(t??=t9(r))}return t}function m9(e,t){return!e||e.role!==`assistant`?!1:q7(J5(e.parts),t).some(e=>e.kind===`group`&&!e.hasLaterText)}function h9(){let e=(0,G.c)(8),{message:t}=U6(),{debugMode:n}=T6(),r;e[0]===t.parts?r=e[1]:(r=J5(t.parts),e[0]=t.parts,e[1]=r);let i=r,a;if(e[2]!==n||e[3]!==t.id||e[4]!==i){let r;e[6]===t.id?r=e[7]:(r=e=>e.kind===`group`?{...e,key:`${t.id}-${e.firstIndex}-group-${e.hasLaterText?`past`:`current`}`}:{...e,key:`${t.id}-${Y5(e.segment,e.segmentIndex)}-${e.segment.kind}`},e[6]=t.id,e[7]=r),a=q7(i,n).map(r),e[2]=n,e[3]=t.id,e[4]=i,e[5]=a}else a=e[5];return a}var g9=(0,R.createContext)(null);function _9(){let e=(0,R.use)(g9);if(!e)throw Error(`CompactTrajectory group parts must be rendered within CompactTrajectory.Group`);return e}function v9(e){let t=(0,G.c)(23),{group:n,children:r}=e,{registry:i}=T6(),{message:a}=U6(),o=H6(),s=c6(),[c,l]=(0,R.useState)(!n.hasLaterText),u,d,f;if(t[0]!==n.hasLaterText||t[1]!==n.items||t[2]!==i||t[3]!==o||t[4]!==s){let e;t[8]!==i||t[9]!==s?(e=e=>{let{segment:t}=e;return n9(t,i,s)},t[8]=i,t[9]=s,t[10]=e):e=t[10],d=n.items.map(e),u=c9({items:n.items,labels:d,status:o,hasLaterText:n.hasLaterText}),f=Y7({groupStatus:u,labelCount:d.length}),t[0]=n.hasLaterText,t[1]=n.items,t[2]=i,t[3]=o,t[4]=s,t[5]=u,t[6]=d,t[7]=f}else u=t[5],d=t[6],f=t[7];let p=f,m;t[11]!==n.items||t[12]!==u||t[13]!==d||t[14]!==a.id||t[15]!==p?(m={items:n.items,labels:d,groupStatus:u,tone:p,messageId:a.id},t[11]=n.items,t[12]=u,t[13]=d,t[14]=a.id,t[15]=p,t[16]=m):m=t[16];let h;t[17]!==r||t[18]!==c?(h=(0,z.jsx)(Ia,{open:c,onOpenChange:l,className:`my-2 min-w-0`,children:r}),t[17]=r,t[18]=c,t[19]=h):h=t[19];let g;return t[20]!==m||t[21]!==h?(g=(0,z.jsx)(g9,{value:m,children:h}),t[20]=m,t[21]=h,t[22]=g):g=t[22],g}function y9(e){let t=(0,G.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`button`,{type:`button`,className:R6(`items-start`)}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,z.jsx)(La,{render:r,children:(0,z.jsx)(`span`,{className:`min-w-0 flex-1 text-start text-sm`,children:n})}),t[1]=n,t[2]=i),i}function b9(){let e=(0,G.c)(21),{items:t,labels:n,groupStatus:r,tone:i}=_9(),a=c6(),o;e[0]===n?o=e[1]:(o=u9(n),e[0]=n,e[1]=o);let s=o;if(s){let t=l9(n)-1,a=t>0?t:void 0,o;return e[2]!==r||e[3]!==s.detail||e[4]!==s.text||e[5]!==a||e[6]!==i?(o={title:s.text,more:a,detail:s.detail,isSentence:!0,tone:i,groupStatus:r},e[2]=r,e[3]=s.detail,e[4]=s.text,e[5]=a,e[6]=i,e[7]=o):o=e[7],o}let c;e[8]!==r||e[9]!==t||e[10]!==n||e[11]!==a?(c=d9(n,r,a,p9(t)),e[8]=r,e[9]=t,e[10]=n,e[11]=a,e[12]=c):c=e[12];let l=c,u;e[13]!==r||e[14]!==n?(u=f9(n,r),e[13]=r,e[14]=n,e[15]=u):u=e[15];let d=u,f;return e[16]!==d||e[17]!==r||e[18]!==l||e[19]!==i?(f={title:l,more:void 0,detail:d,isSentence:!1,tone:i,groupStatus:r},e[16]=d,e[17]=r,e[18]=l,e[19]=i,e[20]=f):f=e[20],f}function x9(e){let t=(0,G.c)(14),{title:n,suffix:r,children:i}=e,a=b9(),{tone:o,groupStatus:s}=a,c=n===void 0,l=n??a.title,u=r?`${l} · ${r}`:l,d=c?a.more:void 0,f=s===`running`?`text-info`:o.title,p=c&&a.isSentence?`auto`:void 0,m=s===`running`,h;t[0]===f?h=t[1]:(h=I(`max-w-full min-w-0 truncate`,f),t[0]=f,t[1]=h);let g;t[2]!==p||t[3]!==m||t[4]!==h||t[5]!==u?(g=(0,z.jsx)(I6,{as:`span`,dir:p,enabled:m,className:h,children:u}),t[2]=p,t[3]=m,t[4]=h,t[5]=u,t[6]=g):g=t[6];let _;t[7]!==d||t[8]!==f?(_=d!==void 0&&(0,z.jsxs)(`span`,{dir:`ltr`,className:I(`shrink-0 tabular-nums`,f),children:[`+`,d]}),t[7]=d,t[8]=f,t[9]=_):_=t[9];let v;return t[10]!==i||t[11]!==g||t[12]!==_?(v=(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[g,_,i]}),t[10]=i,t[11]=g,t[12]=_,t[13]=v):v=t[13],v}function S9(){let e=(0,G.c)(2),{tone:t}=_9(),n;return e[0]===t.chevron?n=e[1]:(n=(0,z.jsx)(L6,{className:t.chevron}),e[0]=t.chevron,e[1]=n),n}function Iee(e){let t=(0,G.c)(6),{detail:n}=e,{title:r,detail:i,isSentence:a,tone:o}=b9();if(n===null)return null;let s=n??i;if(!s||s===r)return null;let c=n===void 0&&a?`auto`:void 0,l;t[0]===o.detail?l=t[1]:(l=I(`block truncate text-start text-xs`,o.detail),t[0]=o.detail,t[1]=l);let u;return t[2]!==s||t[3]!==c||t[4]!==l?(u=(0,z.jsx)(`span`,{dir:c,className:l,children:s}),t[2]=s,t[3]=c,t[4]=l,t[5]=u):u=t[5],u}function Lee(e){let t=(0,G.c)(14),{children:n}=e,{items:r,messageId:i,groupStatus:a}=_9(),o=a===`running`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={initial:`instant`,resize:`instant`},t[0]=s):s=t[0];let{scrollRef:c,contentRef:l}=Aj(s),u=o?c:void 0,d=o&&`max-h-64 overflow-y-auto`,f;t[1]===d?f=t[2]:(f=I(`mt-2`,d),t[1]=d,t[2]=f);let p=o?l:void 0,m;t[3]!==n||t[4]!==r||t[5]!==i?(m=n??r.map((e,t)=>{let{segment:n}=e,r=`${i}-${Y5(n,t)}-${n.kind}`;return n.kind===`tool`?(0,z.jsx)(W5.Tool,{segment:n},r):n.kind===`reasoning`?(0,z.jsx)(W5.Reasoning,{segment:n},r):n.kind===`dynamic-tool`?(0,z.jsx)(W5.DynamicTool,{segment:n},r):null}),t[3]=n,t[4]=r,t[5]=i,t[6]=m):m=t[6];let h;t[7]!==p||t[8]!==m?(h=(0,z.jsx)(`div`,{ref:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;return t[10]!==u||t[11]!==f||t[12]!==h?(g=(0,z.jsx)(Ra,{ref:u,className:f,children:h}),t[10]=u,t[11]=f,t[12]=h,t[13]=g):g=t[13],g}function Ree(e){let t=(0,G.c)(19),{item:n,textClassName:r}=e,i=r===void 0?`my-4`:r,{elements:a}=V6(),{segment:o}=n;if(o.kind===`text`){let e;t[0]===o.parts?e=t[1]:(e=o.parts.filter(zee),t[0]=o.parts,t[1]=e);let n=e;if(n.length===0)return null;let r;t[2]!==o||t[3]!==n?(r={...o,parts:n},t[2]=o,t[3]=n,t[4]=r):r=t[4];let s;return t[5]!==a||t[6]!==r||t[7]!==i?(s=(0,z.jsx)(W5.Text,{segment:r,elements:a,className:i}),t[5]=a,t[6]=r,t[7]=i,t[8]=s):s=t[8],s}if(o.kind===`file`){let e;return t[9]===o?e=t[10]:(e=(0,z.jsx)(W5.File,{segment:o}),t[9]=o,t[10]=e),e}if(o.kind===`source`){let e;return t[11]===o?e=t[12]:(e=(0,z.jsx)(W5.Source,{segment:o}),t[11]=o,t[12]=e),e}if(o.kind===`tool`){let e;return t[13]===o?e=t[14]:(e=(0,z.jsx)(W5.Tool,{segment:o}),t[13]=o,t[14]=e),e}if(o.kind===`reasoning`){let e;return t[15]===o?e=t[16]:(e=(0,z.jsx)(W5.Reasoning,{segment:o}),t[15]=o,t[16]=e),e}if(o.kind===`dynamic-tool`){let e;return t[17]===o?e=t[18]:(e=(0,z.jsx)(W5.DynamicTool,{segment:o}),t[17]=o,t[18]=e),e}return null}function zee(e){let{part:t}=e;return!M5(t)}function Bee(){let e=(0,G.c)(1),t=H6(),{messages:n}=V6(),{debugMode:r}=T6(),i=n[n.length-1];if(t!==`ready`&&t!==`error`&&m9(i,r))return null;let a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(m7,{}),e[0]=a):a=e[0],a}var C9={Root:a7,List:o7,Item:s7,UserBubble:U7,AssistantContent:(0,R.memo)(function(e){let t=(0,G.c)(5),{className:n}=e,r=h9(),i;t[0]===r?i=t[1]:(i=r.map(Vee),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}),Actions:$5,CopyAction:e7,RegenerateAction:t7,CopyDebugJsonAction:n7,Thinking:Bee,Error:i7};function Vee(e){return e.kind===`group`?(0,z.jsxs)(v9,{group:e,children:[(0,z.jsxs)(y9,{children:[(0,z.jsx)(x9,{children:(0,z.jsx)(S9,{})}),(0,z.jsx)(Iee,{})]}),(0,z.jsx)(Lee,{})]},e.key):(0,z.jsx)(Ree,{item:e},e.key)}function Hee(e){let t=(0,G.c)(8),{message:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`text-destructive/90 bg-destructive/10 flex items-start gap-2 rounded-md px-3 py-2 text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(_t,{className:`text-destructive mt-0.5 size-4 shrink-0`}),t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=(0,z.jsx)(`span`,{children:n}),t[3]=n,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s=(0,z.jsxs)(`div`,{className:i,children:[a,o]}),t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function Uee(e){let t=(0,G.c)(9),{name:n,args:r}=e,i;t[0]===r?i=t[1]:(i=r?Object.values(r)[0]:void 0,t[0]=r,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=(0,z.jsx)(`span`,{className:`ms-2 font-mono`,children:n}),t[2]=n,t[3]=o);let s;t[4]===a?s=t[5]:(s=a&&(0,z.jsxs)(`span`,{className:`truncate`,children:[`(`,a,`)`]}),t[4]=a,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,z.jsxs)(z.Fragment,{children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Wee(e){let t=(0,G.c)(15),{part:n}=e,r=T6(),i,a;if(t[0]!==r.registry||t[1]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let{toolEntry:e}=i5(n,r.registry);if(e&&a5(e,n.state)){let t=e.label?.(n);if(!t){a=null;break bb0}let r=t.icon;a=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center text-xs`,children:[r&&(0,z.jsx)(r,{className:`size-3.5`}),t.kind===`sentence`?(0,z.jsx)(`span`,{dir:`auto`,className:`ms-2 truncate text-start`,children:t.text}):(0,z.jsx)(Uee,{name:t.name,args:t.args})]});break bb0}i=e?.label?.(n)}t[0]=r.registry,t[1]=n,t[2]=i,t[3]=a}else i=t[2],a=t[3];if(a!==Symbol.for(`react.early_return_sentinel`))return a;let o=i,s;t[4]!==o||t[5]!==n?(s=o&&(0,z.jsx)(O5,{label:o,part:n}),t[4]=o,t[5]=n,t[6]=s):s=t[6];let c;t[7]===o?c=t[8]:(c=o?.isError&&o.detail&&(0,z.jsx)(Hee,{message:o.detail}),t[7]=o,t[8]=c);let l;t[9]===n?l=t[10]:(l=(0,z.jsx)(w5,{part:n}),t[9]=n,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,z.jsxs)(z.Fragment,{children:[s,c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function Gee(e){let t=(0,G.c)(5),{part:n}=e,[r,i]=(0,R.useState)(!1),a;t[0]===n.text?a=t[1]:(a=(0,z.jsx)(I8,{mode:`static`,children:n.text}),t[0]=n.text,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,z.jsx)(`div`,{"data-copy-exclude":`assistant-snapshot`,className:`bg-muted/30 prose max-w-auto prose-sm text-muted-foreground border-border mb-4 w-full min-w-full rounded-lg p-3`,children:(0,z.jsx)(k7,{label:`Reasoning`,open:r,onOpenChange:i,className:`text-xs`,triggerClassName:`w-full gap-x-2 text-sm hover:opacity-80`,contentClassName:`mt-2`,children:a})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function Kee(e){let t=(0,G.c)(16),{part:n}=e,{elements:r}=V6(),i=T5();if(n.type===`text`){if(M5(n))return null;let e;return t[0]!==r||t[1]!==n.citations||t[2]!==n.text?(e=(0,z.jsx)(C5,{text:n.text,citations:n.citations,elements:r}),t[0]=r,t[1]=n.citations,t[2]=n.text,t[3]=e):e=t[3],e}if(n.type===`dynamic-tool`){let e;return t[4]!==i||t[5]!==n?(e=i?(0,z.jsx)(X8,{part:n}):null,t[4]=i,t[5]=n,t[6]=e):e=t[6],e}if(Dv(n)){let e;return t[7]===n?e=t[8]:(e=(0,z.jsx)(Wee,{part:n}),t[7]=n,t[8]=e),e}if(n.type===`reasoning`&&n.text){let e;return t[9]!==i||t[10]!==n?(e=i?(0,z.jsx)(Gee,{part:n}):null,t[9]=i,t[10]=n,t[11]=e):e=t[11],e}if(n.type===`file`){let e;return t[12]!==n.filename||t[13]!==n.mediaType||t[14]!==n.url?(e=(0,z.jsx)(_5,{filename:n.filename,mediaType:n.mediaType,url:n.url}),t[12]=n.filename,t[13]=n.mediaType,t[14]=n.url,t[15]=e):e=t[15],e}return null}(0,R.memo)(function(e){let t=(0,G.c)(10),{className:n}=e,{message:r}=U6(),i;t[0]===n?i=t[1]:(i=I(`flex-1 space-y-3`,n),t[0]=n,t[1]=i);let a;if(t[2]!==r.id||t[3]!==r.parts){let e;t[5]===r.id?e=t[6]:(e=(e,t)=>(0,z.jsx)(Kee,{part:e},`${r.id}-${t}`),t[5]=r.id,t[6]=e),a=r.parts.map(e),t[2]=r.id,t[3]=r.parts,t[4]=a}else a=t[4];let o;return t[7]!==i||t[8]!==a?(o=(0,z.jsx)(`div`,{className:i,children:a}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o});var qee={braille:{frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},pulse:{frames:[`⠁`,`⠉`,`⠋`,`⠛`,`⠟`,`⠿`,`⡿`,`⣿`,`⡿`,`⠿`,`⠟`,`⠛`,`⠋`,`⠉`,`⠁`,`⠀`],interval:80},clock:{frames:[`⠁`,`⠈`,`⠐`,`⠠`,`⢀`,`⡀`,`⠄`,`⠂`],interval:100},limerence:{frames:[`⠁`,`⠃`,`⠇`,`⡇`,`⣇`,`⣇`,`⣆`,`⣄`,`⣀`,`⢀`,`⠀`],interval:100}};function Jee(e){let t=(0,G.c)(18),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`braille`:i,o=un(),s=c6(),{frames:c,interval:l}=qee[a],[u,d]=(0,R.useState)(0),f,p;t[4]!==o||t[5]!==c.length||t[6]!==l?(f=()=>{if(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=o.setInterval(()=>{d(e=>(e+1)%c.length)},l);return()=>o.clearInterval(e)},p=[o,c.length,l],t[4]=o,t[5]=c.length,t[6]=l,t[7]=f,t[8]=p):(f=t[7],p=t[8]),(0,R.useEffect)(f,p);let m;t[9]===s?m=t[10]:(m=s(`status.loading`),t[9]=s,t[10]=m);let h;t[11]===n?h=t[12]:(h=I(`inline-block`,n),t[11]=n,t[12]=h);let g=c[u],_;return t[13]!==r||t[14]!==m||t[15]!==h||t[16]!==g?(_=(0,z.jsx)(`span`,{role:`status`,"aria-label":m,className:h,...r,children:g}),t[13]=r,t[14]=m,t[15]=h,t[16]=g,t[17]=_):_=t[17],_}function Yee(e){let t=(0,G.c)(11),{Icon:n,isLast:r,isLoading:i,aborted:a,state:o,isError:s}=e,c;t[0]!==n||t[1]!==a||t[2]!==s||t[3]!==i||t[4]!==o?(c=i?(0,z.jsx)(Jee,{className:`text-muted-foreground z-10 shrink-0 text-sm`}):a?(0,z.jsx)(Yn,{className:`text-destructive z-10 size-3.5 shrink-0`}):(0,z.jsx)(n,{className:I(`z-10 size-3.5 shrink-0`,o===`output-error`||s?`text-destructive`:`text-muted-foreground`)}),t[0]=n,t[1]=a,t[2]=s,t[3]=i,t[4]=o,t[5]=c):c=t[5];let l;t[6]===r?l=t[7]:(l=!r&&(0,z.jsx)(`span`,{className:`bg-border w-px flex-1`}),t[6]=r,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`absolute top-0 left-0 flex h-full flex-col items-center`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function Xee(e){let t=(0,G.c)(15),{isLast:n,label:r,state:i,aborted:a,children:o}=e,s=(0,R.use)(z5),c=r??s?.label,l=i??s?.state,u=a??s?.aborted??!1,d=c?.icon,f=!!l&&!u&&l!==`output-available`&&l!==`output-error`,p;t[0]!==d||t[1]!==u||t[2]!==c?.isError||t[3]!==l||t[4]!==n||t[5]!==f?(p=d?(0,z.jsx)(Yee,{Icon:d,isLast:n,isLoading:f,aborted:u,state:l,isError:c?.isError??!1}):(0,z.jsx)(f7,{isLast:n}),t[0]=d,t[1]=u,t[2]=c?.isError,t[3]=l,t[4]=n,t[5]=f,t[6]=p):p=t[6];let m=p,h=n?``:`pb-3.5`,g;t[7]===h?g=t[8]:(g=I(`min-w-0 flex-1`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,z.jsx)(`div`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;return t[12]!==m||t[13]!==_?(v=(0,z.jsx)(p7,{marker:m,children:_}),t[12]=m,t[13]=_,t[14]=v):v=t[14],v}function Zee(e){let t=(0,G.c)(10),{label:n,state:r,part:i,defaultOpen:a,children:o}=e,s=a!==void 0&&a,c;t[0]!==n||t[1]!==i||t[2]!==r?(c=(0,z.jsx)(La,{className:`cursor-pointer`,children:(0,z.jsx)(A5,{label:n,state:r,part:i})}),t[0]=n,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,z.jsx)(Ra,{children:o}),t[4]=o,t[5]=l);let u;return t[6]!==s||t[7]!==c||t[8]!==l?(u=(0,z.jsxs)(Ia,{defaultOpen:s,className:`flex min-w-0 flex-1 flex-col`,children:[c,l]}),t[6]=s,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}var w9={Item:Xee,Disclosure:Zee};(0,R.memo)(function(e){let t=(0,G.c)(13),{className:n}=e,{message:r}=U6(),{elements:i}=V6(),{debugMode:a}=T6(),o=T5(),s=n5(),c=c6(),l;t[0]===r.parts?l=t[1]:(l=J5(r.parts),t[0]=r.parts,t[1]=l);let u=l,d;t[2]!==a||t[3]!==i||t[4]!==s||t[5]!==r.id||t[6]!==u||t[7]!==o||t[8]!==c?(d=u.map((e,t)=>{let n=`${r.id}-${Y5(e,t)}-${e.kind}`;if(e.kind===`text`)return(0,z.jsx)(W5.Text,{segment:e,elements:i,className:`my-4`},n);if(e.kind===`file`)return(0,z.jsx)(W5.File,{segment:e},n);if(e.kind===`source`)return(0,z.jsx)(W5.Source,{segment:e},n);if(e.kind===`dynamic-tool`){if(!o)return null;let r=!q5(u,t,!0);return(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(W5.DynamicTool,{segment:e})},n)}if(e.kind===`reasoning`){if(s||e.part.type!==`reasoning`)return null;let r=!q5(u,t,a),i={name:c(`steps.reasoning`,{detail:void 0}),icon:ci,args:{text:[...e.part.text].slice(0,60).join(``)}};return(0,z.jsx)(w9.Item,{isLast:r,label:i,children:(0,z.jsx)(w9.Disclosure,{label:i,children:(0,z.jsx)(W5.Reasoning,{segment:e})})},n)}if(e.kind===`tool`){let r=!q5(u,t,a);return(0,z.jsx)(W5.Tool,{segment:e,children:(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(W5.ToolDisclosure,{})})},n)}return null}),t[2]=a,t[3]=i,t[4]=s,t[5]=r.id,t[6]=u,t[7]=o,t[8]=c,t[9]=d):d=t[9];let f;return t[10]!==n||t[11]!==d?(f=(0,z.jsx)(`div`,{className:n,children:d}),t[10]=n,t[11]=d,t[12]=f):f=t[12],f});function Qee(e){let t=(0,G.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{hasSubmitted:i}=D6(),a;t[3]===n?a=t[4]:(a=I(`bg-background sticky bottom-0 rounded-t-2xl border-0 **:data-[slot=composer-editor]:!min-h-15`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==r||t[7]!==a?(o=(0,z.jsx)(c4.Root,{hasInteracted:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function $ee(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`border-border bg-card focus-within:border-primary/80 focus-within:ring-primary/15 relative rounded-2xl border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ete(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`space-y-1 px-3.5 pt-3`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Content,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tte(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`!min-h-15 !rounded-none !border-0 !bg-transparent !shadow-none **:data-[slot=composer-editor]:!p-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Editor,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nte(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`pb-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Attachments,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rte(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=I(`p-1.5 pt-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,z.jsx)(c4.Toolbar,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ite(e){let t=(0,G.c)(6),n=c6(),r;t[0]===n?r=t[1]:(r=n(`composer.attachFiles`),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(Z5,{icon:(0,z.jsx)(bi,{className:`size-4`})}),t[2]=i):i=t[2];let a;return t[3]!==e||t[4]!==r?(a=(0,z.jsx)(c4.AttachFiles,{"aria-label":r,render:i,...e}),t[3]=e,t[4]=r,t[5]=a):a=t[5],a}function ate(){let e=(0,G.c)(9),{actions:t,meta:n}=qQ(`ChatComposer.CommandButton`),r=c6(),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,z.jsx)(Si,{className:`size-4`}),e[0]=i):i=e[0];let a;e[1]===r?a=e[2]:(a=r(`composer.commandMenu`),e[1]=r,e[2]=a);let o=n.activePopup?.trigger===`/`,s;e[3]===t?s=e[4]:(s=e=>{e.stopPropagation(),t.toggleSlashMenu()},e[3]=t,e[4]=s);let c;return e[5]!==a||e[6]!==o||e[7]!==s?(c=(0,z.jsx)(Z5,{"data-command-button":!0,icon:i,"aria-label":a,"aria-expanded":o,onClick:s}),e[5]=a,e[6]=o,e[7]=s,e[8]=c):c=e[8],c}function ote(e,t){switch(e){case`permission-denied`:return t(`dictation.permissionDenied`);case`no-microphone`:return t(`dictation.noMicrophone`);case`microphone-in-use`:return t(`dictation.microphoneInUse`);case`interrupted`:return t(`dictation.interrupted`);case`transcription-failed`:return t(`dictation.transcriptionFailed`)}}function ste(e,t){switch(e.status){case`unavailable`:return e.reason===`blocked`?t(`dictation.blocked`):t(`dictation.unsupported`);case`idle`:return t(`dictation.start`);case`starting`:return t(`dictation.starting`);case`recording`:return t(`dictation.stop`);case`finishing`:return t(`dictation.transcribing`);case`failed`:return ote(e.error.code,t)}}function cte(e){switch(e.status){case`recording`:return(0,z.jsx)(Ei,{className:`size-4 fill-current`});case`starting`:case`finishing`:return(0,z.jsx)(me,{className:`size-4 animate-spin`});case`unavailable`:case`idle`:case`failed`:return(0,z.jsx)(mi,{className:`size-4`})}}function lte(){let e=(0,G.c)(22),{status:t}=E6(),{state:n}=Y1(`ChatComposer.Dictate`),r=c6(),i;e[0]!==n||e[1]!==r?(i=ste(n,r),e[0]=n,e[1]=r,e[2]=i):i=e[2];let a=i,o=n.status===`starting`||n.status===`recording`||n.status===`finishing`,s=t===`streaming`||t===`submitted`,c;e[3]===n?c=e[4]:(c=cte(n),e[3]=n,e[4]=c);let l;e[5]!==a||e[6]!==c?(l=(0,z.jsx)(Z5,{icon:c,"aria-label":a,title:a}),e[5]=a,e[6]=c,e[7]=l):l=e[7];let u;e[8]!==s||e[9]!==l?(u=(0,z.jsx)(c4.Dictate,{disabled:s,render:l}),e[8]=s,e[9]=l,e[10]=u):u=e[10];let d;e[11]!==o||e[12]!==n.status||e[13]!==r?(d=o?(0,z.jsx)(c4.CancelDictation,{render:(0,z.jsx)(Z5,{icon:(0,z.jsx)(ye,{className:`size-4`}),"aria-label":r(n.status===`finishing`?`dictation.cancelTranscription`:`dictation.cancel`)})}):null,e[11]=o,e[12]=n.status,e[13]=r,e[14]=d):d=e[14];let f;e[15]!==a||e[16]!==n.status?(f=n.status===`failed`?(0,z.jsx)(`span`,{role:`status`,className:`text-destructive max-w-48 truncate text-xs`,children:a}):null,e[15]=a,e[16]=n.status,e[17]=f):f=e[17];let p;return e[18]!==u||e[19]!==d||e[20]!==f?(p=(0,z.jsxs)(z.Fragment,{children:[u,d,f]}),e[18]=u,e[19]=d,e[20]=f,e[21]=p):p=e[21],p}var T9={Provider:Qee,Root:$ee,Popup:c4.Popup,Content:ete,Attachments:nte,Editor:tte,Error:c4.Error,Toolbar:rte,CommandButton:ate,AttachFiles:ite,Dictate:lte};function ute(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`border-border flex flex-col border-b px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function dte(e){let t=(0,G.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`flex items-center gap-2 px-2 py-1.5`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,z.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function fte(e){let t=(0,G.c)(4),{className:n}=e,r;t[0]===n?r=t[1]:(r=I(`text-muted-foreground size-3.5 shrink-0`,n),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(ui,{className:r}),t[2]=r,t[3]=i),i}function pte(e){let t=(0,G.c)(7),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=I(`min-w-0 flex-1 truncate text-sm`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=typeof n==`string`?(0,z.jsx)(u4,{text:n}):n,t[2]=n,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,z.jsx)(`span`,{className:i,children:a}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function mte(e){let t=(0,G.c)(9),{onClick:n,className:r}=e,i=c6(),a;t[0]===r?a=t[1]:(a=I(`text-muted-foreground hover:text-foreground shrink-0 rounded p-1 transition-colors`,r),t[0]=r,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`queue.remove`),t[2]=i,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(zn,{className:`size-3.5`}),t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==a||t[7]!==o?(c=(0,z.jsx)(`button`,{type:`button`,onClick:n,className:a,"aria-label":o,children:s}),t[5]=n,t[6]=a,t[7]=o,t[8]=c):c=t[8],c}var E9={Root:ute,Item:dte,Icon:fte,Text:pte,Remove:mte},hte={normal:{d:`m5 12 7-7 7 7`,translateY:0},animate:{d:`m5 12 7-7 7 7`,translateY:[0,3,0],transition:{duration:.4}}},gte={normal:{d:`M12 19V5`},animate:{d:[`M12 19V5`,`M12 19V10`,`M12 19V5`],transition:{duration:.4}}},D9=e=>{let t=(0,G.c)(30),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({ref:o,onMouseEnter:r,onMouseLeave:i,className:n,size:s,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=s===void 0?20:s,l=Cj(),u=(0,R.useRef)(!1),d;t[7]===l?d=t[8]:(d=()=>(u.current=!0,{startAnimation:()=>l.start(`animate`),stopAnimation:()=>l.start(`normal`)}),t[7]=l,t[8]=d),(0,R.useImperativeHandle)(o,d);let f;t[9]!==l||t[10]!==r?(f=e=>{u.current?r?.(e):l.start(`animate`)},t[9]=l,t[10]=r,t[11]=f):f=t[11];let p=f,m;t[12]!==l||t[13]!==i?(m=e=>{u.current?i?.(e):l.start(`normal`)},t[12]=l,t[13]=i,t[14]=m):m=t[14];let h=m,g;t[15]===n?g=t[16]:(g=I(n),t[15]=n,t[16]=g);let _,v;t[17]===l?(_=t[18],v=t[19]):(_=(0,z.jsx)(wj.path,{animate:l,d:`m5 12 7-7 7 7`,variants:hte}),v=(0,z.jsx)(wj.path,{animate:l,d:`M12 19V5`,variants:gte}),t[17]=l,t[18]=_,t[19]=v);let y;t[20]!==c||t[21]!==_||t[22]!==v?(y=(0,z.jsxs)(`svg`,{fill:`none`,height:c,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:c,xmlns:`http://www.w3.org/2000/svg`,children:[_,v]}),t[20]=c,t[21]=_,t[22]=v,t[23]=y):y=t[23];let b;return t[24]!==p||t[25]!==h||t[26]!==a||t[27]!==g||t[28]!==y?(b=(0,z.jsx)(`div`,{className:g,onMouseEnter:p,onMouseLeave:h,...a,children:y}),t[24]=p,t[25]=h,t[26]=a,t[27]=g,t[28]=y,t[29]=b):b=t[29],b};D9.displayName=`ArrowUpIcon`;var _te={duration:.15,ease:[0,0,.2,1]},vte={duration:.12,ease:[0,0,.2,1]};function O9(e){let t=(0,G.c)(43),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({variant:a,className:n,disabled:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=_j(),s=c6(),c=a===`stop`,l;t[5]===o?l=t[6]:(l=!o&&{opacity:0,scale:.9},t[5]=o,t[6]=l);let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u={opacity:1,scale:1},t[7]=u):u=t[7];let d;t[8]===o?d=t[9]:(d=o?void 0:{opacity:0,scale:.9},t[8]=o,t[9]=d);let f;t[10]!==r||t[11]!==o?(f=r||o?void 0:{scale:1.04},t[10]=r,t[11]=o,t[12]=f):f=t[12];let p;t[13]!==r||t[14]!==o?(p=r||o?void 0:{scale:.96},t[13]=r,t[14]=o,t[15]=p):p=t[15];let m=c?`composer.stop`:`composer.send`,h;t[16]!==s||t[17]!==m?(h=s(m),t[16]=s,t[17]=m,t[18]=h):h=t[18];let g;t[19]===n?g=t[20]:(g=I(`relative flex size-8 items-center justify-center rounded-full`,`bg-primary text-primary-foreground`,`transition-opacity hover:opacity-90 active:opacity-80`,`disabled:cursor-not-allowed disabled:opacity-35 disabled:hover:opacity-35`,`focus-visible:outline-[1.5px] focus-visible:outline-offset-[2.5px] focus-visible:outline-current`,n),t[19]=n,t[20]=g);let _=c?`stop`:`send`,v;t[21]===o?v=t[22]:(v=!o&&{opacity:0,scale:.7},t[21]=o,t[22]=v);let y;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(y={opacity:1,scale:1},t[23]=y):y=t[23];let b;t[24]===o?b=t[25]:(b=o?void 0:{opacity:0,scale:.7},t[24]=o,t[25]=b);let x;t[26]===c?x=t[27]:(x=(0,z.jsx)(c?xte:bte,{}),t[26]=c,t[27]=x);let S;t[28]!==v||t[29]!==b||t[30]!==x||t[31]!==_?(S=(0,z.jsx)(Mk,{initial:!1,children:(0,z.jsx)(wj.span,{initial:v,animate:y,exit:b,transition:vte,className:`absolute flex items-center justify-center`,children:x},_)}),t[28]=v,t[29]=b,t[30]=x,t[31]=_,t[32]=S):S=t[32];let C;return t[33]!==r||t[34]!==i||t[35]!==l||t[36]!==S||t[37]!==d||t[38]!==f||t[39]!==p||t[40]!==h||t[41]!==g?(C=(0,z.jsx)(wj.button,{initial:l,animate:u,exit:d,transition:_te,whileHover:f,whileTap:p,"aria-label":h,...i,disabled:r,className:g,children:S}),t[33]=r,t[34]=i,t[35]=l,t[36]=S,t[37]=d,t[38]=f,t[39]=p,t[40]=h,t[41]=g,t[42]=C):C=t[42],C}function yte(e){let t=(0,G.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,z.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:n}),t[0]=n,t[1]=r),r}function bte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(D9,{}),e[0]=t):t=e[0],t}function xte(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(yte,{children:(0,z.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`1.5`})}),e[0]=t):t=e[0],t}function Ste(e){let t=(0,G.c)(38),{title:n,detail:r,detailLabel:i,part:a,error:o}=e,s=O6(),c=c6(),l;t[0]===o.issues?l=t[1]:(l=o.issues.map(Cte).join(`
|
|
350
|
+
`),t[0]=o.issues,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,z.jsx)(_t,{className:`size-5`}),t[2]=d):d=t[2];let f;t[3]!==c||t[4]!==n?(f=n??c(`tool.renderFailed`),t[3]=c,t[4]=n,t[5]=f):f=t[5];let p;t[6]===f?p=t[7]:(p=(0,z.jsx)(ea,{children:(0,z.jsxs)(ta,{className:`text-destructive flex items-center gap-2`,children:[d,f]})}),t[6]=f,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(_t,{className:`size-4`}),t[8]=m):m=t[8];let h;t[9]===c?h=t[10]:(h=c(`tool.error`),t[9]=c,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,z.jsx)(_r,{children:h}),t[11]=h,t[12]=g);let _;t[13]===u?_=t[14]:(_=(0,z.jsx)(Je,{children:u}),t[13]=u,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,z.jsxs)(we,{variant:`destructive`,children:[m,g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==r||t[19]!==i||t[20]!==c?(y=r&&(0,z.jsxs)(`details`,{className:`text-sm`,children:[(0,z.jsx)(`summary`,{className:`text-muted-foreground hover:text-foreground cursor-pointer`,children:i??c(`tool.details`)}),(0,z.jsx)(`pre`,{className:`bg-muted mt-2 max-h-48 overflow-auto rounded-md p-3 text-xs`,children:(0,z.jsx)(`code`,{children:r})})]}),t[18]=r,t[19]=i,t[20]=c,t[21]=y):y=t[21];let b;t[22]!==y||t[23]!==v?(b=(0,z.jsxs)(ia,{className:`space-y-4`,children:[v,y]}),t[22]=y,t[23]=v,t[24]=b):b=t[24];let x;t[25]!==s||t[26]!==a?(x=()=>{let e=[`The model tried to call the tool "${jv(a)}" with the following inputs:`,JSON.stringify(a.input),`Please fix the inputs.`];s.addToolOutput({toolCallId:a.toolCallId,tool:jv(a),output:e,state:`output-available`})},t[25]=s,t[26]=a,t[27]=x):x=t[27];let S;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,z.jsx)(wi,{className:`size-4`}),t[28]=S):S=t[28];let C;t[29]===c?C=t[30]:(C=c(`tool.askToFix`),t[29]=c,t[30]=C);let w;t[31]!==x||t[32]!==C?(w=(0,z.jsx)(aa,{children:(0,z.jsxs)(Ce,{variant:`outline`,onClick:x,className:`gap-2`,children:[S,C]})}),t[31]=x,t[32]=C,t[33]=w):w=t[33];let T;return t[34]!==b||t[35]!==w||t[36]!==p?(T=(0,z.jsxs)($i,{className:`border-destructive/50 bg-destructive/5`,children:[p,b,w]}),t[34]=b,t[35]=w,t[36]=p,t[37]=T):T=t[37],T}function Cte(e){return`${e.path.join(`.`)}: ${e.message}`}(0,R.createContext)(``);function wte({question:e}){let{submit:t}=T6();return typeof e!=`string`||e===``?null:(0,z.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-accent hover:text-accent-foreground my-1 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-sm transition-colors`,onClick:()=>void t({prompt:e,persistedPrompt:e}),children:[(0,z.jsx)(oi,{className:`size-3.5`}),e]})}var k9=Vj([{name:`followup`,description:`Suggest a follow-up question the user is likely to ask next. Renders as a clickable chip that sends the question as the next message. Example: <followup question="How do I undo this?" />`,allowedAttributes:[`question`],component:wte}]),Tte=F({label:L().describe(`Display text for the option`),value:L().optional().describe(`Machine value; defaults to label`),description:L().optional().describe(`Helper text for the option`)}),A9=D(e=>typeof e==`object`&&e&&`questions`in e&&Array.isArray(e.questions)?{...e,questions:e.questions.map(e=>typeof e==`object`&&e?{...e,type:`choice`}:e)}:e,F({questions:Zt(F({type:Ye(`choice`).describe(`Selection from predefined options`),question:L().describe(`The question text displayed to the user`),header:L().optional().describe(`Short context label`),multiSelect:Dt().default(!1).describe(`Whether multiple options can be selected`),options:Zt(Tte).min(1).describe(`Available choices`)})).min(1).describe(`Questions to present as a wizard`)})),j9=F({label:L(),value:L()}),Ete=F({answers:Zt(F({type:L(),question:L(),freeText:L().optional(),notes:L().optional(),choice:j9.optional(),choices:Zt(j9).optional(),multiSelect:Dt().optional(),answer:L().optional()}))});function M9(e){if(e.multiSelect){if(e.selectedMulti.length===0&&!e.customText.trim())return`Pick at least one option or add your own answer.`}else{if(!e.selected&&!e.isOther)return`Select an option or add your own answer.`;if(e.isOther&&!e.customText.trim())return`Add your custom answer for the "Other" option.`}return null}function Dte(e){return{type:`choice`,multiSelect:e.multiSelect??!1,selected:null,selectedMulti:[],isOther:!1,customText:``,notes:``}}function N9(e){return e.options.filter(e=>(e.value??e.label).toLowerCase()!==`other`&&e.label.toLowerCase()!==`other`).map(e=>({label:e.label,value:e.value??e.label,description:e.description}))}function Ote(e,t,n){let r=e=>{let t=n.find(t=>t.value===e);return t?{label:t.label,value:t.value}:{label:e,value:e}},i=t.notes.trim()||void 0,a=t.customText.trim()||void 0;if(t.multiSelect){let n=t.selectedMulti.map(r);return a&&n.push({label:`Other`,value:a}),{type:`choice`,question:e.question,multiSelect:!0,choices:n,freeText:a,notes:i}}return{type:`choice`,question:e.question,multiSelect:!1,choice:t.isOther?{label:`Other`,value:a??``}:r(t.selected??``),freeText:t.isOther?a:void 0,notes:i}}function P9({checked:e,children:t,disabled:n}){return(0,z.jsx)(`div`,{className:I(`border-border/60 relative flex items-start gap-2 rounded-lg border px-3 py-1.5 transition-all duration-150`,!n&&`hover:bg-muted/40`,e&&`border-primary/50 bg-primary/5`,n&&`opacity-60`),children:t})}function F9({htmlFor:e,label:t,description:n}){return(0,z.jsxs)(Fn,{htmlFor:e,className:`min-w-0 flex-1 cursor-pointer flex-col items-start gap-0`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium`,children:t}),n?(0,z.jsx)(`p`,{className:`text-muted-foreground text-xs leading-relaxed text-pretty`,children:n}):null]})}function kte({id:e,value:t,label:n,description:r,checked:i,disabled:a}){return(0,z.jsxs)(P9,{checked:i,disabled:a,children:[(0,z.jsx)(Ho,{id:e,value:t,disabled:a,className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:n,description:r})]})}function Ate({id:e,label:t,description:n,checked:r,disabled:i,onCheckedChange:a}){return(0,z.jsxs)(P9,{checked:r,disabled:i,children:[(0,z.jsx)(Sa,{id:e,checked:r,disabled:i,onCheckedChange:e=>a(e===!0),className:`mt-0.5`}),(0,z.jsx)(F9,{htmlFor:e,label:t,description:n})]})}function jte({id:e,checked:t,disabled:n,customText:r,onCustomTextChange:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:t,disabled:n,children:[(0,z.jsx)(Ho,{ref:a,id:e,value:`other`,disabled:n,className:`mt-0.5`}),(0,z.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Type your answer...`,disabled:n,onFocus:()=>{t||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function Mte({hasCustom:e,disabled:t,customText:n,onCustomTextChange:r,onClear:i}){let a=(0,R.useRef)(null);return(0,z.jsxs)(P9,{checked:e,disabled:t,children:[(0,z.jsx)(Sa,{ref:a,checked:e,disabled:t,onCheckedChange:e=>{e||i()},className:`mt-0.5`}),(0,z.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Type your answer...`,disabled:t,onFocus:()=>{e||a.current?.click()},className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none disabled:cursor-not-allowed`})]})}function Nte({value:e,onChange:t,disabled:n}){return(0,z.jsx)(`div`,{className:`mt-2.5 border-t border-dashed pt-2.5`,children:(0,z.jsx)(et,{value:e,onChange:e=>t(e.target.value),placeholder:`Add notes (optional)...`,disabled:n,rows:2,className:`resize-none text-sm`})})}function Pte({value:e,onChange:t,options:n,disabled:r,fieldId:i}){if(e.multiSelect){let a=e.customText.trim().length>0,o=(n,r)=>{let i=new Set(e.selectedMulti);r?i.add(n):i.delete(n),t({...e,selectedMulti:[...i]})};return(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[n.map(t=>(0,z.jsx)(Ate,{id:`${i}-multi-${t.value}`,label:t.label,description:t.description,checked:e.selectedMulti.includes(t.value),disabled:r,onCheckedChange:e=>o(t.value,e)},t.value)),(0,z.jsx)(Mte,{hasCustom:a,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n}),onClear:()=>t({...e,customText:``})})]})}return(0,z.jsxs)(Vo,{value:e.isOther?`other`:e.selected??``,onValueChange:n=>t(n===`other`?{...e,selected:null,isOther:!0}:{...e,selected:n,isOther:!1,customText:``}),children:[n.map(t=>(0,z.jsx)(kte,{id:`${i}-single-${t.value}`,value:t.value,label:t.label,description:t.description,checked:!e.isOther&&e.selected===t.value,disabled:r},t.value)),(0,z.jsx)(jte,{id:`${i}-single-other`,checked:e.isOther,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n})})]})}function Fte({current:e,total:t}){return t<=1?null:(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:t},(t,n)=>(0,z.jsx)(`div`,{className:I(`h-1 w-3 rounded-full transition-colors duration-200`,n<=e?`bg-primary`:`bg-muted`)},n))})}function Ite({onBack:e,onNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}){return o?null:(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-dashed px-3 py-1.5`,children:[(0,z.jsx)(`div`,{className:`w-16`,children:n?null:(0,z.jsx)(`button`,{type:`button`,onClick:e,disabled:a,className:`text-muted-foreground hover:text-foreground text-xs transition-colors disabled:opacity-50`,children:`← Back`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Fte,{current:s,total:c}),c>1?(0,z.jsxs)(`span`,{className:`text-muted-foreground text-[11px] tabular-nums`,children:[s+1,`/`,c]}):null]}),(0,z.jsx)(`div`,{className:`flex w-16 justify-end`,children:(0,z.jsxs)(Ce,{type:`button`,size:`sm`,onClick:t,disabled:!i||a,children:[a?(0,z.jsx)(Uo,{}):null,a?`Sending...`:r?`Submit`:`Next`]})})]})}function Lte({question:e}){return(0,z.jsxs)(`div`,{className:`px-3 pt-2.5 pb-2`,children:[(0,z.jsxs)(`div`,{className:`text-muted-foreground mb-2 flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(Ct,{className:`size-3`}),(0,z.jsx)(`span`,{children:e.header??`Clarification`})]}),(0,z.jsx)(Qi,{className:`mb-2`}),(0,z.jsx)(`p`,{className:`text-sm font-medium text-pretty`,children:e.question})]})}function Rte({question:e,answer:t,options:n,onChange:r,disabled:i,fieldId:a}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Pte,{value:t,onChange:r,options:n,disabled:i,fieldId:a}),(0,z.jsx)(Nte,{value:t.notes,onChange:e=>r({...t,notes:e}),disabled:i})]})}function zte({question:e,answer:t,options:n}){let r=t.multiSelect?[...t.selectedMulti.map(e=>n.find(t=>t.value===e)?.label??e),...t.customText.trim()?[`Other: ${t.customText.trim()}`]:[]].join(`, `):t.isOther?`Other: ${t.customText.trim()}`:n.find(e=>e.value===t.selected)?.label??t.selected??``,i=t.notes.trim()||void 0;return(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:r}),i?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,i]}):null]})}function Bte(e){return e.type===`free_form`?e.answer??``:e.multiSelect&&e.choices?e.choices.map(({label:e,value:t})=>e===`Other`?`Other: ${t}`:e).join(`, `):e.freeText?`Other: ${e.freeText}`:e.choice?.label??``}function Vte({answers:e}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Qi,{}),e.map((e,t)=>(0,z.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-sm text-pretty`,children:e.question}),(0,z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-pretty`,children:Bte(e)}),e.notes?(0,z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs text-pretty italic`,children:[`Note: `,e.notes]}):null]},t))]})}function Hte({questions:e,answers:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3 pt-2.5 pb-2`,children:(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-2 text-xs`,children:[(0,z.jsx)(d,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Answered`})]})}),(0,z.jsx)(Qi,{}),e.map((e,n)=>(0,z.jsx)(zte,{question:e,answer:t[n],options:N9(e)},n))]})}var I9=(0,R.createContext)(void 0);function L9(){let e=(0,R.use)(I9);if(!e)throw Error(`useWizard must be used within <ClarificationWizard.Root>`);return e}function Ute({questions:e,onSubmit:t,disabled:n,fieldId:r,children:i}){let[a,o]=(0,R.useState)(0),[s,c]=(0,R.useState)(()=>e.map(Dte)),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(!1),h=e[a],g=s[a],_=a===0,v=a===e.length-1,y={questions:e,currentStep:a,currentQuestion:h,currentAnswer:g,options:N9(h),answers:s,updateAnswer:e=>{c(t=>{let n=[...t];return n[a]=e,n}),u(null)},handleBack:()=>{_||(o(e=>e-1),u(null))},handleNext:async()=>{let n=M9(g);if(n){u(n);return}if(!v){o(e=>e+1),u(null);return}for(let t=0;t<e.length;t++){let e=M9(s[t]);if(e){o(t),u(e);return}}f(!0);try{await t(e.map((e,t)=>Ote(e,s[t],N9(e)))),m(!0)}catch(e){u(e instanceof Error?e.message:`Failed to send your answers.`)}finally{f(!1)}},error:l,isFirst:_,isLast:v,canProceed:!n&&!p,isSubmitting:d,isSubmitted:p,disabled:n,fieldId:r,totalSteps:e.length};return(0,z.jsx)(I9,{value:y,children:i})}function Wte(){let{currentQuestion:e,isSubmitted:t}=L9();return t?null:(0,z.jsx)(Lte,{question:e})}function Gte(){let{currentQuestion:e,currentAnswer:t,options:n,updateAnswer:r,disabled:i,isSubmitting:a,isSubmitted:o,fieldId:s,currentStep:c}=L9();return o?null:(0,z.jsx)(Rte,{question:e,answer:t,options:n,onChange:r,disabled:i||a,fieldId:`${s}-step-${c}`})}function Kte(){let{error:e,isSubmitted:t}=L9();return t||!e?null:(0,z.jsx)(`p`,{className:`text-destructive text-xs`,role:`alert`,children:e})}function qte(){let{handleBack:e,handleNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}=L9();return(0,z.jsx)(Ite,{onBack:e,onNext:()=>void t(),isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c})}function Jte({children:e,className:t}){let{isSubmitted:n}=L9();return n?null:(0,z.jsx)(`div`,{className:t,children:e})}function Yte(){let{questions:e,answers:t,isSubmitted:n}=L9();return n?(0,z.jsx)(Hte,{questions:e,answers:t}):null}var R9={Root:Ute,Header:Wte,Content:Jte,Field:Gte,Error:Kte,Navigation:qte,Submitted:Yte};function Xte({part:e}){let t=O6(),[n,r]=(0,R.useState)(!1),i=(0,R.useId)();if(e.state===`output-available`){let t=Ete.safeParse(e.output);return t.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 mb-2 rounded-lg border border-dashed`),children:(0,z.jsx)(Vte,{answers:t.data.answers})}):null}if(e.state!==`input-available`)return null;let a=A9.safeParse(e.input);return a.success?(0,z.jsx)(`div`,{className:I(`border-border/60 bg-muted/20 rounded-lg border border-dashed`,`animate-in fade-in-0 duration-200`),children:(0,z.jsxs)(R9.Root,{questions:a.data.questions,onSubmit:async n=>{await t.addToolOutput({toolCallId:e.toolCallId,tool:jv(e),output:{answers:n},state:`output-available`}),r(!0)},disabled:n,fieldId:i,children:[(0,z.jsx)(R9.Submitted,{}),(0,z.jsx)(R9.Header,{}),(0,z.jsxs)(R9.Content,{className:`space-y-2 px-3 pb-2`,children:[(0,z.jsx)(R9.Field,{}),(0,z.jsx)(R9.Error,{})]}),(0,z.jsx)(R9.Navigation,{})]})}):(0,z.jsx)(Ste,{error:a.error,title:`Failed to render clarification`,detail:JSON.stringify(e.input,null,2),detailLabel:`View input`,part:e})}var Zte={component:Xte,label:e=>{let t=e.state===`input-available`||e.state===`output-available`?A9.safeParse(e.input):void 0,n=t?.success?t.data.questions[0]:void 0;return{name:`AskUserQuestion`,icon:eee,args:n?{question:n.header??n.question}:void 0}},requiresUserInput:!0,static:!1,inputSchema:A9,description:`Tool to collect information from the user via a multi-step wizard. Use when you need to clarify requirements, gather preferences, or resolve ambiguity before proceeding.
|
|
351
351
|
|
|
352
352
|
Each question MUST have a "type" field set to "choice" for selection from predefined options (single or multiple).
|
|
353
353
|
|
|
354
354
|
IMPORTANT: NEVER include an "Other" option in your options array — the UI always renders one automatically with an inline text input.
|
|
355
355
|
|
|
356
356
|
Example:
|
|
357
|
-
{"questions":[{"type":"choice","question":"Which timeframe?","header":"Timeframe","multiSelect":false,"options":[{"label":"Last 30 days"},{"label":"Last quarter"}]}]}`};function z9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function B9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`string`?n:void 0}function V9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`number`?n:void 0}function H9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`boolean`?n:void 0}function U9(e){return e.state!==`output-available`&&e.state!==`output-error`&&e.state!==`output-denied`}function W9(e){if(e.state===`output-error`)return e.errorText;if(e.state===`output-denied`)return`Execution denied.`}function G9({children:e,pending:t=!1,error:n=!1}){return(0,z.jsx)(`p`,{"aria-live":t?`polite`:void 0,className:I(`text-xs leading-relaxed`,t&&`animate-pulse`,n?`text-destructive`:`text-muted-foreground`),children:e})}function K9({title:e,code:t,language:n,detail:r,error:i=!1}){return(0,z.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,z.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3 px-0.5`,children:[(0,z.jsx)(`h4`,{className:I(`text-[10px] font-semibold tracking-[0.08em] uppercase`,i?`text-destructive`:`text-muted-foreground`),children:e}),r&&(0,z.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px]`,children:r})]}),(0,z.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-md`,children:(0,z.jsx)(
|
|
358
|
-
`)||void 0}}function Zte(e){return!z9(e)||e.type!==`content`||!Array.isArray(e.value)?[]:e.value.flatMap(e=>{if(!z9(e)||e.type!==`file`)return[];let t=typeof e.mediaType==`string`?e.mediaType:`file`;return[`${typeof e.filename==`string`?e.filename:`Attachment`} · ${t}`]})}var Qte={css:`css`,csv:`csv`,html:`html`,js:`javascript`,json:`json`,jsx:`jsx`,md:`markdown`,py:`python`,sh:`bash`,sql:`sql`,ts:`typescript`,tsx:`tsx`,txt:`text`,xml:`xml`,yaml:`yaml`,yml:`yaml`};function Y9(e){return Qte[e.split(`.`).pop()?.toLowerCase()??``]??`text`}function X9(e){let t=V9(e,`offset`),n=V9(e,`limit`);if(t===void 0&&n===void 0)return;let r=t??1;return n===void 0?`${r}+`:`${r}-${r+n-1}`}function $te({part:e}){let t=B9(e.input,`path`)??``,n=J9(e.output),r=Zte(e.output),i=z9(e.output)&&e.output.type===`error-text`?J9(e.output):void 0,a=W9(e)??i,o=U9(e),s=X9(e.input);return(0,z.jsx)(q9,{children:a?(0,z.jsx)(G9,{error:!0,children:a}):o?(0,z.jsxs)(G9,{pending:!0,children:[`Reading `,t||`file`,`...`]}):n===void 0?r.length>0?(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`File content`}),r.map(e=>(0,z.jsx)(`p`,{className:`text-foreground/80 text-xs`,children:e},e))]}):(0,z.jsx)(G9,{children:`File content is unavailable.`}):n?(0,z.jsx)(K9,{code:n,detail:s?`lines ${s}`:void 0,language:Y9(t),title:`File contents`}):(0,z.jsx)(G9,{children:`The file is empty.`})})}function ene({part:e}){let t=B9(e.input,`path`)??``,n=B9(e.input,`content`)??``,r=V9(e.output,`exitCode`),i=B9(e.output,`stderr`)??``,a=B9(e.output,`stdout`)??``,o=H9(e.output,`success`),s=W9(e);return(0,z.jsxs)(q9,{children:[U9(e)?(0,z.jsxs)(G9,{pending:!0,children:[`Writing `,t||`file`,`...`]}):s||o===!1||(r??0)!==0?(0,z.jsx)(G9,{error:!0,children:s||i||a||`Failed to write ${t||`file`}.`}):(0,z.jsx)(G9,{children:`File written.`}),n?(0,z.jsx)(K9,{code:n,language:Y9(t),title:`Written content`}):(0,z.jsx)(G9,{children:`The file content is empty.`})]})}function tne(e){let t=B9(e.input,`command`),n=B9(e.input,`reasoning`),r=V9(e.output,`exitCode`);return{name:`Bash`,args:t?{cmd:t.slice(0,80)}:void 0,detail:n,isError:e.state===`output-error`||e.state===`output-denied`||r!==void 0&&r!==0}}function Z9(e,t){let n=B9(e.input,`path`),r=t===`ReadFile`?X9(e.input):void 0,i=V9(e.output,`exitCode`);return{name:t,args:n||r?{...n?{path:n}:{},...r?{lines:r}:{}}:void 0,isError:e.state===`output-error`||e.state===`output-denied`||H9(e.output,`success`)===!1||i!==void 0&&i!==0||z9(e.output)&&e.output.type===`error-text`}}var Q9={ask_user_question:Yte,bash:{component:Xte,label:tne,static:!0},readFile:{component:$te,label:e=>Z9(e,`ReadFile`),static:!0},writeFile:{component:ene,label:e=>Z9(e,`WriteFile`),static:!0}},nne=ur(`status`,[F({id:L(),status:Ye(`restored`),sourceMessages:nr(),replacementMessages:nr()}),F({id:L(),status:Ye(`started`),tokenScope:Ye(`request`).optional(),triggerIndex:nr(),targetTokens:nr(),messageCount:nr()}),F({id:L(),status:Ye(`completed`),tokenScope:Ye(`request`).optional(),tokens:F({before:nr(),after:nr()})}),F({id:L(),status:Ye(`failed`),phase:Nn([`restore`,`evaluate`,`compact`,`persist`]),reason:Nn([`no-safe-boundary`,`protected-history`,`incomplete-summary`,`empty-summary`,`summary-too-large`,`request-overhead`,`error`])})]);function rne({message:e,running:t}){let n=e.parts.flatMap(e=>{if(e.type!==`data-compaction`)return[];let t=nne.safeParse(e.data);return t.success?[t.data]:[]}),r=Map.groupBy(n,e=>e.id);return Array.from(r,([e,n])=>(0,z.jsx)(ine,{events:n,running:t},e))}function ine({events:e,running:t}){let n=e.find(e=>e.status===`started`),r=e.find(e=>e.status===`completed`),i=e.find(e=>e.status===`failed`),a=e.find(e=>e.status===`restored`),o=n!==void 0&&!r&&!i;return(0,z.jsxs)(Ia,{className:`my-3`,children:[(0,z.jsx)(La,{className:`group w-full text-left`,children:(0,z.jsxs)(ko,{children:[(0,z.jsx)(jo,{children:o&&t?(0,z.jsx)(Uo,{"aria-label":`Compacting context`}):i?(0,z.jsx)(_t,{className:`text-destructive size-4`}):r?(0,z.jsx)(d,{className:`size-4`}):(0,z.jsx)(gi,{className:`size-4`})}),(0,z.jsxs)(Mo,{children:[(0,z.jsx)(No,{children:i?`Compaction failed`:r?`Context compacted`:o?t?`Compacting context…`:`Compaction interrupted`:`Using saved summary`}),r&&(0,z.jsxs)(Po,{children:[r.tokens.before.toLocaleString(),` →`,` `,r.tokens.after.toLocaleString(),` estimated`,` `,r.tokenScope===`request`?`input`:`message`,` `,`tokens`]})]}),(0,z.jsx)(Ct,{className:`size-3.5 transition-transform group-data-[panel-open]:rotate-90`})]})}),(0,z.jsxs)(Ra,{children:[(0,z.jsx)(Qi,{}),(0,z.jsxs)(`div`,{className:`space-y-3 px-3 py-3 text-sm`,children:[(0,z.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-4 gap-y-2`,children:[n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Messages before compaction`}),(0,z.jsx)(`dd`,{children:n.messageCount.toLocaleString()}),(0,z.jsxs)(`dt`,{children:[`Estimated`,` `,n.tokenScope===`request`?`input`:`message`,` `,`target`]}),(0,z.jsxs)(`dd`,{children:[n.targetTokens.toLocaleString(),` tokens`]}),(0,z.jsx)(`dt`,{children:`Matched trigger`}),(0,z.jsxs)(`dd`,{children:[`#`,n.triggerIndex+1]})]}),r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Checkpoint`}),(0,z.jsx)(`dd`,{children:`Saved`})]}),a&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Using saved summary`}),(0,z.jsxs)(`dd`,{children:[a.sourceMessages,` → `,a.replacementMessages,` `,`messages`]})]})]}),i&&(0,z.jsx)(we,{variant:`destructive`,children:(0,z.jsxs)(Je,{children:[i.phase,`: `,i.reason]})})]})]})]})}var ane=F({messages:Zt(pn())});async function one(e){let{params:t,request:n}=e,r=t.sessionId??new URL(n.url).searchParams.get(`chatId`);if(!r)return ln(`/chat?chatId=${encodeURIComponent(crypto.randomUUID())}`);let i=await qn(n.signal),a=i.history.find(e=>e.chatId===r),o=i.discovery?.capabilities.chat.href;if(!o||!t.sessionId&&!a&&!i.historyError)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};try{let e=await fetch(`${o}/${encodeURIComponent(r)}`,{signal:n.signal});if(e.status===404&&!t.sessionId)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};if(!e.ok)throw Error(`Session request failed: ${e.status}`);let s=ane.safeParse(await e.json());if(!s.success)throw Error(`Session response did not include messages`);return{...i,chatId:r,conversation:a,initialMessages:await oy({messages:s.data.messages}),sessionExists:!0,sessionError:!1}}catch{return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!0}}}function sne({currentParams:e,currentUrl:t,nextParams:n,nextUrl:r}){return e.sessionId!==n.sessionId||t.searchParams.get(`chatId`)!==r.searchParams.get(`chatId`)}function cne(){let{chatId:e}=Ie();return(0,z.jsx)(lne,{chatId:e},e)}function lne({chatId:e}){let{discovery:t,initialMessages:n,sessionError:r,sessionExists:i}=Ie(),a=t?.capabilities.chat.href;return a?r?(0,z.jsx)($9,{children:`Unable to load this conversation.`}):(0,z.jsx)(une,{api:a,chatId:e,initialMessages:n,sessionExists:i,supportsUploads:t.capabilities.uploads!==void 0,accept:t.capabilities.uploads?.mediaTypes?.join(`,`)}):(0,z.jsx)($9,{children:`Development runtime unavailable.`})}function une({api:e,chatId:t,initialMessages:n,sessionExists:r,supportsUploads:i,accept:a}){let o=gn(),{revalidate:s}=fe(),c=Ie(),[l]=(0,R.useState)(()=>new x7({api:e,tools:M6(Q9),elements:k9}));return(0,z.jsx)(x6,{chatId:t,initialMessages:n,onFinish:()=>void s(),onResetChat:e=>{o(`/chat?chatId=${encodeURIComponent(e)}`)},resume:r,registry:Q9,transport:l,children:(0,z.jsxs)(l6,{className:`**:data-[slot='content']:max-w-3xl`,children:[(0,z.jsx)(h6.Root,{className:`px-6`,children:(0,z.jsx)(h6.Hero,{children:`How can I help?`})}),(0,z.jsx)(dne,{}),(0,z.jsx)(sn,{treeId:t,snapshot:c.conversation?.children}),(0,z.jsx)(fne,{supportsUploads:i,accept:a})]})})}function dne(){let{error:e,messages:t,regenerate:n,status:r}=T6();return t.length===0&&!e?null:(0,z.jsxs)(C9.Root,{className:`mb-8 min-h-0 flex-1 px-6`,messages:t,elements:k9,status:r,children:[(0,z.jsx)(C9.List,{children:t.map((e,n)=>(0,z.jsx)(C9.Item,{message:e,index:n,children:e.role===`user`?(0,z.jsx)(C9.UserBubble,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(rne,{message:e,running:n===t.length-1&&(r===`submitted`||r===`streaming`)}),(0,z.jsx)(C9.AssistantContent,{})]})},e.id))}),(0,z.jsx)(C9.Error,{error:e,onRetry:()=>void n()}),(0,z.jsx)(C9.Thinking,{})]})}function fne({supportsUploads:e,accept:t}){let{submit:n}=S6(),{hasSubmitted:r}=w6(),{status:i}=C6(),a=i===`submitted`||i===`streaming`;return(0,z.jsx)(`div`,{className:I(`w-full px-6 pb-6`,r&&`bg-background sticky bottom-0 mt-auto pt-2`),children:(0,z.jsx)(c7,{className:`bg-background`,children:(0,z.jsx)(T9.Provider,{isTaskRunning:a,onSubmit:t=>{let r=t.items.flatMap(e=>e.type===`image`||e.type===`video`||e.type===`audio`?[e.file]:[]);return!e&&r.length>0?Promise.reject(Error(`This runtime does not support file uploads`)):n({prompt:t.prompt,persistedPrompt:t.persistedPrompt,files:r})},children:(0,z.jsxs)(T9.Root,{children:[(0,z.jsx)(pne,{}),(0,z.jsx)(T9.Popup,{}),(0,z.jsxs)(T9.Content,{children:[(0,z.jsx)(T9.Attachments,{}),(0,z.jsx)(T9.Editor,{placeholder:`Message Zukhruf…`}),(0,z.jsx)(T9.Error,{})]}),(0,z.jsxs)(T9.Toolbar,{children:[e&&(0,z.jsx)(T9.AttachFiles,{accept:t}),(0,z.jsx)(mne,{})]})]})})})})}function pne(){let{experimental_queuedMessages:e,experimental_removeQueuedMessage:t}=T6();return e.length===0?null:(0,z.jsx)(E9.Root,{children:e.map(e=>(0,z.jsxs)(E9.Item,{children:[(0,z.jsx)(E9.Icon,{}),(0,z.jsx)(E9.Text,{children:i6(e)}),(0,z.jsx)(E9.Remove,{onClick:()=>t(e.id)})]},e.id))})}function mne(){let{state:e}=qQ(`ChatSubmitButton`),{stop:t}=S6(),{status:n}=C6(),r=e.text.trim().length>0;return(n===`submitted`||n===`streaming`)&&!r?(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`stop`,onClick:t}):(0,z.jsx)(c4.Submit,{render:(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`send`,disabled:!r})})}function $9({children:e}){return(0,z.jsx)(`p`,{className:`text-muted-foreground p-8 text-sm`,children:e})}export{cne as Component,one as loader,sne as shouldRevalidate};
|
|
357
|
+
{"questions":[{"type":"choice","question":"Which timeframe?","header":"Timeframe","multiSelect":false,"options":[{"label":"Last 30 days"},{"label":"Last quarter"}]}]}`};function z9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function B9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`string`?n:void 0}function V9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`number`?n:void 0}function H9(e,t){if(!z9(e))return;let n=e[t];return typeof n==`boolean`?n:void 0}function U9(e){return e.state!==`output-available`&&e.state!==`output-error`&&e.state!==`output-denied`}function W9(e){if(e.state===`output-error`)return e.errorText;if(e.state===`output-denied`)return`Execution denied.`}function G9({children:e,pending:t=!1,error:n=!1}){return(0,z.jsx)(`p`,{"aria-live":t?`polite`:void 0,className:I(`text-xs leading-relaxed`,t&&`animate-pulse`,n?`text-destructive`:`text-muted-foreground`),children:e})}function K9({title:e,code:t,language:n,detail:r,error:i=!1}){return(0,z.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,z.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3 px-0.5`,children:[(0,z.jsx)(`h4`,{className:I(`text-[10px] font-semibold tracking-[0.08em] uppercase`,i?`text-destructive`:`text-muted-foreground`),children:e}),r&&(0,z.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px]`,children:r})]}),(0,z.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-md`,children:(0,z.jsx)(z8,{className:I(`border-border/60 rounded-md shadow-none`,i&&`border-destructive/30`),code:t,language:n,wrap:!0,children:(0,z.jsx)(B8,{"aria-label":`Copy ${e.toLowerCase()}`,className:`text-muted-foreground bg-background/90 hover:bg-muted h-6 rounded-md px-2 font-mono text-[10px]`,size:`xs`,variant:`ghost`,children:`Copy`})})})]})}function q9({children:e}){return(0,z.jsx)(`div`,{className:`border-border/60 mb-2 space-y-3 border-l pl-3`,children:e})}function Qte({part:e}){let t=B9(e.input,`command`)??``,n=B9(e.output,`stdout`)??``,r=B9(e.output,`stderr`)??``,i=V9(e.output,`exitCode`),a=W9(e),o=U9(e);return(0,z.jsxs)(q9,{children:[a?(0,z.jsx)(G9,{error:!0,children:a}):o?(0,z.jsx)(G9,{pending:!0,children:`Running command...`}):(0,z.jsx)(G9,{error:i!==void 0&&i!==0,children:i===void 0?`Command finished.`:`Command exited with code ${i}.`}),t&&(0,z.jsx)(K9,{code:t,language:`bash`,title:`Command`}),n&&(0,z.jsx)(K9,{code:n,language:`text`,title:`Standard output`}),r&&(0,z.jsx)(K9,{code:r,error:!0,language:`text`,title:`Standard error`}),!o&&!a&&!n&&!r&&(0,z.jsx)(G9,{children:`The command produced no output.`})]})}function J9(e){if(typeof e==`string`)return e;if(z9(e)){if((e.type===`text`||e.type===`error-text`)&&typeof e.value==`string`)return e.value;if(!(e.type!==`content`||!Array.isArray(e.value)))return e.value.filter(e=>z9(e)&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
|
|
358
|
+
`)||void 0}}function $te(e){return!z9(e)||e.type!==`content`||!Array.isArray(e.value)?[]:e.value.flatMap(e=>{if(!z9(e)||e.type!==`file`)return[];let t=typeof e.mediaType==`string`?e.mediaType:`file`;return[`${typeof e.filename==`string`?e.filename:`Attachment`} · ${t}`]})}var ene={css:`css`,csv:`csv`,html:`html`,js:`javascript`,json:`json`,jsx:`jsx`,md:`markdown`,py:`python`,sh:`bash`,sql:`sql`,ts:`typescript`,tsx:`tsx`,txt:`text`,xml:`xml`,yaml:`yaml`,yml:`yaml`};function Y9(e){return ene[e.split(`.`).pop()?.toLowerCase()??``]??`text`}function X9(e){let t=V9(e,`offset`),n=V9(e,`limit`);if(t===void 0&&n===void 0)return;let r=t??1;return n===void 0?`${r}+`:`${r}-${r+n-1}`}function tne({part:e}){let t=B9(e.input,`path`)??``,n=J9(e.output),r=$te(e.output),i=z9(e.output)&&e.output.type===`error-text`?J9(e.output):void 0,a=W9(e)??i,o=U9(e),s=X9(e.input);return(0,z.jsx)(q9,{children:a?(0,z.jsx)(G9,{error:!0,children:a}):o?(0,z.jsxs)(G9,{pending:!0,children:[`Reading `,t||`file`,`...`]}):n===void 0?r.length>0?(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`p`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`File content`}),r.map(e=>(0,z.jsx)(`p`,{className:`text-foreground/80 text-xs`,children:e},e))]}):(0,z.jsx)(G9,{children:`File content is unavailable.`}):n?(0,z.jsx)(K9,{code:n,detail:s?`lines ${s}`:void 0,language:Y9(t),title:`File contents`}):(0,z.jsx)(G9,{children:`The file is empty.`})})}function nne({part:e}){let t=B9(e.input,`path`)??``,n=B9(e.input,`content`)??``,r=V9(e.output,`exitCode`),i=B9(e.output,`stderr`)??``,a=B9(e.output,`stdout`)??``,o=H9(e.output,`success`),s=W9(e);return(0,z.jsxs)(q9,{children:[U9(e)?(0,z.jsxs)(G9,{pending:!0,children:[`Writing `,t||`file`,`...`]}):s||o===!1||(r??0)!==0?(0,z.jsx)(G9,{error:!0,children:s||i||a||`Failed to write ${t||`file`}.`}):(0,z.jsx)(G9,{children:`File written.`}),n?(0,z.jsx)(K9,{code:n,language:Y9(t),title:`Written content`}):(0,z.jsx)(G9,{children:`The file content is empty.`})]})}function rne(e){let t=B9(e.input,`command`),n=B9(e.input,`reasoning`),r=V9(e.output,`exitCode`);return{name:`Bash`,args:t?{cmd:t.slice(0,80)}:void 0,detail:n,isError:e.state===`output-error`||e.state===`output-denied`||r!==void 0&&r!==0}}function Z9(e,t){let n=B9(e.input,`path`),r=t===`ReadFile`?X9(e.input):void 0,i=V9(e.output,`exitCode`);return{name:t,args:n||r?{...n?{path:n}:{},...r?{lines:r}:{}}:void 0,isError:e.state===`output-error`||e.state===`output-denied`||H9(e.output,`success`)===!1||i!==void 0&&i!==0||z9(e.output)&&e.output.type===`error-text`}}var Q9={ask_user_question:Zte,bash:{component:Qte,label:rne,static:!0},readFile:{component:tne,label:e=>Z9(e,`ReadFile`),static:!0},writeFile:{component:nne,label:e=>Z9(e,`WriteFile`),static:!0}},ine=ur(`status`,[F({id:L(),status:Ye(`restored`),sourceMessages:nr(),replacementMessages:nr()}),F({id:L(),status:Ye(`started`),tokenScope:Ye(`request`).optional(),triggerIndex:nr(),targetTokens:nr(),messageCount:nr()}),F({id:L(),status:Ye(`completed`),tokenScope:Ye(`request`).optional(),tokens:F({before:nr(),after:nr()})}),F({id:L(),status:Ye(`failed`),phase:Nn([`restore`,`evaluate`,`compact`,`persist`]),reason:Nn([`no-safe-boundary`,`protected-history`,`incomplete-summary`,`empty-summary`,`summary-too-large`,`request-overhead`,`error`])})]);function ane({message:e,running:t}){let n=e.parts.flatMap(e=>{if(e.type!==`data-compaction`)return[];let t=ine.safeParse(e.data);return t.success?[t.data]:[]}),r=Map.groupBy(n,e=>e.id);return Array.from(r,([e,n])=>(0,z.jsx)(one,{events:n,running:t},e))}function one({events:e,running:t}){let n=e.find(e=>e.status===`started`),r=e.find(e=>e.status===`completed`),i=e.find(e=>e.status===`failed`),a=e.find(e=>e.status===`restored`),o=n!==void 0&&!r&&!i;return(0,z.jsxs)(Ia,{className:`my-3`,children:[(0,z.jsx)(La,{className:`group w-full text-left`,children:(0,z.jsxs)(ko,{children:[(0,z.jsx)(jo,{children:o&&t?(0,z.jsx)(Uo,{"aria-label":`Compacting context`}):i?(0,z.jsx)(_t,{className:`text-destructive size-4`}):r?(0,z.jsx)(d,{className:`size-4`}):(0,z.jsx)(gi,{className:`size-4`})}),(0,z.jsxs)(Mo,{children:[(0,z.jsx)(No,{children:i?`Compaction failed`:r?`Context compacted`:o?t?`Compacting context…`:`Compaction interrupted`:`Using saved summary`}),r&&(0,z.jsxs)(Po,{children:[r.tokens.before.toLocaleString(),` →`,` `,r.tokens.after.toLocaleString(),` estimated`,` `,r.tokenScope===`request`?`input`:`message`,` `,`tokens`]})]}),(0,z.jsx)(Ct,{className:`size-3.5 transition-transform group-data-[panel-open]:rotate-90`})]})}),(0,z.jsxs)(Ra,{children:[(0,z.jsx)(Qi,{}),(0,z.jsxs)(`div`,{className:`space-y-3 px-3 py-3 text-sm`,children:[(0,z.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-4 gap-y-2`,children:[n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Messages before compaction`}),(0,z.jsx)(`dd`,{children:n.messageCount.toLocaleString()}),(0,z.jsxs)(`dt`,{children:[`Estimated`,` `,n.tokenScope===`request`?`input`:`message`,` `,`target`]}),(0,z.jsxs)(`dd`,{children:[n.targetTokens.toLocaleString(),` tokens`]}),(0,z.jsx)(`dt`,{children:`Matched trigger`}),(0,z.jsxs)(`dd`,{children:[`#`,n.triggerIndex+1]})]}),r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Checkpoint`}),(0,z.jsx)(`dd`,{children:`Saved`})]}),a&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{children:`Using saved summary`}),(0,z.jsxs)(`dd`,{children:[a.sourceMessages,` → `,a.replacementMessages,` `,`messages`]})]})]}),i&&(0,z.jsx)(we,{variant:`destructive`,children:(0,z.jsxs)(Je,{children:[i.phase,`: `,i.reason]})})]})]})]})}var sne=F({messages:Zt(pn())});async function cne(e){let{params:t,request:n}=e,r=t.sessionId??new URL(n.url).searchParams.get(`chatId`);if(!r)return ln(`/chat?chatId=${encodeURIComponent(crypto.randomUUID())}`);let i=await qn(n.signal),a=i.history.find(e=>e.chatId===r),o=i.discovery?.capabilities.chat.href;if(!o||!t.sessionId&&!a&&!i.historyError)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};try{let e=await fetch(`${o}/${encodeURIComponent(r)}`,{signal:n.signal});if(e.status===404&&!t.sessionId)return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!1};if(!e.ok)throw Error(`Session request failed: ${e.status}`);let s=sne.safeParse(await e.json());if(!s.success)throw Error(`Session response did not include messages`);return{...i,chatId:r,conversation:a,initialMessages:await oy({messages:s.data.messages}),sessionExists:!0,sessionError:!1}}catch{return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!0}}}function lne({currentParams:e,currentUrl:t,nextParams:n,nextUrl:r}){return e.sessionId!==n.sessionId||t.searchParams.get(`chatId`)!==r.searchParams.get(`chatId`)}function une(){let{chatId:e}=Ie();return(0,z.jsx)(dne,{chatId:e},e)}function dne({chatId:e}){let{discovery:t,initialMessages:n,sessionError:r,sessionExists:i}=Ie(),a=t?.capabilities.chat.href;return a?r?(0,z.jsx)($9,{children:`Unable to load this conversation.`}):(0,z.jsx)(fne,{api:a,chatId:e,initialMessages:n,sessionExists:i,supportsUploads:t.capabilities.uploads!==void 0,accept:t.capabilities.uploads?.mediaTypes?.join(`,`)}):(0,z.jsx)($9,{children:`Development runtime unavailable.`})}function fne({api:e,chatId:t,initialMessages:n,sessionExists:r,supportsUploads:i,accept:a}){let o=gn(),{revalidate:s}=fe(),c=Ie(),[l]=(0,R.useState)(()=>new C7({api:e,tools:F6(Q9),elements:k9}));return(0,z.jsx)(w6,{chatId:t,initialMessages:n,onFinish:()=>void s(),onResetChat:e=>{o(`/chat?chatId=${encodeURIComponent(e)}`)},resume:r,registry:Q9,transport:l,children:(0,z.jsxs)(f6,{className:`**:data-[slot='content']:max-w-3xl`,children:[(0,z.jsx)(v6.Root,{className:`px-6`,children:(0,z.jsx)(v6.Hero,{children:`How can I help?`})}),(0,z.jsx)(pne,{}),(0,z.jsx)(sn,{treeId:t,snapshot:c.conversation?.children}),(0,z.jsx)(mne,{supportsUploads:i,accept:a})]})})}function pne(){let{error:e,messages:t,regenerate:n,status:r}=O6();return t.length===0&&!e?null:(0,z.jsxs)(C9.Root,{className:`mb-8 min-h-0 flex-1 px-6`,messages:t,elements:k9,status:r,children:[(0,z.jsx)(C9.List,{children:t.map((e,n)=>(0,z.jsx)(C9.Item,{message:e,index:n,children:e.role===`user`?(0,z.jsx)(C9.UserBubble,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ane,{message:e,running:n===t.length-1&&(r===`submitted`||r===`streaming`)}),(0,z.jsx)(C9.AssistantContent,{})]})},e.id))}),(0,z.jsx)(C9.Error,{error:e,onRetry:()=>void n()}),(0,z.jsx)(C9.Thinking,{})]})}function mne({supportsUploads:e,accept:t}){let{submit:n}=T6(),{hasSubmitted:r}=D6(),{status:i}=E6(),a=i===`submitted`||i===`streaming`;return(0,z.jsx)(`div`,{className:I(`w-full px-6 pb-6`,r&&`bg-background sticky bottom-0 mt-auto pt-2`),children:(0,z.jsx)(u7,{className:`bg-background`,children:(0,z.jsx)(T9.Provider,{isTaskRunning:a,onSubmit:t=>{let r=t.items.flatMap(e=>e.type===`image`||e.type===`video`||e.type===`audio`?[e.file]:[]);return!e&&r.length>0?Promise.reject(Error(`This runtime does not support file uploads`)):n({prompt:t.prompt,persistedPrompt:t.persistedPrompt,files:r})},children:(0,z.jsxs)(T9.Root,{children:[(0,z.jsx)(hne,{}),(0,z.jsx)(T9.Popup,{}),(0,z.jsxs)(T9.Content,{children:[(0,z.jsx)(T9.Attachments,{}),(0,z.jsx)(T9.Editor,{placeholder:`Message Zukhruf…`}),(0,z.jsx)(T9.Error,{})]}),(0,z.jsxs)(T9.Toolbar,{children:[e&&(0,z.jsx)(T9.AttachFiles,{accept:t}),(0,z.jsx)(gne,{})]})]})})})})}function hne(){let{experimental_queuedMessages:e,experimental_removeQueuedMessage:t}=O6();return e.length===0?null:(0,z.jsx)(E9.Root,{children:e.map(e=>(0,z.jsxs)(E9.Item,{children:[(0,z.jsx)(E9.Icon,{}),(0,z.jsx)(E9.Text,{children:i6(e)}),(0,z.jsx)(E9.Remove,{onClick:()=>t(e.id)})]},e.id))})}function gne(){let{state:e}=qQ(`ChatSubmitButton`),{stop:t}=T6(),{status:n}=E6(),r=e.text.trim().length>0;return(n===`submitted`||n===`streaming`)&&!r?(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`stop`,onClick:t}):(0,z.jsx)(c4.Submit,{render:(0,z.jsx)(O9,{className:`ml-auto`,type:`button`,variant:`send`,disabled:!r})})}function $9({children:e}){return(0,z.jsx)(`p`,{className:`text-muted-foreground p-8 text-sm`,children:e})}export{une as Component,cne as loader,lne as shouldRevalidate};
|