@deepagents/devtool 7.44.0 → 7.45.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.
- package/dist/ui/assets/chat-D7Ok6eXq.js +352 -0
- package/dist/ui/assets/index-Dt0nCqi6.css +2 -0
- package/dist/ui/assets/index-TNzRpwiE.js +12 -0
- package/dist/ui/assets/runtime-data-D25NI3GU.js +56 -0
- package/dist/ui/index.html +3 -3
- package/package.json +8 -8
- package/dist/ui/assets/chat-CRniBiKK.js +0 -352
- package/dist/ui/assets/index-CfNGpC1x.css +0 -2
- package/dist/ui/assets/index-DDKoMA1M.js +0 -12
- package/dist/ui/assets/runtime-data-Cj2bjaL7.js +0 -56
|
@@ -0,0 +1,352 @@
|
|
|
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 eee,ba as Nt,bn as Pt,br as Ft,bt as It,ca as Lt,cr as Rt,ct as zt,dr as Bt,dt as Vt,ea as Ht,ei as Ut,eo as Wt,er as Gt,et as Kt,f as I,fi as qt,fr as Jt,ft as Yt,g as Xt,ga as Zt,gn as Qt,gr as $t,gt as en,h as tn,hn as nn,hr as rn,ht as an,i as on,ia as sn,in as cn,io as ln,ir as un,it as dn,j as fn,jn as pn,jr as mn,jt as hn,k as L,kn as gn,la as _n,lt as vn,m as yn,mi as bn,mn as xn,mr as Sn,mt as Cn,na as wn,ni as Tn,no as En,nr as Dn,nt as On,oa as kn,or as An,ot as jn,p as Mn,pi as Nn,pn as Pn,pr as Fn,pt as In,q as Ln,qa as Rn,qi as zn,qn as Bn,qr as Vn,rr as Hn,rt as Un,sr as Wn,st as Gn,t as Kn,ti as qn,to as Jn,tt as Yn,ur as Xn,ut as Zn,v as Qn,vn as $n,vt as er,w as tr,wn as nr,wr as rr,wt as ir,x as ar,xn as or,xr as sr,xt as cr,y as lr,yn as ur,yr as dr,yt as fr,z as pr,za as mr,zi as hr,zn as gr,zr as _r}from"./runtime-data-D25NI3GU.js";import{A as vr,D as yr,E as br,F as xr,I as Sr,M as Cr,N as wr,O as Tr,P as Er,S as Dr,T as Or,_ as kr,a as Ar,b as jr,c as Mr,d as Nr,f as Pr,g as Fr,h as Ir,j as Lr,k as Rr,l as zr,m as Br,o as Vr,p as Hr,s as Ur,t as Wr,v as Gr,w as Kr,x as qr,y as Jr}from"./chunk-RIHGWQV5-DnqKmwfH.js";var Yr={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`]};Yr.node;var Xr=En(Yr),Zr={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`]};Zr.node;var Qr=En(Zr),$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=En($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=En(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=En(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=En(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=En(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=En(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=En(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=En(pi),hi={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};hi.node;var gi=En(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=En(_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=En(yi),xi={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};xi.node;var Si=En(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=En(Ci),Ti={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Ti.node;var Ei=En(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=En(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}=Lt(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=kn,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)});mr(()=>{!y||u===`starting`||b(!1)},[y,u]),R.useEffect(()=>()=>{re(),ne()},[re,ne]),mr(()=>{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=_n.request(()=>{w(n,e.signal)}),()=>{_n.cancel(t),e.abort()}},[C,a,s,E,w,O,c]),mr(()=>{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=_n.request(()=>{C.current||(r&&(g.current=!1),i&&e.setAttribute(Pi,``),e.setAttribute(`hidden`,`until-found`))}))})},i=zn(e,`beforematch`,t=>{let n=Ne(Nt,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(),_n.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=Ht(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=_n.request(n);return()=>{_n.cancel(r),n()}}var z=r(),qi=hr(`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=hr(`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 mr(()=>{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}=pn(),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;gn(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`]);mr(()=>{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?Tn:qn,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(Nt,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),Ht(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 mr(()=>{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}=Lt(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),...sn},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=hr(`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
|
+
`).map((e,t)=>(0,z.jsx)(Oa,{children:e},t)):t})})}var Da=hr(`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,...sn},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,...sn},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;mr(()=>(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];Gt(_.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)}Gt(_.current,r,a,n)});mr(()=>{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:Bn,m=s?Bn:be,h=n===`vertical`?ae:c,v=n===`vertical`?ge:m,y=Pe(e.nativeEvent);if(y!=null&&f(y)&&!xn(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=Vn(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={...Rt,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Rt.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Rt.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Rt.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 Xn{constructor(e,t,n){let r=new rn;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=dr(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=sr(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={...Wn(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=Bt(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(Zt))}),[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 rr(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var io=Jt(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=An(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=Hn(y,{enabled:!a&&l&&!D,mouseOnly:!0,move:!1,handleClose:Dn(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),O=mn(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?Nn.open(e):bn.open(e)}},{handlePreFocusGuardFocus:ie,handleFocusTargetFocus:M}=nn(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)(Ut,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:ie}),oe,(0,z.jsx)(Ut,{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)(_r,{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`;ur(C&&k,D===`touch`,ee,T);let re=v.useStateSetter(`positionerElement`),j=Pt(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=$n(!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)}}),un(w,{enabled:D&&!E,closeDelay:ee});let te=a===void 0?Ft(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`,...$t,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&xt.has(e.key)&&e.stopPropagation()}},or(g),s],stateAttributesMapping:qt});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:wn(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]:``}},...sn,...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}=pn(),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]));mr(()=>{fe.current?.checked&&ne(!0)},[ne]),mr(()=>{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?Tn:qn,"aria-hidden":!0,...c===void 0?lt:{value:nr(c)},disabled:M,checked:ce,required:oe,readOnly:ae,onChange(e){if(e.nativeEvent.defaultPrevented||M||ae||c===void 0)return;let t=Ne(Nt,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)(Qt,{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}=Lt(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}=pn(),{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))});mr(()=>{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});gn(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=hr(`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=hr(`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=Fs(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},tee=class{constructor(e){this.ruleName=e}ruleName;kind=2},nee=class{constructor(e){this.scopeName=e}scopeName;kind=3},ree=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function Fs(e){if(e===`$base`)return new Ns;if(e===`$self`)return new Ps;let t=e.indexOf(`#`);return t===-1?new nee(e):t===0?new tee(e.substring(1)):new ree(e.substring(0,t),e.substring(t+1))}var Is=/\\(\d+)/,Ls=/\\(\d+)/g,Rs=-1,zs=-2;function Bs(e){return e}function Vs(e){return e}var Hs=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)}},Us=class extends Hs{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!`)}},Ws=class extends Hs{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,i){super(e,t,n,null),this._match=new Ys(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 Xs,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Gs=class extends Hs{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 Xs,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ks=class extends Hs{_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 Ys(i,this.id),this.beginCaptures=a,this._end=new Ys(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 Xs;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}},qs=class extends Hs{_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 Ys(i,this.id),this.beginCaptures=a,this.whileCaptures=s,this._while=new Ys(o,zs),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 Xs;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 Xs,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||``),this._cachedCompiledWhilePatterns}},Js=class e{static createCaptureRule(e,t,n,r,i){return e.registerRule(e=>new Us(t,e,n,r,i))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(i=>{if(t.id=i,t.match)return new Ws(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 Gs(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,n,r))}return t.while?new qs(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 Ks(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=Fs(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 Gs||e instanceof Ks||e instanceof qs)&&e.hasMissingPatterns&&e.patterns.length===0&&(t=!0),t)continue;i.push(s)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},Ys=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=Is.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 Ls.lastIndex=0,this.source.replace(Ls,(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}},Xs=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 Zs(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 Zs(e,this._items.map(e=>e.resolveAnchors(t,n)),this._items.map(e=>e.ruleId))}},Zs=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
|
+
`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Qs=class{constructor(e,t){this.languageId=e,this.tokenType=t}languageId;tokenType},$s=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new Qs(e,8),this._embeddedLanguagesMatcher=new ec(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 Qs(0,0);_getBasicScopeAttributes=new rs(e=>new Qs(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/},ec=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 tc=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}stack;stoppedEarly};function nc(e,t,n,r,i,a,o,s){let c=t.content.length,l=!1,u=-1;if(o){let o=rc(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 tc(i,!0);f()}return new tc(i,!1);function f(){let o=ic(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===Rs){let o=i.getRule(e);a.produce(i,s[0].start),i=i.withContentNameScopesList(i.nameScopesList),lc(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 Ks){let r=o;lc(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 qs){let r=o;lc(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(lc(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 rc(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 qs&&s.push({rule:n,stack:t})}for(let c=s.pop();c;c=s.pop()){let{ruleScanner:s,findOptions:l}=cc(c.rule,e,c.stack.endRule,n,r===o),u=s.findNextMatchSync(t,r,l);if(u){if(u.ruleId!==zs){i=c.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(a.produce(c.stack,u.captureIndices[0].start),lc(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 ic(e,t,n,r,i,a){let o=ac(e,t,n,r,i,a),s=e.getInjections();if(s.length===0)return o;let c=oc(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 ac(e,t,n,r,i,a){let{ruleScanner:o,findOptions:s}=sc(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 oc(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}=sc(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 sc(e,t,n,r,i){return{ruleScanner:e.compileAG(t,n,r,i),findOptions:0}}function cc(e,t,n,r,i){return{ruleScanner:e.compileWhileAG(t,n,r,i),findOptions:0}}function lc(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));nc(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 uc(t,d.end))}}for(;l.length>0;)i.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var uc=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function dc(e,t,n,r,i,a,o,s){return new hc(e,t,n,r,i,a,o,s)}function fc(e,t,n,r,i){let a=xs(t,pc),o=Js.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 pc(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(mc(t[r],e))return n=r+1,!0;return!1})}function mc(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 hc=class{constructor(e,t,n,r,i,a,o,s){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=s,this._basicScopeAttributesProvider=new $s(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=gc(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(let e of Object.keys(i)){let t=xs(e,pc);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)fc(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&&fc(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(Bs(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[Vs(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]=gc(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=Js.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!t||t===vc.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?_c.createRootAndLookUpScopeName(a,r,this):_c.createRoot(`unknown`,r),t=new vc(null,this._rootId,-1,-1,!1,null,o,o)}else i=!1,t.reset();e+=`
|
|
6
|
+
`;let a=this.createOnigString(e),o=a.content.length,s=new bc(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=nc(this,a,i,0,t,s,!0,r);return ws(a),{lineLength:o,lineTokens:s,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function gc(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 _c=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}},vc=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)?_c.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:Vs(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=_c.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new e(t,Bs(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,_c.fromExtension(r,n.contentNameScopesList))}},yc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>e===`*`?(this.allowAny=!0,[]):xs(e,pc).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>xs(e,pc).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}},bc=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}},xc=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,dc(e,a,t,n,r,i,this,this._onigLib))}return this._grammars.get(e)}},Sc=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new xc(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 yc(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)}},Cc=vc.NULL;function wc(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 Tc(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Ec(e){return Array.isArray(e)?e:[e]}async function Dc(e){return Promise.resolve(typeof e==`function`?e():e).then(e=>e.default||e)}function Oc(e){return!e||[`plaintext`,`txt`,`text`,`plain`].includes(e)}function kc(e){return e===`ansi`||Oc(e)}function Ac(e){return e===`none`}function jc(e){return Ac(e)}var Mc=/(\r?\n)/g;function Nc(e,t=!1){if(e.length===0)return[[``,0]];let n=e.split(Mc),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 Pc={light:`#333333`,dark:`#bbbbbb`},Fc={light:`#fffffe`,dark:`#1e1e1e`},Ic=`__shiki_resolved`;function Lc(e){if(e?.[Ic])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`?Pc.light:Pc.dark,n||=t.type===`light`?Fc.light:Fc.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,Ic,{enumerable:!1,writable:!1,value:!0}),t}async function Rc(e){return[...new Set((await Promise.all(e.filter(e=>!kc(e)).map(async e=>await Dc(e).then(e=>Array.isArray(e)?e:[e])))).flat())]}async function zc(e){return(await Promise.all(e.map(async e=>jc(e)?null:Lc(await Dc(e))))).filter(e=>!!e)}function Bc(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 Vc=class extends Sc{_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=Lc(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=Bc(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))}},Hc=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}},Uc=0;function Wc(e){Uc+=1,e.warnings!==!1&&Uc>=10&&Uc%10==0&&console.warn(`[Shiki] ${Uc} 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(Lc),i=new Vc(new Hc(e.engine,n),r,n,e.langAlias),a;function o(t){return Bc(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 Rc(e))}function m(...e){g();for(let t of e.flat(1))i.loadTheme(t)}async function h(...e){return g(),m(await zc(e))}function g(){if(t)throw new Wo(`Shiki instance has been disposed`)}function _(){t||(t=!0,i.dispose(),--Uc)}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 Gc(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,n,r]=await Promise.all([zc(e.themes||[]),Rc(e.langs||[]),e.engine]);return Wc({...e,themes:t,langs:n,engine:r})}var Kc=new WeakMap;function qc(e,t){Kc.set(e,t)}function Jc(e){return Kc.get(e)}var Yc=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(Ec(n).map(e=>[e,Cc])),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 Xc(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Xc(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 Zc(e,t){if(!(e instanceof Yc))throw new Wo(`Invalid grammar state`);return e.getInternalStack(t)}var Qc=/,/,$c=/ /;function el(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Oc(e.resolveLangAlias(n.lang||`text`))||Ac(r))return Nc(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 nl(t,o,i,a,n)}function tl(...e){if(e.length===2)return Jc(e[1]);let[t,n,r={}]=e,{lang:i=`text`,theme:a=t.getLoadedThemes()[0]}=r;if(Oc(i)||Ac(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 Yc(rl(n,c,o,s,r).stateStack,c.name,o.name)}function nl(e,t,n,r,i){let a=rl(e,t,n,r,i),o=new Yc(a.stateStack,t.name,n.name);return qc(a.tokens,o),a.tokens}function rl(e,t,n,r,i){let a=wc(n,i),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:s=500,includeExplanation:c=!1}=i,l=Nc(e),u=i.grammarState?Zc(i.grammarState,n.name)??Cc:i.grammarContextCode==null?Cc:rl(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=Tc(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(Qc).map(e=>e.trim());break;case`object`:n=t.scope;break;default:continue}e.push({settings:t,selectors:n.map(e=>e.split($c))})}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`?il(t.scopes):al(e,t.scopes)}),g+=1}}d.push(f)}f.push(d),d=[],u=_.ruleStack}return{tokens:f,stateStack:u}}function il(e){return e.map(e=>({scopeName:e}))}function al(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];n[r]={scopeName:i,themeMatches:cl(e,i,t.slice(0,r))}}return n}function ol(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]===`.`}function sl(e,t,n){if(!ol(e.at(-1),t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)ol(e[r],n[i])&&--r,--i;return r===-1}function cl(e,t,n){let r=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(sl(e,t,n)){r.push(a);break}return r}function ll(e,t,n,r=el){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:Jc(a),theme:typeof i.theme==`string`?i.theme:i.theme.name}}),o=ul(...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 Yc(Object.fromEntries(a.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),a[0].state.lang):void 0;return c&&qc(s,c),s}function ul(...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 dl=/["&'<>`]/g,fl=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,pl=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ml=/[|\\{}()[\]^$+*?.]/g,hl=new WeakMap;function gl(e,t){if(e=e.replace(t.subset?_l(t.subset):dl,r),t.subset||t.escapeOnly)return e;return e.replace(fl,n).replace(pl,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 _l(e){let t=hl.get(e);return t||(t=vl(e),hl.set(e,t)),t}function vl(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(ml,`\\$&`));return RegExp(`(?:`+t.join(`|`)+`)`,`g`)}var yl=/[\dA-Fa-f]/;function bl(e,t,n){let r=`&#x`+e.toString(16).toUpperCase();return n&&t&&!yl.test(String.fromCharCode(t))?r:r+`;`}var xl=/\d/;function Sl(e,t,n){let r=`&#`+String(e);return n&&t&&!xl.test(String.fromCharCode(t))?r:r+`;`}var Cl=`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(`.`),wl={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:`€`},Tl=[`cent`,`copy`,`divide`,`gt`,`lt`,`not`,`para`,`times`],El={}.hasOwnProperty,Dl={},Ol;for(Ol in wl)El.call(wl,Ol)&&(Dl[wl[Ol]]=Ol);var kl=/[^\dA-Za-z]/;function Al(e,t,n,r){let i=String.fromCharCode(e);if(El.call(Dl,i)){let e=Dl[i],a=`&`+e;return n&&Cl.includes(e)&&!Tl.includes(e)&&(!r||t&&t!==61&&kl.test(String.fromCharCode(t)))?a:a+`;`}return``}function jl(e,t,n){let r=bl(e,t,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=Al(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){let i=Sl(e,t,n.omitOptionalSemicolons);i.length<r.length&&(r=i)}return i&&(!n.useShortestReferences||i.length<r.length)?i:r}function Ml(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Nl(e,t){return gl(e,Object.assign({format:jl},t))}function Pl(e,t){return gl(e,Object.assign({format:Ml},t))}var Fl=/^>|^->|<!--|-->|--!>|<!-$/g,Il=[`>`],Ll=[`<`,`>`];function Rl(e,t,n,r){return r.settings.bogusComments?`<?`+Nl(e.value,Object.assign({},r.settings.characterReferences,{subset:Il}))+`>`:`<!--`+e.value.replace(Fl,i)+`-->`;function i(e){return Nl(e,Object.assign({},r.settings.characterReferences,{subset:Ll}))}}function zl(e,t,n,r){return`<!`+(r.settings.upperDoctype?`DOCTYPE`:`doctype`)+(r.settings.tightDoctype?``:` `)+`html>`}var Bl=Ul(1),Vl=Ul(-1),Hl=[];function Ul(e){return t;function t(t,n,r){let i=t?t.children:Hl,a=(n||0)+e,o=i[a];if(!r)for(;o&&Tr(o);)a+=e,o=i[a];return o}}var Wl={}.hasOwnProperty;function Gl(e){return t;function t(t,n,r){return Wl.call(e,t.tagName)&&e[t.tagName](t,n,r)}}var Kl=Gl({body:Yl,caption:ql,colgroup:ql,dd:$l,dt:Ql,head:ql,html:Jl,li:Zl,optgroup:tu,option:nu,p:Xl,rp:eu,rt:eu,tbody:iu,td:su,tfoot:au,th:su,thead:ru,tr:ou});function ql(e,t,n){let r=Bl(n,t,!0);return!r||r.type!==`comment`&&!(r.type===`text`&&Tr(r.value.charAt(0)))}function Jl(e,t,n){let r=Bl(n,t);return!r||r.type!==`comment`}function Yl(e,t,n){let r=Bl(n,t);return!r||r.type!==`comment`}function Xl(e,t,n){let r=Bl(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 Zl(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&r.tagName===`li`}function Ql(e,t,n){let r=Bl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`))}function $l(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&(r.tagName===`dt`||r.tagName===`dd`)}function eu(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&(r.tagName===`rp`||r.tagName===`rt`)}function tu(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&r.tagName===`optgroup`}function nu(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&(r.tagName===`option`||r.tagName===`optgroup`)}function ru(e,t,n){let r=Bl(n,t);return!!(r&&r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`))}function iu(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&(r.tagName===`tbody`||r.tagName===`tfoot`)}function au(e,t,n){return!Bl(n,t)}function ou(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&r.tagName===`tr`}function su(e,t,n){let r=Bl(n,t);return!r||r.type===`element`&&(r.tagName===`td`||r.tagName===`th`)}var cu=Gl({body:du,colgroup:fu,head:uu,html:lu,tbody:pu});function lu(e){let t=Bl(e,-1);return!t||t.type!==`comment`}function uu(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 du(e){let t=Bl(e,-1,!0);return!t||t.type!==`comment`&&!(t.type===`text`&&Tr(t.value.charAt(0)))&&!(t.type===`element`&&(t.tagName===`meta`||t.tagName===`link`||t.tagName===`script`||t.tagName===`style`||t.tagName===`template`))}function fu(e,t,n){let r=Vl(n,t);if(n&&r&&r.type===`element`&&r.tagName===`colgroup`&&Kl(r,n.children.indexOf(r),n))return!1;let i=Bl(e,-1,!0);return!!(i&&i.type===`element`&&i.tagName===`col`)}function pu(e,t,n){let r=Vl(n,t);if(n&&r&&r.type===`element`&&(r.tagName===`thead`||r.tagName===`tbody`)&&Kl(r,n.children.indexOf(r),n))return!1;let i=Bl(e,-1);return!!(i&&i.type===`element`&&i.tagName===`tr`)}var mu={name:[[`
|
|
7
|
+
\f\r &/=>`.split(``),`
|
|
8
|
+
\f\r "&'/=>\``.split(``)],[`\0
|
|
9
|
+
\f\r "&'/<=>`.split(``),`\0
|
|
10
|
+
\f\r "&'/<=>\``.split(``)]],unquoted:[[`
|
|
11
|
+
\f\r &>`.split(``),`\0
|
|
12
|
+
\f\r "&'<=>\``.split(``)],[`\0
|
|
13
|
+
\f\r "&'<=>\``.split(``),`\0
|
|
14
|
+
\f\r "&'<=>\``.split(``)]],single:[[`&'`.split(``),`"&'\``.split(``)],[`\0&'`.split(``),`\0"&'\``.split(``)]],double:[[`"&`.split(``),`"&'\``.split(``)],[`\0"&`.split(``),`\0"&'\``.split(``)]]},hu=new Set([`desc`,`foreignObject`,`title`]);function gu(e,t,n,r){let{schema:i}=r,a=i.space!==`svg`&&r.settings.omitOptionalTags,o=i.space===`svg`?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),s=[];i.space===`html`&&e.tagName===`svg`&&(r.schema=Er);let c=_u(r,e.properties);r.schema.space===`svg`&&hu.has(e.tagName)&&(r.schema=wr);let l=r.all(i.space===`html`&&e.tagName===`template`?e.content:e);if(r.schema=i,l&&(o=!1),c||!a||!cu(e,t,n)){if(s.push(`<`,e.tagName,c?` `+c:``),o&&(i.space===`svg`||r.settings.closeSelfClosing)){let e=c.charAt(c.length-1);(!r.settings.tightSelfClosing||e===`/`||e&&e!==`"`&&e!==`'`)&&s.push(` `),s.push(`/`)}s.push(`>`)}return s.push(l),!o&&(!a||!Kl(e,t,n))&&s.push(`</`+e.tagName+`>`),s.join(``)}function _u(e,t){let n=[],r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){let r=vu(e,i,t[i]);r&&n.push(r)}}for(;++r<n.length;){let t=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&t!==`"`&&t!==`'`&&(n[r]+=` `)}return n.join(``)}function vu(e,t,n){let r=xr(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space===`html`?0:1,a=+!e.settings.allowDangerousCharacters;if(r.overloadedBoolean&&(n===r.attribute||n===``)?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!=`string`||n===r.attribute||n===``)&&(n=!!n),n==null||n===!1||typeof n==`number`&&Number.isNaN(n))return``;let o=Nl(r.attribute,Object.assign({},e.settings.characterReferences,{subset:mu.name[i][a]}));if(n===!0||(n=Array.isArray(n)?(r.commaSeparated?vr:Rr)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n))return o;let s;if(e.settings.preferUnquoted&&(s=Nl(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:mu.unquoted[i][a]}))),s!==n){let{quote:t}=e;e.settings.quoteSmart&&Lr(n,t)>Lr(n,e.alternative)&&(t=e.alternative),s=t+Nl(n,Object.assign({},e.settings.characterReferences,{subset:(t===`'`?mu.single:mu.double)[i][a],attribute:!0}))+t}return o+(s&&`=`+s)}var yu=[`<`,`&`],bu=new Set([`iframe`,`noembed`,`noframes`,`plaintext`,`script`,`style`,`xmp`]);function xu(e,t,n,r){return n&&n.type===`element`&&r.schema.space===`html`&&bu.has(n.tagName)?e.value:Nl(e.value,Object.assign({},r.settings.characterReferences,{subset:yu}))}function Su(e,t,n,r){return r.settings.allowDangerousHtml?e.value:xu(e,t,n,r)}function Cu(e,t,n,r){return r.all(e)}var wu=Cr(`type`,{invalid:Tu,unknown:Eu,handlers:{comment:Rl,doctype:zl,element:gu,raw:Su,root:Cu,text:xu}});function Tu(e){throw Error("Expected node, not `"+e+"`")}function Eu(e){throw Error("Cannot compile unknown node `"+e.type+"`")}var Du={},Ou={},ku=[];function Au(e,t){let n=t||Du,r=n.quote||`"`;if(r!==`"`&&r!==`'`)throw Error("Invalid quote `"+r+"`, expected `'` or `\"`");let i=r===`"`?`'`:`"`;return{one:ju,all:Mu,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Sr,characterReferences:n.characterReferences||Ou,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space===`svg`?Er:wr,quote:r,alternative:i}.one(Array.isArray(e)?{type:`root`,children:e}:e,void 0,void 0)}function ju(e,t,n){return wu(e,t,n,this)}function Mu(e){let t=[],n=e&&e.children||ku,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join(``)}var Nu=/\s+/g;function Pu(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class==`string`&&(e.properties.class=e.properties.class.split(Nu)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Nu);for(let t of n)t&&!e.properties.class.includes(t)&&e.properties.class.push(t);return e}function Fu(e){let t=Nc(e,!0),n=t.map(([e])=>e),r=t.map(([,e])=>e);function i(t){if(t===e.length)return{line:n.length-1,character:n.at(-1).length};let i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>>1;r[e]<=t?i=e:a=e-1}return{line:i,character:t-r[i]}}function a(e,t){return r[e]+t}return{lines:n,indexToPos:i,posToIndex:a}}var Iu=[`color`,`background-color`];function Lu(e,t){let n=0,r=[];for(let i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Ru(e,t){let n=0,r=e.length;for(;n<r;){let i=n+(r-n>>1);e[i]<=t?n=i+1:r=i}return n}function zu(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((e,t)=>e-t);return n.length?e.map(e=>e.flatMap(e=>{let t=e.offset+e.content.length,r=Ru(n,e.offset),i=r;for(;i<n.length&&n[i]<t;)i++;if(r===i)return e;let a=n.slice(r,i);for(let t=0;t<a.length;t++)a[t]-=e.offset;return Lu(e,a)})):e}function Bu(e,t,n,r,i=`css-vars`){let a={content:e.content,explanation:e.explanation,offset:e.offset},o=t.map(t=>Vu(e.variants[t])),s=new Set(o.flatMap(e=>Object.keys(e))),c={},l=(e,r)=>{let i=r===`color`?``:r===`background-color`?`-bg`:`-${r}`;return n+t[e]+(r===`color`?``:i)};return o.forEach((e,n)=>{for(let a of s){let s=e[a]||`inherit`;if(n===0&&r&&Iu.includes(a))if(r===`light-dark()`&&o.length>1){let e=t.findIndex(e=>e===`light`),r=t.findIndex(e=>e===`dark`);if(e===-1||r===-1)throw new Wo('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let u=o[e][a]||`inherit`,d=o[r][a]||`inherit`;c[a]=`light-dark(${u}, ${d})`,i===`css-vars`&&(c[l(n,a)]=s)}else c[a]=s;else i===`css-vars`&&(c[l(n,a)]=s)}}),a.htmlStyle=c,a}function Vu(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t[`background-color`]=e.bgColor),e.fontStyle){e.fontStyle&fs.Italic&&(t[`font-style`]=`italic`),e.fontStyle&fs.Bold&&(t[`font-weight`]=`bold`);let n=[];e.fontStyle&fs.Underline&&n.push(`underline`),e.fontStyle&fs.Strikethrough&&n.push(`line-through`),n.length&&(t[`text-decoration`]=n.join(` `))}return t}function Hu(e){return typeof e==`string`?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(`;`)}function Uu(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){let n=Fu(t.source);function r(e){if(typeof e==`number`){if(e<0||e>t.source.length)throw new Wo(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...n.indexToPos(e),offset:e}}else{let t=n.lines[e.line];if(t===void 0)throw new Wo(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${n.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new Wo(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:n.posToIndex(e.line,r)}}}let i=(t.options.decorations||[]).map(e=>({...e,start:r(e.start),end:r(e.end)}));Wu(i),e.set(t.meta,{decorations:i,converter:n,source:t.source})}return e.get(t.meta)}return{name:`shiki:decorations`,tokens(e){if(this.options.decorations?.length)return zu(e,t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]))},code(e){if(!this.options.decorations?.length)return;let n=t(this),r=[...e.children].filter(e=>e.type===`element`&&e.tagName===`span`);if(r.length!==n.converter.lines.length)throw new Wo(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${n.converter.lines.length}). Failed to apply decorations.`);function i(e,t,n,i){let a=r[e],s=``,c=-1,l=-1;if(t===0&&(c=0),n===0&&(l=0),n===1/0&&(l=a.children.length),c===-1||l===-1)for(let e=0;e<a.children.length;e++)s+=Ku(a.children[e]),c===-1&&s.length===t&&(c=e+1),l===-1&&s.length===n&&(l=e+1);if(c===-1)throw new Wo(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(l===-1)throw new Wo(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let u=a.children.slice(c,l);if(!i.alwaysWrap&&u.length===a.children.length)o(a,i,`line`);else if(!i.alwaysWrap&&u.length===1&&u[0].type===`element`)o(u[0],i,`token`);else{let e={type:`element`,tagName:`span`,properties:{},children:u};o(e,i,`wrapper`),a.children.splice(c,u.length,e)}}function a(e,t){r[e]=o(r[e],t,`line`)}function o(e,t,n){let r=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||`span`,e.properties={...e.properties,...r,class:e.properties.class},t.properties?.class&&Pu(e,t.properties.class),e=i(e,n)||e,e}let s=[],c=n.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset);for(let e of c){let{start:t,end:n}=e;if(t.line===n.line)i(t.line,t.character,n.character,e);else if(t.line<n.line){i(t.line,t.character,1/0,e);for(let r=t.line+1;r<n.line;r++)s.push(()=>a(r,e));i(n.line,0,n.character,e)}}for(let e=s.length-1;e>=0;e--)s[e]()}}}function Wu(e){if(!Gu(e))for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new Wo(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let t=e[r],i=n.start.offset<=t.start.offset&&t.start.offset<n.end.offset,a=n.start.offset<t.end.offset&&t.end.offset<=n.end.offset,o=t.start.offset<=n.start.offset&&n.start.offset<t.end.offset,s=t.start.offset<n.end.offset&&n.end.offset<=t.end.offset;if(i||a||o||s){if(i&&a||o&&s||o&&n.start.offset===n.end.offset||a&&t.start.offset===t.end.offset)continue;throw new Wo(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(t.start)} intersect.`)}}}}function Gu(e){let t=[],n=new Map,r=new Map;for(let i=0;i<e.length;i++){let{start:a,end:o}=e[i];if(a.offset>o.offset)return!1;a.offset!==o.offset&&(t.push(e[i]),n.has(a.offset)||n.set(a.offset,i),r.set(o.offset,i))}for(let t=0;t<e.length;t++){let{start:i,end:a}=e[t];if(i.offset===a.offset&&((n.get(i.offset)??t)<t||(r.get(i.offset)??t)>t))return!1}t.sort((e,t)=>e.start.offset-t.start.offset||t.end.offset-e.end.offset);let i=[];for(let{start:e,end:n}of t){for(;i.length&&i.at(-1)<=e.offset;)i.pop();if(i.length&&n.offset>i.at(-1))return!1;i.push(n.offset)}return!0}function Ku(e){return e.type===`text`?e.value:e.type===`element`?e.children.map(Ku).join(``):``}var qu=[Uu()];function Ju(e){let t=Yu(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...qu]}function Yu(e){let t=[],n=[],r=[];for(let i of e)switch(i.enforce){case`pre`:t.push(i);break;case`post`:n.push(i);break;default:r.push(i)}return{pre:t,post:n,normal:r}}var Xu=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Zu={1:`bold`,2:`dim`,3:`italic`,4:`underline`,7:`reverse`,8:`hidden`,9:`strikethrough`};function Qu(e,t){let n=e.indexOf(`\x1B`,t);if(n!==-1&&e[n+1]===`[`){let t=e.indexOf(`m`,n);if(t!==-1)return{sequence:e.substring(n+2,t).split(`;`),startPosition:n,position:t+1}}return{position:e.length}}function $u(e){let t=e.shift();if(t===`2`){let t=e.splice(0,3).map(e=>Number.parseInt(e));return t.length!==3||t.some(e=>Number.isNaN(e))?void 0:{type:`rgb`,rgb:t}}else if(t===`5`){let t=e.shift();if(t)return{type:`table`,index:Number(t)}}}function ed(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:`resetAll`});else if(r<=9)Zu[r]&&t.push({type:`setDecoration`,value:Zu[r]});else if(r<=29){let e=Zu[r-20];e&&(t.push({type:`resetDecoration`,value:e}),e===`dim`&&t.push({type:`resetDecoration`,value:`bold`}))}else if(r<=37)t.push({type:`setForegroundColor`,value:{type:`named`,name:Xu[r-30]}});else if(r===38){let n=$u(e);n&&t.push({type:`setForegroundColor`,value:n})}else if(r===39)t.push({type:`resetForegroundColor`});else if(r<=47)t.push({type:`setBackgroundColor`,value:{type:`named`,name:Xu[r-40]}});else if(r===48){let n=$u(e);n&&t.push({type:`setBackgroundColor`,value:n})}else r===49?t.push({type:`resetBackgroundColor`}):r===53?t.push({type:`setDecoration`,value:`overline`}):r===55?t.push({type:`resetDecoration`,value:`overline`}):r>=90&&r<=97?t.push({type:`setForegroundColor`,value:{type:`named`,name:Xu[r-90+8]}}):r>=100&&r<=107&&t.push({type:`setBackgroundColor`,value:{type:`named`,name:Xu[r-100+8]}})}return t}function td(){let e=null,t=null,n=new Set;return{parse(r){let i=[],a=0;do{let o=Qu(r,a),s=o.sequence?r.substring(a,o.startPosition):r.substring(a);if(s.length>0&&i.push({value:s,foreground:e,background:t,decorations:new Set(n)}),o.sequence){let r=ed(o.sequence);for(let i of r)i.type===`resetAll`?(e=null,t=null,n.clear()):i.type===`resetForegroundColor`?e=null:i.type===`resetBackgroundColor`?t=null:i.type===`resetDecoration`&&n.delete(i.value);for(let i of r)i.type===`setForegroundColor`?e=i.value:i.type===`setBackgroundColor`?t=i.value:i.type===`setDecoration`&&n.add(i.value)}a=o.position}while(a<r.length);return i}}}var nd={black:`#000000`,red:`#bb0000`,green:`#00bb00`,yellow:`#bbbb00`,blue:`#0000bb`,magenta:`#ff00ff`,cyan:`#00bbbb`,white:`#eeeeee`,brightBlack:`#555555`,brightRed:`#ff5555`,brightGreen:`#00ff00`,brightYellow:`#ffff55`,brightBlue:`#5555ff`,brightMagenta:`#ff55ff`,brightCyan:`#55ffff`,brightWhite:`#ffffff`};function rd(e=nd){function t(t){return e[t]}function n(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,`0`)).join(``)}`}let r;function i(){if(r)return r;r=[];for(let e=0;e<Xu.length;e++)r.push(t(Xu[e]));let e=[0,95,135,175,215,255];for(let t=0;t<6;t++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)r.push(n([e[t],e[i],e[a]]));let i=8;for(let e=0;e<24;e++,i+=10)r.push(n([i,i,i]));return r}function a(e){return i()[e]}function o(e){switch(e.type){case`named`:return t(e.name);case`rgb`:return n(e.rgb);case`table`:return a(e.index)}}return{value:o}}var id=/#([0-9a-f]{3,8})/i,ad=/var\((--[\w-]+-ansi-[\w-]+)\)/,od={black:`#000000`,red:`#cd3131`,green:`#0DBC79`,yellow:`#E5E510`,blue:`#2472C8`,magenta:`#BC3FBC`,cyan:`#11A8CD`,white:`#E5E5E5`,brightBlack:`#666666`,brightRed:`#F14C4C`,brightGreen:`#23D18B`,brightYellow:`#F5F543`,brightBlue:`#3B8EEA`,brightMagenta:`#D670D6`,brightCyan:`#29B8DB`,brightWhite:`#FFFFFF`};function sd(e,t,n){let r=wc(e,n),i=Nc(t),a=rd(Object.fromEntries(Xu.map(t=>{let n=`terminal.ansi${t[0].toUpperCase()}${t.substring(1)}`;return[t,e.colors?.[n]||od[t]]}))),o=td();return i.map(t=>o.parse(t[0]).map(n=>{let i,o;n.decorations.has(`reverse`)?(i=n.background?a.value(n.background):e.bg,o=n.foreground?a.value(n.foreground):e.fg):(i=n.foreground?a.value(n.foreground):e.fg,o=n.background?a.value(n.background):void 0),i=Tc(i,r),o=Tc(o,r),n.decorations.has(`dim`)&&(i=cd(i));let s=fs.None;return n.decorations.has(`bold`)&&(s|=fs.Bold),n.decorations.has(`italic`)&&(s|=fs.Italic),n.decorations.has(`underline`)&&(s|=fs.Underline),n.decorations.has(`strikethrough`)&&(s|=fs.Strikethrough),{content:n.value,offset:t[1],color:i,bgColor:o,fontStyle:s}}))}function cd(e){let t=e.match(id);if(t){let e=t[1];if(e.length===8){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,`0`);return`#${e.slice(0,6)}${t}`}else if(e.length===6)return`#${e}80`;else if(e.length===4){let t=e[0],n=e[1],r=e[2],i=e[3];return`#${t}${t}${n}${n}${r}${r}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,`0`)}`}else if(e.length===3){let t=e[0],n=e[1],r=e[2];return`#${t}${t}${n}${n}${r}${r}80`}}let n=e.match(ad);return n?`var(${n[1]}-dim)`:e}function ld(e,t,n={}){let r=e.resolveLangAlias(n.lang||`text`),{theme:i=e.getLoadedThemes()[0]}=n;if(!Oc(r)&&!Ac(i)&&r===`ansi`){let{theme:r}=e.setTheme(i);return sd(r,t,n)}return el(e,t,n)}function ud(e,t,n){let r,i,a,o,s,c;if(`themes`in n){let{defaultColor:l=`light`,cssVariablePrefix:u=`--shiki-`,colorsRendering:d=`css-vars`}=n,f=Object.entries(n.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===l?-1:+(t.color===l));if(f.length===0)throw new Wo("`themes` option must not be empty");let p=ll(e,t,n,ld);if(c=Jc(p),l&&l!==`light-dark()`&&!f.some(e=>e.color===l))throw new Wo(`\`themes\` option must contain the defaultColor key \`${l}\``);let m=f.map(t=>e.getTheme(t.theme)),h=f.map(e=>e.color);a=p.map(e=>e.map(e=>Bu(e,h,u,l,d))),c&&qc(a,c);let g=f.map(e=>wc(e.theme,n));i=dd(f,m,g,u,l,`fg`,d),r=dd(f,m,g,u,l,`bg`,d),o=`shiki-themes ${m.map(e=>e.name).join(` `)}`,s=l?void 0:[i,r].join(`;`)}else if(`theme`in n){let s=wc(n.theme,n);a=ld(e,t,n);let l=e.getTheme(n.theme);r=Tc(l.bg,s),i=Tc(l.fg,s),o=l.name,c=Jc(a)}else throw new Wo("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:r,themeName:o,rootStyle:s,grammarState:c}}function dd(e,t,n,r,i,a,o){return e.map((s,c)=>{let l=Tc(t[c][a],n[c])||`inherit`,u=`${r+s.color}${a===`bg`?`-bg`:``}:${l}`;if(c===0&&i){if(i===`light-dark()`&&e.length>1){let r=e.findIndex(e=>e.color===`light`),i=e.findIndex(e=>e.color===`dark`);if(r===-1||i===-1)throw new Wo('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Tc(t[r][a],n[r])||`inherit`}, ${Tc(t[i][a],n[i])||`inherit`});${u}`}return l}return o===`css-vars`?u:null}).filter(e=>!!e).join(`;`)}var fd=/^\s+$/,pd=/^(\s*)(.*?)(\s*)$/;function md(e,t,n,r={meta:{},options:n,codeToHast:(t,n)=>md(e,t,n),codeToTokens:(t,n)=>ud(e,t,n)}){let i=t;for(let e of Ju(n))i=e.preprocess?.call(r,i,n)||i;let{tokens:a,fg:o,bg:s,themeName:c,rootStyle:l,grammarState:u}=ud(e,i,n),{mergeWhitespaces:d=!0,mergeSameStyleTokens:f=!1}=n;d===!0?a=gd(a):d===`never`&&(a=_d(a)),f&&(a=vd(a));let p={...r,get source(){return i}};for(let e of Ju(n))a=e.tokens?.call(p,a)||a;return hd(a,{...n,fg:o,bg:s,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},p,u)}function hd(e,t,n,r=Jc(e)){let i=Ju(t),a=[],o={type:`root`,children:[]},{structure:s=`classic`,tabindex:c=`0`}=t,l={class:`shiki ${t.themeName||``}`};t.rootStyle!==!1&&(t.rootStyle==null?l.style=`background-color:${t.bg};color:${t.fg}`:l.style=t.rootStyle),c!==!1&&c!=null&&(l.tabindex=c.toString());for(let[e,n]of Object.entries(t.meta||{}))e.startsWith(`_`)||(l[e]=n);let u={type:`element`,tagName:`pre`,properties:l,children:[],data:t.data},d={type:`element`,tagName:`code`,properties:{},children:a},f=[],p={...n,structure:s,addClassToHast:Pu,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return o},get pre(){return u},get code(){return d},get lines(){return f}};if(e.forEach((e,t)=>{t&&(s===`inline`?o.children.push({type:`element`,tagName:`br`,properties:{},children:[]}):s===`classic`&&a.push({type:`text`,value:`
|
|
15
|
+
`}));let n={type:`element`,tagName:`span`,properties:{class:`line`},children:[]},r=0;for(let a of e){let e={type:`element`,tagName:`span`,properties:{...a.htmlAttrs},children:[{type:`text`,value:a.content}]},c=Hu(a.htmlStyle||Vu(a));c&&(e.properties.style=c);for(let o of i)e=o?.span?.call(p,e,t+1,r,n,a)||e;s===`inline`?o.children.push(e):s===`classic`&&n.children.push(e),r+=a.content.length}if(s===`classic`){for(let e of i)n=e?.line?.call(p,n,t+1)||n;f.push(n),a.push(n)}else s===`inline`&&f.push(n)}),s===`classic`){for(let e of i)d=e?.code?.call(p,d)||d;u.children.push(d);for(let e of i)u=e?.pre?.call(p,u)||u;o.children.push(u)}else if(s===`inline`){let e=[],t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]};for(let n of o.children)n.type===`element`&&n.tagName===`br`?(e.push(t),t={type:`element`,tagName:`span`,properties:{class:`line`},children:[]}):(n.type===`element`||n.type===`text`)&&t.children.push(n);e.push(t);let n={type:`element`,tagName:`code`,properties:{},children:e};for(let e of i)n=e?.code?.call(p,n)||n;o.children=[];for(let e=0;e<n.children.length;e++){e>0&&o.children.push({type:`element`,tagName:`br`,properties:{},children:[]});let t=n.children[e];t.type===`element`&&o.children.push(...t.children)}}let m=o;for(let e of i)m=e?.root?.call(p,m)||m;return r&&qc(m,r),m}function gd(e){return e.map(e=>{let t=[],n=``,r;return e.forEach((i,a)=>{let o=!(i.fontStyle&&(i.fontStyle&fs.Underline||i.fontStyle&fs.Strikethrough));o&&fd.test(i.content)&&e[a+1]?(r===void 0&&(r=i.offset),n+=i.content):n?(o?t.push({...i,offset:r,content:n+i.content}):t.push({content:n,offset:r},i),r=void 0,n=``):t.push(i)}),t})}function _d(e){return e.map(e=>e.flatMap(e=>{if(fd.test(e.content))return e;let t=e.content.match(pd);if(!t)return e;let[,n,r,i]=t;if(!n&&!i)return e;let a=[{...e,offset:e.offset+n.length,content:r}];return n&&a.unshift({content:n,offset:e.offset}),i&&a.push({content:i,offset:e.offset+n.length+r.length}),a}))}function vd(e){return e.map(e=>{let t=[];for(let n of e){if(t.length===0){t.push({...n});continue}let e=t.at(-1),r=Hu(e.htmlStyle||Vu(e)),i=Hu(n.htmlStyle||Vu(n)),a=e.fontStyle&&(e.fontStyle&fs.Underline||e.fontStyle&fs.Strikethrough),o=n.fontStyle&&(n.fontStyle&fs.Underline||n.fontStyle&fs.Strikethrough);!a&&!o&&r===i?e.content+=n.content:t.push({...n})}return t})}var yd=Au;function bd(e,t,n){let r={meta:{},options:n,codeToHast:(t,n)=>md(e,t,n),codeToTokens:(t,n)=>ud(e,t,n)},i=yd(md(e,t,n,r));for(let e of Ju(n))i=e.postprocess?.call(r,i,n)||i;return i}async function xd(e){let t=await Gc(e);return{getLastGrammarState:(...e)=>tl(t,...e),codeToTokensBase:(e,n)=>ld(t,e,n),codeToTokensWithThemes:(e,n)=>ll(t,e,n),codeToTokens:(e,n)=>ud(t,e,n),codeToHast:(e,n)=>md(t,e,n),codeToHtml:(e,n)=>bd(t,e,n),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}var Sd=4294967295;function Cd(e){return!e.sticky&&!e.rawOptions?.strategy}function wd(e,t){return{index:e,captureIndices:t.map(e=>e==null?{start:Sd,end:Sd,length:0}:{start:e[0],end:e[1],length:e[1]-e[0]})}}var Td=class{patterns;options;regexps;lastSearches;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}}),this.lastSearches=this.regexps.map(e=>e&&Cd(e)?{strId:0,searchedFrom:0,matchIndex:-1,indices:null}:null)}findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=typeof e==`string`?0:e.id||0,a=-1,o=0,s=null;for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{let c=i?this.lastSearches[e]:null,l,u;if(c&&c.strId===i&&c.searchedFrom<=t&&(c.matchIndex===-1||c.matchIndex>=t))l=c.matchIndex,u=c.indices;else{n.lastIndex=t;let e=n.exec(r);l=e?e.index:-1,u=e?e.indices:null,c&&(c.strId=i,c.searchedFrom=t,c.matchIndex=l,c.indices=u)}if(l===-1)continue;if(l===t)return wd(e,u);(a===-1||l<o)&&(a=e,o=l,s=u)}catch(e){if(this.options.forgiving)continue;throw e}}return a===-1?null:wd(a,s)}},Ed=0;function Dd(e){return{content:e,id:++Ed}}function Od(e){if([...e].length!==1)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function kd(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var Ad=new Set([`alnum`,`alpha`,`ascii`,`blank`,`cntrl`,`digit`,`graph`,`lower`,`print`,`punct`,`space`,`upper`,`word`,`xdigit`]),jd=String.raw;function Md(e,t){if(e==null)throw Error(t??`Value expected`);return e}var Nd=jd`\[\^?`,Pd=`c.? | C(?:-.?)?|${jd`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${jd`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${jd`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${jd`o\{[^\}]*\}?`}|${jd`\d{1,3}`}`,Fd=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Id=new RegExp(jd`
|
|
16
|
+
\\ (?:
|
|
17
|
+
${Pd}
|
|
18
|
+
| [gk]<[^>]*>?
|
|
19
|
+
| [gk]'[^']*'?
|
|
20
|
+
| .
|
|
21
|
+
)
|
|
22
|
+
| \( (?:
|
|
23
|
+
\? (?:
|
|
24
|
+
[:=!>({]
|
|
25
|
+
| <[=!]
|
|
26
|
+
| <[^>]*>
|
|
27
|
+
| '[^']*'
|
|
28
|
+
| ~\|?
|
|
29
|
+
| #(?:[^)\\]|\\.?)*
|
|
30
|
+
| [^:)]*[:)]
|
|
31
|
+
)?
|
|
32
|
+
| \*[^\)]*\)?
|
|
33
|
+
)?
|
|
34
|
+
| (?:${Fd.source})+
|
|
35
|
+
| ${Nd}
|
|
36
|
+
| .
|
|
37
|
+
`.replace(/\s+/g,``),`gsu`),Ld=new RegExp(jd`
|
|
38
|
+
\\ (?:
|
|
39
|
+
${Pd}
|
|
40
|
+
| .
|
|
41
|
+
)
|
|
42
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
43
|
+
| ${Nd}
|
|
44
|
+
| &&
|
|
45
|
+
| .
|
|
46
|
+
`.replace(/\s+/g,``),`gsu`);function Rd(e,t={}){let n={flags:``,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!=`string`)throw Error(`String expected as pattern`);let r=hf(n.flags),i=[r.extended],a={captureGroup:n.rules.captureGroup,getCurrentModX(){return i.at(-1)},numOpenGroups:0,popModX(){i.pop()},pushModX(e){i.push(e)},replaceCurrentModX(e){i[i.length-1]=e},singleline:n.rules.singleline},o=[],s;for(Id.lastIndex=0;s=Id.exec(e);){let t=zd(a,e,s[0],Id.lastIndex);t.tokens?o.push(...t.tokens):t.token&&o.push(t.token),t.lastIndex!==void 0&&(Id.lastIndex=t.lastIndex)}let c=[],l=0;o.filter(e=>e.type===`GroupOpen`).forEach(e=>{e.kind===`capturing`?e.number=++l:e.raw===`(`&&c.push(e)}),l||c.forEach((e,t)=>{e.kind=`capturing`,e.number=t+1});let u=l||c.length;return{tokens:o.map(e=>e.type===`EscapedNumber`?_f(e,u):e).flat(),flags:r}}function zd(e,t,n,r){let[i,a]=n;if(n===`[`||n===`[^`){let e=Bd(t,n,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if(i===`\\`){if(`AbBGyYzZ`.includes(a))return{token:Wd(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:af(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw Error(`Invalid group name "${n}"`);return{token:Gd(n)}}if(a===`K`)return{token:Qd(`keep`,n)};if(a===`N`||a===`R`)return{token:Zd(`newline`,n,{negate:a===`N`})};if(a===`O`)return{token:Zd(`any`,n)};if(a===`X`)return{token:Zd(`text_segment`,n)};let e=Hd(n,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if(i===`(`){if(a===`*`)return{token:uf(n)};if(n===`(?{`)throw Error(`Unsupported callout "${n}"`);if(n.startsWith(`(?#`)){if(t[r]!==`)`)throw Error(`Unclosed comment group "(?#"`);return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:lf(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n===`(`&&!e.captureGroup||n===`(?:`)return{token:tf(`group`,n)};if(n===`(?>`)return{token:tf(`atomic`,n)};if(n===`(?=`||n===`(?!`||n===`(?<=`||n===`(?<!`)return{token:tf(n[2]===`<`?`lookbehind`:`lookahead`,n,{negate:n.endsWith(`!`)})};if(n===`(`&&e.captureGroup||n.startsWith(`(?<`)&&n.endsWith(`>`)||n.startsWith(`(?'`)&&n.endsWith(`'`))return{token:tf(`capturing`,n,{...n!==`(`&&{name:n.slice(3,-1)}})};if(n.startsWith(`(?~`)){if(n===`(?~|`)throw Error(`Unsupported absence function kind "${n}"`);return{token:tf(`absence_repeater`,n)}}throw Error(n===`(?(`?`Unsupported conditional "${n}"`:`Invalid or unsupported group option "${n}"`)}if(n===`)`){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error(`Unmatched ")"`);return{token:ef(n)}}if(e.getCurrentModX()){if(n===`#`){let e=t.indexOf(`
|
|
47
|
+
`,r);return{lastIndex:e===-1?t.length:e}}if(/^\s$/.test(n)){let e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(t)?e.lastIndex:r}}}return n===`.`?{token:Zd(`dot`,n)}:n===`^`||n===`$`?{token:Wd(e.singleline?{"^":jd`\A`,$:jd`\Z`}[n]:n,n)}:n===`|`?{token:Ud(n)}:Fd.test(n)?{tokens:vf(n)}:{token:Kd(Od(n),n)}}function Bd(e,t,n){let r=[Xd(t[1]===`^`,t)],i=1,a;for(Ld.lastIndex=n;a=Ld.exec(e);){let e=a[0];if(e[0]===`[`&&e[1]!==`:`)i++,r.push(Xd(e[1]===`^`,e));else if(e===`]`){if(r.at(-1).type===`CharacterClassOpen`)r.push(Kd(93,e));else if(i--,r.push(qd(e)),!i)break}else{let t=Vd(e);Array.isArray(t)?r.push(...t):r.push(t)}}return{tokens:r,lastIndex:Ld.lastIndex||e.length}}function Vd(e){if(e[0]===`\\`)return Hd(e,{inCharClass:!0});if(e[0]===`[`){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Ad.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return Zd(`posix`,e,{value:t.groups.name,negate:!!t.groups.negate})}return e===`-`?Jd(e):e===`&&`?Yd(e):Kd(Od(e),e)}function Hd(e,{inCharClass:t}){let n=e[1];if(n===`c`||n===`C`)return cf(e);if(`dDhHsSwW`.includes(n))return ff(e);if(e.startsWith(jd`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw Error(`Incomplete or invalid Unicode property "${e}"`);return pf(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),n=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),r=new TextEncoder;return[...n].map(e=>{let t=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join(``);return Kd(Od(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n===`u`||n===`x`)return Kd(gf(e),e);if(sf.has(n))return Kd(sf.get(n),e);if(/\d/.test(n))return $d(t,e);if(e===`\\`)throw Error(jd`Incomplete escape "\"`);if(n===`M`)throw Error(`Unsupported meta "${e}"`);if([...e].length===2)return Kd(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function Ud(e){return{type:`Alternator`,raw:e}}function Wd(e,t){return{type:`Assertion`,kind:e,raw:t}}function Gd(e){return{type:`Backreference`,raw:e}}function Kd(e,t){return{type:`Character`,value:e,raw:t}}function qd(e){return{type:`CharacterClassClose`,raw:e}}function Jd(e){return{type:`CharacterClassHyphen`,raw:e}}function Yd(e){return{type:`CharacterClassIntersector`,raw:e}}function Xd(e,t){return{type:`CharacterClassOpen`,negate:e,raw:t}}function Zd(e,t,n={}){return{type:`CharacterSet`,kind:e,...n,raw:t}}function Qd(e,t,n={}){return e===`keep`?{type:`Directive`,kind:e,raw:t}:{type:`Directive`,kind:e,flags:Md(n.flags),raw:t}}function $d(e,t){return{type:`EscapedNumber`,inCharClass:e,raw:t}}function ef(e){return{type:`GroupClose`,raw:e}}function tf(e,t,n={}){return{type:`GroupOpen`,kind:e,...n,raw:t}}function nf(e,t,n,r){return{type:`NamedCallout`,kind:e,tag:t,arguments:n,raw:r}}function rf(e,t,n,r){return{type:`Quantifier`,kind:e,min:t,max:n,raw:r}}function af(e){return{type:`Subroutine`,raw:e}}var of=new Set([`COUNT`,`CMP`,`ERROR`,`FAIL`,`MAX`,`MISMATCH`,`SKIP`,`TOTAL_COUNT`]),sf=new Map([[`a`,7],[`b`,8],[`e`,27],[`f`,12],[`n`,10],[`r`,13],[`t`,9],[`v`,11]]);function cf(e){let t=e[1]===`c`?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${e}"`);return Kd(Od(t.toUpperCase())-64,e)}function lf(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??=``;let i=(t.getCurrentModX()||n.includes(`x`))&&!r.includes(`x`),a=mf(n),o=mf(r),s={};if(a&&(s.enable=a),o&&(s.disable=o),e.endsWith(`)`))return t.replaceCurrentModX(i),Qd(`flags`,e,{flags:s});if(e.endsWith(`:`))return t.pushModX(i),t.numOpenGroups++,tf(`group`,e,{...(a||o)&&{flags:s}});throw Error(`Unexpected flag modifier "${e}"`)}function uf(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:i}=t.groups;if(!n)throw Error(`Invalid named callout "${e}"`);if(r===``)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(`,`).filter(e=>e!==``).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[o,s,c]=a,l=of.has(n)?n.toLowerCase():`custom`;switch(l){case`fail`:case`mismatch`:case`skip`:if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case`error`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(typeof o==`string`)throw Error(`Named callout argument must be a number "${o}"`);break;case`max`:if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(a.length===2&&(typeof s==`number`||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${s}"`);break;case`count`:case`total_count`:if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(a.length===1&&(typeof o==`number`||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${o}"`);break;case`cmp`:if(a.length!==3)throw Error(`Named callout must have three arguments "${a}"`);if(typeof o==`string`&&!/^[A-Za-z_]\w*$/.test(o))throw Error(`Named callout argument one must be a tag or number "${o}"`);if(typeof s==`number`||!/^(?:[<>!=]=|[<>])$/.test(s))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${s}"`);if(typeof c==`string`&&!/^[A-Za-z_]\w*$/.test(c))throw Error(`Named callout argument three must be a tag or number "${c}"`);break;case`custom`:throw Error(`Undefined callout name "${n}"`);default:throw Error(`Unexpected named callout kind "${l}"`)}return nf(l,r??null,i?.split(`,`)??null,e)}function df(e){let t=null,n,r;if(e[0]===`{`){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,o=1e5;if(+i>o||a&&+a>o)throw Error(`Quantifier value unsupported in Oniguruma`);if(n=+i,r=a===void 0?+i:a===``?1/0:+a,n>r&&(t=`possessive`,[n,r]=[r,n]),e.endsWith(`?`)){if(t===`possessive`)throw Error(`Unsupported possessive interval quantifier chain with "?"`);t=`lazy`}else t||=`greedy`}else n=+(e[0]===`+`),r=e[0]===`?`?1:1/0,t=e[1]===`+`?`possessive`:e[1]===`?`?`lazy`:`greedy`;return rf(t,n,r,e)}function ff(e){let t=e[1].toLowerCase();return Zd({d:`digit`,h:`hex`,s:`space`,w:`word`}[t],e,{negate:e[1]!==t})}function pf(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Zd(`property`,e,{value:r,negate:t===`P`&&!n||t===`p`&&!!n})}function mf(e){let t={};return e.includes(`i`)&&(t.ignoreCase=!0),e.includes(`m`)&&(t.dotAll=!0),e.includes(`x`)&&(t.extended=!0),Object.keys(t).length?t:null}function hf(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!`imxDPSWy`.includes(r))throw Error(`Invalid flag "${r}"`);if(r===`y`){if(!/^y{[gw]}/.test(e.slice(n)))throw Error(`Invalid or unspecified flag "y" mode`);t.textSegmentMode=e[n+2]===`g`?`grapheme`:`word`,n+=3;continue}t[{i:`ignoreCase`,m:`dotAll`,x:`extended`,D:`digitIsAscii`,P:`posixIsAscii`,S:`spaceIsAscii`,W:`wordIsAscii`}[r]]=!0}return t}function gf(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);let t=e[2]===`{`?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function _f(e,t){let{raw:n,inCharClass:r}=e,i=n.slice(1);if(!r&&(i!==`0`&&i.length===1||i[0]!==`0`&&+i<=t))return[Gd(n)];let a=[],o=i.match(/^[0-7]+|\d/g);for(let e=0;e<o.length;e++){let t=o[e],r;if(e===0&&t!==`8`&&t!==`9`){if(r=parseInt(t,8),r>127)throw Error(jd`Octal encoded byte above 177 unsupported "${n}"`)}else r=Od(t);a.push(Kd(r,(e===0?`\\`:``)+t))}return a}function vf(e){let t=[],n=new RegExp(Fd,`gy`),r;for(;r=n.exec(e);){let e=r[0];if(e[0]===`{`){let r=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(r){let{min:i,max:a}=r.groups;if(+i>+a&&e.endsWith(`?`)){n.lastIndex--,t.push(df(e.slice(0,-1)));continue}}}t.push(df(e))}return t}function yf(e,t){if(!Array.isArray(e.body))throw Error(`Expected node with body array`);if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(e=>t[e]===n[e])}function bf(e){return xf.has(e.type)}var xf=new Set([`AbsenceFunction`,`Backreference`,`CapturingGroup`,`Character`,`CharacterClass`,`CharacterSet`,`Group`,`Quantifier`,`Subroutine`]);function Sf(e,t={}){let n={flags:``,normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=Rd(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),i=(e,t)=>{let n=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,n.type){case`Alternator`:return Mf();case`Assertion`:return Cf(n);case`Backreference`:return wf(n,a);case`Character`:return If(n.value,{useLastValid:!!t.isCheckingRangeEnd});case`CharacterClassHyphen`:return Tf(n,a,t);case`CharacterClassOpen`:return Ef(n,a,t);case`CharacterSet`:return Df(n,a);case`Directive`:return Bf(n.kind,{flags:n.flags});case`GroupOpen`:return Of(n,a,t);case`NamedCallout`:return Wf(n.kind,n.tag,n.arguments);case`Quantifier`:return kf(n,a);case`Subroutine`:return Af(n,a);default:throw Error(`Unexpected token type "${n.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:i},o=qf(Vf(r.flags)),s=o.body[0];for(;a.nextIndex<r.tokens.length;){let e=i(s,{});e.type===`Alternative`?(o.body.push(e),s=e):s.body.push(e)}let{capturingGroups:c,hasNumberedRef:l,namedGroupsByName:u,subroutines:d}=a;if(l&&u.size&&!n.rules.captureGroup)throw Error(`Numbered backref/subroutine not allowed when using named capture`);for(let{ref:e}of d)if(typeof e==`number`){if(e>c.length)throw Error(`Subroutine uses a group number that's not defined`);e&&(c[e-1].isSubroutined=!0)}else if(u.has(e)){if(u.get(e).length>1)throw Error(jd`Subroutine uses a duplicate group name "\g<${e}>"`);u.get(e)[0].isSubroutined=!0}else throw Error(jd`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function Cf({kind:e}){return Nf(Md({"^":`line_start`,$:`line_end`,"\\A":`string_start`,"\\b":`word_boundary`,"\\B":`word_boundary`,"\\G":`search_start`,"\\y":`text_segment_boundary`,"\\Y":`text_segment_boundary`,"\\z":`string_end`,"\\Z":`string_end_newline`}[e],`Unexpected assertion kind "${e}"`),{negate:e===jd`\B`||e===jd`\Y`})}function wf({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),i=(n,r=!1)=>{let i=t.capturingGroups.length,a=!1;if(n>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,Pf(r?i+1-n:n,{orphan:a})};if(n){let n=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(n)return i(+n.groups.num,!!n.groups.sign);if(/[-+]/.test(r))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw Error(`Group name not defined to the left "${e}"`);return Pf(r)}return i(+r)}function Tf(e,t,n){let{tokens:r,walk:i}=t,a=t.parent,o=a.body.at(-1),s=r[t.nextIndex];if(!n.isCheckingRangeEnd&&o&&o.type!==`CharacterClass`&&o.type!==`CharacterClassRange`&&s&&s.type!==`CharacterClassOpen`&&s.type!==`CharacterClassClose`&&s.type!==`CharacterClassIntersector`){let e=i(a,{...n,isCheckingRangeEnd:!0});if(o.type===`Character`&&e.type===`Character`)return a.body.pop(),Rf(o,e);throw Error(`Invalid character class range`)}return If(Od(`-`))}function Ef({negate:e},t,n){let{tokens:r,walk:i}=t,a=[Lf()],o=r[t.nextIndex],s=ip(o);for(;s.type!==`CharacterClassClose`;){if(s.type===`CharacterClassIntersector`)a.push(Lf()),t.nextIndex++;else{let e=a.at(-1);e.body.push(i(e,n))}s=ip(r[t.nextIndex],o)}let c=Lf({negate:e});return a.length===1?c.body=a[0].body:(c.kind=`intersection`,c.body=a.map(e=>e.body.length===1?e.body[0]:e)),t.nextIndex++,c}function Df({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o}=r;if(e===`property`){let r=rp(n);if(Ad.has(r)&&!o?.has(r))e=`posix`,n=r;else return Yf(n,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:o})}return e===`posix`?Gf(n,{negate:t}):zf(e,{negate:t})}function Of(e,t,n){let{tokens:r,capturingGroups:i,namedGroupsByName:a,skipLookbehindValidation:o,walk:s}=t,c=Xf(e),l=c.type===`AbsenceFunction`,u=ep(c),d=u&&c.negate;if(c.type===`CapturingGroup`&&(i.push(c),c.name&&kd(a,c.name,[]).push(c)),l&&n.isInAbsenceFunction)throw Error(`Nested absence function not supported by Oniguruma`);let f=ap(r[t.nextIndex]);for(;f.type!==`GroupClose`;){if(f.type===`Alternator`)c.body.push(Mf()),t.nextIndex++;else{let e=c.body.at(-1),t=s(e,{...n,isInAbsenceFunction:n.isInAbsenceFunction||l,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||d});if(e.body.push(t),(u||n.isInLookbehind)&&!o){let e=`Lookbehind includes a pattern not allowed by Oniguruma`;if(d||n.isInNegLookbehind){if($f(t)||t.type===`CapturingGroup`)throw Error(e)}else if($f(t)||ep(t)&&t.negate)throw Error(e)}}f=ap(r[t.nextIndex])}return t.nextIndex++,c}function kf({kind:e,min:t,max:n},r){let i=r.parent,a=i.body.at(-1);if(!a||!bf(a))throw Error(`Quantifier requires a repeatable token`);let o=Kf(e,t,n,a);return i.body.pop(),o}function Af({raw:e},t){let{capturingGroups:n,subroutines:r}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,r=n.length;if(t.hasNumberedRef=!0,i={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],i<1)throw Error(`Invalid subroutine number`)}else i===`0`&&(i=0);let o=Jf(i);return r.push(o),o}function jf(e,t){if(e!==`repeater`)throw Error(`Unexpected absence function kind "${e}"`);return{type:`AbsenceFunction`,kind:e,body:Zf(t?.body)}}function Mf(e){return{type:`Alternative`,body:Qf(e?.body)}}function Nf(e,t){let n={type:`Assertion`,kind:e};return(e===`word_boundary`||e===`text_segment_boundary`)&&(n.negate=!!t?.negate),n}function Pf(e,t){let n=!!t?.orphan;return{type:`Backreference`,ref:e,...n&&{orphan:n}}}function Ff(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!tp(n.name))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:`CapturingGroup`,number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:Zf(t?.body)}}function If(e,t){let n={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(n.useLastValid)e=1114111;else throw Error(e>1310719?`Invalid code point out of range "\\x{${t}}"`:`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:`Character`,value:e}}function Lf(e){let t={kind:`union`,negate:!1,...e};return{type:`CharacterClass`,kind:t.kind,negate:t.negate,body:Qf(e?.body)}}function Rf(e,t){if(t.value<e.value)throw Error(`Character class range out of order`);return{type:`CharacterClassRange`,min:e,max:t}}function zf(e,t){let n=!!t?.negate,r={type:`CharacterSet`,kind:e};return(e===`digit`||e===`hex`||e===`newline`||e===`space`||e===`word`)&&(r.negate=n),(e===`text_segment`||e===`newline`&&!n)&&(r.variableLength=!0),r}function Bf(e,t={}){if(e===`keep`)return{type:`Directive`,kind:e};if(e===`flags`)return{type:`Directive`,kind:e,flags:Md(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}function Vf(e){return{type:`Flags`,...e}}function Hf(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw Error(`Atomic group cannot have flags`);return{type:`Group`,...t&&{atomic:t},...n&&{flags:n},body:Zf(e?.body)}}function Uf(e){let t={behind:!1,negate:!1,...e};return{type:`LookaroundAssertion`,kind:t.behind?`lookbehind`:`lookahead`,negate:t.negate,body:Zf(e?.body)}}function Wf(e,t,n){return{type:`NamedCallout`,kind:e,tag:t,arguments:n}}function Gf(e,t){let n=!!t?.negate;if(!Ad.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:`CharacterSet`,kind:`posix`,value:e,negate:n}}function Kf(e,t,n,r){if(t>n)throw Error(`Invalid reversed quantifier range`);return{type:`Quantifier`,kind:e,min:t,max:n,body:r}}function qf(e,t){return{type:`Regex`,body:Zf(t?.body),flags:e}}function Jf(e){return{type:`Subroutine`,ref:e}}function Yf(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(rp(e));if(!r){if(n.normalizeUnknownPropertyNames)r=np(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw Error(jd`Invalid Unicode property "\p{${e}}"`)}return{type:`CharacterSet`,kind:`property`,value:r??e,negate:n.negate}}function Xf({flags:e,kind:t,name:n,negate:r,number:i}){switch(t){case`absence_repeater`:return jf(`repeater`);case`atomic`:return Hf({atomic:!0});case`capturing`:return Ff(i,{name:n});case`group`:return Hf({flags:e});case`lookahead`:case`lookbehind`:return Uf({behind:t===`lookbehind`,negate:r});default:throw Error(`Unexpected group kind "${t}"`)}}function Zf(e){if(e===void 0)e=[Mf()];else if(!Array.isArray(e)||!e.length||!e.every(e=>e.type===`Alternative`))throw Error(`Invalid body; expected array of one or more Alternative nodes`);return e}function Qf(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error(`Invalid body; expected array of nodes`);return e}function $f(e){return e.type===`LookaroundAssertion`&&e.kind===`lookahead`}function ep(e){return e.type===`LookaroundAssertion`&&e.kind===`lookbehind`}function tp(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function np(e){return e.trim().replace(/[- _]+/g,`_`).replace(/[A-Z][a-z]+(?=[A-Z])/g,`$&_`).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function rp(e){return e.replace(/[- _]+/g,``).toLowerCase()}function ip(e,t){let n=t;return Md(e,`Unclosed character class${n?.type===`Character`&&n.value===93&&n.raw===`]`?` (started with "]")`:``}`)}function ap(e){return Md(e,`Unclosed group`)}function op(e,t,n=null){function r(e,t){for(let n=0;n<e.length;n++){let r=i(e[n],t,n,e);n=Math.max(-1,n+r)}}function i(a,o=null,s=null,c=null){let l=0,u=!1,d={node:a,parent:o,key:s,container:c,root:e,remove(){sp(c).splice(Math.max(0,cp(s)+l),1),l--,u=!0},removeAllNextSiblings(){return sp(c).splice(cp(s)+1)},removeAllPrevSiblings(){let e=cp(s)+l;return l-=e,sp(c).splice(0,Math.max(0,e))},replaceWith(e,t={}){let n=!!t.traverse;c?c[Math.max(0,cp(s)+l)]=e:Md(o,`Can't replace root node`)[s]=e,n&&i(e,o,s,c),u=!0},replaceWithMultiple(e,t={}){let n=!!t.traverse;if(sp(c).splice(Math.max(0,cp(s)+l),1,...e),l+=e.length-1,n){let t=0;for(let n=0;n<e.length;n++)t+=i(e[n],o,cp(s)+n+t,c)}u=!0},skip(){u=!0}},{type:f}=a,p=t[`*`],m=t[f],h=typeof p==`function`?p:p?.enter,g=typeof m==`function`?m:m?.enter;if(h?.(d,n),g?.(d,n),!u)switch(f){case`AbsenceFunction`:case`Alternative`:case`CapturingGroup`:case`CharacterClass`:case`Group`:case`LookaroundAssertion`:r(a.body,a);break;case`Assertion`:case`Backreference`:case`Character`:case`CharacterSet`:case`Directive`:case`Flags`:case`NamedCallout`:case`Subroutine`:break;case`CharacterClassRange`:i(a.min,a,`min`),i(a.max,a,`max`);break;case`Quantifier`:i(a.body,a,`body`);break;case`Regex`:r(a.body,a),i(a.flags,a,`flags`);break;default:throw Error(`Unexpected node type "${f}"`)}return m?.exit?.(d,n),p?.exit?.(d,n),l}return i(e),e}function sp(e){if(!Array.isArray(e))throw Error(`Container expected`);return e}function cp(e){if(typeof e!=`number`)throw Error(`Numeric key expected`);return e}var lp=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function up(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function dp(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var fp=Object.freeze({DEFAULT:`DEFAULT`,CHAR_CLASS:`CHAR_CLASS`});function pp(e,t,n,r){let i=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,`gsu`),a=[!1],o=0,s=``;for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!r||r===fp.DEFAULT==!o)){n instanceof Function?s+=n(t,{context:o?fp.CHAR_CLASS:fp.DEFAULT,negated:a[a.length-1]}):s+=n;continue}e[0]===`[`?(o++,a.push(e[1]===`^`)):e===`]`&&o&&(o--,a.pop()),s+=e}return s}function mp(e,t,n,r){pp(e,t,n,r)}function hp(e,t,n=0,r){if(!new RegExp(t,`su`).test(e))return null;let i=RegExp(`${t}|(?<$skip>\\\\?.)`,`gsu`);i.lastIndex=n;let a=0,o;for(;o=i.exec(e);){let{0:e,groups:{$skip:t}}=o;if(!t&&(!r||r===fp.DEFAULT==!a))return o;e===`[`?a++:e===`]`&&a&&a--,i.lastIndex==o.index&&i.lastIndex++}return null}function gp(e,t,n){return!!hp(e,t,0,n)}function _p(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,i=0,a=1,o;for(;o=n.exec(e);){let[e]=o;if(e===`[`)i++;else if(i)e===`]`&&i--;else if(e===`(`)a++;else if(e===`)`&&(a--,!a)){r=o.index;break}}return e.slice(t,r)}var vp=new RegExp(String.raw`(?<noncapturingStart>${lp})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,`gsu`);function yp(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let i=[0],a=[],o=0,s=0,c=NaN,l;do{l=!1;let t=0,u=0,d=!1,f;for(vp.lastIndex=Number.isNaN(c)?0:c+7;f=vp.exec(e);){let{0:p,index:m,groups:{capturingStart:h,noncapturingStart:g}}=f;if(p===`[`)t++;else if(t)p===`]`&&t--;else if(p===`(?>`&&!d)c=m,d=!0;else if(d&&g)u++;else if(h)d?u++:(o++,i.push(o+s));else if(p===`)`&&d){if(!u){s++;let t=o+s;if(e=`${e.slice(0,c)}(?:(?=(${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,l=!0,a.push(t),up(n,t),r.size){let e=new Map;r.forEach((n,r)=>{e.set(r>=t?r+1:r,n.map(e=>e>=t?e+1:e))}),r=e}break}u--}}}while(l);return n.push(...a),e=pp(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:n}})=>{if(t){let n=+t;if(n>i.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${i[n]}`}return`\\${n}`},fp.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var bp=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,xp=new RegExp(String.raw`
|
|
48
|
+
\\(?: \d+
|
|
49
|
+
| c[A-Za-z]
|
|
50
|
+
| [gk]<[^>]+>
|
|
51
|
+
| [pPu]\{[^\}]+\}
|
|
52
|
+
| u[A-Fa-f\d]{4}
|
|
53
|
+
| x[A-Fa-f\d]{2}
|
|
54
|
+
)
|
|
55
|
+
| \((?: \? (?: [:=!>]
|
|
56
|
+
| <(?:[=!]|[^>]+>)
|
|
57
|
+
| [A-Za-z\-]+:
|
|
58
|
+
| \(DEFINE\)
|
|
59
|
+
))?
|
|
60
|
+
| (?<qBase>${bp})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
61
|
+
| \\?.
|
|
62
|
+
`.replace(/\s+/g,``),`gsu`);function Sp(e){if(!RegExp(`${bp}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,i=``,a=0,o;for(xp.lastIndex=0;o=xp.exec(e);){let{0:s,index:c,groups:{qBase:l,qMod:u,invalidQ:d}}=o;if(s===`[`)a||(r=c),a++;else if(s===`]`)a?a--:r=null;else if(!a)if(u===`+`&&i&&!i.startsWith(`(`)){if(d)throw Error(`Invalid quantifier "${s}"`);let t=-1;if(/^\{\d+\}$/.test(l))e=dp(e,c+l.length,u,``);else{if(i===`)`||i===`]`){let t=i===`)`?n:r;if(t===null)throw Error(`Invalid unmatched "${i}"`);e=`${e.slice(0,t)}(?>${e.slice(t,c)}${l})${e.slice(c+s.length)}`}else e=`${e.slice(0,c-i.length)}(?>${i}${l})${e.slice(c+s.length)}`;t+=4}xp.lastIndex+=t}else s[0]===`(`?t.push(c):s===`)`&&(n=t.length?t.pop():null);i=s}return{pattern:e}}var Cp=String.raw,wp=Cp`\(\?R=(?<rDepth>[^\)]+)\)|${Cp`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`}`,Tp=Cp`\(\?<(?![=!])(?<captureName>[^>]+)>`,Ep=Cp`${Tp}|(?<unnamed>\()(?!\?)`,Dp=new RegExp(Cp`${Tp}|${wp}|\(\?|\\?.`,`gsu`),Op=`Cannot use multiple overlapping recursions`;function kp(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:`plugin`,...t},i=t?.captureTransfers??new Map;if(!new RegExp(wp,`su`).test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};if(r===`plugin`&&gp(e,Cp`\(\?\(DEFINE\)`,fp.DEFAULT))throw Error(`DEFINE groups cannot be used with recursion`);let a=[],o=gp(e,Cp`\\[1-9]`,fp.DEFAULT),s=new Map,c=[],l=!1,u=0,d=0,f;for(Dp.lastIndex=0;f=Dp.exec(e);){let{0:t,groups:{captureName:p,rDepth:m,gRNameOrNum:h,gRDepth:g}}=f;if(t===`[`)u++;else if(u)t===`]`&&u--;else if(m){if(Ap(m),l)throw Error(Op);if(o)throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with global recursion`);let t=e.slice(0,f.index),s=e.slice(Dp.lastIndex);if(gp(s,wp,fp.DEFAULT))throw Error(Op);let c=m-1;e=jp(t,s,c,!1,n,a,d),i=Pp(i,t,c,a.length,0,d);break}else if(h){Ap(g);let u=!1;for(let e of c)if(e.name===h||e.num===+h){if(u=!0,e.hasRecursedWithin)throw Error(Op);break}if(!u)throw Error(Cp`Recursive \g cannot be used outside the referenced group "${r===`external`?h:Cp`\g<${h}&R=${g}>`}"`);let p=s.get(h),m=_p(e,p);if(o&&gp(m,Cp`${Tp}|\((?!\?)`,fp.DEFAULT))throw Error(`${r===`external`?`Backrefs`:`Numbered backrefs`} cannot be used with recursion of capturing groups`);let _=e.slice(p,f.index),v=m.slice(_.length+t.length),y=a.length,b=g-1,x=jp(_,v,b,!0,n,a,d);i=Pp(i,_,b,a.length-y,y,d),e=`${e.slice(0,p)}${x}${e.slice(p+m.length)}`,Dp.lastIndex+=x.length-t.length-_.length-v.length,c.forEach(e=>e.hasRecursedWithin=!0),l=!0}else if(p)d++,s.set(String(d),Dp.lastIndex),s.set(p,Dp.lastIndex),c.push({num:d,name:p});else if(t[0]===`(`){let e=t===`(`;e&&(d++,s.set(String(d),Dp.lastIndex)),c.push(e?{num:d}:{})}else t===`)`&&c.pop()}return n.push(...a),{pattern:e,captureTransfers:i,hiddenCaptures:n}}function Ap(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e)||(e=+e,e<2||e>100))throw Error(t)}function jp(e,t,n,r,i,a,o){let s=new Set;r&&mp(e+t,Tp,({groups:{captureName:e}})=>{s.add(e)},fp.DEFAULT);let c=[n,r?s:null,i,a,o];return`${e}${Mp(`(?:${e}`,`forward`,...c)}(?:)${Mp(`${t})`,`backward`,...c)}${t}`}function Mp(e,t,n,r,i,a,o){let s=e=>t===`forward`?e+2:n-e+2-1,c=``;for(let t=0;t<n;t++){let n=s(t);c+=pp(e,Cp`${Ep}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:s,backref:c}})=>{if(c&&r&&!r.has(c))return e;let l=`_$${n}`;if(s||t){let n=o+a.length+1;return a.push(n),Np(i,n),s?e:`(?<${t}${l}>`}return Cp`\k<${c}${l}>`},fp.DEFAULT)}return c}function Np(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function Pp(e,t,n,r,i,a){if(e.size&&r){let o=0;mp(t,Ep,()=>o++,fp.DEFAULT);let s=a-o+i,c=new Map;return e.forEach((e,t)=>{let i=(r-o*n)/n,a=o*n,l=t>s+o?t+r:t,u=[];for(let t of e)if(t<=s)u.push(t);else if(t>s+o+i)u.push(t+r);else if(t<=s+o)for(let e=0;e<=n;e++)u.push(t+o*e);else for(let e=0;e<=n;e++)u.push(t+a+i*e);c.set(l,u)}),c}return e}var Fp=String.fromCodePoint,B=String.raw,Ip={},Lp=globalThis.RegExp;Ip.flagGroups=(()=>{try{new Lp(`(?i:)`)}catch{return!1}return!0})(),Ip.unicodeSets=(()=>{try{new Lp(`[[]]`,`v`)}catch{return!1}return!0})(),Ip.bugFlagVLiteralHyphenIsRange=Ip.unicodeSets?(()=>{try{new Lp(B`[\d\-a]`,`v`)}catch{return!0}return!1})():!1,Ip.bugNestedClassIgnoresNegation=Ip.unicodeSets&&new Lp(`[[^a]]`,`v`).test(`a`);function Rp(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function zp(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function Bp(e,t){return Hp[e]>=Hp[t]}function Vp(e,t){if(e==null)throw Error(t??`Value expected`);return e}var Hp={ES2025:2025,ES2024:2024,ES2018:2018},Up={auto:`auto`,ES2025:`ES2025`,ES2024:`ES2024`,ES2018:`ES2018`};function Wp(e={}){if({}.toString.call(e)!==`[object Object]`)throw Error(`Unexpected options`);if(e.target!==void 0&&!Up[e.target])throw Error(`Unexpected target "${e.target}"`);let t={accuracy:`default`,avoidSubclass:!1,flags:``,global:!1,hasIndices:!1,lazyCompileLength:1/0,target:`auto`,verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target===`auto`&&(t.target=Ip.flagGroups?`ES2025`:Ip.unicodeSets?`ES2024`:`ES2018`),t}var Gp=`[ -\r ]`,Kp=new Set([Fp(304),Fp(305)]),qp=B`[\p{L}\p{M}\p{N}\p{Pc}]`;function Jp(e){if(Kp.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),i=Qp.get(n),a=Xp.get(n),o=Zp.get(n);return[...r].length===1&&t.add(r),o&&t.add(o),i&&t.add(i),t.add(n),a&&t.add(a),[...t]}var Yp=new Map(`C Other
|
|
63
|
+
Cc Control cntrl
|
|
64
|
+
Cf Format
|
|
65
|
+
Cn Unassigned
|
|
66
|
+
Co Private_Use
|
|
67
|
+
Cs Surrogate
|
|
68
|
+
L Letter
|
|
69
|
+
LC Cased_Letter
|
|
70
|
+
Ll Lowercase_Letter
|
|
71
|
+
Lm Modifier_Letter
|
|
72
|
+
Lo Other_Letter
|
|
73
|
+
Lt Titlecase_Letter
|
|
74
|
+
Lu Uppercase_Letter
|
|
75
|
+
M Mark Combining_Mark
|
|
76
|
+
Mc Spacing_Mark
|
|
77
|
+
Me Enclosing_Mark
|
|
78
|
+
Mn Nonspacing_Mark
|
|
79
|
+
N Number
|
|
80
|
+
Nd Decimal_Number digit
|
|
81
|
+
Nl Letter_Number
|
|
82
|
+
No Other_Number
|
|
83
|
+
P Punctuation punct
|
|
84
|
+
Pc Connector_Punctuation
|
|
85
|
+
Pd Dash_Punctuation
|
|
86
|
+
Pe Close_Punctuation
|
|
87
|
+
Pf Final_Punctuation
|
|
88
|
+
Pi Initial_Punctuation
|
|
89
|
+
Po Other_Punctuation
|
|
90
|
+
Ps Open_Punctuation
|
|
91
|
+
S Symbol
|
|
92
|
+
Sc Currency_Symbol
|
|
93
|
+
Sk Modifier_Symbol
|
|
94
|
+
Sm Math_Symbol
|
|
95
|
+
So Other_Symbol
|
|
96
|
+
Z Separator
|
|
97
|
+
Zl Line_Separator
|
|
98
|
+
Zp Paragraph_Separator
|
|
99
|
+
Zs Space_Separator
|
|
100
|
+
ASCII
|
|
101
|
+
ASCII_Hex_Digit AHex
|
|
102
|
+
Alphabetic Alpha
|
|
103
|
+
Any
|
|
104
|
+
Assigned
|
|
105
|
+
Bidi_Control Bidi_C
|
|
106
|
+
Bidi_Mirrored Bidi_M
|
|
107
|
+
Case_Ignorable CI
|
|
108
|
+
Cased
|
|
109
|
+
Changes_When_Casefolded CWCF
|
|
110
|
+
Changes_When_Casemapped CWCM
|
|
111
|
+
Changes_When_Lowercased CWL
|
|
112
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
113
|
+
Changes_When_Titlecased CWT
|
|
114
|
+
Changes_When_Uppercased CWU
|
|
115
|
+
Dash
|
|
116
|
+
Default_Ignorable_Code_Point DI
|
|
117
|
+
Deprecated Dep
|
|
118
|
+
Diacritic Dia
|
|
119
|
+
Emoji
|
|
120
|
+
Emoji_Component EComp
|
|
121
|
+
Emoji_Modifier EMod
|
|
122
|
+
Emoji_Modifier_Base EBase
|
|
123
|
+
Emoji_Presentation EPres
|
|
124
|
+
Extended_Pictographic ExtPict
|
|
125
|
+
Extender Ext
|
|
126
|
+
Grapheme_Base Gr_Base
|
|
127
|
+
Grapheme_Extend Gr_Ext
|
|
128
|
+
Hex_Digit Hex
|
|
129
|
+
IDS_Binary_Operator IDSB
|
|
130
|
+
IDS_Trinary_Operator IDST
|
|
131
|
+
ID_Continue IDC
|
|
132
|
+
ID_Start IDS
|
|
133
|
+
Ideographic Ideo
|
|
134
|
+
Join_Control Join_C
|
|
135
|
+
Logical_Order_Exception LOE
|
|
136
|
+
Lowercase Lower
|
|
137
|
+
Math
|
|
138
|
+
Noncharacter_Code_Point NChar
|
|
139
|
+
Pattern_Syntax Pat_Syn
|
|
140
|
+
Pattern_White_Space Pat_WS
|
|
141
|
+
Quotation_Mark QMark
|
|
142
|
+
Radical
|
|
143
|
+
Regional_Indicator RI
|
|
144
|
+
Sentence_Terminal STerm
|
|
145
|
+
Soft_Dotted SD
|
|
146
|
+
Terminal_Punctuation Term
|
|
147
|
+
Unified_Ideograph UIdeo
|
|
148
|
+
Uppercase Upper
|
|
149
|
+
Variation_Selector VS
|
|
150
|
+
White_Space space
|
|
151
|
+
XID_Continue XIDC
|
|
152
|
+
XID_Start XIDS`.split(/\s/).map(e=>[rp(e),e])),Xp=new Map([[`s`,Fp(383)],[Fp(383),`s`]]),Zp=new Map([[Fp(223),Fp(7838)],[Fp(107),Fp(8490)],[Fp(229),Fp(8491)],[Fp(969),Fp(8486)]]),Qp=new Map([tm(453),tm(456),tm(459),tm(498),...nm(8072,8079),...nm(8088,8095),...nm(8104,8111),tm(8124),tm(8140),tm(8188)]),$p=new Map([[`alnum`,B`[\p{Alpha}\p{Nd}]`],[`alpha`,B`\p{Alpha}`],[`ascii`,B`\p{ASCII}`],[`blank`,B`[\p{Zs}\t]`],[`cntrl`,B`\p{Cc}`],[`digit`,B`\p{Nd}`],[`graph`,B`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],[`lower`,B`\p{Lower}`],[`print`,B`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],[`punct`,B`[\p{P}\p{S}]`],[`space`,B`\p{space}`],[`upper`,B`\p{Upper}`],[`word`,B`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],[`xdigit`,B`\p{AHex}`]]);function em(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function tm(e){let t=Fp(e);return[t.toLowerCase(),t]}function nm(e,t){return em(e,t).map(e=>tm(e))}var rm=new Set([`Lower`,`Lowercase`,`Upper`,`Uppercase`,`Ll`,`Lowercase_Letter`,`Lt`,`Titlecase_Letter`,`Lu`,`Uppercase_Letter`]);function im(e,t){let n={accuracy:`default`,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:`ES2025`,...t};cm(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:Bp(n.bestEffortTarget,`ES2024`),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};op(e,am,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return op(e,om,a),op(e,sm,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var am={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i===`repeater`){let e=Hf();e.body[0].body.push(Uf({negate:!0,body:r}),Yf(`Any`));let i=Hf();i.body[0].body.push(Kf(`greedy`,0,1/0,e)),n(Dm(i,t),{traverse:!0})}else throw Error(`Unsupported absence function "(?~|"`)},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>e.kind===`flags`);for(let e=n+1;e<t.body.length;e++){let n=t.body[e];zp(r,n,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=hm(t.get(e));if(n){let t=Hf({flags:n});t.body[0].body=e.body,e.body=[Dm(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:o},s){let{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:p}=s;if(c===`text_segment_boundary`)throw Error(`Unsupported text segment boundary "\\${l?`Y`:`y`}"`);if(c===`line_end`)o(Dm(Uf({body:[Mf({body:[Nf(`string_end`)]}),Mf({body:[If(10)]})]}),t));else if(c===`line_start`)o(Dm(wm(B`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c===`search_start`)if(f.has(e))i.flags.sticky=!0,a();else{let e=r[n-1];if(e&&xm(e))o(Dm(Uf({negate:!0}),t));else if(d)throw Error(B`Uses "\G" in a way that requires a subclass`);else o(Em(Nf(`string_start`),t)),s.strategy=`clip_search`}else if(!(c===`string_end`||c===`string_start`))if(c===`string_end_newline`)o(Dm(wm(B`(?=\n?\z)`),t));else if(c===`word_boundary`){if(!p&&!u){let e=`(?:(?<=${qp})(?!${qp})|(?<!${qp})(?=${qp}))`,n=`(?:(?<=${qp})(?=${qp})|(?<!${qp})(?!${qp}))`;o(Dm(wm(l?n:e),t))}}else throw Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Cm(n)&&(n=mm(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Cm(r)&&(r=mm(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){t.kind===`intersection`&&n(Dm(Lf({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:o,wordIsAscii:s}){let{kind:c,negate:l,value:u}=e;if(a&&(c===`digit`||u===`digit`)){n(Em(zf(`digit`,{negate:l}),t));return}if(o&&(c===`space`||u===`space`)){n(Dm(Tm(wm(Gp),l),t));return}if(s&&(c===`word`||u===`word`)){n(Em(zf(`word`,{negate:l}),t));return}if(c===`any`)n(Em(Yf(`Any`),t));else if(c===`digit`)n(Em(Yf(`Nd`,{negate:l}),t));else if(c!==`dot`)if(c===`text_segment`){if(r===`strict`)throw Error(B`Use of "\X" requires non-strict accuracy`);let e=`\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?`,a=B`\p{RI}{2}|${e}(?:\u200D${e})*`;n(Dm(wm(B`(?>\r\n|${i?B`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c===`hex`)n(Em(Yf(`AHex`,{negate:l}),t));else if(c===`newline`)n(Dm(wm(l?`[^
|
|
153
|
+
]`:`(?>\r
|
|
154
|
+
?|[
|
|
155
|
+
\v\f
\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${Fp(e.codePointAt(0)-1)}${Fp(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Dm(wm(`[${e}]`),t))}else n(Dm(Tm(wm($p.get(u)),l),t));else if(c===`property`)Yp.has(rp(u))||(e.key=`sc`);else if(c===`space`)n(Em(Yf(`space`,{negate:l}),t));else if(c===`word`)n(Dm(Tm(wm(qp),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=Hf({flags:c});e.body[0].body=o(),i(Dm(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&yf(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(B`Uses "\K" in a way that's unsupported`);let o=Uf({behind:!0});o.body[0].body=a(),i(Dm(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Dm(Uf({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=Hf();t.body[0].body.push(e.body),e.body=Dm(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=vm(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(B`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Cm(n)&&(n=mm(n,t),e.ref=n)}},om={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=Em(fm(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&zp(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=zp(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Rp(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?fm(0):dm(o,r.groupOriginByCopy,null),l=c;if(!s){let e=hm(pm(o,e=>e.type===`Group`&&!!e.flags)),t=e?Rp(r.globalFlags,e):r.globalFlags;lm(t,r.currentFlags)||(l=Hf({flags:gm(t)}),l.body[0].body.push(c))}n(Dm(l,t),{traverse:!s})}},sm={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>um(t,e));i.length?i.length>1?n(Dm(Hf({atomic:!0,body:i.reverse().map(e=>Mf({body:[Pf(e.number)]}))}),t)):e.ref=i[0].number:n(Dm(Uf({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=Ff();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function cm(e){op(e,{"*"({node:e,parent:t}){e.parent=t}})}function lm(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function um(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=_m(n.parent);for(let r of t){if(r===n)break;if(r===e||ym(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function dm(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=dm(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function fm(e){let t=Jf(e);return t.isRecursive=!0,t}function pm(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function mm(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function hm(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function gm({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function _m(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function vm(e){let t=e.find(e=>e.kind===`search_start`||Sm(e,{negate:!1})||!bm(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=vm(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function ym(e,t){let n=_m(e)??[];for(let e of n)if(e===t||ym(e,t))return!0;return!1}function bm({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function xm(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function Sm(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&yf(e.body[0],{type:`Assertion`,kind:`search_start`})}function Cm(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function wm(e,t){let n=Sf(e,{...t,unicodePropertyMap:Yp}).body;return n.length>1||n[0].body.length>1?Hf({body:n}):n[0].body[0]}function Tm(e,t){return e.negate=t,e}function Em(e,t){return e.parent=t,e}function Dm(e,t){return cm(e),e.parent=t,e}function Om(e,t){let n=Wp(t),r=Bp(n.target,`ES2024`),i=Bp(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];op(e,km,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,Vp(Am[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&zp(f._captureTransfers,e.transferTo,[]).push(t)}),f}var km={"*":{enter({node:e},t){if(Hm(e)){let n=t.getCurrentModI();t.pushModI(e.flags?Rp({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Hm(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Im(Fp(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Lm(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&rm.has(e.value)&&t.setHasCasedChar()}},Am={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?B`\B`:B`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=Fp(e),r=Rm(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Im(n)){let e=Jp(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);Ip.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(Wm)&&(o=[If(45),...o.filter(e=>!Wm(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||Ip.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=Hf(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=Mf({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(Ip.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=Rm(n,i),o=Rm(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&zm(Lm(e)).forEach(e=>{s.add(Array.isArray(e)?`${Rm(e[0],i)}-${Rm(e[1],i)}`:Rm(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:B`[^\n]`;if(e===`digit`)return t?B`\D`:B`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&rm.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?B`\P`:B`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?B`\W`:B`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=Rp(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${Bm(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+Vm(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:B`\g<${t}&R=${r}>`}},jm=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),Mm=new Set([`-`,`\\`,`]`,`^`,`[`]),Nm=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),Pm=new Map([[9,B`\t`],[10,B`\n`],[11,B`\v`],[12,B`\f`],[13,B`\r`],[8232,B`\u2028`],[8233,B`\u2029`],[65279,B`\uFEFF`]]),Fm=/^\p{Cased}$/u;function Im(e){return Fm.test(e)}function Lm(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=Fp(e);if(!Im(t))continue;let o=Jp(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function Rm(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Pm.has(e))return Pm.get(e);if(e<32||e>126&&e<160||e>262143||t&&Um(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?Nm:Mm:jm,a=Fp(e);return(i.has(a)?`\\`:``)+a}function zm(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function Bm(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function Vm({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function Hm({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function Um(e){return e>47&&e<58}function Wm({type:e,value:t}){return e===`Character`&&t===45}var Gm=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=qm(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(Km(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=Jm(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function Km(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function qm(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)zp(n,t,{}).transferTo=e;return n}function Jm(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function Ym(e,t){let n=Xm(e,t);return n.options?new Gm(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Xm(e,t){let n=Wp(t),r=im(Sf(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:Yp}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Om(r,n),a=kp(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=yp(Sp(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function Zm(e,t){return Ym(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Qm(e={}){let t={target:`auto`,cache:new Map,...e};return t.regexConstructor||=e=>Zm(e,{target:t.target}),{createScanner(e){return new Td(e,t)},createString:Dd}}var $m={bash:()=>c(()=>import(`./shellscript-CLZ0U2zV.js`),[],import.meta.url),css:()=>c(()=>import(`./css-DUjzNfgv.js`),__vite__mapDeps([0,1]),import.meta.url),diff:()=>c(()=>import(`./diff-woXpYk--.js`),[],import.meta.url),html:()=>c(()=>import(`./html-BHZv6uqE.js`),__vite__mapDeps([2,1,3]),import.meta.url),javascript:()=>c(()=>import(`./javascript-Yelw-5ZN.js`),__vite__mapDeps([4,3]),import.meta.url),json:()=>c(()=>import(`./json-qhed-kSA.js`),[],import.meta.url),jsx:()=>c(()=>import(`./jsx-Bz0zcwM4.js`),[],import.meta.url),markdown:()=>c(()=>import(`./markdown-BYOwaDjH.js`),[],import.meta.url),python:()=>c(()=>import(`./python-gzcpVVnB.js`),[],import.meta.url),sql:()=>c(()=>import(`./sql-CEbI0hMM.js`),[],import.meta.url),tsx:()=>c(()=>import(`./tsx-udAQXfEw.js`),[],import.meta.url),typescript:()=>c(()=>import(`./typescript-bsJCZSQ-.js`),[],import.meta.url),yaml:()=>c(()=>import(`./yaml-rwi0_p6S.js`),[],import.meta.url)},eh={js:`javascript`,md:`markdown`,py:`python`,sh:`bash`,shell:`bash`,shellscript:`bash`,ts:`typescript`,yml:`yaml`,zsh:`bash`},th;function nh(){return th??=xd({themes:[c(()=>import(`./github-light-EUqPIrTm.js`),[],import.meta.url),c(()=>import(`./github-dark-C-LZuMrd.js`),[],import.meta.url)],langs:[],engine:Qm({forgiving:!0})}),th}function rh(e){let t=e.toLowerCase();return t===`ansi`||t in $m?t:eh[t]??null}async function ih(e){let t=rh(e);if(!t)return null;let n=await nh();return t!==`ansi`&&!n.getLoadedLanguages().includes(t)&&await n.loadLanguage($m[t]),{highlight(e,r){let i=e=>n.codeToTokens(e,{lang:t,themes:{light:`github-light`,dark:`github-dark`},defaultColor:!1,grammarState:r}).tokens,a=t===`ansi`?e.split(`
|
|
156
|
+
`).flatMap(e=>i(e)):i(e);return{lines:a.map(e=>e.map((e,t)=>(0,z.jsx)(`span`,{style:e.htmlStyle,className:`text-(--shiki-light) dark:text-(--shiki-dark)`,children:e.content},t))),state:n.getLastGrammarState(a)}}}}function ah(e,t){let n=e.endsWith(`
|
|
157
|
+
`)?e.slice(0,-1):e,[r,i]=R.useState(null),a=r?.language===t?r.highlighter:null;R.useEffect(()=>{let e=!1;return ih(t).then(n=>{e||i({language:t,highlighter:n})}).catch(()=>{}),()=>{e=!0}},[t]);let[o,s]=R.useState({highlighter:null,text:``,lines:[]}),c=o;(c.highlighter!==a||!n.startsWith(c.text))&&(c={highlighter:a,text:``,lines:[]});let l=n.lastIndexOf(`
|
|
158
|
+
`)+1;if(a&&l>c.text.length){let e=a.highlight(n.slice(c.text.length,l-1),c.state);c={highlighter:a,text:n.slice(0,l),lines:[...c.lines,...e.lines],state:e.state}}c!==o&&s(c);let u=n.slice(l);return R.useMemo(()=>a?[...c.lines,a.highlight(u,c.state).lines[0]]:n.split(`
|
|
159
|
+
`),[n,a,c,u])}var oh=`vercel.ai.error`,sh=Symbol.for(oh),ch=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[sh]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,oh)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},lh=`AI_APICallError`,uh=`vercel.ai.error.${lh}`,dh=Symbol.for(uh),fh=class extends ch{constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:lh,message:e,cause:o}),this[dh]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return ch.hasMarker(e,uh)}},ph=`AI_EmptyResponseBodyError`,mh=`vercel.ai.error.${ph}`,hh=Symbol.for(mh),gh=class extends ch{constructor({message:e=`Empty response body`}={}){super({name:ph,message:e}),this[hh]=!0}static isInstance(e){return ch.hasMarker(e,mh)}};function _h(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var vh=`AI_InvalidArgumentError`,yh=`vercel.ai.error.${vh}`,bh=Symbol.for(yh),xh=class extends ch{constructor({message:e,cause:t,argument:n}){super({name:vh,message:e,cause:t}),this[bh]=!0,this.argument=n}static isInstance(e){return ch.hasMarker(e,yh)}},Sh=`AI_JSONParseError`,Ch=`vercel.ai.error.${Sh}`,wh=Symbol.for(Ch),Th=class extends ch{constructor({text:e,cause:t}){super({name:Sh,message:`JSON parsing failed: Text: ${e}.\nError message: ${_h(t)}`,cause:t}),this[wh]=!0,this.text=e}static isInstance(e){return ch.hasMarker(e,Ch)}},Eh=`AI_TypeValidationError`,Dh=`vercel.ai.error.${Eh}`,Oh=Symbol.for(Dh),kh=class e extends ch{constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:Eh,message:`${r}: Value: ${JSON.stringify(e)}.\nError message: ${_h(t)}`,cause:t}),this[Oh]=!0,this.value=e,this.context=n}static isInstance(e){return ch.hasMarker(e,Dh)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},Ah=`AI_UnsupportedFunctionalityError`,jh=`vercel.ai.error.${Ah}`,Mh=Symbol.for(jh),Nh=class extends ch{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:Ah,message:t}),this[Mh]=!0,this.functionality=e}static isInstance(e){return ch.hasMarker(e,jh)}},Ph=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},Fh=10,Ih=13,Lh=32;function Rh(e){}function zh(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Rh,onError:n=Rh,onRetry:r=Rh,onComment:i}=e,a=[],o=!0,s,c=``,l=0,u;function d(e){if(o&&(o=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),a.length===0){let t=f(e);t!==``&&a.push(t);return}if(e.indexOf(`
|
|
160
|
+
`)===-1&&e.indexOf(`\r`)===-1){a.push(e);return}a.push(e);let t=a.join(``);a.length=0;let n=f(t);n!==``&&a.push(n)}function f(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
|
|
161
|
+
`,n);for(;r!==-1;){if(n===r){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0,n=r+1,r=e.indexOf(`
|
|
162
|
+
`,n);continue}let i=e.charCodeAt(n);if(Bh(e,n,i)){let i=e.charCodeAt(n+5)===Lh?n+6:n+5,a=e.slice(i,r);if(l===0&&e.charCodeAt(r+1)===Fh){t({id:s,event:u,data:a}),s=void 0,c=``,u=void 0,n=r+2,r=e.indexOf(`
|
|
163
|
+
`,n);continue}c=l===0?a:`${c}
|
|
164
|
+
${a}`,l++}else Vh(e,n,i)?u=e.slice(e.charCodeAt(n+6)===Lh?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf(`
|
|
165
|
+
`,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
|
|
166
|
+
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;p(e,n,i),n=i+1,e.charCodeAt(n-1)===Ih&&e.charCodeAt(n)===Fh&&n++}return e.slice(n)}function p(e,t,n){if(t===n){h();return}let r=e.charCodeAt(t);if(Bh(e,t,r)){let r=e.charCodeAt(t+5)===Lh?t+6:t+5,i=e.slice(r,n);c=l===0?i:`${c}
|
|
167
|
+
${i}`,l++;return}if(Vh(e,t,r)){u=e.slice(e.charCodeAt(t+6)===Lh?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)===Lh?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)===Lh?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)===Lh?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
|
+
${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Ph(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Ph(`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 Bh(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 Vh(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 Hh=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=zh({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:iee,atob:aee}=globalThis,Uh=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get,oee=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`).get;function see(e){return ArrayBuffer.isView(e)&&Uh.call(e)===`Uint8Array`}function cee(e){if(typeof e!=`object`||!e||!(`byteLength`in e))return!1;try{return oee.call(e),!0}catch{return!1}}function Wh(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 Gh=({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 xh({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},lee=Gh();function uee(e){return globalThis.Buffer?.isBuffer(e)??!1}function Kh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var dee=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,fee=/"(?: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 qh(e){let t=JSON.parse(e);return typeof t!=`object`||!t||dee.test(e)===!1&&fee.test(e)===!1?t:pee(t)}function pee(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 mee(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return qh(e)}try{return qh(e)}finally{Error.stackTraceLimit=t}}function Jh(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&Yh(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=Yh(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Yh):Yh(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Yh)),e.allOf!=null&&(e.allOf=e.allOf.map(Yh)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Yh));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=Yh(t[e]);return e}function Yh(e){return typeof e==`boolean`?e:Jh(e)}var hee=Symbol(`Let zodToJsonSchema decide on which parser to use`),Xh={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`},Zh=e=>typeof e==`string`?{...Xh,name:e}:{...Xh,...e};function Qh(){return{}}function $h(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=Wg(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 eg(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 tg(){return{type:`boolean`}}function ng(e,t){return Wg(e.type._def,t)}var rg=(e,t)=>Wg(e.innerType._def,t);function ig(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>ig(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 ag(e)}}var ag=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 og(e,t){return{...Wg(e.innerType._def,t),default:e.defaultValue()}}function sg(e,t){return t.effectStrategy===`input`?Wg(e.schema._def,t):Qh()}function cg(e){return{type:`string`,enum:Array.from(e.values)}}var lg=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function ug(e,t){let n=[Wg(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),Wg(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(lg(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 dg(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 fg=void 0,pg={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:()=>(fg===void 0&&(fg=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),fg),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 mg(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`:vg(n,`email`,r.message,t);break;case`format:idn-email`:vg(n,`idn-email`,r.message,t);break;case`pattern:zod`:yg(n,pg.email,r.message,t)}break;case`url`:vg(n,`uri`,r.message,t);break;case`uuid`:vg(n,`uuid`,r.message,t);break;case`regex`:yg(n,r.regex,r.message,t);break;case`cuid`:yg(n,pg.cuid,r.message,t);break;case`cuid2`:yg(n,pg.cuid2,r.message,t);break;case`startsWith`:yg(n,RegExp(`^${hg(r.value,t)}`),r.message,t);break;case`endsWith`:yg(n,RegExp(`${hg(r.value,t)}$`),r.message,t);break;case`datetime`:vg(n,`date-time`,r.message,t);break;case`date`:vg(n,`date`,r.message,t);break;case`time`:vg(n,`time`,r.message,t);break;case`duration`:vg(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`:yg(n,RegExp(hg(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&vg(n,`ipv4`,r.message,t),r.version!==`v4`&&vg(n,`ipv6`,r.message,t);break;case`base64url`:yg(n,pg.base64url,r.message,t);break;case`jwt`:yg(n,pg.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&yg(n,pg.ipv4Cidr,r.message,t),r.version!==`v4`&&yg(n,pg.ipv6Cidr,r.message,t);break;case`emoji`:yg(n,pg.emoji(),r.message,t);break;case`ulid`:yg(n,pg.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:vg(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:yg(n,pg.base64,r.message,t)}break;case`nanoid`:yg(n,pg.nanoid,r.message,t)}return n}function hg(e,t){return t.patternStrategy===`escape`?_g(e):e}var gg=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function _g(e){let t=``;for(let n=0;n<e.length;n++)gg.has(e[n])||(t+=`\\`),t+=e[n];return t}function vg(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 yg(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:bg(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=bg(t,r)}function bg(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
|
+
]))`;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 xg(e,t){let n={type:`object`,additionalProperties:Wg(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}=mg(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}=ng(e.keyType._def,t);return{...n,propertyNames:i}}return n}function Sg(e,t){return t.mapStrategy===`record`?xg(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Wg(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Qh(),Wg(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Qh()],minItems:2,maxItems:2}}}function Cg(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 wg(){return{not:Qh()}}function Tg(){return{type:`null`}}var Eg={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Dg(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Eg&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Eg[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 Og(e,t)}var Og=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Wg(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 kg(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Eg[e.innerType._def.typeName],`null`]};let n=Wg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Ag(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 jg(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=Ng(a),s=Wg(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=Mg(e,t);return a!==void 0&&(n.additionalProperties=a),n}function Mg(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Wg(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 Ng(e){try{return e.isOptional()}catch{return!0}}var Pg=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Wg(e.innerType._def,t);let n=Wg(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Qh()},n]}:Qh()},Fg=(e,t)=>{if(t.pipeStrategy===`input`)return Wg(e.in._def,t);if(t.pipeStrategy===`output`)return Wg(e.out._def,t);let n=Wg(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Wg(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Ig(e,t){return Wg(e.type._def,t)}function Lg(e,t){let n={type:`array`,uniqueItems:!0,items:Wg(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 Rg(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Wg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Wg(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Wg(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function zg(){return{not:Qh()}}function Bg(){return Qh()}var Vg=(e,t)=>Wg(e.innerType._def,t),Hg=(e,t,n)=>{switch(t){case`ZodString`:return mg(e,n);case`ZodNumber`:return Ag(e);case`ZodObject`:return jg(e,n);case`ZodBigInt`:return eg(e);case`ZodBoolean`:return tg();case`ZodDate`:return ig(e,n);case`ZodUndefined`:return zg();case`ZodNull`:return Tg();case`ZodArray`:return $h(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return Dg(e,n);case`ZodIntersection`:return ug(e,n);case`ZodTuple`:return Rg(e,n);case`ZodRecord`:return xg(e,n);case`ZodLiteral`:return dg(e);case`ZodEnum`:return cg(e);case`ZodNativeEnum`:return Cg(e);case`ZodNullable`:return kg(e,n);case`ZodOptional`:return Pg(e,n);case`ZodMap`:return Sg(e,n);case`ZodSet`:return Lg(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Ig(e,n);case`ZodNaN`:case`ZodNever`:return wg();case`ZodEffects`:return sg(e,n);case`ZodAny`:return Qh();case`ZodUnknown`:return Bg();case`ZodDefault`:return og(e,n);case`ZodBranded`:return ng(e,n);case`ZodReadonly`:return Vg(e,n);case`ZodCatch`:return rg(e,n);case`ZodPipeline`:return Fg(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},Ug=(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 Wg(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==hee)return i}if(r&&!n){let e=Gg(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=Hg(e,e.typeName,t),o=typeof a==`function`?Wg(a(),t):a;if(o&&Kg(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var Gg=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Ug(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`),Qh()):t.$refStrategy===`seen`?Qh():void 0}},Kg=(e,t,n)=>(e.description&&(n.description=e.description),n),qg=e=>{let t=Zh(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}]))}},gee=(e,t)=>{let n=qg(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Wg(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Qh()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Wg(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Qh(),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},Jg=Symbol.for(`vercel.ai.schema`);function Yg(e){let t;return()=>(t??=e(),t)}function Xg(e,{validate:t}={}){return{[Jg]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Zg(e){return typeof e==`object`&&!!e&&Jg in e&&e[Jg]===!0&&`jsonSchema`in e&&`validate`in e}function Qg(e){return e==null?Xg({type:`object`,properties:{},additionalProperties:!1}):Zg(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?i_(e):$g(e):e()}function $g(e){return Xg(()=>{if(!e_(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return Jh(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 kh({value:t,cause:n.issues})}}})}function e_(e){return e[`~standard`].jsonSchema!=null}function t_(e,t){let n=t?.useReferences??!1;return Xg(()=>gee(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 n_(e,t){It().localeError||It(pe());let n=t?.useReferences??!1;return Xg(()=>Jh(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 r_(e){return`_zod`in e}function i_(e,t){return r_(e)?n_(e,t):t_(e,t)}async function a_({value:e,schema:t,context:n}){let r=await o_({value:e,schema:t,context:n});if(!r.success)throw kh.wrap({value:e,cause:r.error,context:n});return r.value}async function o_({value:e,schema:t,context:n}){let r=Qg(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:kh.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:kh.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function s_({text:e,schema:t}){try{let n=mee(e);return t==null?{success:!0,value:n,rawValue:n}:await o_({value:n,schema:t})}catch(t){return{success:!1,error:Th.isInstance(t)?t:new Th({text:e,cause:t}),rawValue:void 0}}}function c_({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Hh).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await s_({text:e,schema:t}))}}))}async function l_(e){return typeof e==`function`&&(e=e()),e}new TextDecoder;var u_=er(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);Zn.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 In(this,e,t,{callee:this.parse})},parseAsync(e,t){return Cn(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return an(this,e,t)},safeParseAsync(e,t){return en(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 cr(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)}}),d_=er(`ZodMiniString`,(e,t)=>{zt.init(e,t),u_.init(e,t)});function f_(e){return ve(d_,e)}var p_=er(`ZodMiniNumber`,(e,t)=>{On.init(e,t),u_.init(e,t)});function m_(e){return oe(p_,e)}var h_=er(`ZodMiniNumberFormat`,(e,t)=>{Un.init(e,t),p_.init(e,t)});function g_(e){return xe(h_,e)}var __=er(`ZodMiniBoolean`,(e,t)=>{gt.init(e,t),u_.init(e,t)});function v_(e){return ne(__,e)}var y_=er(`ZodMiniUnknown`,(e,t)=>{Yt.init(e,t),u_.init(e,t)});function b_(){return Ln(y_)}var x_=er(`ZodMiniNever`,(e,t)=>{Yn.init(e,t),u_.init(e,t)});function S_(e){return _(x_,e)}var C_=er(`ZodMiniArray`,(e,t)=>{vt.init(e,t),u_.init(e,t)});function w_(e,t){return new C_({type:`array`,element:e,...ir(t)})}var T_=er(`ZodMiniObject`,(e,t)=>{dn.init(e,t),u_.init(e,t),S(e,`shape`,e=>e._zod.def.shape,!1)});function E_(e,t){return new T_({type:`object`,shape:e??{},...ir(t)})}function D_(e,t){return new T_({type:`object`,shape:e,catchall:b_(),...ir(t)})}function O_(e,t){return Qe(e,t)}var k_=er(`ZodMiniUnion`,(e,t)=>{Vt.init(e,t),u_.init(e,t)});function A_(e,t){return new k_({type:`union`,options:e,...ir(t)})}var j_=er(`ZodMiniDiscriminatedUnion`,(e,t)=>{Ve.init(e,t),u_.init(e,t)});function M_(e,t,n){return new j_({type:`union`,options:t,discriminator:e,...ir(n)})}var N_=er(`ZodMiniRecord`,(e,t)=>{Gn.init(e,t),u_.init(e,t)});function P_(e,t,n){return!t||!t._zod?new N_({type:`record`,keyType:f_(),valueType:e,...ir(t)}):new N_({type:`record`,keyType:e,valueType:t,...ir(n)})}var F_=er(`ZodMiniEnum`,(e,t)=>{u.init(e,t),u_.init(e,t),e.options=[...e._zod.values]});function I_(e,t){return new F_({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ir(t)})}var L_=er(`ZodMiniLiteral`,(e,t)=>{Kt.init(e,t),u_.init(e,t)});function R_(e,t){return new L_({type:`literal`,values:Array.isArray(e)?e:[e],...ir(t)})}var z_=er(`ZodMiniTransform`,(e,t)=>{vn.init(e,t),u_.init(e,t)});function B_(e){return new z_({type:`transform`,transform:e})}var V_=er(`ZodMiniOptional`,(e,t)=>{Mt.init(e,t),u_.init(e,t)});function H_(e){return new V_({type:`optional`,innerType:e})}var U_=er(`ZodMiniPipe`,(e,t)=>{jn.init(e,t),u_.init(e,t)});function W_(e,t){return new U_({type:`pipe`,in:e,out:t})}var G_=er(`ZodMiniCustom`,(e,t)=>{St.init(e,t),u_.init(e,t)});function K_(e,t){return le(G_,e??(()=>!0),t)}function q_(e,t={}){return pt(G_,e,t)}var J_=`AI_InvalidArgumentError`,Y_=`vercel.ai.error.${J_}`,X_=Symbol.for(Y_),Z_=class extends ch{constructor({parameter:e,value:t,message:n}){super({name:J_,message:`Invalid argument for parameter ${e}: ${n}`}),this[X_]=!0,this.parameter=e,this.value=t}static isInstance(e){return ch.hasMarker(e,Y_)}},Q_=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 $_(e){return e.replace(/[^a-zA-Z0-9]/g,e=>`_${e.charCodeAt(0).toString(16).toUpperCase().padStart(4,`0`)}`)}function ev({setting:e,provider:t}){return t==null?Q_.get(e)??`AISDK_DEP_SETTING_${$_(e)}`:`AISDK_DEP_PROVIDER_${$_(t)}__${$_(e)}`}function tv({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 nv=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,rv=!1,iv=new Set;function av({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 ov=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}rv||(rv=!0,av({message:nv,type:`Warning`}));for(let t of e.warnings){let n=t.type===`deprecated`?ev({setting:t.setting,provider:e.provider}):void 0;if(n!=null){if(iv.has(n))continue;iv.add(n)}av({message:tv({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`,code:n})}}};function sv(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]=sv(a,i):n[r]=i}return n}function cv(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function lv(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(!lv(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)||!lv(e[i],t[i]))return!1;return!0}new TextEncoder,new TextEncoder;var uv=`AI_UIMessageStreamError`,dv=`vercel.ai.error.${uv}`,fv=Symbol.for(dv),pv=class extends ch{constructor({chunkType:e,chunkId:t,message:n}){super({name:uv,message:n}),this[fv]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return ch.hasMarker(e,dv)}};function mv(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 hv(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await s_({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await s_({text:mv(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}Gh({prefix:`steer`,size:24}),Gh({prefix:`aitxt`,size:24}),Gh({prefix:`call`,size:24}),TransformStream;var V={NEVER:fr,array:w_,boolean:v_,custom:K_,discriminatedUnion:M_,enum:I_,extend:O_,int:g_,literal:R_,looseObject:D_,maximum:Ge,minLength:pr,never:S_,nonnegative:ct,number:m_,object:E_,optional:H_,pipe:W_,positive:rt,record:P_,refine:q_,safeParse:an,startsWith:j,string:f_,transform:B_,union:A_,unknown:b_},H={array:Xt,boolean:Dt,custom:Qn,discriminatedUnion:lr,instanceof:yn,lazy:ar,literal:Ye,null:tn,number:tr,object:F,record:C,string:L,union:p,unknown:fn},gv=H.lazy(()=>H.union([H.null(),H.string(),H.number(),H.boolean(),H.record(H.string(),gv.optional()),H.array(gv)])),U=H.record(H.string(),H.record(H.string(),gv.optional()));function _v(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 vv=_v(U),yv=V.record(V.string(),V.optional(gv)),bv=Yg(()=>i_(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(vv)),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(yv),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(yv),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(yv),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(yv),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(yv),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 xv(e){return e.type.startsWith(`data-`)}function Sv(){return Object.create(null)}function Cv(e){return e.type===`text`}function wv(e){return e.type===`reasoning`}function Tv(e){return e.type.startsWith(`tool-`)}function Ev(e){return e.type===`dynamic-tool`}function Dv(e){return Tv(e)||Ev(e)}function Ov(e){return e.type.split(`-`).slice(1).join(`-`)}function kv(e){return Ev(e)?e.toolName:Ov(e)}function Av({lastMessage:e,messageId:t}){let n=e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},r=Sv(),i=n.parts.findLastIndex(e=>e.type===`step-start`),a=0;for(let e of n.parts.slice(i+1)){if(!Dv(e))continue;let t=a;Tv(e)&&a++,e.state===`input-streaming`&&(r[e.toolCallId]={text:e.rawInput??``,inputEncoding:e.inputEncoding,index:t,toolName:e.type===`dynamic-tool`?e.toolName:Ov(e),dynamic:e.type===`dynamic-tool`,title:e.title,toolMetadata:e.toolMetadata})}return{message:n,activeTextParts:Sv(),activeReasoningParts:Sv(),partialToolCalls:r}}function jv({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(Dv)}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(Dv(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new pv({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(Dv).find(t=>t.approval?.id===e);if(t==null)throw new pv({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=>Tv(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:sv(r.message.metadata,e);t!=null&&await a_({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 pv({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 pv({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 pv({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 pv({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(Tv);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 pv({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 hv(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(Dv).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:Ov(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:Ov(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=Sv(),r.activeReasoningParts=Sv(),r.partialToolCalls=Sv(),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,Av({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(xv(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 a_({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 Mv({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 Nv(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}Gh({prefix:`aitxt`,size:24}),Gh({prefix:`call`,size:24}),Gh({prefix:`aitxt`,size:24}),Gh({prefix:`call`,size:24});function Pv(e){return e.dynamic=!1,e}var Fv={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 Iv(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))&&ov({warnings:[Fv]})}var Lv=Symbol(`invalid`);function Rv(e){let t=[],n=zv(e,t,new Set);return n===Lv?{success:!1,path:t}:{success:!0,value:n}}function zv(e,t,n){switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:Lv;case`object`:{if(e===null)return e;if(n.has(e))return Lv;n.add(e);let r=Array.isArray(e)?Bv(e,t,n):Vv(e,t,n);return n.delete(e),r}default:return Lv}}function Bv(e,t,n){let r;for(let i=0;i<e.length;i++){let a=e[i];t.push(i);let o=zv(a,t,n);if(o===Lv)return Lv;t.pop(),r==null?o!==a&&(r=e.slice(0,i),r.push(o)):r.push(o)}return r??e}function Vv(e,t,n){if(!Uv(e)||Wv(e))return Lv;let r=Object.keys(e),i;for(let a=0;a<r.length;a++){let o=r[a];if(o===`__proto__`){i??=Hv(e,r,a);continue}let s=e[o],c=s;if(s!==void 0){if(t.push(o),c=zv(s,t,n),c===Lv)return Lv;t.pop()}i==null?c!==s&&(i=Hv(e,r,a),i[o]=c):i[o]=c}return i??e}function Hv(e,t,n){let r={};for(let i=0;i<n;i++)r[t[i]]=e[t[i]];return r}function Uv(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 Wv(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 Gv=V.pipe(V.unknown(),V.transform((e,t)=>{let n=Rv(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)})),Kv=V.custom(),qv=V.pipe(Gv,V.record(V.string(),Kv)),Jv=V.pipe(Gv,V.record(V.string(),V.record(V.string(),Kv))),Yv=V.record(V.string(),V.string()),Xv=_v(Jv);function Zv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function Qv(e){let{type:t,...n}=e;return Pv({...n,type:`dynamic-tool`,toolName:t.slice(5)})}function $v(e){return e.approval!=null&&Object.prototype.hasOwnProperty.call(e.approval,`inputSchemaInput`)?{value:e.approval.inputSchemaInput}:void 0}function ey(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 ty=Yg(()=>{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(Jv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(Yv),providerMetadata:V.optional(Jv)})]),a=V.discriminatedUnion(`type`,[V.object({type:V.literal(`text`),text:V.string(),citations:V.optional(ey(()=>Xv)),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Jv)}),V.object({type:V.literal(`reasoning`),id:V.optional(V.string()),text:V.string(),state:V.optional(V.enum([`streaming`,`done`])),providerMetadata:V.optional(Jv)}),V.object({type:V.literal(`custom`),kind:V.string(),providerMetadata:V.optional(Jv)}),V.object({type:V.literal(`source-url`),sourceId:V.string(),url:V.string(),title:V.optional(V.string()),providerMetadata:V.optional(Jv)}),V.object({type:V.literal(`source-document`),sourceId:V.string(),mediaType:V.string(),title:V.string(),filename:V.optional(V.string()),providerMetadata:V.optional(Jv)}),V.object({type:V.literal(`file`),mediaType:V.string(),filename:V.optional(V.string()),url:V.string(),providerReference:V.optional(Yv),providerMetadata:V.optional(Jv)}),V.object({type:V.literal(`reasoning-file`),mediaType:V.string(),url:V.string(),providerMetadata:V.optional(Jv)}),V.object({type:V.literal(`steering-message`),id:V.string(),parts:ey(()=>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(qv),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(Jv),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(qv),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(Jv),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(qv),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(Jv),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(qv),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(Jv),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(qv),state:V.literal(`output-available`),input:V.unknown(),providerExecuted:V.optional(V.boolean()),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Jv),resultProviderMetadata:V.optional(Jv),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(qv),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(Jv),resultProviderMetadata:V.optional(Jv),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(qv),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(Jv),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(qv),state:V.literal(`input-streaming`),providerExecuted:V.optional(V.boolean()),callProviderMetadata:V.optional(Jv),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(qv),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(Jv),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(qv),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(Jv),approval:e}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(qv),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(Jv),approval:t}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(qv),state:V.literal(`output-available`),providerExecuted:V.optional(V.boolean()),input:V.unknown(),output:V.unknown(),errorText:V.optional(V.never()),callProviderMetadata:V.optional(Jv),resultProviderMetadata:V.optional(Jv),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(qv),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(Jv),resultProviderMetadata:V.optional(Jv),approval:V.optional(n)}),V.object({type:V.string().check(V.startsWith(`tool-`)),toolCallId:V.string(),title:V.optional(V.string()),toolMetadata:V.optional(qv),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(Jv),approval:r})]),l=V.object({id:V.string(),role:V.enum([`system`,`user`,`assistant`]),metadata:V.optional(V.unknown()),parts:ey(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 i_(ey(()=>l).check(V.minLength(1,`Messages array must not be empty`)))});async function ny({messages:e,metadataSchema:t,dataSchemas:n,tools:r,experimental_refineToolInput:i},{convertMissingTerminalToolsToDynamic:a}){try{if(e==null)return{success:!1,error:new Z_({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let o=await a_({value:e,schema:ty});if(Iv(o),t)for(let[e,n]of o.entries())n.metadata=await a_({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 kh({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 a_({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:cv(r,s),u=n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`;if(!l&&u){(r!=null||a)&&(t.parts[o]=Qv(n));continue}if(!l)return{success:!1,error:new kh({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=$v(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 o_({value:p,schema:l.inputSchema,context:d}),t;if(!e.success)t=e.error;else if(f!=null)try{let r=cv(i,s);lv(r==null?e.value:await r(e.value),n.input)||(t=new kh({value:n.input,cause:`Tool input does not match the output reconstructed from inputSchemaInput.`,context:d}))}catch(e){t=new kh({value:p,cause:e,context:d})}if(t!=null)if(n.state===`output-error`||n.state===`output-available`&&Zv(n.input))m=!0;else throw t}n.state===`output-available`&&l.outputSchema&&await a_({value:n.output,schema:l.outputSchema,context:{field:`messages[${e}].parts[${o}].output`,entityName:s,entityId:n.toolCallId}}),m&&(t.parts[o]=Qv(n))}}return{success:!0,data:o}}catch(e){return{success:!1,error:e}}}async function ry(e){return ny(e,{convertMissingTerminalToolsToDynamic:!1})}async function iy(e){let t=await ry(e);if(!t.success)throw t.error;return t.data}Gh({prefix:`call`,size:24}),Gh({prefix:`call`,size:24}),new TextEncoder,Gh({prefix:`call`,size:24}),Gh({prefix:`call`,size:24}),Gh({prefix:`aiobj`,size:24});var{atob:_ee}=globalThis,ay=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)})}};Gh({prefix:`aiobj`,size:24}),Gh({prefix:`call`,size:24});var oy=H.union([H.string(),H.custom(see,{message:`Must be a Uint8Array`}),H.custom(cee,{message:`Must be an ArrayBuffer`}),H.custom(uee,{message:`Must be a Buffer`})]),sy=H.record(H.string(),H.string()),cy=H.object({type:H.literal(`text`),text:H.string(),providerOptions:U.optional()}),ly=H.object({type:H.literal(`image`),image:H.union([oy,H.instanceof(URL),sy]),mediaType:H.string().optional(),providerOptions:U.optional()}),uy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:oy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)}),H.object({type:H.literal(`reference`),reference:sy}),H.object({type:H.literal(`text`),text:H.string()})]),dy=H.discriminatedUnion(`type`,[H.object({type:H.literal(`data`),data:oy}),H.object({type:H.literal(`url`),url:H.instanceof(URL)})]),fy=H.object({type:H.literal(`file`),data:H.union([uy,oy,H.instanceof(URL),sy]),filename:H.string().optional(),mediaType:H.string(),providerOptions:U.optional()}),py=H.object({type:H.literal(`reasoning`),text:H.string(),providerOptions:U.optional()}),my=H.object({type:H.literal(`custom`),kind:H.string().transform(e=>e),providerOptions:U.optional()}),hy=H.object({type:H.literal(`reasoning-file`),data:H.union([dy,oy,H.instanceof(URL)]),mediaType:H.string(),providerOptions:U.optional()}),gy=H.object({type:H.literal(`tool-call`),toolCallId:H.string(),toolName:H.string(),input:H.unknown(),providerOptions:U.optional(),providerExecuted:H.boolean().optional()}),_y=H.discriminatedUnion(`type`,[H.object({type:H.literal(`text`),value:H.string(),providerOptions:U.optional()}),H.object({type:H.literal(`json`),value:gv,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:gv,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:uy,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()})]))})]),vy=H.object({type:H.literal(`tool-result`),toolCallId:H.string(),toolName:H.string(),output:_y,providerOptions:U.optional()}),yy=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()}),by=H.object({type:H.literal(`tool-approval-response`),approvalId:H.string(),approved:H.boolean(),reason:H.string().optional()}),xy=H.object({role:H.literal(`system`),content:H.string(),providerOptions:U.optional()}),Sy=H.object({role:H.literal(`user`),content:H.union([H.string(),H.array(H.union([cy,ly,fy]))]),providerOptions:U.optional()}),Cy=H.object({role:H.literal(`assistant`),content:H.union([H.string(),H.array(H.union([cy,my,fy,py,hy,gy,vy,yy]))]),providerOptions:U.optional()}),wy=H.object({role:H.literal(`tool`),content:H.array(H.union([vy,by])),providerOptions:U.optional()});H.union([xy,Sy,Cy,wy]),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())})))}),Gh({prefix:`call`,size:24}),Gh({prefix:`call`,size:24}),Gh({prefix:`call`,size:24});async function Ty({response:e,url:t,fallbackMessage:n}){let r=await e.text();return new fh({message:r||n,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:r})}async function Ey(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Nh({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 Dy(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 Oy=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 l_(this.body),r=await l_(this.headers),i=await l_(this.credentials),a={...Wh(r),...Wh(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:Wh(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 Ty({response:d,url:s,fallbackMessage:`Failed to fetch the chat response.`});if(!d.body)throw new gh({message:`The response body is empty.`});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await l_(this.body),n=await l_(this.headers),r=await l_(this.credentials),i={...Wh(n),...Wh(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 Z_({parameter:`chatId`,value:e.chatId,message:`Chat IDs must not be "." or ".." when using the default reconnect URL.`});o=Dy(this.api,`/${encodeURIComponent(e.chatId)}/stream`)}let s=a?.headers===void 0?i:Wh(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 Ty({response:l,url:o,fallbackMessage:`Failed to fetch the chat response.`});if(!l.body)throw new gh({message:`The response body is empty.`});return this.processResponseStream(l.body)}},ky=class extends Oy{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return c_({stream:e,schema:bv}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},Ay=class{get id(){return this._id??=this.generateId()}constructor({generateId:e=lee,id:t,transport:n=new ky,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 ay,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=>Dv(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 Ey(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 Z_({parameter:`message.messageId`,value:e.messageId,message:`message with id ${e.messageId} not found`});if(this.state.messages[t].role!==`user`)throw new Z_({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 Z_({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=>Dv(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=>Dv(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(!Dv(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=>Dv(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=>Dv(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=>Dv(e)&&e.state===`approval-responded`)&&!e.parts.some(e=>Dv(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=Nv();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=>Dv(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:Av({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 Mv({stream:jv({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 jy({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(Dv);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 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),i=r.filter(Dv).filter(e=>!e.providerExecuted),a=r.reduce((e,t,n)=>Dv(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 Ny=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 Py(e,t){return t==null?e:(0,Ny.default)(e,t)}function Fy(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var Iy=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=Fy(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?Py(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},Ly=class extends Ay{#e;constructor({messages:e,...t}){let n=new Iy(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}},Ry=new WeakMap;function zy({chat:e,state:t}){if(document.visibilityState!==`visible`||t.pendingVisibilityResume!=null)return;let n=()=>Ry.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 By({chat:e,registration:t}){let n=Ry.get(e);if(n==null){let t={registrations:new Set};if(Ry.set(e,t),n=t,typeof document<`u`){let n=()=>zy({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?.(),Ry.delete(e))}}function Vy(e){return{chat:e,messages:e.messages,status:e.status,error:e.error,experimental_queuedMessages:e.experimental_queuedMessages}}function Hy(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 Uy({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 ky),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 Ly(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)(()=>Vy(u));f.chat!==u&&p(Vy(u)),(0,R.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=Vy(u);p(e=>e.chat!==u||Hy(e,t)?e:t)},n=[u[`~registerMessagesCallback`](t,i),u[`~registerStatusCallback`](t),u[`~registerErrorCallback`](t),u[`~registerQueuedMessagesCallback`](t)],r=Vy(u);return p(e=>Hy(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 By({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 Wy=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})})),Gy=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})),Ky=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})),qy=a(((e,t)=>{var n=Gy(),r=Ky(),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})),Jy=a(((e,t)=>{var n=Ky();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),Yy=a(((e,t)=>{var n=Gy(),r=Ky(),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})),Xy=a(((e,t)=>{var n=Ky(),r=Yy();function i(e){return i.isConstcase(e)?e:n(r(e))}i.isConstcase=function(e){return e&&/^[A-Z_]+$/.test(e)},t.exports=i})),Zy=a(((e,t)=>{var n=Yy();function r(e){return n(e).replace(/_/g,``)}t.exports=r})),Qy=a(((e,t)=>{var n=Gy();function r(e){return e=String(e),e&&n(e[0])+e.slice(1)}t.exports=r})),$y=a(((e,t)=>{var n=Yy();function r(e){return n(e).replace(/_/g,`.`)}t.exports=r})),eb=a(((e,t)=>{var n=Yy();function r(e){return n(e).replace(/_/g,`:`)}t.exports=r})),tb=a(((e,t)=>{var n=qy(),r=Jy();function i(e){return r(n(e))}t.exports=i})),nb=a(((e,t)=>{var n=Yy();function r(e){return n(e).replace(/_/g,`/`)}t.exports=r})),rb=a(((e,t)=>{function n(e){return String(e).trim()}t.exports=n})),ib=a(((e,t)=>{Gy();var n=rb(),r=Yy(),i=Jy(),a=` `;function o(e){return e=String(e).replace(/^[\-_\.\s]/g,a),e&&i(r(n(e)).replace(/_/g,a))}t.exports=o})),ab=a(((e,t)=>{var n=Yy();function r(e){return n(e).replace(/_/g,` `)}t.exports=r})),ob=a(((e,t)=>{var n=Yy();function r(e){return n(e).replace(/_/g,`-`)}t.exports=r})),sb=a(((e,t)=>{var n=Yy(),r=Gy(),i=rb(),a=Jy(),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})),cb=a(((e,t)=>{var n=qy(),r=Jy(),i=Xy(),a=Zy(),o=Qy(),s=$y(),c=eb(),l=Gy(),u=tb(),d=nb(),f=ib(),p=Yy(),m=ab(),h=ob(),g=sb(),_=rb(),v=Ky();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}}));Wy(),cb();function lb(e){return typeof e==`object`&&!!e&&`name`in e&&(`data`in e||`codec`in e)&&typeof e.name==`string`}function ub(e){return db(e,new WeakSet)}function db(e,t){return typeof e==`object`?e===null||t.has(e)?!0:(t.add(e),Array.isArray(e)?e.every(e=>db(e,t)):e instanceof Promise?!1:Symbol.asyncIterator in e||Symbol.iterator in e?!0:lb(e)?db(e.data,t):Object.values(e).every(e=>db(e,t))):typeof e!=`bigint`&&typeof e!=`symbol`}function fb(e){return!(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Promise||Symbol.asyncIterator in e||Symbol.iterator in e||lb(e))}function pb(e){return e.type===`message`}function mb(e){if(lb(e)){if(pb(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=>mb(e)):fb(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,mb(t)])):e}function hb(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 gb(e){return{name:`hint`,data:e,codec:{encode(){return{type:`hint`,text:e}},decode(){return e}}}}function _b(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 vb(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 yb(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 bb(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 xb(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 Sb(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 Cb(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 wb(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 Tb(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 Eb(e){return{name:`role`,data:e,codec:{encode(){return{type:`role`,content:e}},decode(){return e}}}}function vee(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=>mb(e))}}},decode(){return{title:e.title,description:e.description,...e.policies?.length&&{policies:e.policies}}}}}}function yee(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=>mb(e))}}},decode(){return{rule:e.rule,...e.before&&{before:e.before},...e.reason&&{reason:e.reason},...e.policies?.length&&{policies:e.policies}}}}}}function bee(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 xee(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 See(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 Cee(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 wee(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 Tee(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function Db(e,t){if(Tee(e))return Nb(e,t);if(Array.isArray(e))return e.map(e=>Db(e,t));if(fb(e))return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Db(n,t)]));if(!ub(e))throw Error(`Unsupported serialized value of type ${typeof e}`);return e}function Ob(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 kb=Xt(fn()).optional(),Ab={term:Ob(F({name:L(),definition:L()}),e=>hb(e.name,e.definition)),hint:Ob(F({text:L()}),e=>gb(e.text)),guardrail:Ob(F({rule:L(),reason:L().optional(),action:L().optional()}),e=>_b({rule:e.rule,reason:e.reason,action:e.action})),explain:Ob(F({concept:L(),explanation:L(),therefore:L().optional()}),e=>vb({concept:e.concept,explanation:e.explanation,therefore:e.therefore})),example:Ob(F({question:L(),answer:L(),note:L().optional()}),e=>yb({question:e.question,answer:e.answer,note:e.note})),clarification:Ob(F({when:L(),ask:L(),reason:L()}),e=>bb({when:e.when,ask:e.ask,reason:e.reason})),workflow:Ob(F({task:L(),steps:Xt(L()),triggers:Xt(L()).optional(),notes:L().optional()}),e=>xb({task:e.task,steps:e.steps,triggers:e.triggers,notes:e.notes})),quirk:Ob(F({issue:L(),workaround:L()}),e=>Sb({issue:e.issue,workaround:e.workaround})),styleGuide:Ob(F({prefer:L(),never:L().optional(),always:L().optional()}),e=>Cb({prefer:e.prefer,never:e.never,always:e.always})),analogy:Ob(F({concepts:Xt(L()),relationship:L(),insight:L().optional(),therefore:L().optional(),pitfall:L().optional()}),e=>wb({concepts:e.concepts,relationship:e.relationship,insight:e.insight,therefore:e.therefore,pitfall:e.pitfall})),glossary:Ob(F({entries:C(L(),L())}),e=>Tb(e.entries)),role:Ob(F({content:L()}),e=>Eb(e.content)),principle:Ob(F({title:L(),description:L(),policies:kb}),(e,t)=>vee({title:e.title,description:e.description,policies:e.policies?.map(e=>Db(e,t))})),policy:Ob(F({rule:L(),before:L().optional(),reason:L().optional(),policies:kb}),(e,t)=>yee({rule:e.rule,before:e.before,reason:e.reason,policies:e.policies?.map(e=>Db(e,t))})),identity:Ob(F({name:L().optional(),role:L().optional()}),e=>bee({name:e.name,role:e.role})),persona:Ob(F({name:L(),role:L().optional(),objective:L().optional(),tone:L().optional()}),e=>xee({name:e.name,role:e.role,objective:e.objective,tone:e.tone})),alias:Ob(F({term:L(),meaning:L()}),e=>See(e.term,e.meaning)),preference:Ob(F({aspect:L(),value:L()}),e=>Cee(e.aspect,e.value)),correction:Ob(F({subject:L(),clarification:L()}),e=>wee(e.subject,e.clarification))};function jb(e){return Object.hasOwn(Ab,e)}var Mb=new Set([`user`,`assistant`,`message`]);function Nb(e,t){if(Mb.has(e.type))throw Error(`Message fragments are not supported by serialized fragment conversion`);let n=t?.registry?.[e.type]??(jb(e.type)?Ab[e.type]:void 0);if(!n)throw Error(`Unsupported serialized fragment type: ${e.type}`);return n.toFragment(e,t)}function Pb(e){let t=e?.reminders;return Array.isArray(t)?t.filter(e=>Kh(e)&&typeof e.partIndex==`number`&&typeof e.start==`number`&&typeof e.end==`number`):[]}function Fb(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 Ib(e){if(Lb(e))return Rb(e);let t=Pb(Kh(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=Fb(r.text,i);return a.length===0?[]:[{...r,text:a}]}),i={...e,parts:r};if(Kh(e.metadata)){let t={...e.metadata};delete t.reminders,Object.keys(t).length>0?i.metadata=t:delete i.metadata}return i}function Lb(e){let t=e.metadata;if(!Kh(t))return!1;let n=t.synthetic;return Kh(n)?n.source===`reminder`:!1}function Rb(e){let t={...e,parts:e.parts.filter(e=>e.type!==`text`)};if(Kh(e.metadata)){let n={...e.metadata};delete n.synthetic,Object.keys(n).length>0?t.metadata=n:delete t.metadata}return t}var zb=(0,R.createContext)({});function Bb(e){let t=(0,R.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Vb=typeof window<`u`?R.useLayoutEffect:R.useEffect,Hb=(0,R.createContext)(null);function Ub(e,t){e.indexOf(t)===-1&&e.push(t)}function Wb(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Gb=(e,t,n)=>n>t?t:n<e?e:n,Kb={},qb=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Jb=e=>typeof e==`object`&&!!e,Yb=e=>/^0[^.\s]+$/u.test(e);function Xb(e){let t;return()=>(t===void 0&&(t=e()),t)}var Zb=e=>e,Qb=(...e)=>e.reduce((e,t)=>n=>t(e(n))),$b=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},ex=class{constructor(){this.subscriptions=[]}add(e){return Ub(this.subscriptions,e),()=>Wb(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}},tx=e=>e*1e3,nx=e=>e/1e3,rx=(e,t)=>t?1e3/t*e:0,ix=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ax=1e-7,ox=12;function sx(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ix(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ax&&++s<ox);return o}function cx(e,t,n,r){if(e===t&&n===r)return Zb;let i=t=>sx(t,0,1,e,n);return e=>e===0||e===1?e:ix(i(e),t,r)}var lx=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ux=e=>t=>1-e(1-t),dx=cx(.33,1.53,.69,.99),fx=ux(dx),px=lx(fx),mx=e=>e>=1?1:(e*=2)<1?.5*fx(e):.5*(2-2**(-10*(e-1))),hx=e=>1-Math.sin(Math.acos(e)),gx=ux(hx),_x=lx(hx),vx=cx(.42,0,1,1),yx=cx(0,0,.58,1),bx=cx(.42,0,.58,1),xx=e=>Array.isArray(e)&&typeof e[0]!=`number`,Sx=e=>Array.isArray(e)&&typeof e[0]==`number`,Cx={linear:Zb,easeIn:vx,easeInOut:bx,easeOut:yx,circIn:hx,circInOut:_x,circOut:gx,backIn:fx,backInOut:px,backOut:dx,anticipate:mx},wx=e=>typeof e==`string`,Tx=e=>{if(Sx(e)){e.length;let[t,n,r,i]=e;return cx(t,n,r,i)}else if(wx(e))return Cx[e],`${e}`,Cx[e];return e},Ex=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function Dx(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 Ox=40;function kx(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Ex.reduce((e,t)=>(e[t]=Dx(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Kb.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Ox),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:Ex.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<Ex.length;t++)o[Ex[t]].cancel(e)},state:i,steps:o}}var{schedule:Ax,cancel:jx,state:Mx,steps:Nx}=kx(typeof requestAnimationFrame<`u`?requestAnimationFrame:Zb,!0),Px;function Fx(){Px=void 0}var Ix={now:()=>(Px===void 0&&Ix.set(Mx.isProcessing||Kb.useManualTiming?Mx.timestamp:performance.now()),Px),set:e=>{Px=e,queueMicrotask(Fx)}},Lx=e=>t=>typeof t==`string`&&t.startsWith(e),Rx=Lx(`--`),zx=Lx(`var(--`),Bx=e=>zx(e)?Vx.test(e.split(`/*`)[0].trim()):!1,Vx=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Hx(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Ux={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Wx={...Ux,transform:e=>Gb(0,1,e)},Gx={...Ux,default:1},Kx=e=>Math.round(e*1e5)/1e5,qx=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Jx(e){return e==null}var Yx=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Xx=(e,t)=>n=>!!(typeof n==`string`&&Yx.test(n)&&n.startsWith(e)||t&&!Jx(n)&&Object.prototype.hasOwnProperty.call(n,t)),Zx=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(qx);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Qx=e=>Gb(0,255,e),$x={...Ux,transform:e=>Math.round(Qx(e))},eS={test:Xx(`rgb`,`red`),parse:Zx(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+$x.transform(e)+`, `+$x.transform(t)+`, `+$x.transform(n)+`, `+Kx(Wx.transform(r))+`)`};function tS(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 nS={test:Xx(`#`),parse:tS,transform:eS.transform},rS=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),iS=rS(`deg`),aS=rS(`%`),W=rS(`px`),oS=rS(`vh`),sS=rS(`vw`),cS={...aS,parse:e=>aS.parse(e)/100,transform:e=>aS.transform(e*100)},lS={test:Xx(`hsl`,`hue`),parse:Zx(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+aS.transform(Kx(t))+`, `+aS.transform(Kx(n))+`, `+Kx(Wx.transform(r))+`)`},uS={test:e=>eS.test(e)||nS.test(e)||lS.test(e),parse:e=>eS.test(e)?eS.parse(e):lS.test(e)?lS.parse(e):nS.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?eS.transform(e):lS.transform(e),getAnimatableNone:e=>{let t=uS.parse(e);return t.alpha=0,uS.transform(t)}},dS=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function fS(e){return isNaN(e)&&typeof e==`string`&&(e.match(qx)?.length||0)+(e.match(dS)?.length||0)>0}var pS=`number`,mS=`color`,hS=`var`,gS=`var(`,_S="${}",vS=/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 yS(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(vS,e=>(uS.test(e)?(r.color.push(a),i.push(mS),n.push(uS.parse(e))):e.startsWith(gS)?(r.var.push(a),i.push(hS),n.push(e)):(r.number.push(a),i.push(pS),n.push(parseFloat(e))),++a,_S)).split(_S),indexes:r,types:i}}function bS(e){return yS(e).values}function xS({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===pS?i+=Kx(r[a]):e===mS?i+=uS.transform(r[a]):i+=r[a]}return i}}function SS(e){return xS(yS(e))}var CS=e=>typeof e==`number`?0:uS.test(e)?uS.getAnimatableNone(e):e,wS=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:CS(e);function TS(e){let t=yS(e);return xS(t)(t.values.map((e,n)=>wS(e,t.split[n])))}var ES={test:fS,parse:bS,createTransformer:SS,getAnimatableNone:TS};function DS(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 OS({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=DS(s,r,e+1/3),a=DS(s,r,e),o=DS(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function kS(e,t){return n=>n>0?t:e}var AS=(e,t,n)=>e+(t-e)*n,jS=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},MS=[nS,eS,lS],NS=e=>MS.find(t=>t.test(e));function PS(e){let t=NS(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===lS&&(n=OS(n)),n}var FS=(e,t)=>{let n=PS(e),r=PS(t);if(!n||!r)return kS(e,t);let i={...n};return e=>(i.red=jS(n.red,r.red,e),i.green=jS(n.green,r.green,e),i.blue=jS(n.blue,r.blue,e),i.alpha=AS(n.alpha,r.alpha,e),eS.transform(i))},IS=new Set([`none`,`hidden`]);function LS(e,t){return IS.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function RS(e,t){return n=>AS(e,t,n)}function zS(e){return typeof e==`number`?RS:typeof e==`string`?Bx(e)?kS:uS.test(e)?FS:US:Array.isArray(e)?BS:typeof e==`object`?uS.test(e)?FS:VS:kS}function BS(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>zS(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function VS(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=zS(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function HS(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 US=(e,t)=>{let n=ES.createTransformer(t),r=yS(e),i=yS(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?IS.has(e)&&!i.values.length||IS.has(t)&&!r.values.length?LS(e,t):Qb(BS(HS(r,i),i.values),n):(`${e}${t}`,kS(e,t))};function WS(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?AS(e,t,n):zS(e)(e,t)}var GS=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Ax.update(t,e),stop:()=>jx(t),now:()=>Mx.isProcessing?Mx.timestamp:Ix.now()}},KS=(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)})`},qS=2e4;function JS(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 YS(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(JS(r),qS);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:nx(i)}}var XS={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 ZS(e,t){return e*Math.sqrt(1-t*t)}var QS=12;function $S(e,t,n){let r=n;for(let n=1;n<QS;n++)r-=e(r)/t(r);return r}var eC=.001;function tC({duration:e=XS.duration,bounce:t=XS.bounce,velocity:n=XS.velocity,mass:r=XS.mass}){let i,a;XS.maxDuration;let o=1-t;o=Gb(XS.minDamping,XS.maxDamping,o),e=Gb(XS.minDuration,XS.maxDuration,nx(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=ZS(t,o),c=Math.exp(-i);return eC-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=ZS(t**2,o);return(-i(t)+eC>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=$S(i,a,s);if(e=tx(e),isNaN(c))return{stiffness:XS.stiffness,damping:XS.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var nC=[`duration`,`bounce`],rC=[`stiffness`,`damping`,`mass`];function iC(e,t){return t.some(t=>e[t]!==void 0)}function aC(e){let t={velocity:XS.velocity,stiffness:XS.stiffness,damping:XS.damping,mass:XS.mass,isResolvedFromDuration:!1,...e};if(!iC(e,rC)&&iC(e,nC))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Gb(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:XS.mass,stiffness:i,damping:a}}else{let n=tC({...e,velocity:0});t={...t,...n,mass:XS.mass},t.isResolvedFromDuration=!0}return t}function oC(e=XS.visualDuration,t=XS.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}=aC({...n,velocity:-nx(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=nx(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?XS.restSpeed.granular:XS.restSpeed.default,i||=v?XS.restDelta.granular:XS.restDelta.default;let y,b,x,S,C,w;if(h<1)x=ZS(_,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=>tx(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=tx(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=tx(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(JS(T),qS),t=KS(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}oC.applyToOptions=e=>{let t=YS(e,100,oC);return e.ease=t.ease,e.duration=tx(t.duration),e.type=`keyframes`,e};var sC=5;function cC(e,t,n){let r=Math.max(t-sC,0);return rx(n-e(r),t-r)}function lC({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=oC({keyframes:[f.value,m(f.value)],velocity:cC(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 uC(e,t,n){let r=[],i=n||Kb.mix||WS,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Qb(Array.isArray(t)?t[n]||Zb:t,a)),r.push(a)}return r}function dC(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=uC(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=$b(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Gb(e[0],e[a-1],t)):l}function fC(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=$b(0,t,r);e.push(AS(n,1,i))}}function pC(e){let t=[0];return fC(t,e.length-1),t}function mC(e,t){return e.map(e=>e*t)}function hC(e,t){return e.map(()=>t||bx).splice(0,e.length-1)}function gC({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=xx(r)?r.map(Tx):Tx(r),a={done:!1,value:t[0]},o=dC(mC(n&&n.length===t.length?n:pC(t),e),t,{ease:Array.isArray(i)?i:hC(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var _C=e=>e!==null;function vC(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(_C),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var yC={decay:lC,inertia:lC,tween:gC,keyframes:gC,spring:oC};function bC(e){typeof e.type==`string`&&(e.type=yC[e.type])}var xC=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)}},SC=e=>e/100,CC=class extends xC{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!==Ix.now()&&this.tick(Ix.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;bC(e);let{type:t=gC,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||gC;s!==gC&&typeof o[0]!=`number`&&(this.mixKeyframes=Qb(SC,WS(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=JS(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=Gb(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!==lC&&(b.value=vC(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 nx(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+nx(e)}get time(){return nx(this.currentTime)}set time(e){e=tx(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 cC(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(Ix.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=nx(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=GS,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(Ix.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 wC(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var TC=e=>e*180/Math.PI,EC=e=>OC(TC(Math.atan2(e[1],e[0]))),DC={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:EC,rotateZ:EC,skewX:e=>TC(Math.atan(e[1])),skewY:e=>TC(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},OC=e=>(e%=360,e<0&&(e+=360),e),kC=EC,AC=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),jC=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),MC={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:AC,scaleY:jC,scale:e=>(AC(e)+jC(e))/2,rotateX:e=>OC(TC(Math.atan2(e[6],e[5]))),rotateY:e=>OC(TC(Math.atan2(-e[2],e[0]))),rotateZ:kC,rotate:kC,skewX:e=>TC(Math.atan(e[4])),skewY:e=>TC(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function NC(e){return+!!e.includes(`scale`)}function PC(e,t){if(!e||e===`none`)return NC(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=MC,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=DC,i=t}if(!i)return NC(t);let a=r[t],o=i[1].split(`,`).map(IC);return typeof a==`function`?a(o):o[a]}var FC=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return PC(n,t)};function IC(e){return parseFloat(e.trim())}var LC=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],RC=new Set([...LC,`pathRotation`]),zC=e=>e===Ux||e===W,BC=new Set([`x`,`y`,`z`]),VC=LC.filter(e=>!BC.has(e));function HC(e){let t=[];return VC.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var UC={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})=>PC(t,`x`),y:(e,{transform:t})=>PC(t,`y`)};UC.translateX=UC.x,UC.translateY=UC.y;var WC=new Set,GC=!1,KC=!1,qC=!1;function JC(){if(KC){let e=Array.from(WC).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=HC(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)})}KC=!1,GC=!1,WC.forEach(e=>e.complete(qC)),WC.clear()}function YC(){WC.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(KC=!0)})}function XC(){qC=!0,YC(),JC(),qC=!1}var ZC=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?(WC.add(this),GC||(GC=!0,Ax.read(YC),Ax.resolveKeyframes(JC))):(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])}wC(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),WC.delete(this)}cancel(){this.state===`scheduled`&&(WC.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},QC=e=>e.startsWith(`--`);function $C(e,t,n){QC(t)?e.style.setProperty(t,n):e.style[t]=n}var ew={};function tw(e,t){let n=Xb(e);return()=>ew[t]??n()}var nw=tw(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),rw=tw(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),iw=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,aw={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:iw([0,.65,.55,1]),circOut:iw([.55,0,1,.45]),backIn:iw([.31,.01,.66,-.59]),backOut:iw([.33,1.53,.69,.99])};function ow(e,t){if(e)return typeof e==`function`?rw()?KS(e,t):`ease-out`:Sx(e)?iw(e):Array.isArray(e)?e.map(e=>ow(e,t)||aw.easeOut):aw[e]}function sw(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=ow(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 cw(e){return typeof e==`function`&&`applyToOptions`in e}function lw({type:e,...t}){return cw(e)&&rw()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var uw=class extends xC{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=lw(e);this.animation=sw(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=vC(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),$C(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 nx(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+nx(e)}get time(){return nx(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=tx(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&&nw()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Zb):r(this)}},dw={anticipate:mx,backInOut:px,circInOut:_x};function fw(e){return e in dw}function pw(e){typeof e.ease==`string`&&fw(e.ease)&&(e.ease=dw[e.ease])}var mw=10,hw=class extends uw{constructor(e){pw(e),bC(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 CC({...a,autoplay:!1}),s=Math.max(mw,Ix.now()-this.startTime),c=Gb(0,mw,s-mw),l=o.sample(s).value,{name:u}=this.options;i&&u&&$C(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},gw=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(ES.test(e)||e===`0`)&&!e.startsWith(`url(`));function _w(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 vw(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=gw(i,t),s=gw(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:_w(e)||(n===`spring`||cw(n))&&r}function yw(e){e.duration=0,e.type=`keyframes`}var bw=new Set([`opacity`,`clipPath`,`filter`,`transform`]),xw=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Sw(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&xw.test(e[t]))return!0;return!1}var Cw=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),ww=Xb(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Tw(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 ww()&&n&&(bw.has(n)||Cw.has(n)&&Sw(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Ew=40,Dw=class extends xC{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=Ix.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||ZC;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=Ix.now();let u=!0;vw(e,i,a,o)||(u=!1,(Kb.instantAnimations||!s)&&l?.(vC(e,n,t)),e[0]=e[e.length-1],yw(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Ew?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Tw(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new hw({...d,element:p})}catch{m=new CC(d)}else m=new CC(d);m.finished.then(()=>{this.notifyFinished()}).catch(Zb),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(),XC()),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 Ow(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 kw=30,Aw=e=>!isNaN(parseFloat(e)),jw={current:void 0},Mw=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Ix.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=Ix.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Aw(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 ex);let n=this.events[e].add(t);return e===`change`?()=>{n(),Ax.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 jw.current&&jw.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Ix.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>kw)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,kw);return rx(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 Nw(e,t){return new Mw(e,t)}function Pw(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Fw(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Pw(n,e)}var Iw={type:`spring`,stiffness:500,damping:25,restSpeed:10},Lw=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Rw={type:`keyframes`,duration:.8},zw={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Bw=(e,{keyframes:t})=>t.length>2?Rw:RC.has(e)?e.startsWith(`scale`)?Lw(t[1]):Iw:zw,Vw=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Hw(e){for(let t in e)if(!Vw.has(t))return!0;return!1}var Uw=(e,t,n,r={},i,a)=>o=>{let s=Fw(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=tx(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};Hw(s)||Object.assign(u,Bw(e,u)),u.duration&&=tx(u.duration),u.repeatDelay&&=tx(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(yw(u),u.delay===0&&(d=!0)),(Kb.instantAnimations||Kb.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,yw(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=vC(u.keyframes,s);if(e!==void 0){Ax.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new CC(u):new Dw(u)},Ww=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Gw(e){let t=Ww.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Kw(e,t,n=1){`${e}`;let[r,i]=Gw(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return qb(e)?parseFloat(e):e}return Bx(i)?Kw(i,t,n+1):i}function qw(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Jw(e,t,n,r){if(typeof t==`function`){let[i,a]=qw(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]=qw(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Yw(e,t,n){let r=e.getProps();return Jw(r,t,n===void 0?r.custom:n,e)}var Xw=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...LC]),Zw=e=>Array.isArray(e);function Qw(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Nw(n))}function $w(e){return Zw(e)?e[e.length-1]||0:e}function eT(e,t){let{transitionEnd:n={},transition:r={},...i}=Yw(e,t)||{};i={...i,...n};for(let t in i)Qw(e,t,$w(i[t]))}var tT=e=>!!(e&&e.getVelocity);function nT(e){return!!(tT(e)&&e.add)}function rT(e,t){let n=e.getValue(`willChange`);if(nT(n))return n.add(t);if(!n&&Kb.WillChange){let n=new Kb.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function iT(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var aT=`data-`+iT(`framerAppearId`);function oT(e){return e.props[aT]}function sT({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function cT(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Pw(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&&sT(f,t))continue;let o={delay:n,...Fw(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Ax.update(()=>r.set(i));continue}let p=!1;if(window.MotionHandoffAnimation){let n=oT(e);if(n){let e=window.MotionHandoffAnimation(n,t,Ax);e!==null&&(o.startTime=e,p=!0)}}rT(e,t);let m=l??e.shouldReduceMotion;r.start(Uw(t,r,i,m&&Xw.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Ax.update(()=>{o&&eT(e,o)});d.length?Promise.all(d).then(t):t()}return d}function lT(e,t,n={}){let r=Yw(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(cT(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return uT(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 uT(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(lT(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Ow(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function dT(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>lT(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=lT(e,t,n);else{let i=typeof t==`function`?Yw(e,t,n.custom):t;r=Promise.all(cT(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var fT={test:e=>e===`auto`,parse:e=>e},pT=e=>t=>t.test(e),mT=[Ux,W,aS,iS,sS,oS,fT],hT=e=>mT.find(pT(e));function gT(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Yb(e)}var _T=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function vT(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(qx)||[];if(!r)return e;let i=n.replace(r,``),a=+!!_T.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var yT=/\b([a-z-]*)\(.*?\)/gu,bT={...ES,getAnimatableNone:e=>{let t=e.match(yT);return t?t.map(vT).join(` `):e}},xT={...ES,getAnimatableNone:e=>{let t=ES.parse(e);return ES.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},ST={...Ux,transform:Math.round},CT={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:iS,pathRotation:iS,rotateX:iS,rotateY:iS,rotateZ:iS,scale:Gx,scaleX:Gx,scaleY:Gx,scaleZ:Gx,skew:iS,skewX:iS,skewY:iS,distance:W,translateX:W,translateY:W,translateZ:W,x:W,y:W,z:W,perspective:W,transformPerspective:W,opacity:Wx,originX:cS,originY:cS,originZ:W,zIndex:ST,fillOpacity:Wx,strokeOpacity:Wx,numOctaves:ST},wT={...CT,color:uS,backgroundColor:uS,outlineColor:uS,fill:uS,stroke:uS,borderColor:uS,borderTopColor:uS,borderRightColor:uS,borderBottomColor:uS,borderLeftColor:uS,filter:bT,WebkitFilter:bT,mask:xT,WebkitMask:xT},TT=e=>wT[e],ET=new Set([bT,xT]);function DT(e,t){let n=TT(e);return ET.has(n)||(n=ES),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var OT=new Set([`auto`,`none`,`0`]);function kT(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!OT.has(t)&&yS(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=DT(n,i)}var AT=class extends ZC{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(),Bx(r))){let i=Kw(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Xw.has(n)||e.length!==2)return;let[r,i]=e,a=hT(r),o=hT(i);if(Hx(r)!==Hx(i)&&UC[n]){this.needsMeasurement=!0;return}if(a!==o)if(zC(a)&&zC(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else UC[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||gT(e[t]))&&n.push(t);n.length&&kT(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=UC[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]=UC[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()}},jT=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function MT(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 NT=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function PT(e){return Jb(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:FT,cancel:Eee}=kx(queueMicrotask,!1),IT={x:!1,y:!1};function LT(){return IT.x||IT.y}function RT(e){return e===`x`||e===`y`?IT[e]?null:(IT[e]=!0,()=>{IT[e]=!1}):IT.x||IT.y?null:(IT.x=IT.y=!0,()=>{IT.x=IT.y=!1})}function zT(e,t){let n=MT(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function BT(e){return!(e.pointerType===`touch`||LT())}function VT(e,t,n={}){let[r,i,a]=zT(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(!BT(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 HT=(e,t)=>t?e===t||HT(e,t.parentElement):!1,UT=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,WT=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function GT(e){return WT.has(e.tagName)||e.isContentEditable===!0}var KT=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function qT(e){return KT.has(e.tagName)||e.isContentEditable===!0}var JT=new WeakSet;function YT(e){return t=>{t.key===`Enter`&&e(t)}}function XT(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var ZT=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=YT(()=>{if(JT.has(n))return;XT(n,`down`);let e=YT(()=>{XT(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>XT(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function QT(e){return UT(e)&&!LT()}var $T=new WeakSet;function eE(e,t,n={}){let[r,i,a]=zT(e,n),o=e=>{let r=e.currentTarget;if(!QT(e)||$T.has(e))return;JT.add(r),n.stopPropagation&&$T.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),JT.has(r)&&JT.delete(r),QT(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||HT(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),PT(e)&&(e.addEventListener(`focus`,e=>ZT(e,i)),!GT(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function tE(e){return Jb(e)&&`ownerSVGElement`in e}var nE=new WeakMap,rE,iE=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:tE(r)&&`getBBox`in r?r.getBBox()[t]:r[n],aE=iE(`inline`,`width`,`offsetWidth`),oE=iE(`block`,`height`,`offsetHeight`);function sE({target:e,borderBoxSize:t}){nE.get(e)?.forEach(n=>{n(e,{get width(){return aE(e,t)},get height(){return oE(e,t)}})})}function cE(e){e.forEach(sE)}function lE(){typeof ResizeObserver>`u`||(rE=new ResizeObserver(cE))}function uE(e,t){rE||lE();let n=MT(e);return n.forEach(e=>{let n=nE.get(e);n||(n=new Set,nE.set(e,n)),n.add(t),rE?.observe(e)}),()=>{n.forEach(e=>{let n=nE.get(e);n?.delete(t),n?.size||rE?.unobserve(e)})}}var dE=new Set,fE;function pE(){fE=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};dE.forEach(t=>t(e))},window.addEventListener(`resize`,fE)}function mE(e){return dE.add(e),fE||pE(),()=>{dE.delete(e),!dE.size&&typeof fE==`function`&&(window.removeEventListener(`resize`,fE),fE=void 0)}}function hE(e,t){return typeof e==`function`?mE(e):uE(e,t)}var gE={value:null,addProjectionMetrics:null};function _E(e){return tE(e)&&e.tagName===`svg`}var vE=[...mT,uS,ES],yE=e=>vE.find(pT(e)),bE=()=>({translate:0,scale:1,origin:0,originPoint:0}),xE=()=>({x:bE(),y:bE()}),SE=()=>({min:0,max:0}),CE=()=>({x:SE(),y:SE()}),wE=new WeakMap;function TE(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function EE(e){return typeof e==`string`||Array.isArray(e)}var DE=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],OE=[`initial`,...DE];function kE(e){return TE(e.animate)||OE.some(t=>EE(e[t]))}function AE(e){return!!(kE(e)||e.variants)}function jE(e,t,n){for(let r in t){let i=t[r],a=n[r];if(tT(i))e.addValue(r,i);else if(tT(a))e.addValue(r,Nw(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,Nw(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var ME={current:null},NE={current:!1},PE=typeof window<`u`;function FE(){if(NE.current=!0,PE)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>ME.current=e.matches;e.addEventListener(`change`,t),t()}else ME.current=!1}var IE=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],LE={};function RE(e){LE=e}function zE(){return LE}var BE=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=ZC,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=Ix.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Ax.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=kE(t),this.isVariantNode=AE(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&&tT(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,wE.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:(NE.current||FE(),this.shouldReduceMotion=ME.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(),jx(this.notifyUpdate),jx(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&&bw.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new uw({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:tx(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=RC.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Ax.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 LE){let t=LE[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):CE()}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<IE.length;t++){let n=IE[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=jE(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=Nw(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`&&(qb(n)||Yb(n))?n=parseFloat(n):!yE(n)&&ES.test(t)&&(n=DT(e,t)),this.setBaseTarget(e,tT(n)?n.get():n)),tT(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=Jw(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&&!tT(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 ex),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){FT.render(this.render)}},VE=class extends BE{constructor(){super(...arguments),this.KeyframeResolver=AT}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;tT(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},HE=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function UE({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function WE({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function GE(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 KE(e){return e===void 0||e===1}function qE({scale:e,scaleX:t,scaleY:n}){return!KE(e)||!KE(t)||!KE(n)}function JE(e){return qE(e)||YE(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function YE(e){return XE(e.x)||XE(e.y)}function XE(e){return e&&e!==`0%`}function ZE(e,t,n){return n+t*(e-n)}function QE(e,t,n,r,i){return i!==void 0&&(e=ZE(e,i,r)),ZE(e,n,r)+t}function $E(e,t=0,n=1,r,i){e.min=QE(e.min,t,n,r,i),e.max=QE(e.max,t,n,r,i)}function eD(e,{x:t,y:n}){$E(e.x,t.translate,t.scale,t.originPoint),$E(e.y,n.translate,n.scale,n.originPoint)}var tD=.999999999999,nD=1.0000000000001;function rD(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&&(iD(e.x,-a.scroll.offset.x),iD(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,eD(e,o)),r&&JE(a.latestValues)&&sD(e,a.latestValues,a.layout?.layoutBox))}t.x<nD&&t.x>tD&&(t.x=1),t.y<nD&&t.y>tD&&(t.y=1)}function iD(e,t){e.min+=t,e.max+=t}function aD(e,t,n,r,i=.5){$E(e,t,n,AS(e.min,e.max,i),r)}function oD(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function sD(e,t,n){let r=n??e;aD(e.x,oD(t.x,r.x),t.scaleX,t.scale,t.originX),aD(e.y,oD(t.y,r.y),t.scaleY,t.scale,t.originY)}function cD(e,t){return UE(GE(e.getBoundingClientRect(),t))}function lD(e,t,n){let r=cD(e,n),{scroll:i}=t;return i&&(iD(r.x,i.offset.x),iD(r.y,i.offset.y)),r}var uD={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},dD=LC.length;function fD(e,t,n){let r=``,i=!0;for(let a=0;a<dD;a++){let o=LC[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=NT(s,CT[o]);if(!c){i=!1;let t=uD[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${NT(a,CT.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function pD(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(RC.has(e)){o=!0;continue}else if(Rx(e)){i[e]=n;continue}else{let t=NT(n,CT[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=fD(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 mD(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 hD(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var gD={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(W.test(e))e=parseFloat(e);else return e;return`${hD(e,t.target.x)}% ${hD(e,t.target.y)}%`}},_D={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=ES.parse(e);if(i.length>5)return r;let a=ES.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=AS(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},vD={borderRadius:{...gD,applyTo:[...jT]},borderTopLeftRadius:gD,borderTopRightRadius:gD,borderBottomLeftRadius:gD,borderBottomRightRadius:gD,boxShadow:_D};function yD(e,{layout:t,layoutId:n}){return RC.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!vD[e]||e===`opacity`)}function bD(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(tT(r[t])||i&&tT(i[t])||yD(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function xD(e){return window.getComputedStyle(e)}var SD=class extends VE{constructor(){super(...arguments),this.type=`html`,this.renderInstance=mD}readValueFromInstance(e,t){if(RC.has(t))return this.projection?.isProjecting?NC(t):FC(e,t);{let n=xD(e),r=(Rx(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return cD(e,t)}build(e,t,n){pD(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return bD(e,t,n)}},CD={offset:`stroke-dashoffset`,array:`stroke-dasharray`},wD={offset:`strokeDashoffset`,array:`strokeDasharray`};function TD(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?CD:wD;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var ED=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function DD(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(pD(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 ED)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&&TD(d,i,a,o,!1)}var OD=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`]),kD=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function AD(e,t,n,r){mD(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(OD.has(n)?n:iT(n),t.attrs[n])}function jD(e,t,n){let r=bD(e,t,n);for(let n in e)if(tT(e[n])||tT(t[n])){let t=LC.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var MD=class extends VE{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=CE}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(RC.has(t)){let e=TT(t);return e&&e.default||0}return t=OD.has(t)?t:iT(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return jD(e,t,n)}build(e,t,n){DD(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){AD(e,t,n,r)}mount(e){this.isSVGTag=kD(e.tagName),super.mount(e)}},ND=OE.length;function PD(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&PD(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<ND;n++){let r=OE[n],i=e.props[r];(EE(i)||i===!1)&&(t[r]=i)}return t}function FD(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 ID=[...DE].reverse(),LD=DE.length;function RD(e){return t=>Promise.all(t.map(({animation:t,options:n})=>dT(e,t,n)))}function zD(e){let t=RD(e),n=HD(),r=!0,i=!1,a=t=>(n,r)=>{let i=Yw(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=PD(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<LD;t++){let p=ID[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=EE(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||TE(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=BD(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=Zw(t)&&Zw(n)?!FD(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=Yw(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Ow(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Yw(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=HD(),i=!0}}}function BD(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!FD(t,e):!1}function VD(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function HD(){return{animate:VD(!0),whileInView:VD(),whileHover:VD(),whileTap:VD(),whileDrag:VD(),whileFocus:VD(),exit:VD()}}function UD(e,t){e.min=t.min,e.max=t.max}function WD(e,t){UD(e.x,t.x),UD(e.y,t.y)}function GD(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var KD=.9999,qD=1.0001,JD=-.01,YD=.01;function XD(e){return e.max-e.min}function ZD(e,t,n){return Math.abs(e-t)<=n}function QD(e,t,n,r=.5){e.origin=r,e.originPoint=AS(t.min,t.max,e.origin),e.scale=XD(n)/XD(t),e.translate=AS(n.min,n.max,e.origin)-e.originPoint,(e.scale>=KD&&e.scale<=qD||isNaN(e.scale))&&(e.scale=1),(e.translate>=JD&&e.translate<=YD||isNaN(e.translate))&&(e.translate=0)}function $D(e,t,n,r){QD(e.x,t.x,n.x,r?r.originX:void 0),QD(e.y,t.y,n.y,r?r.originY:void 0)}function eO(e,t,n,r=0){e.min=(r?AS(n.min,n.max,r):n.min)+t.min,e.max=e.min+XD(t)}function tO(e,t,n,r){eO(e.x,t.x,n.x,r?.x),eO(e.y,t.y,n.y,r?.y)}function nO(e,t,n,r=0){let i=r?AS(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+XD(t)}function rO(e,t,n,r){nO(e.x,t.x,n.x,r?.x),nO(e.y,t.y,n.y,r?.y)}function iO(e,t,n,r,i){return e-=t,e=ZE(e,1/n,r),i!==void 0&&(e=ZE(e,1/i,r)),e}function aO(e,t=0,n=1,r=.5,i,a=e,o=e){if(aS.test(t)&&(t=parseFloat(t),t=AS(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=AS(a.min,a.max,r);e===a&&(s-=t),e.min=iO(e.min,t,n,s,i),e.max=iO(e.max,t,n,s,i)}function oO(e,t,[n,r,i],a,o){aO(e,t[n],t[r],t[i],t.scale,a,o)}var sO=[`x`,`scaleX`,`originX`],cO=[`y`,`scaleY`,`originY`];function lO(e,t,n,r){oO(e.x,t,sO,n?n.x:void 0,r?r.x:void 0),oO(e.y,t,cO,n?n.y:void 0,r?r.y:void 0)}function uO(e){return e.translate===0&&e.scale===1}function dO(e){return uO(e.x)&&uO(e.y)}function fO(e,t){return e.min===t.min&&e.max===t.max}function pO(e,t){return fO(e.x,t.x)&&fO(e.y,t.y)}function mO(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function hO(e,t){return mO(e.x,t.x)&&mO(e.y,t.y)}function gO(e){return XD(e.x)/XD(e.y)}function _O(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function vO(e){return[e(`x`),e(`y`)]}function yO(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 bO=jT.length,xO=e=>typeof e==`string`?parseFloat(e):e,SO=e=>typeof e==`number`||W.test(e);function CO(e,t,n,r,i,a){i?(e.opacity=AS(0,n.opacity??1,TO(r)),e.opacityExit=AS(t.opacity??1,0,EO(r))):a&&(e.opacity=AS(t.opacity??1,n.opacity??1,r));for(let i=0;i<bO;i++){let a=jT[i],o=wO(t,a),s=wO(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||SO(o)===SO(s)?(e[a]=Math.max(AS(xO(o),xO(s),r),0),(aS.test(s)||aS.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=AS(t.rotate||0,n.rotate||0,r))}function wO(e,t){return e[t]===void 0?e.borderRadius:e[t]}var TO=DO(0,.5,gx),EO=DO(.5,.95,Zb);function DO(e,t,n){return r=>r<e?0:r>t?1:n($b(e,t,r))}function OO(e,t,n){let r=tT(e)?e:Nw(e);return r.start(Uw(``,r,t,n)),r.animation}function kO(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var AO=(e,t)=>e.depth-t.depth,jO=class{constructor(){this.children=[],this.isDirty=!1}add(e){Ub(this.children,e),this.isDirty=!0}remove(e){Wb(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(AO),this.isDirty=!1,this.children.forEach(e)}};function MO(e,t){let n=Ix.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(jx(r),e(a-t))};return Ax.setup(r,!0),()=>jx(r)}function NO(e){return tT(e)?e.get():e}var PO=class{constructor(){this.members=[]}add(e){Ub(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&&(Wb(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Wb(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)}},FO={hasAnimatedSinceResize:!0,hasEverUpdated:!1},IO={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},LO=[``,`X`,`Y`,`Z`],RO=1e3,zO=0;function BO(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function VO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=oT(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Ax,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&VO(r)}function HO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=zO++,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,gE.value&&(IO.nodes=IO.calculatedTargetDeltas=IO.calculatedProjections=0),this.nodes.forEach(GO),this.nodes.forEach(ek),this.nodes.forEach(tk),this.nodes.forEach(KO),gE.addProjectionMetrics&&gE.addProjectionMetrics(IO)},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 jO)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ex),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=tE(t)&&!_E(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;Ax.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=MO(i,250),FO.hasAnimatedSinceResize&&(FO.hasAnimatedSinceResize=!1,this.nodes.forEach($O)))})}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()||ck,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!hO(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={...Fw(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||$O(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(),jx(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(nk),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&&VO(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(YO),this.nodes.forEach(JO);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(XO);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ZO),this.nodes.forEach(QO),this.nodes.forEach(UO),this.nodes.forEach(WO)):this.nodes.forEach(XO),this.clearAllSnapshots();let e=Ix.now();Mx.delta=Gb(0,1e3/60,e-Mx.timestamp),Mx.timestamp=e,Mx.isProcessing=!0,Nx.update.process(Mx),Nx.preRender.process(Mx),Nx.render.process(Mx),Mx.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,FT.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(qO),this.sharedNodes.forEach(rk)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ax.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ax.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!XD(this.snapshot.measuredBox.x)&&!XD(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||=CE(),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&&!dO(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||JE(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)),fk(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return CE();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(mk))){let{scroll:e}=this.root;e&&(iD(t.x,e.offset.x),iD(t.y,e.offset.y))}return t}removeElementScroll(e){let t=CE();if(WD(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&&WD(t,e),iD(t.x,i.offset.x),iD(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||CE();WD(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&&(iD(r.x,-n.scroll.offset.x),iD(r.y,-n.scroll.offset.y)),JE(n.latestValues)&&sD(r,n.latestValues,n.layout?.layoutBox)}return JE(this.latestValues)&&sD(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=CE();WD(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!JE(n.latestValues))continue;let r;n.instance&&(qE(n.latestValues)&&n.updateSnapshot(),r=CE(),WD(r,n.measurePageBox())),lO(t,n.latestValues,n.snapshot?.layoutBox,r)}return JE(this.latestValues)&&lO(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!==Mx.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=Mx.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=CE(),this.targetWithTransforms=CE()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),tO(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):WD(this.target,this.layout.layoutBox),eD(this.target,this.targetDelta)):WD(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),gE.value&&IO.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||qE(this.parent.latestValues)||YE(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=CE(),this.relativeTargetOrigin=CE(),rO(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),WD(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===Mx.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;WD(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;rD(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=CE());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(GD(this.prevProjectionDelta.x,this.projectionDelta.x),GD(this.prevProjectionDelta.y,this.projectionDelta.y)),$D(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!_O(this.projectionDelta.x,this.prevProjectionDelta.x)||!_O(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),gE.value&&IO.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=xE(),this.projectionDelta=xE(),this.projectionDeltaWithTransform=xE()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=xE();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=CE(),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(sk));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=AS(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=AS(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(ik(o.x,e.x,n),ik(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(rO(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),ok(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&pO(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=CE(),WD(f,this.relativeTarget)),c&&(this.animationValues=a,CO(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&&=(jx(this.pendingAnimation),void 0),this.pendingAnimation=Ax.update(()=>{FO.hasAnimatedSinceResize=!0,this.motionValue||=Nw(0),this.motionValue.jump(0,!1),this.currentAnimation=OO(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(RO),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&&pk(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||CE();let t=XD(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=XD(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}WD(t,n),sD(t,i),$D(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new PO),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&&BO(`z`,e,r,this.animationValues);for(let t=0;t<LO.length;t++)BO(`rotate${LO[t]}`,e,r,this.animationValues),BO(`skew${LO[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=NO(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=NO(t?.pointerEvents)||``),this.hasProjected&&!JE(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=yO(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 vD){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=vD[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?NO(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(JO),this.root.sharedNodes.clear()}}}function UO(e){e.updateLayout()}function WO(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`)vO(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=XD(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;UD(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else pk(i,t.layoutBox,n)&&vO(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=XD(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=xE();$D(o,n,t.layoutBox);let s=xE();a?$D(s,e.applyTransform(r,!0),t.measuredBox):$D(s,n,t.layoutBox);let c=!dO(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=CE();rO(s,t.layoutBox,i.layoutBox,o);let c=CE();rO(c,n,a.layoutBox,o),hO(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 GO(e){gE.value&&IO.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 KO(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function qO(e){e.clearSnapshot()}function JO(e){e.clearMeasurements()}function YO(e){e.isLayoutDirty=!0,e.updateLayout()}function XO(e){e.isLayoutDirty=!1}function ZO(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function QO(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function $O(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function ek(e){e.resolveTargetDelta()}function tk(e){e.calcProjection()}function nk(e){e.resetSkewAndRotation()}function rk(e){e.removeLeadSnapshot()}function ik(e,t,n){e.translate=AS(t.translate,0,n),e.scale=AS(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ak(e,t,n,r){e.min=AS(t.min,n.min,r),e.max=AS(t.max,n.max,r)}function ok(e,t,n,r){ak(e.x,t.x,n.x,r),ak(e.y,t.y,n.y,r)}function sk(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var ck={duration:.45,ease:[.4,0,.1,1]},lk=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),uk=lk(`applewebkit/`)&&!lk(`chrome/`)?Math.round:Zb;function dk(e){e.min=uk(e.min),e.max=uk(e.max)}function fk(e){dk(e.x),dk(e.y)}function pk(e,t,n){return e===`position`||e===`preserve-aspect`&&!ZD(gO(t),gO(n),.2)}function mk(e){return e!==e.root&&e.scroll?.wasRoot}var hk=HO({attachResizeListener:(e,t)=>kO(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),gk={current:void 0},_k=HO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!gk.current){let e=new hk({});e.mount(window),e.setOptions({layoutScroll:!0}),gk.current=e}return gk.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),vk=(0,R.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function yk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function bk(...e){return t=>{let n=!1,r=e.map(e=>{let r=yk(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():yk(e[t],null)}}}}function xk(...e){return R.useCallback(bk(...e),e)}var Sk=class extends R.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(PT(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=PT(e)&&e.offsetWidth||0,r=PT(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 Ck({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)(vk),u=xk(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
|
+
[data-motion-pop-id="${o}"] {
|
|
172
|
+
position: absolute !important;
|
|
173
|
+
width: ${e}px !important;
|
|
174
|
+
height: ${u}px !important;
|
|
175
|
+
${_}px !important;
|
|
176
|
+
${v}px !important;
|
|
177
|
+
}
|
|
178
|
+
`),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,z.jsx)(Sk,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:R.cloneElement(e,{ref:u})})}var wk=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=Bb(Tk),d=(0,R.useId)(),f=(0,R.useRef)(n),p=(0,R.useRef)(r);Vb(()=>{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)(Ck,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,z.jsx)(Hb.Provider,{value:h,children:e})};function Tk(){return new Map}function Ek(e=!0){let t=(0,R.useContext)(Hb);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 Dk=e=>e.key||``;function Ok(e){let t=[];return R.Children.forEach(e,e=>{(0,R.isValidElement)(e)&&t.push(e)}),t}var kk=({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]=Ek(o),f=(0,R.useMemo)(()=>Ok(e),[e]),p=o&&!u?[]:f.map(Dk),m=(0,R.useRef)(!0),h=(0,R.useRef)(f),g=Bb(()=>new Map),_=(0,R.useRef)(new Set),[v,y]=(0,R.useState)(f),[b,x]=(0,R.useState)(f);Vb(()=>{m.current=!1,h.current=f;for(let e=0;e<b.length;e++){let t=Dk(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=Dk(n);p.includes(r)||(e.splice(t,0,n),S.push(n))}return a===`wait`&&S.length&&(e=S),x(Ok(e)),y(f),null}let{forceRender:C}=(0,R.useContext)(zb);return(0,z.jsx)(z.Fragment,{children:b.map(e=>{let v=Dk(e),y=o&&!u?!1:f===b||p.includes(v);return(0,z.jsx)(wk,{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)})})},Ak=(0,R.createContext)({strict:!1}),jk={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`]},Mk=!1;function Nk(){if(Mk)return;let e={};for(let t in jk)e[t]={isEnabled:e=>jk[t].some(t=>!!e[t])};RE(e),Mk=!0}function Pk(){return Nk(),zE()}function Fk(e){let t=Pk();for(let n in e)t[n]={...t[n],...e[n]};RE(t)}var Ik=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 Lk(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Ik.has(e)}var Rk=t({default:()=>zk}),zk,Bk=s((()=>{throw zk={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Vk=e=>!Lk(e);function Hk(e){typeof e==`function`&&(Vk=t=>t.startsWith(`on`)?!Lk(t):e(t))}try{Hk((Bk(),l(Rk)).default)}catch{}function Uk(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||tT(e[i])||(Vk(i)||n===!0&&Lk(i)||!t&&!Lk(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Wk=(0,R.createContext)({});function Gk(e,t){if(kE(e)){let{initial:t,animate:n}=e;return{initial:t===!1||EE(t)?t:void 0,animate:EE(n)?n:void 0}}return e.inherit===!1?{}:t}function Kk(e){let{initial:t,animate:n}=Gk(e,(0,R.useContext)(Wk));return(0,R.useMemo)(()=>({initial:t,animate:n}),[qk(t),qk(n)])}function qk(e){return Array.isArray(e)?e.join(` `):e}var Jk=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Yk(e,t,n){for(let r in t)!tT(t[r])&&!yD(r,n)&&(e[r]=t[r])}function Xk({transformTemplate:e},t){return(0,R.useMemo)(()=>{let n=Jk();return pD(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Zk(e,t){let n=e.style||{},r={};return Yk(r,n,e),Object.assign(r,Xk(e,t)),r}function Qk(e,t){let n={},r=Zk(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 $k=()=>({...Jk(),attrs:{}});function eA(e,t,n,r){let i=(0,R.useMemo)(()=>{let n=$k();return DD(n,t,kD(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Yk(t,e.style,e),i.style={...t,...i.style}}return i}var tA=[`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 nA(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(tA.indexOf(e)>-1||/[A-Z]/u.test(e))}function rA(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??nA(e)?eA:Qk)(t,r,i,e),c=Uk(t,typeof e==`string`,a),l=e===R.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,R.useMemo)(()=>tT(u)?u.get():u,[u]);return(0,R.createElement)(e,{...l,children:d})}function iA({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:aA(n,r,i,e),renderState:t()}}function aA(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=NO(a[e]);let{initial:o,animate:s}=e,c=kE(e),l=AE(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`&&!TE(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Jw(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 oA=e=>(t,n)=>{let r=(0,R.useContext)(Wk),i=(0,R.useContext)(Hb),a=()=>iA(e,t,r,i);return n?a():Bb(a)},sA=oA({scrapeMotionValuesFromProps:bD,createRenderState:Jk}),cA=oA({scrapeMotionValuesFromProps:jD,createRenderState:$k}),lA=Symbol.for(`motionComponentSymbol`);function uA(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 dA=(0,R.createContext)({});function fA(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function pA(e,t,n,r,i,a){let{visualElement:o}=(0,R.useContext)(Wk),s=(0,R.useContext)(Ak),c=(0,R.useContext)(Hb),l=(0,R.useContext)(vk),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)(dA);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&mA(f.current,n,i,h);let g=(0,R.useRef)(!1);(0,R.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[aT],v=(0,R.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Vb(()=>{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 mA(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:hA(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&fA(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function hA(e){if(e)return e.options.allowProjection===!1?hA(e.parent):e.projection}function gA(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Fk(r);let a=n?n===`svg`:nA(e),o=a?cA:sA;function s(n,s){let c,l={...(0,R.useContext)(vk),...n,layoutId:_A(n)},{isStatic:u}=l,d=Kk(n),f=o(n,u);if(!u&&typeof window<`u`){vA(l,r);let t=yA(l);c=t.MeasureLayout,d.visualElement=pA(e,f,l,i,t.ProjectionNode,a)}return(0,z.jsxs)(Wk.Provider,{value:d,children:[c&&d.visualElement?(0,z.jsx)(c,{visualElement:d.visualElement,...l}):null,rA(e,n,uA(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[lA]=e,c}function _A({layoutId:e}){let t=(0,R.useContext)(zb).id;return t&&e!==void 0?t+`-`+e:e}function vA(e,t){(0,R.useContext)(Ak).strict}function yA(e){let{drag:t,layout:n}=Pk();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function bA(e,t){if(typeof Proxy>`u`)return gA;let n=new Map,r=(n,r)=>gA(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,gA(a,void 0,e,t)),n.get(a))})}var xA=(e,t)=>t.isSVG??nA(e)?new MD(t):new SD(t,{allowProjection:e!==R.Fragment}),SA=class extends HE{constructor(e){super(e),e.animationState||=zD(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();TE(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?.()}},CA=0,wA={animation:{Feature:SA},exit:{Feature:class extends HE{constructor(){super(...arguments),this.id=CA++,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=Yw(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 TA(e){return{point:{x:e.pageX,y:e.pageY}}}var EA=e=>t=>UT(t)&&e(t,TA(t));function DA(e,t,n,r){return kO(e,t,EA(n),r)}var OA=({current:e})=>e?e.ownerDocument.defaultView:null,kA=(e,t)=>Math.abs(e-t);function Dee(e,t){let n=kA(e.x,t.x),r=kA(e.y,t.y);return Math.sqrt(n**2+r**2)}var AA=new Set([`auto`,`scroll`]),jA=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=MA(this.lastRawMoveEventInfo,this.transformPagePoint));let e=PA(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Dee(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Mx;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=MA(t,this.transformPagePoint),Ax.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=PA(e.type===`pointercancel`?this.lastMoveEventInfo:MA(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!UT(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=MA(TA(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Mx;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,PA(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=Qb(DA(this.contextWindow,`pointermove`,this.handlePointerMove,d),DA(this.contextWindow,`pointerup`,this.handlePointerUp,d),DA(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(AA.has(e.overflowX)||AA.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),Ax.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),jx(this.updatePoint)}};function MA(e,t){return t?{point:t(e.point)}:e}function NA(e,t){return{x:e.x-t.x,y:e.y-t.y}}function PA({point:e},t){return{point:e,delta:NA(e,FA(t)),offset:NA(e,Oee(t)),velocity:kee(t,.1)}}function Oee(e){return e[0]}function FA(e){return e[e.length-1]}function kee(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=FA(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>tx(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>tx(t)*2&&(r=e[1]);let a=nx(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 Aee(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?AS(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?AS(n,e,r.max):Math.min(e,n)),e}function IA(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 jee(e,{top:t,left:n,bottom:r,right:i}){return{x:IA(e.x,n,i),y:IA(e.y,t,r)}}function LA(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 Mee(e,t){return{x:LA(e.x,t.x),y:LA(e.y,t.y)}}function Nee(e,t){let n=.5,r=XD(e),i=XD(t);return i>r?n=$b(t.min,t.max-r,e.min):r>i&&(n=$b(e.min,e.max-i,t.min)),Gb(0,1,n)}function Pee(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 RA=.35;function zA(e=RA){return e===!1?e=0:e===!0&&(e=RA),{x:BA(e,`left`,`right`),y:BA(e,`top`,`bottom`)}}function BA(e,t,n){return{min:VA(e,t),max:VA(e,n)}}function VA(e,t){return typeof e==`number`?e:e[t]||0}var HA=new WeakMap,UA=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=CE(),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(TA(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=RT(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),vO(e=>{let t=this.getAxisMotionValue(e).get()||0;if(aS.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=XD(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Ax.update(()=>i(e,t),!1,!0),rT(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=qA(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&&Ax.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 jA(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:OA(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&&Ax.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=Aee(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&&fA(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=jee(n.layoutBox,e):this.constraints=!1,this.elastic=zA(t),r!==this.constraints&&!fA(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&vO(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Pee(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!fA(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=lD(n,r.root,this.visualElement.getTransformPagePoint()),a=Mee(r.layout.layoutBox,i);if(t){let e=t(WE(a));this.hasMutatedConstraints=!!e,e&&(a=UE(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=vO(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 rT(this.visualElement,e),n.start(Uw(e,n,0,t,this.visualElement,!1))}stopAnimation(){vO(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){vO(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]-AS(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!fA(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};vO(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Nee({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(),vO(t=>{if(!KA(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(AS(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;HA.set(this.visualElement,this);let e=this.visualElement.current,t=DA(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&qT(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();fA(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=GA(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Ax.read(r);let o=kO(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(vO(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=RA,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function WA(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function GA(e,t,n){let r=hE(e,WA(n)),i=hE(t,WA(n));return()=>{r(),i()}}function KA(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function qA(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var JA=class extends HE{constructor(e){super(e),this.removeGroupControls=Zb,this.removeListeners=Zb,this.controls=new UA(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Zb}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()}},YA=e=>(t,n)=>{e&&Ax.update(()=>e(t,n),!1,!0)},XA=class extends HE{constructor(){super(...arguments),this.removePointerDownListener=Zb}onPointerDown(e){this.session=new jA(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:OA(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:YA(e),onStart:YA(t),onMove:YA(n),onEnd:(e,t)=>{delete this.session,r&&Ax.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=DA(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},ZA=!1,QA=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),ZA&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),FO.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}),ZA=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Ax.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(),FT.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;ZA=!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 $A(e){let[t,n]=Ek(),r=(0,R.useContext)(zb);return(0,z.jsx)(QA,{...e,layoutGroup:r,switchLayoutGroup:(0,R.useContext)(dA),isPresent:t,safeToRemove:n})}var ej={pan:{Feature:XA},drag:{Feature:JA,ProjectionNode:_k,MeasureLayout:$A}};function tj(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Ax.postRender(()=>i(t,TA(t)))}var nj=class extends HE{mount(){let{current:e}=this.node;e&&(this.unmount=VT(e,(e,t)=>(tj(this.node,t,`Start`),e=>tj(this.node,e,`End`))))}unmount(){}},rj=class extends HE{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=Qb(kO(this.node.current,`focus`,()=>this.onFocus()),kO(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function ij(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&&Ax.postRender(()=>i(t,TA(t)))}var aj=class extends HE{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=eE(e,(e,t)=>(ij(this.node,t,`Start`),(e,{success:t})=>ij(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},oj=new WeakMap,sj=new WeakMap,cj=e=>{let t=oj.get(e.target);t&&t(e)},lj=e=>{e.forEach(cj)};function uj({root:e,...t}){let n=e||document;sj.has(n)||sj.set(n,{});let r=sj.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(lj,{root:e,...t})),r[i]}function dj(e,t,n){let r=uj(t);return oj.set(e,n),r.observe(e),()=>{oj.delete(e),r.unobserve(e)}}var fj={some:0,all:1},pj=class extends HE{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:fj[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=dj(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(mj(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function mj({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var hj={inView:{Feature:pj},tap:{Feature:aj},focus:{Feature:rj},hover:{Feature:nj}},gj={layout:{ProjectionNode:_k,MeasureLayout:$A}},_j=bA({...wA,...hj,...ej,...gj},xA);function vj(){!NE.current&&FE();let[e]=(0,R.useState)(ME.current);return e}function yj(e){e.values.forEach(e=>e.stop())}function bj(e,t){[...t].reverse().forEach(n=>{let r=e.getVariant(n);r&&eT(e,r),e.variantChildren&&e.variantChildren.forEach(e=>{bj(e,t)})})}function xj(e,t){if(Array.isArray(t))return bj(e,t);if(typeof t==`string`)return bj(e,[t]);eT(e,t)}function Sj(){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(dT(e,t,{transitionOverride:n}))}),Promise.all(r)},set(t){return e.forEach(e=>{xj(e,t)})},stop(){e.forEach(e=>{yj(e)})},mount(){return()=>{t.stop()}}};return t}function Cj(){let e=Bb(Sj);return Vb(e.mount,[]),e}var wj=Cj,G=jt(),Tj=_j,Ej={damping:.7,stiffness:.05,mass:1.25},Dj=70,Oj=1e3/60,kj=350,Aj=!1;globalThis.document?.addEventListener(`mousedown`,()=>{Aj=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{Aj=!1}),globalThis.document?.addEventListener(`click`,()=>{Aj=!1});var jj=(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(!Aj)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<=Dj}}},[]),f=(0,R.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Pj(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))/Oj;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:Pj(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=Mj(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=Mj(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=Pj(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:kj})}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 Mj(e,t){let n=(0,R.useCallback)(t=>(n.current=t,e(t)),t);return n}var Nj=new Map;function Pj(...e){let t={...Ej},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 Nj.has(r)||Nj.set(r,Object.freeze(t)),n?`instant`:Nj.get(r)}var Fj=new Set([`name`,`id`,`aria-describedby`,`aria-labelledby`]);function Ij(e){let t=new Set;for(let{name:n}of e){if(t.has(n))return n;t.add(n)}}function Lj(e){let t=e.allowedAttributes.filter(e=>Fj.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 Rj=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,zj=L().min(1).max(64).regex(Rj).refine(e=>!Fj.has(e),{error:`Attribute is reserved: the markdown sanitizer rewrites it to "user-content-<value>". Use a domain attribute instead (e.g. "param").`}),Bj=Me({name:L().min(1).max(64).regex(Rj),description:L().max(512).optional(),allowedAttributes:Xt(zj).max(20)});Xt(Bj).max(100).superRefine((e,t)=>{let n=Ij(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 Vj(e){let{name:t,allowedAttributes:n,description:r}=e;return{name:t,allowedAttributes:n,description:r}}function Hj(e){for(let t of e){let e=Bj.safeParse(Vj(t));if(!e.success)throw Error(`Interactive element <${t.name}> is invalid:
|
|
179
|
+
${At(e.error)}`)}let t=Ij(e);if(t!==void 0)throw Error(`Duplicate element name <${t}>: a catalog must map each tag to exactly one element.`);return[...e]}var Uj={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 Wj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function Gj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function Kj(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function qj(e){return Kj(e)||Wj(e)}var Jj=[``,`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 Yj(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`?qj:u===`decimal`?Wj:Gj;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&Cl.includes(y)&&(_=y,v=yr(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&yr(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=``):qj(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(Xj(e))h(7,S),C=`�`;else if(e in Uj)h(6,S),C=Uj[e];else{let t=``;Zj(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,Jj[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function Xj(e){return e>=55296&&e<=57343||e>1114111}function Zj(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 Qj={}.hasOwnProperty,$j={},eM=/^[^\t\n\r "#'.<=>`}]+$/,tM=/^[^\t\n\r "'<=>`}]+$/;function nM(){return{canContainEols:[`textDirective`],enter:{directiveContainer:iM,directiveContainerAttributes:dM,directiveContainerLabel:lM,directiveLeaf:aM,directiveLeafAttributes:dM,directiveText:oM,directiveTextAttributes:dM},exit:{directiveContainer:_M,directiveContainerAttributeClassValue:pM,directiveContainerAttributeIdValue:fM,directiveContainerAttributeName:hM,directiveContainerAttributeValue:mM,directiveContainerAttributes:gM,directiveContainerLabel:uM,directiveContainerName:cM,directiveLeaf:_M,directiveLeafAttributeClassValue:pM,directiveLeafAttributeIdValue:fM,directiveLeafAttributeName:hM,directiveLeafAttributeValue:mM,directiveLeafAttributes:gM,directiveLeafName:cM,directiveText:_M,directiveTextAttributeClassValue:pM,directiveTextAttributeIdValue:fM,directiveTextAttributeName:hM,directiveTextAttributeValue:mM,directiveTextAttributes:gM,directiveTextName:cM}}}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=vM,{handlers:{containerDirective:n,leafDirective:n,textDirective:n},unsafe:[{character:`\r`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{character:`
|
|
180
|
+
`,inConstruct:[`leafDirectiveLabel`,`containerDirectiveLabel`]},{before:`[^:]`,character:`:`,after:`[A-Za-z]`,inConstruct:[`phrasing`]},{atBreak:!0,character:`:`,after:`:`}]};function n(e,t,n,i){let a=n.createTracker(i),o=bM(e),s=n.enter(e.type),c=a.move(o+(e.name||``)),l;if(e.type===`containerDirective`){let t=(e.children||[])[0];l=yM(t)?t:void 0}else l=e;if(l&&l.children&&l.children.length>0){let t=n.enter(`label`),r=`${e.type}Label`,i=n.enter(r);c+=a.move(`[`),c+=a.move(n.containerPhrasing(l,{...a.current(),before:c,after:`]`})),c+=a.move(`]`),i(),t()}if(c+=a.move(r(e,n)),e.type===`containerDirective`){let t=(e.children||[])[0],r=e;yM(t)&&(r=Object.assign({},e,{children:e.children.slice(1)})),r&&r.children&&r.children.length>0&&(c+=a.move(`
|
|
181
|
+
`),c+=a.move(n.containerFlow(r,a.current()))),c+=a.move(`
|
|
182
|
+
`+o)}return s(),c}function r(e,n){let r=e.attributes||{},a=[],o,s,c,l;for(l in r)if(Qj.call(r,l)&&r[l]!==void 0&&r[l]!==null){let u=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 ]+/g),a=[],c=[],l=-1;for(;++l<r.length;)(t.preferShortcut!==!1&&eM.test(r[l])?c:a).push(r[l]);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&&Lr(n,a)>Lr(n,o)?o:a,c=r.type===`textDirective`?[s]:[s,`
|
|
183
|
+
`,`\r`];return e+`=`+s+Pl(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)}function lM(e){this.enter({type:`paragraph`,data:{directiveLabel:!0},children:[]},e)}function uM(e){this.exit(e)}function dM(){this.data.directiveAttributes=[],this.buffer()}function fM(e){this.data.directiveAttributes.push([`id`,Yj(this.sliceSerialize(e),{attribute:!0})])}function pM(e){this.data.directiveAttributes.push([`class`,Yj(this.sliceSerialize(e),{attribute:!0})])}function mM(e){let t=this.data.directiveAttributes;t[t.length-1][1]=Yj(this.sliceSerialize(e),{attribute:!0})}function hM(e){this.data.directiveAttributes.push([this.sliceSerialize(e),``])}function gM(){let e=this.data.directiveAttributes,t={},n=-1;for(;++n<e.length;){let r=e[n];r[0]===`class`&&t.class?t.class+=` `+r[1]:t[r[0]]=r[1]}this.data.directiveAttributes=void 0,this.resume();let r=this.stack[this.stack.length-1];r.type===`containerDirective`||r.type===`leafDirective`||r.type,r.attributes=t}function _M(e){this.exit(e)}function vM(){return`:`}function yM(e){return!!(e&&e.type===`paragraph`&&e.data&&e.data.directiveLabel)}function bM(e){let t=0;return e.type===`containerDirective`?(br(e,function(e,n){if(e.type===`containerDirective`){let e=n.length,r=0;for(;e--;)n[e].type===`containerDirective`&&r++;r>t&&(t=r)}}),t+=3):t=e.type===`leafDirective`?2:1,`:`.repeat(t)}function xM(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)?Fr(e,v,`whitespace`)(t):!m&&Jr(t)?Ir(e,v)(t):t===null||Gr(t)||Dr(t)||qr(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||Jr(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||Jr(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||Gr(t)||Dr(t)||qr(t)&&t!==45&&t!==46&&t!==58&&t!==95?(e.exit(c),m&&jr(t)?Fr(e,C,`whitespace`)(t):!m&&Jr(t)?Ir(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&&Gr(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)?Fr(e,w,`whitespace`)(t):!m&&Jr(t)?Ir(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||Jr(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):Gr(t)?m?n(t):Ir(e,D)(t):(e.enter(p),e.consume(t),ee)}function ee(t){return t===g||t===null||Gr(t)?(e.exit(p),D(t)):(e.consume(t),ee)}function te(e){return e===125||Jr(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 SM(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)):Gr(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 CM(e,t,n,r){let i=this;return a;function a(t){return t===null||Gr(t)||qr(t)||Dr(t)?n(t):(e.enter(r),e.consume(t),o)}function o(a){return a===null||Gr(a)||Dr(a)||qr(a)&&a!==45&&a!==95?(e.exit(r),i.previous===45||i.previous===95?n(a):t(a)):(e.consume(a),o)}}var wM={tokenize:OM,concrete:!0},TM={tokenize:kM,partial:!0},EM={tokenize:AM,partial:!0},DM={tokenize:jM,partial:!0};function OM(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`),CM.call(r,e,u,n,`directiveContainerName`)(t))}function u(t){return t===91?e.attempt(TM,d,d)(t):d(t)}function d(t){return t===123?e.attempt(EM,f,f)(t):f(t)}function f(t){return Fr(e,p,`whitespace`)(t)}function p(i){return e.exit(`directiveContainerFence`),i===null?C(i):Gr(i)?r.interrupt?t(i):e.attempt(DM,m,C)(i):n(i)}function m(t){return t===null?C(t):Gr(t)?e.check(DM,y,C)(t):(e.enter(`directiveContainerContent`),h(t))}function h(t){return e.attempt({tokenize:w,partial:!0},S,a?Fr(e,g,`linePrefix`,a+1):g)(t)}function g(t){return t===null?S(t):Gr(t)?e.check(DM,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 Gr(t)?e.check(DM,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 Fr(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`),Fr(e,c,`whitespace`)(t))}function c(r){return r===null||Gr(r)?(e.exit(`directiveContainerFence`),t(r)):n(r)}}}function kM(e,t,n){return SM(e,t,n,`directiveContainerLabel`,`directiveContainerLabelMarker`,`directiveContainerLabelString`,!0)}function AM(e,t,n){return xM(e,t,n,`directiveContainerAttributes`,`directiveContainerAttributesMarker`,`directiveContainerAttribute`,`directiveContainerAttributeId`,`directiveContainerAttributeClass`,`directiveContainerAttributeName`,`directiveContainerAttributeInitializerMarker`,`directiveContainerAttributeValueLiteral`,`directiveContainerAttributeValue`,`directiveContainerAttributeValueMarker`,`directiveContainerAttributeValueData`,!0)}function jM(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 MM={tokenize:FM},NM={tokenize:IM,partial:!0},PM={tokenize:LM,partial:!0};function FM(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`),CM.call(r,e,o,n,`directiveLeafName`)):n(t)}function o(t){return t===91?e.attempt(NM,s,s)(t):s(t)}function s(t){return t===123?e.attempt(PM,c,c)(t):c(t)}function c(t){return Fr(e,l,`whitespace`)(t)}function l(r){return r===null||Gr(r)?(e.exit(`directiveLeaf`),t(r)):n(r)}}function IM(e,t,n){return SM(e,t,n,`directiveLeafLabel`,`directiveLeafLabelMarker`,`directiveLeafLabelString`,!0)}function LM(e,t,n){return xM(e,t,n,`directiveLeafAttributes`,`directiveLeafAttributesMarker`,`directiveLeafAttribute`,`directiveLeafAttributeId`,`directiveLeafAttributeClass`,`directiveLeafAttributeName`,`directiveLeafAttributeInitializerMarker`,`directiveLeafAttributeValueLiteral`,`directiveLeafAttributeValue`,`directiveLeafAttributeValueMarker`,`directiveLeafAttributeValueData`,!0)}var RM={tokenize:HM,previous:VM},zM={tokenize:UM,partial:!0},BM={tokenize:WM,partial:!0};function VM(e){return e!==58||this.events[this.events.length-1][1].type===`characterEscape`}function HM(e,t,n){let r=this;return i;function i(t){return e.enter(`directiveText`),e.enter(`directiveTextMarker`),e.consume(t),e.exit(`directiveTextMarker`),CM.call(r,e,a,n,`directiveTextName`)}function a(t){return t===58?n(t):t===91?e.attempt(zM,o,o)(t):o(t)}function o(t){return t===123?e.attempt(BM,s,s)(t):s(t)}function s(n){return e.exit(`directiveText`),t(n)}}function UM(e,t,n){return SM(e,t,n,`directiveTextLabel`,`directiveTextLabelMarker`,`directiveTextLabelString`)}function WM(e,t,n){return xM(e,t,n,`directiveTextAttributes`,`directiveTextAttributesMarker`,`directiveTextAttribute`,`directiveTextAttributeId`,`directiveTextAttributeClass`,`directiveTextAttributeName`,`directiveTextAttributeInitializerMarker`,`directiveTextAttributeValueLiteral`,`directiveTextAttributeValue`,`directiveTextAttributeValueMarker`,`directiveTextAttributeValueData`)}function GM(){return{text:{58:RM},flow:{58:[wM,MM]}}}function KM(){let e=this.data(),t=e.micromarkExtensions||=[],n=e.fromMarkdownExtensions||=[],r=e.toMarkdownExtensions||=[];t.push(GM()),n.push(nM()),r.push(rM())}var qM=/```([^\r\n`]*)\r?\n?([\s\S]*?)```|`([^`\r\n]+)`/g,JM=/\$\[[^\]\r\n]+\]|\$[A-Za-z0-9][\w.-]*/g,YM=`skill://`,XM=`mention://`;function ZM(e,t){return`[${iN(e,`[]`)}](${iN(t,`()`)})`}function QM(e){let t=[],n=0;for(let r of e.matchAll(qM)){let i=r.index;i>n&&t.push(...$M(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(...$M(e.slice(n),n)),t}function $M(e,t){let n=[],r=rN(e),i=0;for(let a of r)a.start>i&&n.push(...tN(e.slice(i,a.start),t+i)),n.push(eN(a,e,t)),i=a.end;return i<e.length&&n.push(...tN(e.slice(i),t+i)),n}function eN(e,t,n){let r=n+e.start,i=n+e.end,a=t.slice(e.start,e.end);if(e.href.startsWith(XM)){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(YM)){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 tN(e,t){let n=[],r=0;for(let i of e.matchAll(JM)){let a=i.index,o=e[a-1];if(o&&/[\w$]/.test(o))continue;a>r&&n.push(nN(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(nN(e.slice(r),t+r)),n}function nN(e,t){return{kind:`text`,source:e,start:t,end:t+e.length,value:e}}function rN(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!==`[`)continue;let r=aN(e,n+1,`]`);if(!r||e[r.end+1]!==`(`)continue;let i=oN(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 iN(e,t){let n=``;for(let r of e)n+=r===`\\`||t.includes(r)?`\\${r}`:r;return n}function aN(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 oN(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 sN=Sn(),cN=Object.defineProperty,lN=(e,t)=>{let n={};for(var r in e)cN(n,r,{get:e[r],enumerable:!0});return t||cN(n,Symbol.toStringTag,{value:`Module`}),n};function uN(e){this.content=e}uN.prototype={constructor:uN,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 uN(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 uN(n)},addToStart:function(e,t){return new uN([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new uN(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 uN(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=uN.from(e),e.size?new uN(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=uN.from(e),e.size?new uN(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=uN.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}},uN.from=function(e){if(e instanceof uN)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new uN(t)};function dN(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&&mN(e.charCodeAt(r-1))&&pN(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=dN(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function fN(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&&mN(e.charCodeAt(i-1))&&pN(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=fN(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function pN(e){return e>=56320&&e<57344}function mN(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 dN(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return fN(this,e,t,n)}findIndex(e){if(e==0)return gN(0,e);if(e==this.size)return gN(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?gN(t+1,i):gN(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 hN={index:0,offset:0};function gN(e,t){return hN.index=e,hN.offset=t,hN}function _N(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(!_N(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!_N(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var vN=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&&_N(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}};vN.none=[];var yN=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=xN(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(bN(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 bN(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(bN(a.content,t-i-1,n-i-1)))}function xN(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=xN(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 SN(e,t,n){if(n.openStart>e.depth)throw new yN(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new yN(`Inconsistent open depths`);return CN(e,t,n,0)}function CN(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=CN(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return ON(a,AN(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return ON(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=jN(n,e);return ON(a,kN(e,i,o,t,r))}}function wN(e,t){if(!t.type.compatibleContent(e.type))throw new yN(`Cannot join `+t.type.name+` onto `+e.type.name)}function TN(e,t,n){let r=e.node(n);return wN(r,t.node(n)),r}function EN(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 DN(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&&(EN(e.nodeAfter,r),a++));for(let e=a;e<o;e++)EN(i.child(e),r);t&&t.depth==n&&t.textOffset&&EN(t.nodeBefore,r)}function ON(e,t){if(!e.type.validContent(t))throw new yN(`Invalid content for node `+e.type.name);return e.copy(t)}function kN(e,t,n,r,i){let a=e.depth>i&&TN(e,t,i+1),o=r.depth>i&&TN(n,r,i+1),s=[];return DN(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(wN(a,o),EN(ON(a,kN(e,t,n,r,i+1)),s)):(a&&EN(ON(a,AN(e,t,i+1)),s),DN(t,n,i,s),o&&EN(ON(o,AN(n,r,i+1)),s)),DN(r,null,i,s),new K(s)}function AN(e,t,n){let r=[];return DN(null,e,n,r),e.depth>n&&EN(ON(TN(e,t,n+1),AN(e,t,n+1)),r),DN(t,null,n,r),new K(r)}function jN(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 MN=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 vN.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 IN(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=FN.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 FN.set(t,r=new NN);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%PN,i}},NN=class{constructor(){this.elts=[],this.i=0}},PN=12,FN=new WeakMap,IN=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)}},LN=Object.create(null),RN=class e{constructor(e,t,n,r=vN.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&&_N(this.attrs,t||e.defaultAttrs||LN)&&vN.sameSet(this.marks,n||vN.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 SN(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 MN.resolveCached(this,e)}resolveNoCache(e){return MN.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()+`)`),BN(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=vN.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(!vN.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}};RN.prototype.text=void 0;var zN=class e extends RN{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):BN(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 BN(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var VN=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new HN(t,n);if(r.next==null)return e.empty;let i=UN(r);r.next&&r.err(`Unexpected trailing text`);let a=$N(XN(i));return eP(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
|
+
`)}};VN.empty=new VN(!0);var HN=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 UN(e){let t=[];do t.push(WN(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function WN(e){let t=[];do t.push(GN(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function GN(e){let t=YN(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=qN(e,t);else break;return t}function KN(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function qN(e,t){let n=KN(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:KN(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function JN(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 YN(e){if(e.eat(`(`)){let t=UN(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=JN(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 XN(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 ZN(e,t){return t-e}function QN(e,t){let n=[];return r(t),n.sort(ZN);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 $N(e){let t=Object.create(null);return n(QN(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]);QN(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new VN(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ZN);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function eP(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 tP(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 nP(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 rP(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 iP(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new sP(e,r,t[r]);return n}var aP=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=iP(e,n.attrs),this.defaultAttrs=tP(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==VN.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:nP(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new RN(this,this.computeAttrs(e),K.from(t),vN.setFrom(n))}createChecked(e=null,t,n){return t=K.from(t),this.checkContent(t),new RN(this,this.computeAttrs(e),t,vN.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 RN(this,e,t.append(i),vN.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){rP(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:vN.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 oP(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 sP=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?oP(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},cP=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=iP(e,r.attrs),this.excluded=null;let i=tP(this.attrs);this.instance=i?new vN(this,i):null}create(e=null){return!e&&this.instance?this.instance:new vN(this,nP(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){rP(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},lP=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=uN.from(e.nodes),t.marks=uN.from(e.marks||{}),this.nodes=aP.compile(this.spec.nodes,this),this.marks=cP.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]=VN.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?uP(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==``?[]:uP(this,n.split(` `))}this.nodeFromJSON=e=>RN.fromJSON(this,e),this.markFromJSON=e=>vN.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 aP))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 zN(n,n.defaultAttrs,e,vN.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 uP(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 dP(e){return e.tag!=null}function fP(e){return e.style!=null}var pP=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(dP(e))this.tags.push(e);else if(fP(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 SP(this,t,!1);return n.addAll(e,vN.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new SP(this,t,!0);return n.addAll(e,vN.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(wP(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=TP(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=TP(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)))}},mP={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},hP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},gP={ol:!0,ul:!0},_P=1,vP=2,yP=4;function bP(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?_P:0)|(t===`full`?vP:0)}var xP=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=vN.none,this.match=i||(a&yP?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&_P)){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&&!mP.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},SP=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=bP(null,t.preserveWhitespace,0)|(n?yP:0);i=r?new xP(r.type,r.attrs,vN.none,!0,t.topMatch||r.type.contentMatch,a):n?new xP(null,null,vN.none,!0,null,a):new xP(e.schema.topNodeType,null,vN.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&vP?`full`:this.localPreserveWS||(r.options&_P)>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
|
+
`);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;gP.hasOwnProperty(a)&&this.parser.normalizeLists&&CP(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:hP.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(mP.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
|
+
`),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=vN.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):EP(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=bP(e,i,a.options);a.options&yP&&a.content.length==0&&(o|=yP);let s=vN.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):EP(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new xP(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|=_P);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 CP(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&gP.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function wP(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function TP(e){let t={};for(let n in e)t[n]=e[n];return t}function EP(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 DP=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=kP(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 kP(t).createTextNode(e.text);let{dom:n,contentDOM:r}=NP(kP(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&&NP(kP(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:NP(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=OP(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return OP(e.marks)}};function OP(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function kP(e){return e.document||window.document}var AP=new WeakMap;function jP(e){let t=AP.get(e);return t===void 0&&AP.set(e,t=MP(e)),t}function MP(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 NP(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=jP(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}=NP(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var PP=65535,FP=2**16;function IP(e,t){return e+t*FP}function LP(e){return e&PP}function RP(e){return(e-(e&PP))/FP}var zP=1,BP=2,VP=4,HP=8,UP=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&HP)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&VP)>0}},WP=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=LP(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+RP(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:IP(o/3,e-s),f=e==s?BP:e==u?zP:VP;return(t<0?e!=s:e!=u)&&(f|=HP),new UP(a,f,d)}r+=l-c}return n?e+r:new UP(e+r,0,null)}touches(e,t){let n=0,r=LP(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])}};WP.empty=new WP([]);var GP=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 UP(e,r,null)}},KP=Object.create(null),qP=class{getMap(){return WP.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=KP[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in KP)throw RangeError(`Duplicate use of step JSON ID `+e);return KP[e]=t,t.prototype.jsonID=e,t}},JP=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 yN)return e.fail(t.message);throw t}}};function YP(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(YP(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return K.fromArray(r)}var XP=class e extends qP{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(YP(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 JP.fromReplace(e,this.from,this.to,i)}invert(){return new ZP(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))}};qP.jsonID(`addMark`,XP);var ZP=class e extends qP{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(YP(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return JP.fromReplace(e,this.from,this.to,n)}invert(){return new XP(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))}};qP.jsonID(`removeMark`,ZP);var QP=class e extends qP{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return JP.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return JP.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 $P(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))}};qP.jsonID(`addNodeMark`,QP);var $P=class e extends qP{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return JP.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return JP.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 QP(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))}};qP.jsonID(`removeNodeMark`,$P);var eF=class e extends qP{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&nF(e,this.from,this.to)?JP.fail(`Structure replace would overwrite content`):JP.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new WP([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)}};eF.MAP_BIAS=1,qP.jsonID(`replace`,eF);var tF=class e extends qP{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&&(nF(e,this.from,this.gapFrom)||nF(e,this.gapTo,this.to)))return JP.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return JP.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?JP.fromReplace(e,this.from,this.to,n):JP.fail(`Content does not fit in gap`)}getMap(){return new WP([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)}};qP.jsonID(`replaceAround`,tF);function nF(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 rF(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 ZP(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new XP(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function iF(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 cP){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 ZP(t.from,t.to,t.style)))}function aF(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 eF(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 ZP(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 eF(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 oF(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function sF(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||!oF(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function cF(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 tF(c,l,o,s,new q(u.append(f),d,p),u.size-d,!0))}function lF(e,t,n=null,r=e){let i=dF(e,t),a=i&&fF(r,t);return a?i.map(uF).concat({type:t,attrs:n}).concat(a.map(uF)):null}function uF(e){return{type:e,attrs:null}}function dF(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 fF(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 pF(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 tF(i,a,i,a,new q(r,0,0),n.length,!0))}function mF(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)&&_F(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&&gF(e,t,n,a),aF(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 tF(c,l,c+1,l-1,new q(K.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&hF(e,t,n,a),!1}})}function hF(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 gF(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(`
|
|
187
|
+
`))}})}function _F(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function vF(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new tF(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new q(K.from(o),0,0),1,!0))}function yF(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function bF(e,t,n=1,r){let i=e.doc.resolve(t),a=K.empty,o=K.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=K.from(i.node(e).copy(a));let t=r&&r[s];o=K.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new eF(t,t,new q(a.append(o),n,n),!0))}function xF(e,t){let n=e.resolve(t),r=n.index();return CF(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function SF(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function CF(e,t){return!!(e&&t&&!e.isLeaf&&SF(e,t))}function wF(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&CF(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function TF(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);gF(e,r.node(),r.before(),s)}o.inlineContent&&aF(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new eF(l,c.map(t+n,-1),q.empty,!0)),r===!0){let t=e.doc.resolve(l);hF(e,t.node(),t.before(),e.steps.length)}return e}function EF(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function DF(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function OF(e,t,n=t,r=q.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return kF(i,a,r)?new eF(t,n,r):new AF(i,a,r).fit()}function kF(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var AF=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=K.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=K.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new q(i,a,o);return e>-1?new tF(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new eF(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=NF(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(K.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=NF(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new q(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=NF(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new q(jF(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new q(jF(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(PF(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=MF(this.placed,t,K.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?q.empty:new q(jF(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new q(jF(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!FF(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=FF(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=FF(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=MF(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=MF(this.placed,this.depth,K.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(K.empty,!0);e.childCount&&(this.placed=MF(this.placed,this.frontier.length,e))}};function jF(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(jF(e.firstChild.content,t-1,n)))}function MF(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(MF(e.lastChild.content,t-1,n)))}function NF(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function PF(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,PF(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(K.empty,!0)))),e.copy(r)}function FF(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!IF(n,a.content,o)?s:null}function IF(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function LF(e){return e.spec.defining||e.spec.definingForContent}function RF(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(kF(i,a,r))return e.step(new eF(t,n,r));let o=HF(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=LF(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new q(zF(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function zF(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(zF(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(K.empty,!0))}return e}function BF(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=EF(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new q(K.from(r),0,0))}function VF(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=HF(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function HF(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var UF=class e extends qP{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return JP.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return JP.fromReplace(e,this.pos,this.pos+1,new q(K.from(r),0,+!t.isLeaf))}getMap(){return WP.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};qP.jsonID(`attr`,UF);var WF=class e extends qP{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return JP.ok(n)}getMap(){return WP.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};qP.jsonID(`docAttr`,WF);var GF=class extends Error{};GF=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},GF.prototype=Object.create(Error.prototype),GF.prototype.constructor=GF,GF.prototype.name=`TransformError`;var KF=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new GP}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new GF(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=q.empty){let r=OF(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new q(K.from(n),0,0))}delete(e,t){return this.replace(e,t,q.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return RF(this,e,t,n),this}replaceRangeWith(e,t,n){return BF(this,e,t,n),this}deleteRange(e,t){return VF(this,e,t),this}lift(e,t){return cF(this,e,t),this}join(e,t=1){return TF(this,e,t),this}wrap(e,t){return pF(this,e,t),this}setBlockType(e,t=e,n,r=null){return mF(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return vF(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new UF(e,t,n)),this}setDocAttribute(e,t){return this.step(new WF(e,t)),this}addNodeMark(e,t){return this.step(new QP(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof vN)t.isInSet(n.marks)&&this.step(new $P(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new $P(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return bF(this,e,t,n),this}addMark(e,t,n){return rF(this,e,t,n),this}removeMark(e,t,n){return iF(this,e,t,n),this}clearIncompatible(e,t,n){return aF(this,e,t,n),this}},qF=Object.create(null),J=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new JF(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=q.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?q.empty:t),o==0&&nI(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),nI(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Y(e):tI(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?tI(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):tI(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new $F(e.node(0))}static atStart(e){return tI(e,e,0,0,1)||new $F(e)}static atEnd(e){return tI(e,e,e.content.size,e.childCount,-1)||new $F(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=qF[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in qF)throw RangeError(`Duplicate use of selection JSON ID `+e);return qF[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Y.between(this.$anchor,this.$head).getBookmark()}};J.prototype.visible=!0;var JF=class{constructor(e,t){this.$from=e,this.$to=t}},YF=!1;function XF(e){!YF&&!e.parent.inlineContent&&(YF=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var Y=class e extends J{constructor(e,t=e){XF(e),XF(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return J.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=q.empty){if(super.replace(e,t),t==q.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ZF(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=J.findFrom(n,r,!0)||J.findFrom(n,-r,!0);if(e)n=e.$head;else return J.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(J.findFrom(t,-r,!0)||J.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};J.jsonID(`text`,Y);var ZF=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return Y.between(e.resolve(this.anchor),e.resolve(this.head))}},X=class e extends J{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?J.near(a):new e(a)}content(){return new q(K.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new QF(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};X.prototype.visible=!1,J.jsonID(`node`,X);var QF=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new ZF(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&X.isSelectable(n)?new X(t):J.near(t)}},$F=class e extends J{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=q.empty){if(t==q.empty){e.delete(0,e.doc.content.size);let t=J.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return eI}};J.jsonID(`all`,$F);var eI={map(){return this},resolve(e){return new $F(e)}};function tI(e,t,n,r,i,a=!1){if(t.inlineContent)return Y.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=tI(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&X.isSelectable(r))return X.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function nI(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof eF||i instanceof tF))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(J.near(e.doc.resolve(o),n))}var rI=1,iI=2,aI=4,oI=class extends KF{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|rI)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&rI)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=iI,this}ensureMarks(e){return vN.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&iI)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||vN.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(J.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=aI,this}get scrolledIntoView(){return(this.updated&aI)>0}};function sI(e,t){return!t||!e?e:e.bind(t)}var cI=class{constructor(e,t,n){this.name=e,this.init=sI(t.init,n),this.apply=sI(t.apply,n)}},lI=[new cI(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new cI(`selection`,{init(e,t){return e.selection||J.atStart(t.doc)},apply(e){return e.selection}}),new cI(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new cI(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],uI=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=lI.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new cI(e.key,e.spec.state,e))})}},dI=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new oI(this)}static create(t){let n=new uI(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new uI(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new uI(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=RN.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=J.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function fI(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=fI(i,t,{})),n[r]=i}return n}var pI=class{constructor(e){this.spec=e,this.props={},e.props&&fI(e.props,this,this.props),this.key=e.key?e.key.key:hI(`plugin`)}getState(e){return e[this.key]}},mI=Object.create(null);function hI(e){return e in mI?e+`$`+ ++mI[e]:(mI[e]=0,e+`$`)}var gI=class{constructor(e=`key`){this.key=hI(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},_I=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function vI(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var yI=(e,t,n)=>{let r=vI(e,n);if(!r)return!1;let i=TI(r);if(!i){let n=r.blockRange(),i=n&&sF(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(UI(e,i,t,-1))return!0;if(r.parent.content.size==0&&(CI(a,`end`)||X.isSelectable(a)))for(let n=r.depth;;n--){let o=OF(e.doc,r.before(n),r.after(n),q.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(CI(a,`end`)?J.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):X.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},bI=(e,t,n)=>{let r=vI(e,n);if(!r)return!1;let i=TI(r);return i?SI(e,i,t):!1},xI=(e,t,n)=>{let r=EI(e,n);if(!r)return!1;let i=kI(r);return i?SI(e,i,t):!1};function SI(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=OF(e.doc,i,o,q.empty);if(!s||s.from!=i||s instanceof eF&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(Y.create(t.doc,i)),n(t.scrollIntoView())}return!0}function CI(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var wI=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=TI(r)}let o=a&&a.nodeBefore;return!o||!X.isSelectable(o)?!1:(t&&t(e.tr.setSelection(X.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function TI(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function EI(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var DI=(e,t,n)=>{let r=EI(e,n);if(!r)return!1;let i=kI(r);if(!i)return!1;let a=i.nodeAfter;if(UI(e,i,t,1))return!0;if(r.parent.content.size==0&&(CI(a,`start`)||X.isSelectable(a))){let n=OF(e.doc,r.before(),r.after(),q.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(CI(a,`start`)?J.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):X.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},OI=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=kI(r)}let o=a&&a.nodeAfter;return!o||!X.isSelectable(o)?!1:(t&&t(e.tr.setSelection(X.create(e.doc,a.pos)).scrollIntoView()),!0)};function kI(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var AI=(e,t)=>{let n=e.selection,r=n instanceof X,i;if(r){if(n.node.isTextblock||!xF(e.doc,n.from))return!1;i=n.from}else if(i=wF(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(X.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},jI=(e,t)=>{let n=e.selection,r;if(n instanceof X){if(n.node.isTextblock||!xF(e.doc,n.to))return!1;r=n.to}else if(r=wF(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},MI=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&sF(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},NI=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
188
|
+
`).scrollIntoView()),!0)};function PI(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var FI=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=PI(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(J.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},II=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof $F||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=PI(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(Y.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},LI=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(yF(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&sF(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function RI(e){return(t,n)=>{if(t.selection instanceof X&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!yF(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof Y||t.selection instanceof $F)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=PI(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=yF(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,yF(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var zI=RI(),BI=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(X.create(e.doc,i))),!0)},VI=(e,t)=>(t&&t(e.tr.setSelection(new $F(e.doc))),!0);function HI(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||xF(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function UI(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&HI(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=K.empty;for(let e=o.length-1;e>=0;e--)s=K.from(o[e].create(null,s));s=K.from(i.copy(s));let c=e.tr.step(new tF(t.pos-1,r,t.pos,r,new q(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&xF(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:J.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&sF(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&CI(a,`start`,!0)&&CI(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=K.empty;for(let e=o.length-1;e>=0;e--)r=K.from(o[e].copy(r));n(e.tr.step(new tF(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new q(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function WI(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(Y.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var GI=WI(-1),KI=WI(1);function qI(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&lF(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function JI(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function YI(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var XI=YI(_I,yI,wI),ZI=YI(_I,DI,OI),QI={Enter:YI(NI,II,LI,zI),"Mod-Enter":FI,Backspace:XI,"Mod-Backspace":XI,"Shift-Backspace":XI,Delete:ZI,"Mod-Delete":ZI,"Mod-a":VI},$I={"Ctrl-h":QI.Backspace,"Alt-Backspace":QI[`Mod-Backspace`],"Ctrl-d":QI.Delete,"Ctrl-Alt-Backspace":QI[`Mod-Delete`],"Alt-Delete":QI[`Mod-Delete`],"Alt-d":QI[`Mod-Delete`],"Ctrl-a":GI,"Ctrl-e":KI};for(let e in QI)$I[e]=QI[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function eL(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return tL(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function tL(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new IN(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new IN(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=lF(a,n,r,t);return s?(e&&nL(e,t,s,i,n),!0):!1}function nL(e,t,n,r,i){let a=K.empty;for(let e=n.length-1;e>=0;e--)a=K.from(n[e].type.create(n[e].attrs,a));e.step(new tF(t.start-(r?2:0),t.end,t.start,t.end,new q(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&yF(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function rL(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?iL(t,n,e,a):aL(t,n,a):!0:!1}}function iL(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new tF(a-1,o,a,o,new q(K.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new IN(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=sF(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return xF(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function aL(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?K.empty:K.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new tF(d-+!!s,f+ +!!c,d+1,f-1,new q((s?K.empty:K.from(i.copy(K.empty))).append(c?K.empty:K.from(i.copy(K.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function oL(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=K.from(r?e.create():null),o=new q(K.from(e.create(null,K.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new tF(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var sL=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},cL=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},lL=null,uL=function(e,t,n){let r=lL||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},dL=function(){lL=null},fL=function(e,t,n,r){return n&&(mL(e,t,n,r,-1)||mL(e,t,n,r,1))},pL=/^(img|br|input|textarea|hr)$/i;function mL(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:hL(e))){let n=e.parentNode;if(!n||n.nodeType!=1||yL(e)||pL.test(e.nodeName)||e.contentEditable==`false`)return!1;t=sL(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?hL(e):0}else return!1}}function hL(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function gL(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=hL(e)}else if(e.parentNode&&!yL(e))t=sL(e),e=e.parentNode;else return null}}function _L(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!yL(e))t=sL(e)+1,e=e.parentNode;else return null}}function vL(e,t,n){for(let r=t==0,i=t==hL(e);r||i;){if(e==n)return!0;let t=sL(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==hL(e)}}function yL(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var bL=function(e){return e.focusNode&&fL(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function xL(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function SL(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function CL(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(hL(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(hL(r.startContainer),r.startOffset)}}}var wL=typeof navigator<`u`?navigator:null,TL=typeof document<`u`?document:null,EL=wL&&wL.userAgent||``,DL=/Edge\/(\d+)/.exec(EL),OL=/MSIE \d/.exec(EL),kL=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(EL),AL=!!(OL||kL||DL),jL=OL?document.documentMode:kL?+kL[1]:DL?+DL[1]:0,ML=!AL&&/gecko\/(\d+)/i.test(EL);ML&&+(/Firefox\/(\d+)/.exec(EL)||[0,0])[1];var NL=!AL&&/Chrome\/(\d+)/.exec(EL),PL=!!NL,FL=NL?+NL[1]:0,IL=!AL&&!!wL&&/Apple Computer/.test(wL.vendor),LL=IL&&(/Mobile\/\w+/.test(EL)||!!wL&&wL.maxTouchPoints>2),RL=LL||(wL?/Mac/.test(wL.platform):!1),zL=wL?/Win/.test(wL.platform):!1,BL=/Android \d/.test(EL),VL=!!TL&&`webkitFontSmoothing`in TL.documentElement.style,HL=VL?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function UL(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function WL(e,t){return typeof e==`number`?e:e[t]}function GL(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function KL(e,t,n){if(!sR(t)&&t.left==0)return;let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=cL(o);continue}let e=o,n=e==a.body,s=n?UL(a):GL(e),c=0,l=0;if(t.top<s.top+WL(r,`top`)?l=-(s.top-t.top+WL(i,`top`)):t.bottom>s.bottom-WL(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+WL(i,`top`)-s.top:t.bottom-s.bottom+WL(i,`bottom`)),t.left<s.left+WL(r,`left`)?c=-(s.left-t.left+WL(i,`left`)):t.right>s.right-WL(r,`right`)&&(c=t.right-s.right+WL(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:cL(o)}}function qL(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:JL(e.dom)}}function JL(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=cL(r));return t}function YL({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;XL(n,r==0?0:r-t)}function XL(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var ZL=null;function QL(e){if(e.setActive)return e.setActive();if(ZL)return e.focus(ZL);let t=JL(e);e.focus(ZL==null?{get preventScroll(){return ZL={preventScroll:!0},!0}}:void 0),ZL||(ZL=!1,XL(t,0))}function $L(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=uL(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?eR(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:$L(n,i)}function eR(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=cR(r,1);if(n.top!=n.bottom&&tR(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function tR(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function nR(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function rR(e,t,n){let{node:r,offset:i}=$L(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function iR(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function aR(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(tR(t,i))return aR(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function oR(e,t){let n=e.dom.ownerDocument,r,i=0,a=CL(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!tR(t,n)||(o=aR(e.dom,t,n),!o))return null}if(IL)for(let e=o;r&&e;e=cL(e))e.draggable&&(r=void 0);if(o=nR(o,t),r){if(ML&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;VL&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=iR(e,r,i,t))}s??=rR(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function sR(e){return e.top<e.bottom||e.left<e.right}function cR(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(sR(e))return e}return Array.prototype.find.call(n,sR)||e.getBoundingClientRect()}var lR=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function uR(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=VL||ML;if(r.nodeType==3)if(o&&(lR.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=cR(uL(r,i,i),n);if(ML&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=cR(uL(r,i-1,i-1),-1);if(t.top==e.top){let n=cR(uL(r,i,i+1),-1);if(n.top!=e.top)return dR(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,dR(cR(uL(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==hL(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return fR(e.getBoundingClientRect(),!1)}if(a==null&&i<hL(r)){let e=r.childNodes[i];if(e.nodeType==1)return fR(e.getBoundingClientRect(),!0)}return fR(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==hL(r))){let e=r.childNodes[i-1],t=e.nodeType==3?uL(e,hL(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return dR(cR(t,1),!1)}if(a==null&&i<hL(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?uL(e,0,+!o):e.nodeType==1?e:null:null;if(t)return dR(cR(t,-1),!0)}return dR(cR(r.nodeType==3?uL(r):r,-n),n>=0)}function dR(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function fR(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function pR(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function mR(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return pR(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=uR(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=uL(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var hR=/[\u0590-\u08ac]/;function gR(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!hR.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:pR(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var _R=null,vR=null,yR=!1;function bR(e,t,n){return _R==t&&vR==n?yR:(_R=t,vR=n,yR=n==`up`||n==`down`?mR(e,t,n):gR(e,t,n))}var xR=0,SR=1,CR=2,wR=3,TR=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=xR,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>sL(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof MR){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof ER&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?sL(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?sL(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=sL(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=sL(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((ML||IL)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
|
|
189
|
+
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:sL(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(ML&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&IL)&&fL(o.node,o.offset,l.anchorNode,l.anchorOffset)&&fL(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&ML)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?CR:SR,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=wR:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?CR:wR}n=a}this.dirty=CR}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?CR:SR;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},ER=class extends TR{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.hasAttribute(`contenteditable`)||(a.contentEditable=`false`),a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==xR&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},DR=class extends TR{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},OR=class e extends TR{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=DP.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&wR||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=wR&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=xR){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=xR}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=YR(a,n,o,r)),t>0&&(a=YR(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},kR=class e extends TR{constructor(e,t,n,r,i,a,o){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=DP.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=BR(u,r,n),l?c=new NR(t,n,r,i,u,d||null,f,l):n.isText?new jR(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>t.nodeType==1&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>K.empty}}return t}matchesNode(e,t,n){return this.dirty==xR&&e.eq(this.node)&&VR(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new UR(this,a&&a.node,e);KR(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?vN.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==CR)&&(a&&this.protectLocalComposition(e,a),PR(this.contentDOM,this.children,e),LL&&qR(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Y)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=JR(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new DR(this,i,t,r);e.input.compositionNodes.push(a),this.children=YR(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==wR||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=xR}updateOuterDeco(e){if(VR(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=RR(this.dom,this.nodeDOM,LR(this.outerDeco,this.node,t),LR(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function AR(e,t,n,r,i){BR(r,t,e);let a=new kR(void 0,e,t,n,r,r,r);return a.contentDOM&&a.updateChildren(i,0),a}var jR=class e extends kR{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==wR||this.dirty!=xR&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=xR||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=xR,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=wR)}get domAtom(){return!1}isText(e){return this.node.text==e}},MR=class extends TR{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==xR&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},NR=class extends kR{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r){if(this.dirty==wR)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function PR(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=HR(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof OR){let t=r?r.previousSibling:e.lastChild;PR(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=HR(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var FR=function(e){e&&(this.nodeName=e)};FR.prototype=Object.create(null);var IR=[new FR];function LR(e,t,n){if(e.length==0)return IR;let r=n?IR[0]:new FR,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new FR(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new FR(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function RR(e,t,n,r){if(n==IR&&r==IR)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=IR[0],i=t)}zR(i,o||IR[0],a)}return i}function zR(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function BR(e,t,n){return RR(e,e,IR,LR(t,n,e.nodeType!=1))}function VR(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function HR(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var UR=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=WR(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=xR,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof OR&&t.dirty!=wR&&t.mark.type==e[a].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[a])&&(t.mark=e[a],i=this.index,this.changed=!0)}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=OR.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==wR&&a.dom==a.contentDOM&&(a.dirty=CR),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof kR){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=wR&&VR(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=CR,u.updateChildren(r,a+1),u.dirty=xR),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!VR(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=kR.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=kR.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new ER(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof OR;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jR)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((IL||PL)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new MR(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function WR(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof OR)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function GR(e,t){return e.type.side-t.type.side}function KR(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(GR);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function qR(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function JR(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function YR(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function XR(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(bL(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&X.isSelectable(e)&&i.parent&&!(e.isInline&&vL(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new X(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=sz(e,u,s,n)}return l}function ZR(e){return e.editable?e.hasFocus():lz(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function QR(e,t=!1){let n=e.state.selection;if(az(e,n),!ZR(e))return;let r=e.input.mouseDown;if(!t&&PL&&r){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&fL(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)iz(e);else{let{anchor:r,head:i}=n,a,o;$R&&!(n instanceof Y)&&(n.$from.parent.inlineContent||(a=ez(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=ez(e,n.to))),e.docView.setSelection(r,i,e,t),$R&&(a&&nz(a),o&&nz(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&rz(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var $R=IL||PL&&FL<63;function ez(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(IL&&i&&i.contentEditable==`false`)return tz(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return tz(i);if(a)return tz(a)}}function tz(e){return e.contentEditable=`true`,IL&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function nz(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function rz(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!ZR(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function iz(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,sL(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&AL&&jL<=11&&(n.disabled=!0,n.disabled=!1)}function az(e,t){if(t instanceof X){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(oz(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else oz(e)}function oz(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function sz(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||Y.between(t,n,r)}function cz(e){return e.editable&&!e.hasFocus()?!1:lz(e)}function lz(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function uz(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return fL(t.node,t.offset,n.anchorNode,n.anchorOffset)}function dz(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&J.findFrom(a,t)}function fz(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function pz(e,t,n){let r=e.state.selection;if(r instanceof Y){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return fz(e,new Y(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=dz(e.state,t);return n&&n instanceof X?fz(e,n):!1}else if(!(RL&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?X.isSelectable(i)?fz(e,new X(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):VL?fz(e,new Y(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof X&&r.node.isInline)return fz(e,new Y(t>0?r.$to:r.$from));else{let n=dz(e.state,t);return n?fz(e,n):!1}}function mz(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function hz(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function gz(e,t){return t<0?_z(e):vz(e)}function _z(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(ML&&n.nodeType==1&&r<mz(n)&&hz(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(hz(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(yz(n))break;else{let t=n.previousSibling;for(;t&&hz(t,-1);)i=n.parentNode,a=sL(t),t=t.previousSibling;if(t)n=t,r=mz(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Sz(e,n,r):i&&Sz(e,i,a)}function vz(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=mz(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(hz(e,1))a=n,o=++r;else break}else if(yz(n))break;else{let t=n.nextSibling;for(;t&&hz(t,1);)a=t.parentNode,o=sL(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=mz(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Sz(e,a,o)}function yz(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function bz(e,t){for(;e&&t==e.childNodes.length&&!yL(e);)t=sL(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function xz(e,t){for(;e&&!t&&!yL(e);)t=sL(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function Sz(e,t,n){if(t.nodeType!=3){let e,r;(r=bz(t,n))?(t=r,n=0):(e=xz(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(bL(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&QR(e)},50)}function Cz(e,t){let n=e.state.doc.resolve(t);if(!(PL||zL)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function wz(e,t,n){let r=e.state.selection;if(r instanceof Y&&!r.empty||n.indexOf(`s`)>-1||RL&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=dz(e.state,t);if(n&&n instanceof X)return fz(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof $F?J.near(n,t):J.findFrom(n,t);return o?fz(e,o):!1}return!1}function Tz(e,t){if(!(e.state.selection instanceof Y))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Ez(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Dz(e){if(!IL||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Ez(e,n,`true`),setTimeout(()=>Ez(e,n,`false`),20)}return!1}function Oz(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function kz(e,t){let n=t.keyCode,r=Oz(t);if(n==8||RL&&n==72&&r==`c`)return Tz(e,-1)||gz(e,-1);if(n==46&&!t.shiftKey||RL&&n==68&&r==`c`)return Tz(e,1)||gz(e,1);if(n==13||n==27)return!0;if(n==37||RL&&n==66&&r==`c`){let t=n==37?Cz(e,e.state.selection.from)==`ltr`?-1:1:-1;return pz(e,t,r)||gz(e,t)}else if(n==39||RL&&n==70&&r==`c`){let t=n==39?Cz(e,e.state.selection.from)==`ltr`?1:-1:1;return pz(e,t,r)||gz(e,t)}else if(n==38||RL&&n==80&&r==`c`)return wz(e,-1,r)||gz(e,-1);else if(n==40||RL&&n==78&&r==`c`)return Dz(e)||wz(e,1,r)||gz(e,1);else if(r==(RL?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function Az(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||DP.fromSchema(e.state.schema),s=Bz(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=zz[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
|
|
190
|
+
|
|
191
|
+
`),slice:t}}function jz(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
|
+
`))),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=DP.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=Uz(n),VL&&Wz(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`)||pP.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Mz.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=Gz(Rz(s,+u[1],+u[2]),u[4]);else if(s=q.maxOpen(Nz(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=Rz(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Mz=/^(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 Nz(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&&Fz(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Iz(a[a.length-1],i.length));let n=Pz(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return K.from(a)}return e}function Pz(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,K.from(e));return e}function Fz(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Fz(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(Pz(n,e,i+1))))}}function Iz(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Iz(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(K.empty,!0);return e.copy(n.append(r))}function Lz(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=Lz(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 Rz(e,t,n){return t<e.openStart&&(e=new q(Lz(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new q(Lz(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var zz={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 Bz(){return document.implementation.createHTMLDocument(`title`)}var Vz=null;function Hz(e){let t=window.trustedTypes;if(!t)return e;if(!Vz){if(Vz=t.defaultPolicy)try{return Vz.createHTML(e)}catch{}Vz=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return Vz.createHTML(e)}function Uz(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Bz(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&zz[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=Hz(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 Wz(e){let t=e.querySelectorAll(PL?`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 Gz(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 Kz={},qz={},Jz={touchstart:!0,touchmove:!0},Yz=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 Xz(e){for(let t in Kz){let n=Kz[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{tB(e,t)&&!eB(e,t)&&(e.editable||!(t.type in qz))&&n(e,t)},Jz[t]?{passive:!0}:void 0)}IL&&e.dom.addEventListener(`input`,()=>null),$z(e)}function Zz(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Qz(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 $z(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>eB(e,t))})}function eB(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function tB(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 nB(e,t){!eB(e,t)&&Kz[t.type]&&(e.editable||!(t.type in qz))&&Kz[t.type](e,t)}qz.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!yB(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(BL&&PL&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),LL&&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,xL(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||kz(e,n)?n.preventDefault():Zz(e,`key`)},qz.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},qz.keypress=(e,t)=>{let n=t;if(yB(e)||!n.charCode||n.ctrlKey&&!n.altKey||RL&&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 rB(e){return{left:e.clientX,top:e.clientY}}function iB(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function aB(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 oB(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 sB(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&X.isSelectable(r)?(oB(e,new X(n),`pointer`),!0):!1}function cB(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:(oB(e,X.create(e.state.doc,i),`pointer`),!0)}function lB(e,t,n,r,i){return aB(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?cB(e,n):sB(e,n))}function uB(e,t,n,r){return aB(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function dB(e,t,n,r){return aB(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||fB(e,n,r)}function fB(e,t,n){if(n.button!=0)return!1;let r=pB(e,t,!0),i=e.state.doc;return r?(oB(e,r,`pointer`),r instanceof Y&&i.eq(e.state.doc)&&(e.input.mouseDown=new vB(e,r)),!0):!1}function pB(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 mB(e){return TB(e)}var hB=RL?`metaKey`:`ctrlKey`;Kz.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=mB(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&iB(n,e.input.lastClick)&&!n[hB]&&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(rB(n));o&&(a==`singleClick`?e.input.mouseDown=new _B(e,o,n,!!r):(a==`doubleClick`?uB:dB)(e,o.pos,o.inside,n)?n.preventDefault():Zz(e,`pointer`))};var gB=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}},_B=class extends gB{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[hB],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&&ML&&!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()),Zz(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||QR(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(rB(e))),this.updateAllowDefault(e),this.allowDefault||!t?Zz(this.view,`pointer`):lB(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||IL&&this.mightDrag&&!this.mightDrag.node.isAtom||PL&&!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)?(oB(this.view,J.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):Zz(this.view,`pointer`)}move(e){this.updateAllowDefault(e),Zz(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}},vB=class extends gB{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(),Zz(this.view,`pointer`);let t=this.view.posAtCoords(rB(e)),n=t&&pB(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];oB(this.view,Y.create(r,a,o),`pointer`)}};Kz.touchstart=e=>{e.input.lastTouch=Date.now(),mB(e),Zz(e,`pointer`)},Kz.touchmove=e=>{e.input.lastTouch=Date.now(),Zz(e,`pointer`)},Kz.contextmenu=e=>mB(e);function yB(e,t){return e.composing?!0:IL&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var bB=BL?5e3:-1;qz.compositionstart=qz.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)||PL&&zL&&xB(e)))e.markCursor=e.state.storedMarks||n.marks(),TB(e,!0),e.markCursor=null;else if(TB(e,!t.selection.empty),ML&&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}SB(e,bB)};function xB(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`}qz.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++,SB(e,20))};function SB(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>TB(e),t))}function CB(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function wB(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=gL(t.focusNode,t.focusOffset),r=_L(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 TB(e,t=!1){if(!(BL&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),CB(e),t||e.docView&&e.docView.dirty){let n=XR(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 EB(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 DB=AL&&jL<15||LL&&HL<604;Kz.copy=qz.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=DB?null:n.clipboardData,{dom:o,text:s}=Az(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):EB(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function OB(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function kB(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?AB(e,r.value,null,i,t):AB(e,r.textContent,r.innerHTML,i,t)},50)}function AB(e,t,n,r,i){let a=jz(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=OB(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 jB(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,` `):``}qz.paste=(e,t)=>{let n=t;if(e.composing&&!BL)return;let r=DB?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&AB(e,jB(r),r.getData(`text/html`),i,n)?n.preventDefault():kB(e,n)};var MB=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},NB=RL?`altKey`:`ctrlKey`;function PB(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[NB]:!n}Kz.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(rB(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}=Az(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!PL||FL>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(DB?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,DB||n.dataTransfer.setData(`text/plain`,c),e.dragging=new MB(l,PB(e,n),o)},Kz.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},qz.dragover=qz.dragenter=(e,t)=>t.preventDefault(),qz.drop=(e,t)=>{try{FB(e,t,e.dragging)}finally{e.dragging=null}};function FB(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(rB(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=jz(e,jB(t.dataTransfer),DB?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&PB(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?DF(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(sz(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}Kz.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())&&QR(e)},20))},Kz.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)},Kz.beforeinput=(e,t)=>{if(BL&&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,xL(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 qz)Kz[e]=qz[e];function IB(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 LB=class e{constructor(e,t){this.toDOM=e,this.spec=t||HB,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 BB(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&&IB(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},RB=class e{constructor(e,t){this.attrs=e,this.spec=t||HB}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 BB(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&IB(this.attrs,t.attrs)&&IB(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},zB=class e{constructor(e,t){this.attrs=e,this.spec=t||HB}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 BB(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&&IB(this.attrs,t.attrs)&&IB(this.spec,t.spec)}destroy(){}},BB=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 LB(n,r))}static inline(t,n,r,i){return new e(t,n,new RB(r,i))}static node(t,n,r,i){return new e(t,n,new zB(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof RB}get widget(){return this.type instanceof LB}},VB=[],HB={},UB=class e{constructor(e,t){this.local=e.length?e:VB,this.children=t.length?t:VB}static create(e,t){return t.length?ZB(t,e,0,HB):WB}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==WB||e.maps.length==0?this:this.mapInner(e,t,0,0,n||HB)}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?KB(this.children,o||[],t,n,r,i,a):o?new e(o.sort(QB),VB):WB}add(t,n){return n.length?this==WB?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=YB(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,ZB(s,e,o+1,HB)),a+=3}});let o=qB(a?XB(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(QB):this.local,i||this.children)}remove(e){return e.length==0||this==WB?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==WB?(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):WB}forChild(t,n){if(this==WB)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 RB){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(QB),VB);return r?new GB([t,r]):t}return r||WB}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 $B(this.localsInner(e))}localsInner(e){if(this==WB)return VB;if(e.inlineContent||!this.local.some(RB.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof RB||t.push(this.local[e]);return t}forEachSet(e){e(this)}};UB.empty=new UB([],[]),UB.removeOverlap=$B;var WB=UB.empty,GB=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,HB));return e.from(r)}forChild(t,n){if(n.isLeaf)return UB.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=WB&&(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?$B(n?t:t.sort(QB)):VB}static from(t){switch(t.length){case 0:return WB;case 1:return t[0];default:return new e(t.every(e=>e instanceof UB)?t:t.reduce((e,t)=>e.concat(t instanceof UB?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function KB(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==WB?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=ZB(JB(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 UB(t.sort(QB),s)}function qB(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 BB(i.from+t,i.to+t,i.type))}return n}function JB(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 YB(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 XB(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function ZB(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=YB(e,t,o+n);if(s){a=!0;let e=ZB(s,t,n+o+1,r);e!=WB&&i.push(o,o+t.nodeSize,e)}});let o=qB(a?XB(e):e,-n).sort(QB);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 UB(o,i):WB}function QB(e,t){return e.from-t.from||e.to-t.to}function $B(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),eV(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),eV(t,i,r.copy(a.from,r.to)));break}}}return t}function eV(e,t,n){for(;t<e.length&&QB(n,e[t])>0;)t++;e.splice(t,0,n)}function tV(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=WB&&t.push(r)}),e.cursorWrapper&&t.push(UB.create(e.state.doc,[e.cursorWrapper.deco])),GB.from(t)}var nV={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rV=AL&&jL<=11,iV=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}},aV=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new iV,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]);AL&&jL<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():IL&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rV&&(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,nV)),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(cz(this.view)){if(this.suppressingSelectionUpdates)return QR(this.view);if(AL&&jL<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&fL(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=cL(n))t.add(n);for(let r=e.anchorNode;r;r=cL(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)&&cz(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||PL&&(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(ML&&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||dV(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&&bL(n)&&(c=XR(e))&&c.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,QR(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),cV(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,fV(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||QR(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(AL&&jL<=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?sL(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?sL(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}}},oV=new WeakMap,sV=!1;function cV(e){if(!oV.has(e)&&(oV.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=ML,sV)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.`),sV=!0}}function lV(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return fL(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function uV(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return lV(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?lV(e,n):null}function dV(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 fV(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 pV(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}],bL(l)||u.push({node:l.focusNode,offset:l.focusOffset})),PL&&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`)||pP.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:mV(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 mV=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(IL&&/^(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||IL&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},hV=/^(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 gV(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=XR(e,t);if(n&&!e.state.selection.eq(n)){if(PL&&BL&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,xL(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=pV(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=xV(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(LL&&e.input.lastIOSEnter>Date.now()-225||BL)&&i.some(e=>e.nodeType==1&&!hV.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,xL(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=_V(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)),AL&&jL<=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((LL&&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,xL(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&yV(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,xL(8,`Backspace`)))){BL&&PL&&e.domObserver.suppressSelectionUpdates();return}PL&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),BL&&!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,xL(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=_V(e,n.doc,l.sel);t&&!(PL&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||AL&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){AL&&jL<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>QR(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=vV(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 _V(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:sz(e,t.resolve(n.anchor),t.resolve(n.head))}function vV(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 yV(e,t,n,r,i){if(n-t<=i.pos-r.pos||bV(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(bV(a,!0,!0));return!o.parent.isTextblock||o.pos>n||bV(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function bV(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 xV(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 SV=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 Yz,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(kV),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=TV(this),wV(this),this.nodeViews=DV(this),this.docView=AR(this.state.doc,CV(this),tV(this),this.dom,this),this.domObserver=new aV(this,(e,t,n,r)=>gV(this,e,t,n,r)),this.domObserver.start(),Xz(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&&$z(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(kV),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&&(CB(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=DV(this);OV(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&$z(this),this.editable=TV(this),wV(this);let o=tV(this),s=CV(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&&qL(this);if(i){this.domObserver.stop();let t=l&&(AL||PL)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&EV(n.selection,e.selection);if(l){let n=PL?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=wB(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=AR(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())&&uz(this)&&i.delaySelUpdate())?QR(this,t):(az(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&&YL(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&&KL(this,t.getBoundingClientRect(),e)}else KL(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 MB(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(AL){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&&QL(this.dom),QR(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 oR(this,e)}coordsAtPos(e,t=1){return uR(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 bR(this,t||this.state,e)}pasteHTML(e,t){return AB(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return AB(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Az(this,e)}destroy(){this.docView&&(Qz(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],tV(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,dL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return nB(this,e)}domSelectionRange(){let e=this.domSelection();return e?IL&&this.root.nodeType===11&&SL(this.dom.ownerDocument)==this.dom&&uV(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};SV.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function CV(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`,[BB.node(0,e.state.doc.content.size,t)]}function wV(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:BB.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function TV(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function EV(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 DV(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 OV(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 kV(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 AV={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:`'`},jV={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},MV=typeof navigator<`u`&&/Mac/.test(navigator.platform),NV=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),PV=0;PV<10;PV++)AV[48+PV]=AV[96+PV]=String(PV);for(var PV=1;PV<=24;PV++)AV[PV+111]=`F`+PV;for(var PV=65;PV<=90;PV++)AV[PV]=String.fromCharCode(PV+32),jV[PV]=String.fromCharCode(PV);for(var FV in AV)jV.hasOwnProperty(FV)||(jV[FV]=AV[FV]);function IV(e){var t=!(MV&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||NV&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?jV:AV)[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 LV=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),RV=typeof navigator<`u`&&/Win/.test(navigator.platform);function zV(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))LV?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 BV(e){let t=Object.create(null);for(let n in e)t[zV(n)]=e[n];return t}function VV(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 HV(e){return new pI({props:{handleKeyDown:UV(e)}})}function UV(e){let t=BV(e);return function(e,n){let r=IV(n),i,a=t[VV(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[VV(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(RV&&n.ctrlKey&&n.altKey)&&(i=AV[n.keyCode])&&i!=r){let r=t[VV(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}function WV(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 GV=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:WV({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}},KV=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),qV=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),JV=()=>({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=sF(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},YV=e=>t=>e(t),XV=()=>({state:e,dispatch:t})=>II(e,t),ZV=(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},QV=()=>({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 $V(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 eH=e=>({tr:t,state:n,dispatch:r})=>{let i=$V(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},tH=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},nH=e=>e.content?/^text(\*|\+)/.test(e.content):!1,rH=(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 nH(r)?n===`left`?e.start()-1:e.end()+1:e.pos},iH=(e,t,n)=>({from:rH(e,n,`left`),to:rH(t,n,`right`)}),aH=()=>({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}=iH(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},oH=()=>({commands:e})=>e.keyboardShortcut(`Enter`),sH=()=>({state:e,dispatch:t})=>FI(e,t);function cH(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function lH(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:cH(t[r])?t[r].test(e[r]):t[r]===e[r])}function uH(e,t,n={}){return e.find(e=>e.type===t&&lH(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function dH(e,t,n={}){return!!uH(e,t,n)}function fH(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(!uH([...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&&dH([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&dH([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function pH(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 mH=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=pH(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=fH(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},hH=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 gH(e){return e instanceof Y}function _H(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function vH(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,_H(0,i,a),_H(e.content.size,i,a)):Y.create(e,_H(t,i,a),_H(t,i,a))}function yH(){return[`Android`].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function bH(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function xH(){return typeof navigator<`u`&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var SH=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(bH()||yH())&&r.dom.focus(),xH()&&!bH()&&!yH()&&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&&!gH(n.state.selection))return o(),!0;let s=vH(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},CH=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),wH=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),TH=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&&TH(r)}return e};function EH(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 TH(n)}function DH(e){return typeof e?.nodesBetween==`function`}function OH(e,t,n){if(DH(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),OH(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new lP({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?pP.fromSchema(a).parseSlice(EH(e),n.parseOptions):pP.fromSchema(a).parse(EH(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=pP.fromSchema(t);return n.slice?r.parseSlice(EH(e),n.parseOptions).content:r.parse(EH(e),n.parseOptions)}return OH(``,t,n)}function kH(e){return!(`type`in e)}function AH(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof eF||i instanceof tF))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 jH=(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{OH(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=OH(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=kH(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(``):DH(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&&AH(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 MH(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 NH=(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=MH(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=OH(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&AH(t,t.steps.length-1,-1)),!0):!1},PH=()=>({state:e,dispatch:t})=>AI(e,t),FH=()=>({state:e,dispatch:t})=>jI(e,t),IH=()=>({state:e,dispatch:t})=>yI(e,t),LH=()=>({state:e,dispatch:t})=>DI(e,t),RH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=wF(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},zH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=wF(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},BH=()=>({state:e,dispatch:t})=>bI(e,t),VH=()=>({state:e,dispatch:t})=>xI(e,t);function HH(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function UH(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))bH()||HH()?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 WH=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=UH(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 GH(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?$V(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=>lH(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var KH=(e,t={})=>({state:n,dispatch:r})=>GH(n,$V(e,n.schema),t)?MI(n,r):!1,qH=()=>({state:e,dispatch:t})=>LI(e,t),JH=e=>({state:t,dispatch:n})=>rL($V(e,t.schema))(t,n),YH=()=>({state:e,dispatch:t})=>NI(e,t);function XH(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function ZH(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 QH=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=XH(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=$V(e,r.schema)),s===`mark`&&(o=pH(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,ZH(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(ZH(a.attrs,t))))})})}),c},$H=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),eU=()=>({tr:e,dispatch:t})=>{if(t){let t=new $F(e.doc);e.setSelection(t)}return!0},tU=()=>({state:e,dispatch:t})=>wI(e,t),nU=()=>({state:e,dispatch:t})=>OI(e,t),rU=()=>({state:e,dispatch:t})=>BI(e,t),iU=()=>({state:e,dispatch:t})=>KI(e,t),aU=()=>({state:e,dispatch:t})=>GI(e,t);function oU(e,t,n={},r={}){return OH(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var sU=(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=oU(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=kH(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 cU(e,t){let n=pH(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 lU(e,t){let n=new KF(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function uU(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function dU(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 fU(e){return t=>dU(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 pU(e){return e.map(e=>{let t=Z(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...pU(t())]:e}).flat(10)}function mU(e,t){let n=DP.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function hU(e){return typeof e==`function`}function gU(e,t=void 0,...n){return hU(e)?t?e.bind(t)(...n):e(...n):e}function _U(e={}){return Object.keys(e).length===0&&e.constructor===Object}function vU(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function yU(e){let t=[],{nodeExtensions:n,markExtensions:r}=vU(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 bU(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 xU(e){let t=[],n=bU(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 SU(...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([...xU(n[e]),...xU(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function CU(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)=>SU(e,t),{})}function wU(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function TU(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):wU(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function EU(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&_U(t)?!1:t!=null))}function DU(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 OU(e,t){let n=yU(e),{nodeExtensions:r,markExtensions:i}=vU(e);return new lP({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=EU({...e.reduce((e,t)=>{let n=Z(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:gU(Z(r,`content`,a)),marks:gU(Z(r,`marks`,a)),group:gU(Z(r,`group`,a)),inline:gU(Z(r,`inline`,a)),atom:gU(Z(r,`atom`,a)),selectable:gU(Z(r,`selectable`,a)),draggable:gU(Z(r,`draggable`,a)),code:gU(Z(r,`code`,a)),whitespace:gU(Z(r,`whitespace`,a)),linebreakReplacement:gU(Z(r,`linebreakReplacement`,a)),defining:gU(Z(r,`defining`,a)),isolating:gU(Z(r,`isolating`,a)),attrs:Object.fromEntries(i.map(DU))}),s=gU(Z(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>TU(e,i)));let c=Z(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:CU(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=EU({...e.reduce((e,t)=>{let n=Z(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:gU(Z(r,`inclusive`,a)),excludes:gU(Z(r,`excludes`,a)),group:gU(Z(r,`group`,a)),spanning:gU(Z(r,`spanning`,a)),code:gU(Z(r,`code`,a)),attrs:Object.fromEntries(i.map(DU))}),s=gU(Z(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>TU(e,i)));let c=Z(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:CU(e,i)})),[r.name,o]}))})}function kU(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function AU(e){return e.sort((e,t)=>{let n=Z(e,`priority`)||100,r=Z(t,`priority`)||100;return n>r?-1:+(n<r)})}function jU(e){let t=AU(pU(e)),n=kU(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 MU(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
|
|
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 NU(e,t){return MU(e,{from:0,to:e.content.size},t)}function PU(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function FU(e,t){let n=$V(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 IU(e,t){let n=XH(typeof t==`string`?t:t.name,e.schema);return n===`node`?FU(e,t):n===`mark`?cU(e,t):{}}function LU(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 RU(e){let t=LU(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 zU(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}})})}),RU(r)}function BU(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=fH(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 VU=(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]},HU=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 UU(e,t){return t.nodes[e]||t.marks[e]||null}function WU(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 GU=(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 KU(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?pH(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>lH(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=>lH(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 qU(e,t,n={}){if(!t)return GH(e,null,n)||KU(e,null,n);let r=XH(t,e.schema);return r===`node`?GH(e,t,n):r===`mark`&&KU(e,t,n)}var JU=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=fU(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)},YU=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function XU(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function ZU(e,t){let{nodeExtensions:n}=vU(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=gU(Z(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function QU(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&&(QU(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function $U(e){return e instanceof X}var eW=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function tW(e,t){let n=t.mapping.mapResult(e.position);return{position:new eW(n.pos),mapResult:n}}function nW(e){return new eW(e)}function rW(e,t,n){let{selection:r}=t,i=null;if(gH(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 iW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=pH(e,r.schema);if(i)if(o){let e=cU(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 rW(r,n,c)},aW=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),oW=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=$V(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>JI(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>JI(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},sW=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=_H(e,0,n.content.size),i=X.create(n,r);t.setSelection(i)}return!0},cW=(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},lW=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=_H(r,a,o),c=_H(i,a,o),l=Y.create(n,s,c);t.setSelection(l)}return!0},uW=e=>({state:t,dispatch:n})=>oL($V(e,t.schema))(t,n);function dW(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 fW=({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=WU(l,s.node().type.name,s.node().attrs);if(a instanceof X&&a.node.isBlock)return!s.parentOffset||!yF(o,s.pos)?!1:(r&&(e&&dW(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:MH(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=yF(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&yF(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&&dW(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},pW=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=$V(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={...WU(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={...WU(d,u.type.name,u.attrs),...t},m={...WU(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(!yF(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 mW(e){return!e||e===`1`?null:e}function hW(e,t){return mW(e)===mW(t)}var gW=(e,t)=>{let n=fU(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&&xF(e.doc,n.pos))||!hW(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},_W=(e,t)=>{let n=fU(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&&xF(e.doc,r))||!hW(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function vW(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 yW=(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=$V(e,o.schema),m=$V(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=fU(e=>ZU(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&&ZU(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=vW(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(ZU(E.node.type.name,d)&&p.validContent(E.node.content))return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>gW(a,p)).command(()=>_W(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>gW(a,p)).command(()=>_W(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(()=>gW(a,p)).command(()=>_W(a,p)).run()},bW=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=pH(e,r.schema);return KU(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},xW=(e,t,n={})=>({state:r,commands:i})=>{let a=$V(e,r.schema),o=$V(t,r.schema),s=GH(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})},SW=(e,t={})=>({state:n,commands:r})=>{let i=$V(e,n.schema);return GH(n,i,t)?r.lift(i):r.wrapIn(i,t)},CW=()=>({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},wW=(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},TW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=pH(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=fH(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},EW=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},DW=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=XH(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=$V(e,r.schema)),s===`mark`&&(o=pH(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},OW=new gI(`__tiptap_decorations__`),kW=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(OW,{type:`force`,name:e}),!0),AW=(e,t={})=>({state:n,dispatch:r})=>qI($V(e,n.schema),t)(n,r),jW=(e,t={})=>({state:n,dispatch:r})=>eL($V(e,n.schema),t)(n,r),MW=lN({blur:()=>KV,clearContent:()=>qV,clearNodes:()=>JV,command:()=>YV,createParagraphNear:()=>XV,cut:()=>ZV,deleteCurrentNode:()=>QV,deleteNode:()=>eH,deleteRange:()=>tH,deleteSelection:()=>aH,enter:()=>oH,exitCode:()=>sH,extendMarkRange:()=>mH,first:()=>hH,focus:()=>SH,forEach:()=>CH,insertContent:()=>wH,insertContentAt:()=>jH,insertDefaultBlock:()=>NH,joinBackward:()=>IH,joinDown:()=>FH,joinForward:()=>LH,joinItemBackward:()=>RH,joinItemForward:()=>zH,joinTextblockBackward:()=>BH,joinTextblockForward:()=>VH,joinUp:()=>PH,keyboardShortcut:()=>WH,lift:()=>KH,liftEmptyBlock:()=>qH,liftListItem:()=>JH,newlineInCode:()=>YH,resetAttributes:()=>QH,scrollIntoView:()=>$H,selectAll:()=>eU,selectNodeBackward:()=>tU,selectNodeForward:()=>nU,selectParentNode:()=>rU,selectTextblockEnd:()=>iU,selectTextblockStart:()=>aU,setContent:()=>sU,setMark:()=>iW,setMeta:()=>aW,setNode:()=>oW,setNodeSelection:()=>sW,setTextDirection:()=>cW,setTextSelection:()=>lW,sinkListItem:()=>uW,splitBlock:()=>fW,splitListItem:()=>pW,toggleList:()=>yW,toggleMark:()=>bW,toggleNode:()=>xW,toggleWrap:()=>SW,undoInputRule:()=>CW,unsetAllMarks:()=>wW,unsetMark:()=>TW,unsetTextDirection:()=>EW,updateAttributes:()=>DW,updateDecorations:()=>kW,wrapIn:()=>AW,wrapInList:()=>jW}),NW=new WeakMap;function PW(e,t){NW.set(e,(NW.get(e)??0)+1);try{return t()}finally{let t=(NW.get(e)??1)-1;t>0?NW.set(e,t):NW.delete(e)}}function FW(e){return NW.has(e)}var IW=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={}}},LW=typeof process<`u`&&!1;function RW(e){return e.kind===`widget`}function zW(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&RW(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function BW(e,t,n){let{decorations:r,widgetKeys:i}=zW(t,n);return{set:UB.create(e,r),widgetKeys:i}}function VW({position:e,from:t,to:n,docSize:r}){return e<t?!1:e<n||e===n&&n===r}function HW({decorations:e,from:t,to:n,docSize:r,extensionName:i,warnedExtensions:a}){return e.filter(e=>VW({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 UW(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function WW(e){let t=new Map,n=new Map;for(let r of e.find()){let e=UW(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 GW(e){return e.jsonID===`attr`}function KW(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||GW(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function qW(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 JW(e,t){if(e.steps.some(e=>!KW(e)))return{type:`full`};let n=zU(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!GW(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=qW(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 YW(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function XW(e,t,n){let r=t.decorationSetsByExtension[e]??UB.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:YW(r,n.mapping,n.doc,i),widgetKeys:i}}function ZW(e,t){let n=Object.values(t).flatMap(e=>e.find());return UB.create(e,n)}function QW(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function $W(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 eG(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var tG=new Set,nG=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=OW.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>$W(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 OW.getState(this.editor.state)?.widgetKeys??tG}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 pI({key:OW,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:QW(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(OW),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return PW(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!eG(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=XW(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:QW(u)}}},props:{decorations(e){return OW.getState(e)?.mergedDecorationSet??UB.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=JW(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]??UB.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=YW(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=>VW({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=UW(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=zW(HW({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 BW(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(!LW)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=WW(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]]:ZW(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):ZW(n.doc,r)}};function rG(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 iG(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 aG(e){return typeof e==`number`}function oG(e){return Object.prototype.toString.call(e).slice(8,-1)}function sG(e){return oG(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function cG(e,t,n){let r=e.split(`
|
|
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
|
+
`);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 lG(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
|
+
`).map(e=>e?t.indent(e):t.indent(``)).join(`
|
|
198
|
+
`);s+=e.type===`paragraph`?`\n\n${n}`:`\n${n}`}}),s}function uG(e,t){let n={...e};return sG(e)&&sG(t)&&Object.keys(t).forEach(r=>{sG(t[r])&&sG(e[r])?n[r]=uG(e[r],t[r]):n[r]=t[r]}),n}function dG(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var fG=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},pG=(e,t)=>{if(cH(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function mG(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=GU(c)+i;return a.forEach(e=>{if(l)return;let a=pG(u,e.find);if(!a)return;let d=a[0].length-i.length;if(d>0){let e=c.parentOffset-d;if(e<0||c.parent.textBetween(e,c.parentOffset)!==a[0].slice(0,d))return}let f=s.state.tr,p=WV({state:s.state,transaction:f}),m={from:n-(a[0].length-i.length),to:r},{commands:h,chain:g,can:_}=new GV({editor:t,state:p});e.handler({state:p,range:m,match:a,commands:h,chain:g,can:_})===null||!f.steps.length||(e.undoable&&f.setMeta(o,{transform:f,from:n,to:r,text:i}),s.dispatch(f),l=!0)}),l}function hG(e){let{editor:t,rules:n}=e,r=new pI({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:mU(K.from(e),a.schema);let{from:i}=s,o=i+e.length;mG({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return mG({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&mG({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?mG({editor:t,from:a.pos,to:a.pos,text:`
|
|
199
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var gG=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...gU(Z(this,`addOptions`,{name:this.name}))}}get storage(){return{...gU(Z(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>uG(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},_G=class e extends gG{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},vG=class{constructor(e){this.find=e.find,this.handler=e.handler}},yG=(e,t,n)=>{if(cH(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function bG(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new GV({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if(!((f=e.type)==null||(f=f.spec)==null)&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||yG(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var xG=null,SG=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function CG(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr,l=WV({state:e,transaction:c});if(!(!bG({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new pI({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(xG=t)},i=()=>{xG&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=xG;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:mU(K.from(t),r.schema);let{from:n}=d,i=n+t.length,a=SG(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!aG(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var wG=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=jU(e),this.schema=OU(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=Z(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:UU(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=AU([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:UU(t.name,this.schema)},r=[],i=Z(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&Z(t,`exitable`,n)&&(a.ArrowRight=()=>_G.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=HV(a);r.push(o);let s=Z(t,`addInputRules`,n);if(XU(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=hG({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=Z(t,`addPasteRules`,n);if(XU(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=CG({editor:e,rules:t});r.push(...n)}}let l=Z(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)==null||e.destroy();let n=[];return this.extensions.forEach(e=>{let r=Z(e,`addDecorations`,{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:UU(e.name,this.schema)});r&&n.push({name:e.name,addDecorations:r})}),this.decorationManager=new nG({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){return yU(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=vU(this.extensions);return Object.fromEntries(t.filter(e=>!!Z(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=Z(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:$V(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>{let l=CU(r,n);return i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return AU([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:UU(n.name,this.schema)},i=Z(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return AU([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:UU(n.name,this.schema)},i=Z(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=vU(this.extensions);return Object.fromEntries(t.filter(e=>!!Z(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=Z(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:pH(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=CU(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{dG(i,e,t)}})}]:[]}))}destroy(){var e;(e=this.decorationManager)==null||e.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:UU(e.name,this.schema)};e.type===`mark`&&((gU(Z(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(gU(Z(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=Z(e,`onBeforeCreate`,t),r=Z(e,`onCreate`,t),i=Z(e,`onUpdate`,t),a=Z(e,`onSelectionUpdate`,t),o=Z(e,`onTransaction`,t),s=Z(e,`onFocus`,t),c=Z(e,`onBlur`,t),l=Z(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};wG.resolve=jU,wG.sort=AU,wG.flatten=pU;var TG=class e extends gG{constructor(...e){super(...e),this.type=`extension`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},EG=TG.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new pI({key:new gI(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=PU(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>MU(r,{from:e.pos,to:t.pos},s)).join(o??`
|
|
200
|
+
|
|
201
|
+
`)}}})]}}),DG=TG.create({name:`commands`,addCommands(){return{...MW}}}),OG=TG.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=lU(e.before,[e,...t]);zU(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof ZP){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),kG=TG.create({name:`drop`,addProseMirrorPlugins(){return[new pI({key:new gI(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),AG=TG.create({name:`editable`,addProseMirrorPlugins(){return[new pI({key:new gI(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),jG=new gI(`focusEvents`),MG=TG.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new pI({key:jG,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),NG=TG.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:J.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return bH()||HH()?i:r},addProseMirrorPlugins(){return[new pI({key:new gI(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=J.atStart(t.doc).from,l=J.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!QU(n.doc))return;let u=n.tr,d=WV({state:n,transaction:u}),{commands:f}=new GV({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),PG=TG.create({name:`paste`,addProseMirrorPlugins(){return[new pI({key:new gI(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),FG=TG.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new pI({key:new gI(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),IG=TG.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=vU(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new pI({key:new gI(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),LG=!1;function RG(e){if(LG)return;LG=!0;let t;try{t=eF.fromJSON(e,{from:0,to:0}).slice.content}catch{return}t instanceof K||console.warn(`[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.`)}var zG=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||this.children.length===0)return r;let i=Object.keys(t);return this.children.forEach(a=>{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},BG=`.ProseMirror {
|
|
202
|
+
position: relative;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.ProseMirror {
|
|
206
|
+
word-wrap: break-word;
|
|
207
|
+
white-space: pre-wrap;
|
|
208
|
+
white-space: break-spaces;
|
|
209
|
+
-webkit-font-variant-ligatures: none;
|
|
210
|
+
font-variant-ligatures: none;
|
|
211
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.ProseMirror [contenteditable="false"] {
|
|
215
|
+
white-space: normal;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
219
|
+
white-space: pre-wrap;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.ProseMirror pre {
|
|
223
|
+
white-space: pre-wrap;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
img.ProseMirror-separator {
|
|
227
|
+
display: inline !important;
|
|
228
|
+
border: none !important;
|
|
229
|
+
margin: 0 !important;
|
|
230
|
+
width: 0 !important;
|
|
231
|
+
height: 0 !important;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.ProseMirror-gapcursor {
|
|
235
|
+
display: none;
|
|
236
|
+
pointer-events: none;
|
|
237
|
+
position: absolute;
|
|
238
|
+
margin: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.ProseMirror-gapcursor:after {
|
|
242
|
+
content: "";
|
|
243
|
+
display: block;
|
|
244
|
+
position: absolute;
|
|
245
|
+
top: -2px;
|
|
246
|
+
width: 20px;
|
|
247
|
+
border-top: 1px solid black;
|
|
248
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@keyframes ProseMirror-cursor-blink {
|
|
252
|
+
to {
|
|
253
|
+
visibility: hidden;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.ProseMirror-hideselection *::selection {
|
|
258
|
+
background: transparent;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
262
|
+
background: transparent;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.ProseMirror-hideselection * {
|
|
266
|
+
caret-color: transparent;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
270
|
+
display: block;
|
|
271
|
+
}`,VG=class extends IW{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:tW,createMappablePosition:nW},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=vH(t,this.options.autofocus);this.editorState=dI.create({doc:t,schema:this.schema,selection:e||void 0})}RG(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():GV.createFakeChain()}can(){return this.commandManager?this.commandManager.can():GV.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=iG(BG,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return LW&&!this.hasWarnedStaleDecorationRead&&FW(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=hU(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[AG,EG.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),DG,MG,NG,FG.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),kG,PG,OG,IG.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new wG(n,this)}createCommandManager(){this.commandManager=new GV({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=oU(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=oU(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=dI.create({doc:t,schema:this.schema,selection:vH(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new SV(e,{...t,attributes:{role:`textbox`,...t?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),!(e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc))&&this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return IU(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return qU(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return mU(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
272
|
+
|
|
273
|
+
`,textSerializers:n={}}=e||{};return NU(this.state.doc,{blockSeparator:t,textSerializers:{...PU(this.schema),...n}})}get isEmpty(){return QU(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new zG(t,this,!1,n)}get $doc(){return this.$pos(0)}};function HG(e){return new fG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=gU(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(BU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function UG(e){return new fG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=gU(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function WG(e){return new fG({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=gU(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function GG(e){return new fG({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=gU(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&lF(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&xF(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var KG=class e extends gG{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function qG(e){return new vG({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=gU(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(BU(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var{getOwnPropertyNames:JG,getOwnPropertySymbols:YG}=Object,{hasOwnProperty:XG}=Object.prototype;function ZG(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function QG(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function $G(e){return e?.[Symbol.toStringTag]}function eK(e){return JG(e).concat(YG(e))}var tK=Object.hasOwn||((e,t)=>XG.call(e,t));function nK(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var rK=`__v`,iK=`__o`,aK=`_owner`,{getOwnPropertyDescriptor:oK,keys:sK}=Object;function cK(e,t){return e.byteLength===t.byteLength&&xK(new Uint8Array(e),new Uint8Array(t))}function lK(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-->0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function uK(e,t){return e.byteLength===t.byteLength&&xK(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function dK(e,t){return nK(e.getTime(),t.getTime())}function fK(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function pK(e,t){return e===t}function mK(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var hK=nK;function gK(e,t,n){let r=sK(e),i=r.length;if(sK(t).length!==i)return!1;for(;i-->0;)if(!CK(e,t,n,r[i]))return!1;return!0}function _K(e,t,n){let r=eK(e),i=r.length;if(eK(t).length!==i)return!1;let a,o,s;for(;i-->0;)if(a=r[i],!CK(e,t,n,a)||(o=oK(e,a),s=oK(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function vK(e,t){return nK(e.valueOf(),t.valueOf())}function yK(e,t){return e.source===t.source&&e.flags===t.flags}function bK(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function xK(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-->0;)if(e[n]!==t[n])return!1;return!0}function SK(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function CK(e,t,n,r){return(r===aK||r===iK||r===rK)&&(e.$$typeof||t.$$typeof)?!0:tK(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var wK=`[object ArrayBuffer]`,TK=`[object Arguments]`,EK=`[object Boolean]`,DK=`[object DataView]`,OK=`[object Date]`,kK=`[object Error]`,AK=`[object Map]`,jK=`[object Number]`,MK=`[object Object]`,NK=`[object RegExp]`,PK=`[object Set]`,FK=`[object String]`,IK={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},LK=`[object URL]`,RK=Object.prototype.toString;function zK({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`&&a(h,g,_);let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=RK.call(h);if(b===OK)return r(h,g,_);if(b===NK)return u(h,g,_);if(b===AK)return o(h,g,_);if(b===PK)return d(h,g,_);if(b===MK)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===LK)return p(h,g,_);if(b===kK)return i(h,g,_);if(b===TK)return c(h,g,_);if(IK[b])return f(h,g,_);if(b===wK)return e(h,g,_);if(b===DK)return n(h,g,_);if(b===EK||b===jK||b===FK)return l(h,g,_);if(m){let e=m[b];if(!e){let t=$G(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function BK({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:cK,areArraysEqual:n?_K:lK,areDataViewsEqual:uK,areDatesEqual:dK,areErrorsEqual:fK,areFunctionsEqual:pK,areMapsEqual:n?ZG(mK,_K):mK,areNumbersEqual:hK,areObjectsEqual:n?_K:gK,arePrimitiveWrappersEqual:vK,areRegExpsEqual:yK,areSetsEqual:n?ZG(bK,_K):bK,areTypedArraysEqual:n?ZG(xK,_K):xK,areUrlsEqual:SK,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=QG(r.areArraysEqual),t=QG(r.areMapsEqual),n=QG(r.areObjectsEqual),i=QG(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function VK(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function HK({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var UK=WK();WK({strict:!0}),WK({circular:!0}),WK({circular:!0,strict:!0}),WK({createInternalComparator:()=>nK}),WK({strict:!0,createInternalComparator:()=>nK}),WK({circular:!0,createInternalComparator:()=>nK}),WK({circular:!0,createInternalComparator:()=>nK,strict:!0});function WK(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=zK(BK(e));return HK({circular:t,comparator:a,createState:r,equals:n?n(a):VK(a),strict:i})}var GK=Fn(),KK=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},qK=({contentComponent:e})=>{let t=(0,sN.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,z.jsx)(z.Fragment,{children:Object.values(t)})};function JK(){let e=new Set,t={},n=!1,r=()=>{n||!e.size||(n=!0,queueMicrotask(()=>{n=!1,e.forEach(e=>e())}))};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(e,n){t={...t,[e]:Ya.createPortal(n.reactElement,n.element,e)},r()},removeRenderer(e){let n={...t};delete n[e],t=n,r()}}}var YK=class extends R.Component{constructor(e){super(e),this.editorContentRef=R.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=JK(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{ref:KK(t,this.editorContentRef),...n}),e?.contentComponent&&(0,z.jsx)(qK,{contentComponent:e.contentComponent})]})}},XK=(0,R.forwardRef)((e,t)=>{let n=R.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return R.createElement(YK,{key:n,innerRef:t,...e})}),ZK=R.memo(XK),QK=typeof window<`u`?R.useLayoutEffect:R.useEffect,$K=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e,t=t=>{t?.transaction!==void 0&&t.transaction===e||(e=t?.transaction,this.transactionNumber+=1,this.subscribers.forEach(e=>e()))},n=this.editor;return n.on(`transaction`,t),n.on(`update`,t),()=>{n.off(`transaction`,t),n.off(`update`,t)}}}};function eq(e){let[t]=(0,R.useState)(()=>new $K(e.editor)),n=(0,GK.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??UK);return QK(()=>t.watch(e.editor),[e.editor,t]),(0,R.useDebugValue)(n),n}var tq=typeof window>`u`,nq=tq||!!(typeof window<`u`&&window.next),rq=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=e??!0;return(tq||nq&&e===void 0)&&(t=!1),t?this.createEditor():null}createEditor(){return new VG({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)},onMount:(...e)=>{var t;return(t=this.options.current).onMount?.call(t,...e)},onUnmount:(...e)=>{var t;return(t=this.options.current).onUnmount?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>e===t.extensions?.[n]):e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function iq(e={},t=[]){let n=(0,R.useRef)(e);n.current=e;let[r]=(0,R.useState)(()=>new rq(n)),i=(0,sN.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,R.useDebugValue)(i),(0,R.useEffect)(r.onRender(t)),eq({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var aq=(0,R.createContext)({editor:null});aq.Consumer;var oq=(0,R.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),sq=()=>(0,R.useContext)(oq);R.forwardRef((e,t)=>{let{onDragStart:n}=sq();return(0,z.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),R.createContext({markViewContentRef:()=>{}});var cq=(0,R.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});cq.displayName=`TiptapContext`;var lq=()=>(0,R.useContext)(cq);function uq({children:e,...t}){let n=`editor`in t?t.editor:t.instance;if(!n)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,R.useMemo)(()=>({editor:n}),[n]),i=(0,R.useMemo)(()=>({editor:n}),[n]);return(0,z.jsx)(aq.Provider,{value:i,children:(0,z.jsx)(cq.Provider,{value:r,children:e})})}uq.displayName=`Tiptap`;function dq({...e}){let{editor:t}=lq();return(0,z.jsx)(ZK,{editor:t,...e})}dq.displayName=`Tiptap.Content`,Object.assign(uq,{Content:dq});var fq=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,pq=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,mq=`numeric`,hq=`ascii`,gq=`alpha`,_q=`asciinumeric`,vq=`alphanumeric`,yq=`domain`,bq=`emoji`,xq=`scheme`,Sq=`slashscheme`,Cq=`whitespace`;function wq(e,t){return e in t||(t[e]=[]),t[e]}function Tq(e,t,n){t[mq]&&(t[_q]=!0,t[vq]=!0),t[hq]&&(t[_q]=!0,t[gq]=!0),t[_q]&&(t[vq]=!0),t[gq]&&(t[vq]=!0),t[vq]&&(t[yq]=!0),t[bq]&&(t[yq]=!0);for(let r in t){let t=wq(r,n);t.indexOf(e)<0&&t.push(e)}}function Eq(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function Dq(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Dq.groups={},Dq.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=Dq.groups;let i;return t&&t.j?i=t:(i=new Dq(t),n&&r&&Tq(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=Dq.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new Dq,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new Dq,a&&(r&&(o.t&&typeof o.t==`string`?Tq(a,Object.assign(Eq(o.t,r),n),r):n&&Tq(a,n,r)),o.t=a),i.j[e]=o,o}};var Q=(e,t,n,r,i)=>e.ta(t,n,r,i),Oq=(e,t,n,r,i)=>e.tr(t,n,r,i),kq=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),Aq=`WORD`,jq=`UWORD`,Mq=`ASCIINUMERICAL`,Nq=`ALPHANUMERICAL`,Pq=`LOCALHOST`,Fq=`TLD`,Iq=`UTLD`,Lq=`SCHEME`,Rq=`SLASH_SCHEME`,zq=`NUM`,Bq=`WS`,Vq=`NL`,Hq=`OPENBRACE`,Uq=`CLOSEBRACE`,Wq=`OPENBRACKET`,Gq=`CLOSEBRACKET`,Kq=`OPENPAREN`,qq=`CLOSEPAREN`,Jq=`OPENANGLEBRACKET`,Yq=`CLOSEANGLEBRACKET`,Xq=`FULLWIDTHLEFTPAREN`,Zq=`FULLWIDTHRIGHTPAREN`,Qq=`LEFTCORNERBRACKET`,$q=`RIGHTCORNERBRACKET`,eJ=`LEFTWHITECORNERBRACKET`,tJ=`RIGHTWHITECORNERBRACKET`,nJ=`FULLWIDTHLESSTHAN`,rJ=`FULLWIDTHGREATERTHAN`,iJ=`AMPERSAND`,aJ=`APOSTROPHE`,oJ=`ASTERISK`,sJ=`AT`,cJ=`BACKSLASH`,lJ=`BACKTICK`,uJ=`CARET`,dJ=`COLON`,fJ=`COMMA`,pJ=`DOLLAR`,mJ=`DOT`,hJ=`EQUALS`,gJ=`EXCLAMATION`,_J=`HYPHEN`,vJ=`PERCENT`,yJ=`PIPE`,bJ=`PLUS`,xJ=`POUND`,SJ=`QUERY`,CJ=`QUOTE`,wJ=`FULLWIDTHMIDDLEDOT`,TJ=`SEMI`,EJ=`SLASH`,DJ=`TILDE`,OJ=`UNDERSCORE`,kJ=`EMOJI`,AJ=`SYM`,jJ=Object.freeze({__proto__:null,ALPHANUMERICAL:Nq,AMPERSAND:iJ,APOSTROPHE:aJ,ASCIINUMERICAL:Mq,ASTERISK:oJ,AT:sJ,BACKSLASH:cJ,BACKTICK:lJ,CARET:uJ,CLOSEANGLEBRACKET:Yq,CLOSEBRACE:Uq,CLOSEBRACKET:Gq,CLOSEPAREN:qq,COLON:dJ,COMMA:fJ,DOLLAR:pJ,DOT:mJ,EMOJI:kJ,EQUALS:hJ,EXCLAMATION:gJ,FULLWIDTHGREATERTHAN:rJ,FULLWIDTHLEFTPAREN:Xq,FULLWIDTHLESSTHAN:nJ,FULLWIDTHMIDDLEDOT:wJ,FULLWIDTHRIGHTPAREN:Zq,HYPHEN:_J,LEFTCORNERBRACKET:Qq,LEFTWHITECORNERBRACKET:eJ,LOCALHOST:Pq,NL:Vq,NUM:zq,OPENANGLEBRACKET:Jq,OPENBRACE:Hq,OPENBRACKET:Wq,OPENPAREN:Kq,PERCENT:vJ,PIPE:yJ,PLUS:bJ,POUND:xJ,QUERY:SJ,QUOTE:CJ,RIGHTCORNERBRACKET:$q,RIGHTWHITECORNERBRACKET:tJ,SCHEME:Lq,SEMI:TJ,SLASH:EJ,SLASH_SCHEME:Rq,SYM:AJ,TILDE:DJ,TLD:Fq,UNDERSCORE:OJ,UTLD:Iq,UWORD:jq,WORD:Aq,WS:Bq}),MJ=/[a-z]/,NJ=/\p{L}/u,PJ=/\p{Emoji}/u,FJ=/\d/,IJ=/\s/,LJ=`\r`,RJ=`
|
|
274
|
+
`,zJ=`️`,BJ=``,VJ=``,HJ=null,UJ=null;function WJ(e=[]){let t={};Dq.groups=t;let n=new Dq;HJ??=JJ(fq),UJ??=JJ(pq),$(n,`'`,aJ),$(n,`{`,Hq),$(n,`}`,Uq),$(n,`[`,Wq),$(n,`]`,Gq),$(n,`(`,Kq),$(n,`)`,qq),$(n,`<`,Jq),$(n,`>`,Yq),$(n,`(`,Xq),$(n,`)`,Zq),$(n,`「`,Qq),$(n,`」`,$q),$(n,`『`,eJ),$(n,`』`,tJ),$(n,`<`,nJ),$(n,`>`,rJ),$(n,`&`,iJ),$(n,`*`,oJ),$(n,`@`,sJ),$(n,"`",lJ),$(n,`^`,uJ),$(n,`:`,dJ),$(n,`,`,fJ),$(n,`$`,pJ),$(n,`.`,mJ),$(n,`=`,hJ),$(n,`!`,gJ),$(n,`-`,_J),$(n,`%`,vJ),$(n,`|`,yJ),$(n,`+`,bJ),$(n,`#`,xJ),$(n,`?`,SJ),$(n,`"`,CJ),$(n,`/`,EJ),$(n,`;`,TJ),$(n,`~`,DJ),$(n,`_`,OJ),$(n,`\\`,cJ),$(n,`・`,wJ);let r=Oq(n,FJ,zq,{[mq]:!0});Oq(r,FJ,r);let i=Oq(r,MJ,Mq,{[_q]:!0}),a=Oq(r,NJ,Nq,{[vq]:!0}),o=Oq(n,MJ,Aq,{[hq]:!0});Oq(o,FJ,i),Oq(o,MJ,o),Oq(i,FJ,i),Oq(i,MJ,i);let s=Oq(n,NJ,jq,{[gq]:!0});Oq(s,MJ),Oq(s,FJ,a),Oq(s,NJ,s),Oq(a,FJ,a),Oq(a,MJ),Oq(a,NJ,a);let c=$(n,RJ,Vq,{[Cq]:!0}),l=$(n,LJ,Bq,{[Cq]:!0}),u=Oq(n,IJ,Bq,{[Cq]:!0});$(n,VJ,u),$(l,RJ,c),$(l,VJ,u),Oq(l,IJ,u),$(u,LJ),$(u,RJ),Oq(u,IJ,u),$(u,VJ,u);let d=Oq(n,PJ,kJ,{[bq]:!0});$(d,`#`),Oq(d,PJ,d),$(d,zJ,d);let f=$(d,BJ);$(f,`#`),Oq(f,PJ,d);let p=[[MJ,o],[FJ,i]],m=[[MJ,null],[NJ,s],[FJ,a]];for(let e=0;e<HJ.length;e++)qJ(n,HJ[e],Fq,Aq,p);for(let e=0;e<UJ.length;e++)qJ(n,UJ[e],Iq,jq,m);Tq(Fq,{tld:!0,ascii:!0},t),Tq(Iq,{utld:!0,alpha:!0},t),qJ(n,`file`,Lq,Aq,p),qJ(n,`mailto`,Lq,Aq,p),qJ(n,`http`,Rq,Aq,p),qJ(n,`https`,Rq,Aq,p),qJ(n,`ftp`,Rq,Aq,p),qJ(n,`ftps`,Rq,Aq,p),Tq(Lq,{scheme:!0,ascii:!0},t),Tq(Rq,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[xq]:!0}:{[Sq]:!0};r.indexOf(`-`)>=0?i[yq]=!0:MJ.test(r)?FJ.test(r)?i[_q]=!0:i[hq]=!0:i[mq]=!0,kq(n,r,r,i)}return kq(n,`localhost`,Pq,{ascii:!0}),n.jd=new Dq(AJ),{start:n,tokens:Object.assign({groups:t},jJ)}}function GJ(e,t){let n=KJ(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function KJ(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function qJ(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new Dq(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new Dq(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function JJ(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var YJ={defaultProtocol:`http`,events:null,format:ZJ,formatHref:ZJ,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function XJ(e,t=null){let n=Object.assign({},YJ);e&&(n=Object.assign(n,e instanceof XJ?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}XJ.prototype={o:YJ,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:YJ[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function ZJ(e){return e}function QJ(e,t){this.t=`token`,this.v=e,this.tk=t}QJ.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=YJ.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function $J(e,t){class n extends QJ{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var eY=$J(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),tY=$J(`text`),nY=$J(`nl`),rY=$J(`url`,{isLink:!0,toHref(e=YJ.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==Pq&&e[1].t===dJ}}),iY=e=>new Dq(e);function aY({groups:e}){let t=e.domain.concat([iJ,oJ,sJ,cJ,lJ,uJ,pJ,hJ,_J,zq,vJ,yJ,bJ,xJ,EJ,AJ,DJ,OJ]),n=[aJ,dJ,fJ,mJ,gJ,vJ,SJ,CJ,TJ,Jq,Yq,Hq,Uq,Gq,Wq,Kq,qq,Xq,Zq,Qq,$q,eJ,tJ,nJ,rJ],r=[iJ,aJ,oJ,cJ,lJ,uJ,pJ,hJ,_J,Hq,Uq,vJ,yJ,bJ,xJ,SJ,EJ,AJ,DJ,OJ],i=iY(),a=$(i,DJ);Q(a,r,a),Q(a,e.domain,a);let o=iY(),s=iY(),c=iY();Q(i,e.domain,o),Q(i,e.scheme,s),Q(i,e.slashscheme,c),Q(o,r,a),Q(o,e.domain,o);let l=$(o,sJ);$(a,sJ,l),$(s,sJ,l),$(c,sJ,l);let u=$(a,mJ);Q(u,r,a),Q(u,e.domain,a);let d=iY();Q(l,e.domain,d),Q(d,e.domain,d);let f=$(d,mJ);Q(f,e.domain,d);let p=iY(eY);Q(f,e.tld,p),Q(f,e.utld,p),$(l,Pq,p);let m=$(d,_J);$(m,_J,m),Q(m,e.domain,d),Q(p,e.domain,d),$(p,mJ,f),$(p,_J,m);let h=$(o,_J),g=$(o,mJ);$(h,_J,h),Q(h,e.domain,o),Q(g,r,a),Q(g,e.domain,o);let _=iY(rY);Q(g,e.tld,_),Q(g,e.utld,_),Q(_,e.domain,o),Q(_,r,a),$(_,mJ,g),$(_,_J,h),$(_,sJ,l);let v=$(_,dJ),y=iY(rY);Q(v,e.numeric,y);let b=iY(rY),x=iY();Q(b,t,b),Q(b,n,x),Q(x,t,b),Q(x,n,x),$(_,EJ,b),$(y,EJ,b);let S=$(s,dJ),C=$($($(c,dJ),EJ),EJ);Q(s,e.domain,o),$(s,mJ,g),$(s,_J,h),Q(c,e.domain,o),$(c,mJ,g),$(c,_J,h),Q(S,e.domain,b),$(S,EJ,b),$(S,SJ,b),Q(C,e.domain,b),Q(C,t,b),$(C,EJ,b);let w=[[Hq,Uq],[Wq,Gq],[Kq,qq],[Jq,Yq],[Xq,Zq],[Qq,$q],[eJ,tJ],[nJ,rJ]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=$(b,r);$(x,r,a);let o=iY(rY);Q(a,t,o);let s=iY();Q(a,n,s),$(a,i,b),Q(o,t,o),Q(o,n,s),Q(s,t,o),Q(s,n,s),$(o,i,b),$(s,i,b)}return $(i,Pq,_),$(i,Vq,nY),{start:i,tokens:jJ}}function oY(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(sY(tY,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(sY(e,t,r))}}return o.length>0&&a.push(sY(tY,t,o)),a}function sY(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var cY=typeof console<`u`&&console&&console.warn||(()=>{}),lY=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,uY={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function dY(){return Dq.groups={},uY.scanner=null,uY.parser=null,uY.tokenQueue=[],uY.pluginQueue=[],uY.customSchemes=[],uY.initialized=!1,uY}function fY(e,t=!1){if(uY.initialized&&cY(`linkifyjs: already initialized - will not register custom scheme "${e}" ${lY}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
275
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
276
|
+
2. Cannot start or end with "-"
|
|
277
|
+
3. "-" cannot repeat`);uY.customSchemes.push([e,t])}function pY(){uY.scanner=WJ(uY.customSchemes);for(let e=0;e<uY.tokenQueue.length;e++)uY.tokenQueue[e][1]({scanner:uY.scanner});uY.parser=aY(uY.scanner.tokens);for(let e=0;e<uY.pluginQueue.length;e++)uY.pluginQueue[e][1]({scanner:uY.scanner,parser:uY.parser});return uY.initialized=!0,uY}function mY(e){return uY.initialized||pY(),oY(uY.parser.start,e,GJ(uY.scanner.start,e))}mY.scan=GJ;function hY(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new XJ(n),i=mY(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var gY=`[\0- \xA0 -\u2029 ]`,_Y=new RegExp(gY),vY=RegExp(`${gY}$`),yY=new RegExp(gY,`g`);function bY(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function xY(e){return new pI({key:new gI(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(zU(lU(n.doc,[...t])).forEach(({newRange:t})=>{let n=uU(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!vY.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(_Y).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=mY(n).map(t=>t.toObject(e.defaultProtocol));if(!bY(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{BU(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function SY(e){return new pI({key:new gI(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=IU(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var CY=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,wY=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function TY(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function EY(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"){r+=1;continue}if(n===0&&TY(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function DY(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||TY(e,t.index??0)||EY(e,t.index??0)?!1:!!r.trim()&&n(i)}function OY(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function kY(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function AY(e){return{href:e.data?.href,title:e.data?.title??null}}function jY(e){let t=HG({find:t=>{let n=CY.exec(t);return!n||!DY(t,n,e.isAllowedHref)?null:OY(n)},type:e.type,getAttributes:AY});return new fG({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function MY(e){let t=qG({find:t=>{let n=[];for(let r of t.matchAll(wY))DY(t,r,e.isAllowedHref)&&n.push(OY(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>kY(t,e)));return[...n,...r]},type:e.type,getAttributes:AY});return new vG({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function NY(e){return new pI({key:new gI(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=hY(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function PY(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(yY,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var FY=_G.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){fY(e);return}fY(e.scheme,e.optionalSlashes)})},onDestroy(){dY()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!PY(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!PY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!PY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,SU(this.options.HTMLAttributes,e),0]:[`a`,SU(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!PY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!PY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[jY({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!PY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;hY(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!PY(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[MY({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!PY(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[qG({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(xY({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!PY(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(SY({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(NY({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),IY=FY;function LY(e={}){return new pI({view(t){return new RY(t,e)}})}var RY=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=DF(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},zY=class e extends J{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):J.near(r)}content(){return q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new BY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!HY(e)||!UY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!X.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};zY.prototype.visible=!1,zY.findFrom=zY.findGapCursorFrom,J.jsonID(`gapcursor`,zY);var BY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return zY.valid(t)?new zY(t):J.near(t)}};function VY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function HY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||VY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function UY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||VY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function WY(){return new pI({props:{decorations:YY,createSelectionBetween(e,t,n){return t.pos==n.pos&&zY.valid(n)?new zY(n):null},handleClick:qY,handleKeyDown:GY,handleDOMEvents:{beforeinput:JY}}})}var GY=UV({ArrowLeft:KY(`horiz`,-1),ArrowRight:KY(`horiz`,1),ArrowUp:KY(`vert`,-1),ArrowDown:KY(`vert`,1)});function KY(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Y){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=zY.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new zY(c))),!0):!1}}function qY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!zY.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&X.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new zY(r))),!0)}function JY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof zY))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=K.empty;for(let e=r.length-1;e>=0;e--)i=K.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new q(i,0,0));return a.setSelection(Y.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function YY(e){if(!(e.selection instanceof zY))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,UB.create(e.doc,[BB.widget(e.selection.head,t,{key:`gapcursor`})])}var XY=200,ZY=function(){};ZY.prototype.append=function(e){return e.length?(e=ZY.from(e),!this.length&&e||e.length<XY&&this.leafAppend(e)||this.length<XY&&e.leafPrepend(this)||this.appendInner(e)):this},ZY.prototype.prepend=function(e){return e.length?ZY.from(e).append(this):this},ZY.prototype.appendInner=function(e){return new $Y(this,e)},ZY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ZY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ZY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ZY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ZY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},ZY.from=function(e){return e instanceof ZY?e:e&&e.length?new QY(e):ZY.empty};var QY=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=XY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=XY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ZY);ZY.empty=new QY([]);var $Y=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ZY),eX=500,tX=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new rX(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new rX(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new rX(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>aX&&(s=nX(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new GP;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new rX(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new rX(i,o,l))}else r.push(new rX(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new rX(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>eX&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new rX(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(ZY.from(i.reverse()),a)}};tX.empty=new tX(ZY.empty,0);function nX(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var rX=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},iX=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},aX=20;function oX(e,t,n,r){let i=n.getMeta(mX),a;if(i)return i.historyState;n.getMeta(hX)&&(e=new iX(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(mX))return o.getMeta(mX).redo?new iX(e.done.addTransform(n,void 0,r,pX(t)),e.undone,cX(n.mapping.maps),e.prevTime,e.prevComposition):new iX(e.done,e.undone.addTransform(n,void 0,r,pX(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!sX(n,e.prevRanges)),s=o?lX(e.prevRanges,n.mapping):cX(n.mapping.maps);return new iX(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,pX(t)),tX.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new iX(e.done.rebased(n,a),e.undone.rebased(n,a),lX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new iX(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),lX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function sX(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function cX(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function lX(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function uX(e,t,n){let r=pX(t),i=mX.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new iX(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(mX,{redo:n,historyState:c})}var dX=!1,fX=null;function pX(e){let t=e.plugins;if(fX!=t){dX=!1,fX=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){dX=!0;break}}return dX}var mX=new gI(`history`),hX=new gI(`closeHistory`);function gX(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new pI({key:mX,state:{init(){return new iX(tX.empty,tX.empty,null,0,-1)},apply(t,n,r){return oX(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?vX:n==`historyRedo`?yX:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function _X(e,t){return(n,r)=>{let i=mX.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=uX(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var vX=_X(!1,!0),yX=_X(!0,!0);TG.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new pI({key:new gI(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var bX=TG.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[LY(this.options)]}});TG.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new pI({key:new gI(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return UB.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(BB.node(t,t+e.nodeSize,{class:this.options.className}))}),UB.create(e,a)}}})]}});var xX=TG.create({name:`gapCursor`,addProseMirrorPlugins(){return[WY()]},extendNodeSchema(e){return{allowGapCursor:gU(Z(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),SX=`placeholder`,CX=new gI(`tiptap__placeholder`);function wX(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),BB.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function TX(e,t){return typeof e==`function`?e(t):e}function EX({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&QU(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(wX({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:TX(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function DX({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&QU(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(wX({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:TX(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...EX({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return UB.create(r,o)}function OX(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function kX(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function AX(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function jX(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function MX(e,t){let n=AX(e,t.from,t.to);return n.push(kX(e,OX(e,t.from))),t.to>t.from?n.push(kX(e,OX(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(kX(e,OX(e,Math.min(t.from+1,e.content.size)))),n}function NX(e,t,n){let r=[];if(e.docChanged){let t=zU(e);for(let e of t)r.push(...MX(n.doc,e.newRange))}return e.selectionSet&&(r.push(kX(n.doc,OX(n.doc,e.mapping.map(t.selection.anchor)))),r.push(kX(n.doc,OX(n.doc,n.selection.anchor)))),jX(r)}function PX(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function FX({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=PX(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=EX({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function IX({editor:e,options:t,dataAttribute:n}){return{init(r,i){return DX({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??UB.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:FX({decorations:i.map(r.mapping,r.doc),ranges:NX(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function LX(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function RX({editor:e,options:t}){let n=t.dataAttribute?`data-${LX(t.dataAttribute)}`:`data-${SX}`,r=t.showOnlyCurrent&&!t.includeChildren;return new pI({key:CX,...r?{}:{state:IX({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>DX({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?UB.empty:CX.getState(n)??UB.empty}})}var zX=TG.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:SX,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[RX({editor:this.editor,options:this.options})]}});function BX(e,t){return!e.selection.empty&&!$U(e.selection)&&t.isEditable}function VX(e,t){return BX(e,t)&&!t.isFocused&&!t.view.dragging}function HX(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function UX(e){e.focus()}TG.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new pI({key:new gI(`selection`),props:{decorations(n){return VX(n,e)?UB.create(n.doc,[BB.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return BX(t.state,e)&&HX(),!1},focus(t){return BX(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&UX(t)}),!1}}}})]}});function WX({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var GX=TG.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new gI(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new pI({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!WX({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!WX({node:r,types:n})}}})]}}),KX=TG.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>vX(e,t),redo:()=>({state:e,dispatch:t})=>yX(e,t)}},addProseMirrorPlugins(){return[gX(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),qX=new WeakSet,JX=new WeakSet;function YX(e){let t=e;return qX.add(t),t}function XX(e){return Array.isArray(e)&&qX.has(e)}function ZX(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&JX.has(e)&&!XX(e)?ZX(e):[e])}function QX(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!XX(n)&&!JX.has(n)?YX(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(XX(n))return YX([e,r,n]);if(n.length===0)return YX([e,r]);let t=ZX(n);return t.length===0?YX([e,r]):YX([e,r,...t])}return YX(n==null?[e,r]:[e,r,n])}var $X=(e,t)=>QX(e,t),eZ=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new q(n,0,0);return e.replace(l,i.after(),r),e.setSelection(Y.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},tZ=/^\s*>\s$/,nZ=KG.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return $X(`blockquote`,{...SU(this.options.HTMLAttributes,e),children:$X(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
278
|
+
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
|
|
279
|
+
`))}),n.join(`
|
|
280
|
+
>
|
|
281
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>eZ(this.editor,this.type)}},addInputRules(){return[GG({find:tZ,type:this.type})]}}),rZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,iZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,aZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,oZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,sZ=_G.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return $X(`strong`,{...SU(this.options.HTMLAttributes,e),children:$X(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[HG({find:rZ,type:this.type}),HG({find:aZ,type:this.type})]},addPasteRules(){return[qG({find:iZ,type:this.type}),qG({find:oZ,type:this.type})]}}),cZ=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},lZ=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},uZ=_G.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,SU(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[HG({find:cZ,type:this.type})]},addPasteRules(){return[qG({find:lZ,type:this.type})]}}),dZ=4,fZ=/^```([a-z]+)?[\s\n]$/,pZ=/^~~~([a-z]+)?[\s\n]$/,mZ=KG.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:dZ,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,SU(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
|
|
282
|
+
`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??dZ,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
|
|
283
|
+
`,`
|
|
284
|
+
`).split(`
|
|
285
|
+
`).map(e=>o+e).join(`
|
|
286
|
+
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??dZ,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
|
|
287
|
+
`,`
|
|
288
|
+
`).split(`
|
|
289
|
+
`),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(Y.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
|
|
290
|
+
`,`
|
|
291
|
+
`).split(`
|
|
292
|
+
`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
|
|
293
|
+
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
294
|
+
|
|
295
|
+
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(J.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[WG({find:fZ,type:this.type,getAttributes:e=>({language:e[1]})}),WG({find:pZ,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new pI({key:new gI(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
|
|
296
|
+
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Y.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),hZ=KG.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
297
|
+
|
|
298
|
+
`):``}),gZ=KG.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,SU(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
299
|
+
`},renderMarkdown:()=>`
|
|
300
|
+
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),_Z=KG.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,SU(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>WG({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),vZ=KG.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,SU(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!rG(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return $U(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(Y.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(X.create(t.doc,n.pos)):t.setSelection(Y.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(Y.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[UG({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),yZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,bZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,xZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,SZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,CZ=_G.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,SU(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[HG({find:yZ,type:this.type}),HG({find:xZ,type:this.type})]},addPasteRules(){return[qG({find:bZ,type:this.type}),qG({find:SZ,type:this.type})]}}),wZ=`listItem`,TZ=`textStyle`,EZ=/^\s*([-+*])\s$/,DZ=KG.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,SU(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
301
|
+
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(wZ,this.editor.getAttributes(TZ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=GG({find:EZ,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=GG({find:EZ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(TZ),editor:this.editor})),[e]}}),OZ=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},kZ=(e,t,n,r)=>{let i=OZ(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,K.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},AZ=(e,t,n)=>kZ(e.state,e.view.dispatch,t,n),jZ=(e,t)=>TG.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>AZ(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),MZ=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],NZ=`abcdefghijklmnopqrstuvwxyz`,PZ=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function FZ(e){let t=e,n=``;for(let[e,r]of MZ)for(;t>=e;)n+=r,t-=e;return n}function IZ(e){return FZ(e).toUpperCase()}function LZ(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of MZ)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function RZ(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=LZ(e);return t<=0?!1:(e===e.toLowerCase()?FZ(t):IZ(t))===e}function zZ(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function BZ(e){if(e<=26)return NZ[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?NZ[n]:NZ[t]+NZ[n]}function VZ(e){if(!(!e||/^\d+$/.test(e))){if(RZ(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function HZ(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=VZ(e);if(t===`i`||t===`I`)return LZ(e);if(t===`a`||t===`A`){let t=zZ(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function UZ(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return BZ(t);case`A`:return BZ(t).toUpperCase();case`i`:return FZ(t);case`I`:return IZ(t);default:return String(t)}}function WZ(e){if(e.length===0)return!1;let t=VZ(e[0])??`numeric`,n=HZ(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=UZ(t,n+r);if(e[r]!==i)return!1}return!0}function GZ(e){return{type:VZ(e),start:HZ(e)}}function KZ(e){let{type:t,start:n}=GZ(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function qZ(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${BZ(r)}${n}`;case`A`:return`${BZ(r).toUpperCase()}${n}`;case`i`:return`${FZ(r)}${n}`;case`I`:return`${IZ(r)}${n}`;default:return`${r}${n}`}}function JZ(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function YZ(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var XZ=KG.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,SU(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(JZ(e))return{type:`listItem`,content:[{type:`paragraph`,content:YZ(e.text||``,t)}]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>lG(e,t,e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return qZ((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},n),addExtensions(){return[jZ(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ZZ=(e,t)=>{let{$from:n}=t.selection,r=$V(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},QZ=(e,t)=>{let n=ZZ(e,t);if(!n)return!1;let[,r]=VU(t,e,n.$pos.pos+4);return r},$Z=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},eQ=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!GH(e.state,t)&&$Z(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!GH(e.state,t)||!YU(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},tQ=(e,t)=>{let n=QZ(e,t),r=ZZ(e,t);return!r||!n?!1:n>r.depth},nQ=(e,t)=>{let n=QZ(e,t),r=ZZ(e,t);return!r||!n?!1:n<r.depth},rQ=(e,t)=>{if(!GH(e.state,t)||!JU(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:tQ(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():nQ(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},iQ=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||GH(r,t))return!1;let o=HU(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let c=a.parent;if(!s.canReplace(s.childCount,s.childCount,K.from(c)))return!1;let l=a.before(),u=a.after(),d=l-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(l,u).insert(d,K.from(c)),e.setSelection(Y.create(e.doc,d+1)),e.scrollIntoView()),!0))},aQ=TG.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&rQ(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&rQ(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&eQ(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&eQ(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&iQ(e,t,n))return!0;return!1}}}}),oQ=RegExp(`^(\\s*)(${PZ})([.)])\\s+(.*)$`),sQ=/^\s/,cQ={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function lQ(e){return oQ.test(e.trimStart())}function uQ(e){let t=e.trimStart();return cQ.bulletItem.test(t)||lQ(t)||cQ.heading.test(t)||cQ.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||cQ.codeFence.test(t)||cQ.blockMath.test(t)}function dQ(e){return Object.values(cQ).some(t=>t.test(e))}function fQ(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&uQ(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function pQ(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],a=i.match(oQ);if(!a)break;let[,o,s,c,l]=a,u=o.length,d=parseInt(s,10),f=isNaN(d)?VZ(s):void 0,p=isNaN(d)?HZ(s):d,m=[l],h=n+1,g=[i],_=!1;for(;h<e.length;){let t=e[h];if(t.match(oQ))break;if(t.trim()===``)g.push(t),m.push(``),_=!0,h+=1;else if(t.match(sQ)){let e=t.length-t.trimStart().length,n=u+s.length+1;g.push(t),m.push(t.slice(Math.min(e,n))),h+=1}else{if(_||dQ(t))break;g.push(t),m.push(t),h+=1}}t.push({indent:u,number:p,type:f,content:m.join(`
|
|
302
|
+
`).trim(),contentLines:m,raw:g.join(`
|
|
303
|
+
`)}),r=h,n=h}return[t,r]}var mQ=RegExp(`^(${PZ})([.)])\\s+(.+)$`);function hQ(e){let t=e.split(`
|
|
304
|
+
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(mQ);if(!t)return null;n.push({marker:t[1],content:t[3]})}return WZ(n.map(e=>e.marker))?{type:`orderedList`,attrs:KZ(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function gQ(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=fQ(a.contentLines),c=o.join(`
|
|
305
|
+
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
|
|
306
|
+
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=gQ(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
|
|
307
|
+
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function _Q(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var vQ=`listItem`,yQ=`textStyle`,bQ=/^(\d+)\.\s$/;function xQ(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var SQ=KG.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=xQ(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=xQ(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=SU(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?_Q(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
308
|
+
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
|
|
309
|
+
`),[i,a]=pQ(r);if(i.length===0)return;let o=gQ(i,i[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,typeMarker:i[0]?.type,items:o,raw:r.slice(0,a).join(`
|
|
310
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vQ,this.editor.getAttributes(yQ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new pI({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=hQ(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=GG({find:bQ,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=GG({find:bQ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(yQ)}),joinPredicate:e,editor:this.editor})),[t]}}),CQ=/^\s*(\[([( |x])?\])\s$/,wQ=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,TQ=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},EQ=KG.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,SU(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>lG(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addExtensions(){return this.options.nested?[jZ(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=wQ;let l=e=>{let t=TQ(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=CU(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[GG({find:CQ,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),DQ=KG.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,SU(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
311
|
+
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=cG(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=cG(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});TG.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(DZ.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(XZ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(aQ.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(SQ.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(EQ.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(DQ.configure(this.options.taskList)),e}});var OQ=` `,kQ=`\xA0`,AQ=KG.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,SU(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===OQ||n[0].text===OQ||n[0].raw===kQ||n[0].text===kQ)&&r.length===1&&r[0].type===`text`&&(r[0].text===OQ||r[0].text===kQ)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?OQ:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),jQ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,MQ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,NQ=_G.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,SU(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[HG({find:jQ,type:this.type})]},addPasteRules(){return[qG({find:MQ,type:this.type})]}}),PQ=KG.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),FQ=_G.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,SU(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),IQ=TG.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(sZ.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(nZ.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(DZ.configure(this.options.bulletList)),this.options.code!==!1&&e.push(uZ.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(mZ.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(hZ.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(bX.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(xX.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(gZ.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(_Z.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(KX.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(vZ.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(CZ.configure(this.options.italic)),this.options.listItem!==!1&&e.push(XZ.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(aQ.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(FY.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(SQ.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(AQ.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(NQ.configure(this.options.strike)),this.options.text!==!1&&e.push(PQ.configure(this.options.text)),this.options.underline!==!1&&e.push(FQ.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(GX.configure(this.options?.trailingNode)),e}}),LQ=(0,R.createContext)(null);function RQ(e){let t=(0,R.use)(LQ);if(!t)throw Error(`${e} must be used inside Composer.Root.`);return t}function zQ(e){let t=(0,G.c)(9),n=RQ(e===void 0?`useComposer`:e),r;t[0]!==n.activePopup||t[1]!==n.disabled||t[2]!==n.meta||t[3]!==n.suggestions?(r={...n.meta,disabled:n.disabled,activePopup:n.activePopup,suggestions:n.suggestions},t[0]=n.activePopup,t[1]=n.disabled,t[2]=n.meta,t[3]=n.suggestions,t[4]=r):r=t[4];let i;return t[5]!==n.actions||t[6]!==n.state||t[7]!==r?(i={state:n.state,actions:n.actions,meta:r},t[5]=n.actions,t[6]=n.state,t[7]=r,t[8]=i):i=t[8],i}function BQ(e){let t=(0,G.c)(23),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,attachedImages:a}=RQ(`Composer.Attachments`),o=i.imageAttachments,s,c,l,u,d,f;if(t[3]!==a||t[4]!==n||t[5]!==r||t[6]!==i.imageAttachments){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[13]===a?e=t[14]:(e=e=>a.has(e.id),t[13]=a,t[14]=e);let i=o.filter(e);if(i.length===0){f=null;break bb0}s=`list`,c=`Attached files`,t[15]===n?l=t[16]:(l=I(`flex flex-wrap gap-2`,n),t[15]=n,t[16]=l),u=r,d=i.map(VQ)}t[3]=a,t[4]=n,t[5]=r,t[6]=i.imageAttachments,t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f}else s=t[7],c=t[8],l=t[9],u=t[10],d=t[11],f=t[12];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;return t[17]!==s||t[18]!==c||t[19]!==l||t[20]!==u||t[21]!==d?(p=(0,z.jsx)(`div`,{role:s,"aria-label":c,className:l,...u,children:d}),t[17]=s,t[18]=c,t[19]=l,t[20]=u,t[21]=d,t[22]=p):p=t[22],p}function VQ(e){return(0,z.jsx)(HQ,{attachment:e},e.id)}function HQ(e){let t=(0,G.c)(18),{attachment:n}=e,{id:r,placeholder:i,media:a}=n,{attachedImages:o,disabled:s,actions:c}=RQ(`Composer.Attachments`),l;t[0]!==o||t[1]!==r?(l=o.get(r),t[0]=o,t[1]=r,t[2]=l):l=t[2];let u=l;if(!u)return null;let d;t[3]!==u||t[4]!==a||t[5]!==i?(d=a===`video`?(0,z.jsx)(GQ,{placeholder:i,file:u}):a===`audio`?(0,z.jsx)(qQ,{placeholder:i,file:u,glyph:`♪`}):(0,z.jsx)(WQ,{placeholder:i,file:u}),t[3]=u,t[4]=a,t[5]=i,t[6]=d):d=t[6];let f=`Remove ${i}`,p;t[7]!==c||t[8]!==r?(p=()=>c.removeImageAttachment(r),t[7]=c,t[8]=r,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(ye,{"aria-hidden":!0,className:`size-3`}),t[10]=m):m=t[10];let h;t[11]!==s||t[12]!==f||t[13]!==p?(h=(0,z.jsx)(y,{type:`button`,"aria-label":f,disabled:s,onClick:p,className:`bg-background text-foreground border-border hover:bg-muted absolute -top-1.5 -right-1.5 flex size-5 items-center justify-center rounded-full border disabled:opacity-50`,children:m}),t[11]=s,t[12]=f,t[13]=p,t[14]=h):h=t[14];let g;return t[15]!==d||t[16]!==h?(g=(0,z.jsxs)(`div`,{role:`listitem`,className:`relative`,children:[d,h]}),t[15]=d,t[16]=h,t[17]=g):g=t[17],g}function UQ(e){let t=(0,G.c)(3),[n,r]=(0,R.useState)(null),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{let t=URL.createObjectURL(e);return r(t),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,R.useEffect)(i,a),n}function WQ(e){let t=(0,G.c)(5),{placeholder:n,file:r}=e,i=UQ(r),[a,o]=(0,R.useState)(null),s;return t[0]!==a||t[1]!==r||t[2]!==i||t[3]!==n?(s=i===null?null:i===a?(0,z.jsx)(qQ,{placeholder:n,file:r,glyph:`🖼`}):(0,z.jsx)(`img`,{src:i,alt:n,title:r.name,className:`border-border size-16 rounded-md border object-cover`,onError:()=>o(i)}),t[0]=a,t[1]=r,t[2]=i,t[3]=n,t[4]=s):s=t[4],s}function GQ(e){let t=(0,G.c)(11),{placeholder:n,file:r}=e,i=UQ(r),[a,o]=(0,R.useState)(null),s=i??void 0,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>o(e.currentTarget.duration),t[0]=c):c=t[0];let l;t[1]===s?l=t[2]:(l=(0,z.jsx)(`video`,{src:s,muted:!0,playsInline:!0,preload:`metadata`,className:`size-full object-cover`,onLoadedMetadata:c}),t[1]=s,t[2]=l);let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 flex items-center justify-center text-lg text-white drop-shadow`,children:`▶`}),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a!==null&&Number.isFinite(a)?(0,z.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 rounded bg-black/70 px-1 text-[10px] leading-4 text-white`,children:KQ(a)}):null,t[4]=a,t[5]=d);let f;return t[6]!==r.name||t[7]!==n||t[8]!==l||t[9]!==d?(f=(0,z.jsxs)(`div`,{role:`img`,"aria-label":n,title:r.name,className:`border-border bg-muted relative size-16 overflow-hidden rounded-md border`,children:[l,u,d]}),t[6]=r.name,t[7]=n,t[8]=l,t[9]=d,t[10]=f):f=t[10],f}function KQ(e){let t=Math.round(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function qQ(e){let t=(0,G.c)(12),{placeholder:n,file:r,glyph:i}=e,a;t[0]===i?a=t[1]:(a=(0,z.jsxs)(`span`,{"aria-hidden":!0,children:[i,` `]}),t[0]=i,t[1]=a);let o=r.name||n,s;t[2]!==a||t[3]!==o?(s=(0,z.jsxs)(`span`,{className:`text-foreground truncate`,children:[a,o]}),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c=r.type||`file`,l;t[5]===c?l=t[6]:(l=(0,z.jsx)(`span`,{className:`truncate`,children:c}),t[5]=c,t[6]=l);let u;return t[7]!==r.name||t[8]!==n||t[9]!==s||t[10]!==l?(u=(0,z.jsxs)(`div`,{role:`img`,"aria-label":n,title:r.name,className:`border-border bg-muted text-muted-foreground flex h-16 max-w-48 flex-col justify-center gap-0.5 rounded-md border px-2 text-xs`,children:[s,l]}),t[7]=r.name,t[8]=n,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function JQ(e,t){return e===`hidden`?!1:e===`before-interaction`?!t:e!==`after-interaction`||t}function YQ(e,t,n){let r=ZQ(e),i=t.filter(e=>QQ(e)&&JQ(e.visibility,n));return r?i.map((e,t)=>{let n=e$(r,e);return n===null?null:{command:e,rank:n,index:t}}).filter(e=>!!e).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.command).slice(0,10):i.slice(0,10)}function XQ(e,t){let n=e.toLowerCase();return t.find(e=>QQ(e)&&(e.value.toLowerCase()===n||$Q(e).some(e=>e===n)))}function ZQ(e){return e.slice(1).toLowerCase()}function QQ(e){return e.availability!==`disabled`}function $Q(e){return(e.aliases??[]).map(e=>e.toLowerCase())}function e$(e,t){let n=t.value.toLowerCase(),r=$Q(t),i=[t.label.toLowerCase(),...(t.searchTerms??[]).map(e=>e.toLowerCase())];return n===e?0:r.some(t=>t===e)?1:n.startsWith(e)?2:r.some(t=>t.startsWith(e))?3:i.some(t=>t.startsWith(e))?4:null}function t$(e){return e.map(RegExp.escape).join(`|`)}function n$(e){return`(?:${t$(e)})[A-Za-z0-9_:-]+`}function r$(e){return`(?:${t$(e)})[^\\s]+`}function i$(e,t){let n=[];return t.length>0&&n.push(r$(t)),e.length>0&&n.push(n$(e)),n.length>0?new RegExp(n.join(`|`),`g`):null}function a$(e,t){return t.some(t=>e.startsWith(t))}function o$(e){return`${e.trigger}${e.value}`}function s$({initialDraft:e,text:t=``,slashCommands:n=[],mentionCandidates:r=[],commandTriggers:i=[],remoteImageUrls:a=[],isTaskRunning:o=!1,queueSubmissions:s=!1}={}){let c=e?.text??t,l=r.flatMap(e=>{let t=A$(`mention`,o$(e),c,{detail:e.detail});return t?[t]:[]}),u=l.flatMap(e=>{let t=r.find(t=>o$(t)===e.label);return t?[{id:e.id,trigger:t.trigger,value:t.value,payload:t.payload,persistsAs:t.persistsAs}]:[]}),d=e?.remoteImages??(e?.remoteImageUrls??a).map((e,t)=>({id:c1(`remote-image`,e,t),url:e}));return{text:c,cursor:c.length,elements:j$(e?.elements??[...p$(c,n,i),...l]),mentionBindings:e?.mentionBindings??u,imageAttachments:[],remoteImages:d,pendingPastes:e?.pendingPastes??[],selectedRemoteImageId:null,isTaskRunning:o,queueSubmissions:s,error:null,reverseSearch:null,shortcutsOpen:!1,history:[],historyCursor:null,killBuffer:``}}function c$(e){return e.text.length===0&&e.imageAttachments.length===0&&e.remoteImages.length===0&&e.pendingPastes.length===0}function l$(e,t,n){return f$(e,t,n)}function u$(e,t){if(!t||t<1)return null;let n=R$(e.prompt);return n<=t?null:`Prompt is too long after expanding pasted content (${n} chars; max ${t} chars).`}function d$(e,t,n){let r=w$(e.elements,e.text);r=[...r.filter(e=>e.kind!==`slash-command`),...p$(e.text,t,n)];let i=e.mentionBindings.filter(e=>r.some(t=>t.id===e.id)),a=e.imageAttachments.filter(e=>r.some(t=>t.kind===`image`&&t.label===e.placeholder)),o=e.pendingPastes.filter(e=>r.some(t=>t.kind===`paste`&&t.label===e.placeholder));return{...e,elements:j$(r),mentionBindings:i,imageAttachments:I$(a,e.remoteImages.length),pendingPastes:o}}function f$(e,t,n){let r=e.text.trim(),i=b$(e.text,r,e.elements),a=v$(e.text,e.elements,e.pendingPastes),o=a.text,s=o.trim(),c=b$(o,s,a.elements),l=e.imageAttachments.filter(t=>e.text.includes(t.placeholder)),u=x$(r,i),d=W$({text:u.text,elements:u.elements,mentionBindings:e.mentionBindings}),f=W$({text:s,elements:c,mentionBindings:e.mentionBindings});if(!s&&l.length===0&&e.remoteImages.length===0)return null;let p=a$(o,n)?m$(s,c,t,n):null,m=p?.prompt===void 0?null:p.args?`${p.prompt}\n\n${W$({text:p.args,elements:p.argsElements,mentionBindings:e.mentionBindings})}`:p.prompt,h=p?.prompt===void 0?null:p.args?(()=>{let t=x$(p.args,p.argsElements);return`${p.prompt}\n\n${W$({text:t.text,elements:t.elements,mentionBindings:e.mentionBindings})}`})():p.prompt,g=m??f,_=p?.args===void 0?p?`command`:`submitted`:`command-with-args`,v=[...e.remoteImages.map(e=>({type:`remote_image`,url:e.url}))];!p&&s&&v.push({type:`text`,text:s,textElements:c});let y=p?.args??s;for(let t of e.mentionBindings){let e=`${t.trigger}${t.value}`;!e||!y.includes(e)||v.push({type:`item`,id:t.id,trigger:t.trigger,value:t.value,payload:t.payload})}for(let e of c)e.kind===`link`&&e.detail&&v.push({type:`link`,text:e.label,href:e.detail}),e.kind===`rich-link`&&e.detail&&v.push({type:`rich_link`,text:e.label,href:e.detail,metadata:e.metadata});return{mode:_,prompt:g,persistedPrompt:d,historyPrompt:h??d,action:p?.args===void 0?p?`Command`:`Plain`:`CommandWithArgs`,command:p?.command,args:p?.args,items:v,elements:i,payloadElements:c,mentionBindings:e.mentionBindings}}function p$(e,t,n){let r=[];if(n.length===0)return r;let i=e.matchAll(RegExp(`(^|\\s)((?:${t$(n)})([A-Za-z0-9_:-]+))(?=\\s|$)`,`g`));for(let e of i){let n=XQ(e[3],t);if(!n)continue;let i=e[2],a=e.index+e[1].length;r.push({id:c1(`slash-command`,i,a),kind:`slash-command`,label:i,range:{start:a,end:a+i.length},detail:n.detail})}return r}function m$(e,t,n,r){let i=e.match(RegExp(`^(?:${t$(r)})([A-Za-z0-9_:-]+)(?:\\s+([\\s\\S]+))?$`));if(!i)return null;let a=XQ(i[1],n);if(!a)return null;let o=i[2]??``;if(!o.trim())return{command:a.value,prompt:a.expandsTo};if(!a.supportsArgs)return null;let s=a.trigger.length+a.value.length,c=e.slice(s).search(/\S/),l=c===-1?s:s+c,u=o.trim();return{command:a.value,prompt:a.expandsTo,args:u,argsElements:y$(t,l,l+u.length)}}function h$(e,t,n){if(n.length===0)return null;let r=e.match(RegExp(`^(?:${t$(n)})([A-Za-z0-9_:-]+)(?:\\s+[\\s\\S]*)?$`));return!r||XQ(r[1],t)||_$(r[1])?null:r[1]}var g$=new Set([`Applications`,`Library`,`System`,`Users`,`Volumes`,`bin`,`dev`,`etc`,`home`,`mnt`,`opt`,`private`,`sbin`,`tmp`,`usr`,`var`,`workspace`]);function _$(e){return g$.has(e)}function v$(e,t,n){if(n.length===0||t.length===0)return{text:e,elements:t};let r=new Map;for(let e of n){let t=r.get(e.placeholder)??[];t.push(e.content),r.set(e.placeholder,t)}let i=``,a=[],o=0;for(let n of j$(t)){let t=Math.min(n.range.start,e.length),s=Math.min(n.range.end,e.length);if(t>s)continue;t>o&&(i+=e.slice(o,t));let c=e.slice(t,s),l=r.get(n.label)?.shift();if(l!==void 0)i+=l;else{let e=i.length;i+=c,a.push({...n,range:{start:e,end:i.length}})}o=s}return o<e.length&&(i+=e.slice(o)),{text:i,elements:a}}function y$(e,t,n){return e.filter(e=>e.range.end>t&&e.range.start<n).map(e=>({...e,range:{start:Math.max(0,e.range.start-t),end:Math.min(n,e.range.end)-t}})).filter(e=>e.range.start<e.range.end)}function b$(e,t,n){let r=e.indexOf(t);return r<=0?n:n.filter(e=>e.range.end>r).map(e=>({...e,range:{start:Math.max(0,e.range.start-r),end:Math.max(0,e.range.end-r)}}))}function x$(e,t){let n=j$(t.filter(e=>e.kind===`image`));for(let t of n.toReversed())e=C$(e,t.range,``);let r=e=>n.reduce((t,n)=>t+Math.max(0,Math.min(e,n.range.end)-n.range.start),0);return{text:e,elements:j$(t.filter(e=>e.kind!==`image`)).map(e=>({...e,range:{start:e.range.start-r(e.range.start),end:e.range.end-r(e.range.end)}}))}}function S$(e,t,n,r){return e<r&&t>n}function C$(e,t,n){return e.slice(0,t.start)+n+e.slice(t.end)}function w$(e,t){let n=new Map;return j$(e).map(e=>{let r=T$(t,e.label);if(r.length===0)return null;let i=`${e.kind}:${e.label}`,a=n.get(i)??[],o=E$(r,e,a)??D$(r,e,a)??O$(r,e);return n.set(i,[...a,o]),{...e,range:o}}).filter(e=>!!e)}function T$(e,t){if(!t)return[];let n=[],r=e.indexOf(t);for(;r!==-1;)n.push({start:r,end:r+t.length}),r=e.indexOf(t,r+t.length);return n}function E$(e,t,n){return e.find(e=>e.start===t.range.start&&e.end===t.range.end&&!k$(e,n))}function D$(e,t,n){return O$(e.filter(e=>!k$(e,n)),t)}function O$(e,t){return[...e].sort((e,n)=>Math.abs(e.start-t.range.start)-Math.abs(n.start-t.range.start)||e.start-n.start)[0]}function k$(e,t){return t.some(t=>e.start===t.start&&e.end===t.end&&S$(e.start,e.end,t.start,t.end))}function A$(e,t,n,r={}){let i=n.indexOf(t);return i===-1?null:{id:c1(e,t,i),kind:e,label:t,range:{start:i,end:i+t.length},detail:r.detail}}function j$(e){return[...e].sort((e,t)=>e.range.start-t.range.start)}var M$={image:`Image`,video:`Video`,audio:`Audio`};function N$(e){let t=e.type.split(`/`)[0];return t===`image`||t===`video`||t===`audio`?t:null}function P$(e){return e===`video`||e===`audio`?e:`image`}function F$(e,t){return`[${M$[e]} #${t}]`}function I$(e,t){return e.map((e,n)=>({...e,placeholder:F$(e.media,t+n+1)}))}function L$(e,t){if(!t)return null;let n=e.remoteImages.findIndex(e=>e.id===t);return n===-1?null:n}function R$(e){return Array.from(e).length}function z$(e){let t=x$(e.text,e.elements);return{text:t.text,elements:e1(t.elements),mentionBindings:t1(e.mentionBindings),remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:n1(e.pendingPastes)}}function B$(e,t){return{persistedPrompt:t,remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:n1(e.pendingPastes)}}function V$(e,t){let n=B$(e,t);return!n.persistedPrompt.trim()&&n.remoteImages.length===0&&n.pendingPastes.length===0?e.history:[n,...e.history].slice(0,8)}function H$({text:e,slashCommands:t=[],commandTriggers:n=[],mentionCandidates:r=[]}){let i=K$(e,r),a=Z$(i.text,i.elements,i.protectedRanges,t,r);return z$(d$(s$({initialDraft:{text:i.text,elements:j$([...i.elements,...a.elements]),mentionBindings:[...i.mentionBindings,...a.mentionBindings]},slashCommands:t}),t,n))}function U$({source:e,slashCommands:t=[],mentionCandidates:n=[]}){let r=H$({text:e.persistedPrompt,slashCommands:t,mentionCandidates:n}),i=[...e.pendingPastes.flatMap(e=>{let t=A$(`paste`,e.placeholder,r.text??``,{detail:`${R$(e.content)} chars`});return t?[t]:[]})];return{...r,elements:j$([...r.elements??[],...i]),remoteImages:e.remoteImages.map(e=>({...e})),pendingPastes:n1(e.pendingPastes)}}function W$(e){let t=e.text??``,n=j$(e.elements??[]).map(t=>$$(t,e)).filter(e=>!!e).sort((e,t)=>t.range.start-e.range.start);for(let e of n)t=C$(t,e.range,e.text);return t}function G$(e){return e.startsWith(`composer-text-link://`)?decodeURIComponent(e.replace(/^composer-text-link:\/\//,``)):e}function K$(e,t){let n=[],r=[],i=[],a=``;for(let o of QM(e)){if(o.kind===`inline-code`||o.kind===`code-block`){let e=a.length;a+=o.source,i.push({start:e,end:a.length});continue}if(o.kind!==`link`&&o.kind!==`skill-link`&&o.kind!==`mention`){a+=o.source;continue}let e=o.label,s=o.href,c=G$(s),l=q$(e,t),u=l?o$(l):e,d=a.length;if(a+=u,l){let e=c1(`mention`,u,d);n.push({id:e,kind:`mention`,label:u,range:{start:d,end:d+u.length},detail:l.detail}),r.push({id:e,trigger:l.trigger,value:l.value,payload:l.payload,persistsAs:l.persistsAs})}else n.push({id:c1(`link`,u,d),kind:`link`,label:u,range:{start:d,end:d+u.length},detail:c})}return{text:a,elements:n,mentionBindings:r,protectedRanges:i}}function q$(e,t){return t.find(t=>o$(t)===e)??null}function J$(e){return[...new Set(e.map(e=>e.trigger).filter(Boolean))].sort((e,t)=>t.length-e.length)}function Y$(e){let t=J$(e);return t.length===0?null:RegExp(`(?:${t$(t)})[A-Za-z0-9_:-]+`,`g`)}function X$(e,t){return J$(t).find(t=>e.startsWith(t))?.length??0}function Z$(e,t,n,r,i){let a=[],o=[],s=[],c=(r,i)=>{let a=r+i.length;return(r===0||/\s/.test(e[r-1]??``))&&!Q$(r,i,t)&&!s.some(e=>r<e.end&&a>e.start)&&!n.some(e=>r<e.end&&a>e.start)},l=[...i].sort((e,t)=>o$(t).length-o$(e).length);for(let t of l){let n=o$(t);if(n)for(let r=e.indexOf(n);r!==-1;r=e.indexOf(n,r+n.length)){let i=r+n.length;if(/[\w-]/.test(e[i]??``)||!c(r,n))continue;let l=c1(`mention`,n,r);s.push({start:r,end:i}),a.push({id:l,kind:`mention`,label:n,range:{start:r,end:i},detail:t.detail}),o.push({id:l,trigger:t.trigger,value:t.value,payload:t.payload,persistsAs:t.persistsAs})}}let u=Y$(r);for(let t of u?e.matchAll(u):[]){let e=t.index??0,n=t[0];if(!c(e,n))continue;let i=XQ(n.slice(X$(n,r)),r);i&&(s.push({start:e,end:e+n.length}),a.push({id:c1(`slash-command`,n,e),kind:`slash-command`,label:n,range:{start:e,end:e+n.length},detail:i.detail}))}return{elements:a,mentionBindings:o}}function Q$(e,t,n){let r=e+t.length;return n.some(t=>e<t.range.end&&r>t.range.start)}function $$(e,t){if(e.kind===`mention`){let n=(t.mentionBindings??[]).find(t=>t.id===e.id||`${t.trigger}${t.value}`===e.label);return n?{range:e.range,text:n.persistsAs??e.label}:null}return(e.kind===`link`||e.kind===`rich-link`)&&e.detail?{range:e.range,text:ZM(e.label,e.detail)}:null}function e1(e){return e.map(e=>{let t={...e,range:{...e.range}};return e.metadata?{...t,metadata:{...e.metadata}}:t})}function t1(e){return e.map(e=>({...e}))}function n1(e){return e.map(e=>({...e}))}function r1(e,t,n,r=1){if(t.length===0)return null;let i=t.toLowerCase(),a=e.map((e,t)=>({index:t,entry:e})).filter(e=>e.entry.persistedPrompt.toLowerCase().includes(i));if(a.length===0)return null;if(n===null)return a[0];let o=a.findIndex(e=>e.index===n);return o===-1?a[0]:a[s1(o+r,a.length)]}function i1(e,t,n){return n===-1?t===0||!e.slice(0,t).includes(`
|
|
312
|
+
`):t===e.length||!e.slice(t).includes(`
|
|
313
|
+
`)}function a1(e,t){let n=l1(e,t);for(;n>0&&g1(f1(e,n));)n=u1(e,n);if(n===0)return 0;let r=y1(f1(e,n));if(r===`cjk`)return u1(e,n);for(;n>0&&y1(f1(e,n))===r;)n=u1(e,n);return n}function o1(e,t){let n=l1(e,t);for(;n<e.length&&g1(p1(e,n));)n=d1(e,n);if(n>=e.length)return e.length;let r=y1(p1(e,n));if(r===`cjk`)return d1(e,n);for(;n<e.length&&y1(p1(e,n))===r;)n=d1(e,n);return n}function s1(e,t){return(e%t+t)%t}function c1(e,t,n){return`${e}:${n}:${t}`}function l1(e,t){let n=Math.max(0,Math.min(t,e.length));return n>0&&n<e.length&&h1(e.charCodeAt(n))&&--n,n}function u1(e,t){let n=t-1;return n>0&&h1(e.charCodeAt(n))?n-1:Math.max(n,0)}function d1(e,t){let n=t+(m1(e.charCodeAt(t))?2:1);return Math.min(n,e.length)}function f1(e,t){let n=u1(e,t);return e.slice(n,t)}function p1(e,t){return e.slice(t,d1(e,t))}function m1(e){return e>=55296&&e<=56319}function h1(e){return e>=56320&&e<=57343}function g1(e){return/\s/u.test(e)}function _1(e){return!v1(e)&&/[\p{Letter}\p{Number}_]/u.test(e)}function v1(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e)}function y1(e){return v1(e)?`cjk`:_1(e)?`word`:`separator`}var b1=`composer-draft:v1:`;function x1(e){let t=localStorage.getItem(`${b1}${e}`);if(!t)return null;try{let e=JSON.parse(t);return w1(e)?e:null}catch{return null}}function S1(e,t){let n=`${b1}${e}`;if(!t||C1(t)){localStorage.removeItem(n);return}try{localStorage.setItem(n,JSON.stringify(t))}catch(e){if(!(e instanceof DOMException&&e.name===`QuotaExceededError`))throw e}}function C1(e){return!e.persistedPrompt.trim()&&e.remoteImages.length===0&&e.pendingPastes.length===0}function w1(e){return T1(e)&&Object.keys(e).every(e=>[`persistedPrompt`,`remoteImages`,`pendingPastes`].includes(e))&&typeof e.persistedPrompt==`string`&&Array.isArray(e.remoteImages)&&Array.isArray(e.pendingPastes)}function T1(e){return typeof e==`object`&&!!e}var E1=Symbol.for(`composer.registry.trigger`),D1=Symbol.for(`composer.registry.command`),O1=Symbol.for(`composer.registry.mention`);function k1(e){return null}k1.role=E1;function A1(e){return null}A1.role=D1;function j1(e){return null}j1.role=O1;function M1(e){let t=[],n=[],r=new Set,i=new Set,a=!1,o=e=>{for(let s of R.Children.toArray(e)){if(!(0,R.isValidElement)(s)){a=!0;continue}if(s.type===R.Fragment){(0,R.isValidElement)(s)&&o(s.props.children);continue}if(L1(s.type,E1)){(0,R.isValidElement)(s)&&F1(s.props,{slashCommands:t,mentionCandidates:n,commandTriggers:r,mentionTriggers:i});continue}if(L1(s.type,D1)||L1(s.type,O1))throw Error(`Composer.Command and Composer.Mention must be placed inside a <Composer.Trigger>.`);a=!0}};return o(e),{slashCommands:t,mentionCandidates:n,commandTriggers:[...r],mentionTriggers:[...i],hasLayoutChildren:a}}function N1(e){return JSON.stringify([e.slashCommands.map(P1),e.mentionCandidates.map(P1),e.commandTriggers,e.mentionTriggers])}function P1(e){let{icon:t,...n}=e;return n}function F1(e,t){let{trigger:n}=e;for(let r of R.Children.toArray(e.children))if((0,R.isValidElement)(r)){if(r.type===R.Fragment){(0,R.isValidElement)(r)&&F1({trigger:n,children:r.props.children},t);continue}if(L1(r.type,D1)){if(t.mentionTriggers.has(n))throw Error(`Composer.Trigger "${n}" already holds mentions; a trigger carries either commands or mentions, not both.`);t.commandTriggers.add(n),(0,R.isValidElement)(r)&&t.slashCommands.push({...r.props,atomic:!1,trigger:n});continue}if(L1(r.type,O1)){if(t.commandTriggers.has(n))throw Error(`Composer.Trigger "${n}" already holds commands; a trigger carries either commands or mentions, not both.`);t.mentionTriggers.add(n),(0,R.isValidElement)(r)&&t.mentionCandidates.push(I1(r.props,n));continue}throw Error(`<Composer.Trigger trigger="${n}"> accepts only <Composer.Command> and <Composer.Mention> children; wrap them in a fragment rather than a component, which the registry cannot see through.`)}}function I1(e,t){return{id:e.id,trigger:t,value:e.value,label:e.label,detail:e.detail,atomic:!0,icon:e.icon,payload:e.payload,persistsAs:e.persistsAs,visibility:e.visibility}}function L1(e,t){return typeof e==`function`&&`role`in e&&e.role===t}function R1(e,t,n,r){return[...YQ(e.query,t.filter(t=>t.trigger===e.trigger),r),...z1(e.query,n.filter(t=>t.trigger===e.trigger),r)]}function z1(e,t,n){let r=e.slice(1).toLowerCase();return t.filter(e=>JQ(e.visibility,n)&&(e.label.toLowerCase().includes(r)||o$(e).slice(1).toLowerCase().includes(r))).slice(0,10)}var B1=(0,R.createContext)(null);function V1(e){let t=e===void 0?`useComposerDictation`:e;RQ(t);let n=(0,R.use)(B1);if(!n)throw Error(`${t} needs the dictation prop of Composer.Root.`);return n}function H1(e,t){return typeof e==`function`?n=>e(n,t):e}function U1(e){let t=(0,G.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({dictation:a,refusesStart:r,render:i,...n}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{state:o,start:s,stop:c}=a,l=o.status===`recording`,u=(o.status===`idle`||o.status===`failed`)&&!r,d=o.status,f=!l&&!u,p=l?c:s,m;t[5]!==i||t[6]!==o?(m=H1(i,o),t[5]=i,t[6]=o,t[7]=m):m=t[7];let h;return t[8]!==n||t[9]!==l||t[10]!==o.status||t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,z.jsx)(y,{...n,"data-status":d,"aria-pressed":l,disabled:f,onClick:p,render:m}),t[8]=n,t[9]=l,t[10]=o.status,t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function W1(e){let t=(0,G.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({dictation:a,render:i,disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{state:o,cancel:s}=a,c=o.status===`starting`||o.status===`recording`||o.status===`finishing`,l=o.status,u=!c||n===!0,d;t[5]!==i||t[6]!==o?(d=H1(i,o),t[5]=i,t[6]=o,t[7]=d):d=t[7];let f;return t[8]!==s||t[9]!==r||t[10]!==o.status||t[11]!==u||t[12]!==d?(f=(0,z.jsx)(y,{...r,"data-status":l,disabled:u,onClick:s,render:d}),t[8]=s,t[9]=r,t[10]=o.status,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function G1(e){let t=(0,G.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({disabled:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let{disabled:i}=RQ(`Composer.Dictate`),a=V1(`Composer.Dictate`),{state:o}=a,s=o.status===`finishing`?o.end:void 0,c=n===!0||i,l;return t[3]!==a||t[4]!==r||t[5]!==s||t[6]!==c?(l=(0,z.jsx)(U1,{...r,"data-end":s,dictation:a,refusesStart:c}),t[3]=a,t[4]=r,t[5]=s,t[6]=c,t[7]=l):l=t[7],l}function K1(e){let t=(0,G.c)(3),n=V1(`Composer.CancelDictation`),r;return t[0]!==n||t[1]!==e?(r=(0,z.jsx)(W1,{...e,dictation:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}var q1=class extends Error{code;constructor(e,t){super(`Dictation failed: ${e}`,t),this.name=`DictationError`,this.code=e}},J1=new Map([[`NotAllowedError`,`permission-denied`],[`NotFoundError`,`no-microphone`],[`NotReadableError`,`microphone-in-use`]]);function Y1(e){switch(e.status){case`starting`:case`ended`:return{status:e.status};case`recording`:return{status:`recording`};case`stopping`:case`transcribing`:return{status:`finishing`};case`failed`:return{status:`failed`,error:e.error}}}var X1=class e{#e={status:`starting`};#t={status:`starting`};#n=new AbortController;#r=new Set;#i=new Set;#a;constructor(e){this.#a=e}static start(t){let n=new e(t);return n.#o(),n}subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getSnapshot=()=>this.#t;onTranscript(e){return this.#i.add(e),()=>{this.#i.delete(e)}}stop(){let e=this.#e;if(e.status===`starting`){this.cancel();return}e.status===`recording`&&(this.#u({...e,status:`stopping`}),e.recorder.stop())}cancel(){this.#l({status:`ended`})}async#o(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e instanceof DOMException?J1.get(e.name):void 0;if(!t)throw e;this.#l({status:`failed`,error:new q1(t,{cause:e})});return}let{signal:t}=this.#n;if(t.aborted){for(let t of e.getTracks())t.stop();return}let n=new MediaRecorder(e),r=[];n.addEventListener(`dataavailable`,e=>{r.push(e.data)},{signal:t}),n.addEventListener(`stop`,()=>{this.#e.status===`stopping`&&this.#s(new Blob(r,{type:n.mimeType}))},{signal:t}),n.addEventListener(`error`,e=>{this.#l({status:`failed`,error:new q1(`interrupted`,{cause:e})})},{signal:t});for(let n of e.getAudioTracks())n.addEventListener(`ended`,()=>{this.#l({status:`failed`,error:new q1(`interrupted`)})},{signal:t});n.start(),this.#u({status:`recording`,stream:e,recorder:n})}async#s(e){this.#c(),this.#u({status:`transcribing`});let{signal:t}=this.#n;try{let{text:n}=await this.#a(e,{signal:t});if(t.aborted)return;for(let e of this.#i)e(n)}catch(e){if(t.aborted)return;this.#l({status:`failed`,error:new q1(`transcription-failed`,{cause:e})});return}this.#l({status:`ended`})}#c(){let e=this.#e;if(!(e.status!==`recording`&&e.status!==`stopping`)){e.recorder.state!==`inactive`&&e.recorder.stop();for(let t of e.stream.getTracks())t.stop()}}#l(e){let{status:t}=this.#e;t===`ended`||t===`failed`||(this.#n.abort(),this.#c(),this.#u(e))}#u(e){this.#e=e,this.#t=Y1(e);for(let e of this.#r)e()}},Z1=class{#e=`unknown`;subscribe=e=>{let t=new AbortController;return navigator.permissions.query({name:`microphone`}).then(n=>{if(t.signal.aborted)return;let r=()=>{this.#e=n.state,e()};r(),n.addEventListener(`change`,r,{signal:t.signal})},e=>{if(!(e instanceof TypeError))throw e}),()=>{t.abort()}};getSnapshot=()=>this.#e},Q1=()=>()=>void 0,$1=()=>null,e0=()=>`unknown`;function t0(e){let t=(0,G.c)(29),{offered:n,disabled:r,onTranscript:i}=e,a=`MediaRecorder`in globalThis&&`mediaDevices`in navigator,[o]=(0,R.useState)(n0),s=(0,R.useSyncExternalStore)(n&&a?o.subscribe:Q1,o.getSnapshot,e0),[c,l]=(0,R.useState)(null),u=(0,R.useSyncExternalStore)(c?c.subscribe:Q1,c?c.getSnapshot:$1,$1),d;t[0]===i?d=t[1]:(d=e=>{i(e)},t[0]=i,t[1]=d);let f=(0,R.useEffectEvent)(d),p;t[2]!==f||t[3]!==c?(p=()=>{if(!c)return;let e=c.onTranscript(e=>{f(e)});return()=>{e(),c.cancel()}},t[2]=f,t[3]=c,t[4]=p):p=t[4];let m;t[5]===c?m=t[6]:(m=[c],t[5]=c,t[6]=m),(0,R.useEffect)(p,m);let h,g;t[7]!==r||t[8]!==n||t[9]!==c?(h=()=>{(r||!n)&&c?.cancel()},g=[r,n,c],t[7]=r,t[8]=n,t[9]=c,t[10]=h,t[11]=g):(h=t[10],g=t[11]),(0,R.useEffect)(h,g);let _,v;if(t[12]!==s||t[13]!==u){v=e(),_=v.status===`starting`||v.status===`recording`||v.status===`finishing`;function e(){if(!a)return{status:`unavailable`,reason:`unsupported`};switch(u?.status){case`starting`:case`recording`:case`finishing`:return{status:u.status};case`ended`:case`failed`:case void 0:}return s===`denied`?{status:`unavailable`,reason:`blocked`}:u?.status===`failed`?{status:`failed`,error:u.error}:{status:`idle`}}t[12]=s,t[13]=u,t[14]=_,t[15]=v}else _=t[14],v=t[15];let y;t[16]!==_||t[17]!==r||t[18]!==v?(y=function(e){return r||_||v.status===`unavailable`?!1:(l(X1.start(e)),!0)},t[16]=_,t[17]=r,t[18]=v,t[19]=y):y=t[19];let b=y,x;t[20]===c?x=t[21]:(x=function(){c?.stop()},t[20]=c,t[21]=x);let S=x,C;t[22]===c?C=t[23]:(C=function(){c?.cancel()},t[22]=c,t[23]=C);let w=C,T;return t[24]!==w||t[25]!==b||t[26]!==v||t[27]!==S?(T={state:v,start:b,stop:S,cancel:w},t[24]=w,t[25]=b,t[26]=v,t[27]=S,t[28]=T):T=t[28],T}function n0(){return new Z1}function r0(e){let t=(0,G.c)(25),{dictation:n,disabled:r,insertTranscript:i,submitDraft:a}=e,[o,s]=(0,R.useState)(`insert`),c=n!==void 0,l;t[0]!==o||t[1]!==i||t[2]!==a?(l=e=>{let t=e.trim();t&&i(t),o===`send`&&a()},t[0]=o,t[1]=i,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==r||t[5]!==c||t[6]!==l?(u={offered:c,disabled:r,onTranscript:l},t[4]=r,t[5]=c,t[6]=l,t[7]=u):u=t[7];let d=t0(u);if(!n)return null;let{transcribe:f}=n,p;t[8]!==o||t[9]!==d.state?(p=d.state.status===`finishing`?{status:`finishing`,end:o}:d.state,t[8]=o,t[9]=d.state,t[10]=p):p=t[10];let m=p,h;t[11]!==d||t[12]!==f?(h=function(){d.start(f)&&s(`insert`)},t[11]=d,t[12]=f,t[13]=h):h=t[13];let g=h,_;t[14]!==d||t[15]!==m?(_=function(){switch(m.status){case`starting`:return d.cancel(),!1;case`recording`:return s(`send`),d.stop(),!0;case`finishing`:return s(`send`),!0;default:return!1}},t[14]=d,t[15]=m,t[16]=_):_=t[16];let v=_,y;t[17]!==d.cancel||t[18]!==d.stop||t[19]!==g||t[20]!==m?(y={state:m,start:g,stop:d.stop,cancel:d.cancel},t[17]=d.cancel,t[18]=d.stop,t[19]=g,t[20]=m,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b={api:y,endWithSend:v},t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function i0({getPlaceholder:e,...t}){return[IQ.configure({link:!1}),IY.configure({autolink:!0,linkOnPaste:!1,openOnClick:!1,HTMLAttributes:{"data-token":`link`}}),s0,c0,l0,zX.configure({placeholder:e,showOnlyWhenEditable:!1}),u0(t)]}var a0=1e3;function o0(e,t){return{default:t,parseHTML:n=>n.getAttribute(e)??t}}var s0=_G.create({name:`composerSlashCommand`,inclusive:!1,addAttributes(){return{value:{default:null},detail:{default:null}}},parseHTML(){return[{tag:`span[data-composer-slash-command]`}]},renderHTML({HTMLAttributes:e}){return[`span`,SU(e,{"data-token":`slash-command`,"data-composer-slash-command":e.value}),0]}}),c0=KG.create({name:`composerMention`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{id:o0(`id`,null),trigger:o0(`trigger`,``),value:o0(`value`,``),label:o0(`label`,``),detail:o0(`detail`,``),persistsAs:o0(`persistsAs`,null),payload:{default:null,renderHTML:e=>e.payload===null||e.payload===void 0?{}:{payload:JSON.stringify(e.payload)},parseHTML:e=>{let t=e.getAttribute(`payload`);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}}}},parseHTML(){return[{tag:`span[data-composer-mention]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.label||`${e.attrs.trigger??``}${e.attrs.value??``}`;return[`span`,SU(t,{"data-token":`mention`,"data-composer-mention":e.attrs.value,"data-composer-mention-trigger":e.attrs.trigger}),n]},renderText({node:e}){return e.attrs.label||`${e.attrs.trigger??``}${e.attrs.value??``}`}}),l0=KG.create({name:`composerAtom`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{kind:{default:`paste`},label:{default:``},detail:{default:``},content:{default:``},href:{default:``},attachmentId:{default:``,rendered:!1},media:{default:`image`,rendered:!1},metadata:{default:null}}},parseHTML(){return[{tag:`span[data-composer-atom]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.kind??`paste`),r=String(e.attrs.label??``);return[`span`,SU(t,{"data-token":n,"data-composer-atom":n,"data-composer-atom-detail":e.attrs.detail}),r]},renderText({node:e}){return String(e.attrs.label??``)}});function u0(e){return TG.create({name:`composerClipboard`,addProseMirrorPlugins(){return[new pI({props:{handlePaste(t,n){let r=n.clipboardData;if(!r)return!1;let i=Array.from(r.files).find(e=>N$(e)!==null);if(i)return n.preventDefault(),z0(t,e.getRemoteImageCount(),i,e.attachImageFile),!0;let a=Array.from(r.files).find(e=>N$(e)===null);if(a)return n.preventDefault(),B0(t,a.name||`pasted-file`,e.getMentionTrigger()),!0;let o=m2(y2(r.getData(`text/uri-list`))||b2(r.getData(`DownloadURL`))||r.getData(`text/plain`)||r.getData(`text`)),s=o.trim();if(!o)return!1;let c=M0(t);if(c&&x2(s)){n.preventDefault();let e=S2(s),r=t.state.schema.marks.link;return r?P0(t,c,e,r):!1}return h2(s)&&!s.includes(`
|
|
314
|
+
`)?(n.preventDefault(),B0(t,s,e.getMentionTrigger()),!0):x2(s)&&!s.includes(`
|
|
315
|
+
`)?(n.preventDefault(),L0(t,s,S2(s))):c&&o&&!o.includes(`
|
|
316
|
+
`)&&R$(o)<=a0?(n.preventDefault(),R0(t,o,c),!0):R$(o)>a0?(n.preventDefault(),j0(t,o),!0):!1},handleDrop(t,n){let r=n.dataTransfer;return r&&d0(t,r,e.getRemoteImageCount(),e.getMentionTrigger(),e.attachImageFile)?(n.preventDefault(),!0):!1}}})]}})}function d0(e,t,n,r,i){let a=Array.from(t.files).find(e=>N$(e)!==null);if(a)return z0(e,n,a,i),!0;let o=Array.from(t.files).find(e=>N$(e)===null);if(o)return B0(e,o.name||`dropped-file`,r),!0;let s=m2(y2(t.getData(`text/uri-list`))||b2(t.getData(`DownloadURL`))||t.getData(`text/plain`)).trim();return s?h2(s)&&!s.includes(`
|
|
317
|
+
`)?(B0(e,s,r),!0):x2(s)&&!s.includes(`
|
|
318
|
+
`)?(L0(e,s,S2(s)),!0):!1:!1}function f0({state:e,text:t,slashCommands:n,mentionCandidates:r,triggers:i}){return e?p0(s$({initialDraft:e,slashCommands:n,commandTriggers:i.commandTriggers,mentionCandidates:r}),n,r,i):m0(t??``,n,r,i)}function p0(e,t,n,r){if(e.elements.length===0)return m0(e.text,t,n,r);let i=[],a=0;for(let o of j$(e.elements)){o.range.start>a&&i.push(...h0(e.text.slice(a,o.range.start),t,n,r.commandTriggers,r.mentionTriggers));let s=e.mentionBindings.find(e=>e.id===o.id||`${e.trigger}${e.value}`===o.label),c=e.pendingPastes.find(e=>e.placeholder===o.label);o.kind===`mention`&&s?i.push(T0(E0(s,o,n))):o.kind===`paste`&&c?i.push(D0({kind:`paste`,label:c.placeholder,detail:o.detail??`${R$(c.content)} chars`,content:c.content})):o.kind===`rich-link`?i.push(D0({kind:`rich-link`,label:o.label,detail:o.detail??``,href:o.detail??``,metadata:o.metadata})):o.kind===`link`?i.push(C0(o.label,[w0(o.detail??``)])):i.push(...h0(e.text.slice(o.range.start,o.range.end),t,n,r.commandTriggers,r.mentionTriggers)),a=o.range.end}return a<e.text.length&&i.push(...h0(e.text.slice(a),t,n,r.commandTriggers,r.mentionTriggers)),x0(i)}function m0(e,t,n,r){let i=H$({text:e,slashCommands:t,commandTriggers:r.commandTriggers,mentionCandidates:n});return(i.elements?.length??0)>0?p0(s$({initialDraft:i,slashCommands:t,commandTriggers:r.commandTriggers,mentionCandidates:n}),t,n,r):{type:`doc`,content:e.split(`
|
|
319
|
+
`).map(e=>({type:`paragraph`,content:h0(e,t,n,r.commandTriggers,r.mentionTriggers)}))}}function h0(e,t,n,r,i){return QM(e).flatMap(e=>e.kind===`inline-code`||e.kind===`code-block`||e.kind===`link`||e.kind===`skill-link`?[C0(e.source)]:g0(e.source,t,n,r,i))}function g0(e,t,n,r,i){let a=[],o=i$(r,i);if(!o)return[C0(e)];let s=0;for(let r of e.matchAll(o)){let o=r.index??0,c=r[0];if(o===0||/\s/.test(e[o-1]??``)){if(o>s&&a.push(C0(e.slice(s,o))),a$(c,i)){let e=n.find(e=>o$(e)===c);a.push(e?T0(e):C0(c))}else{let e=XQ(c.replace(/^\//,``),t);a.push(e?C0(c,[{type:`composerSlashCommand`,attrs:{value:e.value,detail:e.detail}}]):C0(c))}s=o+c.length}}return s<e.length&&a.push(C0(e.slice(s))),a}function _0(e,t,n,r,i,a){let o={text:``,elements:[],mentionBindings:[],imageAttachments:[],pendingPastes:[]};v0(e,o,n);let s=s$({text:o.text,slashCommands:n,isTaskRunning:r,queueSubmissions:i});return{...s,cursor:a,elements:p2([...s.elements,...o.elements]),mentionBindings:o.mentionBindings,imageAttachments:o.imageAttachments,remoteImages:t,pendingPastes:o.pendingPastes}}function v0(e,t,n){if(e.type===`doc`){e.content?.forEach((e,r)=>{r>0&&t.text.length>0&&(t.text+=`
|
|
320
|
+
`),v0(e,t,n)});return}if(e.type===`paragraph`){e.content?.forEach(e=>v0(e,t,n));return}if(e.type===`hardBreak`){t.text+=`
|
|
321
|
+
`;return}if(e.type===`text`){let r=e.text??``,i=t.text.length;t.text+=r;for(let a of e.marks??[])if(a.type===`link`&&a.attrs?.href&&t.elements.push({id:c1(`link`,r,i),kind:`link`,label:r,range:{start:i,end:i+r.length},detail:String(a.attrs.href)}),a.type===`composerSlashCommand`){let e=XQ(r.replace(/^\//,``),n);if(!e)continue;t.elements.push({id:c1(`slash-command`,r,i),kind:`slash-command`,label:r,range:{start:i,end:i+r.length},detail:e.detail})}return}if(e.type===`composerMention`){let n=String(e.attrs?.label??``)||`${String(e.attrs?.trigger??``)}${String(e.attrs?.value??``)}`,r=t.text.length,i=String(e.attrs?.id??c1(`mention`,n,r));t.text+=n,t.elements.push({id:i,kind:`mention`,label:n,range:{start:r,end:r+n.length},detail:String(e.attrs?.detail??``)});let a=e.attrs?.persistsAs;t.mentionBindings.push({id:i,trigger:String(e.attrs?.trigger??``),value:String(e.attrs?.value??``),payload:e.attrs?.payload,persistsAs:typeof a==`string`?a:void 0});return}if(e.type===`composerAtom`){let n=String(e.attrs?.label??``),r=b0(e.attrs?.kind),i=t.text.length,a=String(e.attrs?.attachmentId??``);if(r===`image`&&!a)return;let o=r===`image`?a:c1(r,n,i);t.text+=n;let s=r===`rich-link`?y0(e.attrs?.metadata):void 0;t.elements.push({id:o,kind:r,label:n,range:{start:i,end:i+n.length},detail:String(e.attrs?.detail||e.attrs?.href||``),...s?{metadata:s}:{}}),r===`image`&&t.imageAttachments.push({id:o,placeholder:n,media:P$(e.attrs?.media)}),r===`paste`&&t.pendingPastes.push({id:o,placeholder:n,content:String(e.attrs?.content??``)})}}function y0(e){if(!e||typeof e!=`object`)return;let t={};for(let n of[`title`,`description`,`siteName`,`domain`,`imageUrl`,`faviconUrl`]){let r=Object.entries(e).find(([e])=>e===n)?.[1];typeof r==`string`&&r.length>0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function b0(e){switch(e){case`slash-command`:case`mention`:case`image`:case`paste`:case`link`:case`rich-link`:return e;default:return`paste`}}function x0(e){return{type:`doc`,content:[{type:`paragraph`,content:e}]}}function S0(){return{type:`doc`,content:[{type:`paragraph`}]}}function C0(e,t){return t&&t.length>0?{type:`text`,text:e,marks:t}:{type:`text`,text:e}}function w0(e){return{type:`link`,attrs:{href:e}}}function T0(e){return{type:`composerMention`,attrs:{id:e.id,trigger:e.trigger,value:e.value,label:o$(e),detail:e.detail,payload:e.payload,persistsAs:e.persistsAs}}}function E0(e,t,n){let r=`${e.trigger}${e.value}`;return n.find(e=>o$(e)===t.label||o$(e)===r)||{id:e.id,trigger:e.trigger,value:e.value,label:e.value,detail:``,atomic:!0,payload:e.payload}}function D0({kind:e,label:t,detail:n=``,content:r=``,href:i=``,metadata:a}){return{type:`composerAtom`,attrs:{kind:e,label:t,detail:n,content:r,href:i,metadata:a??null}}}function O0(e,t,n=`image`){return{type:`composerAtom`,attrs:{kind:`image`,attachmentId:e,label:t,media:n}}}function k0(e,t){let{selection:n}=e.state;if(!n.empty)return null;let r=n.$from,i=r.parent.textBetween(0,r.parentOffset,void 0,``),a=r.parent.textBetween(r.parentOffset,r.parent.content.size,void 0,``),o=[...t.commandTriggers,...t.mentionTriggers];if(o.length===0)return null;let s=A0(i,a,o);if(!s)return null;let c=o.find(e=>s.token.startsWith(e));return!c||s.token.slice(c.length).includes(c)?null:{trigger:c,query:s.token,from:n.from-(i.length-s.start),to:n.from+s.tail.length}}function A0(e,t,n){let r=`(?:${t$(n)})`,i=e.search(RegExp(`(?:^|\\s|\\ufffc)(${r}[^\\s\\ufffc]*)$`));if(i===-1)return null;let a=/[\s\ufffc]/.test(e[i]??``)?i+1:i,o=t.match(/^[^\s\ufffc]*/)?.[0]??``;return{start:a,token:e.slice(a)+o,tail:o}}function j0(e,t){let n=G0(e.state.doc.toJSON(),R$(t)),r=e.state.schema.nodes.composerAtom?.create({kind:`paste`,label:n,detail:`${R$(t)} chars`,content:t});r&&e.dispatch(e.state.tr.replaceSelectionWith(r).scrollIntoView())}function M0(e){let t=e.dom.ownerDocument.getSelection();if(t&&t.rangeCount>0&&!t.isCollapsed){let n=t.getRangeAt(0);if(e.dom.contains(n.commonAncestorContainer)){let r=e.posAtDOM(n.startContainer,n.startOffset),i=e.posAtDOM(n.endContainer,n.endOffset);if(r!==i)return{from:Math.min(r,i),to:Math.max(r,i),selectedAtomLabels:N0(n,e.dom),selectedText:t.toString()}}}return e.state.selection.empty?null:{from:e.state.selection.from,to:e.state.selection.to}}function N0(e,t){return Array.from(t.querySelectorAll(`[data-composer-atom]`)).filter(t=>e.intersectsNode(t)).map(e=>e.textContent??``).filter(Boolean)}function P0(e,t,n,r){let i=F0(e.state.doc,t),a=I0(e.state.doc,i.from,i.to)||n,o=e.state.schema.text(a,[r.create({href:n})]),s=e.state.tr.replaceWith(i.from,i.to,o),c=i.from+a.length;return e.dispatch(s.setSelection(Y.create(s.doc,c)).scrollIntoView()),!0}function F0(e,t){if(!t.selectedText&&!t.selectedAtomLabels?.length)return t;let n={from:t.from,to:t.to},r=!0;for(;r;)r=!1,e.nodesBetween(0,e.content.size,(e,i)=>{if(e.type.name!==`composerAtom`)return!0;let a=String(e.attrs.label??``),o=t.selectedText?.includes(a)||t.selectedAtomLabels?.includes(a);if(!a||!o)return!1;let s={from:i,to:i+e.nodeSize};if(!(s.from<=n.to+1&&s.to>=n.from-1))return!1;let c=Math.min(n.from,s.from),l=Math.max(n.to,s.to);return(c!==n.from||l!==n.to)&&(n={from:c,to:l},r=!0),!1});return n}function I0(e,t,n){let r=``;return e.nodesBetween(t,n,(e,i)=>{if(e.isText){let a=e.text??``,o=Math.max(t-i,0),s=Math.min(n-i,a.length);return r+=a.slice(o,s),!1}return e.type.name===`composerMention`?(r+=String(e.attrs.label??``),!1):e.type.name===`composerAtom`?(e.attrs.kind===`rich-link`&&(r+=String(e.attrs.label??``)),!1):e.type.name===`hardBreak`?(r+=`
|
|
322
|
+
`,!1):!0}),r.replace(/\n+/g,` `).trim()}function L0(e,t,n){let r=e.state.schema.marks.link;if(!r)return!1;let{from:i,to:a}=e.state.selection,o=e.state.tr.insertText(t,i,a);return o.addMark(i,i+t.length,r.create({href:n})),e.dispatch(o.scrollIntoView()),!0}function R0(e,t,n){e.dispatch(e.state.tr.replaceWith(n.from,n.to,e.state.schema.text(t)).scrollIntoView())}function z0(e,t,n,r){let i=r(n);if(i===null)return;let a=t+K0(e.state.doc.toJSON(),`image`)+1,o=N$(n)??`image`,s=e.state.schema.nodeFromJSON(O0(i,F$(o,a),o));if(!s)return;let c=e.state.tr.replaceSelectionWith(s);c=c.insertText(` `,c.selection.from),e.dispatch(c.scrollIntoView())}function B0(e,t,n){let r=g2(t),i=_2(r),a=`${n}${i}`,o=e.state.schema.nodes.composerMention?.create({id:c1(`mention`,a,e.state.selection.from),trigger:n,value:i,label:a,detail:v2(r)?`directory`:`file`,payload:{path:r,type:v2(r)?`directory`:`file`}});if(!o)return;let s=e.state.tr.replaceSelectionWith(o);s=s.insertText(` `,s.selection.from),e.dispatch(s.scrollIntoView())}function V0(e,t){let n=0;return H0(e,e=>e.type!==`composerAtom`||e.attrs?.kind!==`image`?e:(n+=1,{...e,attrs:{...e.attrs,label:F$(P$(e.attrs?.media),t+n)}}))}function H0(e,t){let n=t(e);return{...n,content:n.content?.map(e=>H0(e,t))}}function U0(e,t){return W0(e,e=>e.type!==`composerAtom`||e.attrs?.kind!==`image`||e.attrs?.attachmentId!==t)}function W0(e,t){return{...e,content:e.content?.filter(t).map(e=>W0(e,t))}}function G0(e,t){let n=`[Pasted Content ${t} chars]`,r=new Set;if(q0(e,e=>{e.type===`composerAtom`&&e.attrs?.kind===`paste`&&r.add(String(e.attrs.label??``))}),!r.has(n))return n;let i=2;for(;r.has(`${n} #${i}`);)i+=1;return`${n} #${i}`}function K0(e,t){let n=0;return q0(e,e=>{e.type===`composerAtom`&&e.attrs?.kind===t&&(n+=1)}),n}function q0(e,t){t(e),e.content?.forEach(e=>q0(e,t))}function J0(e){let{selection:t}=e.state,n=t.from;return r2(e,n,t.empty?t.$from.end():t.to)}function Y0(e){let{selection:t}=e.state,n=t.empty?$0(e,t.from):t.from,r=t.to;return r2(e,n,r)}function X0(e){let{selection:t}=e.state;if(!t.empty)return r2(e,t.from,t.to);let n=t.$from.parent.textBetween(0,t.$from.parentOffset,void 0,i2),r=a1(n,n.length);return r2(e,t2(t.$from.parent,t.$from.start(),r),t.from)}function Z0(e){let t=e.state.selection.to,n=e2(e,t),r=e.state.tr.setSelection(Y.create(e.state.doc,n)).scrollIntoView();e.view.dispatch(r),e.view.focus()}function Q0(e,t){let{selection:n}=e.state,r=t===-1?n.from:n.to,i=e.state.doc.resolve(r),a=i.parent.textBetween(0,i.parent.content.size,void 0,i2),o=i.parent.textBetween(0,i.parentOffset,void 0,i2).length,s=t===-1?a1(a,o):o1(a,o),c=t2(i.parent,i.start(),s),l=e.state.tr.setSelection(Y.create(e.state.doc,c)).scrollIntoView();e.view.dispatch(l),e.view.focus()}function $0(e,t){let{selection:n}=e.state,r=n.$from.start();return e.state.doc.nodesBetween(r,t,(e,t)=>{e.type.name===`hardBreak`&&(r=t+e.nodeSize)}),r}function e2(e,t){let n=e.state.doc.resolve(t).end();return e.state.doc.nodesBetween(t,n,(e,r)=>e.type.name===`hardBreak`&&r>=t?(n=r,!1):!0),n}function t2(e,t,n){let r=0,i=t;for(let t=0;t<e.childCount;t+=1){let a=e.child(t),o=n2(a);if(o===null){i+=a.nodeSize;continue}let s=r+o.length;if(n<=s)return a.isText?i+n-r:n===s?i+a.nodeSize:i;r=s,i+=a.nodeSize}return i}function n2(e){return e.isText?e.text??``:e.type.name===`hardBreak`?`
|
|
323
|
+
`:e.type.name===`composerMention`||e.type.name===`composerAtom`?i2(e):null}function r2(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
|
+
`,i2),slice:r.toJSON()};return e.chain().focus().deleteRange({from:t,to:n}).run(),i}function i2(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 a2(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 o2(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||!s2(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 s2(e){return e.isAtom&&(e.type.name===`composerMention`||e.type.name===`composerAtom`)}function c2(e){try{return e.state.doc.textBetween(0,e.state.selection.from,`
|
|
325
|
+
`,``).length}catch{return 0}}function l2(e){return e.state.selection.empty&&c2(e)===0}function u2(e,t){return a$(e.persistedPrompt,t)?`ParseSlash`:e.action}function d2(e){return e.key===`ArrowUp`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`p`}function f2(e){return e.key===`ArrowDown`||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`n`}function p2(e){let t=new Map;for(let n of e)t.set(`${n.kind}:${n.range.start}:${n.range.end}:${n.label}`,n);return j$([...t.values()])}function m2(e){return e.replace(/\r\n?/g,`
|
|
326
|
+
`)}function h2(e){return e.startsWith(`file://`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||/^[A-Za-z]:[\\/]/.test(e)}function g2(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 _2(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??e}function v2(e){return/[\\/]$/.test(e)}function y2(e){return e.split(/\r?\n/).map(e=>e.trim()).find(e=>e&&!e.startsWith(`#`))??``}function b2(e){let t=y2(e);return t?t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim()??t:``}function x2(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function S2(e){return G$(e.trim())}function C2(e){let t=(0,G.c)(3),n=e.draftKey??``,r;return t[0]!==e||t[1]!==n?(r=(0,z.jsx)(T2,{...e},n),t[0]=e,t[1]=n,t[2]=r):r=t[2],r}function w2(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function T2({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=ln(),h=M1(l),g=(0,R.useRef)({signature:N1(h),slashCommands:h.slashCommands,mentionCandidates:h.mentionCandidates,commandTriggers:h.commandTriggers,mentionTriggers:h.mentionTriggers}),_=N1(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=x1(t);return n?U$({source:n,slashCommands:v,mentionCandidates:y}):void 0}),T=(0,R.useRef)(w?.remoteImages??[]),E=(0,R.useRef)(f0({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)(()=>_0(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=iq({extensions:(0,R.useMemo)(()=>i0({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?R1(ne,v,y,a):[],[ne,a,y,v]),Se=(0,R.useMemo)(()=>l$(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||!c$(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?S1(t,B$(re,Se.persistedPrompt)):D.current===0&&S1(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=_0(e.getJSON(),ie.current,v,r,i,c2(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&&c$(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=k0(e,S);if(!t){k(null);return}if(b.includes(t.trigger)){let e={trigger:t.trigger,query:t.query,selectedIndex:0},n=R1(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=R1(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=k0(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=R1(t,v,y,a),i=r[e]??r[0];if(!i)return;if(!i.atomic){we(i);return}let o=k0(P,S),s=o?.trigger===t.trigger,c=P.chain().focus();s&&o&&c.deleteRange({from:o.from,to:o.to}),c.insertContent([T0(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 c$(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(N$(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=N$(t)??`image`;e.chain().focus().insertContent([O0(n,F$(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(V0(U0(P.getJSON(),e),ie.current.length)))}function Ie(e){if(n||!P)return;let t=[...ie.current,{id:c1(`remote-image`,e,m.Date.now()),url:e}];ie.current=t,O(t),Ce(V0(P.getJSON(),t.length))}function Le(e){return n||!P?!1:d0(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=L$({...t,selectedRemoteImageId:r},r);if(n!==null)return e.preventDefault(),Re(Math.max(0,n-1)),!0;if((P&&l2(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=L$({...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(V0(P.getJSON(),i.length)),A(e=>({...e,remoteImages:i,selectedRemoteImageId:a?.id??null,shortcutsOpen:!1}))}function Ue(e){if(n||!P)return;let t=G0(P.getJSON(),R$(e));P.chain().focus().insertContent(D0({kind:`paste`,label:t,detail:`${R$(e)} chars`,content:e})).run()}function We(e,t=e,r){n||P?.chain().focus().insertContent(D0({kind:`rich-link`,label:t,detail:e,href:e,metadata:r})).run()}function Ge(){return P?{..._0(P.getJSON(),ie.current,v,r,i,c2(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()??S0(),i=e.isTaskRunning||e.queueSubmissions,a=i?null:h$(e.text,v,b);if(a){A(e=>({...e,error:`Unrecognized command: /${a}`,shortcutsOpen:!1})),k(null);return}let s=l$(e,v,b),c=s??{mode:`submitted`,prompt:``,persistedPrompt:``,historyPrompt:``,action:`Plain`,command:void 0,args:void 0,items:[],elements:[],payloadElements:[],mentionBindings:[]},l=u$(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?u2(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=B$(e,c.persistedPrompt),g=fe.current?.(p,{editableSource:h});w2(g)&&(D.current+=1,g.then(()=>{t!==void 0&&S1(t,null)}).catch(e=>{for(let[e,t]of u)pe.current.set(e,t);t!==void 0&&S1(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?V$(e,c.historyPrompt):e.history;N.current=null,ie.current=[],O([]),k(null),Ce(S0()),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:s1(r+e,t.history.length);r===null&&(ce.current=z$(Ge()));let a=t.history[i];Qe(a,i)}function Qe(e,t){F(U$({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(f0({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=r1(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=r1(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=U$({source:e,slashCommands:v,mentionCandidates:y}),a=i.remoteImages??[];ie.current=a,O(a),Ce(f0({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(f0({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(Y2(e)){e.preventDefault(),P.chain().focus().setHardBreak().run(),N.current=null,k(null);return}if(M.current){if(d2(e)||f2(e)){e.preventDefault(),st(d2(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(X2(e)){let t=X0(P);t&&(e.preventDefault(),ae.current=t,A(e=>({...e,killBuffer:t.text}))),N.current=null;return}let t=Z2(e);if(t!==null){e.preventDefault(),Q0(P,t),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`e`){e.preventDefault(),Z0(P),N.current=null;return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){let t=J0(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=Y0(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(),a2(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`)&&$2(P)){e.preventDefault(),N.current=null,k(null);return}if((e.key===`Backspace`||e.key===`Delete`)&&o2(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=Q2(e);if(r!==null&&!M.current){let t=Ge();if(e.key===`ArrowUp`&&(l2(P)||t.cursor===0)&&t.remoteImages.length>0){e.preventDefault(),Re(t.remoteImages.length-1);return}i1(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=R1(t,v,y,a).length;return n===0?t:{...t,selectedIndex:s1(t.selectedIndex+e,n)}})}let ct=r0({dictation:u,disabled:n,insertTranscript:qe,submitDraft:Ye});return(0,z.jsx)(LQ,{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)(B1,{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)(E2,{})]})})})})}function E2(){let e=(0,G.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(N2,{}),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)(D2,{children:[(0,z.jsx)(k2,{}),(0,z.jsx)(BQ,{}),(0,z.jsx)(j2,{}),(0,z.jsx)(M2,{})]}),(0,z.jsx)(L2,{}),(0,z.jsx)(B2,{})]}),e[1]=n):n=e[1],n}function D2(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 O2(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 k2(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}=RQ(`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 A2(e){e.dataTransfer.types.includes(`Files`)&&e.preventDefault()}function j2(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}=RQ(`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),A2(e)},t[11]=r,t[12]=g);let _;t[13]===i?_=t[14]:(_=e=>{i?.(e),A2(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)(ZK,{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 M2(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}=RQ(`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 N2(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}=RQ(`Composer.Popup`),{acceptSuggestion:s}=o;if(!i)return null;let c;t[3]===a?c=t[4]:(c=a.some(P2),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)(F2,{selected:t===i.selectedIndex,icon:l?e.icon:null,token:o$(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 P2(e){return e.icon}function F2(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 I2=[{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 L2(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}=RQ(`Composer.Shortcuts`),{closeShortcuts:o}=a;if(!i.shortcutsOpen||!c$(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:I2.map(R2)}),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 R2(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(z2)})]},e.title)}function z2(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 B2(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}=RQ(`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(V2),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 V2(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 H2(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}=RQ(`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)(J2,{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 U2(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}=RQ(`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)(J2,{action:a,...n}),t[6]=n,t[7]=a,t[8]=o):o=t[8],o}function W2(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}=RQ(`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)(J2,{action:a,...r}),t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function G2(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}=RQ(`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)(J2,{action:s,...a}),t[10]=a,t[11]=s,t[12]=c):c=t[12],c}function K2(e){let t=(0,G.c)(3),{actions:n}=RQ(`Composer.Submit`),r;return t[0]!==n.submit||t[1]!==e?(r=(0,z.jsx)(J2,{action:n.submit,...e}),t[0]=n.submit,t[1]=e,t[2]=r):r=t[2],r}function q2(e){let t=(0,G.c)(3),{actions:n}=RQ(`Composer.Reset`),r;return t[0]!==n.reset||t[1]!==e?(r=(0,z.jsx)(J2,{action:n.reset,...e}),t[0]=n.reset,t[1]=e,t[2]=r):r=t[2],r}function J2(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}=RQ(`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 Y2(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 X2(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 Z2(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 Q2(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 $2(e){let{doc:t,selection:n}=e.state;return n.empty||n.from>1||n.to<t.content.size-1?!1:(e.commands.setContent(S0(),{emitUpdate:!0}),e.commands.focus(`start`),e.commands.setTextSelection(1),!0)}var e4={Root:C2,Trigger:k1,Command:A1,Mention:j1,Content:D2,Toolbar:O2,RemoteImages:k2,Attachments:BQ,Editor:j2,Error:M2,Popup:N2,Shortcuts:L2,Footer:B2,AttachFiles:H2,AddRemoteImage:U2,InsertPaste:W2,InsertRichLink:G2,Dictate:G1,CancelDictation:K1,Submit:K2,Reset:q2};(0,R.createContext)(null);function t4(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 n4(e){let t=(0,G.c)(6),{text:n}=e,r,i;if(t[0]!==n){let e=QM(n);r=a4,i=e.map(r4),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 r4(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)(i4,{name:e.name,source:e.source,skillId:e.skillId,title:e.href},e.start);case`standalone-skill`:return(0,z.jsx)(i4,{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 i4(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 a4(e){let t=t4(e.currentTarget,window.getSelection());t!==null&&(e.clipboardData.setData(`text/plain`,t),e.preventDefault())}var o4=typeof global==`object`&&global&&global.Object===Object&&global,s4=typeof self==`object`&&self&&self.Object===Object&&self,c4=o4||s4||Function(`return this`)(),l4=c4.Symbol,u4=Object.prototype,d4=u4.hasOwnProperty,f4=u4.toString,p4=l4?l4.toStringTag:void 0;function m4(e){var t=d4.call(e,p4),n=e[p4];try{e[p4]=void 0;var r=!0}catch{}var i=f4.call(e);return r&&(t?e[p4]=n:delete e[p4]),i}var h4=Object.prototype.toString;function g4(e){return h4.call(e)}var _4=`[object Null]`,v4=`[object Undefined]`,y4=l4?l4.toStringTag:void 0;function b4(e){return e==null?e===void 0?v4:_4:y4&&y4 in Object(e)?m4(e):g4(e)}function x4(e){return typeof e==`object`&&!!e}var S4=`[object Symbol]`;function C4(e){return typeof e==`symbol`||x4(e)&&b4(e)==S4}function w4(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 T4=Array.isArray,E4=1/0,D4=l4?l4.prototype:void 0,O4=D4?D4.toString:void 0;function k4(e){if(typeof e==`string`)return e;if(T4(e))return w4(e,k4)+``;if(C4(e))return O4?O4.call(e):``;var t=e+``;return t==`0`&&1/e==-E4?`-0`:t}function A4(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var j4=`[object AsyncFunction]`,M4=`[object Function]`,N4=`[object GeneratorFunction]`,P4=`[object Proxy]`;function F4(e){if(!A4(e))return!1;var t=b4(e);return t==M4||t==N4||t==j4||t==P4}var I4=c4[`__core-js_shared__`],L4=function(){var e=/[^.]+$/.exec(I4&&I4.keys&&I4.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function R4(e){return!!L4&&L4 in e}var z4=Function.prototype.toString;function B4(e){if(e!=null){try{return z4.call(e)}catch{}try{return e+``}catch{}}return``}var V4=/[\\^$.*+?()[\]{}|]/g,H4=/^\[object .+?Constructor\]$/,U4=Function.prototype,W4=Object.prototype,G4=U4.toString,K4=W4.hasOwnProperty,q4=RegExp(`^`+G4.call(K4).replace(V4,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function J4(e){return!A4(e)||R4(e)?!1:(F4(e)?q4:H4).test(B4(e))}function Y4(e,t){return e?.[t]}function X4(e,t){var n=Y4(e,t);return J4(n)?n:void 0}function Z4(e,t){return e===t||e!==e&&t!==t}var Q4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$4=/^\w*$/;function e3(e,t){if(T4(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||C4(e)?!0:$4.test(e)||!Q4.test(e)||t!=null&&e in Object(t)}var t3=X4(Object,`create`);function n3(){this.__data__=t3?t3(null):{},this.size=0}function r3(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var i3=`__lodash_hash_undefined__`,a3=Object.prototype.hasOwnProperty;function o3(e){var t=this.__data__;if(t3){var n=t[e];return n===i3?void 0:n}return a3.call(t,e)?t[e]:void 0}var s3=Object.prototype.hasOwnProperty;function c3(e){var t=this.__data__;return t3?t[e]!==void 0:s3.call(t,e)}var l3=`__lodash_hash_undefined__`;function u3(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=t3&&t===void 0?l3: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=n3,d3.prototype.delete=r3,d3.prototype.get=o3,d3.prototype.has=c3,d3.prototype.set=u3;function f3(){this.__data__=[],this.size=0}function p3(e,t){for(var n=e.length;n--;)if(Z4(e[n][0],t))return n;return-1}var m3=Array.prototype.splice;function h3(e){var t=this.__data__,n=p3(t,e);return n<0?!1:(n==t.length-1?t.pop():m3.call(t,n,1),--this.size,!0)}function g3(e){var t=this.__data__,n=p3(t,e);return n<0?void 0:t[n][1]}function _3(e){return p3(this.__data__,e)>-1}function v3(e,t){var n=this.__data__,r=p3(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=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=f3,y3.prototype.delete=h3,y3.prototype.get=g3,y3.prototype.has=_3,y3.prototype.set=v3;var b3=X4(c4,`Map`);function x3(){this.size=0,this.__data__={hash:new d3,map:new(b3||y3),string:new d3}}function S3(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function C3(e,t){var n=e.__data__;return S3(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function w3(e){var t=C3(this,e).delete(e);return this.size-=+!!t,t}function T3(e){return C3(this,e).get(e)}function E3(e){return C3(this,e).has(e)}function D3(e,t){var n=C3(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function O3(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])}}O3.prototype.clear=x3,O3.prototype.delete=w3,O3.prototype.get=T3,O3.prototype.has=E3,O3.prototype.set=D3;var k3=`Expected a function`;function A3(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(k3);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(A3.Cache||O3),n}A3.Cache=O3;var j3=500;function M3(e){var t=A3(e,function(e){return n.size===j3&&n.clear(),e}),n=t.cache;return t}var N3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,P3=/\\(\\)?/g,F3=M3(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(N3,function(e,n,r,i){t.push(r?i.replace(P3,`$1`):n||e)}),t});function I3(e){return e==null?``:k4(e)}function L3(e,t){return T4(e)?e:e3(e,t)?[e]:F3(I3(e))}var R3=1/0;function z3(e){if(typeof e==`string`||C4(e))return e;var t=e+``;return t==`0`&&1/e==-R3?`-0`:t}function B3(e,t){t=L3(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[z3(t[n++])];return n&&n==r?e:void 0}function V3(e,t,n){var r=e==null?void 0:B3(e,t);return r===void 0?n:r}function H3(e){if(!e)return{};let t={...e};return delete t.whenNullish,delete t.locale,t}function U3(e,t){return e==null||Number.isNaN(e)?t?.whenNullish??`—`:new Intl.NumberFormat(t?.locale??`en-US`,H3(t)).format(e)}var W3=U3;function G3(e,t){return U3(e,{notation:`compact`,maximumFractionDigits:1,...t})}var K3=`pending-chat-prefill`;function q3(){try{let e=sessionStorage.getItem(K3);return e?JSON.parse(e):null}catch{return sessionStorage.removeItem(K3),null}}function J3(e){sessionStorage.setItem(K3,JSON.stringify(e))}function Y3(){sessionStorage.removeItem(K3)}function X3(e){let t=Kh(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 Z3=class{chat;uploadFile;submissions=new ay;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&&J3({prompt:e,targetChatId:t}),this.onResetChat(t)}consumePrefill(e){let t=q3();!t||t.targetChatId!==e||(Y3(),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 Q3(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 $3(e){let t=Uy({id:e.chatId,messages:e.initialMessages,transport:e.transport,throttle:50,experimental_queue:!0,resume:e.resume,onData:e.onData,onFinish:e.onFinish,sendAutomaticallyWhen:e6,onToolCall(n){let{toolCall:r}=n;Q3(t,e.registry,r)}});return t}function e6(e){return My(e)||jy(e)}function t6(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(n6,{...e}),t[0]=e,t[1]=n),n}function n6(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}=jj(n),{hasSubmitted:a}=g6(),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 r6(e){let t=(0,G.c)(12),{hasSubmitted:n}=g6(),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)(Tj.div,{layout:!0,className:r,transition:i,children:s}),t[9]=r,t[10]=s,t[11]=c):c=t[11],c}r6.displayName=`AgentHeader.Root`;function i6(e){let t=(0,G.c)(6),{hasSubmitted:n}=g6(),r;t[0]!==n||t[1]!==e.children||t[2]!==e.icon?(r=!n&&(0,z.jsx)(Tj.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)(kk,{mode:`sync`,children:r}),t[4]=r,t[5]=i),i}i6.displayName=`AgentHeader.Hero`;function a6(e){let t=(0,G.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,z.jsx)(Tj.h2,{layout:`position`,className:`text-muted-foreground text-sm font-medium`,children:e.children}),t[0]=e.children,t[1]=n),n}a6.displayName=`AgentHeader.Title`;function o6(e){let t=(0,G.c)(5),{hasSubmitted:n}=g6(),r;t[0]!==n||t[1]!==e.children?(r=n&&!!e.children&&(0,z.jsx)(Tj.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)(kk,{children:r}),t[3]=r,t[4]=i),i}o6.displayName=`AgentHeader.Description`;var s6={Root:r6,Hero:i6,Title:a6,Description:o6},c6=(0,R.createContext)(void 0),l6=(0,R.createContext)(`ready`),u6=(0,R.createContext)(void 0),d6=(0,R.createContext)(null),f6=(0,R.createContext)(void 0);function p6({chatId:e,children:t,skipInitialView:n,debugMode:r,registry:i,initialMessages:a,transport:o,resume:s,onData:c,onFinish:l,onResetChat:u}){let d=$3({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 Z3({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)(d6,{value:_,children:(0,z.jsx)(c6,{value:y,children:(0,z.jsx)(l6,{value:d.status,children:(0,z.jsx)(u6,{value:b,children:(0,z.jsx)(f6,{value:S,children:t})})})})})}function m6(){let e=(0,R.use)(c6);if(e===void 0)throw Error(`useAgent must be used within an AgentProvider`);return e}function h6(){return{status:(0,R.use)(l6)}}function g6(){let e=(0,R.use)(f6);if(e===void 0)throw Error(`useAgentMeta must be used within an AgentProvider`);return e}function _6(){let e=(0,R.use)(u6);if(e===void 0)throw Error(`useAgentMessages must be used within an AgentProvider`);return e}function v6(e){return(e??[]).filter(e=>e.source.sourceType===`url`)}function y6(e){let t=new Set,n=[],r=(e,r)=>{t.has(e)||(t.add(e),n.push({url:e,title:r}))};for(let t of e)for(let e of t.parts){if(e.type===`text`)for(let{source:t}of v6(e.citations))r(t.url,t.title);e.type===`source-url`&&r(e.url,e.title)}return n}function b6(e,t){let n=e.findIndex(e=>e.url===t);return n===-1?null:n+1}function x6(e,t){return t===`streaming`||t===`submitted`?!1:e===`input-streaming`||e===`input-available`}function S6(e,t){return x6(e.state,t)}function C6(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 w6(e){let t=(0,G.c)(11),{children:n,as:r,className:i,duration:a,enabled:o}=e,s=r===void 0?`p`:r,c=o===void 0||o,l=c&&`shimmer`,u;t[0]!==i||t[1]!==l?(u=I(l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d;t[3]!==a||t[4]!==c?(d=c&&a!==void 0?{animationDuration:`${a}s`}:void 0,t[3]=a,t[4]=c,t[5]=d):d=t[5];let f;return t[6]!==s||t[7]!==n||t[8]!==u||t[9]!==d?(f=(0,z.jsx)(s,{className:u,style:d,children:n}),t[6]=s,t[7]=n,t[8]=u,t[9]=d,t[10]=f):f=t[10],f}function T6(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 E6(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 D6=(0,R.createContext)(void 0),O6=(0,R.createContext)(void 0);function k6(){let e=(0,R.use)(D6);if(!e)throw Error(`useMessagesContext must be used within <Messages>`);return e}function A6(){let e=(0,R.use)(D6),{status:t}=h6();return e?.status??t}function j6(){let e=(0,R.use)(O6);if(!e)throw Error(`useMessageItem must be used within <Messages.Item>`);return e}function M6({source:e,index:t,labels:n={source:`Source ${t}`,open:`Open the source`},children:r}){let i=URL.parse(e.url)?.hostname??e.url;return(0,z.jsx)(`sup`,{className:`ml-0.5 inline-block`,children:(0,z.jsxs)(Fo,{children:[(0,z.jsx)(Io,{openOnHover:!0,"aria-label":n.source,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:t}),(0,z.jsxs)(Lo,{className:`w-72 gap-2 text-sm`,children:[(0,z.jsxs)(Ro,{children:[(0,z.jsx)(zo,{dir:`auto`,children:e.title??i}),e.title?(0,z.jsx)(Bo,{dir:`auto`,children:i}):null]}),r,(0,z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline`,children:n.open})]})]})})}function N6(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}N6.displayName=`TablePanel.Root`;function P6(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 F6(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 I6(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 L6(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 R6(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 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 B6=Object.assign(N6,{Header:P6,Heading:F6,Title:I6,Description:L6,Actions:R6,Content:z6}),V6=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>/g,H6=/\b([\w-]+)="((?:\\.|[^"])*)"/g;function U6(e){return e.replace(V6,e=>e.replace(H6,(e,t,n)=>`${t}="${n.replace(/\\"/g,`"`)}"`))}function W6(e,t){if(typeof e!=`string`)return e;let n=U6(Z6(e,q6(t))).replace(/<(\w[\w-]*)((?:\s+[\w-]+="[^"]*")+)\s*(\/?>)/g,(e,t,n,r)=>`<${t}${n.replace(/\s+/g,` `).replace(/"([^"]*)"/g,(e,t)=>`"${t.replace(/\*/g,`*`)}"`)}${r}`);return n=n.replace(/\/>(\s*)</g,(e,t,n,r)=>!t.includes(`
|
|
327
|
+
`)&&K6(r,n)?e:`/>
|
|
328
|
+
|
|
329
|
+
<`),Q6(n,t)}var G6=/<\w[\w-]*(?:"(?:\\.|[^"])*"|[^>"])*>|<\/[\w-]+\s*>/g;function K6(e,t){let n=e.lastIndexOf(`
|
|
330
|
+
`,t-1)+1,r=e.indexOf(`
|
|
331
|
+
`,t);return e.slice(n,r<0?e.length:r).replace(G6,``).trim()!==``}function q6(e){let t=e?.length?new Set(e):null;return t?e=>t.has(e):e=>e.includes(`-`)}var J6=/<([\w-]+)((?:\s+[\w-]+=(?:[“”][^“”]*[“”]|[‘’][^‘’]*[‘’]|"[^"]*"|'[^']*'))+)\s*(\/?>)/g,Y6=/([\w-]+)=(?:[“”]([^“”]*)[“”]|[‘’]([^‘’]*)[‘’])/g;function X6(e){return e.replace(Y6,(e,t,n,r)=>`${t}="${(n??r??``).replace(/"/g,`"`)}"`)}function Z6(e,t){return e.replace(J6,(e,n,r,i)=>t(n)?`<${n}${X6(r)}${i}`:e)}function Q6(e,t,n=!1){let r=q6(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=$6(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>`:K6(e,a)?i+=`<span>`+t.slice(0,-2).trimEnd()+`></`+s+`></span>`:(i+=t,e[c+1]===`
|
|
332
|
+
`&&c+2<e.length&&e[c+2]!==`
|
|
333
|
+
`&&(i+=`
|
|
334
|
+
`)),a=c+1;continue}let l=e8(e,c+1,s);if(!l){if(n){let n=e.slice(a,c+1),r=Q6(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=Q6(d,t,!0);n?i+=`<div>`+u+p+f+`</div>`:i=t8(i)+`<div>`+u+p+f+`</div>`,a=l.end}return i}function $6(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 e8(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=$6(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=$6(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=$6(e,t);i=n<0?t+1:n+1}else i=t+1}return null}function t8(e){return e.length===0?`
|
|
335
|
+
|
|
336
|
+
`:e.endsWith(`
|
|
337
|
+
|
|
338
|
+
`)?e:e.endsWith(`
|
|
339
|
+
`)?e+`
|
|
340
|
+
`:e+`
|
|
341
|
+
|
|
342
|
+
`}var n8=`response-table-panel`,r8=[`title`,`description`],i8=I(qe({variant:`ghost`,size:`icon-sm`})),a8=Pr().use(Hr).use(Br).use(KM),o8=e=>{let t=Mr(e),n=l8(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 s8(e){return e?.type===`leafDirective`&&`name`in e&&e.name===`table`}function c8(e,t){if(t===void 0)return;let n=e[t-1];return s8(n)?n:void 0}function l8(e){let t=[];return Kr(a8.parse(e),`table`,(e,n,r)=>{if(!r)return;let i=c8(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 u8(e,t){return e.attributes?.[t]?.trim()||void 0}function d8(e){let t=a8.parse(e),n=!1;if(Kr(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=[u8(e,`title`),u8(e,`description`)].filter(Boolean).join(` `);e.children=a?[{type:`text`,value:a}]:[]}),n)return Vr(kr(t,{includeHtml:!1}))}function f8(e){let t=(0,G.c)(2),n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(Nr,{...e}),t[0]=e,t[1]=n),n}function p8(e){function t(t){let n=(0,G.c)(6),r;n[0]!==t.content||n[1]!==t.dir?(r=d8(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 m8(e,t){let n=t&&u8(t,`title`),r=t&&u8(t,`description`),i={...n?{title:n}:{},...r?{description:r}:{}};return{type:`tablePanel`,data:{hName:n8,...Object.keys(i).length>0?{hProperties:i}:{}},children:[e]}}function h8(){return e=>{Kr(e,`table`,(e,t,n)=>{if(t===void 0||!n)return;let r=c8(n.children,t),i=r?t-1:t,a=r?2:1;return n.children.splice(i,a,m8(e,r)),[Or,i+1]})}}var g8=[...Object.values(zr),KM,h8],_8=R.createContext({actions:null,controls:!0});function v8(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 y8(e){return e===!1?!1:e===!0||e===void 0?{table:!1}:{...e,table:!1}}function b8(e){let t=(0,G.c)(21),{children:n,className:r,title:i,description:a}=e,{actions:o,controls:s}=R.use(_8),c;t[0]===s?c=t[1]:(c=v8(s,`copy`),t[0]=s,t[1]=c);let l=c,u;t[2]===s?u=t[3]:(u=v8(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)(B6.Header,{className:I(!f&&`justify-end`),children:[f&&(0,z.jsxs)(B6.Heading,{children:[i&&(0,z.jsx)(B6.Title,{children:i}),a&&(0,z.jsx)(B6.Description,{className:I(i&&`mt-1`),children:a})]}),p&&(0,z.jsxs)(B6.Actions,{"data-copy-exclude":`assistant-snapshot`,children:[l&&(0,z.jsx)(Ur,{className:i8}),d&&(0,z.jsx)(Ar,{className:i8}),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)(B6.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)(B6,{"data-streamdown":`table-wrapper`,className:m,children:[h,_]}),t[17]=m,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function x8(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=g8;break bb0}let e;t[11]===u?e=t[12]:(e=[...u,KM,h8],t[11]=u,t[12]=e),f=e}let p=f,m;t[13]===r?m=t[14]:(m={...r,[n8]:r8},t[13]=r,t[14]=m);let h=m,g;t[15]===a?g=t[16]:(g={...a,[n8]:b8},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??f8,r;t[20]===e?r=t[21]:(r=p8(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=d8(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=y8(o),t[25]=o,t[26]=w);let T;t[27]!==i||t[28]!==h?(T=W6(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)(Wr,{allowedTags:h,BlockComponent:x,components:_,controls:w,dir:C,mode:c,parseMarkdownIntoBlocksFn:o8,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)(_8,{value:y,children:E}),t[40]=E,t[41]=y,t[42]=D):D=t[42],D}var S8=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}},C8=(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(`size-full space-y-2 [&>*: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)(S8,{children:(0,z.jsx)(x8,{className:i,dir:`auto`,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a});C8.displayName=`Response`;function w8(e){let t=(0,G.c)(9),n=e===void 0?2e3:e,r=ln(),[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 T8=(0,R.createContext)({code:``}),E8=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=ah(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(O8),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)(T8,{value:d,children:h}),t[21]=d,t[22]=h,t[23]=g):g=t[23],g},D8=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=w8(n),{code:c}=(0,R.use)(T8),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 O8(e,t){return(0,z.jsx)(Oa,{children:e},t)}var k8=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},A8=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)(Xr,{className:`size-4 text-blue-600`}),"output-available":(0,z.jsx)(Xr,{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]]}),j8=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??kv(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=A8(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},M8=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},N8=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)(E8,{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},P8=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=F8(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 F8(e){return typeof e==`string`?(0,z.jsx)(E8,{code:e,language:`json`}):(0,R.isValidElement)(e)?(0,z.jsx)(`div`,{children:e}):typeof e==`object`?(0,z.jsx)(E8,{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 I8(e){let t=(0,G.c)(20),{part:n}=e,r;t[0]===n?r=t[1]:(r=kv(n),t[0]=n,t[1]=r);let i=`Executing ${r}`,a;t[2]!==n||t[3]!==i?(a=(0,z.jsx)(j8,{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)(N8,{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)(C8,{className:`break-all`,children:s}),t[9]=s,t[10]=c);let l;t[11]!==n.errorText||t[12]!==c?(l=(0,z.jsx)(P8,{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)(M8,{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)(k8,{"data-copy-exclude":`assistant-snapshot`,children:[a,u]}),t[17]=a,t[18]=u,t[19]=d):d=t[19],d}function L8(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)(j8,{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)(N8,{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)(C8,{className:`break-all`,children:o}),t[7]=o,t[8]=s);let c;t[9]!==n.errorText||t[10]!==s?(c=(0,z.jsx)(P8,{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)(M8,{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)(k8,{"data-copy-exclude":`assistant-snapshot`,children:[i,l]}),t[15]=i,t[16]=l,t[17]=u):u=t[17],u}var R8=(0,R.createContext)(!1);function z8(e){return e.parts.filter(Cv).map(e=>e.text).join(`
|
|
343
|
+
`)}function B8(){return(0,R.use)(R8)}function V8(e){return Dv(e)&&e.toolMetadata?.kind===`subagent`}function H8(e,t){let n=Ov(e);return{toolKey:n,toolEntry:t?.[n]}}function U8(e,t){return e?.static===!1&&!!e?.requiresUserInput&&t===`input-available`}var W8=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 G8(e){if(!R.isValidElement(e))return!1;let t=typeof e.type==`string`?e.type:e.props.node?.tagName;return t===void 0||!W8.has(t)}function K8(e){let t=(0,G.c)(6),{children:n,dir:r}=e,i=R.Children.toArray(n);if(!i.some(G8)){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(G8))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 q8={p:({children:e,dir:t})=>(0,z.jsx)(K8,{dir:t,children:e})};function J8(e){let t={...q8},n={};for(let r of e)Lj(r),t[r.name]=r.component,n[r.name]=r.allowedAttributes;return{components:t,allowedTags:n}}function Y8(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=J8(i),t[5]=i,t[6]=a);let o=a,s;return t[7]!==r||t[8]!==o?(s=(0,z.jsx)(C8,{...o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function X8(e){let t=(0,G.c)(22),{part:n}=e,{addToolApprovalResponse:r}=_6();if(n.state!==`approval-requested`)return null;let i;t[0]===n?i=t[1]:(i=n.title??Ov(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 Z8(e){let t=(0,G.c)(25),{part:n}=e,{registry:r}=m6();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)(P8,{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)(X8,{part:n}),t[4]=n,t[5]=i);let a=i;if(!r)return a;let o;t[6]!==n||t[7]!==r?(o=H8(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 Q8={animation:`slideUp`};function $8(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 e5(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 t5(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)($8,{filename:n,url:i}):(0,z.jsx)(e5,{filename:n,mediaType:r,url:i}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}var n5=`genai-citation`;function r5(e,t){return t.map((t,n)=>({at:t.endIndex??e.length,order:n})).sort((e,t)=>t.at-e.at||t.order-e.order).reduce((e,{at:t,order:n})=>`${e.slice(0,t)}<${n5} citation="${n}" />${e.slice(t)}`,e)}var i5=(0,R.createContext)(null);function a5(e){let t=(0,G.c)(16),n=(0,R.use)(i5),r=n?.citations[Number(e.citation)];if(!n||!r)return null;let i;t[0]!==r.source.url||t[1]!==n.sources?(i=b6(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)(M6,{source:o,index:a,children:s}),t[12]=a,t[13]=o,t[14]=s,t[15]=c):c=t[15],c}var o5={name:n5,allowedAttributes:[`citation`],component:a5};function s5(e){let t=(0,G.c)(27),{text:n,citations:r,elements:i,className:a}=e,{status:o}=h6(),s=B8(),{messages:c,citation:l}=k6(),u;t[0]===r?u=t[1]:(u=v6(r),t[0]=r,t[1]=u);let d=u,f;t[2]===c?f=t[3]:(f=y6(c),t[2]=c,t[3]=f);let p;t[4]!==l||t[5]!==f||t[6]!==d?(p={citations:d,sources:f,HostCitation:l},t[4]=l,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??[],o5]: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?r5(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)(Y8,{elements:_,animated:Q8,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)(i5,{value:m,children:S}),t[24]=m,t[25]=S,t[26]=C):C=t[26],C}function c5(e){let t=(0,G.c)(8),{part:n}=e,r=l5(),i;t[0]!==n||t[1]!==r?(i=r&&(0,z.jsx)(I8,{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)(Z8,{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 l5(){let{debugMode:e}=m6(),t=B8();return!!e&&!t}function u5(e){return!!e&&e!==`output-available`}function d5(e){let t=(0,G.c)(5),{label:n,part:r,state:i}=e,a=B8(),o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=!a&&!!n.actions&&!!r&&!u5(i),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}function f5(e){let t=(0,G.c)(18),{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.name?l=t[7]:(l=(0,z.jsx)(`span`,{className:`font-mono`,children:n.name}),t[6]=n.name,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==a||t[12]!==r||t[13]!==s?(d=s&&a&&(0,z.jsx)(a,{part:r}),t[11]=a,t[12]=r,t[13]=s,t[14]=d):d=t[14];let f;return t[15]!==u||t[16]!==d?(f=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center justify-between gap-1.5 text-xs`,children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function p5(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 m5(e){let t=(0,G.c)(23),{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;t[4]===n.args?l=t[5]:(l=n.args?Object.entries(n.args).map(h5):`...`,t[4]=n.args,t[5]=l);let u;t[6]!==a||t[7]!==n.name||t[8]!==l?(u=(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,l,`)`]}),t[6]=a,t[7]=n.name,t[8]=l,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]!==n.detail||t[18]!==n.isError?(p=n.detail&&(0,z.jsx)(`span`,{className:I(`line-clamp-3 text-start font-mono text-[10px] leading-relaxed whitespace-pre-wrap`,n.isError?`text-destructive/80`:`text-muted-foreground`),children:n.detail}),t[17]=n.detail,t[18]=n.isError,t[19]=p):p=t[19];let m;return t[20]!==f||t[21]!==p?(m=(0,z.jsxs)(`span`,{className:`mb-2 flex flex-col gap-1`,children:[f,p]}),t[20]=f,t[21]=p,t[22]=m):m=t[22],m}function h5(e){let[t,n]=e;return(0,z.jsx)(p5,{name:t,value:n},t)}function g5(e){return e.type===`text`&&e.providerMetadata?.openai?.phase===`commentary`}function _5(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)(s5,{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 v5(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)(t5,{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 y5(e){let t=(0,G.c)(9),{segment:n}=e,{messages:r}=k6(),i;t[0]===r?i=t[1]:(i=y6(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=b6(a,t.url);return r===null?null:(0,z.jsx)(M6,{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 b5(e){let t=(0,G.c)(3),{segment:n}=e,r=A6();if(B8())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)(C8,{animated:Q8,isAnimating:a,children:i.text})}),t[0]=i.text,t[1]=a,t[2]=o):o=t[2],o}function x5(e){let t=(0,G.c)(2),{segment:n}=e;if(!l5())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)(L8,{part:r}),t[0]=r,t[1]=i),i}var S5=(0,R.createContext)(null),C5=(0,R.createContext)(null);function w5(){let e=(0,R.use)(S5);if(!e)throw Error(`Segment.Tool* parts must be rendered within Segment.Tool`);return e}function T5(e){let t=(0,G.c)(29),{segment:n,children:r}=e,i=m6(),a=A6(),{part:o}=n;if(!Tv(o))return null;let s,c,l,u;t[0]!==i.registry||t[1]!==a||t[2]!==o?({toolEntry:u}=H8(o,i.registry),c=U8(u,o.state),s=!c&&S6(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:Ov(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)(D5,{}),t[21]=r,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,z.jsx)(C5,{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)(S5,{value:h,children:v}),t[26]=h,t[27]=v,t[28]=y):y=t[28],y}function E5(){let e=(0,G.c)(2),{part:t,activeClientInput:n}=w5();if(n)return null;let r;return e[0]===t?r=e[1]:(r=(0,z.jsx)(c5,{part:t}),e[0]=t,e[1]=r),r}function D5(e){let t=(0,G.c)(9),{children:n}=e,{part:r,label:i,defaultOpen:a}=w5();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)(E5,{})}),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)(m5,{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)(E5,{})}),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 O5={Text:_5,File:v5,Source:y5,Reasoning:b5,DynamicTool:x5,Tool:T5,ToolDisclosure:D5,ToolContent:E5};function k5(e){return Tv(e)?`tool`:e.type===`dynamic-tool`?`dynamic-tool`:e.type===`reasoning`&&`text`in e&&e.text?`reasoning`:null}function A5(e,t){return e.kind===`text`||e.kind===`file`||e.kind===`source`?!1:e.kind===`reasoning`||e.kind!==`dynamic-tool`||!!t}function j5(e,t,n){let r=e[t+1];return!!r&&A5(r,n)}function M5(e){let t=[],n=new Set(e.flatMap(e=>e.type===`text`?v6(e.citations).map(({source:e})=>e.url):[]));for(let r=0;r<e.length;r++){let i=e[r],a=k5(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 N5(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)(O5.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)(O5.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)(O5.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)(O5.File,{segment:n}),t[6]=n,t[7]=e),e}return null},P5);function P5(e,t){return e.complete&&t.complete&&e.cacheKey===t.cacheKey}function F5(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)(Tj.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 I5(){let{index:e}=j6(),{messages:t}=k6(),n=A6();return!(e===t.length-1&&(n===`submitted`||n===`streaming`||n===`error`))}function L5(e){let t=(0,G.c)(5),{className:n,children:r}=e;if(!I5()||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 R5(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=j6(),[i,a]=w8(),o=i?`Copied`:`Copy message`,s;t[0]===n?s=t[1]:(s=I(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(z8(r)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,z.jsx)(i?d:ii,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,z.jsx)(F5,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function z5(e){let t=(0,G.c)(9),{className:n}=e,{message:r}=j6(),{regenerate:i}=_6(),a;t[0]===n?a=t[1]:(a=I(`p-1.5`,n),t[0]=n,t[1]=a);let o;t[2]!==r.id||t[3]!==i?(o=()=>void i({messageId:r.id}),t[2]=r.id,t[3]=i,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(wi,{className:`size-3.5`}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,z.jsx)(F5,{"aria-label":`Regenerate response`,className:a,onClick:o,icon:s}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function B5(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=j6(),[i,a]=w8(),o=i?`Copied`:`Copy debug JSON`,s;t[0]===n?s=t[1]:(s=I(`p-1.5`,n),t[0]=n,t[1]=s);let c;t[2]!==a||t[3]!==r?(c=()=>void a(JSON.stringify(r,null,2)),t[2]=a,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,z.jsx)(i?d:Wt,{className:`size-3.5`}),t[5]=i,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,z.jsx)(F5,{"aria-label":o,className:s,onClick:c,icon:l}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function V5(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)(C8,{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 H5(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)(V5,{onTryAgain:r,error:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function U5(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)(D6,{value:l,children:f}),t[12]=f,t[13]=l,t[14]=p):p=t[14],p}function W5(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 G5(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)(O6,{value:s,children:c}),t[6]=c,t[7]=s,t[8]=l):l=t[8],l}function K5(){let e=(0,G.c)(5),{registry:t}=m6(),n=_6().messages,r;if(e[0]!==n||e[1]!==t){bb0:{if(!t){r=null;break bb0}let i=n.findLast(q5);if(!i){r=null;break bb0}let a;e[3]===t?a=e[4]:(a=e=>{if(!Tv(e)||e.state!==`input-available`)return[];let n=t[Ov(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 q5(e){let{role:t}=e;return t===`assistant`}function J5(e){let t=(0,G.c)(10),{children:n,className:r}=e,i=K5(),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 Y5(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(Cv(n)&&g5(n)&&n.text)return n.text}for(let e=t.parts.length-1;e>=0;e--){let n=t.parts[e];if(wv(n)&&n.text)return n.text;if(Dv(n)){let e=n.input;if(Kh(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(Cv(n)&&n.text)return``}return`Thinking...`}function X5(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 Z5(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 Q5(){let e=(0,G.c)(6),t=A6(),{messages:n}=k6(),r=K5(),i=n[n.length-1],a;e[0]!==t||e[1]!==i?(a=Y5(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)(X5,{isLast:!0}),e[3]=s):s=e[3];let c;return e[4]===o?c=e[5]:(c=(0,z.jsx)(Z5,{className:`mt-2`,marker:s,children:(0,z.jsx)(`span`,{role:`status`,children:(0,z.jsx)(w6,{as:`span`,className:`text-muted-foreground line-clamp-2 font-mono text-xs`,children:o})})}),e[4]=o,e[5]=c),c}var $5=[`inputTokens`,`outputTokens`,`reasoningTokens`,`cachedInputTokens`,`totalTokens`],e7={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 t7(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 n7(e){if(!e||typeof e!=`object`)return null;let t={inputTokens:null,outputTokens:null,reasoningTokens:null,cachedInputTokens:null,totalTokens:null};for(let n of $5)for(let r of e7[n]){let i=t7(V3(e,r));if(i!==null){t[n]=i;break}}return $5.some(e=>t[e]!==null)?t:null}function r7(e){return Kh(e)?n7(e.totalUsage??e.usage):null}function i7(e){let t=[`↑ ${G3(e.inputTokens)}`,`↓ ${G3(e.outputTokens)}`];return e.totalTokens!==null&&t.push(`· ${W3(e.totalTokens)} tokens`),e.cachedInputTokens!==null&&e.cachedInputTokens>0&&t.push(`(${G3(e.cachedInputTokens)} cached)`),t.join(` `)}var a7=`x-upload-filename`,o7=Me({path:L().startsWith(`/`),name:L().min(1),mediaType:Mn([`image/png`,`image/jpeg`,`image/webp`,`image/gif`,`image/heic`,`image/heif`,`video/mp4`,`video/quicktime`,`audio/mpeg`,`audio/mp4`,`audio/wav`]),size:eee().nonnegative(),url:Te()}),s7=class extends ky{sessionsApi;request;constructor({api:e,fetch:t=(e,t)=>globalThis.fetch(e,t),tools:n={},elements:r=[]}){let i=d7(e),a=r.map(Vj);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(!f7(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:c7(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:`${c7(i,t)}/stream`,headers:e})}),this.sessionsApi=i,this.request=t}async uploadFile(e,t){let n=await this.request(`${c7(this.sessionsApi,e)}/uploads`,{method:`POST`,headers:{"content-type":t.type,[a7]:encodeURIComponent(t.name)},body:t});if(!n.ok)throw Error(await l7(n,t));let r=o7.safeParse(await n.json());if(!r.success)throw Error(`Zukhruf returned an invalid upload response`);return r.data}};function c7(e,t){return`${e}/${encodeURIComponent(t)}`}async function l7(e,t){let n=`Uploading ${t.name} failed with HTTP ${e.status}`,r=u7(await e.json().catch(e=>{if(e instanceof SyntaxError)return null;throw e}));return r?`${n}: ${r}`:n}function u7(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 f7(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 p7(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 m7(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=r7(n);if(!e){a=null;break bb0}r=`text-muted-foreground mt-2 text-xs tabular-nums opacity-60`,i=i7(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 h7(e,t){return Kh(e.metadata)?e.metadata[t]:void 0}function g7(e){let t=h7(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 _7(e){let t=h7(e,`uploads`);return Array.isArray(t)?t.flatMap(e=>{let t=o7.safeParse(e);return t.success?[t.data]:[]}):[]}function v7(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(y7),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 y7(e){return!e}function b7(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(x7),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)(p7,{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 x7(e){return(0,z.jsx)(v7,{text:e.text},e.id)}function S7(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 C7(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=_7(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(w7)}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 w7(e){return(0,z.jsx)(`div`,{role:`listitem`,"data-slot":`attachment`,children:(0,z.jsx)(S7,{upload:e})},e.path)}function T7(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)(b7,{reminders:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i!==void 0&&(0,z.jsx)(m7,{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 E7(e){let t=(0,G.c)(28),{message:n}=e;h7(n,`reminders`);let r;t[0]===n?r=t[1]:(r=Ib(n),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=g7(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=h7(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)(T7,{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)(C7,{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)(n4,{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)(T7,{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 D7=(0,R.memo)(function(e){let t=(0,G.c)(7),{className:n}=e,{message:r}=j6(),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)(E7,{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 O7(e){return e.kind===`tool`?!V8(e.part):e.kind===`dynamic-tool`||e.kind===`reasoning`}function k7(e,t){return e.kind===`tool`?!0:e.kind===`reasoning`||e.kind===`dynamic-tool`?!!t:!1}function A7(e){return e.kind===`text`&&e.parts.some(({part:e})=>e.type===`text`&&!g5(e))}function j7(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!O7(i)){n.push({kind:`segment`,segment:i,segmentIndex:r});continue}let a=[],o=r;for(;r<e.length&&O7(e[r]);){let n=e[r];k7(n,t)&&a.push({segment:n}),r++}r--,a.length>0&&n.push({kind:`group`,items:a,hasLaterText:e.slice(r+1).some(e=>A7(e)),firstIndex:o})}return n}function M7(e){if(e.kind!==`tool`&&e.kind!==`dynamic-tool`)return;let{part:t}=e;return Dv(t)?t.state:void 0}function N7({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 P7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F7(e,t=80){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-3).trimEnd()}...`}function I7(e){if(typeof e==`string`)return F7(e,48);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`${e.length} items`}function L7(e){if(!P7(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=I7(t);if(n&&(r[e]=n,Object.keys(r).length>=2))break}return Object.keys(r).length>0?r:void 0}function R7(e){if(P7(e))for(let t of[`reasoning`,`thoughts`,`thought`,`hint`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim().length>0)return F7(n)}}function z7(e){if(e.kind!==`reasoning`)return;let{part:t}=e;if(t.type===`reasoning`)return F7(t.text,96)}function B7(e,t){if(e.kind===`reasoning`)return{kind:`reasoning`,name:`reasoning`,detail:z7(e)};if(e.kind===`dynamic-tool`&&e.part.type===`dynamic-tool`){let t=e.part;return{kind:`dynamic-tool`,name:t.toolName||`Tool`,args:L7(t.input),detail:R7(t.input)}}if(e.kind===`tool`&&Tv(e.part)){let n=e.part,{toolEntry:r,toolKey:i}=H8(n,t),a=r?.label?.(n);return{kind:`tool`,name:a?.name??i,args:a?.args??L7(n.input),detail:a?.detail??R7(n.input),isError:a?.isError}}return{kind:`tool`,name:`Step`}}function V7(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}: ${F7(t,36)}`).join(`, `)}function H7(e){let t=V7(e.args);return t?`${e.name}(${t})`:e.name}function U7(e){return e===`output-available`||e===`output-error`||e===`output-denied`}function W7(e){return!!e&&!U7(e)}function G7(e,t){return x6(e,t)}function K7({items:e,labels:t,status:n,hasLaterText:r}){return e.some(({segment:e})=>G7(M7(e),n))?`aborted`:!r&&(n===`streaming`||n===`submitted`)?`running`:t.some(e=>e.isError)||e.some(({segment:e})=>{let t=M7(e);return t===`output-error`||t===`output-denied`})?`error`:e.some(({segment:e})=>W7(M7(e)))||!r&&t.every(e=>e.kind===`reasoning`)&&(n===`streaming`||n===`submitted`)?`running`:`complete`}function q7(e){return e&&`${e[0].toUpperCase()}${e.slice(1)}`}function J7(e){return e.filter(e=>e.kind!==`reasoning`).length}function Y7(e,t){let n=J7(e);if(n!==0)return`${t===`running`||t===`aborted`?`running`:`ran`} ${n} ${n===1?`tool`:`tools`}`}function X7(e,t){let n=Y7(e,t);if(n)return q7(t===`error`?`${n} with issues`:t===`aborted`?`cancelled after ${n}`:n)}function Z7(e,t,n){let r=e.length===1?e[0]:void 0;if(t===`running`)return n||(r?.kind===`reasoning`?`Reasoning${r.detail?` ${r.detail}`:``}`:e.every(e=>e.kind===`reasoning`)?`Reasoning`:`Working...`);if(r){let e=H7(r);return t===`error`?`Failed ${e}`:t===`aborted`?`Cancelled ${e}`:r.kind===`reasoning`?`Reasoned${r.detail?` ${r.detail}`:``}`:`Called ${e}`}return e.every(e=>e.kind===`reasoning`)?`Reasoned`:X7(e,t)??`Ran tools`}function Q7(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.name))).slice(0,3).join(`, `)||void 0}}function $7(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=R7(r.part.input);if(e)return e}if(r.kind===`tool`&&Tv(r.part)){let e=R7(r.part.input);if(e)return e}r.kind===`reasoning`&&(t??=z7(r))}return t}function e9(e,t){return!e||e.role!==`assistant`?!1:j7(M5(e.parts),t).some(e=>e.kind===`group`&&!e.hasLaterText)}function t9(){let e=(0,G.c)(8),{message:t}=j6(),{debugMode:n}=m6(),r;e[0]===t.parts?r=e[1]:(r=M5(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}-${N5(e.segment,e.segmentIndex)}-${e.segment.kind}`},e[6]=t.id,e[7]=r),a=j7(i,n).map(r),e[2]=n,e[3]=t.id,e[4]=i,e[5]=a}else a=e[5];return a}var n9=(0,R.createContext)(null);function r9(){let e=(0,R.use)(n9);if(!e)throw Error(`CompactTrajectory group parts must be rendered within CompactTrajectory.Group`);return e}function i9(e){let t=(0,G.c)(21),{group:n,children:r}=e,{registry:i}=m6(),{message:a}=j6(),o=A6(),[s,c]=(0,R.useState)(!n.hasLaterText),l,u,d;if(t[0]!==n.hasLaterText||t[1]!==n.items||t[2]!==i||t[3]!==o){let e;t[7]===i?e=t[8]:(e=e=>{let{segment:t}=e;return B7(t,i)},t[7]=i,t[8]=e),u=n.items.map(e),l=K7({items:n.items,labels:u,status:o,hasLaterText:n.hasLaterText}),d=N7({groupStatus:l,labelCount:u.length}),t[0]=n.hasLaterText,t[1]=n.items,t[2]=i,t[3]=o,t[4]=l,t[5]=u,t[6]=d}else l=t[4],u=t[5],d=t[6];let f=d,p;t[9]!==n.items||t[10]!==l||t[11]!==u||t[12]!==a.id||t[13]!==f?(p={items:n.items,labels:u,groupStatus:l,tone:f,messageId:a.id},t[9]=n.items,t[10]=l,t[11]=u,t[12]=a.id,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==r||t[16]!==s?(m=(0,z.jsx)(Ia,{open:s,onOpenChange:c,className:`my-2 min-w-0`,children:r}),t[15]=r,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,z.jsx)(n9,{value:p,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function a9(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:E6(`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-left text-sm`,children:n})}),t[1]=n,t[2]=i),i}function o9(){let e=(0,G.c)(12),{items:t,labels:n,groupStatus:r,tone:i}=r9(),a;e[0]!==r||e[1]!==t||e[2]!==n?(a=Z7(n,r,$7(t)),e[0]=r,e[1]=t,e[2]=n,e[3]=a):a=e[3];let o=a,s;e[4]!==r||e[5]!==n?(s=Q7(n,r),e[4]=r,e[5]=n,e[6]=s):s=e[6];let c=s,l;return e[7]!==c||e[8]!==r||e[9]!==o||e[10]!==i?(l={title:o,detail:c,tone:i,groupStatus:r},e[7]=c,e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}function s9(e){let t=(0,G.c)(9),{title:n,suffix:r,children:i}=e,{title:a,tone:o,groupStatus:s}=o9(),c=n??a,l=r?`${c} · ${r}`:c,u=s===`running`,d=s===`running`?`text-info`:o.title,f;t[0]===d?f=t[1]:(f=I(`max-w-full min-w-0 truncate`,d),t[0]=d,t[1]=f);let p;t[2]!==u||t[3]!==f||t[4]!==l?(p=(0,z.jsx)(w6,{as:`span`,enabled:u,className:f,children:l}),t[2]=u,t[3]=f,t[4]=l,t[5]=p):p=t[5];let m;return t[6]!==i||t[7]!==p?(m=(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[p,i]}),t[6]=i,t[7]=p,t[8]=m):m=t[8],m}function c9(){let e=(0,G.c)(2),{tone:t}=r9(),n;return e[0]===t.chevron?n=e[1]:(n=(0,z.jsx)(T6,{className:t.chevron}),e[0]=t.chevron,e[1]=n),n}function l9(e){let t=(0,G.c)(5),{detail:n}=e,{title:r,detail:i,tone:a}=o9();if(n===null)return null;let o=n??i;if(!o||o===r)return null;let s;t[0]===a.detail?s=t[1]:(s=I(`block truncate text-xs`,a.detail),t[0]=a.detail,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,z.jsx)(`span`,{className:s,children:o}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}function u9(e){let t=(0,G.c)(14),{children:n}=e,{items:r,messageId:i,groupStatus:a}=r9(),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}=jj(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}-${N5(n,t)}-${n.kind}`;return n.kind===`tool`?(0,z.jsx)(O5.Tool,{segment:n},r):n.kind===`reasoning`?(0,z.jsx)(O5.Reasoning,{segment:n},r):n.kind===`dynamic-tool`?(0,z.jsx)(O5.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 d9(e){let t=(0,G.c)(19),{item:n,textClassName:r}=e,i=r===void 0?`my-4`:r,{elements:a}=k6(),{segment:o}=n;if(o.kind===`text`){let e;t[0]===o.parts?e=t[1]:(e=o.parts.filter(f9),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)(O5.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)(O5.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)(O5.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)(O5.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)(O5.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)(O5.DynamicTool,{segment:o}),t[17]=o,t[18]=e),e}return null}function f9(e){let{part:t}=e;return!g5(t)}function p9(){let e=(0,G.c)(1),t=A6(),{messages:n}=k6(),{debugMode:r}=m6(),i=n[n.length-1];if(t!==`ready`&&t!==`error`&&e9(i,r))return null;let a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,z.jsx)(Q5,{}),e[0]=a):a=e[0],a}var m9={Root:U5,List:W5,Item:G5,UserBubble:D7,AssistantContent:(0,R.memo)(function(e){let t=(0,G.c)(5),{className:n}=e,r=t9(),i;t[0]===r?i=t[1]:(i=r.map(h9),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:L5,CopyAction:R5,RegenerateAction:z5,CopyDebugJsonAction:B5,Thinking:p9,Error:H5};function h9(e){return e.kind===`group`?(0,z.jsxs)(i9,{group:e,children:[(0,z.jsxs)(a9,{children:[(0,z.jsx)(s9,{children:(0,z.jsx)(c9,{})}),(0,z.jsx)(l9,{})]}),(0,z.jsx)(u9,{})]},e.key):(0,z.jsx)(d9,{item:e},e.key)}function g9(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 _9(e){let t=(0,G.c)(15),{part:n}=e,r=m6(),i,a;if(t[0]!==r.registry||t[1]!==n){a=Symbol.for(`react.early_return_sentinel`);bb0:{let{toolEntry:e}=H8(n,r.registry);if(e&&U8(e,n.state)){let t=e.label?.(n);if(!t){a=null;break bb0}let r=t.icon,i=t.args?Object.values(t.args)[0]:void 0;a=(0,z.jsxs)(`div`,{className:`text-muted-foreground flex items-center text-xs`,children:[r&&(0,z.jsx)(r,{className:`size-3.5`}),(0,z.jsx)(`span`,{className:`ms-2 font-mono`,children:t.name}),i&&(0,z.jsxs)(`span`,{className:`truncate`,children:[`(`,i,`)`]})]});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)(f5,{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)(g9,{message:o.detail}),t[7]=o,t[8]=c);let l;t[9]===n?l=t[10]:(l=(0,z.jsx)(c5,{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 v9(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)(C8,{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)(p7,{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 y9(e){let t=(0,G.c)(16),{part:n}=e,{elements:r}=k6(),i=l5();if(n.type===`text`){if(g5(n))return null;let e;return t[0]!==r||t[1]!==n.citations||t[2]!==n.text?(e=(0,z.jsx)(s5,{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)(L8,{part:n}):null,t[4]=i,t[5]=n,t[6]=e):e=t[6],e}if(Tv(n)){let e;return t[7]===n?e=t[8]:(e=(0,z.jsx)(_9,{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)(v9,{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)(t5,{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}=j6(),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)(y9,{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 b9={braille:{frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],interval:80},pulse:{frames:[`⠁`,`⠉`,`⠋`,`⠛`,`⠟`,`⠿`,`⡿`,`⣿`,`⡿`,`⠿`,`⠟`,`⠛`,`⠋`,`⠉`,`⠁`,`⠀`],interval:80},clock:{frames:[`⠁`,`⠈`,`⠐`,`⠠`,`⢀`,`⡀`,`⠄`,`⠂`],interval:100},limerence:{frames:[`⠁`,`⠃`,`⠇`,`⡇`,`⣇`,`⣇`,`⣆`,`⣄`,`⣀`,`⢀`,`⠀`],interval:100}};function x9(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=ln(),{frames:s,interval:c}=b9[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 S9(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)(x9,{className:`text-muted-foreground z-10 shrink-0 text-sm`}):a?(0,z.jsx)(Jn,{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 C9(e){let t=(0,G.c)(15),{isLast:n,label:r,state:i,aborted:a,children:o}=e,s=(0,R.use)(C5),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)(S9,{Icon:d,isLast:n,isLoading:f,aborted:u,state:l,isError:c?.isError??!1}):(0,z.jsx)(X5,{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)(Z5,{marker:m,children:_}),t[12]=m,t[13]=_,t[14]=v):v=t[14],v}function Fee(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)(m5,{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:C9,Disclosure:Fee};(0,R.memo)(function(e){let t=(0,G.c)(12),{className:n}=e,{message:r}=j6(),{elements:i}=k6(),{debugMode:a}=m6(),o=l5(),s=B8(),c;t[0]===r.parts?c=t[1]:(c=M5(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}-${N5(e,t)}-${e.kind}`;if(e.kind===`text`)return(0,z.jsx)(O5.Text,{segment:e,elements:i,className:`my-4`},n);if(e.kind===`file`)return(0,z.jsx)(O5.File,{segment:e},n);if(e.kind===`source`)return(0,z.jsx)(O5.Source,{segment:e},n);if(e.kind===`dynamic-tool`){if(!o)return null;let r=!j5(l,t,!0);return(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(O5.DynamicTool,{segment:e})},n)}if(e.kind===`reasoning`){if(s||e.part.type!==`reasoning`)return null;let r=!j5(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)(O5.Reasoning,{segment:e})})},n)}if(e.kind===`tool`){let r=!j5(l,t,a);return(0,z.jsx)(O5.Tool,{segment:e,children:(0,z.jsx)(w9.Item,{isLast:r,children:(0,z.jsx)(O5.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 Iee(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}=g6(),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)(e4.Root,{hasInteracted:i,className:a,...r}),t[5]=i,t[6]=r,t[7]=a,t[8]=o):o=t[8],o}function Lee(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 Ree(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)(e4.Content,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}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(`!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)(e4.Editor,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Bee(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)(e4.Attachments,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Vee(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)(e4.Toolbar,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Hee(e){let t=(0,G.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,z.jsx)(F5,{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)(e4.AttachFiles,{"aria-label":`Attach files`,render:n,...e}),t[1]=e,t[2]=r),r}function Uee(){let e=(0,G.c)(6),{actions:t,meta:n}=zQ(`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)(F5,{"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 Wee(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 Gee(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 Wee(e.error.code)}}function Kee(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 qee(){let e=(0,G.c)(20),{status:t}=h6(),{state:n}=V1(`ChatComposer.Dictate`),r;e[0]===n?r=e[1]:(r=Gee(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=Kee(n),e[2]=n,e[3]=s);let c;e[4]!==i||e[5]!==s?(c=(0,z.jsx)(F5,{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)(e4.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)(e4.CancelDictation,{render:(0,z.jsx)(F5,{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:Iee,Root:Lee,Popup:e4.Popup,Content:Ree,Attachments:Bee,Editor:zee,Error:e4.Error,Toolbar:Vee,CommandButton:Uee,AttachFiles:Hee,Dictate:qee};function Jee(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 Yee(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 Xee(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 Zee(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)(n4,{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 Qee(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)(Rn,{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:Jee,Item:Yee,Icon:Xee,Text:Zee,Remove:Qee},$ee={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}}},ete={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=wj(),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)(Tj.path,{animate:l,d:`m5 12 7-7 7 7`,variants:$ee}),v=(0,z.jsx)(Tj.path,{animate:l,d:`M12 19V5`,variants:ete}),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 tte={duration:.15,ease:[0,0,.2,1]},nte={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=vj(),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?ate:ite,{}),t[23]=s,t[24]=y);let b;t[25]!==v||t[26]!==y||t[27]!==h||t[28]!==g?(b=(0,z.jsx)(kk,{initial:!1,children:(0,z.jsx)(Tj.span,{initial:g,animate:_,exit:v,transition:nte,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)(Tj.button,{initial:c,animate:l,exit:u,transition:tte,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 rte(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 ite(){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 ate(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(rte,{children:(0,z.jsx)(`rect`,{x:`5`,y:`5`,width:`10`,height:`10`,rx:`1.5`})}),e[0]=t):t=e[0],t}function ote(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=_6(),u;t[0]===o.issues?u=t[1]:(u=o.issues.map(ste).join(`
|
|
344
|
+
`),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)(gr,{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 "${kv(a)}" with the following inputs:`,JSON.stringify(a.input),`Please fix the inputs.`];l.addToolOutput({toolCallId:a.toolCallId,tool:kv(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 ste(e){return`${e.path.join(`.`)}: ${e.message}`}(0,R.createContext)(``);function cte({question:e}){let{submit:t}=m6();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=Hj([{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:cte}]),lte=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:Xt(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:Xt(lte).min(1).describe(`Available choices`)})).min(1).describe(`Questions to present as a wizard`)})),j9=F({label:L(),value:L()}),ute=F({answers:Xt(F({type:L(),question:L(),freeText:L().optional(),notes:L().optional(),choice:j9.optional(),choices:Xt(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 fte(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)(Pn,{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 pte({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 mte({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 hte({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 gte({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 _te({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 vte({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)(mte,{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)(gte,{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)(pte,{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)(hte,{id:`${i}-single-other`,checked:e.isOther,disabled:r,customText:e.customText,onCustomTextChange:n=>t({...e,customText:n})})]})}function yte({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 bte({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)(yte,{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 xte({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 Ste({question:e,answer:t,options:n,onChange:r,disabled:i,fieldId:a}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(vte,{value:t,onChange:r,options:n,disabled:i,fieldId:a}),(0,z.jsx)(_te,{value:t.notes,onChange:e=>r({...t,notes:e}),disabled:i})]})}function Cte({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 wte(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 Tte({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:wte(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 Ete({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)(Cte,{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 Dte({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)=>fte(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 Ote(){let{currentQuestion:e,isSubmitted:t}=L9();return t?null:(0,z.jsx)(xte,{question:e})}function kte(){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)(Ste,{question:e,answer:t,options:n,onChange:r,disabled:i||a,fieldId:`${s}-step-${c}`})}function Ate(){let{error:e,isSubmitted:t}=L9();return t||!e?null:(0,z.jsx)(`p`,{className:`text-destructive text-xs`,role:`alert`,children:e})}function jte(){let{handleBack:e,handleNext:t,isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c}=L9();return(0,z.jsx)(bte,{onBack:e,onNext:()=>void t(),isFirst:n,isLast:r,canProceed:i,isSubmitting:a,isSubmitted:o,currentStep:s,totalSteps:c})}function Mte({children:e,className:t}){let{isSubmitted:n}=L9();return n?null:(0,z.jsx)(`div`,{className:t,children:e})}function Nte(){let{questions:e,answers:t,isSubmitted:n}=L9();return n?(0,z.jsx)(Ete,{questions:e,answers:t}):null}var R9={Root:Dte,Header:Ote,Content:Mte,Field:kte,Error:Ate,Navigation:jte,Submitted:Nte};function Pte({part:e}){let t=_6(),[n,r]=(0,R.useState)(!1),i=(0,R.useId)();if(e.state===`output-available`){let t=ute.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)(Tte,{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:kv(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)(ote,{error:a.error,title:`Failed to render clarification`,detail:JSON.stringify(e.input,null,2),detailLabel:`View input`,part:e})}var Fte={component:Pte,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:Qr,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.
|
|
345
|
+
|
|
346
|
+
Each question MUST have a "type" field set to "choice" for selection from predefined options (single or multiple).
|
|
347
|
+
|
|
348
|
+
IMPORTANT: NEVER include an "Other" option in your options array — the UI always renders one automatically with an inline text input.
|
|
349
|
+
|
|
350
|
+
Example:
|
|
351
|
+
{"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)(E8,{className:I(`border-border/60 rounded-md shadow-none`,i&&`border-destructive/30`),code:t,language:n,wrap:!0,children:(0,z.jsx)(D8,{"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 Ite({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(`
|
|
352
|
+
`)||void 0}}function Lte(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 Rte={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 Rte[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 zte({part:e}){let t=B9(e.input,`path`)??``,n=J9(e.output),r=Lte(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 Bte({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 Vte(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:Fte,bash:{component:Ite,label:Vte,static:!0},readFile:{component:zte,label:e=>Z9(e,`ReadFile`),static:!0},writeFile:{component:Bte,label:e=>Z9(e,`WriteFile`),static:!0}},Hte=lr(`status`,[F({id:L(),status:Ye(`restored`),sourceMessages:tr(),replacementMessages:tr()}),F({id:L(),status:Ye(`started`),tokenScope:Ye(`request`).optional(),triggerIndex:tr(),targetTokens:tr(),messageCount:tr()}),F({id:L(),status:Ye(`completed`),tokenScope:Ye(`request`).optional(),tokens:F({before:tr(),after:tr()})}),F({id:L(),status:Ye(`failed`),phase:Mn([`restore`,`evaluate`,`compact`,`persist`]),reason:Mn([`no-safe-boundary`,`protected-history`,`incomplete-summary`,`empty-summary`,`summary-too-large`,`request-overhead`,`error`])})]);function Ute({message:e,running:t}){let n=e.parts.flatMap(e=>{if(e.type!==`data-compaction`)return[];let t=Hte.safeParse(e.data);return t.success?[t.data]:[]}),r=Map.groupBy(n,e=>e.id);return Array.from(r,([e,n])=>(0,z.jsx)(Wte,{events:n,running:t},e))}function Wte({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 Gte=F({messages:Xt(fn())});async function Kte(e){let{params:t,request:n}=e,r=t.sessionId??new URL(n.url).searchParams.get(`chatId`);if(!r)return cn(`/chat?chatId=${encodeURIComponent(crypto.randomUUID())}`);let i=await Kn(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=Gte.safeParse(await e.json());if(!s.success)throw Error(`Session response did not include messages`);return{...i,chatId:r,conversation:a,initialMessages:await iy({messages:s.data.messages}),sessionExists:!0,sessionError:!1}}catch{return{...i,chatId:r,conversation:a,initialMessages:void 0,sessionExists:!1,sessionError:!0}}}function qte({currentParams:e,currentUrl:t,nextParams:n,nextUrl:r}){return e.sessionId!==n.sessionId||t.searchParams.get(`chatId`)!==r.searchParams.get(`chatId`)}function Jte(){let{chatId:e}=Ie();return(0,z.jsx)(Yte,{chatId:e},e)}function Yte({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)(Xte,{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 Xte({api:e,chatId:t,initialMessages:n,sessionExists:r,supportsUploads:i,accept:a}){let o=hn(),{revalidate:s}=fe(),c=Ie(),[l]=(0,R.useState)(()=>new s7({api:e,tools:C6(Q9),elements:k9}));return(0,z.jsx)(p6,{chatId:t,initialMessages:n,onFinish:()=>void s(),onResetChat:e=>{o(`/chat?chatId=${encodeURIComponent(e)}`)},resume:r,registry:Q9,transport:l,children:(0,z.jsxs)(t6,{className:`**:data-[slot='content']:max-w-3xl`,children:[(0,z.jsx)(s6.Root,{className:`px-6`,children:(0,z.jsx)(s6.Hero,{children:`How can I help?`})}),(0,z.jsx)(Zte,{}),(0,z.jsx)(on,{treeId:t,snapshot:c.conversation?.children}),(0,z.jsx)(Qte,{supportsUploads:i,accept:a})]})})}function Zte(){let{error:e,messages:t,regenerate:n,status:r}=_6();return t.length===0&&!e?null:(0,z.jsxs)(m9.Root,{className:`mb-8 min-h-0 flex-1 px-6`,messages:t,elements:k9,status:r,children:[(0,z.jsx)(m9.List,{children:t.map((e,n)=>(0,z.jsx)(m9.Item,{message:e,index:n,children:e.role===`user`?(0,z.jsx)(m9.UserBubble,{}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ute,{message:e,running:n===t.length-1&&(r===`submitted`||r===`streaming`)}),(0,z.jsx)(m9.AssistantContent,{})]})},e.id))}),(0,z.jsx)(m9.Error,{error:e,onRetry:()=>void n()}),(0,z.jsx)(m9.Thinking,{})]})}function Qte({supportsUploads:e,accept:t}){let{submit:n}=m6(),{hasSubmitted:r}=g6(),{status:i}=h6(),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)(J5,{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)($te,{}),(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)(ene,{})]})]})})})})}function $te(){let{experimental_queuedMessages:e,experimental_removeQueuedMessage:t}=_6();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:X3(e)}),(0,z.jsx)(E9.Remove,{onClick:()=>t(e.id)})]},e.id))})}function ene(){let{state:e}=zQ(`ChatSubmitButton`),{stop:t}=m6(),{status:n}=h6(),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)(e4.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{Jte as Component,Kte as loader,qte as shouldRevalidate};
|