@json-to-office/jto 1.6.0 → 1.7.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.
Files changed (29) hide show
  1. package/dist/cli.js +60 -19
  2. package/dist/cli.js.map +1 -1
  3. package/dist/client/assets/HomePage-fDrbL-5G.js +106 -0
  4. package/dist/client/assets/HomePage-fDrbL-5G.js.map +1 -0
  5. package/dist/client/assets/{JsonEditorPage-4LrF2fB9.js → JsonEditorPage-CRY9589Y.js} +3 -3
  6. package/dist/client/assets/{JsonEditorPage-4LrF2fB9.js.map → JsonEditorPage-CRY9589Y.js.map} +1 -1
  7. package/dist/client/assets/MonacoPluginProvider-n1_V7jsc.js +3 -0
  8. package/dist/client/assets/MonacoPluginProvider-n1_V7jsc.js.map +1 -0
  9. package/dist/client/assets/{editor-D-REaAU9.js → editor-Y9dek093.js} +2 -2
  10. package/dist/client/assets/{editor-D-REaAU9.js.map → editor-Y9dek093.js.map} +1 -1
  11. package/dist/client/assets/{editor-monaco-json-BgziSLMV.js → editor-monaco-json-oBxvTIvi.js} +2 -2
  12. package/dist/client/assets/{editor-monaco-json-BgziSLMV.js.map → editor-monaco-json-oBxvTIvi.js.map} +1 -1
  13. package/dist/client/assets/{editor-refs-store-vzLK2-Zo.js → editor-refs-store-BMwl0ejj.js} +2 -2
  14. package/dist/client/assets/{editor-refs-store-vzLK2-Zo.js.map → editor-refs-store-BMwl0ejj.js.map} +1 -1
  15. package/dist/client/assets/{index-B7bDnXoC.js → index-B4R-AAtI.js} +4 -4
  16. package/dist/client/assets/index-B4R-AAtI.js.map +1 -0
  17. package/dist/client/assets/preview-zCYkbgdR.js +2 -0
  18. package/dist/client/assets/preview-zCYkbgdR.js.map +1 -0
  19. package/dist/client/assets/{useQualityAnalysis-CowAaoA9.js → useQualityAnalysis-BFG1bJDp.js} +2 -2
  20. package/dist/client/assets/{useQualityAnalysis-CowAaoA9.js.map → useQualityAnalysis-BFG1bJDp.js.map} +1 -1
  21. package/dist/client/index.html +1 -1
  22. package/package.json +5 -5
  23. package/dist/client/assets/HomePage-CeUQIXch.js +0 -106
  24. package/dist/client/assets/HomePage-CeUQIXch.js.map +0 -1
  25. package/dist/client/assets/MonacoPluginProvider-Bx_V_FaE.js +0 -3
  26. package/dist/client/assets/MonacoPluginProvider-Bx_V_FaE.js.map +0 -1
  27. package/dist/client/assets/index-B7bDnXoC.js.map +0 -1
  28. package/dist/client/assets/preview-BGqIip90.js +0 -2
  29. package/dist/client/assets/preview-BGqIip90.js.map +0 -1
@@ -1,106 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-D-REaAU9.js","assets/react-vendor-BmQ2Ko_D.js","assets/editor-monaco-json-BgziSLMV.js","assets/index-B7bDnXoC.js","assets/query-vendor--rhYD8mC.js","assets/radix-ui-DFNP5I4e.js","assets/ui-vendor-Bq4-oNFL.js","assets/monaco-editor-DJsdM0WK.js","assets/state-vendor-Cq67_JbF.js","assets/index-CrzIwHLS.css","assets/editor-refs-store-vzLK2-Zo.js","assets/MonacoPluginProvider-Bx_V_FaE.js","assets/useQualityAnalysis-CowAaoA9.js","assets/preview-BGqIip90.js"])))=>i.map(i=>d[i]);
2
- var Ym=Object.defineProperty;var Km=(e,t,n)=>t in e?Ym(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Vs=(e,t,n)=>Km(e,typeof t!="symbol"?t+"":t,n);import{r as x,j as u,c as je,R as Uc,g as uo}from"./react-vendor-BmQ2Ko_D.js";import{b as Jc,c as co,d as Hc,e as ys,f as bs,D as vs,O as ws,g as Xm,V as Qm,G as eg,h as Wc,I as tg,i as ng,j as qc,k as rg,l as Gc,m as ig,n as sg,L as Yc,S as Kc,o as Xc,p as Qc,q as ed,r as kr,s as ag,t as og,u as lg,v as td,w as nd,x as rd,y as id,z as sd,B as ad,E as od,F as ld,H as ud,J as ug,K as cg,M as dg,N as cd,Q as dd,U as fd,W as pd,X as hd,Y as md,Z as gd,_ as xd,$ as yd,a0 as bd,a1 as fg,a2 as vd,a3 as pg,a4 as hg,a5 as wd,a6 as mg,a7 as gg,a8 as xg,a9 as yg,aa as kd,ab as Sd,ac as _d}from"./radix-ui-DFNP5I4e.js";import{c as G,u as Sr,S as gn,A as ei,T as _i,C as bg,E as vg,F as ht,a as wg,b as kg,d as Ge,e as Ye,f as Ke,g as jd,_ as Nd,h as ji,i as Sg,j as _g,k as jg,l as Tr,s as Us,W as Ed,m as $i}from"./index-B7bDnXoC.js";import{X as yn,C as mi,a as an,b as Ng,d as gi,G as Cd,F as Eg,e as _r,f as Td,P as Cg,g as Tg,h as Id,E as Ad,B as _a,H as Ig,T as ja,L as Na,i as Ag,j as zg,S as zd,I as Og,k as Pg,l as Ea,m as Dg,n as Rg,o as Mg,p as $g,q as Fg,r as Lg,s as Bg,t as Zg,u as ks,v as Vg,M as Ug,w as nn,x as Od,y as Jg,z as Hg,A as Pd,D as Wg,J as qg,K as Gg,N as Yg,O as Kg,Q as Dd,R as Xg,U as Ca,V as fo,W as Rd,Y as Qg,Z as Md,_ as Fr,$ as ex,a0 as tx,a1 as nx,a2 as il,a3 as Ta}from"./ui-vendor-Bq4-oNFL.js";import{B as Se,u as $d,d as sl}from"./editor-refs-store-vzLK2-Zo.js";import{u as Ne,i as rx,a as Ia,b as rn,g as ix,c as Lt,T as Fd,d as Hi,S as sx,O as ax,e as ox,M as lx,D as ux}from"./MonacoPluginProvider-Bx_V_FaE.js";import{u as po,a as cx,d as dx,p as fx,b as px,e as hx}from"./state-vendor-Cq67_JbF.js";import{b as mx}from"./query-vendor--rhYD8mC.js";const Ct=Jc,gx=Hc,al=co,Ld=x.forwardRef(({className:e,...t},n)=>u.jsx(ws,{ref:n,className:G("fixed inset-0 z-50 bg-black/50",e),...t}));Ld.displayName=ws.displayName;const kt=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gx,{children:[u.jsx(Ld,{}),u.jsxs(ys,{ref:r,className:G("bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg",e),...n,children:[t,u.jsxs(co,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[u.jsx(yn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));kt.displayName=ys.displayName;const Vt=({className:e,...t})=>u.jsx("div",{className:G("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Vt.displayName="DialogHeader";const bn=({className:e,...t})=>u.jsx("div",{className:G("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});bn.displayName="DialogFooter";const Ut=x.forwardRef(({className:e,...t},n)=>u.jsx(bs,{ref:n,className:G("text-lg leading-none font-semibold tracking-tight",e),...t}));Ut.displayName=bs.displayName;const on=x.forwardRef(({className:e,...t},n)=>u.jsx(vs,{ref:n,className:G("text-muted-foreground text-sm",e),...t}));on.displayName=vs.displayName;const ti=Xm,Bd=eg,ni=Qm,fr=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Wc,{ref:r,className:G("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex min-h-9 w-full min-w-0 items-center justify-between gap-2 rounded-sm border bg-background px-3 py-2 text-sm shadow-xs focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:min-w-0 [&>span]:whitespace-normal [&>span]:break-words text-left cursor-pointer",e),...n,children:[t,u.jsx(tg,{asChild:!0,children:u.jsx(mi,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));fr.displayName=Wc.displayName;const Zd=x.forwardRef(({className:e,...t},n)=>u.jsx(Kc,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(Ng,{className:"h-4 w-4"})}));Zd.displayName=Kc.displayName;const Vd=x.forwardRef(({className:e,...t},n)=>u.jsx(Xc,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(mi,{className:"h-4 w-4"})}));Vd.displayName=Xc.displayName;const pr=x.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>u.jsx(ng,{children:u.jsxs(qc,{ref:i,className:G("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Zd,{}),u.jsx(rg,{className:G("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Vd,{})]})}));pr.displayName=qc.displayName;const ho=x.forwardRef(({className:e,...t},n)=>u.jsx(Yc,{ref:n,className:G("px-2 py-1.5 text-sm font-semibold",e),...t}));ho.displayName=Yc.displayName;const Pn=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Gc,{ref:r,className:G("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(ig,{children:u.jsx(an,{className:"h-4 w-4"})})}),u.jsx(sg,{children:t})]}));Pn.displayName=Gc.displayName;const xx=x.forwardRef(({className:e,...t},n)=>u.jsx(Qc,{ref:n,className:G("bg-muted -mx-1 my-1 h-px",e),...t}));xx.displayName=Qc.displayName;const hr=x.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:G("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-sm border bg-background px-3 py-1 text-sm shadow-xs transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));hr.displayName="Input";const yx=gi("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Wr=x.forwardRef(({className:e,...t},n)=>u.jsx(ed,{ref:n,className:G(yx(),e),...t}));Wr.displayName=ed.displayName;const bx=gi("inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-medium transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Kt({className:e,variant:t,...n}){return u.jsx("div",{className:G(bx({variant:t}),e),...n})}const vx=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:a}=Ne(po(T=>({documents:T.documents,documentTypes:T.documentTypes,activeTab:T.activeTab,createDocument:T.createDocument,openDocument:T.openDocument}))),{toast:o}=Sr(),l=x.useMemo(()=>n.filter(T=>r[T.name]!=="application/json+theme"),[n,r]),[c,d]=x.useState(""),[f,h]=x.useState(""),[p,g]=x.useState("playground"),[v,_]=x.useState(!1),[b,E]=x.useState(null),[m,O]=x.useState(null),[N,w]=x.useState(null),k=()=>{E(null),O(null),w(null)};x.useEffect(()=>{if(!e)return;E(null),O(null),w(null);const T=l.map(P=>P.name),z=T.includes(i)?i:T[0]??"";h(z),d(T.find(P=>P!==z)??"")},[e]);const R=async()=>{const T=l.find(P=>P.name===c),z=l.find(P=>P.name===f);if(!(!T||!z)){_(!0),E(null),O(null),w(null);try{const P=await fetch(ei.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:T.text,newDefinition:z.text,options:{author:p||"playground"}})}),I=await P.json();if(!P.ok||!I.success){const M=Array.isArray(I.errors)?`: ${I.errors.slice(0,3).map(J=>J.message||String(J)).join("; ")}`:"";throw new Error((I.error||`Diff failed (${P.status})`)+M)}O(I.data.summary),w(I.data.document)}catch(P){E(P instanceof Error?P.message:"Diff failed")}finally{_(!1)}}},q=()=>{if(!N)return;const T=new Set(n.map(I=>I.name));let z=`${f}-redline`,P=2;for(;T.has(z);)z=`${f}-redline-${P++}`;s(z,JSON.stringify(N,null,2)),a(z),o({title:`Redline created: ${z}`}),t(!1)},j=m?m.tracked.modified+m.tracked.inserted+m.tracked.deleted:0;return u.jsx(Ct,{open:e,onOpenChange:t,children:u.jsxs(kt,{className:"sm:max-w-[560px]",children:[u.jsxs(Vt,{children:[u.jsxs(Ut,{className:"flex items-center gap-2",children:[u.jsx(Cd,{className:"size-4"}),"Compare documents"]}),u.jsx(on,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),u.jsxs("div",{className:"grid gap-4 py-2",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Wr,{htmlFor:"diff-base",children:"Base (old)"}),u.jsxs(ti,{value:c,onValueChange:T=>{d(T),k()},children:[u.jsx(fr,{id:"diff-base",children:u.jsx(ni,{placeholder:"Select document"})}),u.jsx(pr,{children:l.map(T=>u.jsx(Pn,{value:T.name,children:T.name},T.name))})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Wr,{htmlFor:"diff-revised",children:"Revised (new)"}),u.jsxs(ti,{value:f,onValueChange:T=>{h(T),k()},children:[u.jsx(fr,{id:"diff-revised",children:u.jsx(ni,{placeholder:"Select document"})}),u.jsx(pr,{children:l.map(T=>u.jsx(Pn,{value:T.name,children:T.name},T.name))})]})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Wr,{htmlFor:"diff-author",children:"Revision author"}),u.jsx(hr,{id:"diff-author",value:p,onChange:T=>{g(T.target.value),k()},placeholder:"playground"})]}),b&&u.jsx("p",{className:"text-sm text-destructive",role:"alert",children:b}),m&&u.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsxs(Kt,{variant:"secondary",children:[m.tracked.inserted," inserted"]}),u.jsxs(Kt,{variant:"secondary",children:[m.tracked.deleted," deleted"]}),u.jsxs(Kt,{variant:"secondary",children:[m.tracked.modified," modified"]}),u.jsxs("span",{className:"text-muted-foreground text-xs",children:[m.unchangedBlocks," blocks unchanged"]})]}),j===0&&m.untracked.length===0&&u.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),m.untracked.length>0&&u.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[u.jsxs("p",{className:"font-medium text-warning-bg-foreground",children:[m.untracked.length," change(s) not expressible as tracked changes:"]}),m.untracked.map((T,z)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.path," [",T.component,"] ",T.detail]},z))]}),m.notes.map((T,z)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",T]},z))]})]}),u.jsx(bn,{children:m&&j+m.untracked.length>0?u.jsxs(Se,{onClick:q,children:[u.jsx(Eg,{className:"size-4 mr-1"}),"Open redline"]}):u.jsxs(Se,{onClick:R,disabled:v||!c||!f||c===f,children:[v&&u.jsx(gn,{className:"size-4 mr-1"}),"Compare"]})})]})})};var xi=e=>e.type==="checkbox",In=e=>e instanceof Date,ft=e=>e==null;const Ud=e=>typeof e=="object";var Qe=e=>!ft(e)&&!Array.isArray(e)&&Ud(e)&&!In(e),Jd=e=>Qe(e)&&e.target?xi(e.target)?e.target.checked:e.target.value:e,wx=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Hd=(e,t)=>e.has(wx(t)),kx=e=>{const t=e.constructor&&e.constructor.prototype;return Qe(t)&&t.hasOwnProperty("isPrototypeOf")},mo=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function yt(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(mo&&(e instanceof Blob||r))&&(n||Qe(e)))if(t=n?[]:{},!n&&!kx(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=yt(e[i]));else return e;return t}var Ss=e=>Array.isArray(e)?e.filter(Boolean):[],Xe=e=>e===void 0,ce=(e,t,n)=>{if(!t||!Qe(e))return n;const r=Ss(t.split(/[,[\].]+?/)).reduce((i,s)=>ft(i)?i:i[s],e);return Xe(r)||r===e?Xe(e[t])?n:e[t]:r},zt=e=>typeof e=="boolean",go=e=>/^\w*$/.test(e),Wd=e=>Ss(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Me=(e,t,n)=>{let r=-1;const i=go(t)?[t]:Wd(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let l=n;if(r!==a){const c=e[o];l=Qe(c)||Array.isArray(c)?c:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=l,e=e[o]}return e};const Wi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ft={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},tn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},qd=je.createContext(null),_s=()=>je.useContext(qd),Sx=e=>{const{children:t,...n}=e;return je.createElement(qd.Provider,{value:n},t)};var Gd=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==Ft.all&&(t._proxyFormState[a]=!r||Ft.all),n&&(n[a]=!0),e[a]}});return i},bt=e=>Qe(e)&&!Object.keys(e).length,Yd=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return bt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||Ft.all))},qr=e=>Array.isArray(e)?e:[e],Kd=(e,t,n)=>!e||!t||e===t||qr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function xo(e){const t=je.useRef(e);t.current=e,je.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function _x(e){const t=_s(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=je.useState(n._formState),l=je.useRef(!0),c=je.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=je.useRef(i);return d.current=i,xo({disabled:r,next:f=>l.current&&Kd(d.current,f.name,s)&&Yd(f,c.current,n._updateFormState)&&o({...n._formState,...f}),subject:n._subjects.state}),je.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),je.useMemo(()=>Gd(a,n,c.current,!1),[a,n])}var Yt=e=>typeof e=="string",Xd=(e,t,n,r,i)=>Yt(e)?(r&&t.watch.add(e),ce(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ce(n,s))):(r&&(t.watchAll=!0),n);function jx(e){const t=_s(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=je.useRef(r);o.current=r,xo({disabled:s,subject:n._subjects.values,next:d=>{Kd(o.current,d.name,a)&&c(yt(Xd(o.current,n._names,d.values||n._formValues,!1,i)))}});const[l,c]=je.useState(n._getWatch(r,i));return je.useEffect(()=>n._removeUnmounted()),l}function Nx(e){const t=_s(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=Hd(i._names.array,n),o=jx({control:i,name:n,defaultValue:ce(i._formValues,n,ce(i._defaultValues,n,e.defaultValue)),exact:!0}),l=_x({control:i,name:n,exact:!0}),c=je.useRef(i.register(n,{...e.rules,value:o,...zt(e.disabled)?{disabled:e.disabled}:{}})),d=je.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ce(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!ce(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ce(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ce(l.validatingFields,n)},error:{enumerable:!0,get:()=>ce(l.errors,n)}}),[l,n]),f=je.useMemo(()=>({name:n,value:o,...zt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:h=>c.current.onChange({target:{value:Jd(h),name:n},type:Wi.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:ce(i._formValues,n),name:n},type:Wi.BLUR}),ref:h=>{const p=ce(i._fields,n);p&&h&&(p._f.ref={focus:()=>h.focus(),select:()=>h.select(),setCustomValidity:g=>h.setCustomValidity(g),reportValidity:()=>h.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return je.useEffect(()=>{const h=i._options.shouldUnregister||s,p=(g,v)=>{const _=ce(i._fields,g);_&&_._f&&(_._f.mount=v)};if(p(n,!0),h){const g=yt(ce(i._options.defaultValues,n));Me(i._defaultValues,n,g),Xe(ce(i._formValues,n))&&Me(i._formValues,n,g)}return!a&&i.register(n),()=>{(a?h&&!i._state.action:h)?i.unregister(n):p(n,!1)}},[n,i,a,s]),je.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),je.useMemo(()=>({field:f,formState:l,fieldState:d}),[f,l,d])}const Ex=e=>e.render(Nx(e));var Cx=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},ol=e=>({isOnSubmit:!e||e===Ft.onSubmit,isOnBlur:e===Ft.onBlur,isOnChange:e===Ft.onChange,isOnAll:e===Ft.all,isOnTouch:e===Ft.onTouched}),ll=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Gr=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=ce(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(Gr(o,t))break}else if(Qe(o)&&Gr(o,t))break}}};var Tx=(e,t,n)=>{const r=qr(ce(e,n));return Me(r,"root",t[n]),Me(e,n,r),e},yo=e=>e.type==="file",Gt=e=>typeof e=="function",qi=e=>{if(!mo)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Fi=e=>Yt(e),bo=e=>e.type==="radio",Gi=e=>e instanceof RegExp;const ul={value:!1,isValid:!1},cl={value:!0,isValid:!0};var Qd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Xe(e[0].attributes.value)?Xe(e[0].value)||e[0].value===""?cl:{value:e[0].value,isValid:!0}:cl:ul}return ul};const dl={isValid:!1,value:null};var ef=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,dl):dl;function fl(e,t,n="validate"){if(Fi(e)||Array.isArray(e)&&e.every(Fi)||zt(e)&&!e)return{type:n,message:Fi(e)?e:"",ref:t}}var Ln=e=>Qe(e)&&!Gi(e)?e:{value:e,message:""},pl=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:c,minLength:d,min:f,max:h,pattern:p,validate:g,name:v,valueAsNumber:_,mount:b}=e._f,E=ce(n,v);if(!b||t.has(v))return{};const m=o?o[0]:a,O=z=>{i&&m.reportValidity&&(m.setCustomValidity(zt(z)?"":z||""),m.reportValidity())},N={},w=bo(a),k=xi(a),R=w||k,q=(_||yo(a))&&Xe(a.value)&&Xe(E)||qi(a)&&a.value===""||E===""||Array.isArray(E)&&!E.length,j=Cx.bind(null,v,r,N),T=(z,P,I,M=tn.maxLength,J=tn.minLength)=>{const Z=z?P:I;N[v]={type:z?M:J,message:Z,ref:a,...j(z?M:J,Z)}};if(s?!Array.isArray(E)||!E.length:l&&(!R&&(q||ft(E))||zt(E)&&!E||k&&!Qd(o).isValid||w&&!ef(o).isValid)){const{value:z,message:P}=Fi(l)?{value:!!l,message:l}:Ln(l);if(z&&(N[v]={type:tn.required,message:P,ref:m,...j(tn.required,P)},!r))return O(P),N}if(!q&&(!ft(f)||!ft(h))){let z,P;const I=Ln(h),M=Ln(f);if(!ft(E)&&!isNaN(E)){const J=a.valueAsNumber||E&&+E;ft(I.value)||(z=J>I.value),ft(M.value)||(P=J<M.value)}else{const J=a.valueAsDate||new Date(E),Z=S=>new Date(new Date().toDateString()+" "+S),V=a.type=="time",ne=a.type=="week";Yt(I.value)&&E&&(z=V?Z(E)>Z(I.value):ne?E>I.value:J>new Date(I.value)),Yt(M.value)&&E&&(P=V?Z(E)<Z(M.value):ne?E<M.value:J<new Date(M.value))}if((z||P)&&(T(!!z,I.message,M.message,tn.max,tn.min),!r))return O(N[v].message),N}if((c||d)&&!q&&(Yt(E)||s&&Array.isArray(E))){const z=Ln(c),P=Ln(d),I=!ft(z.value)&&E.length>+z.value,M=!ft(P.value)&&E.length<+P.value;if((I||M)&&(T(I,z.message,P.message),!r))return O(N[v].message),N}if(p&&!q&&Yt(E)){const{value:z,message:P}=Ln(p);if(Gi(z)&&!E.match(z)&&(N[v]={type:tn.pattern,message:P,ref:a,...j(tn.pattern,P)},!r))return O(P),N}if(g){if(Gt(g)){const z=await g(E,n),P=fl(z,m);if(P&&(N[v]={...P,...j(tn.validate,P.message)},!r))return O(P.message),N}else if(Qe(g)){let z={};for(const P in g){if(!bt(z)&&!r)break;const I=fl(await g[P](E,n),m,P);I&&(z={...I,...j(P,I.message)},O(I.message),r&&(N[v]=z))}if(!bt(z)&&(N[v]={ref:m,...z},!r))return N}}return O(!0),N};function Ix(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Xe(e)?r++:e[t[r++]];return e}function Ax(e){for(const t in e)if(e.hasOwnProperty(t)&&!Xe(e[t]))return!1;return!0}function it(e,t){const n=Array.isArray(t)?t:go(t)?[t]:Wd(t),r=n.length===1?e:Ix(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Qe(r)&&bt(r)||Array.isArray(r)&&Ax(r))&&it(e,n.slice(0,-1)),e}var Js=()=>{let e=[];return{get observers(){return e},next:i=>{for(const s of e)s.next&&s.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(s=>s!==i)}}),unsubscribe:()=>{e=[]}}},Aa=e=>ft(e)||!Ud(e);function hn(e,t){if(Aa(e)||Aa(t))return e===t;if(In(e)&&In(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const a=t[i];if(In(s)&&In(a)||Qe(s)&&Qe(a)||Array.isArray(s)&&Array.isArray(a)?!hn(s,a):s!==a)return!1}}return!0}var tf=e=>e.type==="select-multiple",zx=e=>bo(e)||xi(e),Hs=e=>qi(e)&&e.isConnected,nf=e=>{for(const t in e)if(Gt(e[t]))return!0;return!1};function Yi(e,t={}){const n=Array.isArray(e);if(Qe(e)||n)for(const r in e)Array.isArray(e[r])||Qe(e[r])&&!nf(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Yi(e[r],t[r])):ft(e[r])||(t[r]=!0);return t}function rf(e,t,n){const r=Array.isArray(e);if(Qe(e)||r)for(const i in e)Array.isArray(e[i])||Qe(e[i])&&!nf(e[i])?Xe(t)||Aa(n[i])?n[i]=Array.isArray(e[i])?Yi(e[i],[]):{...Yi(e[i])}:rf(e[i],ft(t)?{}:t[i],n[i]):n[i]=!hn(e[i],t[i]);return n}var Ir=(e,t)=>rf(e,t,Yi(t)),sf=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Xe(e)?e:t?e===""?NaN:e&&+e:n&&Yt(e)?new Date(e):r?r(e):e;function Ws(e){const t=e.ref;return yo(t)?t.files:bo(t)?ef(e.refs).value:tf(t)?[...t.selectedOptions].map(({value:n})=>n):xi(t)?Qd(e.refs).value:sf(Xe(t.value)?e.ref.value:t.value,e)}var Ox=(e,t,n,r)=>{const i={};for(const s of e){const a=ce(t,s);a&&Me(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Ar=e=>Xe(e)?e:Gi(e)?e.source:Qe(e)?Gi(e.value)?e.value.source:e.value:e;const hl="AsyncFunction";var Px=e=>!!e&&!!e.validate&&!!(Gt(e.validate)&&e.validate.constructor.name===hl||Qe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===hl)),Dx=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function ml(e,t,n){const r=ce(e,n);if(r||go(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=ce(t,s),o=ce(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var Rx=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,Mx=(e,t)=>!Ss(ce(e,t)).length&&it(e,t);const $x={mode:Ft.onSubmit,reValidateMode:Ft.onChange,shouldFocusError:!0};function Fx(e={}){let t={...$x,...e},n={submitCount:0,isDirty:!1,isLoading:Gt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=Qe(t.defaultValues)||Qe(t.values)?yt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:yt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Js(),array:Js(),state:Js()},h=ol(t.mode),p=ol(t.reValidateMode),g=t.criteriaMode===Ft.all,v=C=>$=>{clearTimeout(c),c=setTimeout(C,$)},_=async C=>{if(!t.disabled&&(d.isValid||C)){const $=t.resolver?bt((await R()).errors):await j(r,!0);$!==n.isValid&&f.state.next({isValid:$})}},b=(C,$)=>{!t.disabled&&(d.isValidating||d.validatingFields)&&((C||Array.from(o.mount)).forEach(U=>{U&&($?Me(n.validatingFields,U,$):it(n.validatingFields,U))}),f.state.next({validatingFields:n.validatingFields,isValidating:!bt(n.validatingFields)}))},E=(C,$=[],U,se,A=!0,K=!0)=>{if(se&&U&&!t.disabled){if(a.action=!0,K&&Array.isArray(ce(r,C))){const ee=U(ce(r,C),se.argA,se.argB);A&&Me(r,C,ee)}if(K&&Array.isArray(ce(n.errors,C))){const ee=U(ce(n.errors,C),se.argA,se.argB);A&&Me(n.errors,C,ee),Mx(n.errors,C)}if(d.touchedFields&&K&&Array.isArray(ce(n.touchedFields,C))){const ee=U(ce(n.touchedFields,C),se.argA,se.argB);A&&Me(n.touchedFields,C,ee)}d.dirtyFields&&(n.dirtyFields=Ir(i,s)),f.state.next({name:C,isDirty:z(C,$),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Me(s,C,$)},m=(C,$)=>{Me(n.errors,C,$),f.state.next({errors:n.errors})},O=C=>{n.errors=C,f.state.next({errors:n.errors,isValid:!1})},N=(C,$,U,se)=>{const A=ce(r,C);if(A){const K=ce(s,C,Xe(U)?ce(i,C):U);Xe(K)||se&&se.defaultChecked||$?Me(s,C,$?K:Ws(A._f)):M(C,K),a.mount&&_()}},w=(C,$,U,se,A)=>{let K=!1,ee=!1;const xe={name:C};if(!t.disabled){const L=!!(ce(r,C)&&ce(r,C)._f&&ce(r,C)._f.disabled);if(!U||se){d.isDirty&&(ee=n.isDirty,n.isDirty=xe.isDirty=z(),K=ee!==xe.isDirty);const Q=L||hn(ce(i,C),$);ee=!!(!L&&ce(n.dirtyFields,C)),Q||L?it(n.dirtyFields,C):Me(n.dirtyFields,C,!0),xe.dirtyFields=n.dirtyFields,K=K||d.dirtyFields&&ee!==!Q}if(U){const Q=ce(n.touchedFields,C);Q||(Me(n.touchedFields,C,U),xe.touchedFields=n.touchedFields,K=K||d.touchedFields&&Q!==U)}K&&A&&f.state.next(xe)}return K?xe:{}},k=(C,$,U,se)=>{const A=ce(n.errors,C),K=d.isValid&&zt($)&&n.isValid!==$;if(t.delayError&&U?(l=v(()=>m(C,U)),l(t.delayError)):(clearTimeout(c),l=null,U?Me(n.errors,C,U):it(n.errors,C)),(U?!hn(A,U):A)||!bt(se)||K){const ee={...se,...K&&zt($)?{isValid:$}:{},errors:n.errors,name:C};n={...n,...ee},f.state.next(ee)}},R=async C=>{b(C,!0);const $=await t.resolver(s,t.context,Ox(C||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return b(C),$},q=async C=>{const{errors:$}=await R(C);if(C)for(const U of C){const se=ce($,U);se?Me(n.errors,U,se):it(n.errors,U)}else n.errors=$;return $},j=async(C,$,U={valid:!0})=>{for(const se in C){const A=C[se];if(A){const{_f:K,...ee}=A;if(K){const xe=o.array.has(K.name),L=A._f&&Px(A._f);L&&d.validatingFields&&b([se],!0);const Q=await pl(A,o.disabled,s,g,t.shouldUseNativeValidation&&!$,xe);if(L&&d.validatingFields&&b([se]),Q[K.name]&&(U.valid=!1,$))break;!$&&(ce(Q,K.name)?xe?Tx(n.errors,Q,K.name):Me(n.errors,K.name,Q[K.name]):it(n.errors,K.name))}!bt(ee)&&await j(ee,$,U)}}return U.valid},T=()=>{for(const C of o.unMount){const $=ce(r,C);$&&($._f.refs?$._f.refs.every(U=>!Hs(U)):!Hs($._f.ref))&&Y(C)}o.unMount=new Set},z=(C,$)=>!t.disabled&&(C&&$&&Me(s,C,$),!hn(le(),i)),P=(C,$,U)=>Xd(C,o,{...a.mount?s:Xe($)?i:Yt(C)?{[C]:$}:$},U,$),I=C=>Ss(ce(a.mount?s:i,C,t.shouldUnregister?ce(i,C,[]):[])),M=(C,$,U={})=>{const se=ce(r,C);let A=$;if(se){const K=se._f;K&&(!K.disabled&&Me(s,C,sf($,K)),A=qi(K.ref)&&ft($)?"":$,tf(K.ref)?[...K.ref.options].forEach(ee=>ee.selected=A.includes(ee.value)):K.refs?xi(K.ref)?K.refs.length>1?K.refs.forEach(ee=>(!ee.defaultChecked||!ee.disabled)&&(ee.checked=Array.isArray(A)?!!A.find(xe=>xe===ee.value):A===ee.value)):K.refs[0]&&(K.refs[0].checked=!!A):K.refs.forEach(ee=>ee.checked=ee.value===A):yo(K.ref)?K.ref.value="":(K.ref.value=A,K.ref.type||f.values.next({name:C,values:{...s}})))}(U.shouldDirty||U.shouldTouch)&&w(C,A,U.shouldTouch,U.shouldDirty,!0),U.shouldValidate&&S(C)},J=(C,$,U)=>{for(const se in $){const A=$[se],K=`${C}.${se}`,ee=ce(r,K);(o.array.has(C)||Qe(A)||ee&&!ee._f)&&!In(A)?J(K,A,U):M(K,A,U)}},Z=(C,$,U={})=>{const se=ce(r,C),A=o.array.has(C),K=yt($);Me(s,C,K),A?(f.array.next({name:C,values:{...s}}),(d.isDirty||d.dirtyFields)&&U.shouldDirty&&f.state.next({name:C,dirtyFields:Ir(i,s),isDirty:z(C,K)})):se&&!se._f&&!ft(K)?J(C,K,U):M(C,K,U),ll(C,o)&&f.state.next({...n}),f.values.next({name:a.mount?C:void 0,values:{...s}})},V=async C=>{a.mount=!0;const $=C.target;let U=$.name,se=!0;const A=ce(r,U),K=()=>$.type?Ws(A._f):Jd(C),ee=xe=>{se=Number.isNaN(xe)||In(xe)&&isNaN(xe.getTime())||hn(xe,ce(s,U,xe))};if(A){let xe,L;const Q=K(),he=C.type===Wi.BLUR||C.type===Wi.FOCUS_OUT,ve=!Dx(A._f)&&!t.resolver&&!ce(n.errors,U)&&!A._f.deps||Rx(he,ce(n.touchedFields,U),n.isSubmitted,p,h),F=ll(U,o,he);Me(s,U,Q),he?(A._f.onBlur&&A._f.onBlur(C),l&&l(0)):A._f.onChange&&A._f.onChange(C);const me=w(U,Q,he,!1),Te=!bt(me)||F;if(!he&&f.values.next({name:U,type:C.type,values:{...s}}),ve)return d.isValid&&(t.mode==="onBlur"&&he?_():he||_()),Te&&f.state.next({name:U,...F?{}:me});if(!he&&F&&f.state.next({...n}),t.resolver){const{errors:Le}=await R([U]);if(ee(Q),se){const rt=ml(n.errors,r,U),et=ml(Le,r,rt.name||U);xe=et.error,U=et.name,L=bt(Le)}}else b([U],!0),xe=(await pl(A,o.disabled,s,g,t.shouldUseNativeValidation))[U],b([U]),ee(Q),se&&(xe?L=!1:d.isValid&&(L=await j(r,!0)));se&&(A._f.deps&&S(A._f.deps),k(U,L,xe,me))}},ne=(C,$)=>{if(ce(n.errors,$)&&C.focus)return C.focus(),1},S=async(C,$={})=>{let U,se;const A=qr(C);if(t.resolver){const K=await q(Xe(C)?C:A);U=bt(K),se=C?!A.some(ee=>ce(K,ee)):U}else C?(se=(await Promise.all(A.map(async K=>{const ee=ce(r,K);return await j(ee&&ee._f?{[K]:ee}:ee)}))).every(Boolean),!(!se&&!n.isValid)&&_()):se=U=await j(r);return f.state.next({...!Yt(C)||d.isValid&&U!==n.isValid?{}:{name:C},...t.resolver||!C?{isValid:U}:{},errors:n.errors}),$.shouldFocus&&!se&&Gr(r,ne,C?A:o.mount),se},le=C=>{const $={...a.mount?s:i};return Xe(C)?$:Yt(C)?ce($,C):C.map(U=>ce($,U))},B=(C,$)=>({invalid:!!ce(($||n).errors,C),isDirty:!!ce(($||n).dirtyFields,C),error:ce(($||n).errors,C),isValidating:!!ce(n.validatingFields,C),isTouched:!!ce(($||n).touchedFields,C)}),y=C=>{C&&qr(C).forEach($=>it(n.errors,$)),f.state.next({errors:C?n.errors:{}})},W=(C,$,U)=>{const se=(ce(r,C,{_f:{}})._f||{}).ref,A=ce(n.errors,C)||{},{ref:K,message:ee,type:xe,...L}=A;Me(n.errors,C,{...L,...$,ref:se}),f.state.next({name:C,errors:n.errors,isValid:!1}),U&&U.shouldFocus&&se&&se.focus&&se.focus()},X=(C,$)=>Gt(C)?f.values.subscribe({next:U=>C(P(void 0,$),U)}):P(C,$,!0),Y=(C,$={})=>{for(const U of C?qr(C):o.mount)o.mount.delete(U),o.array.delete(U),$.keepValue||(it(r,U),it(s,U)),!$.keepError&&it(n.errors,U),!$.keepDirty&&it(n.dirtyFields,U),!$.keepTouched&&it(n.touchedFields,U),!$.keepIsValidating&&it(n.validatingFields,U),!t.shouldUnregister&&!$.keepDefaultValue&&it(i,U);f.values.next({values:{...s}}),f.state.next({...n,...$.keepDirty?{isDirty:z()}:{}}),!$.keepIsValid&&_()},re=({disabled:C,name:$,field:U,fields:se})=>{(zt(C)&&a.mount||C||o.disabled.has($))&&(C?o.disabled.add($):o.disabled.delete($),w($,Ws(U?U._f:ce(se,$)._f),!1,!1,!0))},D=(C,$={})=>{let U=ce(r,C);const se=zt($.disabled)||zt(t.disabled);return Me(r,C,{...U||{},_f:{...U&&U._f?U._f:{ref:{name:C}},name:C,mount:!0,...$}}),o.mount.add(C),U?re({field:U,disabled:zt($.disabled)?$.disabled:t.disabled,name:C}):N(C,!0,$.value),{...se?{disabled:$.disabled||t.disabled}:{},...t.progressive?{required:!!$.required,min:Ar($.min),max:Ar($.max),minLength:Ar($.minLength),maxLength:Ar($.maxLength),pattern:Ar($.pattern)}:{},name:C,onChange:V,onBlur:V,ref:A=>{if(A){D(C,$),U=ce(r,C);const K=Xe(A.value)&&A.querySelectorAll&&A.querySelectorAll("input,select,textarea")[0]||A,ee=zx(K),xe=U._f.refs||[];if(ee?xe.find(L=>L===K):K===U._f.ref)return;Me(r,C,{_f:{...U._f,...ee?{refs:[...xe.filter(Hs),K,...Array.isArray(ce(i,C))?[{}]:[]],ref:{type:K.type,name:C}}:{ref:K}}}),N(C,!1,void 0,K)}else U=ce(r,C,{}),U._f&&(U._f.mount=!1),(t.shouldUnregister||$.shouldUnregister)&&!(Hd(o.array,C)&&a.action)&&o.unMount.add(C)}}},de=()=>t.shouldFocusError&&Gr(r,ne,o.mount),te=C=>{zt(C)&&(f.state.next({disabled:C}),Gr(r,($,U)=>{const se=ce(r,U);se&&($.disabled=se._f.disabled||C,Array.isArray(se._f.refs)&&se._f.refs.forEach(A=>{A.disabled=se._f.disabled||C}))},0,!1))},ae=(C,$)=>async U=>{let se;U&&(U.preventDefault&&U.preventDefault(),U.persist&&U.persist());let A=yt(s);if(o.disabled.size)for(const K of o.disabled)Me(A,K,void 0);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:K,values:ee}=await R();n.errors=K,A=ee}else await j(r);if(it(n.errors,"root"),bt(n.errors)){f.state.next({errors:{}});try{await C(A,U)}catch(K){se=K}}else $&&await $({...n.errors},U),de(),setTimeout(de);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:bt(n.errors)&&!se,submitCount:n.submitCount+1,errors:n.errors}),se)throw se},ue=(C,$={})=>{ce(r,C)&&(Xe($.defaultValue)?Z(C,yt(ce(i,C))):(Z(C,$.defaultValue),Me(i,C,yt($.defaultValue))),$.keepTouched||it(n.touchedFields,C),$.keepDirty||(it(n.dirtyFields,C),n.isDirty=$.defaultValue?z(C,yt(ce(i,C))):z()),$.keepError||(it(n.errors,C),d.isValid&&_()),f.state.next({...n}))},ge=(C,$={})=>{const U=C?yt(C):i,se=yt(U),A=bt(C),K=A?i:se;if($.keepDefaultValues||(i=U),!$.keepValues){if($.keepDirtyValues){const ee=new Set([...o.mount,...Object.keys(Ir(i,s))]);for(const xe of Array.from(ee))ce(n.dirtyFields,xe)?Me(K,xe,ce(s,xe)):Z(xe,ce(K,xe))}else{if(mo&&Xe(C))for(const ee of o.mount){const xe=ce(r,ee);if(xe&&xe._f){const L=Array.isArray(xe._f.refs)?xe._f.refs[0]:xe._f.ref;if(qi(L)){const Q=L.closest("form");if(Q){Q.reset();break}}}}r={}}s=t.shouldUnregister?$.keepDefaultValues?yt(i):{}:yt(K),f.array.next({values:{...K}}),f.values.next({values:{...K}})}o={mount:$.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!d.isValid||!!$.keepIsValid||!!$.keepDirtyValues,a.watch=!!t.shouldUnregister,f.state.next({submitCount:$.keepSubmitCount?n.submitCount:0,isDirty:A?!1:$.keepDirty?n.isDirty:!!($.keepDefaultValues&&!hn(C,i)),isSubmitted:$.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:A?{}:$.keepDirtyValues?$.keepDefaultValues&&s?Ir(i,s):n.dirtyFields:$.keepDefaultValues&&C?Ir(i,C):$.keepDirty?n.dirtyFields:{},touchedFields:$.keepTouched?n.touchedFields:{},errors:$.keepErrors?n.errors:{},isSubmitSuccessful:$.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},pe=(C,$)=>ge(Gt(C)?C(s):C,$);return{control:{register:D,unregister:Y,getFieldState:B,handleSubmit:ae,setError:W,_executeSchema:R,_getWatch:P,_getDirty:z,_updateValid:_,_removeUnmounted:T,_updateFieldArray:E,_updateDisabledField:re,_getFieldArray:I,_reset:ge,_resetDefaultValues:()=>Gt(t.defaultValues)&&t.defaultValues().then(C=>{pe(C,t.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:C=>{n={...n,...C}},_disableForm:te,_subjects:f,_proxyFormState:d,_setErrors:O,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(C){a=C},get _defaultValues(){return i},get _names(){return o},set _names(C){o=C},get _formState(){return n},set _formState(C){n=C},get _options(){return t},set _options(C){t={...t,...C}}},trigger:S,register:D,handleSubmit:ae,watch:X,setValue:Z,getValues:le,reset:pe,resetField:ue,clearErrors:y,unregister:Y,setError:W,setFocus:(C,$={})=>{const U=ce(r,C),se=U&&U._f;if(se){const A=se.refs?se.refs[0]:se.ref;A.focus&&(A.focus(),$.shouldSelect&&Gt(A.select)&&A.select())}},getFieldState:B}}function Lx(e={}){const t=je.useRef(void 0),n=je.useRef(void 0),[r,i]=je.useState({isDirty:!1,isValidating:!1,isLoading:Gt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Gt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Fx(e),formState:r});const s=t.current.control;return s._options=e,xo({subject:s._subjects.state,next:a=>{Yd(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),je.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),je.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),je.useEffect(()=>{e.values&&!hn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),je.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),je.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),je.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=Gd(r,s),t.current}function Bx(e){return async t=>{const n=e(t);if(n.success&&n.data)return{values:n.data,errors:{}};const r={};if(n.errors)for(const i of n.errors){const s=i.path||"root";r[s]||(r[s]={type:"validation",message:i.message})}return{values:{},errors:r}}}const Zx=Sx,af=x.createContext({}),gl=({...e})=>u.jsx(af.Provider,{value:{name:e.name},children:u.jsx(Ex,{...e})}),js=()=>{const e=x.useContext(af),t=x.useContext(of),{getFieldState:n,formState:r}=_s(),i=n(e.name,r);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:s}=t;return{id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...i}},of=x.createContext({}),za=x.forwardRef(({className:e,...t},n)=>{const r=x.useId();return u.jsx(of.Provider,{value:{id:r},children:u.jsx("div",{ref:n,className:G("space-y-2",e),...t})})});za.displayName="FormItem";const Oa=x.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=js();return u.jsx(Wr,{ref:n,className:G(r&&"text-destructive",e),htmlFor:i,...t})});Oa.displayName="FormLabel";const Pa=x.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=js();return u.jsx(kr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Pa.displayName="FormControl";const lf=x.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=js();return u.jsx("p",{ref:n,id:r,className:G("text-muted-foreground text-[0.8rem]",e),...t})});lf.displayName="FormDescription";const Da=x.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=js(),a=i?String(i==null?void 0:i.message):t;return a?u.jsx("p",{ref:r,id:s,className:G("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});Da.displayName="FormMessage";function vo(){const e=new Date,t=n=>String(n).padStart(2,"0");return`Chat ${t(e.getMonth()+1)}/${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`}const uf=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Vx=(e=uf())=>cx()(dx(fx((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,a)=>a!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),a={id:i,documentName:r,title:vo(),messages:[],createdAt:s,updatedAt:s};return t(o=>({threads:{...o.threads,[i]:a},activeThreadId:{...o.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const a=Object.fromEntries(Object.entries(i.threads).filter(([c])=>c!==r)),o=s.documentName,l={...i.activeThreadId};if(l[o]===r){const c=Object.values(a).filter(d=>d.documentName===o);c.length>0?(c.sort((d,f)=>f.updatedAt-d.updatedAt),l[o]=c[0].id):delete l[o]}t({threads:a,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,l]of Object.entries(s))l.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[l,c]of Object.entries(a))c.documentName===r&&(a[l]={...c,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:px(()=>rx),partialize:t=>({threads:t.threads,activeThreadId:t.activeThreadId,scope:t.scope,model:t.model}),migrate:(t,n)=>{if(n===0&&t){const r=t.chatMessages;if(Array.isArray(r)&&r.length>0){const i=crypto.randomUUID(),s=Date.now();return{threads:{[i]:{id:i,documentName:"__migrated__",title:"Migrated Chat",messages:r,createdAt:s,updatedAt:s}},activeThreadId:{__migrated__:i}}}return{threads:{},activeThreadId:{}}}return t}}))),cf=x.createContext(void 0),Ux=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Vx(uf())),u.jsx(cf.Provider,{value:t.current,children:e})},Oe=e=>{const t=x.useContext(cf);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return hx(t,e)};function Jx(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Hx(e,t,n){const r={},i=[];e!=="delete"&&(r.name=_i.String({minLength:1,maxLength:120,pattern:"^[a-zA-Z0-9-_. ]+$",description:"Document name (e.g., my-report.docx.json or my-theme.theme.json)"}),i.push("name")),e==="create"&&(r.template=_i.Optional(_i.String({description:"Template selection"})));const s=_i.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!bg(s,a))for(const c of vg(s,a))o.push({path:c.path.replace(/^\//,""),message:c.message});const l=a;if(e!=="delete"&&l.name){const c=l.name.trim();c?(l.name=c,t(c)||o.push({path:"name",message:"Document with this name already exists"})):o.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&l.template&&(n.some(c=>c.name===l.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?l:void 0,errors:o}}}}function Wx(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const qx=e=>({create:{title:e?"New Theme":"New Document",description:e?"Create a new theme from scratch or based on discovered themes.":"Create a new document from scratch or based on discovered documents.",button:"Create",buttonVariant:"default"},update:{title:"Rename Document",description:"Give your document a new name.",button:"Save",buttonVariant:"default"},delete:{title:"Are you absolutely sure?",description:"This action cannot be undone. Are you sure you want to permanently delete this document?",button:"Confirm",buttonVariant:"destructive"}}),Bn="__empty__";function Gx({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=x.useState(!1),[c,d]=x.useState(null),[f,h]=x.useState("idle"),{toast:p}=Sr(),g=qx(a),{documents:v,openTabs:_,createDocument:b,renameDocument:E,deleteDocument:m,openDocument:O,closeDocument:N}=Ne(le=>le),{updateTheme:w,removeTheme:k}=Ia(le=>le),R=Oe(le=>le.renameThreadsForDocument),q=Oe(le=>le.deleteThreadsForDocument),j=x.useMemo(()=>a?s||[]:i||[],[a,i,s]),T=x.useMemo(()=>{const le={current:[],downstream:[]};return j.forEach(B=>{le[B.location]&&le[B.location].push(B)}),le},[j]),z=x.useMemo(()=>j.map(le=>({name:le.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[j]),P=x.useMemo(()=>Hx(e,le=>Jx(le,v,r),z),[e,v,r,z]),I=P.schema,M=x.useMemo(()=>{const le=new Map;return j.forEach(B=>le.set(B.path,B)),le},[j]),J=Bn,Z=Lx({resolver:Bx(P.validate),defaultValues:Wx(e,void 0,r)}),[V,ne]=x.useState(J);x.useEffect(()=>{if(V&&V!==Bn&&e==="create"){const le=M.get(V);if(le){d(null),h("loading");let B=!1;return fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(le.name)}/content`).then(y=>{if(!y.ok)throw new Error(`Failed to fetch content: ${y.statusText}`);return y.text()}).then(y=>{if(B)return;const W=JSON.parse(y);d(JSON.stringify(W,null,2)),h("idle")}).catch(y=>{B||(console.error("Failed to copy template:",y),d(null),h("error"))}),()=>{B=!0}}}h("idle")},[V,e,M,a]),x.useEffect(()=>{t&&(Z.reset(),d(null),h("idle"),ne(J))},[Z,t]);const S=Z.handleSubmit(async({name:le,template:B})=>{l(!0);try{if(await new Promise(y=>setTimeout(y,200)),e==="create"){const y=V?M.get(V):j.find(ue=>ue.name===B);let W,X=le;if(!!V&&V!==Bn&&c===null){p({title:f==="loading"?"Template still loading":`Could not copy ${(y==null?void 0:y.name)??"the selected template"}`,description:f==="loading"?"Wait for the template to finish loading, then try again.":"Pick another template, or create an empty one instead.",variant:"destructive"});return}if(a){const ue=X.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),ge=ht==="docx"?wg(ue):{name:ue,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}};W=c||JSON.stringify(ge,null,2);const pe=`.${ht}.theme.json`;X.endsWith(pe)||(X=X.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),X+=pe)}else{const ue=y;W=c||JSON.stringify(ht==="docx"?{name:"docx",props:{theme:(ue==null?void 0:ue.theme)||"default",metadata:{title:(ue==null?void 0:ue.title)||X.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(ue==null?void 0:ue.title)||X.replace(/\.(json|js)$/i,""),theme:(ue==null?void 0:ue.theme)||"default"},children:[{name:"slide",props:{},children:[{name:"text",props:{text:"Start writing your presentation content here...",fontSize:24,y:2,x:1,w:8}}]}]},null,2);const ge=ht==="docx"?".docx.json":".pptx.json";!X.endsWith(ge)&&!X.endsWith(".json")&&(X+=ge)}const re=X.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),D=re?re[0]:"",de=X.slice(0,X.length-D.length);let te=X,ae=1;for(;v.some(ue=>ue.name===te);)ae++,te=`${de} (${ae})${D}`;X=te,b(X,W),O(X),a&&w(X,W)}else if(e==="update"){const y=r,W=le,X=_.includes(y);X&&N(y),E(y,W),R(y,W),X&&O(W)}else if(e==="delete"){const y=r;N(y),m(y),q(y),a&&k(y)}n()}finally{l(!1)}});return u.jsx(Zx,{...Z,children:u.jsxs("form",{onSubmit:S,children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:g[e].title}),u.jsx(on,{children:g[e].description})]}),u.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[I.properties&&"name"in I.properties&&u.jsx(gl,{control:Z.control,name:"name",render:({field:le})=>u.jsxs(za,{children:[u.jsx(Oa,{children:"Name"}),u.jsx(Pa,{children:u.jsx(hr,{placeholder:"Enter a name or select a template below",autoComplete:"off",...le})}),u.jsx(Da,{})]})}),e==="create"&&u.jsx(gl,{control:Z.control,name:"template",render:({field:le})=>u.jsxs(za,{children:[u.jsx(Oa,{children:a?"Base Theme":"Base Document"}),u.jsxs(ti,{onValueChange:B=>{if(B===Bn)le.onChange(void 0),Z.setValue("name",""),ne(Bn),d(null);else{const y=M.get(B);y&&(le.onChange(y.name),Z.setValue("name",y.name),ne(B))}},defaultValue:J,children:[u.jsx(Pa,{children:u.jsx(fr,{children:u.jsx(ni,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),u.jsxs(pr,{className:"max-h-[300px]",children:[u.jsxs(Pn,{value:Bn,children:["Empty ",a?"theme":"document"]}),Object.entries(T).map(([B,y])=>y.length===0?null:u.jsxs(Bd,{children:[u.jsx(ho,{children:B==="current"?"📁 Current Directory":"📦 Project"}),y.map(W=>{let X;return W.title&&W.title!==W.name?X=W.title:W.description&&(X=W.description.length>40?W.description.substring(0,40)+"...":W.description),u.jsx(Pn,{value:W.path,className:"pl-6",children:u.jsxs("span",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:W.name}),X&&u.jsx("span",{className:"text-muted-foreground text-xs",children:X})]})},W.path)})]},B))]})]}),u.jsxs(lf,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),u.jsx(Da,{})]})})]}),u.jsx(bn,{children:u.jsx(Se,{type:"submit",variant:g[e].buttonVariant,disabled:o,children:o?u.jsxs(u.Fragment,{children:[u.jsx(gn,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):g[e].button})})]})})}const Ki=je.memo(Gx);function cn(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}function wo({text:e,query:t}){if(!t)return u.jsx(u.Fragment,{children:e});const n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?u.jsx(u.Fragment,{children:e}):u.jsxs(u.Fragment,{children:[e.slice(0,n),u.jsx("mark",{className:"bg-transparent p-0 font-semibold text-current",children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function Ra({children:e,count:t,actions:n,className:r,open:i,onToggle:s}){const a=u.jsxs(u.Fragment,{children:[u.jsx(_r,{"aria-hidden":!0,className:G("size-3 shrink-0 transition-transform duration-150 ease-out",i&&"rotate-90")}),u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:e}),t!==void 0&&u.jsx("span",{className:"text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:t})]});return u.jsxs("div",{className:G("flex h-6 shrink-0 items-center gap-1.5 select-none",r),children:[u.jsx("button",{type:"button",onClick:s,"aria-expanded":i,className:G("flex h-6 min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-sm px-1","text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:a}),n&&u.jsx("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:n})]})}const Ht=je.forwardRef(({className:e,...t},n)=>u.jsx("button",{ref:n,type:"button",className:G("flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm","text-sidebar-foreground/55 transition-colors","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-40","[&>svg]:size-3.5",e),...t}));Ht.displayName="RailIconButton";function xl({tone:e,className:t}){return u.jsx("span",{"aria-hidden":!0,className:G("size-1.5 shrink-0 rounded-full",e==="preview"?"bg-data-blue":"bg-warning",t)})}function yl({icon:e,label:t,onClick:n,hint:r}){return n?u.jsxs("button",{type:"button",onClick:n,title:r,className:G("flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm px-2","text-[13px] text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[u.jsx(e,{className:"size-3.5 shrink-0"}),u.jsx("span",{className:"truncate",children:t})]}):u.jsx("p",{className:"px-2 py-1 text-[12px] leading-tight text-sidebar-foreground/70",children:t})}const Yx=ag,Kx=og,Xx=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(id,{ref:i,className:G("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none",t&&"pl-8",e),...r,children:[n,u.jsx(_r,{className:"ml-auto h-4 w-4"})]}));Xx.displayName=id.displayName;const Qx=x.forwardRef(({className:e,...t},n)=>u.jsx(sd,{ref:n,className:G("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-lg",e),...t}));Qx.displayName=sd.displayName;const df=x.forwardRef(({className:e,...t},n)=>u.jsx(lg,{children:u.jsx(td,{ref:n,className:G("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md",e),...t})}));df.displayName=td.displayName;const ff=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(rd,{ref:r,className:G("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));ff.displayName=rd.displayName;const ey=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(ad,{ref:i,className:G("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(od,{children:u.jsx(an,{className:"h-4 w-4"})})}),t]}));ey.displayName=ad.displayName;const ty=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ld,{ref:r,className:G("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(od,{children:u.jsx(Td,{className:"h-4 w-4 fill-current"})})}),t]}));ty.displayName=ld.displayName;const ny=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(ud,{ref:r,className:G("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ny.displayName=ud.displayName;const pf=x.forwardRef(({className:e,...t},n)=>u.jsx(nd,{ref:n,className:G("bg-border -mx-1 my-1 h-px",e),...t}));pf.displayName=nd.displayName;const hf=({className:e,...t})=>u.jsx("span",{className:G("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});hf.displayName="ContextMenuShortcut";const Ns=ug,Es=cg,ry=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(hd,{ref:i,className:G("focus:bg-accent data-[state=open]:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,u.jsx(_r,{className:"ml-auto"})]}));ry.displayName=hd.displayName;const iy=x.forwardRef(({className:e,...t},n)=>u.jsx(md,{ref:n,className:G("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-lg",e),...t}));iy.displayName=md.displayName;const yi=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(dg,{children:u.jsx(cd,{ref:r,sideOffset:t,className:G("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));yi.displayName=cd.displayName;const $t=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(dd,{ref:r,className:G("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));$t.displayName=dd.displayName;const sy=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(gd,{ref:i,className:G("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(xd,{children:u.jsx(an,{className:"h-4 w-4"})})}),t]}));sy.displayName=gd.displayName;const ay=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(yd,{ref:r,className:G("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center rounded-sm py-1.5 pr-2 pl-8 text-sm transition-colors outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(xd,{children:u.jsx(Td,{className:"h-2 w-2 fill-current"})})}),t]}));ay.displayName=yd.displayName;const ko=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(pd,{ref:r,className:G("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ko.displayName=pd.displayName;const mr=x.forwardRef(({className:e,...t},n)=>u.jsx(fd,{ref:n,className:G("bg-muted -mx-1 my-1 h-px",e),...t}));mr.displayName=fd.displayName;const mf=({className:e,...t})=>u.jsx("span",{className:G("ml-auto text-xs tracking-widest opacity-60",e),...t});mf.displayName="DropdownMenuShortcut";const gf=x.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>u.jsx(bd,{ref:i,decorative:n,orientation:t,className:G("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));gf.displayName=bd.displayName;const xf=Jc,oy=fg,ly=Hc,yf=x.forwardRef(({className:e,...t},n)=>u.jsx(ws,{className:G("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t,ref:n}));yf.displayName=ws.displayName;const uy=gi("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),So=x.forwardRef(({side:e="right",className:t,children:n,...r},i)=>u.jsxs(ly,{children:[u.jsx(yf,{}),u.jsxs(ys,{ref:i,className:G(uy({side:e}),t),...r,children:[u.jsxs(co,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[u.jsx(yn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));So.displayName=ys.displayName;const cy=x.forwardRef(({className:e,...t},n)=>u.jsx(bs,{ref:n,className:G("text-foreground text-lg font-semibold",e),...t}));cy.displayName=bs.displayName;const dy=x.forwardRef(({className:e,...t},n)=>u.jsx(vs,{ref:n,className:G("text-muted-foreground text-sm",e),...t}));dy.displayName=vs.displayName;function Yr({className:e,...t}){return u.jsx("div",{className:G("bg-primary/10 animate-pulse rounded-md",e),...t})}const qs=768,Gs=1200;function bf(e){return typeof window<"u"?window.innerWidth<e:!1}function vf(){const[e,t]=x.useState(()=>bf(qs));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${qs-1}px)`),r=()=>{t(window.innerWidth<qs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function fy(){const[e,t]=x.useState(()=>bf(Gs));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Gs-1}px)`),r=()=>{t(window.innerWidth<Gs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const py="sidebar_state",hy=60*60*24*7,my="16rem",gy="18rem",xy="3rem",yy="b",wf=x.createContext(null);function Cs(){const e=x.useContext(wf);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const kf=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=vf(),[c,d]=x.useState(!1),[f,h]=x.useState(e),p=t??f,g=x.useCallback(E=>{const m=typeof E=="function"?E(p):E;n?n(m):h(m),document.cookie=`${py}=${m}; path=/; max-age=${hy}`},[n,p]),v=x.useCallback(()=>l?d(E=>!E):g(E=>!E),[l,g,d]);x.useEffect(()=>{const E=O=>{var k;const N=O;if(!N)return!1;const w=(k=N.tagName)==null?void 0:k.toLowerCase();return w==="input"||w==="textarea"||w==="select"||N.isContentEditable?!0:!!(N.closest&&N.closest(".monaco-editor"))},m=O=>{const N=O.metaKey||O.ctrlKey,w=O.key.toLowerCase();if(N&&w===yy){O.preventDefault(),v();return}N&&w==="s"&&!E(O.target)&&(O.preventDefault(),v())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[v]);const _=p?"expanded":"collapsed",b=x.useMemo(()=>({state:_,open:p,setOpen:g,isMobile:l,openMobile:c,setOpenMobile:d,toggleSidebar:v}),[_,p,g,l,c,d,v]);return u.jsx(wf.Provider,{value:b,children:u.jsx(kg,{delayDuration:0,children:u.jsx("div",{style:{"--sidebar-width":my,"--sidebar-width-icon":xy,...i},className:G("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});kf.displayName="SidebarProvider";const Sf=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:d}=Cs();return n==="none"?u.jsx("div",{className:G("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?u.jsx(xf,{open:c,onOpenChange:d,...s,children:u.jsx(So,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":gy},side:e,children:u.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):u.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[u.jsx("div",{className:G("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),u.jsx("div",{className:G("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:u.jsx("div",{"data-sidebar":"sidebar",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow",children:i})})]})});Sf.displayName="Sidebar";const by=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Cs();return u.jsxs(Se,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:G("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[u.jsx(Cg,{}),u.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});by.displayName="SidebarTrigger";const vy=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Cs();return u.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:G("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});vy.displayName="SidebarRail";const wy=x.forwardRef(({className:e,...t},n)=>u.jsx("main",{ref:n,className:G("bg-background relative flex min-h-svh flex-1 flex-col","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2",e),...t}));wy.displayName="SidebarInset";const ky=x.forwardRef(({className:e,...t},n)=>u.jsx(hr,{ref:n,"data-sidebar":"input",className:G("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));ky.displayName="SidebarInput";const Ma=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"header",className:G("flex flex-col gap-2 p-2",e),...t}));Ma.displayName="SidebarHeader";const _f=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"footer",className:G("flex flex-col gap-2 p-2",e),...t}));_f.displayName="SidebarFooter";const Sy=x.forwardRef(({className:e,...t},n)=>u.jsx(gf,{ref:n,"data-sidebar":"separator",className:G("bg-sidebar-border mx-2 w-auto",e),...t}));Sy.displayName="SidebarSeparator";const $a=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"content",className:G("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));$a.displayName="SidebarContent";const _y=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group",className:G("relative flex w-full min-w-0 flex-col p-2",e),...t}));_y.displayName="SidebarGroup";const jy=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?kr:"div";return u.jsx(i,{ref:r,"data-sidebar":"group-label",className:G("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opa] duration-200 ease-linear outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});jy.displayName="SidebarGroupLabel";const Ny=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?kr:"button";return u.jsx(i,{ref:r,"data-sidebar":"group-action",className:G("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});Ny.displayName="SidebarGroupAction";const Ey=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group-content",className:G("w-full text-sm",e),...t}));Ey.displayName="SidebarGroupContent";const Lr=x.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu",className:G("flex w-full min-w-0 flex-col gap-1",e),...t}));Lr.displayName="SidebarMenu";const jf=x.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,"data-sidebar":"menu-item",className:G("group/menu-item relative",e),...t}));jf.displayName="SidebarMenuItem";const Cy=gi("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Nf=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?kr:"button",{isMobile:c,state:d}=Cs(),f=u.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:G(Cy({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:f}),u.jsx(Ke,{side:"right",align:"center",hidden:d!=="collapsed"||c,...i})]})):f});Nf.displayName="SidebarMenuButton";const Ef=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?kr:"button";return u.jsx(s,{ref:i,"data-sidebar":"menu-action",className:G("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...r})});Ef.displayName="SidebarMenuAction";const Ty=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:G("text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));Ty.displayName="SidebarMenuBadge";const Iy=x.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=x.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return u.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:G("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&u.jsx(Yr,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),u.jsx(Yr,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Iy.displayName="SidebarMenuSkeleton";const Ay=x.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:G("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Ay.displayName="SidebarMenuSub";const zy=x.forwardRef(({...e},t)=>u.jsx("li",{ref:t,...e}));zy.displayName="SidebarMenuSubItem";const Oy=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?kr:"a";return u.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:G("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 cursor-pointer","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...i})});Oy.displayName="SidebarMenuSubButton";function Li(e,t){const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.style.display="none",r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}const Py=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function Dy({document:e,compact:t=!1,query:n=""}){const r=x.useRef(null),[i,s]=x.useState(!1),[a,o]=x.useState(!1),[l,c]=x.useState(!1),[d,f]=x.useState(!1),h=Ne(B=>B.openDocument),p=Ne(B=>B.documentTypes),g=Ne(B=>B.activeTab),v=rn(B=>B.name),_=rn(B=>B.text),b=rn(B=>B.isGenerating),m=(p[e.name]||"application/json+report")==="application/json+theme",O=g===e.name,[N,w]=x.useState(v),[k,R]=x.useState(_),q=100,j=0;x.useEffect(()=>{const B=setTimeout(()=>{v&&_?(w(v),R(_)):b||(w(""),R(""))},b?q:j);return()=>clearTimeout(B)},[v,_,b]);const T=N===e.name,z=B=>{var W;const y=new Set;try{const X=JSON.parse(B);(W=X.props)!=null&&W.theme&&y.add(X.props.theme),X.children&&Array.isArray(X.children)&&X.children.forEach(Y=>{var re;Y.name==="docx"&&((re=Y.props)!=null&&re.theme)&&y.add(Y.props.theme)})}catch{}return y},P=x.useMemo(()=>{if(!m||!k)return!1;try{const B=JSON.parse(e.text),y=ix(B);if(y)return z(k).has(y)}catch{}return!1},[m,k,e.text]),I=x.useCallback(()=>{c(!1)},[]),M=x.useCallback(()=>{f(!1)},[]),J=O?null:T?"preview":P?"in-use":null,Z=O?"Editing":T?"In preview":P?"Used by preview":null,V=x.useMemo(()=>[{key:"open",label:"Open",shortcut:Py?"⌘⏎":"⌃⏎",run:()=>h(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>Li(e.name,new Blob([e.text],{type:e.type}))},{key:"rename",label:"Rename…",shortcut:"⏎",separatorBefore:!0,run:()=>c(!0)},{key:"delete",label:"Delete",shortcut:"⌫",danger:!0,run:()=>f(!0)}],[e.name,e.text,e.type,h]),ne=m?Tg:Id,S=i||a,le=u.jsxs(Nf,{size:"sm",ref:r,"aria-label":Z?`${e.name} — ${Z}`:e.name,className:G("relative h-7 rounded-sm text-[13px] font-normal","text-sidebar-foreground/85 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",t?"size-7 justify-center px-0":"gap-2 pr-7 pl-2",S&&"bg-sidebar-accent/60 text-sidebar-foreground",O&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),title:Z?`${e.name} — ${Z}`:e.name,onClick:()=>{h(e.name)},onKeyDown:B=>{var y;(B.ctrlKey||B.metaKey)&&B.key==="Enter"?(h(e.name),B.preventDefault()):B.key==="Enter"?(c(!0),B.preventDefault()):B.key==="Backspace"||B.key==="Delete"?(f(!0),B.preventDefault()):B.key==="Escape"&&((y=r.current)==null||y.blur(),B.preventDefault())},children:[O&&u.jsx("span",{"aria-hidden":!0,className:G("bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full",t&&"top-1.5 bottom-1.5")}),u.jsx(ne,{className:G("size-3.5 shrink-0",m?"text-accent2":"text-sidebar-foreground/60",O&&!m&&"text-sidebar-accent-foreground/70")}),!t&&u.jsx("span",{className:"flex-1 truncate",children:u.jsx(wo,{text:e.name,query:n})}),t&&J&&u.jsx(xl,{tone:J,className:"absolute top-1 right-1 size-1.5 ring-2 ring-[hsl(var(--sidebar))]"})]});return u.jsxs(jf,{children:[u.jsxs(Yx,{onOpenChange:s,children:[u.jsx(Kx,{className:"block",children:t?u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:le}),u.jsx(Ke,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[u.jsx("div",{children:e.name}),u.jsx("div",{className:"opacity-70",children:Z??(m?"Theme":"Document")})]})})]}):le}),u.jsx(df,{className:"w-44",children:V.map(B=>u.jsxs(je.Fragment,{children:[B.separatorBefore&&u.jsx(pf,{}),u.jsxs(ff,{onClick:B.run,className:G(B.danger&&"text-destructive focus:text-destructive"),children:[B.label,B.shortcut&&u.jsx(hf,{children:B.shortcut})]})]},B.key))})]}),!t&&u.jsxs(u.Fragment,{children:[J&&u.jsx(xl,{tone:J,className:G("pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 transition-opacity","group-hover/menu-item:opacity-0 group-focus-within/menu-item:opacity-0",a&&"opacity-0")}),u.jsxs(Ns,{onOpenChange:o,children:[u.jsx(Es,{asChild:!0,children:u.jsx(Ef,{showOnHover:!0,"aria-label":`Actions for ${e.name}`,className:"top-1 size-5 rounded-sm text-sidebar-foreground/55 hover:text-sidebar-foreground [&>svg]:size-3.5",children:u.jsx(Ad,{})})}),u.jsx(yi,{side:"right",align:"start",className:"w-44",children:V.map(B=>u.jsxs(je.Fragment,{children:[B.separatorBefore&&u.jsx(mr,{}),u.jsxs($t,{onClick:B.run,className:G(B.danger&&"text-destructive focus:text-destructive"),children:[B.label,B.shortcut&&u.jsx(mf,{children:B.shortcut})]})]},B.key))})]})]}),u.jsx(Ct,{open:l,onOpenChange:c,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:B=>{var y;B.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Ki,{mode:"update",shouldReset:!l,postSubmit:I,selectedName:e.name})})}),u.jsx(Ct,{open:d,onOpenChange:f,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:B=>{var y;B.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Ki,{mode:"delete",shouldReset:!d,postSubmit:M,selectedName:e.name})})})]})}const Ni=je.memo(Dy);function Ry(e,t=!1){const n=e.length;let r=0,i="",s=0,a=16,o=0,l=0,c=0,d=0,f=0;function h(m,O){let N=0,w=0;for(;N<m;){let k=e.charCodeAt(r);if(k>=48&&k<=57)w=w*16+k-48;else if(k>=65&&k<=70)w=w*16+k-65+10;else if(k>=97&&k<=102)w=w*16+k-97+10;else break;r++,N++}return N<m&&(w=-1),w}function p(m){r=m,i="",s=0,a=16,f=0}function g(){let m=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&Zn(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46)if(r++,r<e.length&&Zn(e.charCodeAt(r)))for(r++;r<e.length&&Zn(e.charCodeAt(r));)r++;else return f=3,e.substring(m,r);let O=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101))if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&Zn(e.charCodeAt(r))){for(r++;r<e.length&&Zn(e.charCodeAt(r));)r++;O=r}else f=3;return e.substring(m,O)}function v(){let m="",O=r;for(;;){if(r>=n){m+=e.substring(O,r),f=2;break}const N=e.charCodeAt(r);if(N===34){m+=e.substring(O,r),r++;break}if(N===92){if(m+=e.substring(O,r),r++,r>=n){f=2;break}switch(e.charCodeAt(r++)){case 34:m+='"';break;case 92:m+="\\";break;case 47:m+="/";break;case 98:m+="\b";break;case 102:m+="\f";break;case 110:m+=`
3
- `;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:const k=h(4);k>=0?m+=String.fromCharCode(k):f=4;break;default:f=5}O=r;continue}if(N>=0&&N<=31)if(zr(N)){m+=e.substring(O,r),f=2;break}else f=6;r++}return m}function _(){if(i="",f=0,s=r,l=o,d=c,r>=n)return s=n,a=17;let m=e.charCodeAt(r);if(Ys(m)){do r++,i+=String.fromCharCode(m),m=e.charCodeAt(r);while(Ys(m));return a=15}if(zr(m))return r++,i+=String.fromCharCode(m),m===13&&e.charCodeAt(r)===10&&(r++,i+=`
4
- `),o++,c=r,a=14;switch(m){case 123:return r++,a=1;case 125:return r++,a=2;case 91:return r++,a=3;case 93:return r++,a=4;case 58:return r++,a=6;case 44:return r++,a=5;case 34:return r++,i=v(),a=10;case 47:const O=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!zr(e.charCodeAt(r));)r++;return i=e.substring(O,r),a=12}if(e.charCodeAt(r+1)===42){r+=2;const N=n-1;let w=!1;for(;r<N;){const k=e.charCodeAt(r);if(k===42&&e.charCodeAt(r+1)===47){r+=2,w=!0;break}r++,zr(k)&&(k===13&&e.charCodeAt(r)===10&&r++,o++,c=r)}return w||(r++,f=1),i=e.substring(O,r),a=13}return i+=String.fromCharCode(m),r++,a=16;case 45:if(i+=String.fromCharCode(m),r++,r===n||!Zn(e.charCodeAt(r)))return a=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=g(),a=11;default:for(;r<n&&b(m);)r++,m=e.charCodeAt(r);if(s!==r){switch(i=e.substring(s,r),i){case"true":return a=8;case"false":return a=9;case"null":return a=7}return a=16}return i+=String.fromCharCode(m),r++,a=16}}function b(m){if(Ys(m)||zr(m))return!1;switch(m){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function E(){let m;do m=_();while(m>=12&&m<=15);return m}return{setPosition:p,getPosition:()=>r,scan:t?E:_,getToken:()=>a,getTokenValue:()=>i,getTokenOffset:()=>s,getTokenLength:()=>r-s,getTokenStartLine:()=>l,getTokenStartCharacter:()=>s-d,getTokenError:()=>f}}function Ys(e){return e===32||e===9}function zr(e){return e===10||e===13}function Zn(e){return e>=48&&e<=57}var bl;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(bl||(bl={}));new Array(20).fill(0).map((e,t)=>" ".repeat(t));const Vn=200;new Array(Vn).fill(0).map((e,t)=>`
5
- `+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>`\r
6
- `+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>`
7
- `+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Vn).fill(0).map((e,t)=>`\r
8
- `+" ".repeat(t));var Xi;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Xi||(Xi={}));function My(e,t=[],n=Xi.DEFAULT){let r={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(l){r.type==="property"&&(r.length=l-r.offset,r=r.parent)}function s(l){return r.children.push(l),l}Fy(e,{onObjectBegin:l=>{r=s({type:"object",offset:l,length:-1,parent:r,children:[]})},onObjectProperty:(l,c,d)=>{r=s({type:"property",offset:c,length:-1,parent:r,children:[]}),r.children.push({type:"string",value:l,offset:c,length:d,parent:r})},onObjectEnd:(l,c)=>{i(l+c),r.length=l+c-r.offset,r=r.parent,i(l+c)},onArrayBegin:(l,c)=>{r=s({type:"array",offset:l,length:-1,parent:r,children:[]})},onArrayEnd:(l,c)=>{r.length=l+c-r.offset,r=r.parent,i(l+c)},onLiteralValue:(l,c,d)=>{s({type:Ly(l),offset:c,length:d,parent:r,value:l}),i(c+d)},onSeparator:(l,c,d)=>{r.type==="property"&&(l===":"?r.colonOffset=c:l===","&&i(c))},onError:(l,c,d)=>{t.push({error:l,offset:c,length:d})}},n);const o=r.children[0];return o&&delete o.parent,o}function $y(e,t){if(!e)return;let n=e;for(let r of t)if(typeof r=="string"){if(n.type!=="object"||!Array.isArray(n.children))return;let i=!1;for(const s of n.children)if(Array.isArray(s.children)&&s.children[0].value===r&&s.children.length===2){n=s.children[1],i=!0;break}if(!i)return}else{const i=r;if(n.type!=="array"||i<0||!Array.isArray(n.children)||i>=n.children.length)return;n=n.children[i]}return n}function Fy(e,t,n=Xi.DEFAULT){const r=Ry(e,!1),i=[];let s=0;function a(I){return I?()=>s===0&&I(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function o(I){return I?M=>s===0&&I(M,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(I){return I?M=>s===0&&I(M,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(I){return I?()=>{s>0?s++:I(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(s=1)}:()=>!0}function d(I){return I?()=>{s>0&&s--,s===0&&I(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const f=c(t.onObjectBegin),h=l(t.onObjectProperty),p=d(t.onObjectEnd),g=c(t.onArrayBegin),v=d(t.onArrayEnd),_=l(t.onLiteralValue),b=o(t.onSeparator),E=a(t.onComment),m=o(t.onError),O=n&&n.disallowComments,N=n&&n.allowTrailingComma;function w(){for(;;){const I=r.scan();switch(r.getTokenError()){case 4:k(14);break;case 5:k(15);break;case 3:k(13);break;case 1:O||k(11);break;case 2:k(12);break;case 6:k(16);break}switch(I){case 12:case 13:O?k(10):E();break;case 16:k(1);break;case 15:case 14:break;default:return I}}}function k(I,M=[],J=[]){if(m(I),M.length+J.length>0){let Z=r.getToken();for(;Z!==17;){if(M.indexOf(Z)!==-1){w();break}else if(J.indexOf(Z)!==-1)break;Z=w()}}}function R(I){const M=r.getTokenValue();return I?_(M):(h(M),i.push(M)),w(),!0}function q(){switch(r.getToken()){case 11:const I=r.getTokenValue();let M=Number(I);isNaN(M)&&(k(2),M=0),_(M);break;case 7:_(null);break;case 8:_(!0);break;case 9:_(!1);break;default:return!1}return w(),!0}function j(){return r.getToken()!==10?(k(3,[],[2,5]),!1):(R(!1),r.getToken()===6?(b(":"),w(),P()||k(4,[],[2,5])):k(5,[],[2,5]),i.pop(),!0)}function T(){f(),w();let I=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(I||k(4,[],[]),b(","),w(),r.getToken()===2&&N)break}else I&&k(6,[],[]);j()||k(4,[],[2,5]),I=!0}return p(),r.getToken()!==2?k(7,[2],[]):w(),!0}function z(){g(),w();let I=!0,M=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(M||k(4,[],[]),b(","),w(),r.getToken()===4&&N)break}else M&&k(6,[],[]);I?(i.push(0),I=!1):i[i.length-1]++,P()||k(4,[],[4,5]),M=!0}return v(),I||i.pop(),r.getToken()!==4?k(8,[4],[]):w(),!0}function P(){switch(r.getToken()){case 3:return z();case 1:return T();case 10:return R(!0);default:return q()}}return w(),r.getToken()===17?n.allowEmptyContent?!0:(k(4,[],[]),!1):P()?(r.getToken()!==17&&k(9,[],[]),!0):(k(4,[],[]),!1)}function Ly(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}var vl;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(vl||(vl={}));var wl;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(wl||(wl={}));const By=My,Dz=$y;var kl;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(kl||(kl={}));const Zy=60,Vy=/§jtoc:\d+§/g;function Ie(e,t){if(!(!e||e.type!=="object"||!e.children))for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children;if((r==null?void 0:r.value)===t)return i}}function st(e){return(e==null?void 0:e.type)==="string"&&typeof e.value=="string"?e.value:void 0}function Fa(e){return(e==null?void 0:e.type)==="number"&&typeof e.value=="number"?e.value:void 0}function Et(e){return(e==null?void 0:e.type)==="array"&&e.children?e.children:[]}function vt(e,t=Zy,n=!1){const r=e.replace(Vy,"…"),i=n?r.replace(/\s*\n\s*/g," ").trim():r.split(`
9
- `)[0].trim();return i.length>t?`${i.slice(0,t-1)}…`:i}function Uy(e){const t=Et(Ie(e,"columns"));if(t.length>0)return`${Math.max(0,...t.map(i=>Et(Ie(i,"cells")).length))}×${t.length}`;const n=Et(Ie(e,"rows"));if(n.length>0){const r=n[0],i=(r==null?void 0:r.type)==="array"?Et(r).length:Et(Ie(r,"cells")).length;return i>0?`${n.length}×${i}`:`${n.length} rows`}}function Jy(e){const t=st(Ie(e,"alt"));if(t)return vt(t);const n=st(Ie(e,"src"));if(n){if(n.startsWith("data:")){const i=n.slice(5).split(/[;,]/)[0];return i?`image (${i.split("/").pop()})`:"image"}const r=n.split(/[?#]/)[0].split("/").pop();if(r)return vt(r,40)}return"image"}function Hy(e,t){var r;const n=st(Ie(t,"text"));switch(e){case"heading":{const i=Fa(Ie(t,"level"))??1;return{label:n?vt(n):"heading",detail:`H${i}`}}case"text":return{label:n?vt(n):"text",detail:st(Ie(t,"style"))};case"paragraph":return{label:n?vt(n):"paragraph"};case"chart":case"highcharts":{const i=st(Ie(t,"title"))??st(Ie(Ie(t,"options"),"title"));return{label:i?vt(i):e,detail:st(Ie(t,"type"))}}case"table":return{label:"table",detail:Uy(t)};case"image":return{label:Jy(t)};case"shape":return{label:st(Ie(t,"type"))??"shape"};case"list":{const i=Et(Ie(t,"items"));return{label:"list",detail:i.length>0?`${i.length} items`:void 0}}case"section":{const i=st(Ie(Ie(t,"meta"),"title"))??st(Ie(t,"title"));return{label:i?vt(i):"section"}}case"statistic":{const i=st(Ie(t,"value"))??((r=Fa(Ie(t,"value")))==null?void 0:r.toString()),s=st(Ie(t,"label"));return{label:vt(s??i??"statistic"),detail:i}}default:return{label:n?vt(n):e}}}function gr(e){if(e.type!=="object")return null;const t=st(Ie(e,"name"));return t?{name:t,props:Ie(e,"props"),childrenArr:Ie(e,"children")}:null}function Wy(e){let t;for(const n of Et(e)){const r=gr(n);if(!r)continue;const i=st(Ie(r.props,"text"));if(i){if(r.name==="heading"||r.name==="text")return vt(i,48);r.name==="paragraph"&&t===void 0&&(t=vt(i,48))}}return t}function Qi(e,t,n){let{label:r,detail:i}=Hy(t.name,t.props);return r===t.name&&t.childrenArr&&(r=Wy(t.childrenArr)??r),{id:"",kind:t.name,label:r,detail:i,start:e.offset,end:e.offset+e.length,children:Cf(t.childrenArr),reorder:n}}function Cf(e){if(!e||e.type!=="array")return[];const t=`arr@${e.offset}`,n=[];for(const r of Et(e)){const i=gr(r);i&&n.push(Qi(r,i,{groupId:t,sliceStart:r.offset,sliceEnd:r.offset+r.length}))}return n}function qy(e){const t=Ie(e,"props"),n=st(Ie(Ie(t,"meta"),"title"));if(n)return vt(n,48,!0);let r;const i=(o,l)=>{l&&(!r||o<r.rank)&&(r={rank:o,text:l})},s=Ie(t,"placeholders");if((s==null?void 0:s.type)==="object"&&s.children)for(const o of s.children){if(o.type!=="property"||!o.children)continue;const[l,c]=o.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:"",f=c?gr(c):null,h=f?st(Ie(f.props,"text")):void 0;i(d==="title"?0:d==="subtitle"||d.startsWith("heading")?1:2,h)}const a=(o,l)=>{const c=gr(o);if(c){if(c.name==="text"||c.name==="heading"){const d=st(Ie(c.props,"text"));if(d){const f=st(Ie(c.props,"style"))??"";i(f==="title"?0:f.startsWith("heading")?1:2,d)}}if(l<1)for(const d of Et(c.childrenArr))a(d,l+1)}};for(const o of Et(Ie(e,"children")))a(o,0);return r?vt(r.text,48,!0):void 0}function Gy(e){const t=Ie(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[];let i=0;for(const s of Et(t)){const a=gr(s);if(!a)continue;const o={groupId:n,sliceStart:s.offset,sliceEnd:s.offset+s.length};a.name==="slide"?(i+=1,r.push({id:"",kind:"slide",label:qy(s)??`Slide ${i}`,detail:`${i}`,start:s.offset,end:s.offset+s.length,children:Cf(a.childrenArr),reorder:o})):r.push(Qi(s,a,o))}return r}function Yy(e){const t=Ie(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[],i=[];for(const a of Et(t)){const o=gr(a);if(!o)continue;const l={groupId:n,sliceStart:a.offset,sliceEnd:a.offset+a.length},c=()=>i.length?i[i.length-1].node.children:r;if(o.name==="heading"){const d=Fa(Ie(o.props,"level"))??1;for(;i.length&&i[i.length-1].level>=d;)i.pop();const f=Qi(a,o,l);c().push(f),i.push({level:d,node:f})}else c().push(Qi(a,o,l))}const s=a=>{a.children.forEach(s);const o=a.children[a.children.length-1];a.kind==="heading"&&o&&(a.end=Math.max(a.end,o.end),a.reorder&&o.reorder&&(a.reorder.sliceEnd=Math.max(a.reorder.sliceEnd,o.reorder.sliceEnd)))};return r.forEach(s),r}function Sl(e){switch(e.type){case"string":return vt(String(e.value??""),24);case"number":case"boolean":return String(e.value);case"array":return`${Et(e).length} items`;case"object":return;default:return}}function Ky(e){if(e.type!=="object"||!e.children)return[];const t=[];for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children,s=typeof(r==null?void 0:r.value)=="string"?r.value:void 0;if(!s||s==="$schema"||!i)continue;const a=[];if(i.type==="object"&&i.children)for(const o of i.children){if(o.type!=="property"||!o.children)continue;const[l,c]=o.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:void 0;!d||!c||a.push({id:"",kind:"key",label:d,detail:Sl(c),start:o.offset,end:o.offset+o.length,children:[]})}t.push({id:"",kind:"key",label:s,detail:a.length===0?Sl(i):void 0,start:n.offset,end:n.offset+n.length,children:a})}return t}function _l(e,t,n){if(!e.trim())return[];const r=By(e,[],{allowTrailingComma:!0});if(!r)return[];const i=n==="theme"?Ky(r):t==="pptx"?Gy(r):Yy(r);return Tf(i,""),i}function Tf(e,t){e.forEach((n,r)=>{n.id=t?`${t}.${r}`:`${r}`,Tf(n.children,n.id)})}function If(e,t){const n=[];let r=e;for(;;){const i=r.find(s=>t>=s.start&&t<s.end);if(!i)return n;n.push(i.id),r=i.children}}function Xy(e,t){const n=new Set;for(const r of t)for(const i of If(e,r))n.add(i);return n}function Qy(e,t,n,r){if(n===r||n<0||r<0||n>=t.length||r>=t.length)return null;const i=t.map(d=>d.reorder);if(i.some(d=>!d))return null;const s=i[0].groupId;if(i.some(d=>d.groupId!==s))return null;for(let d=1;d<i.length;d++)if(i[d].sliceStart<i[d-1].sliceEnd)return null;const a=i.map(d=>e.slice(d.sliceStart,d.sliceEnd)),o=[];for(let d=1;d<i.length;d++){const f=e.slice(i[d-1].sliceEnd,i[d].sliceStart);if((f.match(/,/g)??[]).length!==1)return null;o.push(f)}const l=a.map((d,f)=>f);l.splice(r,0,l.splice(n,1)[0]);let c="";return l.forEach((d,f)=>{c+=a[d],f<o.length&&(c+=o[f])}),{start:i[0].sliceStart,end:i[i.length-1].sliceEnd,text:c}}const eb={slide:Mg,heading:Rg,text:ja,paragraph:Dg,chart:Ea,highcharts:Ea,table:Pg,image:Og,shape:zd,list:zg,toc:Ag,section:Na,columns:Na,"text-box":ja,statistic:Ig,key:_a};function tb(e,t){let n=e,r=null;for(const i of t.split(".")){if(r=n[Number(i)]??null,!r)return null;n=r.children}return r}function nb(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(0,t)}function rb(){const{activeTab:e,documentTypes:t}=Ne(po(k=>({activeTab:k.activeTab,documentTypes:k.documentTypes}))),n=Ne(k=>{var R;return k.activeTab?(R=k.documents.find(q=>q.name===k.activeTab))==null?void 0:R.text:void 0}),r=$d(k=>e?k.editors.get(e)??null:null),i=e&&t[e]==="application/json+theme"?"theme":"document",[s,a]=x.useState([]),[o,l]=x.useState(null),[c,d]=x.useState(()=>new Set),[f,h]=x.useState(()=>new Set),[p,g]=x.useState(null),v=x.useRef(s);v.current=s;const _=x.useRef(null),b=x.useRef(null),E=x.useCallback(()=>{var q;if(!e){a([]);return}const k=((q=r==null?void 0:r.editor.getModel())==null?void 0:q.getValue())??n??"",R=_l(k,ht,i);if(a(R),b.current!==e){b.current=e;const j=new Set;if(i==="document"&&ht==="docx")for(const T of R)T.kind==="heading"&&j.add(T.id);h(j),l(null)}},[e,r,n,i]);x.useEffect(()=>{E();const k=r==null?void 0:r.editor.getModel();if(!k)return;const R=sl(E,300),q=k.onDidChangeContent(()=>R());return()=>{R.cancel(),q.dispose()}},[E,r]),x.useEffect(()=>{if(!r)return;const{editor:k}=r,R=sl(()=>{const j=k.getModel(),T=k.getPosition();if(!j||!T)return;const z=j.getOffsetAt(T),P=If(v.current,z);if(P.length===0){l(null);return}l(P[P.length-1]);const I=P.slice(0,-1);I.length&&h(M=>{if(I.every(Z=>M.has(Z)))return M;const J=new Set(M);for(const Z of I)J.add(Z);return J})},150),q=k.onDidChangeCursorPosition(()=>R());return()=>{R.cancel(),q.dispose()}},[r]),x.useEffect(()=>{if(!o||!_.current)return;const k=_.current.querySelector(`[data-oid="${CSS.escape(o)}"]`);k==null||k.scrollIntoView({block:"nearest"})},[o]),x.useEffect(()=>{if(!r){d(new Set);return}const{editor:k,monaco:R}=r,q=()=>{const T=k.getModel();if(!T)return;const z=R.editor.getModelMarkers({resource:T.uri}).filter(P=>P.severity===R.MarkerSeverity.Error).map(P=>T.getOffsetAt({lineNumber:P.startLineNumber,column:P.startColumn}));d(Xy(v.current,z))};q();const j=R.editor.onDidChangeMarkers(T=>{const z=k.getModel();z&&T.some(P=>P.toString()===z.uri.toString())&&q()});return()=>j.dispose()},[r,s]);const m=x.useCallback(k=>{h(R=>{const q=new Set(R);return q.has(k)?q.delete(k):q.add(k),q})},[]),O=x.useCallback(k=>{if(l(k.id),!r)return;const{editor:R,monaco:q}=r,j=R.getModel();if(!j)return;const T=j.getPositionAt(k.start),z=j.getPositionAt(k.end),P=new q.Range(T.lineNumber,T.column,z.lineNumber,z.column);R.revealRangeNearTopIfOutsideViewport(P,q.editor.ScrollType.Smooth),R.setPosition(T),R.focus();const I=R.deltaDecorations([],[{range:P,options:{className:"jto-outline-flash"}}]);window.setTimeout(()=>R.deltaDecorations(I,[]),700)},[r]),N=x.useCallback(k=>{var le;if(!r||!k.overId)return;const{editor:R,monaco:q,collapse:j}=r,T=R.getModel();if(!T)return;const z=T.getValue(),P=_l(z,ht,i),I=k.parentId?((le=tb(P,k.parentId))==null?void 0:le.children)??[]:P,M=I.findIndex(B=>B.id===k.dragId),J=I.findIndex(B=>B.id===k.overId);if(M===-1||J===-1)return;let Z=J+(k.overHalf==="after"?1:0);M<Z&&(Z-=1);const V=Qy(z,I,M,Z);if(!V)return;const ne=T.getPositionAt(V.start),S=T.getPositionAt(V.end);R.executeEdits("outline-reorder",[{range:new q.Range(ne.lineNumber,ne.column,S.lineNumber,S.column),text:V.text}]),j==null||j.resyncDecorations()},[r,i]),w=x.useMemo(()=>{const k=[],R=(q,j,T)=>{var I,M;const z=(M=(I=q[0])==null?void 0:I.reorder)==null?void 0:M.groupId,P=q.length>1&&z!==void 0&&q.every(J=>{var Z;return((Z=J.reorder)==null?void 0:Z.groupId)===z});q.forEach(J=>{const Z=eb[J.kind]??$g,V=J.children.length>0,ne=f.has(J.id),S=o===J.id,le=(p==null?void 0:p.overId)===J.id;k.push(u.jsxs("div",{"data-oid":J.id,role:"treeitem","aria-selected":S,"aria-expanded":V?ne:void 0,tabIndex:0,draggable:P,onClick:()=>O(J),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),O(J)),B.key==="ArrowRight"&&V&&!ne&&m(J.id),B.key==="ArrowLeft"&&V&&ne&&m(J.id)},onDragStart:B=>{B.dataTransfer.setData("text/plain",J.id),B.dataTransfer.effectAllowed="move",g({dragId:J.id,parentId:T,overId:null,overHalf:"before"})},onDragOver:B=>{if(!p||p.dragId===J.id||nb(p.dragId)!==T)return;B.preventDefault(),B.dataTransfer.dropEffect="move";const y=B.currentTarget.getBoundingClientRect(),W=B.clientY<y.top+y.height/2?"before":"after";(p.overId!==J.id||p.overHalf!==W)&&g({...p,overId:J.id,overHalf:W})},onDrop:B=>{B.preventDefault(),p&&N({...p,overId:J.id,overHalf:p.overHalf}),g(null)},onDragEnd:()=>g(null),className:G("group flex h-6 w-full cursor-pointer items-center gap-1 rounded-sm pr-1","text-[12px] text-sidebar-foreground/80 transition-colors select-none","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none",S&&"bg-sidebar-accent font-medium text-sidebar-foreground",le&&(p==null?void 0:p.overHalf)==="before"&&"shadow-[inset_0_2px_0_hsl(var(--ring))]",le&&(p==null?void 0:p.overHalf)==="after"&&"shadow-[inset_0_-2px_0_hsl(var(--ring))]"),style:{paddingLeft:4+j*12},children:[V?u.jsx("span",{role:"button","aria-label":ne?"Collapse":"Expand",onClick:B=>{B.stopPropagation(),m(J.id)},className:"flex size-3.5 shrink-0 items-center justify-center rounded-xs text-sidebar-foreground/55 hover:text-sidebar-foreground",children:u.jsx(_r,{className:G("size-3 transition-transform",ne&&"rotate-90")})}):u.jsx("span",{className:"size-3.5 shrink-0"}),J.kind==="slide"&&u.jsx("span",{className:"w-3 shrink-0 text-right text-[10px] tabular-nums text-sidebar-foreground/50",children:J.detail}),u.jsx(Z,{className:"size-3.5 shrink-0 text-sidebar-foreground/55"}),u.jsx("span",{className:"min-w-0 flex-1 truncate",children:J.label}),J.kind!=="slide"&&J.detail&&u.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/50",children:J.detail}),c.has(J.id)&&u.jsx("span",{"aria-label":"Contains validation errors",className:"bg-destructive size-1.5 shrink-0 rounded-full"})]},J.id)),V&&ne&&R(J.children,j+1,J.id)})};return R(s,0,""),k},[s,f,o,c,p,O,m,N]);return!e||s.length===0?null:u.jsx("li",{className:"list-none",children:u.jsx("div",{ref:_,role:"tree","aria-label":`Outline of ${e}`,className:"border-sidebar-border/70 my-0.5 ml-[15px] max-h-[38vh] overflow-y-auto border-l pl-1",children:w})})}const jl=x.memo(rb);async function ib(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const ri=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:G("relative overflow-hidden",e),...n,children:[u.jsx(pg,{className:"h-full w-full rounded-[inherit]",children:t}),u.jsx(Af,{}),u.jsx(hg,{})]}));ri.displayName=vd.displayName;const Af=x.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(wd,{ref:r,orientation:t,className:G("flex touch-none transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(mg,{className:"bg-border relative flex-1 rounded-full"})}));Af.displayName=wd.displayName;function zf({className:e,...t}){return u.jsx(gg,{"data-slot":"switch",className:G("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-off focus-visible:ring-ring inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:u.jsx(xg,{"data-slot":"switch-thumb",className:G("bg-background pointer-events-none block size-4 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const sb=gi("relative w-full rounded-sm border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-card text-foreground",destructive:"border-transparent bg-destructive-bg text-destructive-bg-foreground [&>svg]:text-destructive-bg-foreground",warning:"border-transparent bg-warning-bg text-warning-bg-foreground [&>svg]:text-warning-bg-foreground",success:"border-transparent bg-success-bg text-success-bg-foreground [&>svg]:text-success-bg-foreground",info:"border-transparent bg-data-blue-bg text-data-blue-bg-foreground [&>svg]:text-data-blue-bg-foreground"}},defaultVariants:{variant:"default"}}),ir=x.forwardRef(({className:e,variant:t,...n},r)=>u.jsx("div",{ref:r,role:"alert",className:G(sb({variant:t}),e),...n}));ir.displayName="Alert";const ab=x.forwardRef(({className:e,...t},n)=>u.jsx("h5",{ref:n,className:G("mb-1 font-medium leading-none tracking-tight",e),...t}));ab.displayName="AlertTitle";const sr=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:G("text-sm [&_p]:leading-relaxed",e),...t}));sr.displayName="AlertDescription";const es=x.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=x.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),l=()=>s(!i),c=()=>t===null?u.jsx("span",{className:"text-muted-foreground",children:"null"}):t===void 0?u.jsx("span",{className:"text-muted-foreground",children:"undefined"}):typeof t=="boolean"?u.jsx("span",{className:"text-warning",children:String(t)}):typeof t=="number"?u.jsx("span",{className:"text-success",children:t}):typeof t=="string"?t.startsWith("http")?u.jsxs("span",{className:"text-data-blue",children:['"',t,'"']}):t.startsWith("#/")?u.jsxs("span",{className:"text-warning",children:['"',t,'"']}):u.jsxs("span",{className:"text-destructive",children:['"',t,'"']}):null,d=a?Object.keys(t).length:0;return u.jsxs("div",{className:G("text-sm",n>0&&"ml-4"),children:[u.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded-sm px-1 py-0.5",children:[a&&u.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded-sm p-0.5","aria-label":i?"Collapse":"Expand",children:i?u.jsx(mi,{className:"h-3 w-3"}):u.jsx(_r,{className:"h-3 w-3"})}),!a&&u.jsx("span",{className:"w-4"}),e&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"text-data-blue",children:['"',e,'"']}),u.jsx("span",{className:"mx-1",children:":"})]}),a?u.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&u.jsxs("span",{className:"mx-1 text-xs",children:[d," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):c(),!a&&!r&&u.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&u.jsxs("div",{className:"ml-4",children:[o?t.map((f,h)=>u.jsx(es,{keyName:String(h),value:f,depth:n+1,isLast:h===t.length-1},h)):Object.entries(t).map(([f,h],p,g)=>u.jsx(es,{keyName:f,value:h,depth:n+1,isLast:p===g.length-1},f)),u.jsx("div",{className:"ml-4",children:u.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});es.displayName="JsonNode";const ts=x.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?u.jsxs("div",{className:G("space-y-4",r),children:[u.jsx(Yr,{className:"h-8 w-64"}),u.jsx(Yr,{className:"h-4 w-full"}),u.jsx(Yr,{className:"h-64 w-full"})]}):n?u.jsx(ir,{variant:"destructive",className:r,children:u.jsx(sr,{children:n})}):e?u.jsx(ri,{className:G("h-full w-full rounded-md border bg-muted/10 p-4",r),children:u.jsx("div",{className:"font-mono text-xs",children:u.jsx(es,{value:e})})}):u.jsx(ir,{className:r,children:u.jsx(sr,{children:"No schema available"})}));ts.displayName="SchemaViewer";function ob({plugins:e,initialFocusedPlugin:t}){var m,O;const n=Lt(N=>N.togglePlugin),r=Lt(N=>N.isPluginSelected),i=Lt(N=>N.selectedPlugins),s=Lt(N=>N.isApplyingPlugins),[a,o]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState("properties");x.useEffect(()=>{if(t){const N=e.find(w=>w.name===t);if(N){o(N);return}}e.length>0&&!a&&o(e[0])},[t,e]);const h=x.useMemo(()=>{const N={current:[],downstream:[],upstream:[]};return e.forEach(w=>{N[w.location]&&N[w.location].push(w)}),N},[e]),p=async(N,w)=>{a&&(await ib(a.name,N.props),c(w),setTimeout(()=>c(null),2e3))},g=N=>{switch(N){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return N}},v=N=>{switch(N){case"current":return u.jsx(Ug,{className:"size-3"});case"downstream":return u.jsx(Vg,{className:"size-3"});case"upstream":return u.jsx(Id,{className:"size-3"});default:return null}},_=((m=a==null?void 0:a.schema)==null?void 0:m.properties)&&Object.keys(a.schema.properties).length>0,b=(O=a==null?void 0:a.schema)==null?void 0:O.jsonSchema,E=(a==null?void 0:a.examples)&&a.examples.length>0;return u.jsxs(u.Fragment,{children:[u.jsxs(Vt,{children:[u.jsxs(Ut,{className:"flex items-center gap-2",children:[u.jsx(Fg,{className:"size-5 text-warning"}),"Plugins",u.jsxs(Kt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),u.jsxs(on,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),u.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[u.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:u.jsx(ri,{className:"h-full",children:u.jsx("div",{className:"p-2 space-y-3",children:Object.entries(h).map(([N,w])=>w.length===0?null:u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[v(N),g(N)]}),u.jsx("div",{className:"space-y-0.5",children:w.map(k=>{const R=r(k.name),q=(a==null?void 0:a.name)===k.name;return u.jsxs("button",{onClick:()=>o(k),className:G("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",q?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[u.jsx("div",{className:G("size-1.5 rounded-full flex-none transition-colors",R?"bg-warning":"bg-muted-foreground/30")}),u.jsx("span",{className:"text-sm font-medium truncate flex-1",children:k.name})]},k.name)})})]},N))})})}),a?u.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[u.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("h3",{className:"text-base font-semibold truncate",children:a.name}),a.version&&u.jsxs(Kt,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",a.version]})]}),a.description&&u.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:a.description})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:r(a.name)?"On":"Off"}),u.jsx(zf,{checked:r(a.name),onCheckedChange:()=>n(a),disabled:s,"aria-label":`Toggle ${a.name}`})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[v(a.location),u.jsx("span",{children:g(a.location)}),u.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),u.jsx("span",{className:"font-mono truncate",children:a.relativePath})]})]}),u.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[_&&u.jsx("button",{onClick:()=>f("properties"),className:G("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(_a,{className:"size-3.5"}),"Properties"]})}),b&&u.jsx("button",{onClick:()=>f("schema"),className:G("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Lg,{className:"size-3.5"}),"Schema"]})}),E&&u.jsx("button",{onClick:()=>f("examples"),className:G("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Bg,{className:"size-3.5"}),"Examples",u.jsx(Kt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),u.jsx(ri,{className:"flex-1",children:u.jsxs("div",{className:"p-5",children:[d==="properties"&&_&&u.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([N,w])=>u.jsx(lb,{name:N,prop:w},N))}),d==="schema"&&b&&u.jsx(ts,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),d==="examples"&&E&&a.examples.map((N,w)=>u.jsxs("div",{className:G(w>0&&"mt-4 pt-4 border-t"),children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[N.title&&u.jsx("span",{className:"font-medium text-sm truncate",children:N.title}),!N.title&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",w+1]})]}),u.jsx(Se,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>p(N,w),children:l===w?u.jsxs(u.Fragment,{children:[u.jsx(Zg,{className:"size-3 mr-1 text-success"}),"Copied"]}):u.jsxs(u.Fragment,{children:[u.jsx(ks,{className:"size-3 mr-1"}),"Copy"]})})]}),N.description&&u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:N.description}),u.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(N.props,null,2)})]},w)),!_&&!b&&!E&&u.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[u.jsx(_a,{className:"size-10 mx-auto mb-3 opacity-20"}),u.jsx("p",{className:"text-sm",children:"No schema or examples available for this plugin"})]})]})})]}):u.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:u.jsx("p",{className:"text-sm",children:"Select a plugin to view details"})})]})]})}function lb({name:e,prop:t}){var a;const[n,r]=x.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return u.jsxs("div",{className:"rounded-md border",children:[u.jsxs("button",{onClick:()=>i&&r(!n),className:G("w-full text-left flex items-center gap-2 px-3 py-2 text-sm",i&&"cursor-pointer hover:bg-muted/50"),children:[i?n?u.jsx(mi,{className:"size-3 text-muted-foreground flex-none"}):u.jsx(_r,{className:"size-3 text-muted-foreground flex-none"}):u.jsx("span",{className:"size-3 flex-none"}),u.jsx("span",{className:"font-mono font-medium text-xs",children:e}),u.jsx(Kt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 flex-none",children:s}),t.optional===!1&&u.jsx("span",{className:"text-[10px] text-destructive font-medium flex-none",children:"required"}),u.jsx("span",{className:"flex-1"}),t.default!==void 0&&u.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&u.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&u.jsx("p",{children:t.description}),t.enum&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((o,l)=>u.jsxs("span",{children:[l>0&&", ",u.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(o)})]},l))]}),((a=t.items)==null?void 0:a.type)&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const ub={current:"Current directory",downstream:"Project"};function Nl({location:e}){return u.jsx("li",{className:"list-none px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:ub[e]??e})}function El({name:e,subtitle:t,query:n,onSelect:r}){return u.jsx("li",{className:"list-none",children:u.jsxs("button",{type:"button",onClick:r,title:t?`${e} — ${t}`:e,"aria-label":`Add ${e} to workspace`,className:G("group/row flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm pr-1 pl-2","text-[13px] text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[u.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:u.jsx(wo,{text:e,query:n})}),u.jsx(nn,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-sidebar-foreground/45 opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-visible/row:opacity-100"})]})})}function cb({plugins:e,query:t,open:n,onToggleSection:r,onShowPluginDetails:i,isPluginSelected:s,onTogglePlugin:a,isApplyingPlugins:o,selectedPluginCount:l}){return e.length===0?null:u.jsxs("section",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:[u.jsx(Ra,{open:n,onToggle:r,count:`${l}/${e.length}`,children:"Plugins"}),n&&u.jsx("div",{className:"flex flex-col gap-0.5",children:e.map(c=>{const d=s(c.name),f=`plugin-switch-${c.filePath||c.name}`;return u.jsxs("div",{title:c.description?`${c.name} — ${c.description}`:c.name,className:G("group/row flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2","transition-colors hover:bg-sidebar-accent/60"),children:[u.jsx("label",{htmlFor:f,className:G("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]",d?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:u.jsx("span",{className:"truncate",children:u.jsx(wo,{text:c.name,query:t})})}),u.jsx(Ht,{"aria-label":`Details for ${c.name}`,onClick:h=>{h.stopPropagation(),i(c.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:u.jsx(Od,{})}),u.jsx(zf,{id:f,checked:d,onCheckedChange:()=>a(c),disabled:o,className:"shrink-0","aria-label":`Toggle ${c.name} plugin`})]},c.filePath||c.name)})})]})}function Cl(e){return x.useMemo(()=>{const t=["current","downstream"],n=new Map;return e.forEach(r=>{const i=n.get(r.location);i?i.push(r):n.set(r.location,[r])}),[...n.entries()].sort(([r],[i])=>t.indexOf(r)-t.indexOf(i))},[e])}function Of({children:e,className:t}){return u.jsx("kbd",{"data-slot":"kbd",className:G("pointer-events-none inline-flex h-5 w-fit min-w-5 select-none items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground","[[data-slot=tooltip-content]_&]:bg-primary-foreground/20 [[data-slot=tooltip-content]_&]:text-primary-foreground",t),children:e})}function db({children:e,className:t}){return u.jsx("span",{className:G("inline-flex items-center gap-0.5",t),children:e})}const Ei=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function ii({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return Ei?"⌘":"Ctrl";case"shift":return Ei?"⇧":"Shift";case"alt":return Ei?"⌥":"Alt";case"ctrl":return Ei?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return u.jsx(db,{className:t,children:r.map((i,s)=>u.jsx(Of,{children:i},s))})}function fb({className:e}={}){const{theme:t,setTheme:n}=jd(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=x.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsxs(Se,{variant:"ghost",size:"icon",onClick:i,className:e,children:[u.jsx(Jg,{className:"hidden dark:block"}),u.jsx(Hg,{className:"block dark:hidden"}),u.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:"Toggle theme"})})]})}function pb({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o,activeTab:l}=Ne(po(A=>({documents:A.documents,documentTypes:A.documentTypes,createDocument:A.createDocument,openDocument:A.openDocument,activeTab:A.activeTab}))),c=Ia(A=>A.updateTheme),d=Ia(A=>A.removeTheme),f=x.useContext(Fd),[h,p]=x.useState(!1),[g,v]=x.useState(!1),[_,b]=x.useState(!1),[E,m]=x.useState(null),O=Lt(A=>A.togglePlugin),N=Lt(A=>A.isPluginSelected),w=Lt(A=>A.selectedPlugins),k=Lt(A=>A.isApplyingPlugins),[R,q]=x.useState(!1),[j,T]=x.useState(new Set(["documents","themes"])),[z,P]=x.useState(""),I=x.useRef(null),{toast:M}=Sr(),J=i.filter(A=>s[A.name]!=="application/json+theme"),Z=i.filter(A=>s[A.name]==="application/json+theme"),V=x.useCallback(()=>{p(!1)},[]),ne=x.useCallback(()=>{v(!1)},[]),S=x.useRef(new Map);x.useEffect(()=>{const A=S.current,K=new Map;Z.forEach(ee=>{K.set(ee.name,ee.text),A.get(ee.name)!==ee.text&&c(ee.name,ee.text)}),A.forEach((ee,xe)=>{K.has(xe)||d(xe)}),S.current=K},[Z,c,d]);const le=x.useRef(!1);x.useEffect(()=>{if(le.current||!f)return;le.current=!0;const A=new Set(Z.map(ee=>ee.name));Object.keys(f.getState().customThemes).forEach(ee=>{A.has(ee)||d(ee)})},[Z,d,f]);const B=x.useCallback(A=>{T(K=>{const ee=new Set(K);return ee.has(A)?ee.delete(A):ee.add(A),ee})},[]),{resolvedTheme:y}=jd(),W=y==="dark"?"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo-white.svg?updatedAt=1751359555877":"https://ik.imagekit.io/wiseair/Brand%20assets/wiseair-logo.svg?updatedAt=1749817149276",X=x.useCallback(async(A,K)=>{if(i.some(ee=>ee.name===A)){o(A);return}try{const ee=await fetch(`/api/discovery/${K?"themes":"documents"}/${encodeURIComponent(A)}/content`);if(!ee.ok)throw new Error(ee.statusText);const xe=await ee.text(),L=JSON.parse(xe);a(A,JSON.stringify(L,null,2)),o(A),M({title:`Added ${K?"theme":"document"}: ${A}`})}catch{M({title:"Failed to load",description:`Could not load ${A}`,variant:"destructive"})}},[i,a,o,M]);x.useEffect(()=>{if(n)return;const A=K=>{var L,Q,he,ve,F;if(K.key!=="/"||K.metaKey||K.ctrlKey||K.altKey)return;const ee=K.target,xe=(L=ee==null?void 0:ee.tagName)==null?void 0:L.toLowerCase();xe==="input"||xe==="textarea"||xe==="select"||ee!=null&&ee.isContentEditable||(Q=ee==null?void 0:ee.closest)!=null&&Q.call(ee,".monaco-editor")||(he=I.current)!=null&&he.closest('[aria-hidden="true"], [inert]')||(K.preventDefault(),(ve=I.current)==null||ve.focus(),(F=I.current)==null||F.select())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n]);const Y=z.trim(),re=x.useMemo(()=>new Set(i.map(A=>A.name)),[i]),D=x.useMemo(()=>J.filter(A=>cn(A.name,Y)),[J,Y]),de=x.useMemo(()=>Z.filter(A=>cn(A.name,Y)),[Z,Y]),te=x.useMemo(()=>((e==null?void 0:e.documents)??[]).filter(A=>!re.has(A.name)&&(cn(A.name,Y)||cn(A.title??"",Y))),[e,Y,re]),ae=x.useMemo(()=>((e==null?void 0:e.themes)??[]).filter(A=>!re.has(A.name)&&(cn(A.name,Y)||cn(A.description??"",Y))),[e,Y,re]),ue=Cl(te),ge=Cl(ae),pe=x.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter(A=>cn(A.name,Y)||cn(A.description??"",Y)),[e,Y]),Pe=A=>Y.length>0||j.has(A),De=Pe("documents"),nt=Pe("themes"),C=D.length+te.length,$=de.length+ae.length,U=Y.length>0&&D.length===0&&de.length===0&&te.length===0&&ae.length===0&&pe.length===0,se=G("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return u.jsxs(u.Fragment,{children:[u.jsxs(Sf,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?u.jsxs(u.Fragment,{children:[u.jsx(Ma,{className:G("gap-0 p-1.5",se),children:u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Ht,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:u.jsx(Pd,{})})}),u.jsxs(Ke,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Expand sidebar"}),u.jsx(ii,{shortcut:"mod+b"})]})]})}),u.jsxs($a,{className:G("gap-2 px-1 py-1",se),children:[u.jsxs(Lr,{className:"items-center gap-0.5",children:[J.map(A=>u.jsx(Ni,{document:A,compact:!0},A.name)),u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Ht,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Ke,{side:"right",children:"New document"})]})]}),u.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),u.jsxs(Lr,{className:"items-center gap-0.5",children:[Z.map(A=>u.jsx(Ni,{document:A,compact:!0},A.name)),u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Ht,{className:"size-7","aria-label":"New theme",onClick:()=>v(!0),children:u.jsx(nn,{})})}),u.jsx(Ke,{side:"right",children:"New theme"})]})]})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs(Ma,{className:G("gap-0 p-2",se),children:[u.jsxs("div",{className:"flex h-7 items-center justify-between gap-1",children:[u.jsx("a",{href:"/","aria-label":"JSON to Office home",className:"focus-visible:ring-sidebar-ring flex items-center rounded-sm pl-1 focus-visible:ring-1 focus-visible:outline-none",children:u.jsx("img",{src:W,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Ht,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:u.jsx(Wg,{})})}),u.jsxs(Ke,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Collapse sidebar"}),u.jsx(ii,{shortcut:"mod+b"})]})]})]}),u.jsxs("div",{className:"relative mt-2",children:[u.jsx(qg,{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-sidebar-foreground/40"}),u.jsx("input",{ref:I,type:"text",value:z,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:A=>P(A.target.value),onKeyDown:A=>{A.key==="Escape"&&(A.preventDefault(),P(""),A.currentTarget.blur())},className:G("border-sidebar-border/70 bg-sidebar-accent/40 h-7 w-full rounded-sm border","pr-7 pl-7 text-[13px] text-sidebar-foreground transition-colors","placeholder:text-sidebar-foreground/60","focus-visible:border-sidebar-ring focus-visible:bg-sidebar-accent/60","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none")}),Y?u.jsx(Ht,{"aria-label":"Clear filter",onClick:()=>{var A;P(""),(A=I.current)==null||A.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:u.jsx(yn,{})}):u.jsx(Of,{className:"absolute top-1/2 right-1.5 h-4 min-w-4 -translate-y-1/2 bg-transparent px-0 text-[10px] text-sidebar-foreground/65",children:"/"})]})]}),u.jsx($a,{className:G("gap-0 px-2 pb-2",se),children:U?u.jsxs("div",{className:"px-1 py-6 text-center",children:[u.jsxs("p",{className:"text-[13px] text-sidebar-foreground/70",children:["No files match “",Y,"”"]}),u.jsx("button",{type:"button",onClick:()=>{var A;P(""),(A=I.current)==null||A.focus()},className:"text-sidebar-foreground/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring mt-1 cursor-pointer rounded-sm text-[12px] underline-offset-2 hover:underline focus-visible:ring-1 focus-visible:outline-none",children:"Clear filter"})]}):u.jsxs(u.Fragment,{children:[(C>0||!Y)&&u.jsxs("section",{children:[u.jsx(Ra,{open:De,onToggle:()=>B("documents"),count:C||void 0,actions:u.jsxs(u.Fragment,{children:[ht==="docx"&&u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Ht,{"aria-label":"Compare documents",disabled:J.length<2,onClick:()=>q(!0),children:u.jsx(Cd,{})})}),u.jsx(Ke,{side:"bottom",children:J.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Ht,{"aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Ke,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),De&&u.jsxs(Lr,{className:"gap-0.5",children:[D.map(A=>u.jsxs(x.Fragment,{children:[u.jsx(Ni,{document:A,query:Y}),!Y&&l===A.name&&u.jsx(jl,{})]},A.name)),ue.map(([A,K])=>u.jsxs(x.Fragment,{children:[ue.length>1&&u.jsx(Nl,{location:A}),K.map(ee=>u.jsx(El,{name:ee.name,subtitle:ee.title,query:Y,onSelect:()=>X(ee.name,!1)},ee.path||ee.name))]},A)),C===0&&u.jsx("li",{className:"list-none",children:u.jsx(yl,{icon:nn,label:"New document",onClick:()=>p(!0)})})]})]}),($>0||!Y)&&u.jsxs("section",{className:"mt-3",children:[u.jsx(Ra,{open:nt,onToggle:()=>B("themes"),count:$||void 0,actions:u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Ht,{"aria-label":"New theme",onClick:()=>v(!0),children:u.jsx(nn,{})})}),u.jsx(Ke,{side:"bottom",children:"New theme"})]}),children:"Themes"}),nt&&u.jsxs(Lr,{className:"gap-0.5",children:[de.map(A=>u.jsxs(x.Fragment,{children:[u.jsx(Ni,{document:A,query:Y}),!Y&&l===A.name&&u.jsx(jl,{})]},A.name)),ge.map(([A,K])=>u.jsxs(x.Fragment,{children:[ge.length>1&&u.jsx(Nl,{location:A}),K.map(ee=>u.jsx(El,{name:ee.name,subtitle:ee.description,query:Y,onSelect:()=>X(ee.name,!0)},ee.path||ee.name))]},A)),$===0&&u.jsx("li",{className:"list-none",children:u.jsx(yl,{icon:nn,label:"New theme",onClick:()=>v(!0)})})]})]}),u.jsx(cb,{plugins:pe,query:Y,open:Pe("plugins"),onToggleSection:()=>B("plugins"),onShowPluginDetails:A=>{m(A),b(!0)},isPluginSelected:N,onTogglePlugin:O,isApplyingPlugins:k,selectedPluginCount:w.size})]})})]}),u.jsx(_f,{className:G("border-sidebar-border/70 gap-0 border-t p-1.5",se),children:u.jsx("div",{className:G("flex items-center",n?"justify-center":"justify-start"),children:u.jsx(fb,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),u.jsx(Ct,{open:h,onOpenChange:p,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Ki,{mode:"create",shouldReset:!h,postSubmit:V,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),u.jsx(Ct,{open:g,onOpenChange:v,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Ki,{mode:"create",shouldReset:!g,postSubmit:ne,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),u.jsx(Ct,{open:_,onOpenChange:A=>{b(A),A||m(null)},children:u.jsx(kt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:u.jsx(ob,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:E})})}),u.jsx(vx,{open:R,onOpenChange:q})]})}const Tl=x.memo(pb),hb=x.lazy(()=>Nd(()=>import("./editor-D-REaAU9.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.Editor})));function Il(){return u.jsx(x.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(gn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:u.jsx(hb,{})})}const mb=x.lazy(()=>Nd(()=>import("./preview-BGqIip90.js"),__vite__mapDeps([13,1,3,4,5,6,7,8,9,10,12,11])).then(e=>({default:e.Preview})));function Al(){return u.jsx(x.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(gn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:u.jsx(mb,{})})}const{createElement:xr,createContext:gb,forwardRef:Pf,useCallback:gt,useContext:Df,useEffect:zn,useImperativeHandle:Rf,useLayoutEffect:xb,useMemo:yb,useRef:wt,useState:ar}=Uc,zl=Uc[`useId${Math.random()}`.slice(0,5)],bb=xb,Ts=gb(null);Ts.displayName="PanelGroupContext";const On=bb,vb=typeof zl=="function"?zl:()=>null;let wb=0;function _o(e=null){const t=vb(),n=wt(e||t||null);return n.current===null&&(n.current=""+wb++),e??n.current}function Mf({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:h,style:p,tagName:g="div",...v}){const _=Df(Ts);if(_===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:E,getPanelSize:m,getPanelStyle:O,groupId:N,isPanelCollapsed:w,reevaluatePanelConstraints:k,registerPanel:R,resizePanel:q,unregisterPanel:j}=_,T=_o(a),z=wt({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:T,idIsFromProps:a!==void 0,order:h});wt({didLogMissingDefaultSizeWarning:!1}),On(()=>{const{callbacks:I,constraints:M}=z.current,J={...M};z.current.id=T,z.current.idIsFromProps=a!==void 0,z.current.order=h,I.onCollapse=c,I.onExpand=d,I.onResize=f,M.collapsedSize=n,M.collapsible=r,M.defaultSize=i,M.maxSize=o,M.minSize=l,(J.collapsedSize!==M.collapsedSize||J.collapsible!==M.collapsible||J.maxSize!==M.maxSize||J.minSize!==M.minSize)&&k(z.current,J)}),On(()=>{const I=z.current;return R(I),()=>{j(I)}},[h,T,R,j]),Rf(s,()=>({collapse:()=>{b(z.current)},expand:I=>{E(z.current,I)},getId(){return T},getSize(){return m(z.current)},isCollapsed(){return w(z.current)},isExpanded(){return!w(z.current)},resize:I=>{q(z.current,I)}}),[b,E,m,w,T,q]);const P=O(z.current,i);return xr(g,{...v,children:e,className:t,id:a,style:{...P,...p},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":N,"data-panel-id":T,"data-panel-size":parseFloat(""+P.flexGrow).toFixed(1)})}const $f=Pf((e,t)=>xr(Mf,{...e,forwardedRef:t}));Mf.displayName="Panel";$f.displayName="forwardRef(Panel)";let La=null,An=null;function kb(e,t){if(t){const n=(t&Vf)!==0,r=(t&Uf)!==0,i=(t&Jf)!==0,s=(t&Hf)!==0;if(n)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Sb(){An!==null&&(document.head.removeChild(An),La=null,An=null)}function Ks(e,t){const n=kb(e,t);La!==n&&(La=n,An===null&&(An=document.createElement("style"),document.head.appendChild(An)),An.innerHTML=`*{cursor: ${n}!important;}`)}function Ff(e){return e.type==="keydown"}function Lf(e){return e.type.startsWith("pointer")}function Bf(e){return e.type.startsWith("mouse")}function Is(e){if(Lf(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Bf(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function _b(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function jb(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Nb(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Dl(e),b:Dl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;_e(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Pl(Ol(n.a)),b:Pl(Ol(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let o=s.length;for(;o--;){const l=s[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(i.a-i.b)}const Eb=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cb(e){var t;const n=getComputedStyle((t=Zf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Tb(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Cb(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Eb.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Ol(e){let t=e.length;for(;t--;){const n=e[t];if(_e(n,"Missing node"),Tb(n))return n}return null}function Pl(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Dl(e){const t=[];for(;e;)t.push(e),e=Zf(e);return t}function Zf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Vf=1,Uf=2,Jf=4,Hf=8,Ib=_b()==="coarse";let Bt=[],or=!1,mn=new Map,As=new Map;const si=new Set;function Ab(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=mn.get(a))!==null&&s!==void 0?s:0;return mn.set(a,l+1),si.add(o),ns(),function(){var d;As.delete(e),si.delete(o);const f=(d=mn.get(a))!==null&&d!==void 0?d:1;if(mn.set(a,f-1),ns(),f===1&&mn.delete(a),Bt.includes(o)){const h=Bt.indexOf(o);h>=0&&Bt.splice(h,1),No(),i("up",!0,null)}}}function Rl(e){const{target:t}=e,{x:n,y:r}=Is(e);or=!0,jo({target:t,x:n,y:r}),ns(),Bt.length>0&&(rs("down",e),e.preventDefault(),e.stopPropagation())}function Or(e){const{x:t,y:n}=Is(e);if(or&&e.buttons===0&&(or=!1,rs("up",e)),!or){const{target:r}=e;jo({target:r,x:t,y:n})}rs("move",e),No(),Bt.length>0&&e.preventDefault()}function Un(e){const{target:t}=e,{x:n,y:r}=Is(e);As.clear(),or=!1,Bt.length>0&&e.preventDefault(),rs("up",e),jo({target:t,x:n,y:r}),No(),ns()}function jo({target:e,x:t,y:n}){Bt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),si.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:c,right:d,top:f}=o,h=Ib?a.coarse:a.fine;if(t>=c-h&&t<=d+h&&n>=f-h&&n<=l+h){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Nb(r,s)>0){let g=r,v=!1;for(;g&&!g.contains(s);){if(jb(g.getBoundingClientRect(),o)){v=!0;break}g=g.parentElement}if(v)return}Bt.push(i)}})}function Xs(e,t){As.set(e,t)}function No(){let e=!1,t=!1;Bt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;As.forEach(r=>{n|=r}),e&&t?Ks("intersection",n):e?Ks("horizontal",n):t?Ks("vertical",n):Sb()}function ns(){mn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Un),n.removeEventListener("pointerdown",Rl),n.removeEventListener("pointerleave",Or),n.removeEventListener("pointermove",Or)}),window.removeEventListener("pointerup",Un),window.removeEventListener("pointercancel",Un),si.size>0&&(or?(Bt.length>0&&mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Un),n.addEventListener("pointerleave",Or),n.addEventListener("pointermove",Or))}),window.addEventListener("pointerup",Un),window.addEventListener("pointercancel",Un)):mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",Rl,{capture:!0}),n.addEventListener("pointermove",Or))}))}function rs(e,t){si.forEach(n=>{const{setResizeHandlerState:r}=n,i=Bt.includes(n);r(e,i,t)})}function zb(){const[e,t]=ar(0);return gt(()=>t(n=>n+1),[])}function _e(e,t){if(!e)throw console.error(t),Error(t)}const Eo=10;function Dn(e,t,n=Eo){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function sn(e,t,n=Eo){return Dn(e,t,n)===0}function Nt(e,t,n){return Dn(e,t,n)===0}function Ob(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],s=t[r];if(!Nt(i,s,n))return!1}return!0}function tr({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];_e(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(Dn(n,o)<0)if(s){const l=(i+o)/2;Dn(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(Eo)),n}function Br({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Nt(e,0))return t;const a=[...t],[o,l]=r;_e(o!=null,"Invalid first pivot index"),_e(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const f=e<0?l:o,h=n[f];_e(h,`Panel constraints not found for index ${f}`);const{collapsedSize:p=0,collapsible:g,minSize:v=0}=h;if(g){const _=t[f];if(_e(_!=null,`Previous layout not found for panel index ${f}`),Nt(_,p)){const b=v-_;Dn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const f=e<0?o:l,h=n[f];_e(h,`No panel constraints found for index ${f}`);const{collapsedSize:p=0,collapsible:g,minSize:v=0}=h;if(g){const _=t[f];if(_e(_!=null,`Previous layout not found for panel index ${f}`),Nt(_,v)){const b=_-p;Dn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const f=e<0?1:-1;let h=e<0?l:o,p=0;for(;;){const v=t[h];_e(v!=null,`Previous layout not found for panel index ${h}`);const b=tr({panelConstraints:n,panelIndex:h,size:100})-v;if(p+=b,h+=f,h<0||h>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let h=e<0?o:l;for(;h>=0&&h<n.length;){const p=Math.abs(e)-Math.abs(c),g=t[h];_e(g!=null,`Previous layout not found for panel index ${h}`);const v=g-p,_=tr({panelConstraints:n,panelIndex:h,size:v});if(!Nt(g,_)&&(c+=g-_,a[h]=_,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(Ob(i,a))return i;{const f=e<0?l:o,h=t[f];_e(h!=null,`Previous layout not found for panel index ${f}`);const p=h+c,g=tr({panelConstraints:n,panelIndex:f,size:p});if(a[f]=g,!Nt(g,p)){let v=p-g,b=e<0?l:o;for(;b>=0&&b<n.length;){const E=a[b];_e(E!=null,`Previous layout not found for panel index ${b}`);const m=E+v,O=tr({panelConstraints:n,panelIndex:b,size:m});if(Nt(E,O)||(v-=O-E,a[b]=O),Nt(v,0))break;e>0?b--:b++}}}const d=a.reduce((f,h)=>h+f,0);return Nt(d,100)?a:i}function Pb({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];_e(o!=null,"No pivot index found"),t.forEach((f,h)=>{const{constraints:p}=f,{maxSize:g=100,minSize:v=0}=p;h===o?(r=v,i=g):(s+=v,a+=g)});const l=Math.min(i,100-s),c=Math.max(r,100-a),d=e[o];return{valueMax:l,valueMin:c,valueNow:d}}function ai(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Wf(e,t,n=document){const i=ai(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function qf(e,t,n){const r=Wf(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Gf(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function zs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function Db(e,t,n,r=document){var i,s,a,o;const l=zs(t,r),c=ai(e,r),d=l?c.indexOf(l):-1,f=(i=(s=n[d])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,h=(a=(o=n[d+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[f,h]}function Rb({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){wt({didWarnAboutMissingResizeHandle:!1}),On(()=>{if(!s)return;const o=ai(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:d,valueNow:f}=Pb({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),h=o[l];if(h!=null){const p=i[l];_e(p,`No panel data found for index "${l}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(c)),h.setAttribute("aria-valuemin",""+Math.round(d)),h.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{o.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),zn(()=>{if(!s)return;const o=t.current;_e(o,"Eager values not found");const{panelDataArray:l}=o,c=Gf(n,s);_e(c!=null,`No group found for id "${n}"`);const d=ai(n,s);_e(d,`No resize handles found for group id "${n}"`);const f=d.map(h=>{const p=h.getAttribute("data-panel-resize-handle-id");_e(p,"Resize handle element has no handle id attribute");const[g,v]=Db(n,p,l,s);if(g==null||v==null)return()=>{};const _=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const E=l.findIndex(m=>m.id===g);if(E>=0){const m=l[E];_e(m,`No panel data found for index ${E}`);const O=r[E],{collapsedSize:N=0,collapsible:w,minSize:k=0}=m.constraints;if(O!=null&&w){const R=Br({delta:Nt(O,N)?k-N:N-O,initialLayout:r,panelConstraints:l.map(q=>q.constraints),pivotIndices:qf(n,p,s),prevLayout:r,trigger:"keyboard"});r!==R&&a(R)}}break}}};return h.addEventListener("keydown",_),()=>{h.removeEventListener("keydown",_)}});return()=>{f.forEach(h=>h())}},[s,e,t,n,r,i,a])}function Ml(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Yf(e,t){const n=e==="horizontal",{x:r,y:i}=Is(t);return n?r:i}function Mb(e,t,n,r,i){const s=n==="horizontal",a=zs(t,i);_e(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");_e(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=Yf(n,e),d=Gf(o,i);_e(d,`No group element found for id "${o}"`);const f=d.getBoundingClientRect(),h=s?f.width:f.height;return(c-l)/h*100}function $b(e,t,n,r,i,s){if(Ff(e)){const a=n==="horizontal";let o=0;e.shiftKey?o=100:i!=null?o=i:o=10;let l=0;switch(e.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:Mb(e,t,n,r,s)}function Fb({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;o!=null&&(r++,t[s]=o,i-=o)}for(let s=0;s<e.length;s++){const a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function Jn(e,t,n){t.forEach((r,i)=>{const s=e[i];_e(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:l}=s,{collapsedSize:c=0,collapsible:d}=o,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:h,onExpand:p,onResize:g}=a;g&&g(r,f),d&&(h||p)&&(p&&(f==null||sn(f,c))&&!sn(r,c)&&p(),h&&(f==null||!sn(f,c))&&sn(r,c)&&h())}})}function Ci(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Lb({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const a=n[i];let o;return a==null?o=e!=null?e.toPrecision(s):"1":r.length===1?o="1":o=a.toPrecision(s),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Bb(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function $l(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Kf(e){return`react-resizable-panels:${e}`}function Xf(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:s}=t;return i?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Qf(e,t){try{const n=Kf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Zb(e,t,n){var r,i;const s=(r=Qf(e,n))!==null&&r!==void 0?r:{},a=Xf(t);return(i=s[a])!==null&&i!==void 0?i:null}function Vb(e,t,n,r,i){var s;const a=Kf(e),o=Xf(t),l=(s=Qf(e,i))!==null&&s!==void 0?s:{};l[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(l))}catch(c){console.error(c)}}function Fl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,a)=>s+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Nt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=100/r*a;n[s]=o}let i=0;for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=tr({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!Nt(i,0))for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=a+i,l=tr({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,Nt(i,0)))break}return n}const Ub=100,Zr={getItem:e=>($l(Zr),Zr.getItem(e)),setItem:(e,t)=>{$l(Zr),Zr.setItem(e,t)}},Ll={};function ep({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=Zr,style:c,tagName:d="div",...f}){const h=_o(s),p=wt(null),[g,v]=ar(null),[_,b]=ar([]),E=zb(),m=wt({}),O=wt(new Map),N=wt(0),w=wt({autoSaveId:e,direction:r,dragState:g,id:h,keyboardResizeBy:o,onLayout:a,storage:l}),k=wt({layout:_,panelDataArray:[],panelDataArrayChanged:!1});wt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Rf(i,()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:y}=k.current;return y},setLayout:y=>{const{onLayout:W}=w.current,{layout:X,panelDataArray:Y}=k.current,re=Fl({layout:y,panelConstraints:Y.map(D=>D.constraints)});Ml(X,re)||(b(re),k.current.layout=re,W&&W(re),Jn(Y,re,m.current))}}),[]),On(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=g,w.current.id=h,w.current.onLayout=a,w.current.storage=l}),Rb({committedValuesRef:w,eagerValuesRef:k,groupId:h,layout:_,panelDataArray:k.current.panelDataArray,setLayout:b,panelGroupElement:p.current}),zn(()=>{const{panelDataArray:y}=k.current;if(e){if(_.length===0||_.length!==y.length)return;let W=Ll[e];W==null&&(W=Bb(Vb,Ub),Ll[e]=W);const X=[...y],Y=new Map(O.current);W(e,X,Y,_,l)}},[e,_,l]),zn(()=>{});const R=gt(y=>{const{onLayout:W}=w.current,{layout:X,panelDataArray:Y}=k.current;if(y.constraints.collapsible){const re=Y.map(ae=>ae.constraints),{collapsedSize:D=0,panelSize:de,pivotIndices:te}=jn(Y,y,X);if(_e(de!=null,`Panel size not found for panel "${y.id}"`),!sn(de,D)){O.current.set(y.id,de);const ue=Kn(Y,y)===Y.length-1?de-D:D-de,ge=Br({delta:ue,initialLayout:X,panelConstraints:re,pivotIndices:te,prevLayout:X,trigger:"imperative-api"});Ci(X,ge)||(b(ge),k.current.layout=ge,W&&W(ge),Jn(Y,ge,m.current))}}},[]),q=gt((y,W)=>{const{onLayout:X}=w.current,{layout:Y,panelDataArray:re}=k.current;if(y.constraints.collapsible){const D=re.map(pe=>pe.constraints),{collapsedSize:de=0,panelSize:te=0,minSize:ae=0,pivotIndices:ue}=jn(re,y,Y),ge=W??ae;if(sn(te,de)){const pe=O.current.get(y.id),Pe=pe!=null&&pe>=ge?pe:ge,nt=Kn(re,y)===re.length-1?te-Pe:Pe-te,C=Br({delta:nt,initialLayout:Y,panelConstraints:D,pivotIndices:ue,prevLayout:Y,trigger:"imperative-api"});Ci(Y,C)||(b(C),k.current.layout=C,X&&X(C),Jn(re,C,m.current))}}},[]),j=gt(y=>{const{layout:W,panelDataArray:X}=k.current,{panelSize:Y}=jn(X,y,W);return _e(Y!=null,`Panel size not found for panel "${y.id}"`),Y},[]),T=gt((y,W)=>{const{panelDataArray:X}=k.current,Y=Kn(X,y);return Lb({defaultSize:W,dragState:g,layout:_,panelData:X,panelIndex:Y})},[g,_]),z=gt(y=>{const{layout:W,panelDataArray:X}=k.current,{collapsedSize:Y=0,collapsible:re,panelSize:D}=jn(X,y,W);return _e(D!=null,`Panel size not found for panel "${y.id}"`),re===!0&&sn(D,Y)},[]),P=gt(y=>{const{layout:W,panelDataArray:X}=k.current,{collapsedSize:Y=0,collapsible:re,panelSize:D}=jn(X,y,W);return _e(D!=null,`Panel size not found for panel "${y.id}"`),!re||Dn(D,Y)>0},[]),I=gt(y=>{const{panelDataArray:W}=k.current;W.push(y),W.sort((X,Y)=>{const re=X.order,D=Y.order;return re==null&&D==null?0:re==null?-1:D==null?1:re-D}),k.current.panelDataArrayChanged=!0,E()},[E]);On(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:y,onLayout:W,storage:X}=w.current,{layout:Y,panelDataArray:re}=k.current;let D=null;if(y){const te=Zb(y,re,X);te&&(O.current=new Map(Object.entries(te.expandToSizes)),D=te.layout)}D==null&&(D=Fb({panelDataArray:re}));const de=Fl({layout:D,panelConstraints:re.map(te=>te.constraints)});Ml(Y,de)||(b(de),k.current.layout=de,W&&W(de),Jn(re,de,m.current))}}),On(()=>{const y=k.current;return()=>{y.layout=[]}},[]);const M=gt(y=>{let W=!1;const X=p.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(re){re.preventDefault();const D=p.current;if(!D)return()=>null;const{direction:de,dragState:te,id:ae,keyboardResizeBy:ue,onLayout:ge}=w.current,{layout:pe,panelDataArray:Pe}=k.current,{initialLayout:De}=te??{},nt=qf(ae,y,D);let C=$b(re,y,de,te,ue,D);const $=de==="horizontal";$&&W&&(C=-C);const U=Pe.map(K=>K.constraints),se=Br({delta:C,initialLayout:De??pe,panelConstraints:U,pivotIndices:nt,prevLayout:pe,trigger:Ff(re)?"keyboard":"mouse-or-touch"}),A=!Ci(pe,se);(Lf(re)||Bf(re))&&N.current!=C&&(N.current=C,!A&&C!==0?$?Xs(y,C<0?Vf:Uf):Xs(y,C<0?Jf:Hf):Xs(y,0)),A&&(b(se),k.current.layout=se,ge&&ge(se),Jn(Pe,se,m.current))}},[]),J=gt((y,W)=>{const{onLayout:X}=w.current,{layout:Y,panelDataArray:re}=k.current,D=re.map(pe=>pe.constraints),{panelSize:de,pivotIndices:te}=jn(re,y,Y);_e(de!=null,`Panel size not found for panel "${y.id}"`);const ue=Kn(re,y)===re.length-1?de-W:W-de,ge=Br({delta:ue,initialLayout:Y,panelConstraints:D,pivotIndices:te,prevLayout:Y,trigger:"imperative-api"});Ci(Y,ge)||(b(ge),k.current.layout=ge,X&&X(ge),Jn(re,ge,m.current))},[]),Z=gt((y,W)=>{const{layout:X,panelDataArray:Y}=k.current,{collapsedSize:re=0,collapsible:D}=W,{collapsedSize:de=0,collapsible:te,maxSize:ae=100,minSize:ue=0}=y.constraints,{panelSize:ge}=jn(Y,y,X);ge!=null&&(D&&te&&sn(ge,re)?sn(re,de)||J(y,de):ge<ue?J(y,ue):ge>ae&&J(y,ae))},[J]),V=gt((y,W)=>{const{direction:X}=w.current,{layout:Y}=k.current;if(!p.current)return;const re=zs(y,p.current);_e(re,`Drag handle element not found for id "${y}"`);const D=Yf(X,W);v({dragHandleId:y,dragHandleRect:re.getBoundingClientRect(),initialCursorPosition:D,initialLayout:Y})},[]),ne=gt(()=>{v(null)},[]),S=gt(y=>{const{panelDataArray:W}=k.current,X=Kn(W,y);X>=0&&(W.splice(X,1),delete m.current[y.id],k.current.panelDataArrayChanged=!0,E())},[E]),le=yb(()=>({collapsePanel:R,direction:r,dragState:g,expandPanel:q,getPanelSize:j,getPanelStyle:T,groupId:h,isPanelCollapsed:z,isPanelExpanded:P,reevaluatePanelConstraints:Z,registerPanel:I,registerResizeHandle:M,resizePanel:J,startDragging:V,stopDragging:ne,unregisterPanel:S,panelGroupElement:p.current}),[R,g,r,q,j,T,h,z,P,Z,I,M,J,V,ne,S]),B={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return xr(Ts.Provider,{value:le},xr(d,{...f,children:t,className:n,id:s,ref:p,style:{...B,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":h}))}const tp=Pf((e,t)=>xr(ep,{...e,forwardedRef:t}));ep.displayName="PanelGroup";tp.displayName="forwardRef(PanelGroup)";function Kn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function jn(e,t,n){const r=Kn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function Jb({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){zn(()=>{if(e||n==null||r==null)return;const i=zs(t,r);if(i==null)return;const s=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const o=i.getAttribute("data-panel-group-id");_e(o,`No group element found for id "${o}"`);const l=ai(o,r),c=Wf(o,t,r);_e(c!==null,`No resize element found for id "${t}"`);const d=a.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[d].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function np({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:a,onFocus:o,style:l={},tabIndex:c=0,tagName:d="div",...f}){var h,p;const g=wt(null),v=wt({onDragging:a});zn(()=>{v.current.onDragging=a});const _=Df(Ts);if(_===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:b,groupId:E,registerResizeHandle:m,startDragging:O,stopDragging:N,panelGroupElement:w}=_,k=_o(i),[R,q]=ar("inactive"),[j,T]=ar(!1),[z,P]=ar(null),I=wt({state:R});On(()=>{I.current.state=R}),zn(()=>{if(n)P(null);else{const V=m(k);P(()=>V)}},[n,k,m]);const M=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,J=(p=r==null?void 0:r.fine)!==null&&p!==void 0?p:5;return zn(()=>{if(n||z==null)return;const V=g.current;return _e(V,"Element ref not attached"),Ab(k,V,b,{coarse:M,fine:J},(S,le,B)=>{if(le)switch(S){case"down":{q("drag"),_e(B,'Expected event to be defined for "down" action'),O(k,B);const{onDragging:y}=v.current;y&&y(!0);break}case"move":{const{state:y}=I.current;y!=="drag"&&q("hover"),_e(B,'Expected event to be defined for "move" action'),z(B);break}case"up":{q("hover"),N();const{onDragging:y}=v.current;y&&y(!1);break}}else q("inactive")})},[M,b,n,J,m,k,z,O,N]),Jb({disabled:n,handleId:k,resizeHandler:z,panelGroupElement:w}),xr(d,{...f,children:e,className:t,id:i,onBlur:()=>{T(!1),s==null||s()},onFocus:()=>{T(!0),o==null||o()},ref:g,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":b,"data-panel-group-id":E,"data-resize-handle":"","data-resize-handle-active":R==="drag"?"pointer":j?"keyboard":void 0,"data-resize-handle-state":R,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":k})}np.displayName="PanelResizeHandle";const Hb=({className:e,...t})=>u.jsx(tp,{className:G("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Qs=$f,Bl=({withHandle:e,className:t,...n})=>u.jsx(np,{className:G("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&u.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-sm border",children:u.jsx(Gg,{className:"h-2.5 w-2.5"})})}),rp=x.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:G("flex min-h-[80px] w-full rounded-sm border border-input bg-background px-3 py-2 text-sm shadow-xs","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));rp.displayName="Textarea";class Wb{constructor(t){Vs(this,"client");this.client=mx.create({baseURL:t||void 0||"/api",headers:{"Content-Type":"application/json"}})}get(t,n){return this.client.get(t,n)}post(t,n,r){return this.client.post(t,n,r)}put(t,n,r){return this.client.put(t,n,r)}delete(t,n){return this.client.delete(t,n)}patch(t,n,r){return this.client.patch(t,n,r)}}const qb=new Wb;class Gb extends Error{constructor(n,r){super(n);Vs(this,"quality");this.name="QualityGateFailedError",this.quality=r}}function Yb(e,t){return e??t}function Kb(e){var n;const t=(n=e==null?void 0:e.split(";",1)[0])==null?void 0:n.trim().toLowerCase();return t?t==="application/json"||t.startsWith("application/")&&t.endsWith("+json"):!1}async function Xb(e){if(Kb(e.headers.get("content-type")))try{return await e.json()}catch{return}}function Zl(e,t){if(t!=null&&t.error)return t.error;if(t!=null&&t.message)return t.message;if(e.ok)return`The server answered ${e.status} but not with a document. This usually means a proxy or extension replaced the response.`;switch(e.status){case 502:case 503:case 504:return`The server did not finish generating (${e.status}). It usually ran out of memory or restarted mid-request — documents with many full-page images or inline SVGs are the common cause. Try again, or split the document and generate it in parts.`;case 413:return"The document is too large for the server to accept (413). Remove or shrink its largest embedded assets.";case 429:return"Too many requests (429). Wait a moment before generating again.";default:return`Generation failed (${e.status}${e.statusText?` ${e.statusText}`:""}).`}}function Qb(){const e=x.useRef(null),t=Hi(i=>i.generationBackend),n=x.useCallback(async(i,s,a,o,l)=>{e.current&&e.current.abort();const c=new AbortController;e.current=c;const d=Yb(l==null?void 0:l.renderer,t);try{o==null||o("parsing","Validating JSON structure...");let f;try{f=JSON.parse(s)}catch(R){throw new Error(`Invalid JSON: ${R instanceof Error?R.message:"Unknown parse error"}`)}o==null||o("building",`Building ${ji.toLowerCase()} structure...`);const h={jsonDefinition:f,options:{...l,sourceName:i,...d?{renderer:d}:{}}};h.customThemes=a??{},o==null||o("rendering",`Generating ${ht.toUpperCase()} content...`);const p={"Content-Type":"application/json"};l!=null&&l.bypassCache&&(p["X-Bypass-Cache"]="true");const g=await fetch(ei.generate,{method:"POST",headers:p,body:JSON.stringify(h),signal:c.signal}),v=await Xb(g);if(g.status===400&&(v==null?void 0:v.code)==="QUALITY_GATE_FAILED")throw new Gb(Zl(g,v),v.quality);if(!g.ok||!(v!=null&&v.success))throw new Error(Zl(g,v));const{data:_,cache:b,warnings:E}=v,m=b.status==="HIT"?"HIT":b.status==="MISS"?"MISS":"UNKNOWN",O=m==="HIT"?`Served from cache (Hit rate: ${b.hitRate})`:`Generated fresh ${ji.toLowerCase()}`;o==null||o("finalizing",O);const N=globalThis.atob(_.document),w=new Uint8Array(N.length);for(let R=0;R<N.length;R++)w[R]=N.charCodeAt(R);const k=new Blob([w],{type:_.contentType});if(k.size===0)throw new Error(`Received empty ${ji.toLowerCase()} from API`);return{name:i,text:s,blob:k,...d?{renderer:d}:{},filename:_.filename,fileId:_.fileId,cacheStatus:m,cacheHitRate:b.hitRate,warnings:E}}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Error(`${ji} generation was cancelled`):f}finally{e.current===c&&(e.current=null)}},[t]),r=x.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:n,generateDocument:n,cancelGeneration:r}}const Bi={ids:[],default:null};let Vl;function ev(){return Vl??(Vl=(async()=>{var e;try{const t=await fetch(ei.renderers);if(!t.ok)return Bi;const n=await t.json();return!(n!=null&&n.success)||!Array.isArray((e=n.data)==null?void 0:e.ids)?Bi:n.data}catch{return Bi}})()),Vl}function tv(){const[e,t]=x.useState(Bi);return x.useEffect(()=>{let n=!1;return ev().then(r=>{n||t(r)}),()=>{n=!0}},[]),e}function nv(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const l=Object.entries(a.context).map(([c,d])=>`${c}: ${JSON.stringify(d)}`).join(", ");o+=` (${l})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function rv({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=je.useState("custom");je.useEffect(()=>{e&&s("custom")},[e]);const a=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),o=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return u.jsx(Ct,{open:e,onOpenChange:l=>!l&&t(),children:u.jsxs(kt,{className:"max-w-md",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Non-safe fonts in this document"}),u.jsxs(on,{children:[a," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),u.jsx("div",{className:"grid gap-2 py-2",children:o.map(l=>{const c=i===l.value;return u.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${c?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${c?"border-primary":"border-muted-foreground/50"}`,children:c&&u.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),u.jsx("span",{className:"text-sm font-medium",children:l.title})]}),u.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),u.jsxs(bn,{children:[u.jsx(Se,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),u.jsx(Se,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}function ea(){return u.jsx("span",{className:"rounded-sm bg-warning/15 px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-warning",children:"experimental"})}function Ul(){return u.jsx("span",{className:"rounded-sm bg-muted px-1 py-px text-[10px] font-semibold uppercase leading-none tracking-wide text-muted-foreground",children:"default"})}function iv({name:e,blob:t,onManualRender:n,isGenerating:r,isRendering:i,onShowCacheMetrics:s,onShowSchemas:a,onShowFonts:o,documentText:l,editorDocumentText:c,warnings:d,onToggleChat:f,chatOpen:h,onTogglePreview:p,previewOpen:g}){const[v,_]=x.useState(!1),[b,E]=x.useState(!1),[m,O]=x.useState(!1),[N,w]=x.useState(!1),[k,R]=x.useState(!1),[q,j]=x.useState(null),{toast:T}=Sr(),{generateDocument:z}=Qb(),P=x.useContext(Fd),I=tv(),M=Hi(te=>te.generationBackend),J=Hi(te=>te.setSettings),Z=M??I.default??void 0,V=x.useCallback(()=>{const te={},{customThemes:ae}=P.getState();return Object.values(ae).forEach(ue=>{ue.valid&&ue.parsed&&(te[ue.name]=ue.parsed)}),te},[P]),ne=je.useMemo(()=>{if(!l)return[];try{const te=JSON.parse(l);return[...(ht==="pptx"?Sg:_g)(te)].filter(ue=>!jg(ue))}catch{return[]}},[l]),[S,le]=x.useState(!1),B=x.useCallback(async()=>{if(t){_(!0);try{await new Promise(te=>setTimeout(te,100)),Li(`${e}${Tr}`,t)}finally{setTimeout(()=>_(!1),500)}}},[t,e]),y=x.useCallback(async()=>{if(t){if(ne.length===0){await B();return}le(!0)}},[t,ne.length,B]),W=x.useCallback(async te=>{var ae;if(l){_(!0);try{const ue=await z(e,l,V(),void 0,{bypassCache:!0,fonts:{mode:te}});if(ue.blob.size===0)T({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{Li(`${e}${Tr}`,ue.blob);const ge=(ae=ue.warnings)==null?void 0:ae.find(pe=>{var Pe,De;return((Pe=pe.context)==null?void 0:Pe.code)==="FONT_MODE_SUBSTITUTED"||((De=pe.context)==null?void 0:De.code)==="FONT_MODE_CUSTOM"});ge&&T({title:te==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:ge.message})}}catch(ue){T({title:"Export failed",description:ue instanceof Error?ue.message:String(ue),variant:"destructive"})}finally{setTimeout(()=>_(!1),500)}}},[l,e,z,T,V]),X=x.useCallback(async()=>{if(!(!d||d.length===0)){E(!0);try{const te=nv(d);if(!te){T({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const ae=await z("warnings",JSON.stringify(te,null,2),{});ae&&typeof ae=="object"&&"blob"in ae&&ae.blob&&(Li(`${e}-warnings${Tr}`,ae.blob),T({title:"Warnings downloaded",description:`Downloaded warnings document with ${d.length} warning(s).`}))}catch(te){console.error("Failed to generate warnings document:",te),T({title:"Download failed",description:te instanceof Error?te.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>E(!1),500)}}},[d,e,z,T]),Y=x.useCallback(async()=>{O(!0);try{await qb.delete(`/${ht}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),T({title:"Cache Cleared",description:"All active caches have been successfully cleared.",variant:"default"})}catch(te){console.error("Failed to clear cache:",te),T({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{O(!1)}},[T]),re=c??l,D=x.useCallback(()=>{var ue,ge;if(!re){T({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(re)}catch{T({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}R(!0);const te=(async()=>{const pe=await fetch(`/api/${ht}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:re,customThemes:V(),options:{sourceName:e}})});if(!pe.ok){let De=`Request failed with status ${pe.status}`;try{const nt=await pe.json(),C=nt.error??nt.message;typeof C=="string"&&C&&(De=C)}catch{}throw new Error(De)}const Pe=await pe.json();return JSON.stringify(Pe.data,null,2)})();let ae;typeof ClipboardItem<"u"&&((ue=navigator.clipboard)!=null&&ue.write)?ae=navigator.clipboard.write([new ClipboardItem({"text/plain":te.then(pe=>new Blob([pe],{type:"text/plain"}))})]):(ge=navigator.clipboard)!=null&&ge.writeText?ae=te.then(pe=>navigator.clipboard.writeText(pe)):ae=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await ae,T({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(pe){let Pe=null;try{Pe=await te}catch(De){console.error("Error fetching standard components:",De),T({title:"Failed to get standard components",description:De instanceof Error?De.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",pe),j(Pe)}finally{R(!1)}})()},[re,e,V,T]),de=x.useCallback(async()=>{if(q!=null)try{await navigator.clipboard.writeText(q),T({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),j(null)}catch{T({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[q,T]);return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-sidebar border-b flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[u.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded-sm hover:bg-muted/60 shrink-0",children:u.jsx(Od,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),u.jsx(Ke,{className:"max-w-sm",children:u.jsxs("p",{className:"text-sm",children:["Preview converts the file to a PDF with LibreOffice. Download the ",Tr," to verify fidelity."]})})]})]}),u.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsxs(Se,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:n,"aria-label":"Render preview",disabled:r||i||g===!1,children:[i?u.jsx(gn,{size:"sm"}):u.jsx(Yg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:g===!1?"Open preview to run":i?"Rendering preview...":"Render preview"})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsxs(Se,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||v||r,onClick:y,children:[v?u.jsx(gn,{size:"sm"}):u.jsx(Kg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download ",Tr]})})]}),d&&d.length>0&&u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Se,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:b||r,onClick:X,children:b?u.jsx(gn,{size:"sm"}):u.jsx(Dd,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download warnings (",d.length,")"]})})]}),I.ids.length>1&&u.jsxs(ti,{value:Z,onValueChange:te=>J({generationBackend:te}),children:[u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsxs(fr,{"aria-label":"Renderer",className:"hidden h-7 w-auto min-h-0 gap-1.5 px-2 text-xs lg:flex [&>span]:flex [&>span]:items-center [&>span]:gap-1.5 [&>span]:whitespace-nowrap",children:[u.jsx(Na,{className:"h-3.5 w-3.5 shrink-0 opacity-60"}),u.jsxs(ni,{placeholder:"Renderer",children:[u.jsx("span",{className:"font-medium",children:Z}),Z!==I.default&&u.jsx(ea,{})]})]})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Renderer that writes the ",ht.toUpperCase()," file. A non-default one may refuse a document it cannot express."]})})]}),u.jsx(pr,{className:"min-w-[var(--radix-select-trigger-width)] text-sidebar-foreground",children:u.jsxs(Bd,{children:[u.jsx(ho,{className:"px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),I.ids.map(te=>u.jsx(Pn,{value:te,className:"text-xs",children:u.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[u.jsx("span",{className:"font-medium",children:te}),te===I.default?u.jsx(Ul,{}):u.jsx(ea,{})]})},te))]})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(Ns,{children:[u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Es,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"icon",className:"h-7 w-7",children:u.jsx(Ad,{className:"h-3.5 w-3.5"})})})}),u.jsx(Ke,{children:u.jsx("p",{children:"More actions"})})]}),u.jsxs(yi,{align:"end",className:"w-52",children:[a&&u.jsxs($t,{onClick:a,children:[u.jsx(Xg,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),o&&u.jsxs($t,{onClick:o,children:[u.jsx(ja,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),s&&u.jsxs($t,{onClick:s,children:[u.jsx(Ea,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),re?u.jsxs($t,{onClick:D,disabled:k,children:[u.jsx(Ca,{className:"h-4 w-4 mr-2"}),k?"Copying...":"Copy standard components"]}):u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx("span",{className:"block",children:u.jsxs($t,{disabled:!0,children:[u.jsx(Ca,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),u.jsx(Ke,{side:"left",children:u.jsx("p",{children:"No document selected — open or select a document first"})})]}),u.jsx(mr,{}),u.jsxs($t,{onClick:()=>w(!0),disabled:m,className:"text-destructive focus:text-destructive",children:[u.jsx(fo,{className:"h-4 w-4 mr-2"}),m?"Clearing...":"Clear all caches"]}),I.ids.length>1&&u.jsxs(u.Fragment,{children:[u.jsx(mr,{className:"lg:hidden"}),u.jsx(ko,{className:"lg:hidden px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Renderer"}),I.ids.map(te=>u.jsxs($t,{className:"lg:hidden gap-1.5",onClick:()=>J({generationBackend:te}),children:[u.jsx(an,{className:`h-3.5 w-3.5 shrink-0 ${Z===te?"opacity-100":"opacity-0"}`}),u.jsx("span",{className:"font-medium",children:te}),te===I.default?u.jsx(Ul,{}):u.jsx(ea,{})]},te))]})]})]}),p&&u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Se,{variant:g?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:p,children:g?u.jsx(Rd,{className:"h-3.5 w-3.5"}):u.jsx(Qg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[g?"Hide":"Show"," Preview"," ",u.jsx(ii,{shortcut:"mod+shift+p"})]})})]}),f&&u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx(Se,{variant:h?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:f,children:u.jsx(Md,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[h?"Close":"Open"," AI Chat"," ",u.jsx(ii,{shortcut:"mod+shift+j"})]})})]})]})]}),u.jsx(rv,{open:S,onClose:()=>le(!1),nonSafeFonts:ne,onChoose:W}),u.jsx(Ct,{open:q!=null,onOpenChange:te=>{te||j(null)},children:u.jsxs(kt,{className:"max-w-lg",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Standard components"}),u.jsx(on,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),u.jsx(rp,{readOnly:!0,value:q??"",className:"h-64 font-mono text-xs",onFocus:te=>te.currentTarget.select()}),u.jsxs(bn,{children:[u.jsx(Se,{variant:"outline",size:"sm",onClick:()=>j(null),children:"Close"}),u.jsx(Se,{size:"sm",onClick:de,children:"Copy to clipboard"})]})]})}),u.jsx(Ct,{open:N,onOpenChange:w,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Clear all caches?"}),u.jsx(on,{children:"This will clear the document, component, and rasterized-visual caches. Next generation will be uncached."})]}),u.jsxs(bn,{children:[u.jsx(Se,{variant:"outline",size:"sm",onClick:()=>w(!1),children:"Cancel"}),u.jsx(Se,{variant:"destructive",size:"sm",disabled:m,onClick:async()=>{await Y(),w(!1)},children:m?u.jsx(gn,{size:"sm"}):"Clear"})]})]})})]})}const sv=je.memo(iv),ip=yg,Co=x.forwardRef(({className:e,...t},n)=>u.jsx(kd,{ref:n,className:G("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));Co.displayName=kd.displayName;const lr=x.forwardRef(({className:e,...t},n)=>u.jsx(Sd,{ref:n,className:G("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex cursor-pointer items-center justify-center rounded-sm px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",e),...t}));lr.displayName=Sd.displayName;const ur=x.forwardRef(({className:e,...t},n)=>u.jsx(_d,{ref:n,className:G("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));ur.displayName=_d.displayName;async function av(e){if(navigator.clipboard&&navigator.clipboard.writeText)try{return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard API failed, falling back to legacy method:",t)}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="2em",t.style.height="2em",t.style.padding="0",t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("Failed to copy text to clipboard:",t),!1}}function ov(e){try{const t=typeof e=="string"?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch(t){return console.error("Failed to format schema:",t),typeof e=="string"?e:JSON.stringify(e)}}async function lv(e){const t=ov(e);return av(t)}const uv=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=x.useState(n),[s,a]=x.useState(null),[o,l]=x.useState(null),[c,d]=x.useState(!1),[f,h]=x.useState(!1),[p,g]=x.useState(null),[v,_]=x.useState(null),[b,E]=x.useState(!1),{toast:m}=Sr(),O=Lt(P=>P.selectedPlugins),N=Array.from(O);x.useEffect(()=>{n&&i(n)},[n]);const w=x.useCallback(async()=>{d(!0),g(null);try{const P=await Us.fetchDocumentSchema(N);a(P)}catch(P){const I=P instanceof Error?P.message:"Failed to load document schema";g(I),m({variant:"destructive",title:"Error loading schema",description:I})}finally{d(!1)}},[N,m]),k=x.useCallback(async()=>{if(!o){h(!0),_(null);try{const P=await Us.fetchThemeSchema();l(P)}catch(P){const I=P instanceof Error?P.message:"Failed to load theme schema";_(I),m({variant:"destructive",title:"Error loading schema",description:I})}finally{h(!1)}}},[o,m]),[R,q]=x.useState([]);x.useEffect(()=>{e||(a(null),g(null))},[e]),x.useEffect(()=>{if(!e)return;const P=N.length!==R.length||N.some((I,M)=>I!==R[M]);r==="document"?(!s||P)&&(P&&(Us.clearPluginSchemaCache(),q([...N])),c||w()):r==="theme"&&!o&&!f&&k()},[r,e,s,o,c,f,N,R,w,k]);const j=N.length,T=r==="document"?s:o,z=async()=>{if(T)try{await lv(T)&&(E(!0),m({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>E(!1),2e3))}catch(P){console.error("Copy failed:",P)}};return u.jsx(Ct,{open:e,onOpenChange:t,children:u.jsxs(kt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Vt,{children:u.jsx(Ut,{children:"Schema Viewer"})}),u.jsxs(ip,{value:r,onValueChange:P=>i(P),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Co,{children:[u.jsxs(lr,{value:"document",className:"flex items-center gap-1",children:["Document",j>0&&u.jsxs(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",j]})]}),u.jsx(lr,{value:"theme",children:"Theme"})]}),u.jsx("div",{className:"ml-auto",children:u.jsx(Se,{variant:"ghost",size:"icon",onClick:z,disabled:b||!T,"aria-label":"Copy schema",children:b?u.jsx(an,{className:"h-4 w-4"}):u.jsx(ks,{className:"h-4 w-4"})})})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[u.jsx(ur,{value:"document",className:"h-full",children:u.jsx(ts,{schema:s,loading:c,error:p||void 0})}),u.jsx(ur,{value:"theme",className:"h-full",children:u.jsx(ts,{schema:o,loading:f,error:v||void 0})})]})]})]})})};function To(e,t){var r;const n=$d.getState().getEditor(e);return(r=n==null?void 0:n.flushPendingSave)==null||r.call(n),n?n.toStorageValue(n.editor.getValue()):t}function sp(e,t,n){if(t.length===0)return n;const r=Jl(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],l=i[a],c=Jl(l,o);i[a]=c,i=c}return i[t[t.length-1]]=n,r}function Jl(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const Hl=2*1024*1024,Wl=12*1024*1024;function cv(e){if(e.length<4)return"unknown";const[t,n,r,i]=e;return t===0&&n===1&&r===0&&i===0||t===116&&n===114&&r===117&&i===101||t===116&&n===116&&r===99&&i===102?"ttf":t===79&&n===84&&r===84&&i===79?"otf":t===119&&n===79&&r===70&&i===70?"woff":t===119&&n===79&&r===70&&i===50?"woff2":"unknown"}function dv(e){let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function is(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.round(e/1024)} KB`}function fv(e,t){if(t.length===0)return{ok:!1,message:`"${e}" is empty.`};if(t.length>Hl)return{ok:!1,message:`"${e}" is ${is(t.length)}. The limit is ${is(Hl)} per font, because the bytes travel inside the document JSON.`};const n=cv(t);return n==="woff"||n==="woff2"?{ok:!1,message:`"${e}" is a ${n.toUpperCase()} file. Upload the TTF or OTF instead — the preview renderer cannot register web font formats.`}:n!=="ttf"&&n!=="otf"?{ok:!1,message:`"${e}" does not look like a TTF or OTF font file.`}:{ok:!0,format:n,base64:dv(t)}}const pv=new Set(["italic","oblique"]);function hv(e){const t=e.replace(/\.[^.]+$/,""),n=t.split(/[-_\s]+/).filter(Boolean),r=new Map;for(const[a,o]of Object.entries(Ed))r.set(o.toLowerCase(),Number(a));let i=400,s=!1;for(;n.length>1;){const a=n[n.length-1].toLowerCase();if(pv.has(a)){s=!0,n.pop();continue}const o=r.get(a);if(o!==void 0){i=o,n.pop();continue}break}return{family:n.join(" ")||t,weight:i,italic:s}}function mv(e,t){const n=Array.isArray(e)?[...e]:[],r=n.findIndex(i=>{var s;return((s=i==null?void 0:i.family)==null?void 0:s.toLowerCase())===t.family.toLowerCase()});return r>=0?n[r]=t:n.push(t),n}function gv(e){return e.kind==="safe"||e.kind==="google"?null:{weight:"weight"in e&&e.weight?e.weight:400,italic:"italic"in e?!!e.italic:!1}}function xv(e,t,n,r){const i=((e==null?void 0:e.sources)??[]).filter(o=>{const l=gv(o);return l?!n.some(c=>c.weight===l.weight&&c.italic===l.italic):!0}),s=n.map(o=>({kind:"data",data:o.data,weight:o.weight,italic:o.italic})),a=r??(e==null?void 0:e.category);return{id:(e==null?void 0:e.id)??t,family:t,...a?{category:a}:{},sources:[...i,...s]}}function yv(e,t){let n=Array.isArray(e)?[...e]:[];for(const r of t){const i=r.sources.filter(a=>a.kind==="data").map(a=>({data:a.data,weight:a.weight??400,italic:a.italic??!1}));if(i.length===0)continue;const s=n.find(a=>{var o;return((o=a==null?void 0:a.family)==null?void 0:o.toLowerCase())===r.family.toLowerCase()});n=mv(n,xv(s,r.family,i,r.category))}return n}function bv(e,t){const n=(e.sources??[]).filter(r=>r.format==="ttf"||r.format==="otf").map(r=>({kind:"data",data:r.data,weight:r.weight,italic:r.italic}));return n.length===0?null:{id:e.family,family:e.family,...t?{category:t}:{},sources:n}}function vv(e){const t=new TextEncoder().encode(e).length;return t<=Wl?null:`Adding this font would push the document to ${is(t)}, past the ${is(Wl)} limit. Remove a font from props.fontRegistry, or use fewer weights.`}const ql=new Set,wv=(e,t,n)=>`${e.toLowerCase()}|${t}|${n?"i":"r"}`;function kv(e){const t=e.startsWith("data:")?e.slice(e.indexOf(",")+1):e,n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}async function Sv(e,t,n,r){const i=wv(e,n,r);if(!ql.has(i))try{if(typeof FontFace>"u"||!(document!=null&&document.fonts))return;const s=kv(t),a=new FontFace(e,s.buffer,{weight:String(n),style:r?"italic":"normal"});await a.load(),document.fonts.add(a),ql.add(i)}catch{}}const _v={safe:[],google:[]};function Gl(e,t){var d;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((d=r==null?void 0:r.dataset.weights)==null?void 0:d.split(",").map(Number).filter(f=>!Number.isNaN(f)))??[]),a=new Set([...s,...i]);if(r&&a.size===s.size)return;const o=[...a].sort((f,h)=>f-h).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${o}&display=swap`,c=r??document.createElement("link");r||(c.id=n,c.rel="stylesheet",document.head.appendChild(c)),c.href=l,c.dataset.weights=[...a].sort((f,h)=>f-h).join(",")}function jv(){const e=Ne(i=>i.activeTab),t=Ne(i=>i.documents),n=Ne(i=>i.documentTypes),r=Ne(i=>i.saveDocument);return x.useCallback(i=>{if(!e)return{ok:!1,error:"No active file"};if(n[e]!=="application/json+theme")return{ok:!1,error:"Fonts are registered on themes, not documents. Open a .theme.json file and try again."};const s=t.find(c=>c.name===e);if(!s)return{ok:!1,error:"Active theme not found"};const a=To(e,s.text);let o;try{o=JSON.parse(a)}catch(c){return{ok:!1,error:`Active theme is not valid JSON: ${c.message}`}}const l=i(o);return r(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n,r])}function Nv(){const e=Ne(r=>r.activeTab),t=Ne(r=>r.documents),n=Ne(r=>r.saveDocument);return x.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(c=>c.name===e);if(!s)return{ok:!1,error:"Active document not found"};const a=To(e,s.text);let o;try{o=JSON.parse(a)}catch(c){return{ok:!1,error:`Active document is not valid JSON: ${c.message}`}}const l=sp(o,r,i);return n(e,JSON.stringify(l,null,2)),{ok:!0,name:e}},[e,t,n])}function Ev(){const e=Ne(i=>i.activeTab),t=Ne(i=>i.documents),n=Ne(i=>i.documentTypes),r=Ne(i=>i.saveDocument);return x.useCallback(i=>{var h;if(i.length===0)return{ok:!0,name:e};if(!e)return{ok:!1,error:"No active file"};if(n[e]==="application/json+theme")return{ok:!1,error:"Custom fonts are registered on the document, not the theme. Open the .docx.json / .pptx.json tab and try again."};const s=t.find(p=>p.name===e);if(!s)return{ok:!1,error:"Active document not found"};const a=To(e,s.text);let o;try{o=JSON.parse(a)}catch(p){return{ok:!1,error:`Active document is not valid JSON: ${p.message}`}}const l=yv((h=o==null?void 0:o.props)==null?void 0:h.fontRegistry,i),c=sp(o,["props","fontRegistry"],l),d=JSON.stringify(c,null,2),f=vv(d);return f?{ok:!1,error:f}:(r(e,d),{ok:!0,name:e})},[e,t,n,r])}function Cv(e,t,n){(!e.fonts||typeof e.fonts!="object")&&(e.fonts={});const r=e.fonts[t];r&&typeof r=="object"?e.fonts[t]={...r,family:n}:e.fonts[t]=n}function Yl(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Tv=({open:e,onOpenChange:t})=>{const n=$i(D=>D.open),r=$i(D=>D.contextual),i=$i(D=>D.close),s=e??n,a=r,o=x.useCallback(D=>{t&&t(D),D||i()},[t,i]),[l,c]=x.useState(_v),[d,f]=x.useState(!1),[h,p]=x.useState(""),[g,v]=x.useState("safe"),[_,b]=x.useState(null),[E,m]=x.useState(null),[O,N]=x.useState(!1),[w,k]=x.useState(!1),[R,q]=x.useState(""),[j,T]=x.useState([]),z=x.useRef(null),{toast:P}=Sr(),I=jv(),M=Nv(),J=Ev(),Z=Ne(D=>D.activeTab),V=Ne(D=>D.documentTypes),ne=Z&&V[Z]==="application/json+theme",S=!!a||ne;x.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(f(!0),fetch(ei.fonts.catalog).then(D=>D.json()).then(D=>c(D)).catch(D=>{P({variant:"destructive",title:"Font catalog unavailable",description:D.message})}).finally(()=>f(!1))))},[s,l,P]),x.useEffect(()=>{if(!(g!=="google"||l.google.length===0))for(const D of l.google)Gl(D.family,D.weights)},[g,l]);const le=x.useMemo(()=>l.safe.filter(D=>D.toLowerCase().includes(h.toLowerCase())),[l.safe,h]),B=x.useMemo(()=>l.google.filter(D=>D.family.toLowerCase().includes(h.toLowerCase())),[l.google,h]),y=x.useCallback(async D=>{try{await navigator.clipboard.writeText(D),m(D),setTimeout(()=>m(null),1500)}catch{P({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[P]),W=x.useCallback(async(D,de,te)=>{b(D);try{const ae=I(ue=>(Cv(ue,te,D),ue));if(!ae.ok){P({variant:"destructive",title:"Could not insert font",description:ae.error});return}P({title:"Font inserted",description:`${D} set as ${te} font in "${ae.name}".`})}finally{b(null)}},[I,P]),X=x.useCallback(async D=>{if(a){b(D);try{const de=M(a.jsonPath,D);if(!de.ok){P({variant:"destructive",title:"Could not insert font",description:de.error});return}P({title:"Font inserted",description:`${D} set at ${Yl(a.jsonPath)}.`}),o(!1)}finally{b(null)}}},[a,M,P,o]),Y=x.useCallback(async D=>{if(!(!D||D.length===0)){N(!0);try{const de=[];for(const ae of Array.from(D)){const ue=new Uint8Array(await ae.arrayBuffer()),ge=fv(ae.name,ue);if(!ge.ok){P({variant:"destructive",title:"Font rejected",description:ge.message});continue}de.push({identity:hv(ae.name),base64:ge.base64})}if(de.length===0)return;const te=J(de.map(({identity:ae,base64:ue})=>({id:ae.family,family:ae.family,sources:[{kind:"data",data:ue,weight:ae.weight,italic:ae.italic}]})));if(!te.ok){P({variant:"destructive",title:"Could not register font",description:te.error});return}for(const{identity:ae,base64:ue}of de)Sv(ae.family,ue,ae.weight,ae.italic),P({title:`Added ${ae.family}`,description:`Registered at weight ${ae.weight}${ae.italic?" italic":""} in props.fontRegistry. Reference it as "${ae.family}".`})}catch(de){P({variant:"destructive",title:"Upload failed",description:de.message})}finally{N(!1),z.current&&(z.current.value="")}}},[J,P]),re=x.useCallback(async()=>{var de,te;const D=R.trim();if(D){k(!0),T([]);try{const ae=await fetch(ei.fonts.materialize,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({family:D,weights:[400,700],italics:!1})});if(ae.status===429)throw new Error("Too many font fetches — the playground allows 20 every 15 minutes. Try again shortly.");if(!ae.ok){const De=await ae.json().catch(()=>({}));throw new Error(De.error??`Materialize failed (${ae.status})`)}const ue=await ae.json();T(ue.warnings??[]);const ge=(de=l.google.find(De=>De.family.toLowerCase()===ue.family.toLowerCase()))==null?void 0:de.category,pe=bv(ue,ge);if(!pe){P({variant:"destructive",title:"Nothing to embed",description:((te=ue.warnings)==null?void 0:te.join(" · "))||`Google Fonts has no family named "${D}".`});return}const Pe=J([pe]);if(!Pe.ok){P({variant:"destructive",title:"Could not register font",description:Pe.error});return}Gl(ue.family,[400,700]),P({title:`Added ${ue.family}`,description:`Embedded ${pe.sources.length} weight(s) in props.fontRegistry.`})}catch(ae){P({variant:"destructive",title:"Google Fonts fetch failed",description:ae.message})}finally{k(!1)}}},[R,l.google,J,P]);return u.jsx(Ct,{open:s,onOpenChange:o,children:u.jsxs(kt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Vt,{children:u.jsx(Ut,{children:a?`Font for ${Yl(a.jsonPath)}`:"Fonts"})}),!a&&!ne&&g!=="custom"&&u.jsx(ir,{children:u.jsxs(sr,{children:["Fonts are registered on themes. Open a ",u.jsx("code",{children:".theme.json"})," ","file to apply a font — the buttons below are disabled until you do."]})}),u.jsxs(ip,{value:g,onValueChange:D=>v(D),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Co,{children:[u.jsxs(lr,{value:"safe",children:["Safe",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),u.jsxs(lr,{value:"google",children:["Google",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]}),u.jsx(lr,{value:"custom",children:"Custom"})]}),u.jsx(hr,{type:"search",placeholder:"Search fonts...",value:h,onChange:D=>p(D.target.value),className:"ml-auto max-w-xs"})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[u.jsx(ur,{value:"safe",className:"m-0",children:d&&le.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(Fr,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:le.map(D=>u.jsx(Kl,{family:D,meta:u.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${D}", sans-serif`},onCopy:()=>y(D),copied:E===D,contextual:!!a,onUseThis:()=>X(D),onInsertHeading:()=>W(D,"safe","heading"),onInsertBody:()=>W(D,"safe","body"),applying:_===D,disabled:!S},D))})}),u.jsx(ur,{value:"google",className:"m-0",children:d&&B.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(Fr,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:B.map(D=>u.jsx(Kl,{family:D.family,meta:u.jsxs("span",{className:"text-xs",children:[D.category," · ",D.weights.length," weights"]}),previewStyle:{fontFamily:`"${D.family}", sans-serif`},onCopy:()=>y(D.family),copied:E===D.family,contextual:!!a,onUseThis:()=>X(D.family),onInsertHeading:()=>W(D.family,"google","heading"),onInsertBody:()=>W(D.family,"google","body"),applying:_===D.family,disabled:!S,extraAction:u.jsx(Av,{family:D.family,weights:D.weights,hasItalic:D.hasItalic})},D.family))})}),u.jsx(ur,{value:"custom",className:"m-0 flex flex-col gap-6",children:ne?u.jsx(ir,{children:u.jsxs(sr,{children:["Custom fonts are stored on the document (",u.jsx("code",{children:"props.fontRegistry"}),"), because the bytes travel with the JSON. Open a document tab to add one."]})}):u.jsxs(u.Fragment,{children:[u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsx("h3",{className:"text-sm font-medium",children:"Upload a font file"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["TTF or OTF, up to 2 MB each. The font is embedded in the document as base64, so it survives export and re-import — and renders in the preview. The family and weight are guessed from the filename (e.g."," ",u.jsx("code",{children:"Geist-SemiBold.ttf"}),")."]}),u.jsxs("div",{onDragOver:D=>D.preventDefault(),onDrop:D=>{D.preventDefault(),Y(D.dataTransfer.files)},className:"rounded-md border border-dashed p-6 text-center",children:[u.jsx("input",{ref:z,type:"file",accept:".ttf,.otf,font/ttf,font/otf",multiple:!0,className:"hidden",onChange:D=>void Y(D.target.files)}),u.jsxs(Se,{variant:"secondary",disabled:O,onClick:()=>{var D;return(D=z.current)==null?void 0:D.click()},children:[O?u.jsx(Fr,{className:"animate-spin mr-2 h-4 w-4"}):u.jsx(ex,{className:"mr-2 h-4 w-4"}),"Choose font files"]}),u.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"or drop them here"})]})]}),u.jsxs("section",{className:"flex flex-col gap-2",children:[u.jsx("h3",{className:"text-sm font-medium",children:"Embed any Google font"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Not limited to the ",l.google.length," curated families — type any Google Fonts family name and its regular and bold weights are fetched and embedded."]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(hr,{placeholder:"e.g. Geist",value:R,onChange:D=>q(D.target.value),onKeyDown:D=>{D.key==="Enter"&&re()}}),u.jsxs(Se,{onClick:()=>void re(),disabled:w||R.trim()==="",children:[w&&u.jsx(Fr,{className:"animate-spin mr-2 h-4 w-4"}),"Embed"]})]}),j.length>0&&u.jsx(ir,{children:u.jsx(sr,{className:"text-xs",children:j.join(" · ")})})]})]})})]})]})]})})},Iv="The quick brown fox jumps over the lazy dog",Av=({family:e,weights:t,hasItalic:n})=>{const r=x.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return u.jsxs(Ns,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Se,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),u.jsxs(yi,{align:"end",className:"min-w-[260px]",children:[u.jsxs(ko,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),u.jsx(mr,{}),r.map(i=>{const s=Ed[i]??String(i);return u.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1.5",children:[u.jsx("span",{className:"truncate",style:{fontFamily:`"${e}", sans-serif`,fontWeight:i},children:s}),u.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["fontWeight: ",i]})]},i)})]})]})},Kl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:a,onInsertHeading:o,onInsertBody:l,applying:c,disabled:d,extraAction:f})=>u.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("div",{className:"font-medium truncate",children:e}),u.jsx("div",{className:"text-muted-foreground",children:t})]}),u.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:Iv}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?u.jsx(Se,{size:"sm",onClick:a,disabled:c||d,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):u.jsxs(u.Fragment,{children:[u.jsx(Se,{size:"sm",variant:"secondary",onClick:o,disabled:c||d,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),u.jsx(Se,{size:"sm",variant:"secondary",onClick:l,disabled:c||d,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),f,u.jsx(Se,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?u.jsx(an,{className:"h-4 w-4"}):u.jsx(ks,{className:"h-4 w-4"})})]})]});function Xl({previewOpen:e,onTogglePreview:t}){const n=rn(N=>N.name||""),r=rn(N=>N.blob),i=rn(N=>N.isGenerating),s=rn(N=>N.text),a=rn(N=>N.warnings),o=rn(N=>N.isRendering),l=Hi(N=>N.useGlobalPreviewHeader??!0),c=Ne(N=>N.activeTab),d=Ne(N=>N.documentTypes),f=c&&d[c]==="application/json+theme"?"theme":"document",h=Ne(N=>{var w;return N.activeTab&&N.documentTypes[N.activeTab]!=="application/json+theme"?(w=N.documents.find(k=>k.name===N.activeTab))==null?void 0:w.text:void 0}),p=Oe(N=>N.chatOpen),g=Oe(N=>N.toggleChat),[v,_]=je.useState(!1),b=$i(N=>N.openFor);if(!l)return null;const E=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),m=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),O=(n==null?void 0:n.trim())||"Preview";return u.jsxs("div",{className:"sticky top-0 z-20",children:[u.jsx(sv,{name:O,blob:r,onManualRender:E,isGenerating:i,isRendering:!!o,onShowCacheMetrics:m,onShowSchemas:()=>_(!0),onShowFonts:()=>b(),documentText:s,editorDocumentText:h,warnings:a,onToggleChat:g,chatOpen:p,onTogglePreview:t,previewOpen:e}),u.jsx(uv,{open:v,onOpenChange:_,defaultTab:f==="theme"?"theme":"document"}),u.jsx(Tv,{})]})}function zv(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ov=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Pv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Dv={};function Ql(e,t){return(Dv.jsx?Pv:Ov).test(e)}const Rv=/[ \t\n\f\r]/g;function Mv(e){return typeof e=="object"?e.type==="text"?eu(e.value):!1:eu(e)}function eu(e){return e.replace(Rv,"")===""}class bi{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}bi.prototype.normal={};bi.prototype.property={};bi.prototype.space=void 0;function ap(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new bi(n,r,t)}function Ba(e){return e.toLowerCase()}class St{constructor(t,n){this.attribute=n,this.property=t}}St.prototype.attribute="";St.prototype.booleanish=!1;St.prototype.boolean=!1;St.prototype.commaOrSpaceSeparated=!1;St.prototype.commaSeparated=!1;St.prototype.defined=!1;St.prototype.mustUseProperty=!1;St.prototype.number=!1;St.prototype.overloadedBoolean=!1;St.prototype.property="";St.prototype.spaceSeparated=!1;St.prototype.space=void 0;let $v=0;const ke=$n(),tt=$n(),Za=$n(),ie=$n(),Be=$n(),cr=$n(),jt=$n();function $n(){return 2**++$v}const Va=Object.freeze(Object.defineProperty({__proto__:null,boolean:ke,booleanish:tt,commaOrSpaceSeparated:jt,commaSeparated:cr,number:ie,overloadedBoolean:Za,spaceSeparated:Be},Symbol.toStringTag,{value:"Module"})),ta=Object.keys(Va);class Io extends St{constructor(t,n,r,i){let s=-1;if(super(t,n),tu(this,"space",i),typeof r=="number")for(;++s<ta.length;){const a=ta[s];tu(this,ta[s],(r&Va[a])===Va[a])}}}Io.prototype.defined=!0;function tu(e,t,n){n&&(e[t]=n)}function jr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Io(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Ba(r)]=r,n[Ba(s.attribute)]=r}return new bi(t,n,e.space)}const op=jr({properties:{ariaActiveDescendant:null,ariaAtomic:tt,ariaAutoComplete:null,ariaBusy:tt,ariaChecked:tt,ariaColCount:ie,ariaColIndex:ie,ariaColSpan:ie,ariaControls:Be,ariaCurrent:null,ariaDescribedBy:Be,ariaDetails:null,ariaDisabled:tt,ariaDropEffect:Be,ariaErrorMessage:null,ariaExpanded:tt,ariaFlowTo:Be,ariaGrabbed:tt,ariaHasPopup:null,ariaHidden:tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Be,ariaLevel:ie,ariaLive:null,ariaModal:tt,ariaMultiLine:tt,ariaMultiSelectable:tt,ariaOrientation:null,ariaOwns:Be,ariaPlaceholder:null,ariaPosInSet:ie,ariaPressed:tt,ariaReadOnly:tt,ariaRelevant:null,ariaRequired:tt,ariaRoleDescription:Be,ariaRowCount:ie,ariaRowIndex:ie,ariaRowSpan:ie,ariaSelected:tt,ariaSetSize:ie,ariaSort:null,ariaValueMax:ie,ariaValueMin:ie,ariaValueNow:ie,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function lp(e,t){return t in e?e[t]:t}function up(e,t){return lp(e,t.toLowerCase())}const Fv=jr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:cr,acceptCharset:Be,accessKey:Be,action:null,allow:null,allowFullScreen:ke,allowPaymentRequest:ke,allowUserMedia:ke,alt:null,as:null,async:ke,autoCapitalize:null,autoComplete:Be,autoFocus:ke,autoPlay:ke,blocking:Be,capture:null,charSet:null,checked:ke,cite:null,className:Be,cols:ie,colSpan:null,content:null,contentEditable:tt,controls:ke,controlsList:Be,coords:ie|cr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ke,defer:ke,dir:null,dirName:null,disabled:ke,download:Za,draggable:tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ke,formTarget:null,headers:Be,height:ie,hidden:Za,high:ie,href:null,hrefLang:null,htmlFor:Be,httpEquiv:Be,id:null,imageSizes:null,imageSrcSet:null,inert:ke,inputMode:null,integrity:null,is:null,isMap:ke,itemId:null,itemProp:Be,itemRef:Be,itemScope:ke,itemType:Be,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ke,low:ie,manifest:null,max:null,maxLength:ie,media:null,method:null,min:null,minLength:ie,multiple:ke,muted:ke,name:null,nonce:null,noModule:ke,noValidate:ke,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ke,optimum:ie,pattern:null,ping:Be,placeholder:null,playsInline:ke,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ke,referrerPolicy:null,rel:Be,required:ke,reversed:ke,rows:ie,rowSpan:ie,sandbox:Be,scope:null,scoped:ke,seamless:ke,selected:ke,shadowRootClonable:ke,shadowRootDelegatesFocus:ke,shadowRootMode:null,shape:null,size:ie,sizes:null,slot:null,span:ie,spellCheck:tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ie,step:null,style:null,tabIndex:ie,target:null,title:null,translate:null,type:null,typeMustMatch:ke,useMap:null,value:tt,width:ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Be,axis:null,background:null,bgColor:null,border:ie,borderColor:null,bottomMargin:ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ke,declare:ke,event:null,face:null,frame:null,frameBorder:null,hSpace:ie,leftMargin:ie,link:null,longDesc:null,lowSrc:null,marginHeight:ie,marginWidth:ie,noResize:ke,noHref:ke,noShade:ke,noWrap:ke,object:null,profile:null,prompt:null,rev:null,rightMargin:ie,rules:null,scheme:null,scrolling:tt,standby:null,summary:null,text:null,topMargin:ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ke,disableRemotePlayback:ke,prefix:null,property:null,results:ie,security:null,unselectable:null},space:"html",transform:up}),Lv=jr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:jt,accentHeight:ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ie,amplitude:ie,arabicForm:null,ascent:ie,attributeName:null,attributeType:null,azimuth:ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ie,by:null,calcMode:null,capHeight:ie,className:Be,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ie,diffuseConstant:ie,direction:null,display:null,dur:null,divisor:ie,dominantBaseline:null,download:ke,dx:null,dy:null,edgeMode:null,editable:null,elevation:ie,enableBackground:null,end:null,event:null,exponent:ie,externalResourcesRequired:null,fill:null,fillOpacity:ie,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:cr,g2:cr,glyphName:cr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ie,horizOriginX:ie,horizOriginY:ie,id:null,ideographic:ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ie,k:ie,k1:ie,k2:ie,k3:ie,k4:ie,kernelMatrix:jt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ie,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ie,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ie,overlineThickness:ie,paintOrder:null,panose1:null,path:null,pathLength:ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Be,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ie,pointsAtY:ie,pointsAtZ:ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:jt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:jt,rev:jt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:jt,requiredFeatures:jt,requiredFonts:jt,requiredFormats:jt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ie,specularExponent:ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ie,strikethroughThickness:ie,string:null,stroke:null,strokeDashArray:jt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ie,strokeOpacity:ie,strokeWidth:null,style:null,surfaceScale:ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:jt,tabIndex:ie,tableValues:null,target:null,targetX:ie,targetY:ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:jt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ie,underlineThickness:ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ie,values:null,vAlphabetic:ie,vMathematical:ie,vectorEffect:null,vHanging:ie,vIdeographic:ie,version:null,vertAdvY:ie,vertOriginX:ie,vertOriginY:ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:lp}),cp=jr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),dp=jr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:up}),fp=jr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Bv={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Zv=/[A-Z]/g,nu=/-[a-z]/g,Vv=/^data[-\w.:]+$/i;function Uv(e,t){const n=Ba(t);let r=t,i=St;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Vv.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(nu,Hv);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!nu.test(s)){let a=s.replace(Zv,Jv);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Io}return new i(r,t)}function Jv(e){return"-"+e.toLowerCase()}function Hv(e){return e.charAt(1).toUpperCase()}const Wv=ap([op,Fv,cp,dp,fp],"html"),Ao=ap([op,Lv,cp,dp,fp],"svg");function qv(e){return e.join(" ").trim()}var Hn={},na,ru;function Gv(){if(ru)return na;ru=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
10
- `,c="/",d="*",f="",h="comment",p="declaration";function g(_,b){if(typeof _!="string")throw new TypeError("First argument must be a string");if(!_)return[];b=b||{};var E=1,m=1;function O(I){var M=I.match(t);M&&(E+=M.length);var J=I.lastIndexOf(l);m=~J?I.length-J:m+I.length}function N(){var I={line:E,column:m};return function(M){return M.position=new w(I),q(),M}}function w(I){this.start=I,this.end={line:E,column:m},this.source=b.source}w.prototype.content=_;function k(I){var M=new Error(b.source+":"+E+":"+m+": "+I);if(M.reason=I,M.filename=b.source,M.line=E,M.column=m,M.source=_,!b.silent)throw M}function R(I){var M=I.exec(_);if(M){var J=M[0];return O(J),_=_.slice(J.length),M}}function q(){R(n)}function j(I){var M;for(I=I||[];M=T();)M!==!1&&I.push(M);return I}function T(){var I=N();if(!(c!=_.charAt(0)||d!=_.charAt(1))){for(var M=2;f!=_.charAt(M)&&(d!=_.charAt(M)||c!=_.charAt(M+1));)++M;if(M+=2,f===_.charAt(M-1))return k("End of comment missing");var J=_.slice(2,M-2);return m+=2,O(J),_=_.slice(M),m+=2,I({type:h,comment:J})}}function z(){var I=N(),M=R(r);if(M){if(T(),!R(i))return k("property missing ':'");var J=R(s),Z=I({type:p,property:v(M[0].replace(e,f)),value:J?v(J[0].replace(e,f)):f});return R(a),Z}}function P(){var I=[];j(I);for(var M;M=z();)M!==!1&&(I.push(M),j(I));return I}return q(),P()}function v(_){return _?_.replace(o,f):f}return na=g,na}var iu;function Yv(){if(iu)return Hn;iu=1;var e=Hn&&Hn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.default=n;const t=e(Gv());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:d}=l;o?i(c,d,l):d&&(s=s||{},s[c]=d)}),s}return Hn}var Pr={},su;function Kv(){if(su)return Pr;su=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},a=function(c,d){return d.toUpperCase()},o=function(c,d){return"".concat(d,"-")},l=function(c,d){return d===void 0&&(d={}),s(c)?c:(c=c.toLowerCase(),d.reactCompat?c=c.replace(i,o):c=c.replace(r,o),c.replace(t,a))};return Pr.camelCase=l,Pr}var Dr,au;function Xv(){if(au)return Dr;au=1;var e=Dr&&Dr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Yv()),n=Kv();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,Dr=r,Dr}var Qv=Xv();const ew=uo(Qv),pp=hp("end"),zo=hp("start");function hp(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function tw(e){const t=zo(e),n=pp(e);if(t&&n)return{start:t,end:n}}function Kr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ou(e.position):"start"in e||"end"in e?ou(e):"line"in e||"column"in e?Ua(e):""}function Ua(e){return lu(e&&e.line)+":"+lu(e&&e.column)}function ou(e){return Ua(e&&e.start)+"-"+Ua(e&&e.end)}function lu(e){return e&&typeof e=="number"?e:1}class lt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=Kr(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}lt.prototype.file="";lt.prototype.name="";lt.prototype.reason="";lt.prototype.message="";lt.prototype.stack="";lt.prototype.column=void 0;lt.prototype.line=void 0;lt.prototype.ancestors=void 0;lt.prototype.cause=void 0;lt.prototype.fatal=void 0;lt.prototype.place=void 0;lt.prototype.ruleId=void 0;lt.prototype.source=void 0;const Oo={}.hasOwnProperty,nw=new Map,rw=/[A-Z]/g,iw=new Set(["table","tbody","thead","tfoot","tr"]),sw=new Set(["td","th"]),mp="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function aw(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=hw(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=pw(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ao:Wv,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=gp(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function gp(e,t,n){if(t.type==="element")return ow(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return lw(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return cw(e,t,n);if(t.type==="mdxjsEsm")return uw(e,t);if(t.type==="root")return dw(e,t,n);if(t.type==="text")return fw(e,t)}function ow(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Ao,e.schema=i),e.ancestors.push(t);const s=yp(e,t.tagName,!1),a=mw(e,t);let o=Do(e,t);return iw.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!Mv(l):!0})),xp(e,a,s,t),Po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function lw(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}oi(e,t.position)}function uw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);oi(e,t.position)}function cw(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Ao,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:yp(e,t.name,!0),a=gw(e,t),o=Do(e,t);return xp(e,a,s,t),Po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function dw(e,t,n){const r={};return Po(r,Do(e,t)),e.create(t,e.Fragment,r,n)}function fw(e,t){return t.value}function xp(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Po(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function pw(e,t,n){return r;function r(i,s,a,o){const c=Array.isArray(a.children)?n:t;return o?c(s,a,o):c(s,a)}}function hw(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=zo(r);return t(i,s,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function mw(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Oo.call(t.properties,i)){const s=xw(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&sw.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function gw(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else oi(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else oi(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Do(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:nw;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;a=l+"-"+c,i.set(l,c+1)}}const o=gp(e,s,a);o!==void 0&&n.push(o)}return n}function xw(e,t,n){const r=Uv(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?zv(n):qv(n)),r.property==="style"){let i=typeof n=="object"?n:yw(e,String(n));return e.stylePropertyNameCase==="css"&&(i=bw(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Bv[r.property]||r.property:r.attribute,n]}}function yw(e,t){try{return ew(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new lt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=mp+"#cannot-parse-style-attribute",i}}function yp(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=Ql(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=Ql(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Oo.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);oi(e)}function oi(e,t){const n=new lt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=mp+"#cannot-handle-mdx-estrees-without-createevaluater",n}function bw(e){const t={};let n;for(n in e)Oo.call(e,n)&&(t[vw(n)]=e[n]);return t}function vw(e){let t=e.replace(rw,ww);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function ww(e){return"-"+e.toLowerCase()}const ra={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},kw={};function Ro(e,t){const n=kw,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return bp(e,r,i)}function bp(e,t,n){if(Sw(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return uu(e.children,t,n)}return Array.isArray(e)?uu(e,t,n):""}function uu(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=bp(e[i],t,n);return r.join("")}function Sw(e){return!!(e&&typeof e=="object")}const cu=document.createElement("i");function Mo(e){const t="&"+e+";";cu.innerHTML=t;const n=cu.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Tt(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Ot(e,t){return e.length>0?(Tt(e,e.length,0,t),e):t}const du={}.hasOwnProperty;function vp(e){const t={};let n=-1;for(;++n<e.length;)_w(t,e[n]);return t}function _w(e,t){let n;for(n in t){const i=(du.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){du.call(i,a)||(i[a]=[]);const o=s[a];jw(i[a],Array.isArray(o)?o:o?[o]:[])}}}function jw(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Tt(e,0,0,r)}function wp(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Zt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pt=kn(/[A-Za-z]/),ot=kn(/[\dA-Za-z]/),Nw=kn(/[#-'*+\--9=?A-Z^-~]/);function ss(e){return e!==null&&(e<32||e===127)}const Ja=kn(/\d/),Ew=kn(/[\dA-Fa-f]/),Cw=kn(/[!-/:-@[-`{-~]/);function ye(e){return e!==null&&e<-2}function Fe(e){return e!==null&&(e<0||e===32)}function Ce(e){return e===-2||e===-1||e===32}const Os=kn(new RegExp("\\p{P}|\\p{S}","u")),Rn=kn(/\s/);function kn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Nr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&ot(e.charCodeAt(n+1))&&ot(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ze(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Ce(l)?(e.enter(n),o(l)):t(l)}function o(l){return Ce(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const Tw={tokenize:Iw};function Iw(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ze(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return ye(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Aw={tokenize:zw},fu={tokenize:Ow};function zw(e){const t=this,n=[];let r=0,i,s,a;return o;function o(m){if(r<n.length){const O=n[r];return t.containerState=O[1],e.attempt(O[0].continuation,l,c)(m)}return c(m)}function l(m){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&E();const O=t.events.length;let N=O,w;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){w=t.events[N][1].end;break}b(r);let k=O;for(;k<t.events.length;)t.events[k][1].end={...w},k++;return Tt(t.events,N+1,0,t.events.slice(O)),t.events.length=k,c(m)}return o(m)}function c(m){if(r===n.length){if(!i)return h(m);if(i.currentConstruct&&i.currentConstruct.concrete)return g(m);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fu,d,f)(m)}function d(m){return i&&E(),b(r),h(m)}function f(m){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(m)}function h(m){return t.containerState={},e.attempt(fu,p,g)(m)}function p(m){return r++,n.push([t.currentConstruct,t.containerState]),h(m)}function g(m){if(m===null){i&&E(),b(0),e.consume(m);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(m)}function v(m){if(m===null){_(e.exit("chunkFlow"),!0),b(0),e.consume(m);return}return ye(m)?(e.consume(m),_(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(m),v)}function _(m,O){const N=t.sliceStream(m);if(O&&N.push(null),m.previous=s,s&&(s.next=m),s=m,i.defineSkip(m.start),i.write(N),t.parser.lazy[m.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<a&&(!i.events[w][1].end||i.events[w][1].end.offset>a))return;const k=t.events.length;let R=k,q,j;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(q){j=t.events[R][1].end;break}q=!0}for(b(r),w=k;w<t.events.length;)t.events[w][1].end={...j},w++;Tt(t.events,R+1,0,t.events.slice(k)),t.events.length=w}}function b(m){let O=n.length;for(;O-- >m;){const N=n[O];t.containerState=N[1],N[0].exit.call(t,e)}n.length=m}function E(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ow(e,t,n){return ze(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function yr(e){if(e===null||Fe(e)||Rn(e))return 1;if(Os(e))return 2}function Ps(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Ha={name:"attention",resolveAll:Pw,tokenize:Dw};function Pw(e,t){let n=-1,r,i,s,a,o,l,c,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};pu(f,-l),pu(h,l),a={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},o={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Ot(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Ot(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),c=Ot(c,Ps(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Ot(c,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,c=Ot(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Tt(e,r-1,n-r+3,c),n=r+c.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Dw(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=yr(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const c=e.exit("attentionSequence"),d=yr(l),f=!d||d===2&&i||n.includes(l),h=!i||i===2&&d||n.includes(r);return c._open=!!(s===42?f:f&&(i||!h)),c._close=!!(s===42?h:h&&(d||!f)),t(l)}}function pu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Rw={name:"autolink",tokenize:Mw};function Mw(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return pt(p)?(e.consume(p),a):p===64?n(p):c(p)}function a(p){return p===43||p===45||p===46||ot(p)?(r=1,o(p)):c(p)}function o(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||ot(p))&&r++<32?(e.consume(p),o):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ss(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),d):Nw(p)?(e.consume(p),c):n(p)}function d(p){return ot(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||ot(p))&&r++<63){const g=p===45?h:f;return e.consume(p),g}return n(p)}}const vi={partial:!0,tokenize:$w};function $w(e,t,n){return r;function r(s){return Ce(s)?ze(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ye(s)?t(s):n(s)}}const kp={continuation:{tokenize:Lw},exit:Bw,name:"blockQuote",tokenize:Fw};function Fw(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return Ce(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Lw(e,t,n){const r=this;return i;function i(a){return Ce(a)?ze(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(kp,t,n)(a)}}function Bw(e){e.exit("blockQuote")}const Sp={name:"characterEscape",tokenize:Zw};function Zw(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Cw(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const _p={name:"characterReference",tokenize:Vw};function Vw(e,t,n){const r=this;let i=0,s,a;return o;function o(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,a=ot,d(f))}function c(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Ew,d):(e.enter("characterReferenceValue"),s=7,a=Ja,d(f))}function d(f){if(f===59&&i){const h=e.exit("characterReferenceValue");return a===ot&&!Mo(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&i++<s?(e.consume(f),d):n(f)}}const hu={partial:!0,tokenize:Jw},mu={concrete:!0,name:"codeFenced",tokenize:Uw};function Uw(e,t,n){const r=this,i={partial:!0,tokenize:N};let s=0,a=0,o;return l;function l(w){return c(w)}function c(w){const k=r.events[r.events.length-1];return s=k&&k[1].type==="linePrefix"?k[2].sliceSerialize(k[1],!0).length:0,o=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===o?(a++,e.consume(w),d):a<3?n(w):(e.exit("codeFencedFenceSequence"),Ce(w)?ze(e,f,"whitespace")(w):f(w))}function f(w){return w===null||ye(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(hu,v,O)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(w))}function h(w){return w===null||ye(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(w)):Ce(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ze(e,p,"whitespace")(w)):w===96&&w===o?n(w):(e.consume(w),h)}function p(w){return w===null||ye(w)?f(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(w))}function g(w){return w===null||ye(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(w)):w===96&&w===o?n(w):(e.consume(w),g)}function v(w){return e.attempt(i,O,_)(w)}function _(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),b}function b(w){return s>0&&Ce(w)?ze(e,E,"linePrefix",s+1)(w):E(w)}function E(w){return w===null||ye(w)?e.check(hu,v,O)(w):(e.enter("codeFlowValue"),m(w))}function m(w){return w===null||ye(w)?(e.exit("codeFlowValue"),E(w)):(e.consume(w),m)}function O(w){return e.exit("codeFenced"),t(w)}function N(w,k,R){let q=0;return j;function j(M){return w.enter("lineEnding"),w.consume(M),w.exit("lineEnding"),T}function T(M){return w.enter("codeFencedFence"),Ce(M)?ze(w,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):z(M)}function z(M){return M===o?(w.enter("codeFencedFenceSequence"),P(M)):R(M)}function P(M){return M===o?(q++,w.consume(M),P):q>=a?(w.exit("codeFencedFenceSequence"),Ce(M)?ze(w,I,"whitespace")(M):I(M)):R(M)}function I(M){return M===null||ye(M)?(w.exit("codeFencedFence"),k(M)):R(M)}}}function Jw(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const ia={name:"codeIndented",tokenize:Ww},Hw={partial:!0,tokenize:qw};function Ww(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ze(e,s,"linePrefix",5)(c)}function s(c){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(c):n(c)}function a(c){return c===null?l(c):ye(c)?e.attempt(Hw,a,l)(c):(e.enter("codeFlowValue"),o(c))}function o(c){return c===null||ye(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),o)}function l(c){return e.exit("codeIndented"),t(c)}}function qw(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):ye(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ze(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):ye(a)?i(a):n(a)}}const Gw={name:"codeText",previous:Kw,resolve:Yw,tokenize:Xw};function Yw(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Kw(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Xw(e,t,n){let r=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),o(f)}function o(f){return f===96?(e.consume(f),r++,o):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):ye(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(f))}function c(f){return f===null||f===32||f===96||ye(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),c)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",c(f))}}class Qw{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Rr(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Rr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Rr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Rr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Rr(this.left,n.reverse())}}}function Rr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function jp(e){const t={};let n=-1,r,i,s,a,o,l,c;const d=new Qw(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,e0(d,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=d.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},o=d.slice(i,n),o.unshift(r),d.splice(i,n-i+1,o))}}return Tt(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function e0(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],c={};let d,f,h=-1,p=n,g=0,v=0;const _=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),f&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++h<o.length;)o[h][0]==="exit"&&o[h-1][0]==="enter"&&o[h][1].type===o[h-1][1].type&&o[h][1].start.line!==o[h][1].end.line&&(v=h+1,_.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):_.pop(),h=_.length;h--;){const b=o.slice(_[h],_[h+1]),E=s.pop();l.push([E,E+b.length-1]),e.splice(E,2,b)}for(l.reverse(),h=-1;++h<l.length;)c[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return c}const t0={resolve:r0,tokenize:i0},n0={partial:!0,tokenize:s0};function r0(e){return jp(e),e}function i0(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):ye(o)?e.check(n0,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function s0(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ze(e,s,"linePrefix")}function s(a){if(a===null||ye(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Np(e,t,n,r,i,s,a,o,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return f;function f(b){return b===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(b),e.exit(s),h):b===null||b===32||b===41||ss(b)?n(b):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),v(b))}function h(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===62?(e.exit("chunkString"),e.exit(o),h(b)):b===null||b===60||ye(b)?n(b):(e.consume(b),b===92?g:p)}function g(b){return b===60||b===62||b===92?(e.consume(b),p):p(b)}function v(b){return!d&&(b===null||b===41||Fe(b))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(b)):d<c&&b===40?(e.consume(b),d++,v):b===41?(e.consume(b),d--,v):b===null||b===32||b===40||ss(b)?n(b):(e.consume(b),b===92?_:v)}function _(b){return b===40||b===41||b===92?(e.consume(b),v):v(b)}}function Ep(e,t,n,r,i,s){const a=this;let o=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),d}function d(p){return o>999||p===null||p===91||p===93&&!l||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):ye(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||ye(p)||o++>999?(e.exit("chunkString"),d(p)):(e.consume(p),l||(l=!Ce(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function Cp(e,t,n,r,i,s){let a;return o;function o(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,l):n(h)}function l(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),c(h))}function c(h){return h===a?(e.exit(s),l(a)):h===null?n(h):ye(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),ze(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===a||h===null||ye(h)?(e.exit("chunkString"),c(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function Xr(e,t){let n;return r;function r(i){return ye(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ce(i)?ze(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const a0={name:"definition",tokenize:l0},o0={partial:!0,tokenize:u0};function l0(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),a(p)}function a(p){return Ep.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return i=Zt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return Fe(p)?Xr(e,c)(p):c(p)}function c(p){return Np(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(o0,f,f)(p)}function f(p){return Ce(p)?ze(e,h,"whitespace")(p):h(p)}function h(p){return p===null||ye(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function u0(e,t,n){return r;function r(o){return Fe(o)?Xr(e,i)(o):n(o)}function i(o){return Cp(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ce(o)?ze(e,a,"whitespace")(o):a(o)}function a(o){return o===null||ye(o)?t(o):n(o)}}const c0={name:"hardBreakEscape",tokenize:d0};function d0(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ye(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const f0={name:"headingAtx",resolve:p0,tokenize:h0};function p0(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Tt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function h0(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||Fe(d)?(e.exit("atxHeadingSequence"),o(d)):n(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||ye(d)?(e.exit("atxHeading"),t(d)):Ce(d)?ze(e,o,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),o(d))}function c(d){return d===null||d===35||Fe(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),c)}}const m0=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],gu=["pre","script","style","textarea"],g0={concrete:!0,name:"htmlFlow",resolveTo:b0,tokenize:v0},x0={partial:!0,tokenize:k0},y0={partial:!0,tokenize:w0};function b0(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function v0(e,t,n){const r=this;let i,s,a,o,l;return c;function c(y){return d(y)}function d(y){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(y),f}function f(y){return y===33?(e.consume(y),h):y===47?(e.consume(y),s=!0,v):y===63?(e.consume(y),i=3,r.interrupt?t:S):pt(y)?(e.consume(y),a=String.fromCharCode(y),_):n(y)}function h(y){return y===45?(e.consume(y),i=2,p):y===91?(e.consume(y),i=5,o=0,g):pt(y)?(e.consume(y),i=4,r.interrupt?t:S):n(y)}function p(y){return y===45?(e.consume(y),r.interrupt?t:S):n(y)}function g(y){const W="CDATA[";return y===W.charCodeAt(o++)?(e.consume(y),o===W.length?r.interrupt?t:z:g):n(y)}function v(y){return pt(y)?(e.consume(y),a=String.fromCharCode(y),_):n(y)}function _(y){if(y===null||y===47||y===62||Fe(y)){const W=y===47,X=a.toLowerCase();return!W&&!s&&gu.includes(X)?(i=1,r.interrupt?t(y):z(y)):m0.includes(a.toLowerCase())?(i=6,W?(e.consume(y),b):r.interrupt?t(y):z(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(y):s?E(y):m(y))}return y===45||ot(y)?(e.consume(y),a+=String.fromCharCode(y),_):n(y)}function b(y){return y===62?(e.consume(y),r.interrupt?t:z):n(y)}function E(y){return Ce(y)?(e.consume(y),E):j(y)}function m(y){return y===47?(e.consume(y),j):y===58||y===95||pt(y)?(e.consume(y),O):Ce(y)?(e.consume(y),m):j(y)}function O(y){return y===45||y===46||y===58||y===95||ot(y)?(e.consume(y),O):N(y)}function N(y){return y===61?(e.consume(y),w):Ce(y)?(e.consume(y),N):m(y)}function w(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),l=y,k):Ce(y)?(e.consume(y),w):R(y)}function k(y){return y===l?(e.consume(y),l=null,q):y===null||ye(y)?n(y):(e.consume(y),k)}function R(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||Fe(y)?N(y):(e.consume(y),R)}function q(y){return y===47||y===62||Ce(y)?m(y):n(y)}function j(y){return y===62?(e.consume(y),T):n(y)}function T(y){return y===null||ye(y)?z(y):Ce(y)?(e.consume(y),T):n(y)}function z(y){return y===45&&i===2?(e.consume(y),J):y===60&&i===1?(e.consume(y),Z):y===62&&i===4?(e.consume(y),le):y===63&&i===3?(e.consume(y),S):y===93&&i===5?(e.consume(y),ne):ye(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(x0,B,P)(y)):y===null||ye(y)?(e.exit("htmlFlowData"),P(y)):(e.consume(y),z)}function P(y){return e.check(y0,I,B)(y)}function I(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),M}function M(y){return y===null||ye(y)?P(y):(e.enter("htmlFlowData"),z(y))}function J(y){return y===45?(e.consume(y),S):z(y)}function Z(y){return y===47?(e.consume(y),a="",V):z(y)}function V(y){if(y===62){const W=a.toLowerCase();return gu.includes(W)?(e.consume(y),le):z(y)}return pt(y)&&a.length<8?(e.consume(y),a+=String.fromCharCode(y),V):z(y)}function ne(y){return y===93?(e.consume(y),S):z(y)}function S(y){return y===62?(e.consume(y),le):y===45&&i===2?(e.consume(y),S):z(y)}function le(y){return y===null||ye(y)?(e.exit("htmlFlowData"),B(y)):(e.consume(y),le)}function B(y){return e.exit("htmlFlow"),t(y)}}function w0(e,t,n){const r=this;return i;function i(a){return ye(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function k0(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(vi,t,n)}}const S0={name:"htmlText",tokenize:_0};function _0(e,t,n){const r=this;let i,s,a;return o;function o(S){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(S),l}function l(S){return S===33?(e.consume(S),c):S===47?(e.consume(S),N):S===63?(e.consume(S),m):pt(S)?(e.consume(S),R):n(S)}function c(S){return S===45?(e.consume(S),d):S===91?(e.consume(S),s=0,g):pt(S)?(e.consume(S),E):n(S)}function d(S){return S===45?(e.consume(S),p):n(S)}function f(S){return S===null?n(S):S===45?(e.consume(S),h):ye(S)?(a=f,Z(S)):(e.consume(S),f)}function h(S){return S===45?(e.consume(S),p):f(S)}function p(S){return S===62?J(S):S===45?h(S):f(S)}function g(S){const le="CDATA[";return S===le.charCodeAt(s++)?(e.consume(S),s===le.length?v:g):n(S)}function v(S){return S===null?n(S):S===93?(e.consume(S),_):ye(S)?(a=v,Z(S)):(e.consume(S),v)}function _(S){return S===93?(e.consume(S),b):v(S)}function b(S){return S===62?J(S):S===93?(e.consume(S),b):v(S)}function E(S){return S===null||S===62?J(S):ye(S)?(a=E,Z(S)):(e.consume(S),E)}function m(S){return S===null?n(S):S===63?(e.consume(S),O):ye(S)?(a=m,Z(S)):(e.consume(S),m)}function O(S){return S===62?J(S):m(S)}function N(S){return pt(S)?(e.consume(S),w):n(S)}function w(S){return S===45||ot(S)?(e.consume(S),w):k(S)}function k(S){return ye(S)?(a=k,Z(S)):Ce(S)?(e.consume(S),k):J(S)}function R(S){return S===45||ot(S)?(e.consume(S),R):S===47||S===62||Fe(S)?q(S):n(S)}function q(S){return S===47?(e.consume(S),J):S===58||S===95||pt(S)?(e.consume(S),j):ye(S)?(a=q,Z(S)):Ce(S)?(e.consume(S),q):J(S)}function j(S){return S===45||S===46||S===58||S===95||ot(S)?(e.consume(S),j):T(S)}function T(S){return S===61?(e.consume(S),z):ye(S)?(a=T,Z(S)):Ce(S)?(e.consume(S),T):q(S)}function z(S){return S===null||S===60||S===61||S===62||S===96?n(S):S===34||S===39?(e.consume(S),i=S,P):ye(S)?(a=z,Z(S)):Ce(S)?(e.consume(S),z):(e.consume(S),I)}function P(S){return S===i?(e.consume(S),i=void 0,M):S===null?n(S):ye(S)?(a=P,Z(S)):(e.consume(S),P)}function I(S){return S===null||S===34||S===39||S===60||S===61||S===96?n(S):S===47||S===62||Fe(S)?q(S):(e.consume(S),I)}function M(S){return S===47||S===62||Fe(S)?q(S):n(S)}function J(S){return S===62?(e.consume(S),e.exit("htmlTextData"),e.exit("htmlText"),t):n(S)}function Z(S){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),V}function V(S){return Ce(S)?ze(e,ne,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):ne(S)}function ne(S){return e.enter("htmlTextData"),a(S)}}const $o={name:"labelEnd",resolveAll:C0,resolveTo:T0,tokenize:I0},j0={tokenize:A0},N0={tokenize:z0},E0={tokenize:O0};function C0(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Tt(e,0,e.length,n),e}function T0(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",c,t]],o=Ot(o,e.slice(s+1,s+r+3)),o=Ot(o,[["enter",d,t]]),o=Ot(o,Ps(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Ot(o,[["exit",d,t],e[a-2],e[a-1],["exit",c,t]]),o=Ot(o,e.slice(a+1)),o=Ot(o,[["exit",l,t]]),Tt(e,s,e.length,o),e}function I0(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(h){return s?s._inactive?f(h):(a=r.parser.defined.includes(Zt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(j0,d,a?d:f)(h):h===91?e.attempt(N0,d,a?c:f)(h):a?d(h):f(h)}function c(h){return e.attempt(E0,d,f)(h)}function d(h){return t(h)}function f(h){return s._balanced=!0,n(h)}}function A0(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return Fe(f)?Xr(e,s)(f):s(f)}function s(f){return f===41?d(f):Np(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Fe(f)?Xr(e,l)(f):d(f)}function o(f){return n(f)}function l(f){return f===34||f===39||f===40?Cp(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function c(f){return Fe(f)?Xr(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function z0(e,t,n){const r=this;return i;function i(o){return Ep.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Zt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function O0(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const P0={name:"labelStartImage",resolveAll:$o.resolveAll,tokenize:D0};function D0(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const R0={name:"labelStartLink",resolveAll:$o.resolveAll,tokenize:M0};function M0(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const sa={name:"lineEnding",tokenize:$0};function $0(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ze(e,t,"linePrefix")}}const Zi={name:"thematicBreak",tokenize:F0};function F0(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),a(c)}function a(c){return i=c,o(c)}function o(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||ye(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ce(c)?ze(e,o,"whitespace")(c):o(c))}}const xt={continuation:{tokenize:V0},exit:J0,name:"list",tokenize:Z0},L0={partial:!0,tokenize:H0},B0={partial:!0,tokenize:U0};function Z0(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Ja(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Zi,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return Ja(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(vi,r.interrupt?n:d,e.attempt(L0,h,f))}function d(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function f(p){return Ce(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function V0(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(vi,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ze(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Ce(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(B0,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ze(e,e.attempt(xt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function U0(e,t,n){const r=this;return ze(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function J0(e){e.exit(this.containerState.type)}function H0(e,t,n){const r=this;return ze(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Ce(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const xu={name:"setextUnderline",resolveTo:W0,tokenize:q0};function W0(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function q0(e,t,n){const r=this;let i;return s;function s(c){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=c,a(c)):n(c)}function a(c){return e.enter("setextHeadingLineSequence"),o(c)}function o(c){return c===i?(e.consume(c),o):(e.exit("setextHeadingLineSequence"),Ce(c)?ze(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ye(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const G0={tokenize:Y0};function Y0(e){const t=this,n=e.attempt(vi,r,e.attempt(this.parser.constructs.flowInitial,i,ze(e,e.attempt(this.parser.constructs.flow,i,e.attempt(t0,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const K0={resolveAll:Ip()},X0=Tp("string"),Q0=Tp("text");function Tp(e){return{resolveAll:Ip(e==="text"?ek:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(d){return c(d)?s(d):o(d)}function o(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return c(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function c(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const p=f[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function Ip(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function ek(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(c===-2)l=!0,o++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const c={type:n===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const tk={42:xt,43:xt,45:xt,48:xt,49:xt,50:xt,51:xt,52:xt,53:xt,54:xt,55:xt,56:xt,57:xt,62:kp},nk={91:a0},rk={[-2]:ia,[-1]:ia,32:ia},ik={35:f0,42:Zi,45:[xu,Zi],60:g0,61:xu,95:Zi,96:mu,126:mu},sk={38:_p,92:Sp},ak={[-5]:sa,[-4]:sa,[-3]:sa,33:P0,38:_p,42:Ha,60:[Rw,S0],91:R0,92:[c0,Sp],93:$o,95:Ha,96:Gw},ok={null:[Ha,K0]},lk={null:[42,95]},uk={null:[]},ck=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:lk,contentInitial:nk,disable:uk,document:tk,flow:ik,flowInitial:rk,insideSpan:ok,string:sk,text:ak},Symbol.toStringTag,{value:"Module"}));function dk(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:k(N),check:k(w),consume:E,enter:m,exit:O,interrupt:k(w,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:f};let d=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function f(T){return a=Ot(a,T),_(),a[a.length-1]!==null?[]:(R(t,0),c.events=Ps(s,c.events,c),c.events)}function h(T,z){return pk(p(T),z)}function p(T){return fk(a,T)}function g(){const{_bufferIndex:T,_index:z,line:P,column:I,offset:M}=r;return{_bufferIndex:T,_index:z,line:P,column:I,offset:M}}function v(T){i[T.line]=T.column,j()}function _(){let T;for(;r._index<a.length;){const z=a[r._index];if(typeof z=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<z.length;)b(z.charCodeAt(r._bufferIndex));else b(z)}}function b(T){d=d(T)}function E(T){ye(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,j()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=T}function m(T,z){const P=z||{};return P.type=T,P.start=g(),c.events.push(["enter",P,c]),o.push(P),P}function O(T){const z=o.pop();return z.end=g(),c.events.push(["exit",z,c]),z}function N(T,z){R(T,z.from)}function w(T,z){z.restore()}function k(T,z){return P;function P(I,M,J){let Z,V,ne,S;return Array.isArray(I)?B(I):"tokenize"in I?B([I]):le(I);function le(Y){return re;function re(D){const de=D!==null&&Y[D],te=D!==null&&Y.null,ae=[...Array.isArray(de)?de:de?[de]:[],...Array.isArray(te)?te:te?[te]:[]];return B(ae)(D)}}function B(Y){return Z=Y,V=0,Y.length===0?J:y(Y[V])}function y(Y){return re;function re(D){return S=q(),ne=Y,Y.partial||(c.currentConstruct=Y),Y.name&&c.parser.constructs.disable.null.includes(Y.name)?X():Y.tokenize.call(z?Object.assign(Object.create(c),z):c,l,W,X)(D)}}function W(Y){return T(ne,S),M}function X(Y){return S.restore(),++V<Z.length?y(Z[V]):J}}}function R(T,z){T.resolveAll&&!s.includes(T)&&s.push(T),T.resolve&&Tt(c.events,z,c.events.length-z,T.resolve(c.events.slice(z),c)),T.resolveTo&&(c.events=T.resolveTo(c.events,c))}function q(){const T=g(),z=c.previous,P=c.currentConstruct,I=c.events.length,M=Array.from(o);return{from:I,restore:J};function J(){r=T,c.previous=z,c.currentConstruct=P,c.events.length=I,o=M,j()}}function j(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function fk(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function pk(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
11
- `;break}case-3:{a=`\r
12
- `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function hk(e){const r={constructs:vp([ck,...(e||{}).extensions||[]]),content:i(Tw),defined:[],document:i(Aw),flow:i(G0),lazy:{},string:i(X0),text:i(Q0)};return r;function i(s){return a;function a(o){return dk(r,s,o)}}}function mk(e){for(;!jp(e););return e}const yu=/[\0\t\n\r]/g;function gk(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let c,d,f,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(yu.lastIndex=f,c=yu.exec(s),h=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(h),!c){t=s.slice(f);break}if(p===10&&f===h&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<h&&(l.push(s.slice(f,h)),e+=h-f),p){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const xk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function yk(e){return e.replace(xk,bk)}function bk(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return wp(n.slice(s?2:1),s?16:10)}return Mo(n)||e}const Ap={}.hasOwnProperty;function vk(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),wk(n)(mk(hk(n).document().write(gk()(e,t,!0))))}function wk(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s($),autolinkProtocol:q,autolinkEmail:q,atxHeading:s(Pe),blockQuote:s(te),characterEscape:q,characterReference:q,codeFenced:s(ae),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(ae,a),codeText:s(ue,a),codeTextData:q,data:q,codeFlowValue:q,definition:s(ge),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(pe),hardBreakEscape:s(De),hardBreakTrailing:s(De),htmlFlow:s(nt,a),htmlFlowData:q,htmlText:s(nt,a),htmlTextData:q,image:s(C),label:a,link:s($),listItem:s(se),listItemValue:h,listOrdered:s(U,f),listUnordered:s(U),paragraph:s(A),reference:y,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Pe),strong:s(K),thematicBreak:s(xe)},exit:{atxHeading:l(),atxHeadingSequence:N,autolink:l(),autolinkEmail:de,autolinkProtocol:D,blockQuote:l(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:X,characterReferenceMarkerNumeric:X,characterReferenceValue:Y,characterReference:re,codeFenced:l(_),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:j,codeIndented:l(b),codeText:l(M),codeTextData:j,data:j,definition:l(),definitionDestinationString:O,definitionLabelString:E,definitionTitleString:m,emphasis:l(),hardBreakEscape:l(z),hardBreakTrailing:l(z),htmlFlow:l(P),htmlFlowData:j,htmlText:l(I),htmlTextData:j,image:l(Z),label:ne,labelText:V,lineEnding:T,link:l(J),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:W,resourceDestinationString:S,resourceTitleString:le,resource:B,setextHeading:l(R),setextHeadingLineSequence:k,setextHeadingText:w,strong:l(),thematicBreak:l()}};zp(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(L){let Q={type:"root",children:[]};const he={stack:[Q],tokenStack:[],config:t,enter:o,exit:c,buffer:a,resume:d,data:n},ve=[];let F=-1;for(;++F<L.length;)if(L[F][1].type==="listOrdered"||L[F][1].type==="listUnordered")if(L[F][0]==="enter")ve.push(F);else{const me=ve.pop();F=i(L,me,F)}for(F=-1;++F<L.length;){const me=t[L[F][0]];Ap.call(me,L[F][1].type)&&me[L[F][1].type].call(Object.assign({sliceSerialize:L[F][2].sliceSerialize},he),L[F][1])}if(he.tokenStack.length>0){const me=he.tokenStack[he.tokenStack.length-1];(me[1]||bu).call(he,void 0,me[0])}for(Q.position={start:dn(L.length>0?L[0][1].start:{line:1,column:1,offset:0}),end:dn(L.length>0?L[L.length-2][1].end:{line:1,column:1,offset:0})},F=-1;++F<t.transforms.length;)Q=t.transforms[F](Q)||Q;return Q}function i(L,Q,he){let ve=Q-1,F=-1,me=!1,Te,Le,rt,et;for(;++ve<=he;){const at=L[ve];switch(at[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{at[0]==="enter"?F++:F--,et=void 0;break}case"lineEndingBlank":{at[0]==="enter"&&(Te&&!et&&!F&&!rt&&(rt=ve),et=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:et=void 0}if(!F&&at[0]==="enter"&&at[1].type==="listItemPrefix"||F===-1&&at[0]==="exit"&&(at[1].type==="listUnordered"||at[1].type==="listOrdered")){if(Te){let un=ve;for(Le=void 0;un--;){const en=L[un];if(en[1].type==="lineEnding"||en[1].type==="lineEndingBlank"){if(en[0]==="exit")continue;Le&&(L[Le][1].type="lineEndingBlank",me=!0),en[1].type="lineEnding",Le=un}else if(!(en[1].type==="linePrefix"||en[1].type==="blockQuotePrefix"||en[1].type==="blockQuotePrefixWhitespace"||en[1].type==="blockQuoteMarker"||en[1].type==="listItemIndent"))break}rt&&(!Le||rt<Le)&&(Te._spread=!0),Te.end=Object.assign({},Le?L[Le][1].start:at[1].end),L.splice(Le||ve,0,["exit",Te,at[2]]),ve++,he++}if(at[1].type==="listItemPrefix"){const un={type:"listItem",_spread:!1,start:Object.assign({},at[1].start),end:void 0};Te=un,L.splice(ve,0,["enter",un,at[2]]),ve++,he++,rt=void 0,et=!0}}}return L[Q][1]._spread=me,he}function s(L,Q){return he;function he(ve){o.call(this,L(ve),ve),Q&&Q.call(this,ve)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(L,Q,he){this.stack[this.stack.length-1].children.push(L),this.stack.push(L),this.tokenStack.push([Q,he||void 0]),L.position={start:dn(Q.start),end:void 0}}function l(L){return Q;function Q(he){L&&L.call(this,he),c.call(this,he)}}function c(L,Q){const he=this.stack.pop(),ve=this.tokenStack.pop();if(ve)ve[0].type!==L.type&&(Q?Q.call(this,L,ve[0]):(ve[1]||bu).call(this,L,ve[0]));else throw new Error("Cannot close `"+L.type+"` ("+Kr({start:L.start,end:L.end})+"): it’s not open");he.position.end=dn(L.end)}function d(){return Ro(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(L){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(L),10),this.data.expectingFirstListItemValue=void 0}}function p(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=L}function g(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=L}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L.replace(/(\r?\n|\r)$/g,"")}function E(L){const Q=this.resume(),he=this.stack[this.stack.length-1];he.label=Q,he.identifier=Zt(this.sliceSerialize(L)).toLowerCase()}function m(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.title=L}function O(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.url=L}function N(L){const Q=this.stack[this.stack.length-1];if(!Q.depth){const he=this.sliceSerialize(L).length;Q.depth=he}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function k(L){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(L).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function q(L){const he=this.stack[this.stack.length-1].children;let ve=he[he.length-1];(!ve||ve.type!=="text")&&(ve=ee(),ve.position={start:dn(L.start),end:void 0},he.push(ve)),this.stack.push(ve)}function j(L){const Q=this.stack.pop();Q.value+=this.sliceSerialize(L),Q.position.end=dn(L.end)}function T(L){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const he=Q.children[Q.children.length-1];he.position.end=dn(L.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(q.call(this,L),j.call(this,L))}function z(){this.data.atHardBreak=!0}function P(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L}function I(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L}function M(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.value=L}function J(){const L=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";L.type+="Reference",L.referenceType=Q,delete L.url,delete L.title}else delete L.identifier,delete L.label;this.data.referenceType=void 0}function Z(){const L=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";L.type+="Reference",L.referenceType=Q,delete L.url,delete L.title}else delete L.identifier,delete L.label;this.data.referenceType=void 0}function V(L){const Q=this.sliceSerialize(L),he=this.stack[this.stack.length-2];he.label=yk(Q),he.identifier=Zt(Q).toLowerCase()}function ne(){const L=this.stack[this.stack.length-1],Q=this.resume(),he=this.stack[this.stack.length-1];if(this.data.inReference=!0,he.type==="link"){const ve=L.children;he.children=ve}else he.alt=Q}function S(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.url=L}function le(){const L=this.resume(),Q=this.stack[this.stack.length-1];Q.title=L}function B(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function W(L){const Q=this.resume(),he=this.stack[this.stack.length-1];he.label=Q,he.identifier=Zt(this.sliceSerialize(L)).toLowerCase(),this.data.referenceType="full"}function X(L){this.data.characterReferenceType=L.type}function Y(L){const Q=this.sliceSerialize(L),he=this.data.characterReferenceType;let ve;he?(ve=wp(Q,he==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ve=Mo(Q);const F=this.stack[this.stack.length-1];F.value+=ve}function re(L){const Q=this.stack.pop();Q.position.end=dn(L.end)}function D(L){j.call(this,L);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(L)}function de(L){j.call(this,L);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(L)}function te(){return{type:"blockquote",children:[]}}function ae(){return{type:"code",lang:null,meta:null,value:""}}function ue(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function pe(){return{type:"emphasis",children:[]}}function Pe(){return{type:"heading",depth:0,children:[]}}function De(){return{type:"break"}}function nt(){return{type:"html",value:""}}function C(){return{type:"image",title:null,url:"",alt:null}}function $(){return{type:"link",title:null,url:"",children:[]}}function U(L){return{type:"list",ordered:L.type==="listOrdered",start:null,spread:L._spread,children:[]}}function se(L){return{type:"listItem",spread:L._spread,checked:null,children:[]}}function A(){return{type:"paragraph",children:[]}}function K(){return{type:"strong",children:[]}}function ee(){return{type:"text",value:""}}function xe(){return{type:"thematicBreak"}}}function dn(e){return{line:e.line,column:e.column,offset:e.offset}}function zp(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?zp(e,r):kk(e,r)}}function kk(e,t){let n;for(n in t)if(Ap.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function bu(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Kr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Kr({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Kr({start:t.start,end:t.end})+") is still open")}function Sk(e){const t=this;t.parser=n;function n(r){return vk(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _k(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function jk(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
13
- `}]}function Nk(e,t){const n=t.value?t.value+`
14
- `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function Ek(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ck(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Tk(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Nr(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,o=e.footnoteCounts.get(r);o===void 0?(o=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function Ik(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ak(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Op(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function zk(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Op(e,t);const i={src:Nr(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function Ok(e,t){const n={src:Nr(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Pk(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Dk(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Op(e,t);const i={href:Nr(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Rk(e,t){const n={href:Nr(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Mk(e,t,n){const r=e.all(t),i=n?$k(n):Pp(t),s={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const d=r[o];(i||o!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
15
- `}),d.type==="element"&&d.tagName==="p"&&!i?a.push(...d.children):a.push(d)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
16
- `});const c={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,c),e.applyData(t,c)}function $k(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Pp(n[r])}return t}function Pp(e){const t=e.spread;return t??e.children.length>1}function Fk(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function Lk(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Bk(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Zk(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Vk(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=zo(t.children[1]),l=pp(t.children[t.children.length-1]);o&&l&&(a.position={start:o,end:l}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Uk(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let l=-1;const c=[];for(;++l<o;){const f=t.children[l],h={},p=a?a[l]:void 0;p&&(h.align=p);let g={type:"element",tagName:s,properties:h,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),c.push(g)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,d),e.applyData(t,d)}function Jk(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const vu=9,wu=32;function Hk(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(ku(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(ku(t.slice(i),i>0,!1)),s.join("")}function ku(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===vu||s===wu;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===vu||s===wu;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Wk(e,t){const n={type:"text",value:Hk(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function qk(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Gk={blockquote:_k,break:jk,code:Nk,delete:Ek,emphasis:Ck,footnoteReference:Tk,heading:Ik,html:Ak,imageReference:zk,image:Ok,inlineCode:Pk,linkReference:Dk,link:Rk,listItem:Mk,list:Fk,paragraph:Lk,root:Bk,strong:Zk,table:Vk,tableCell:Jk,tableRow:Uk,text:Wk,thematicBreak:qk,toml:Ti,yaml:Ti,definition:Ti,footnoteDefinition:Ti};function Ti(){}const Dp=-1,Ds=0,Qr=1,as=2,Fo=3,Lo=4,Bo=5,Zo=6,Rp=7,Mp=8,Su=typeof self=="object"?self:globalThis,Yk=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case Ds:case Dp:return n(a,i);case Qr:{const o=n([],i);for(const l of a)o.push(r(l));return o}case as:{const o=n({},i);for(const[l,c]of a)o[r(l)]=r(c);return o}case Fo:return n(new Date(a),i);case Lo:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case Bo:{const o=n(new Map,i);for(const[l,c]of a)o.set(r(l),r(c));return o}case Zo:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case Rp:{const{name:o,message:l}=a;return n(new Su[o](l),i)}case Mp:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(new Su[s](a),i)};return r},_u=e=>Yk(new Map,e)(0),Wn="",{toString:Kk}={},{keys:Xk}=Object,Mr=e=>{const t=typeof e;if(t!=="object"||!e)return[Ds,t];const n=Kk.call(e).slice(8,-1);switch(n){case"Array":return[Qr,Wn];case"Object":return[as,Wn];case"Date":return[Fo,Wn];case"RegExp":return[Lo,Wn];case"Map":return[Bo,Wn];case"Set":return[Zo,Wn];case"DataView":return[Qr,n]}return n.includes("Array")?[Qr,n]:n.includes("Error")?[Rp,n]:[as,n]},Ii=([e,t])=>e===Ds&&(t==="function"||t==="symbol"),Qk=(e,t,n,r)=>{const i=(a,o)=>{const l=r.push(a)-1;return n.set(o,l),l},s=a=>{if(n.has(a))return n.get(a);let[o,l]=Mr(a);switch(o){case Ds:{let d=a;switch(l){case"bigint":o=Mp,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);d=null;break;case"undefined":return i([Dp],a)}return i([o,d],a)}case Qr:{if(l){let h=a;return l==="DataView"?h=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(h=new Uint8Array(a)),i([l,[...h]],a)}const d=[],f=i([o,d],a);for(const h of a)d.push(s(h));return f}case as:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const d=[],f=i([o,d],a);for(const h of Xk(a))(e||!Ii(Mr(a[h])))&&d.push([s(h),s(a[h])]);return f}case Fo:return i([o,a.toISOString()],a);case Lo:{const{source:d,flags:f}=a;return i([o,{source:d,flags:f}],a)}case Bo:{const d=[],f=i([o,d],a);for(const[h,p]of a)(e||!(Ii(Mr(h))||Ii(Mr(p))))&&d.push([s(h),s(p)]);return f}case Zo:{const d=[],f=i([o,d],a);for(const h of a)(e||!Ii(Mr(h)))&&d.push(s(h));return f}}const{message:c}=a;return i([o,{name:l,message:c}],a)};return s},ju=(e,{json:t,lossy:n}={})=>{const r=[];return Qk(!(t||n),!!t,new Map,r)(e),r},os=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?_u(ju(e,t)):structuredClone(e):(e,t)=>_u(ju(e,t));function e1(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function t1(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function n1(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||e1,r=e.options.footnoteBackLabel||t1,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const d=e.all(c),f=String(c.identifier).toUpperCase(),h=Nr(f.toLowerCase());let p=0;const g=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++p<=v;){g.length>0&&g.push({type:"text",value:" "});let E=typeof n=="string"?n:n(l,p);typeof E=="string"&&(E={type:"text",value:E}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+h+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(E)?E:[E]})}const _=d[d.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const E=_.children[_.children.length-1];E&&E.type==="text"?E.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...g)}else d.push(...g);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+h},children:e.wrap(d,!0)};e.patch(c,b),o.push(b)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...os(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
17
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
18
- `}]}}const Rs=function(e){if(e==null)return a1;if(typeof e=="function")return Ms(e);if(typeof e=="object")return Array.isArray(e)?r1(e):i1(e);if(typeof e=="string")return s1(e);throw new Error("Expected function, string, or object as test")};function r1(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Rs(e[n]);return Ms(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function i1(e){const t=e;return Ms(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function s1(e){return Ms(t);function t(n){return n&&n.type===e}}function Ms(e){return t;function t(n,r,i){return!!(o1(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function a1(){return!0}function o1(e){return e!==null&&typeof e=="object"&&"type"in e}const $p=[],l1=!0,Wa=!1,u1="skip";function Fp(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Rs(i),a=r?-1:1;o(e,void 0,[])();function o(l,c,d){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const p=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=$p,g,v,_;if((!t||s(l,c,d[d.length-1]||void 0))&&(p=c1(n(l,d)),p[0]===Wa))return p;if("children"in l&&l.children){const b=l;if(b.children&&p[0]!==u1)for(v=(r?b.children.length:-1)+a,_=d.concat(b);v>-1&&v<b.children.length;){const E=b.children[v];if(g=o(E,v,_)(),g[0]===Wa)return g;v=typeof g[1]=="number"?g[1]:v+a}}return p}}}function c1(e){return Array.isArray(e)?e:typeof e=="number"?[l1,e]:e==null?$p:[e]}function Vo(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),Fp(e,s,o,i);function o(l,c){const d=c[c.length-1],f=d?d.children.indexOf(l):void 0;return a(l,f,d)}}const qa={}.hasOwnProperty,d1={};function f1(e,t){const n=t||d1,r=new Map,i=new Map,s=new Map,a={...Gk,...n.handlers},o={all:c,applyData:h1,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:p1,wrap:g1};return Vo(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:i,h=String(d.identifier).toUpperCase();f.has(h)||f.set(h,d)}}),o;function l(d,f){const h=d.type,p=o.handlers[h];if(qa.call(o.handlers,h)&&p)return p(o,d,f);if(o.options.passThrough&&o.options.passThrough.includes(h)){if("children"in d){const{children:v,..._}=d,b=os(_);return b.children=o.all(d),b}return os(d)}return(o.options.unknownHandler||m1)(o,d,f)}function c(d){const f=[];if("children"in d){const h=d.children;let p=-1;for(;++p<h.length;){const g=o.one(h[p],d);if(g){if(p&&h[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Nu(g.value)),!Array.isArray(g)&&g.type==="element")){const v=g.children[0];v&&v.type==="text"&&(v.value=Nu(v.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function p1(e,t){e.position&&(t.position=tw(e))}function h1(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,os(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function m1(e,t){const n=t.data||{},r="value"in t&&!(qa.call(n,"hProperties")||qa.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function g1(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
19
- `});++r<e.length;)r&&n.push({type:"text",value:`
20
- `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
21
- `}),n}function Nu(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Eu(e,t){const n=f1(e,t),r=n.one(e,void 0),i=n1(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
22
- `},i),s}function x1(e,t){return e&&"run"in e?async function(n,r){const i=Eu(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Eu(n,{file:r,...e||t})}}function Cu(e){if(e)throw e}var aa,Tu;function y1(){if(Tu)return aa;Tu=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(c){return typeof Array.isArray=="function"?Array.isArray(c):t.call(c)==="[object Array]"},s=function(c){if(!c||t.call(c)!=="[object Object]")return!1;var d=e.call(c,"constructor"),f=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!d&&!f)return!1;var h;for(h in c);return typeof h>"u"||e.call(c,h)},a=function(c,d){n&&d.name==="__proto__"?n(c,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):c[d.name]=d.newValue},o=function(c,d){if(d==="__proto__")if(e.call(c,d)){if(r)return r(c,d).value}else return;return c[d]};return aa=function l(){var c,d,f,h,p,g,v=arguments[0],_=1,b=arguments.length,E=!1;for(typeof v=="boolean"&&(E=v,v=arguments[1]||{},_=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});_<b;++_)if(c=arguments[_],c!=null)for(d in c)f=o(v,d),h=o(c,d),v!==h&&(E&&h&&(s(h)||(p=i(h)))?(p?(p=!1,g=f&&i(f)?f:[]):g=f&&s(f)?f:{},a(v,{name:d,newValue:l(E,g,h)})):typeof h<"u"&&a(v,{name:d,newValue:h}));return v},aa}var b1=y1();const oa=uo(b1);function Ga(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function v1(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(l,...c){const d=e[++s];let f=-1;if(l){a(l);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,d?w1(d,o)(...c):a(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function w1(e,t){let n;return r;function r(...a){const o=e.length>a.length;let l;o&&a.push(i);try{l=e.apply(this,a)}catch(c){const d=c;if(o&&n)throw d;return i(d)}o||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const Wt={basename:k1,dirname:S1,extname:_1,join:j1,sep:"/"};function k1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');wi(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,o=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(r=i):(o=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function S1(e){if(wi(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function _1(e){wi(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),o===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function j1(...e){let t=-1,n;for(;++t<e.length;)wi(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":N1(n)}function N1(e){wi(e);const t=e.codePointAt(0)===47;let n=E1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function E1(e,t){let n="",r=0,i=-1,s=0,a=-1,o,l;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function wi(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const C1={cwd:T1};function T1(){return"/"}function Ya(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function I1(e){if(typeof e=="string")e=new URL(e);else if(!Ya(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return A1(e)}function A1(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const la=["history","path","basename","stem","extname","dirname"];class Lp{constructor(t){let n;t?Ya(t)?n={path:t}:typeof t=="string"||z1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":C1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<la.length;){const s=la[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)la.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Wt.basename(this.path):void 0}set basename(t){ca(t,"basename"),ua(t,"basename"),this.path=Wt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Wt.dirname(this.path):void 0}set dirname(t){Iu(this.basename,"dirname"),this.path=Wt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Wt.extname(this.path):void 0}set extname(t){if(ua(t,"extname"),Iu(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Wt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ya(t)&&(t=I1(t)),ca(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Wt.basename(this.path,this.extname):void 0}set stem(t){ca(t,"stem"),ua(t,"stem"),this.path=Wt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new lt(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function ua(e,t){if(e&&e.includes(Wt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Wt.sep+"`")}function ca(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Iu(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function z1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const O1=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},P1={}.hasOwnProperty;class Uo extends O1{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=v1()}copy(){const t=new Uo;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(oa(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(pa("data",this.frozen),this.namespace[t]=n,this):P1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(pa("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Ai(t),r=this.parser||this.Parser;return da("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),da("process",this.parser||this.Parser),fa("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=Ai(t),l=r.parse(o);r.run(l,o,function(d,f,h){if(d||!f||!h)return c(d);const p=f,g=r.stringify(p,h);M1(g)?h.value=g:h.result=g,c(d,h)});function c(d,f){d||!f?a(d):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),da("processSync",this.parser||this.Parser),fa("processSync",this.compiler||this.Compiler),this.process(t,i),zu("processSync","process",n),r;function i(s,a){n=!0,Cu(s),r=a}}run(t,n,r){Au(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,o){const l=Ai(n);i.run(t,l,c);function c(d,f,h){const p=f||t;d?o(d):a?a(p):r(void 0,p,h)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),zu("runSync","run",r),i;function s(a,o){Cu(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=Ai(n),i=this.compiler||this.Compiler;return fa("stringify",i),Au(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(pa("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[d,...f]=c;l(d,f)}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(c.plugins),c.settings&&(i.settings=oa(!0,i.settings,c.settings))}function o(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){const f=c[d];s(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let f=-1,h=-1;for(;++f<r.length;)if(r[f][0]===c){h=f;break}if(h===-1)r.push([c,...d]);else if(d.length>0){let[p,...g]=d;const v=r[h][1];Ga(v)&&Ga(p)&&(p=oa(!0,v,p)),r[h]=[c,p,...g]}}}}const D1=new Uo().freeze();function da(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function fa(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function pa(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Au(e){if(!Ga(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zu(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ai(e){return R1(e)?e:new Lp(e)}function R1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function M1(e){return typeof e=="string"||$1(e)}function $1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const F1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ou=[],Pu={allowDangerousHtml:!0},L1=/^(https?|ircs?|mailto|xmpp)$/i,B1=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Z1(e){const t=V1(e),n=U1(e);return J1(t.runSync(t.parse(n),n),e)}function V1(e){const t=e.rehypePlugins||Ou,n=e.remarkPlugins||Ou,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Pu}:Pu;return D1().use(Sk).use(n).use(x1,r).use(t)}function U1(e){const t=e.children||"",n=new Lp;return typeof t=="string"&&(n.value=t),n}function J1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||H1;for(const d of B1)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+F1+d.id,void 0);return Vo(e,c),aw(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(d,f,h){if(d.type==="raw"&&h&&typeof f=="number")return a?h.children.splice(f,1):h.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let p;for(p in ra)if(Object.hasOwn(ra,p)&&Object.hasOwn(d.properties,p)){const g=d.properties[p],v=ra[p];(v===null||v.includes(d.tagName))&&(d.properties[p]=l(String(g||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!p&&r&&typeof f=="number"&&(p=!r(d,f,h)),p&&h&&typeof f=="number")return o&&d.children?h.children.splice(f,1,...d.children):h.children.splice(f,1),f}}}function H1(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||L1.test(e.slice(0,t))?e:""}function Du(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function W1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function q1(e,t,n){const i=Rs((n||{}).ignore||[]),s=G1(t);let a=-1;for(;++a<s.length;)Fp(e,"text",o);function o(c,d){let f=-1,h;for(;++f<d.length;){const p=d[f],g=h?h.children:void 0;if(i(p,g?g.indexOf(p):void 0,h))return;h=p}if(h)return l(c,d)}function l(c,d){const f=d[d.length-1],h=s[a][0],p=s[a][1];let g=0;const _=f.children.indexOf(c);let b=!1,E=[];h.lastIndex=0;let m=h.exec(c.value);for(;m;){const O=m.index,N={index:m.index,input:m.input,stack:[...d,c]};let w=p(...m,N);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?h.lastIndex=O+1:(g!==O&&E.push({type:"text",value:c.value.slice(g,O)}),Array.isArray(w)?E.push(...w):w&&E.push(w),g=O+m[0].length,b=!0),!h.global)break;m=h.exec(c.value)}return b?(g<c.value.length&&E.push({type:"text",value:c.value.slice(g)}),f.children.splice(_,1,...E)):E=[c],_+E.length}}function G1(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([Y1(i[0]),K1(i[1])])}return t}function Y1(e){return typeof e=="string"?new RegExp(W1(e),"g"):e}function K1(e){return typeof e=="function"?e:function(){return e}}const ha="phrasing",ma=["autolink","link","image","label"];function X1(){return{transforms:[sS],enter:{literalAutolink:eS,literalAutolinkEmail:ga,literalAutolinkHttp:ga,literalAutolinkWww:ga},exit:{literalAutolink:iS,literalAutolinkEmail:rS,literalAutolinkHttp:tS,literalAutolinkWww:nS}}}function Q1(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ha,notInConstruct:ma},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ha,notInConstruct:ma},{character:":",before:"[ps]",after:"\\/",inConstruct:ha,notInConstruct:ma}]}}function eS(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ga(e){this.config.enter.autolinkProtocol.call(this,e)}function tS(e){this.config.exit.autolinkProtocol.call(this,e)}function nS(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function rS(e){this.config.exit.autolinkEmail.call(this,e)}function iS(e){this.exit(e)}function sS(e){q1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,aS],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),oS]],{ignore:["link","linkReference"]})}function aS(e,t,n,r,i){let s="";if(!Bp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!lS(n)))return!1;const a=uS(n+r);if(!a[0])return!1;const o={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function oS(e,t,n,r){return!Bp(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function lS(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function uS(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=Du(e,"(");let s=Du(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function Bp(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Rn(n)||Os(n))&&(!t||n!==47)}Zp.peek=yS;function cS(){this.buffer()}function dS(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function fS(){this.buffer()}function pS(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function hS(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function mS(e){this.exit(e)}function gS(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Zt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xS(e){this.exit(e)}function yS(){return"["}function Zp(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=i.move("]"),s}function bS(){return{enter:{gfmFootnoteCallString:cS,gfmFootnoteCall:dS,gfmFootnoteDefinitionLabelString:fS,gfmFootnoteDefinition:pS},exit:{gfmFootnoteCallString:hS,gfmFootnoteCall:mS,gfmFootnoteDefinitionLabelString:gS,gfmFootnoteDefinition:xS}}}function vS(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Zp},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const o=s.createTracker(a);let l=o.move("[^");const c=s.enter("footnoteDefinition"),d=s.enter("label");return l+=o.move(s.safe(s.associationId(r),{before:l,after:"]"})),d(),l+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),l+=o.move((t?`
23
- `:" ")+s.indentLines(s.containerFlow(r,o.current()),t?Vp:wS))),c(),l}}function wS(e,t,n){return t===0?e:Vp(e,t,n)}function Vp(e,t,n){return(n?"":" ")+e}const kS=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Up.peek=ES;function SS(){return{canContainEols:["delete"],enter:{strikethrough:jS},exit:{strikethrough:NS}}}function _S(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:kS}],handlers:{delete:Up}}}function jS(e){this.enter({type:"delete",children:[]},e)}function NS(e){this.exit(e)}function Up(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function ES(){return"~"}function CS(e){return e.length}function TS(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||CS,s=[],a=[],o=[],l=[];let c=0,d=-1;for(;++d<e.length;){const v=[],_=[];let b=-1;for(e[d].length>c&&(c=e[d].length);++b<e[d].length;){const E=IS(e[d][b]);if(n.alignDelimiters!==!1){const m=i(E);_[b]=m,(l[b]===void 0||m>l[b])&&(l[b]=m)}v.push(E)}a[d]=v,o[d]=_}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<c;)s[f]=Ru(r[f]);else{const v=Ru(r);for(;++f<c;)s[f]=v}f=-1;const h=[],p=[];for(;++f<c;){const v=s[f];let _="",b="";v===99?(_=":",b=":"):v===108?_=":":v===114&&(b=":");let E=n.alignDelimiters===!1?1:Math.max(1,l[f]-_.length-b.length);const m=_+"-".repeat(E)+b;n.alignDelimiters!==!1&&(E=_.length+E+b.length,E>l[f]&&(l[f]=E),p[f]=E),h[f]=m}a.splice(1,0,h),o.splice(1,0,p),d=-1;const g=[];for(;++d<a.length;){const v=a[d],_=o[d];f=-1;const b=[];for(;++f<c;){const E=v[f]||"";let m="",O="";if(n.alignDelimiters!==!1){const N=l[f]-(_[f]||0),w=s[f];w===114?m=" ".repeat(N):w===99?N%2?(m=" ".repeat(N/2+.5),O=" ".repeat(N/2-.5)):(m=" ".repeat(N/2),O=m):O=" ".repeat(N)}n.delimiterStart!==!1&&!f&&b.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&E==="")&&(n.delimiterStart!==!1||f)&&b.push(" "),n.alignDelimiters!==!1&&b.push(m),b.push(E),n.alignDelimiters!==!1&&b.push(O),n.padding!==!1&&b.push(" "),(n.delimiterEnd!==!1||f!==c-1)&&b.push("|")}g.push(n.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return g.join(`
24
- `)}function IS(e){return e==null?"":String(e)}function Ru(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function AS(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),zS);return i(),a}function zS(e,t,n){return">"+(n?"":" ")+e}function OS(e,t){return Mu(e,t.inConstruct,!0)&&!Mu(e,t.notInConstruct,!1)}function Mu(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function $u(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
25
- `&&OS(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
26
- `}function PS(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function DS(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function RS(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function MS(e,t,n,r){const i=RS(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(DS(e,n)){const f=n.enter("codeIndented"),h=n.indentLines(s,$S);return f(),h}const o=n.createTracker(r),l=i.repeat(Math.max(PS(s,i)+1,3)),c=n.enter("codeFenced");let d=o.move(l);if(e.lang){const f=n.enter(`codeFencedLang${a}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${a}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:`
27
- `,encode:["`"],...o.current()})),f()}return d+=o.move(`
28
- `),s&&(d+=o.move(s+`
29
- `)),d+=o.move(l),c(),d}function $S(e,t,n){return(n?"":" ")+e}function Jo(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function FS(e,t,n,r){const i=Jo(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
30
- `,...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),a(),c}function LS(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function li(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ls(e,t,n){const r=yr(e),i=yr(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Jp.peek=BS;function Jp(e,t,n,r){const i=LS(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),d=ls(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=li(c)+l.slice(1));const f=l.charCodeAt(l.length-1),h=ls(r.after.charCodeAt(0),f,i);h.inside&&(l=l.slice(0,-1)+li(f));const p=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+l+p}function BS(e,t,n){return n.options.emphasis||"*"}function ZS(e,t){let n=!1;return Vo(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Wa}),!!((!e.depth||e.depth<3)&&Ro(e)&&(t.options.setext||n))}function VS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(ZS(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),h=n.containerPhrasing(e,{...s.current(),before:`
31
- `,after:`
32
- `});return f(),d(),h+`
33
- `+(i===1?"=":"-").repeat(h.length-(Math.max(h.lastIndexOf("\r"),h.lastIndexOf(`
34
- `))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(a+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
35
- `,...s.current()});return/^[\t ]/.test(c)&&(c=li(c.charCodeAt(0))+c.slice(1)),c=c?a+" "+c:a,n.options.closeAtx&&(c+=" "+a),l(),o(),c}Hp.peek=US;function Hp(e){return e.value||""}function US(){return"<"}Wp.peek=JS;function Wp(e,t,n,r){const i=Jo(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),c+=l.move(")"),a(),c}function JS(){return"!"}qp.peek=HS;function qp(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=d,s(),i==="full"||!c||c!==f?l+=o.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function HS(){return"!"}Gp.peek=WS;function Gp(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],o=n.compilePattern(a);let l;if(a.atBreak)for(;l=o.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function WS(){return"`"}function Yp(e,t){const n=Ro(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Kp.peek=qS;function Kp(e,t,n,r){const i=Jo(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(Yp(e,n)){const d=n.stack;n.stack=[],o=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),o(),n.stack=d,f}o=n.enter("link"),l=n.enter("label");let c=a.move("[");return c+=a.move(n.containerPhrasing(e,{before:c,after:"](",...a.current()})),c+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=a.move(" "+i),c+=a.move(n.safe(e.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),o(),c}function qS(e,t,n){return Yp(e,n)?"<":"["}Xp.peek=GS;function Xp(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=d,s(),i==="full"||!c||c!==f?l+=o.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function GS(){return"["}function Ho(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function YS(e){const t=Ho(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function KS(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Qp(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function XS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?KS(n):Ho(n);const o=e.ordered?a==="."?")":".":YS(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Qp(n)===a&&d){let f=-1;for(;++f<e.children.length;){const h=e.children[f];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const c=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),c}function QS(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function e_(e,t,n,r){const i=QS(n);let s=n.bulletCurrent||Ho(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),d);return l(),c;function d(f,h,p){return h?(p?"":" ".repeat(a))+f:(p?s:s+" ".repeat(a-s.length))+f}}function t_(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const n_=Rs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function r_(e,t,n,r){return(e.children.some(function(a){return n_(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function i_(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}eh.peek=s_;function eh(e,t,n,r){const i=i_(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),d=ls(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=li(c)+l.slice(1));const f=l.charCodeAt(l.length-1),h=ls(r.after.charCodeAt(0),f,i);h.inside&&(l=l.slice(0,-1)+li(f));const p=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:d.outside},o+l+p}function s_(e,t,n){return n.options.strong||"*"}function a_(e,t,n,r){return n.safe(e.value,r)}function o_(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function l_(e,t,n){const r=(Qp(n)+(n.options.ruleSpaces?" ":"")).repeat(o_(n));return n.options.ruleSpaces?r.slice(0,-1):r}const th={blockquote:AS,break:$u,code:MS,definition:FS,emphasis:Jp,hardBreak:$u,heading:VS,html:Hp,image:Wp,imageReference:qp,inlineCode:Gp,link:Kp,linkReference:Xp,list:XS,listItem:e_,paragraph:t_,root:r_,strong:eh,text:a_,thematicBreak:l_};function u_(){return{enter:{table:c_,tableData:Fu,tableHeader:Fu,tableRow:f_},exit:{codeText:p_,table:d_,tableData:xa,tableHeader:xa,tableRow:xa}}}function c_(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function d_(e){this.exit(e),this.data.inTable=void 0}function f_(e){this.enter({type:"tableRow",children:[]},e)}function xa(e){this.exit(e)}function Fu(e){this.enter({type:"tableCell",children:[]},e)}function p_(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,h_));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function h_(e,t){return t==="|"?t:e}function m_(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
36
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:a,tableCell:l,tableRow:o}};function a(p,g,v,_){return c(d(p,v,_),p.align)}function o(p,g,v,_){const b=f(p,v,_),E=c([b]);return E.slice(0,E.indexOf(`
37
- `))}function l(p,g,v,_){const b=v.enter("tableCell"),E=v.enter("phrasing"),m=v.containerPhrasing(p,{..._,before:s,after:s});return E(),b(),m}function c(p,g){return TS(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function d(p,g,v){const _=p.children;let b=-1;const E=[],m=g.enter("table");for(;++b<_.length;)E[b]=f(_[b],g,v);return m(),E}function f(p,g,v){const _=p.children;let b=-1;const E=[],m=g.enter("tableRow");for(;++b<_.length;)E[b]=l(_[b],p,g,v);return m(),E}function h(p,g,v){let _=th.inlineCode(p,g,v);return v.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function g_(){return{exit:{taskListCheckValueChecked:Lu,taskListCheckValueUnchecked:Lu,paragraph:y_}}}function x_(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:b_}}}function Lu(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function y_(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function b_(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let l=th.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(d){return d+a}}function v_(){return[X1(),bS(),SS(),u_(),g_()]}function w_(e){return{extensions:[Q1(),vS(e),_S(),m_(e),x_()]}}const k_={tokenize:C_,partial:!0},nh={tokenize:T_,partial:!0},rh={tokenize:I_,partial:!0},ih={tokenize:A_,partial:!0},S_={tokenize:z_,partial:!0},sh={name:"wwwAutolink",tokenize:N_,previous:oh},ah={name:"protocolAutolink",tokenize:E_,previous:lh},ln={name:"emailAutolink",tokenize:j_,previous:uh},Qt={};function __(){return{text:Qt}}let Nn=48;for(;Nn<123;)Qt[Nn]=ln,Nn++,Nn===58?Nn=65:Nn===91&&(Nn=97);Qt[43]=ln;Qt[45]=ln;Qt[46]=ln;Qt[95]=ln;Qt[72]=[ln,ah];Qt[104]=[ln,ah];Qt[87]=[ln,sh];Qt[119]=[ln,sh];function j_(e,t,n){const r=this;let i,s;return a;function a(f){return!Ka(f)||!uh.call(r,r.previous)||Wo(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(f))}function o(f){return Ka(f)?(e.consume(f),o):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(S_,d,c)(f):f===45||f===95||ot(f)?(s=!0,e.consume(f),l):d(f)}function c(f){return e.consume(f),i=!0,l}function d(f){return s&&i&&pt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function N_(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!oh.call(r,r.previous)||Wo(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(k_,e.attempt(nh,e.attempt(rh,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function E_(e,t,n){const r=this;let i="",s=!1;return a;function a(f){return(f===72||f===104)&&lh.call(r,r.previous)&&!Wo(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),o):n(f)}function o(f){if(pt(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),o;if(f===58){const h=i.toLowerCase();if(h==="http"||h==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?c:(s=!0,l)):n(f)}function c(f){return f===null||ss(f)||Fe(f)||Rn(f)||Os(f)?n(f):e.attempt(nh,e.attempt(rh,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function C_(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function T_(e,t,n){let r,i,s;return a;function a(c){return c===46||c===95?e.check(ih,l,o)(c):c===null||Fe(c)||Rn(c)||c!==45&&Os(c)?l(c):(s=!0,e.consume(c),a)}function o(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),a}function l(c){return i||r||!s?n(c):t(c)}}function I_(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(ih,t,s)(a):a===null||Fe(a)||Rn(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function A_(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||Fe(o)||Rn(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Fe(o)||Rn(o)?t(o):r(o)}function s(o){return pt(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):pt(o)?(e.consume(o),a):n(o)}}function z_(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return ot(s)?n(s):t(s)}}function oh(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Fe(e)}function lh(e){return!pt(e)}function uh(e){return!(e===47||Ka(e))}function Ka(e){return e===43||e===45||e===46||e===95||ot(e)}function Wo(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const O_={tokenize:B_,partial:!0};function P_(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:$_,continuation:{tokenize:F_},exit:L_}},text:{91:{name:"gfmFootnoteCall",tokenize:M_},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:D_,resolveTo:R_}}}}function D_(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return n(l);const c=Zt(r.sliceSerialize({start:a.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function R_(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function M_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(f){if(s>999||f===93&&!a||f===null||f===91||Fe(f))return n(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteCallString");return i.includes(Zt(r.sliceSerialize(h)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Fe(f)||(a=!0),s++,e.consume(f),f===92?d:c}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function $_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(g)}function d(g){if(a>999||g===93&&!o||g===null||g===91||Fe(g))return n(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Zt(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return Fe(g)||(o=!0),a++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),a++,d):d(g)}function h(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),ze(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function F_(e,t,n){return e.check(vi,t,e.attempt(O_,t,n))}function L_(e){e.exit("gfmFootnoteDefinition")}function B_(e,t,n){const r=this;return ze(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function Z_(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let c=l;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[l][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},f={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},h=[["enter",d,o],["enter",a[c][1],o],["exit",a[c][1],o],["enter",f,o]],p=o.parser.constructs.insideSpan.null;p&&Tt(h,h.length,0,Ps(p,a.slice(c+1,l),o)),Tt(h,h.length,0,[["exit",f,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",d,o]]),Tt(a,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const c=this.previous,d=this.events;let f=0;return h;function h(g){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(g):(a.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const v=yr(c);if(g===126)return f>1?l(g):(a.consume(g),f++,p);if(f<2&&!n)return l(g);const _=a.exit("strikethroughSequenceTemporary"),b=yr(g);return _._open=!b||b===2&&!!v,_._close=!v||v===2&&!!b,o(g)}}}class V_{constructor(){this.map=[]}add(t,n,r){U_(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function U_(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function J_(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function H_(){return{flow:{null:{name:"table",tokenize:W_,resolveAll:q_}}}}function W_(e,t,n){const r=this;let i=0,s=0,a;return o;function o(j){let T=r.events.length-1;for(;T>-1;){const I=r.events[T][1].type;if(I==="lineEnding"||I==="linePrefix")T--;else break}const z=T>-1?r.events[T][1].type:null,P=z==="tableHead"||z==="tableRow"?w:l;return P===w&&r.parser.lazy[r.now().line]?n(j):P(j)}function l(j){return e.enter("tableHead"),e.enter("tableRow"),c(j)}function c(j){return j===124||(a=!0,s+=1),d(j)}function d(j){return j===null?n(j):ye(j)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),p):n(j):Ce(j)?ze(e,d,"whitespace")(j):(s+=1,a&&(a=!1,i+=1),j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),f(j)))}function f(j){return j===null||j===124||Fe(j)?(e.exit("data"),d(j)):(e.consume(j),j===92?h:f)}function h(j){return j===92||j===124?(e.consume(j),f):f(j)}function p(j){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(j):(e.enter("tableDelimiterRow"),a=!1,Ce(j)?ze(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):g(j))}function g(j){return j===45||j===58?_(j):j===124?(a=!0,e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),v):N(j)}function v(j){return Ce(j)?ze(e,_,"whitespace")(j):_(j)}function _(j){return j===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),b):j===45?(s+=1,b(j)):j===null||ye(j)?O(j):N(j)}function b(j){return j===45?(e.enter("tableDelimiterFiller"),E(j)):N(j)}function E(j){return j===45?(e.consume(j),E):j===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),m):(e.exit("tableDelimiterFiller"),m(j))}function m(j){return Ce(j)?ze(e,O,"whitespace")(j):O(j)}function O(j){return j===124?g(j):j===null||ye(j)?!a||i!==s?N(j):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(j)):N(j)}function N(j){return n(j)}function w(j){return e.enter("tableRow"),k(j)}function k(j){return j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),k):j===null||ye(j)?(e.exit("tableRow"),t(j)):Ce(j)?ze(e,k,"whitespace")(j):(e.enter("data"),R(j))}function R(j){return j===null||j===124||Fe(j)?(e.exit("data"),k(j)):(e.consume(j),j===92?q:R)}function q(j){return j===92||j===124?(e.consume(j),R):R(j)}}function q_(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,c,d,f;const h=new V_;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(o=!1,l!==0&&(Bu(h,t,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",d,t]])),i=g.type==="tableDelimiterRow"?2:d?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],f=zi(h,t,s,i,void 0,f),s=[0,0,0,0]),a[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],f=zi(h,t,s,i,void 0,f)),s=a,a=[s[1],n,0,0])):g.type==="tableHead"?(o=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],f=zi(h,t,s,i,n,f)):a[1]!==0&&(f=zi(h,t,a,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&Bu(h,t,l,c,d),h.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=J_(t.events,n))}return e}function zi(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Xn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Xn(t.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Xn(t.events,n[2]),d=Xn(t.events,n[3]),f={type:o,start:Object.assign({},c),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const h=t.events[n[2]],p=t.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,v=n[3]-n[2]-1;e.add(g,v,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(s.end=Object.assign({},Xn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Bu(e,t,n,r,i){const s=[],a=Xn(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Xn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const G_={name:"tasklistCheck",tokenize:K_};function Y_(){return{text:{91:G_}}}function K_(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Fe(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return ye(l)?t(l):Ce(l)?e.check({tokenize:X_},t,n)(l):n(l)}}function X_(e,t,n){return ze(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Q_(e){return vp([__(),P_(),Z_(e),H_(),Y_()])}const ej={};function tj(e){const t=this,n=e||ej,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Q_(n)),s.push(v_()),a.push(w_(n))}var ch="vercel.ai.error",nj=Symbol.for(ch),Zu,Vu,Xt=class dh extends(Vu=Error,Zu=nj,Vu){constructor({name:t,message:n,cause:r}){super(n),this[Zu]=!0,this.name=t,this.cause=r}static isInstance(t){return dh.hasMarker(t,ch)}static hasMarker(t,n){const r=Symbol.for(n);return t!=null&&typeof t=="object"&&r in t&&typeof t[r]=="boolean"&&t[r]===!0}};function fh(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var ph="AI_InvalidArgumentError",hh=`vercel.ai.error.${ph}`,rj=Symbol.for(hh),Uu,Ju,ij=class extends(Ju=Xt,Uu=rj,Ju){constructor({message:e,cause:t,argument:n}){super({name:ph,message:e,cause:t}),this[Uu]=!0,this.argument=n}static isInstance(e){return Xt.hasMarker(e,hh)}},mh="AI_JSONParseError",gh=`vercel.ai.error.${mh}`,sj=Symbol.for(gh),Hu,Wu,qu=class extends(Wu=Xt,Hu=sj,Wu){constructor({text:e,cause:t}){super({name:mh,message:`JSON parsing failed: Text: ${e}.
38
- Error message: ${fh(t)}`,cause:t}),this[Hu]=!0,this.text=e}static isInstance(e){return Xt.hasMarker(e,gh)}},xh="AI_TypeValidationError",yh=`vercel.ai.error.${xh}`,aj=Symbol.for(yh),Gu,Yu,br=class Xa extends(Yu=Xt,Gu=aj,Yu){constructor({value:t,cause:n,context:r}){let i="Type validation failed";if(r!=null&&r.field&&(i+=` for ${r.field}`),r!=null&&r.entityName||r!=null&&r.entityId){i+=" (";const s=[];r.entityName&&s.push(r.entityName),r.entityId&&s.push(`id: "${r.entityId}"`),i+=s.join(", "),i+=")"}super({name:xh,message:`${i}: Value: ${JSON.stringify(t)}.
39
- Error message: ${fh(n)}`,cause:n}),this[Gu]=!0,this.value=t,this.context=r}static isInstance(t){return Xt.hasMarker(t,yh)}static wrap({value:t,cause:n,context:r}){var i,s,a;return Xa.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===(r==null?void 0:r.field)&&((s=n.context)==null?void 0:s.entityName)===(r==null?void 0:r.entityName)&&((a=n.context)==null?void 0:a.entityId)===(r==null?void 0:r.entityId)?n:new Xa({value:t,cause:n,context:r})}};function H(e,t,n){function r(o,l){if(o._zod||Object.defineProperty(o,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),o._zod.traits.has(e))return;o._zod.traits.add(e),t(o,l);const c=a.prototype,d=Object.keys(c);for(let f=0;f<d.length;f++){const h=d[f];h in o||(o[h]=c[h].bind(o))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function a(o){var l;const c=n!=null&&n.Parent?new s:this;r(c,o),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:o=>{var l,c;return n!=null&&n.Parent&&o instanceof n.Parent?!0:(c=(l=o==null?void 0:o._zod)==null?void 0:l.traits)==null?void 0:c.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class dr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class bh extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const vh={};function vn(e){return vh}function wh(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Qa(e,t){return typeof t=="bigint"?t.toString():t}function $s(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function qo(e){return e==null}function Go(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function oj(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=n>i?n:i,a=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return a%o/10**s}const Ku=Symbol("evaluating");function Ae(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ku)return r===void 0&&(r=Ku,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Sn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Xu(e){return JSON.stringify(e)}function lj(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const kh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ui(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const uj=$s(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function vr(e){if(ui(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ui(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Sh(e){return vr(e)?{...e}:Array.isArray(e)?[...e]:e}const cj=new Set(["string","number","symbol"]);function wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _n(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function fe(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function dj(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const fj={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pj(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Sn(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return Fn(this,"shape",a),a},checks:[]});return _n(e,s)}function hj(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Sn(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return Fn(this,"shape",a),a},checks:[]});return _n(e,s)}function mj(e,t){if(!vr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Sn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Fn(this,"shape",s),s}});return _n(e,i)}function gj(e,t){if(!vr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Fn(this,"shape",r),r}});return _n(e,n)}function xj(e,t){const n=Sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Fn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return _n(e,n)}function yj(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=Sn(t._zod.def,{get shape(){const o=t._zod.def.shape,l={...o};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:o[c]}):o[c])}else for(const c in o)l[c]=e?new e({type:"optional",innerType:o[c]}):o[c];return Fn(this,"shape",l),l},checks:[]});return _n(t,a)}function bj(e,t,n){const r=Sn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const a in n){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(const a in i)s[a]=new e({type:"nonoptional",innerType:i[a]});return Fn(this,"shape",s),s}});return _n(t,r)}function nr(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function rr(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Oi(e){return typeof e=="string"?e:e==null?void 0:e.message}function wn(e,t,n){var i,s,a,o,l,c;const r={...e,path:e.path??[]};if(!e.message){const d=Oi((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??Oi((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??Oi((l=n.customError)==null?void 0:l.call(n,e))??Oi((c=n.localeError)==null?void 0:c.call(n,e))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Yo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ci(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const _h=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Qa,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},jh=H("$ZodError",_h),Nh=H("$ZodError",_h,{Parent:Error});function vj(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function wj(e,t=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let a=n,o=0;for(;o<s.path.length;){const l=s.path[o];o===s.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(s))):a[l]=a[l]||{_errors:[]},a=a[l],o++}}};return r(e),n}const Ko=e=>(t,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new dr;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>wn(l,s,vn())));throw kh(o,i==null?void 0:i.callee),o}return a.value},Xo=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>wn(l,s,vn())));throw kh(o,i==null?void 0:i.callee),o}return a.value},Fs=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new dr;return s.issues.length?{success:!1,error:new(e??jh)(s.issues.map(a=>wn(a,i,vn())))}:{success:!0,data:s.value}},kj=Fs(Nh),Ls=e=>async(t,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>wn(a,i,vn())))}:{success:!0,data:s.value}},Sj=Ls(Nh),_j=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ko(e)(t,n,i)},jj=e=>(t,n,r)=>Ko(e)(t,n,r),Nj=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xo(e)(t,n,i)},Ej=e=>async(t,n,r)=>Xo(e)(t,n,r),Cj=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Fs(e)(t,n,i)},Tj=e=>(t,n,r)=>Fs(e)(t,n,r),Ij=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ls(e)(t,n,i)},Aj=e=>async(t,n,r)=>Ls(e)(t,n,r),zj=/^[cC][^\s-]{8,}$/,Oj=/^[0-9a-z]+$/,Pj=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Dj=/^[0-9a-vA-V]{20}$/,Rj=/^[A-Za-z0-9]{27}$/,Mj=/^[a-zA-Z0-9_-]{21}$/,$j=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fj=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Qu=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Lj=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Bj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Zj(){return new RegExp(Bj,"u")}const Vj=/^(?:(?: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])$/,Uj=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Jj=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Hj=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wj=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Eh=/^[A-Za-z0-9_-]*$/,qj=/^\+[1-9]\d{6,14}$/,Ch="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Gj=new RegExp(`^${Ch}$`);function Th(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Yj(e){return new RegExp(`^${Th(e)}$`)}function Kj(e){const t=Th({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Ch}T(?:${r})$`)}const Xj=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Qj=/^-?\d+$/,Ih=/^-?\d+(?:\.\d+)?$/,eN=/^(?:true|false)$/i,tN=/^null$/i,nN=/^[^A-Z]*$/,rN=/^[^a-z]*$/,_t=H("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ah={number:"number",bigint:"bigint",object:"date"},zh=H("$ZodCheckLessThan",(e,t)=>{_t.init(e,t);const n=Ah[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Oh=H("$ZodCheckGreaterThan",(e,t)=>{_t.init(e,t);const n=Ah[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),iN=H("$ZodCheckMultipleOf",(e,t)=>{_t.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):oj(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),sN=H("$ZodCheckNumberFormat",(e,t)=>{var a;_t.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[i,s]=fj[t.format];e._zod.onattach.push(o=>{const l=o._zod.bag;l.format=t.format,l.minimum=i,l.maximum=s,n&&(l.pattern=Qj)}),e._zod.check=o=>{const l=o.value;if(n){if(!Number.isInteger(l)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?o.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<i&&o.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&o.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),aN=H("$ZodCheckMaxLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!qo(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const a=Yo(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),oN=H("$ZodCheckMinLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!qo(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const a=Yo(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),lN=H("$ZodCheckLengthEquals",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!qo(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const a=Yo(i),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Bs=H("$ZodCheckStringFormat",(e,t)=>{var n,r;_t.init(e,t),e._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),uN=H("$ZodCheckRegex",(e,t)=>{Bs.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),cN=H("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=nN),Bs.init(e,t)}),dN=H("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rN),Bs.init(e,t)}),fN=H("$ZodCheckIncludes",(e,t)=>{_t.init(e,t);const n=wr(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),pN=H("$ZodCheckStartsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`^${wr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),hN=H("$ZodCheckEndsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`.*${wr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),mN=H("$ZodCheckOverwrite",(e,t)=>{_t.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class gN{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
40
- `).filter(a=>a),i=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(i)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,i.join(`
41
- `))}}const xN={major:4,minor:3,patch:6},Je=H("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=xN;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const s=(o,l,c)=>{let d=nr(o),f;for(const h of l){if(h._zod.def.when){if(!h._zod.def.when(o))continue}else if(d)continue;const p=o.issues.length,g=h._zod.check(o);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new dr;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,o.issues.length!==p&&(d||(d=nr(o,p)))});else{if(o.issues.length===p)continue;d||(d=nr(o,p))}}return f?f.then(()=>o):o},a=(o,l,c)=>{if(nr(o))return o.aborted=!0,o;const d=s(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new dr;return d.then(f=>e._zod.parse(f,c))}return e._zod.parse(d,c)};e._zod.run=(o,l)=>{if(l.skipChecks)return e._zod.parse(o,l);if(l.direction==="backward"){const d=e._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>a(f,o,l)):a(d,o,l)}const c=e._zod.parse(o,l);if(c instanceof Promise){if(l.async===!1)throw new dr;return c.then(d=>s(d,r,l))}return s(c,r,l)}}Ae(e,"~standard",()=>({validate:s=>{var a;try{const o=kj(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return Sj(e,s).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Qo=H("$ZodString",(e,t)=>{var n;Je.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Xj(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),We=H("$ZodStringFormat",(e,t)=>{Bs.init(e,t),Qo.init(e,t)}),yN=H("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fj),We.init(e,t)}),bN=H("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Qu(r))}else t.pattern??(t.pattern=Qu());We.init(e,t)}),vN=H("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Lj),We.init(e,t)}),wN=H("$ZodURL",(e,t)=>{We.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),kN=H("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Zj()),We.init(e,t)}),SN=H("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Mj),We.init(e,t)}),_N=H("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=zj),We.init(e,t)}),jN=H("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Oj),We.init(e,t)}),NN=H("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Pj),We.init(e,t)}),EN=H("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Dj),We.init(e,t)}),CN=H("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Rj),We.init(e,t)}),TN=H("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Kj(t)),We.init(e,t)}),IN=H("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Gj),We.init(e,t)}),AN=H("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Yj(t)),We.init(e,t)}),zN=H("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=$j),We.init(e,t)}),ON=H("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Vj),We.init(e,t),e._zod.bag.format="ipv4"}),PN=H("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Uj),We.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),DN=H("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Jj),We.init(e,t)}),RN=H("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Hj),We.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ph(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const MN=H("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Wj),We.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ph(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function $N(e){if(!Eh.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ph(n)}const FN=H("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Eh),We.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{$N(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),LN=H("$ZodE164",(e,t)=>{t.pattern??(t.pattern=qj),We.init(e,t)});function BN(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const ZN=H("$ZodJWT",(e,t)=>{We.init(e,t),e._zod.check=n=>{BN(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Dh=H("$ZodNumber",(e,t)=>{Je.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ih,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),VN=H("$ZodNumberFormat",(e,t)=>{sN.init(e,t),Dh.init(e,t)}),UN=H("$ZodBoolean",(e,t)=>{Je.init(e,t),e._zod.pattern=eN,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),JN=H("$ZodNull",(e,t)=>{Je.init(e,t),e._zod.pattern=tN,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),HN=H("$ZodUnknown",(e,t)=>{Je.init(e,t),e._zod.parse=n=>n}),WN=H("$ZodNever",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ec(e,t,n){e.issues.length&&t.issues.push(...rr(n,e.issues)),t.value[n]=e.value}const qN=H("$ZodArray",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let a=0;a<i.length;a++){const o=i[a],l=t.element._zod.run({value:o,issues:[]},r);l instanceof Promise?s.push(l.then(c=>ec(c,n,a))):ec(l,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function us(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...rr(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Rh(e){var r,i,s,a;const t=Object.keys(e.shape);for(const o of t)if(!((a=(s=(i=(r=e.shape)==null?void 0:r[o])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&a.has("$ZodType")))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=dj(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Mh(e,t,n,r,i,s){const a=[],o=i.keySet,l=i.catchall._zod,c=l.def.type,d=l.optout==="optional";for(const f in t){if(o.has(f))continue;if(c==="never"){a.push(f);continue}const h=l.run({value:t[f],issues:[]},r);h instanceof Promise?e.push(h.then(p=>us(p,n,f,t,d))):us(h,n,f,t,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const GN=H("$ZodObject",(e,t)=>{Je.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const o=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...o};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=$s(()=>Rh(t));Ae(e._zod,"propValues",()=>{const o=t.shape,l={};for(const c in o){const d=o[c]._zod;if(d.values){l[c]??(l[c]=new Set);for(const f of d.values)l[c].add(f)}}return l});const i=ui,s=t.catchall;let a;e._zod.parse=(o,l)=>{a??(a=r.value);const c=o.value;if(!i(c))return o.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),o;o.value={};const d=[],f=a.shape;for(const h of a.keys){const p=f[h],g=p._zod.optout==="optional",v=p._zod.run({value:c[h],issues:[]},l);v instanceof Promise?d.push(v.then(_=>us(_,o,h,c,g))):us(v,o,h,c,g)}return s?Mh(d,c,o,l,r.value,e):d.length?Promise.all(d).then(()=>o):o}}),YN=H("$ZodObjectJIT",(e,t)=>{GN.init(e,t);const n=e._zod.parse,r=$s(()=>Rh(t)),i=h=>{var m;const p=new gN(["shape","payload","ctx"]),g=r.value,v=O=>{const N=Xu(O);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};p.write("const input = payload.value;");const _=Object.create(null);let b=0;for(const O of g.keys)_[O]=`key_${b++}`;p.write("const newResult = {};");for(const O of g.keys){const N=_[O],w=Xu(O),k=h[O],R=((m=k==null?void 0:k._zod)==null?void 0:m.optout)==="optional";p.write(`const ${N} = ${v(O)};`),R?p.write(`
42
- if (${N}.issues.length) {
43
- if (${w} in input) {
44
- payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
45
- ...iss,
46
- path: iss.path ? [${w}, ...iss.path] : [${w}]
47
- })));
48
- }
49
- }
50
-
51
- if (${N}.value === undefined) {
52
- if (${w} in input) {
53
- newResult[${w}] = undefined;
54
- }
55
- } else {
56
- newResult[${w}] = ${N}.value;
57
- }
58
-
59
- `):p.write(`
60
- if (${N}.issues.length) {
61
- payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
62
- ...iss,
63
- path: iss.path ? [${w}, ...iss.path] : [${w}]
64
- })));
65
- }
66
-
67
- if (${N}.value === undefined) {
68
- if (${w} in input) {
69
- newResult[${w}] = undefined;
70
- }
71
- } else {
72
- newResult[${w}] = ${N}.value;
73
- }
74
-
75
- `)}p.write("payload.value = newResult;"),p.write("return payload;");const E=p.compile();return(O,N)=>E(h,O,N)};let s;const a=ui,o=!vh.jitless,c=o&&uj.value,d=t.catchall;let f;e._zod.parse=(h,p)=>{f??(f=r.value);const g=h.value;return a(g)?o&&c&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(s||(s=i(t.shape)),h=s(h,p),d?Mh([],g,h,p,f,e):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),h)}});function tc(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const i=e.filter(s=>!nr(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(a=>wn(a,r,vn())))}),t)}const $h=H("$ZodUnion",(e,t)=>{Je.init(e,t),Ae(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ae(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ae(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ae(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>Go(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(n)return r(i,s);let a=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:i.value,issues:[]},s);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(l=>tc(l,i,e,s)):tc(o,i,e,s)}}),KN=H("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$h.init(e,t);const n=e._zod.parse;Ae(e._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[o,l]of Object.entries(a)){i[o]||(i[o]=new Set);for(const c of l)i[o].add(c)}}return i});const r=$s(()=>{var a;const i=t.options,s=new Map;for(const o of i){const l=(a=o._zod.propValues)==null?void 0:a[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const c of l){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});e._zod.parse=(i,s)=>{const a=i.value;if(!ui(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const o=r.value.get(a==null?void 0:a[t.discriminator]);return o?o._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),XN=H("$ZodIntersection",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([l,c])=>nc(n,l,c)):nc(n,s,a)}});function eo(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(vr(e)&&vr(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),i={...e,...t};for(const s of r){const a=eo(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],s=t[r],a=eo(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function nc(e,t,n){const r=new Map;let i;for(const o of t.issues)if(o.code==="unrecognized_keys"){i??(i=o);for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(o);for(const o of n.issues)if(o.code==="unrecognized_keys")for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(o);const s=[...r].filter(([,o])=>o.l&&o.r).map(([o])=>o);if(s.length&&i&&e.issues.push({...i,keys:s}),nr(e))return e;const a=eo(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const QN=H("$ZodRecord",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!vr(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],a=t.keyType._zod.values;if(a){n.value={};const o=new Set;for(const c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){o.add(typeof c=="number"?c.toString():c);const d=t.valueType._zod.run({value:i[c],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...rr(c,f.issues)),n.value[c]=f.value})):(d.issues.length&&n.issues.push(...rr(c,d.issues)),n.value[c]=d.value)}let l;for(const c in i)o.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;let l=t.keyType._zod.run({value:o,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof o=="string"&&Ih.test(o)&&l.issues.length){const f=t.keyType._zod.run({value:Number(o),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>wn(f,r,vn())),input:o,path:[o],inst:e});continue}const d=t.valueType._zod.run({value:i[o],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...rr(o,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...rr(o,d.issues)),n.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),eE=H("$ZodEnum",(e,t)=>{Je.init(e,t);const n=wh(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>cj.has(typeof i)).map(i=>typeof i=="string"?wr(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}}),tE=H("$ZodLiteral",(e,t)=>{if(Je.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?wr(r):r?wr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),nE=H("$ZodTransform",(e,t)=>{Je.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new bh(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(n.value=a,n));if(i instanceof Promise)throw new dr;return n.value=i,n}});function rc(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Fh=H("$ZodOptional",(e,t)=>{Je.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ae(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ae(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Go(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>rc(s,n.value)):rc(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),rE=H("$ZodExactOptional",(e,t)=>{Fh.init(e,t),Ae(e._zod,"values",()=>t.innerType._zod.values),Ae(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),iE=H("$ZodNullable",(e,t)=>{Je.init(e,t),Ae(e._zod,"optin",()=>t.innerType._zod.optin),Ae(e._zod,"optout",()=>t.innerType._zod.optout),Ae(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Go(n.source)}|null)$`):void 0}),Ae(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),sE=H("$ZodDefault",(e,t)=>{Je.init(e,t),e._zod.optin="optional",Ae(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>ic(s,t)):ic(i,t)}});function ic(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const aE=H("$ZodPrefault",(e,t)=>{Je.init(e,t),e._zod.optin="optional",Ae(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),oE=H("$ZodNonOptional",(e,t)=>{Je.init(e,t),Ae(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>sc(s,e)):sc(i,e)}});function sc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const lE=H("$ZodCatch",(e,t)=>{Je.init(e,t),Ae(e._zod,"optin",()=>t.innerType._zod.optin),Ae(e._zod,"optout",()=>t.innerType._zod.optout),Ae(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(a=>wn(a,r,vn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>wn(s,r,vn()))},input:n.value}),n.issues=[]),n)}}),uE=H("$ZodPipe",(e,t)=>{Je.init(e,t),Ae(e._zod,"values",()=>t.in._zod.values),Ae(e._zod,"optin",()=>t.in._zod.optin),Ae(e._zod,"optout",()=>t.out._zod.optout),Ae(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>Pi(a,t.in,r)):Pi(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Pi(s,t.out,r)):Pi(i,t.out,r)}});function Pi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const cE=H("$ZodReadonly",(e,t)=>{Je.init(e,t),Ae(e._zod,"propValues",()=>t.innerType._zod.propValues),Ae(e._zod,"values",()=>t.innerType._zod.values),Ae(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Ae(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(ac):ac(i)}});function ac(e){return e.value=Object.freeze(e.value),e}const dE=H("$ZodLazy",(e,t)=>{Je.init(e,t),Ae(e._zod,"innerType",()=>t.getter()),Ae(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),Ae(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),Ae(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),Ae(e._zod,"optout",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optout)??void 0}),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),fE=H("$ZodCustom",(e,t)=>{_t.init(e,t),Je.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>oc(s,n,r,e));oc(i,n,r,e)}});function oc(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(ci(i))}}var lc;class pE{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function hE(){return new pE}(lc=globalThis).__zod_globalRegistry??(lc.__zod_globalRegistry=hE());const Vr=globalThis.__zod_globalRegistry;function mE(e,t){return new e({type:"string",...fe(t)})}function gE(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...fe(t)})}function uc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...fe(t)})}function xE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...fe(t)})}function yE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...fe(t)})}function bE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...fe(t)})}function vE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...fe(t)})}function wE(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...fe(t)})}function kE(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...fe(t)})}function SE(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...fe(t)})}function _E(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...fe(t)})}function jE(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...fe(t)})}function NE(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...fe(t)})}function EE(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...fe(t)})}function CE(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...fe(t)})}function TE(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...fe(t)})}function IE(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...fe(t)})}function AE(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...fe(t)})}function zE(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...fe(t)})}function OE(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...fe(t)})}function PE(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...fe(t)})}function DE(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...fe(t)})}function RE(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...fe(t)})}function ME(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...fe(t)})}function $E(e,t){return new e({type:"string",format:"date",check:"string_format",...fe(t)})}function FE(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...fe(t)})}function LE(e,t){return new e({type:"string",format:"duration",check:"string_format",...fe(t)})}function BE(e,t){return new e({type:"number",checks:[],...fe(t)})}function ZE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...fe(t)})}function VE(e,t){return new e({type:"boolean",...fe(t)})}function UE(e,t){return new e({type:"null",...fe(t)})}function JE(e){return new e({type:"unknown"})}function HE(e,t){return new e({type:"never",...fe(t)})}function cc(e,t){return new zh({check:"less_than",...fe(t),value:e,inclusive:!1})}function ya(e,t){return new zh({check:"less_than",...fe(t),value:e,inclusive:!0})}function dc(e,t){return new Oh({check:"greater_than",...fe(t),value:e,inclusive:!1})}function ba(e,t){return new Oh({check:"greater_than",...fe(t),value:e,inclusive:!0})}function fc(e,t){return new iN({check:"multiple_of",...fe(t),value:e})}function Lh(e,t){return new aN({check:"max_length",...fe(t),maximum:e})}function cs(e,t){return new oN({check:"min_length",...fe(t),minimum:e})}function Bh(e,t){return new lN({check:"length_equals",...fe(t),length:e})}function WE(e,t){return new uN({check:"string_format",format:"regex",...fe(t),pattern:e})}function qE(e){return new cN({check:"string_format",format:"lowercase",...fe(e)})}function GE(e){return new dN({check:"string_format",format:"uppercase",...fe(e)})}function YE(e,t){return new fN({check:"string_format",format:"includes",...fe(t),includes:e})}function KE(e,t){return new pN({check:"string_format",format:"starts_with",...fe(t),prefix:e})}function XE(e,t){return new hN({check:"string_format",format:"ends_with",...fe(t),suffix:e})}function Er(e){return new mN({check:"overwrite",tx:e})}function QE(e){return Er(t=>t.normalize(e))}function eC(){return Er(e=>e.trim())}function tC(){return Er(e=>e.toLowerCase())}function nC(){return Er(e=>e.toUpperCase())}function rC(){return Er(e=>lj(e))}function iC(e,t,n){return new e({type:"array",element:t,...fe(n)})}function sC(e,t,n){const r=fe(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function aC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...fe(n)})}function oC(e){const t=lC(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(ci(r,n.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(ci(i))}},e(n.value,n)));return t}function lC(e,t){const n=new _t({check:"custom",...fe(t)});return n._zod.check=e,n}function ds(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Vr,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Ze(e,t,n={path:[],schemaPath:[]}){var d,f;var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const o=(f=(d=e._zod).toJSONSchema)==null?void 0:f.call(d);if(o)a.schema=o;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,h);else{const g=a.schema,v=t.processors[i.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);v(e,t,g,h)}const p=e._zod.parent;p&&(a.ref||(a.ref=p),Ze(p,t,h),t.seen.get(p).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&ct(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function fs(e,t){var a,o,l,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of e.seen.entries()){const f=(a=e.metadataRegistry.get(d[0]))==null?void 0:a.id;if(f){const h=r.get(f);if(h&&h!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var v;const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const _=(v=e.external.registry.get(d[0]))==null?void 0:v.id,b=e.external.uri??(m=>m);if(_)return{ref:b(_)};const E=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=E,{defId:E,ref:`${b("__shared")}#/${f}/${E}`}}if(d[1]===n)return{ref:"#"};const p=`#/${f}/`,g=d[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:p+g}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:h,defId:p}=i(d);f.def={...f.schema},p&&(f.defId=p);const g=f.schema;for(const v in g)delete g[v];g.$ref=h};if(e.cycles==="throw")for(const d of e.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(o=f.cycle)==null?void 0:o.join("/")}/<root>
76
-
77
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const f=d[1];if(t===d[0]){s(d);continue}if(e.external){const p=(l=e.external.registry.get(d[0]))==null?void 0:l.id;if(t!==d[0]&&p){s(d);continue}}if((c=e.metadataRegistry.get(d[0]))==null?void 0:c.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&e.reused==="ref"){s(d);continue}}}function ps(e,t){var a,o,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const d=e.seen.get(c);if(d.ref===null)return;const f=d.def??d.schema,h={...f},p=d.ref;if(d.ref=null,p){r(p);const v=e.seen.get(p),_=v.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(_)):Object.assign(f,_),Object.assign(f,h),c._zod.parent===p)for(const E in f)E==="$ref"||E==="allOf"||E in h||delete f[E];if(_.$ref&&v.def)for(const E in f)E==="$ref"||E==="allOf"||E in v.def&&JSON.stringify(f[E])===JSON.stringify(v.def[E])&&delete f[E]}const g=c._zod.parent;if(g&&g!==p){r(g);const v=e.seen.get(g);if(v!=null&&v.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const _ in f)_==="$ref"||_==="allOf"||_ in v.def&&JSON.stringify(f[_])===JSON.stringify(v.def[_])&&delete f[_]}e.override({zodSchema:c,jsonSchema:f,path:d.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const c=(o=e.external.registry.get(t))==null?void 0:o.id;if(!c)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(c)}Object.assign(i,n.def??n.schema);const s=((l=e.external)==null?void 0:l.defs)??{};for(const c of e.seen.entries()){const d=c[1];d.def&&d.defId&&(s[d.defId]=d.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const c=JSON.parse(JSON.stringify(i));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:hs(t,"input",e.processors),output:hs(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function ct(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ct(r.element,n);if(r.type==="set")return ct(r.valueType,n);if(r.type==="lazy")return ct(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ct(r.innerType,n);if(r.type==="intersection")return ct(r.left,n)||ct(r.right,n);if(r.type==="record"||r.type==="map")return ct(r.keyType,n)||ct(r.valueType,n);if(r.type==="pipe")return ct(r.in,n)||ct(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ct(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ct(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ct(i,n))return!0;return!!(r.rest&&ct(r.rest,n))}return!1}const uC=(e,t={})=>n=>{const r=ds({...n,processors:t});return Ze(e,r),fs(r,e),ps(r,e)},hs=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=ds({...i??{},target:s,io:t,processors:n});return Ze(e,a),fs(a,e),ps(a,e)},cC={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Zh=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:a,format:o,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),o&&(i.format=cC[o]??o,i.format===""&&delete i.format,o==="time"&&delete i.format),c&&(i.contentEncoding=c),l&&l.size>0){const d=[...l];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Vh=(e,t,n,r)=>{const i=n,{minimum:s,maximum:a,format:o,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=e._zod.bag;typeof o=="string"&&o.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&t.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c),typeof a=="number"&&(i.maximum=a,typeof c=="number"&&t.target!=="draft-04"&&(c<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},Uh=(e,t,n,r)=>{n.type="boolean"},dC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},fC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Jh=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},pC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},hC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Hh=(e,t,n,r)=>{n.not={}},mC=(e,t,n,r)=>{},Wh=(e,t,n,r)=>{},gC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},qh=(e,t,n,r)=>{const i=e._zod.def,s=wh(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},Gh=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},xC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},yC=(e,t,n,r)=>{const i=n,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=s.source},bC=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:l}=e._zod.bag;a!==void 0&&(s.minLength=a),o!==void 0&&(s.maxLength=o),l?l.length===1?(s.contentMediaType=l[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(i,s)},vC=(e,t,n,r)=>{n.type="boolean"},Yh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Kh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},kC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},SC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Xh=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:a,maximum:o}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof o=="number"&&(i.maxItems=o),i.type="array",i.items=Ze(s.element,t,{...r,path:[...r.path,"items"]})},Qh=(e,t,n,r)=>{var c;const i=n,s=e._zod.def;i.type="object",i.properties={};const a=s.shape;for(const d in a)i.properties[d]=Ze(a[d],t,{...r,path:[...r.path,"properties",d]});const o=new Set(Object.keys(a)),l=new Set([...o].filter(d=>{const f=s.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((c=s.catchall)==null?void 0:c._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Ze(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},em=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,l)=>Ze(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},tm=(e,t,n,r)=>{const i=e._zod.def,s=Ze(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Ze(i.right,t,{...r,path:[...r.path,"allOf",1]}),o=c=>"allOf"in c&&Object.keys(c).length===1,l=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=l},_C=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((h,p)=>Ze(h,t,{...r,path:[...r.path,a,p]})),c=s.rest?Ze(s.rest,t,{...r,path:[...r.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=l,c&&(i.items=c)):t.target==="openapi-3.0"?(i.items={anyOf:l},c&&i.items.anyOf.push(c),i.minItems=l.length,c||(i.maxItems=l.length)):(i.items=l,c&&(i.additionalItems=c));const{minimum:d,maximum:f}=e._zod.bag;typeof d=="number"&&(i.minItems=d),typeof f=="number"&&(i.maxItems=f)},nm=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const a=s.keyType,o=a._zod.bag,l=o==null?void 0:o.patterns;if(s.mode==="loose"&&l&&l.size>0){const d=Ze(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of l)i.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ze(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Ze(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=a._zod.values;if(c){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},rm=(e,t,n,r)=>{const i=e._zod.def,s=Ze(i.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},im=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},sm=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},am=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},om=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},lm=(e,t,n,r)=>{const i=e._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ze(s,t,r);const a=t.seen.get(e);a.ref=s},um=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},jC=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},el=(e,t,n,r)=>{const i=e._zod.def;Ze(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},cm=(e,t,n,r)=>{const i=e._zod.innerType;Ze(i,t,r);const s=t.seen.get(e);s.ref=i},pc={string:Zh,number:Vh,boolean:Uh,bigint:dC,symbol:fC,null:Jh,undefined:pC,void:hC,never:Hh,any:mC,unknown:Wh,date:gC,enum:qh,literal:Gh,nan:xC,template_literal:yC,file:bC,success:vC,custom:Yh,function:wC,transform:Kh,map:kC,set:SC,array:Xh,object:Qh,union:em,intersection:tm,tuple:_C,record:nm,nullable:rm,nonoptional:im,default:sm,prefault:am,catch:om,pipe:lm,readonly:um,promise:jC,optional:el,lazy:cm};function NC(e,t){if("_idmap"in e){const r=e,i=ds({...t,processors:pc}),s={};for(const l of r._idmap.entries()){const[c,d]=l;Ze(d,i)}const a={},o={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=o;for(const l of r._idmap.entries()){const[c,d]=l;fs(i,d),a[c]=ps(i,d)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:s}}return{schemas:a}}const n=ds({...t,processors:pc});return Ze(e,n),fs(n,e),ps(n,e)}const EC=H("ZodISODateTime",(e,t)=>{TN.init(e,t),qe.init(e,t)});function CC(e){return ME(EC,e)}const TC=H("ZodISODate",(e,t)=>{IN.init(e,t),qe.init(e,t)});function IC(e){return $E(TC,e)}const AC=H("ZodISOTime",(e,t)=>{AN.init(e,t),qe.init(e,t)});function zC(e){return FE(AC,e)}const OC=H("ZodISODuration",(e,t)=>{zN.init(e,t),qe.init(e,t)});function PC(e){return LE(OC,e)}const DC=(e,t)=>{jh.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>wj(e,n)},flatten:{value:n=>vj(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Qa,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Qa,2)}},isEmpty:{get(){return e.issues.length===0}}})},Pt=H("ZodError",DC,{Parent:Error}),RC=Ko(Pt),MC=Xo(Pt),$C=Fs(Pt),dm=Ls(Pt),FC=_j(Pt),LC=jj(Pt),BC=Nj(Pt),ZC=Ej(Pt),VC=Cj(Pt),UC=Tj(Pt),JC=Ij(Pt),HC=Aj(Pt),He=H("ZodType",(e,t)=>(Je.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:hs(e,"input"),output:hs(e,"output")}}),e.toJSONSchema=uC(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Sn(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>_n(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>RC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>$C(e,n,r),e.parseAsync=async(n,r)=>MC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>dm(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>FC(e,n,r),e.decode=(n,r)=>LC(e,n,r),e.encodeAsync=async(n,r)=>BC(e,n,r),e.decodeAsync=async(n,r)=>ZC(e,n,r),e.safeEncode=(n,r)=>VC(e,n,r),e.safeDecode=(n,r)=>UC(e,n,r),e.safeEncodeAsync=async(n,r)=>JC(e,n,r),e.safeDecodeAsync=async(n,r)=>HC(e,n,r),e.refine=(n,r)=>e.check(ZT(n,r)),e.superRefine=n=>e.check(VT(n)),e.overwrite=n=>e.check(Er(n)),e.optional=()=>gc(e),e.exactOptional=()=>CT(e),e.nullable=()=>xc(e),e.nullish=()=>gc(xc(e)),e.nonoptional=n=>PT(e,n),e.array=()=>Cr(e),e.or=n=>mt([e,n]),e.and=n=>kT(e,n),e.transform=n=>yc(e,NT(n)),e.default=n=>AT(e,n),e.prefault=n=>OT(e,n),e.catch=n=>RT(e,n),e.pipe=n=>yc(e,n),e.readonly=()=>FT(e),e.describe=n=>{const r=e.clone();return Vr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Vr.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Vr.get(e);const r=e.clone();return Vr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),fm=H("_ZodString",(e,t)=>{Qo.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Zh(e,r,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(WE(...r)),e.includes=(...r)=>e.check(YE(...r)),e.startsWith=(...r)=>e.check(KE(...r)),e.endsWith=(...r)=>e.check(XE(...r)),e.min=(...r)=>e.check(cs(...r)),e.max=(...r)=>e.check(Lh(...r)),e.length=(...r)=>e.check(Bh(...r)),e.nonempty=(...r)=>e.check(cs(1,...r)),e.lowercase=r=>e.check(qE(r)),e.uppercase=r=>e.check(GE(r)),e.trim=()=>e.check(eC()),e.normalize=(...r)=>e.check(QE(...r)),e.toLowerCase=()=>e.check(tC()),e.toUpperCase=()=>e.check(nC()),e.slugify=()=>e.check(rC())}),WC=H("ZodString",(e,t)=>{Qo.init(e,t),fm.init(e,t),e.email=n=>e.check(gE(qC,n)),e.url=n=>e.check(wE(GC,n)),e.jwt=n=>e.check(RE(cT,n)),e.emoji=n=>e.check(kE(YC,n)),e.guid=n=>e.check(uc(hc,n)),e.uuid=n=>e.check(xE(Di,n)),e.uuidv4=n=>e.check(yE(Di,n)),e.uuidv6=n=>e.check(bE(Di,n)),e.uuidv7=n=>e.check(vE(Di,n)),e.nanoid=n=>e.check(SE(KC,n)),e.guid=n=>e.check(uc(hc,n)),e.cuid=n=>e.check(_E(XC,n)),e.cuid2=n=>e.check(jE(QC,n)),e.ulid=n=>e.check(NE(eT,n)),e.base64=n=>e.check(OE(oT,n)),e.base64url=n=>e.check(PE(lT,n)),e.xid=n=>e.check(EE(tT,n)),e.ksuid=n=>e.check(CE(nT,n)),e.ipv4=n=>e.check(TE(rT,n)),e.ipv6=n=>e.check(IE(iT,n)),e.cidrv4=n=>e.check(AE(sT,n)),e.cidrv6=n=>e.check(zE(aT,n)),e.e164=n=>e.check(DE(uT,n)),e.datetime=n=>e.check(CC(n)),e.date=n=>e.check(IC(n)),e.time=n=>e.check(zC(n)),e.duration=n=>e.check(PC(n))});function oe(e){return mE(WC,e)}const qe=H("ZodStringFormat",(e,t)=>{We.init(e,t),fm.init(e,t)}),qC=H("ZodEmail",(e,t)=>{vN.init(e,t),qe.init(e,t)}),hc=H("ZodGUID",(e,t)=>{yN.init(e,t),qe.init(e,t)}),Di=H("ZodUUID",(e,t)=>{bN.init(e,t),qe.init(e,t)}),GC=H("ZodURL",(e,t)=>{wN.init(e,t),qe.init(e,t)}),YC=H("ZodEmoji",(e,t)=>{kN.init(e,t),qe.init(e,t)}),KC=H("ZodNanoID",(e,t)=>{SN.init(e,t),qe.init(e,t)}),XC=H("ZodCUID",(e,t)=>{_N.init(e,t),qe.init(e,t)}),QC=H("ZodCUID2",(e,t)=>{jN.init(e,t),qe.init(e,t)}),eT=H("ZodULID",(e,t)=>{NN.init(e,t),qe.init(e,t)}),tT=H("ZodXID",(e,t)=>{EN.init(e,t),qe.init(e,t)}),nT=H("ZodKSUID",(e,t)=>{CN.init(e,t),qe.init(e,t)}),rT=H("ZodIPv4",(e,t)=>{ON.init(e,t),qe.init(e,t)}),iT=H("ZodIPv6",(e,t)=>{PN.init(e,t),qe.init(e,t)}),sT=H("ZodCIDRv4",(e,t)=>{DN.init(e,t),qe.init(e,t)}),aT=H("ZodCIDRv6",(e,t)=>{RN.init(e,t),qe.init(e,t)}),oT=H("ZodBase64",(e,t)=>{MN.init(e,t),qe.init(e,t)}),lT=H("ZodBase64URL",(e,t)=>{FN.init(e,t),qe.init(e,t)}),uT=H("ZodE164",(e,t)=>{LN.init(e,t),qe.init(e,t)}),cT=H("ZodJWT",(e,t)=>{ZN.init(e,t),qe.init(e,t)}),pm=H("ZodNumber",(e,t)=>{Dh.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Vh(e,r,i),e.gt=(r,i)=>e.check(dc(r,i)),e.gte=(r,i)=>e.check(ba(r,i)),e.min=(r,i)=>e.check(ba(r,i)),e.lt=(r,i)=>e.check(cc(r,i)),e.lte=(r,i)=>e.check(ya(r,i)),e.max=(r,i)=>e.check(ya(r,i)),e.int=r=>e.check(mc(r)),e.safe=r=>e.check(mc(r)),e.positive=r=>e.check(dc(0,r)),e.nonnegative=r=>e.check(ba(0,r)),e.negative=r=>e.check(cc(0,r)),e.nonpositive=r=>e.check(ya(0,r)),e.multipleOf=(r,i)=>e.check(fc(r,i)),e.step=(r,i)=>e.check(fc(r,i)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function dT(e){return BE(pm,e)}const fT=H("ZodNumberFormat",(e,t)=>{VN.init(e,t),pm.init(e,t)});function mc(e){return ZE(fT,e)}const pT=H("ZodBoolean",(e,t)=>{UN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Uh(e,n,r)});function dt(e){return VE(pT,e)}const hT=H("ZodNull",(e,t)=>{JN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jh(e,n,r)});function mT(e){return UE(hT,e)}const gT=H("ZodUnknown",(e,t)=>{HN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wh()});function qt(){return JE(gT)}const xT=H("ZodNever",(e,t)=>{WN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hh(e,n,r)});function hm(e){return HE(xT,e)}const yT=H("ZodArray",(e,t)=>{qN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(cs(n,r)),e.nonempty=n=>e.check(cs(1,n)),e.max=(n,r)=>e.check(Lh(n,r)),e.length=(n,r)=>e.check(Bh(n,r)),e.unwrap=()=>e.element});function Cr(e,t){return iC(yT,e,t)}const mm=H("ZodObject",(e,t)=>{YN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qh(e,n,r,i),Ae(e,"shape",()=>t.shape),e.keyof=()=>xm(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:qt()}),e.loose=()=>e.clone({...e._zod.def,catchall:qt()}),e.strict=()=>e.clone({...e._zod.def,catchall:hm()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>mj(e,n),e.safeExtend=n=>gj(e,n),e.merge=n=>xj(e,n),e.pick=n=>pj(e,n),e.omit=n=>hj(e,n),e.partial=(...n)=>yj(ym,e,n[0]),e.required=(...n)=>bj(bm,e,n[0])});function $e(e,t){const n={type:"object",shape:e??{},...fe(t)};return new mm(n)}function Ve(e,t){return new mm({type:"object",shape:e,catchall:hm(),...fe(t)})}const gm=H("ZodUnion",(e,t)=>{$h.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>em(e,n,r,i),e.options=t.options});function mt(e,t){return new gm({type:"union",options:e,...fe(t)})}const bT=H("ZodDiscriminatedUnion",(e,t)=>{gm.init(e,t),KN.init(e,t)});function vT(e,t,n){return new bT({type:"union",options:t,discriminator:e,...fe(n)})}const wT=H("ZodIntersection",(e,t)=>{XN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tm(e,n,r,i)});function kT(e,t){return new wT({type:"intersection",left:e,right:t})}const ST=H("ZodRecord",(e,t)=>{QN.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nm(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function di(e,t,n){return new ST({type:"record",keyType:e,valueType:t,...fe(n)})}const to=H("ZodEnum",(e,t)=>{eE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,i,s)=>qh(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const s={};for(const a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new to({...t,checks:[],...fe(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new to({...t,checks:[],...fe(i),entries:s})}});function xm(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new to({type:"enum",entries:n,...fe(t)})}const _T=H("ZodLiteral",(e,t)=>{tE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gh(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function be(e,t){return new _T({type:"literal",values:Array.isArray(e)?e:[e],...fe(t)})}const jT=H("ZodTransform",(e,t)=>{nE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new bh(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(ci(s,n.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(ci(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function NT(e){return new jT({type:"transform",transform:e})}const ym=H("ZodOptional",(e,t)=>{Fh.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>el(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function gc(e){return new ym({type:"optional",innerType:e})}const ET=H("ZodExactOptional",(e,t)=>{rE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>el(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function CT(e){return new ET({type:"optional",innerType:e})}const TT=H("ZodNullable",(e,t)=>{iE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function xc(e){return new TT({type:"nullable",innerType:e})}const IT=H("ZodDefault",(e,t)=>{sE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function AT(e,t){return new IT({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Sh(t)}})}const zT=H("ZodPrefault",(e,t)=>{aE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>am(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function OT(e,t){return new zT({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Sh(t)}})}const bm=H("ZodNonOptional",(e,t)=>{oE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>im(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function PT(e,t){return new bm({type:"nonoptional",innerType:e,...fe(t)})}const DT=H("ZodCatch",(e,t)=>{lE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>om(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function RT(e,t){return new DT({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const MT=H("ZodPipe",(e,t)=>{uE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lm(e,n,r,i),e.in=t.in,e.out=t.out});function yc(e,t){return new MT({type:"pipe",in:e,out:t})}const $T=H("ZodReadonly",(e,t)=>{cE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>um(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function FT(e){return new $T({type:"readonly",innerType:e})}const LT=H("ZodLazy",(e,t)=>{dE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cm(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function BT(e){return new LT({type:"lazy",getter:e})}const tl=H("ZodCustom",(e,t)=>{fE.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yh(e,n)});function vm(e,t){return sC(tl,e??(()=>!0),t)}function ZT(e,t={}){return aC(tl,e,t)}function VT(e){return oC(e)}function ms(e,t={}){const n=new tl({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...fe(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var fi;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(fi||(fi={}));var bc;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(bc||(bc={}));fi.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);fi.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class gs extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(n(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof gs))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fi.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}gs.create=e=>new gs(e);var vc;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(vc||(vc={}));var we;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(we||(we={}));class wc extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function va(e){}function UT(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=va,onError:n=va,onRetry:r=va,onComment:i}=e;let s="",a=!0,o,l="",c="";function d(v){const _=a?v.replace(/^\xEF\xBB\xBF/,""):v,[b,E]=JT(`${s}${_}`);for(const m of b)f(m);s=E,a=!1}function f(v){if(v===""){p();return}if(v.startsWith(":")){i&&i(v.slice(v.startsWith(": ")?2:1));return}const _=v.indexOf(":");if(_!==-1){const b=v.slice(0,_),E=v[_+1]===" "?2:1,m=v.slice(_+E);h(b,m,v);return}h(v,"",v)}function h(v,_,b){switch(v){case"event":c=_;break;case"data":l=`${l}${_}
78
- `;break;case"id":o=_.includes("\0")?void 0:_;break;case"retry":/^\d+$/.test(_)?r(parseInt(_,10)):n(new wc(`Invalid \`retry\` value: "${_}"`,{type:"invalid-retry",value:_,line:b}));break;default:n(new wc(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:_,line:b}));break}}function p(){l.length>0&&t({id:o,event:c||void 0,data:l.endsWith(`
79
- `)?l.slice(0,-1):l}),o=void 0,l="",c=""}function g(v={}){s&&v.consume&&f(s),a=!0,o=void 0,l="",c="",s=""}return{feed:d,reset:g}}function JT(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
80
- `,r);let a=-1;if(i!==-1&&s!==-1?a=Math.min(i,s):i!==-1?i===e.length-1?a=-1:a=i:s!==-1&&(a=s),a===-1){n=e.slice(r);break}else{const o=e.slice(r,a);t.push(o),r=a+1,e[r-1]==="\r"&&e[r]===`
81
- `&&r++}}return[t,n]}class HT extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=UT({onEvent:a=>{s.enqueue(a)},onError(a){t==="terminate"?s.error(a):typeof t=="function"&&t(a)},onRetry:n,onComment:r})},transform(s){i.feed(s)}})}}var ki=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,a=new Array(t);for(let o=0;o<t;o++)a[o]=n[Math.random()*s|0];return a.join("")};if(e==null)return i;if(n.includes(r))throw new ij({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},WT=ki();function qn(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,r)=>{t[r.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var qT=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,GT=/"(?: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 kc(e){const t=JSON.parse(e);return t===null||typeof t!="object"||qT.test(e)===!1&&GT.test(e)===!1?t:YT(t)}function YT(e){let t=[e];for(;t.length;){const n=t;t=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&r.constructor!==null&&typeof r.constructor=="object"&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in r){const s=r[i];s&&typeof s=="object"&&t.push(s)}}}return e}function KT(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return kc(e)}try{return kc(e)}finally{Error.stackTraceLimit=t}}function nl(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:n}=e;if(n!=null)for(const r of Object.keys(n))n[r]=En(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(En):En(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(En)),e.allOf!=null&&(e.allOf=e.allOf.map(En)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(En));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=En(t[n]);return e}function En(e){return typeof e=="boolean"?e:nl(e)}var XT=Symbol("Let zodToJsonSchema decide on which parser to use"),Sc={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"},QT=e=>typeof e=="string"?{...Sc,name:e}:{...Sc,...e};function It(){return{}}function eI(e,t){var n,r,i;const s={type:"array"};return(n=e.type)!=null&&n._def&&((i=(r=e.type)==null?void 0:r._def)==null?void 0:i.typeName)!==we.ZodAny&&(s.items=Re(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(s.minItems=e.minLength.value),e.maxLength&&(s.maxItems=e.maxLength.value),e.exactLength&&(s.minItems=e.exactLength.value,s.maxItems=e.exactLength.value),s}function tI(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const 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;break}return t}function nI(){return{type:"boolean"}}function wm(e,t){return Re(e.type._def,t)}var rI=(e,t)=>Re(e.innerType._def,t);function km(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>km(e,t,i))};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 iI(e)}}var iI=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function sI(e,t){return{...Re(e.innerType._def,t),default:e.defaultValue()}}function aI(e,t){return t.effectStrategy==="input"?Re(e.schema._def,t):It()}function oI(e){return{type:"string",enum:Array.from(e.values)}}var lI=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function uI(e,t){const n=[Re(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Re(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(lI(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:a,...o}=i;s=o}r.push(s)}}),r.length?{allOf:r}:void 0}function cI(e){const 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 wa=void 0,Dt={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:()=>(wa===void 0&&(wa=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),wa),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 Sm(e,t){const n={type:"string"};if(e.checks)for(const 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":Rt(n,"email",r.message,t);break;case"format:idn-email":Rt(n,"idn-email",r.message,t);break;case"pattern:zod":ut(n,Dt.email,r.message,t);break}break;case"url":Rt(n,"uri",r.message,t);break;case"uuid":Rt(n,"uuid",r.message,t);break;case"regex":ut(n,r.regex,r.message,t);break;case"cuid":ut(n,Dt.cuid,r.message,t);break;case"cuid2":ut(n,Dt.cuid2,r.message,t);break;case"startsWith":ut(n,RegExp(`^${ka(r.value,t)}`),r.message,t);break;case"endsWith":ut(n,RegExp(`${ka(r.value,t)}$`),r.message,t);break;case"datetime":Rt(n,"date-time",r.message,t);break;case"date":Rt(n,"date",r.message,t);break;case"time":Rt(n,"time",r.message,t);break;case"duration":Rt(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":{ut(n,RegExp(ka(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Rt(n,"ipv4",r.message,t),r.version!=="v4"&&Rt(n,"ipv6",r.message,t);break}case"base64url":ut(n,Dt.base64url,r.message,t);break;case"jwt":ut(n,Dt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ut(n,Dt.ipv4Cidr,r.message,t),r.version!=="v4"&&ut(n,Dt.ipv6Cidr,r.message,t);break}case"emoji":ut(n,Dt.emoji(),r.message,t);break;case"ulid":{ut(n,Dt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Rt(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ut(n,Dt.base64,r.message,t);break}}break}case"nanoid":ut(n,Dt.nanoid,r.message,t)}return n}function ka(e,t){return t.patternStrategy==="escape"?fI(e):e}var dI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function fI(e){let t="";for(let n=0;n<e.length;n++)dI.has(e[n])||(t+="\\"),t+=e[n];return t}function Rt(e,t,n,r){var i;e.format||(i=e.anyOf)!=null&&i.some(s=>s.format)?(e.anyOf||(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 ut(e,t,n,r){var i;e.pattern||(i=e.allOf)!=null&&i.some(s=>s.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:_c(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=_c(t,r)}function _c(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source;let s="",a=!1,o=!1,l=!1;for(let c=0;c<i.length;c++){if(a){s+=i[c],a=!1;continue}if(r.i){if(o){if(i[c].match(/[a-z]/)){l?(s+=i[c],s+=`${i[c-2]}-${i[c]}`.toUpperCase(),l=!1):i[c+1]==="-"&&((n=i[c+2])!=null&&n.match(/[a-z]/))?(s+=i[c],l=!0):s+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){s+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){s+=`(^|(?<=[\r
82
- ]))`;continue}else if(i[c]==="$"){s+=`($|(?=[\r
83
- ]))`;continue}}if(r.s&&i[c]==="."){s+=o?`${i[c]}\r
84
- `:`[${i[c]}\r
85
- ]`;continue}s+=i[c],i[c]==="\\"?a=!0:o&&i[c]==="]"?o=!1:!o&&i[c]==="["&&(o=!0)}try{new RegExp(s)}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 s}function _m(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=Re(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===we.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...d}=Sm(e.keyType._def,t);return{...l,propertyNames:d}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===we.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===we.ZodBranded&&e.keyType._def.type._def.typeName===we.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:c,...d}=wm(e.keyType._def,t);return{...l,propertyNames:d}}}return l}function pI(e,t){if(t.mapStrategy==="record")return _m(e,t);const n=Re(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||It(),r=Re(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||It();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function hI(e){const t=e.values,r=Object.keys(e.values).filter(s=>typeof t[t[s]]!="number").map(s=>t[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function mI(){return{not:It()}}function gI(){return{type:"null"}}var no={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function xI(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in no&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=no[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,s)=>{const a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){const i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return yI(e,t)}var yI=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Re(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function bI(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[no[e.innerType._def.typeName],"null"]};const n=Re(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function vI(e){const t={type:"number"};if(!e.checks)return t;for(const 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;break}return t}function wI(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const a in i){let o=i[a];if(o===void 0||o._def===void 0)continue;const l=SI(o),c=Re(o._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});c!==void 0&&(n.properties[a]=c,l||r.push(a))}r.length&&(n.required=r);const s=kI(e,t);return s!==void 0&&(n.additionalProperties=s),n}function kI(e,t){if(e.catchall._def.typeName!=="ZodNever")return Re(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 SI(e){try{return e.isOptional()}catch{return!0}}var _I=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Re(e.innerType._def,t);const r=Re(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:It()},r]}:It()},jI=(e,t)=>{if(t.pipeStrategy==="input")return Re(e.in._def,t);if(t.pipeStrategy==="output")return Re(e.out._def,t);const n=Re(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Re(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function NI(e,t){return Re(e.type._def,t)}function EI(e,t){const r={type:"array",uniqueItems:!0,items:Re(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}function CI(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Re(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Re(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Re(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function TI(){return{not:It()}}function II(){return It()}var AI=(e,t)=>Re(e.innerType._def,t),zI=(e,t,n)=>{switch(t){case we.ZodString:return Sm(e,n);case we.ZodNumber:return vI(e);case we.ZodObject:return wI(e,n);case we.ZodBigInt:return tI(e);case we.ZodBoolean:return nI();case we.ZodDate:return km(e,n);case we.ZodUndefined:return TI();case we.ZodNull:return gI();case we.ZodArray:return eI(e,n);case we.ZodUnion:case we.ZodDiscriminatedUnion:return xI(e,n);case we.ZodIntersection:return uI(e,n);case we.ZodTuple:return CI(e,n);case we.ZodRecord:return _m(e,n);case we.ZodLiteral:return cI(e);case we.ZodEnum:return oI(e);case we.ZodNativeEnum:return hI(e);case we.ZodNullable:return bI(e,n);case we.ZodOptional:return _I(e,n);case we.ZodMap:return pI(e,n);case we.ZodSet:return EI(e,n);case we.ZodLazy:return()=>e.getter()._def;case we.ZodPromise:return NI(e,n);case we.ZodNaN:case we.ZodNever:return mI();case we.ZodEffects:return aI(e,n);case we.ZodAny:return It();case we.ZodUnknown:return II();case we.ZodDefault:return sI(e,n);case we.ZodBranded:return wm(e,n);case we.ZodReadonly:return AI(e,n);case we.ZodCatch:return rI(e,n);case we.ZodPipeline:return jI(e,n);case we.ZodFunction:case we.ZodVoid:case we.ZodSymbol:return;default:return(r=>{})()}},OI=(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 Re(e,t,n=!1){var r;const i=t.seen.get(e);if(t.override){const l=(r=t.override)==null?void 0:r.call(t,e,t,i,n);if(l!==XT)return l}if(i&&!n){const l=PI(i,t);if(l!==void 0)return l}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=zI(e,e.typeName,t),o=typeof a=="function"?Re(a(),t):a;if(o&&DI(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var PI=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:OI(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,r)=>t.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),It()):t.$refStrategy==="seen"?It():void 0}},DI=(e,t,n)=>(e.description&&(n.description=e.description),n),RI=e=>{const t=QT(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}},MI=(e,t)=>{var n;const r=RI(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[d,f])=>{var h;return{...c,[d]:(h=Re(f._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?h:It()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=Re(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:It(),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o);const l=s===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},ro=Symbol.for("vercel.ai.schema");function $I(e){let t;return()=>(t==null&&(t=e()),t)}function Zs(e,{validate:t}={}){return{[ro]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function FI(e){return typeof e=="object"&&e!==null&&ro in e&&e[ro]===!0&&"jsonSchema"in e&&"validate"in e}function rl(e){return e==null?Zs({properties:{},additionalProperties:!1}):FI(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?jm(e):LI(e):e()}function LI(e){return Zs(()=>nl(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{const n=await e["~standard"].validate(t);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new br({value:t,cause:n.issues})}}})}function BI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Zs(()=>MI(e,{$refStrategy:r?"root":"none"}),{validate:async i=>{const s=await e.safeParseAsync(i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function ZI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Zs(()=>nl(NC(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await dm(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function VI(e){return"_zod"in e}function jm(e,t){return VI(e)?ZI(e):BI(e)}async function jc({value:e,schema:t,context:n}){const r=await pi({value:e,schema:t,context:n});if(!r.success)throw br.wrap({value:e,cause:r.error,context:n});return r.value}async function pi({value:e,schema:t,context:n}){const r=rl(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const i=await r.validate(e);return i.success?{success:!0,value:i.value,rawValue:e}:{success:!1,error:br.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:br.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function Mn({text:e,schema:t}){try{const n=KT(e);return t==null?{success:!0,value:n,rawValue:n}:await pi({value:n,schema:t})}catch(n){return{success:!1,error:qu.isInstance(n)?n:new qu({text:e,cause:n}),rawValue:void 0}}}function UI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new HT).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Mn({text:n,schema:t}))}}))}async function pn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var JI=Object.defineProperty,HI=(e,t)=>{for(var n in t)JI(e,n,{get:t[n],enumerable:!0})},Nm="AI_NoObjectGeneratedError",Em=`vercel.ai.error.${Nm}`,WI=Symbol.for(Em),Cm,xn=class extends Xt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Nm,message:e,cause:t}),this[Cm]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Xt.hasMarker(e,Em)}};Cm=WI;var Tm="AI_UIMessageStreamError",Im=`vercel.ai.error.${Tm}`,qI=Symbol.for(Im),Am,Gn=class extends Xt{constructor({chunkType:e,chunkId:t,message:n}){super({name:Tm,message:n}),this[Am]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Xt.hasMarker(e,Im)}};Am=qI;var zm=mt([oe(),ms(Uint8Array),ms(ArrayBuffer),vm(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),hi=BT(()=>mt([mT(),oe(),dT(),dt(),di(oe(),hi.optional()),Cr(hi)])),Ee=di(oe(),di(oe(),hi.optional())),Om=$e({type:be("text"),text:oe(),providerOptions:Ee.optional()}),GI=$e({type:be("image"),image:mt([zm,ms(URL)]),mediaType:oe().optional(),providerOptions:Ee.optional()}),Pm=$e({type:be("file"),data:mt([zm,ms(URL)]),filename:oe().optional(),mediaType:oe(),providerOptions:Ee.optional()}),YI=$e({type:be("reasoning"),text:oe(),providerOptions:Ee.optional()}),KI=$e({type:be("tool-call"),toolCallId:oe(),toolName:oe(),input:qt(),providerOptions:Ee.optional(),providerExecuted:dt().optional()}),XI=vT("type",[$e({type:be("text"),value:oe(),providerOptions:Ee.optional()}),$e({type:be("json"),value:hi,providerOptions:Ee.optional()}),$e({type:be("execution-denied"),reason:oe().optional(),providerOptions:Ee.optional()}),$e({type:be("error-text"),value:oe(),providerOptions:Ee.optional()}),$e({type:be("error-json"),value:hi,providerOptions:Ee.optional()}),$e({type:be("content"),value:Cr(mt([$e({type:be("text"),text:oe(),providerOptions:Ee.optional()}),$e({type:be("media"),data:oe(),mediaType:oe()}),$e({type:be("file-data"),data:oe(),mediaType:oe(),filename:oe().optional(),providerOptions:Ee.optional()}),$e({type:be("file-url"),url:oe(),providerOptions:Ee.optional()}),$e({type:be("file-id"),fileId:mt([oe(),di(oe(),oe())]),providerOptions:Ee.optional()}),$e({type:be("image-data"),data:oe(),mediaType:oe(),providerOptions:Ee.optional()}),$e({type:be("image-url"),url:oe(),providerOptions:Ee.optional()}),$e({type:be("image-file-id"),fileId:mt([oe(),di(oe(),oe())]),providerOptions:Ee.optional()}),$e({type:be("custom"),providerOptions:Ee.optional()})]))})]),Dm=$e({type:be("tool-result"),toolCallId:oe(),toolName:oe(),output:XI,providerOptions:Ee.optional()}),QI=$e({type:be("tool-approval-request"),approvalId:oe(),toolCallId:oe()}),eA=$e({type:be("tool-approval-response"),approvalId:oe(),approved:dt(),reason:oe().optional()}),tA=$e({role:be("system"),content:oe(),providerOptions:Ee.optional()}),nA=$e({role:be("user"),content:mt([oe(),Cr(mt([Om,GI,Pm]))]),providerOptions:Ee.optional()}),rA=$e({role:be("assistant"),content:mt([oe(),Cr(mt([Om,Pm,YI,KI,Dm,QI]))]),providerOptions:Ee.optional()}),iA=$e({role:be("tool"),content:Cr(mt([Dm,eA])),providerOptions:Ee.optional()});mt([tA,nA,rA,iA]);function Rm(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const i=t[r];if(i===void 0)continue;const s=r in e?e[r]:void 0,a=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),o=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);a&&o?n[r]=Rm(s,i):n[r]=i}return n}var sA={};HI(sA,{array:()=>uA,choice:()=>cA,json:()=>dA,object:()=>lA,text:()=>oA});function aA(e){const t=["ROOT"];let n=-1,r=null;function i(l,c,d){switch(l){case'"':{n=c,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=c,r=c,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),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=c,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=c,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=c,t.pop(),t.push(d),t.push("INSIDE_ARRAY_START");break}}}function s(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}function a(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}for(let l=0;l<e.length;l++){const c=e[l];switch(t[t.length-1]){case"ROOT":i(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=l,t.pop();break}default:{n=l,i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(c){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"&&a(c,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const f=e.substring(r,l+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(c,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l)):n=l;break}}}let o=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{o+='"';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":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?o+="true".slice(d.length):"false".startsWith(d)?o+="false".slice(d.length):"null".startsWith(d)&&(o+="null".slice(d.length))}}return o}async function Si(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Mn({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Mn({text:aA(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var oA=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),lA=({schema:e,name:t,description:n})=>{const r=rl(e);return{name:"object",responseFormat:pn(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await Mn({text:i});if(!a.success)throw new xn({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=await pi({value:a.value,schema:r});if(!o.success)throw new xn({message:"No object generated: response did not match schema.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});return o.value},async parsePartialOutput({text:i}){const s=await Si(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},uA=({element:e,name:t,description:n})=>{const r=rl(e);return{name:"array",responseFormat:pn(r.jsonSchema).then(i=>{const{$schema:s,...a}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:a}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},s){const a=await Mn({text:i});if(!a.success)throw new xn({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=a.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new xn({message:"No object generated: response did not match schema.",cause:new br({value:o,cause:"response must be an object with an elements array"}),text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const l of o.elements){const c=await pi({value:l,schema:r});if(!c.success)throw new xn({message:"No object generated: response did not match schema.",cause:c.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason})}return o.elements},async parsePartialOutput({text:i}){const s=await Si(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=s.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))return;const o=s.state==="repaired-parse"&&a.elements.length>0?a.elements.slice(0,-1):a.elements,l=[];for(const c of o){const d=await pi({value:c,schema:r});d.success&&l.push(d.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},a){if(s!=null)for(;i<s.length;i++)a.enqueue(s[i])}})}}},cA=({options:e,name:t,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},i){const s=await Mn({text:r});if(!s.success)throw new xn({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const a=s.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string"||!e.includes(a.result))throw new xn({message:"No object generated: response did not match schema.",cause:new br({value:a,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return a.result},async parsePartialOutput({text:r}){const i=await Si(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=i.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string")return;const a=e.filter(o=>o.startsWith(s.result));return i.state==="successful-parse"?a.includes(s.result)?{partial:s.result}:void 0:a.length===1?{partial:a[0]}:void 0}}},createElementStreamTransform(){}}),dA=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},r){const i=await Mn({text:n});if(!i.success)throw new xn({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value},async parsePartialOutput({text:n}){const r=await Si(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return r.value===void 0?void 0:{partial:r.value}}},createElementStreamTransform(){}});ki({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
86
-
87
- `)},flush(e){e.enqueue(`data: [DONE]
88
-
89
- `)}})}});var fA=$I(()=>jm(mt([Ve({type:be("text-start"),id:oe(),providerMetadata:Ee.optional()}),Ve({type:be("text-delta"),id:oe(),delta:oe(),providerMetadata:Ee.optional()}),Ve({type:be("text-end"),id:oe(),providerMetadata:Ee.optional()}),Ve({type:be("error"),errorText:oe()}),Ve({type:be("tool-input-start"),toolCallId:oe(),toolName:oe(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),title:oe().optional()}),Ve({type:be("tool-input-delta"),toolCallId:oe(),inputTextDelta:oe()}),Ve({type:be("tool-input-available"),toolCallId:oe(),toolName:oe(),input:qt(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),title:oe().optional()}),Ve({type:be("tool-input-error"),toolCallId:oe(),toolName:oe(),input:qt(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),errorText:oe(),title:oe().optional()}),Ve({type:be("tool-approval-request"),approvalId:oe(),toolCallId:oe()}),Ve({type:be("tool-output-available"),toolCallId:oe(),output:qt(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional(),preliminary:dt().optional()}),Ve({type:be("tool-output-error"),toolCallId:oe(),errorText:oe(),providerExecuted:dt().optional(),providerMetadata:Ee.optional(),dynamic:dt().optional()}),Ve({type:be("tool-output-denied"),toolCallId:oe()}),Ve({type:be("reasoning-start"),id:oe(),providerMetadata:Ee.optional()}),Ve({type:be("reasoning-delta"),id:oe(),delta:oe(),providerMetadata:Ee.optional()}),Ve({type:be("reasoning-end"),id:oe(),providerMetadata:Ee.optional()}),Ve({type:be("source-url"),sourceId:oe(),url:oe(),title:oe().optional(),providerMetadata:Ee.optional()}),Ve({type:be("source-document"),sourceId:oe(),mediaType:oe(),title:oe(),filename:oe().optional(),providerMetadata:Ee.optional()}),Ve({type:be("file"),url:oe(),mediaType:oe(),providerMetadata:Ee.optional()}),Ve({type:vm(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:oe().optional(),data:qt(),transient:dt().optional()}),Ve({type:be("start-step")}),Ve({type:be("finish-step")}),Ve({type:be("start"),messageId:oe().optional(),messageMetadata:qt().optional()}),Ve({type:be("finish"),finishReason:xm(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:qt().optional()}),Ve({type:be("abort"),reason:oe().optional()}),Ve({type:be("message-metadata"),messageMetadata:qt()})])));function pA(e){return e.type.startsWith("data-")}function io(e){return e.type.startsWith("tool-")}function hA(e){return e.type==="dynamic-tool"}function xs(e){return io(e)||hA(e)}function Nc(e){return e.type.split("-").slice(1).join("-")}function mA({lastMessage:e,messageId:t}){return{message:(e==null?void 0:e.role)==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function gA({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return e.pipeThrough(new TransformStream({async transform(o,l){await r(async({state:c,write:d})=>{var f,h,p,g;function v(m){const N=c.message.parts.filter(xs).find(w=>w.toolCallId===m);if(N==null)throw new Gn({chunkType:"tool-invocation",chunkId:m,message:`No tool invocation found for tool call ID "${m}".`});return N}function _(m){var O;const N=c.message.parts.find(R=>io(R)&&R.toolCallId===m.toolCallId),w=m,k=N;if(N!=null){N.state=m.state,k.input=w.input,k.output=w.output,k.errorText=w.errorText,k.rawInput=w.rawInput,k.preliminary=w.preliminary,m.title!==void 0&&(k.title=m.title),k.providerExecuted=(O=w.providerExecuted)!=null?O:N.providerExecuted;const R=w.providerMetadata;if(R!=null)if(m.state==="output-available"||m.state==="output-error"){const q=N;q.resultProviderMetadata=R}else N.callProviderMetadata=R}else c.message.parts.push({type:`tool-${m.toolName}`,toolCallId:m.toolCallId,state:m.state,title:m.title,input:w.input,output:w.output,rawInput:w.rawInput,errorText:w.errorText,providerExecuted:w.providerExecuted,preliminary:w.preliminary,...w.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:w.providerMetadata}:{},...w.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:w.providerMetadata}:{}})}function b(m){var O,N;const w=c.message.parts.find(q=>q.type==="dynamic-tool"&&q.toolCallId===m.toolCallId),k=m,R=w;if(w!=null){w.state=m.state,R.toolName=m.toolName,R.input=k.input,R.output=k.output,R.errorText=k.errorText,R.rawInput=(O=k.rawInput)!=null?O:R.rawInput,R.preliminary=k.preliminary,m.title!==void 0&&(R.title=m.title),R.providerExecuted=(N=k.providerExecuted)!=null?N:w.providerExecuted;const q=k.providerMetadata;if(q!=null)if(m.state==="output-available"||m.state==="output-error"){const j=w;j.resultProviderMetadata=q}else w.callProviderMetadata=q}else c.message.parts.push({type:"dynamic-tool",toolName:m.toolName,toolCallId:m.toolCallId,state:m.state,input:k.input,output:k.output,errorText:k.errorText,preliminary:k.preliminary,providerExecuted:k.providerExecuted,title:m.title,...k.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:k.providerMetadata}:{},...k.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:k.providerMetadata}:{}})}async function E(m){if(m!=null){const O=c.message.metadata!=null?Rm(c.message.metadata,m):m;t!=null&&await jc({value:O,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=O}}switch(o.type){case"text-start":{const m={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeTextParts[o.id]=m,c.message.parts.push(m),d();break}case"text-delta":{const m=c.activeTextParts[o.id];if(m==null)throw new Gn({chunkType:"text-delta",chunkId:o.id,message:`Received text-delta for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});m.text+=o.delta,m.providerMetadata=(f=o.providerMetadata)!=null?f:m.providerMetadata,d();break}case"text-end":{const m=c.activeTextParts[o.id];if(m==null)throw new Gn({chunkType:"text-end",chunkId:o.id,message:`Received text-end for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});m.state="done",m.providerMetadata=(h=o.providerMetadata)!=null?h:m.providerMetadata,delete c.activeTextParts[o.id],d();break}case"reasoning-start":{const m={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeReasoningParts[o.id]=m,c.message.parts.push(m),d();break}case"reasoning-delta":{const m=c.activeReasoningParts[o.id];if(m==null)throw new Gn({chunkType:"reasoning-delta",chunkId:o.id,message:`Received reasoning-delta for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});m.text+=o.delta,m.providerMetadata=(p=o.providerMetadata)!=null?p:m.providerMetadata,d();break}case"reasoning-end":{const m=c.activeReasoningParts[o.id];if(m==null)throw new Gn({chunkType:"reasoning-end",chunkId:o.id,message:`Received reasoning-end for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});m.providerMetadata=(g=o.providerMetadata)!=null?g:m.providerMetadata,m.state="done",delete c.activeReasoningParts[o.id],d();break}case"file":{c.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url,...o.providerMetadata!=null?{providerMetadata:o.providerMetadata}:{}}),d();break}case"source-url":{c.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),d();break}case"source-document":{c.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),d();break}case"tool-input-start":{const m=c.message.parts.filter(io);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:m.length,dynamic:o.dynamic,title:o.title},o.dynamic?b({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}):_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}),d();break}case"tool-input-delta":{const m=c.partialToolCalls[o.toolCallId];if(m==null)throw new Gn({chunkType:"tool-input-delta",chunkId:o.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${o.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});m.text+=o.inputTextDelta;const{value:O}=await Si(m.text);m.dynamic?b({toolCallId:o.toolCallId,toolName:m.toolName,state:"input-streaming",input:O,title:m.title}):_({toolCallId:o.toolCallId,toolName:m.toolName,state:"input-streaming",input:O,title:m.title}),d();break}case"tool-input-available":{o.dynamic?b({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),d(),s&&!o.providerExecuted&&await s({toolCall:o});break}case"tool-input-error":{const m=c.message.parts.filter(xs).find(N=>N.toolCallId===o.toolCallId);(m!=null?m.type==="dynamic-tool":!!o.dynamic)?b({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):_({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),d();break}case"tool-approval-request":{const m=v(o.toolCallId);m.state="approval-requested",m.approval={id:o.approvalId},d();break}case"tool-output-denied":{const m=v(o.toolCallId);m.state="output-denied",d();break}case"tool-output-available":{const m=v(o.toolCallId);m.type==="dynamic-tool"?b({toolCallId:o.toolCallId,toolName:m.toolName,state:"output-available",input:m.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:m.title}):_({toolCallId:o.toolCallId,toolName:Nc(m),state:"output-available",input:m.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,providerMetadata:o.providerMetadata,title:m.title}),d();break}case"tool-output-error":{const m=v(o.toolCallId);m.type==="dynamic-tool"?b({toolCallId:o.toolCallId,toolName:m.toolName,state:"output-error",input:m.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:m.title}):_({toolCallId:o.toolCallId,toolName:Nc(m),state:"output-error",input:m.input,rawInput:m.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:m.title}),d();break}case"start-step":{c.message.parts.push({type:"step-start"});break}case"finish-step":{c.activeTextParts={},c.activeReasoningParts={};break}case"start":{o.messageId!=null&&(c.message.id=o.messageId),await E(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&d();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await E(o.messageMetadata),o.messageMetadata!=null&&d();break}case"message-metadata":{await E(o.messageMetadata),o.messageMetadata!=null&&d();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(pA(o)){if((n==null?void 0:n[o.type])!=null){const N=c.message.parts.findIndex(k=>"id"in k&&"data"in k&&k.id===o.id&&k.type===o.type),w=N>=0?N:c.message.parts.length;await jc({value:o.data,schema:n[o.type],context:{field:`message.parts[${w}].data`,entityName:o.type,entityId:o.id}})}const m=o;if(m.transient){a==null||a(m);break}const O=m.id!=null?c.message.parts.find(N=>m.type===N.type&&m.id===N.id):void 0;O!=null?O.data=m.data:c.message.parts.push(m),a==null||a(m),d()}}l.enqueue(o)})}}))}async function xA({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){t==null||t(r)}finally{n.releaseLock()}}ki({prefix:"aitxt",size:24});ki({prefix:"aiobj",size:24});var yA=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(r){n(r)}}),this.processQueue()})}};ki({prefix:"aiobj",size:24});async function bA(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,i=await new Promise((s,a)=>{const o=new FileReader;o.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},o.onerror=l=>a(l),o.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var vA=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var n,r,i,s,a;const o=await pn(this.body),l=await pn(this.headers),c=await pn(this.credentials),d={...qn(l),...qn(t.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...o,...t.body},headers:d,credentials:c,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),h=(r=f==null?void 0:f.api)!=null?r:this.api,p=(f==null?void 0:f.headers)!==void 0?qn(f.headers):d,g=(f==null?void 0:f.body)!==void 0?f.body:{...o,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},v=(i=f==null?void 0:f.credentials)!=null?i:c,b=await((s=this.fetch)!=null?s:globalThis.fetch)(h,{method:"POST",headers:{"Content-Type":"application/json",...p},body:JSON.stringify(g),credentials:v,signal:e});if(!b.ok)throw new Error((a=await b.text())!=null?a:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}async reconnectToStream(e){var t,n,r,i,s;const a=await pn(this.body),o=await pn(this.headers),l=await pn(this.credentials),c={...qn(o),...qn(e.headers)},d=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:c,credentials:l,requestMetadata:e.metadata})),f=(n=d==null?void 0:d.api)!=null?n:`${this.api}/${e.chatId}/stream`,h=(d==null?void 0:d.headers)!==void 0?qn(d.headers):c,p=(r=d==null?void 0:d.credentials)!=null?r:l,v=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"GET",headers:h,credentials:p});if(v.status===204)return null;if(!v.ok)throw new Error((s=await v.text())!=null?s:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}},Mm=class extends vA{constructor(e={}){super(e)}processResponseStream(e){return UI({stream:e,schema:fA}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},wA=class{constructor({generateId:e=WT,id:t=e(),transport:n=new Mm,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:c,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new yA,this.sendMessage=async(f,h)=>{var p,g,v,_;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...h});return}let b;if("text"in f||"files"in f?b={parts:[...Array.isArray(f.files)?f.files:await bA(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:b=f,f.messageId!=null){const E=this.state.messages.findIndex(m=>m.id===f.messageId);if(E===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[E].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,E+1),this.state.replaceMessage(E,{...b,id:f.messageId,role:(g=b.role)!=null?g:"user",metadata:f.metadata})}else this.state.pushMessage({...b,id:(v=b.id)!=null?v:this.generateId(),role:(_=b.role)!=null?_:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...h})},this.regenerate=async({messageId:f,...h}={})=>{const p=f==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===f);if(p===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...h})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:f,approved:h,reason:p,options:g})=>this.jobExecutor.run(async()=>{const v=this.state.messages,_=v[v.length-1],b=E=>xs(E)&&E.state==="approval-requested"&&E.approval.id===f?{...E,state:"approval-responded",approval:{id:f,approved:h,reason:p}}:E;this.state.replaceMessage(v.length-1,{..._,parts:_.parts.map(b)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(b)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(E=>{var m;E&&this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...g})})}),this.addToolOutput=async({state:f="output-available",toolCallId:h,output:p,errorText:g,options:v})=>this.jobExecutor.run(async()=>{const _=this.state.messages,b=_[_.length-1],E=m=>xs(m)&&m.toolCallId===h?{...m,state:f,output:p,errorText:g}:m;this.state.replaceMessage(_.length-1,{...b,parts:b.parts.map(E)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(E)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(m=>{var O;m&&this.makeRequest({trigger:"submit-message",messageId:(O=this.lastMessage)==null?void 0:O.id,...v})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=o,this.onFinish=l,this.onData=c,this.sendAutomaticallyWhen=d}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(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]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var s,a,o;let l;if(e==="resume-stream")try{const p=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(p==null)return;l=p}catch(p){this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p});return}this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let d=!1,f=!1,h=!1;try{const p={state:mA({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=p;let g;e==="resume-stream"?g=l:g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});const v=_=>this.jobExecutor.run(()=>_({state:p.state,write:()=>{var b;this.setStatus({status:"streaming"}),p.state.message.id===((b=this.lastMessage)==null?void 0:b.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await xA({stream:gA({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:_=>{throw _}}),onError:_=>{throw _}}),this.setStatus({status:"ready"})}catch(p){if(d||p.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;h=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:h,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}!h&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:t,headers:n,body:r})}},Sa,Ec;function kA(){if(Ec)return Sa;Ec=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let r,i=0;return function(...a){clearTimeout(r);const o=Date.now(),l=o-i,c=n-l;c<=0?(i=o,t.apply(this,a)):r=setTimeout(()=>{i=Date.now(),t.apply(this,a)},c)}}return Sa=e,Sa}var SA=kA();const _A=uo(SA);var $m=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Ue=(e,t,n)=>($m(e,t,"read from private field"),n?n.call(e):t.get(e)),Jt=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},fn=(e,t,n,r)=>($m(e,t,"write to private field"),t.set(e,n),n);function jA(e,t){return t!=null?_A(e,t):e}var At,Vi,Ui,Ur,Jr,Hr,Qn,so,ao,NA=class{constructor(e=[]){Jt(this,At,void 0),Jt(this,Vi,"ready"),Jt(this,Ui,void 0),Jt(this,Ur,new Set),Jt(this,Jr,new Set),Jt(this,Hr,new Set),this.pushMessage=t=>{fn(this,At,Ue(this,At).concat(t)),Ue(this,Qn).call(this)},this.popMessage=()=>{fn(this,At,Ue(this,At).slice(0,-1)),Ue(this,Qn).call(this)},this.replaceMessage=(t,n)=>{fn(this,At,[...Ue(this,At).slice(0,t),this.snapshot(n),...Ue(this,At).slice(t+1)]),Ue(this,Qn).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?jA(t,n):t;return Ue(this,Ur).add(r),()=>{Ue(this,Ur).delete(r)}},this["~registerStatusCallback"]=t=>(Ue(this,Jr).add(t),()=>{Ue(this,Jr).delete(t)}),this["~registerErrorCallback"]=t=>(Ue(this,Hr).add(t),()=>{Ue(this,Hr).delete(t)}),Jt(this,Qn,()=>{Ue(this,Ur).forEach(t=>t())}),Jt(this,so,()=>{Ue(this,Jr).forEach(t=>t())}),Jt(this,ao,()=>{Ue(this,Hr).forEach(t=>t())}),fn(this,At,e)}get status(){return Ue(this,Vi)}set status(e){fn(this,Vi,e),Ue(this,so).call(this)}get error(){return Ue(this,Ui)}set error(e){fn(this,Ui,e),Ue(this,ao).call(this)}get messages(){return Ue(this,At)}set messages(e){fn(this,At,[...e]),Ue(this,Qn).call(this)}};At=new WeakMap;Vi=new WeakMap;Ui=new WeakMap;Ur=new WeakMap;Jr=new WeakMap;Hr=new WeakMap;Qn=new WeakMap;so=new WeakMap;ao=new WeakMap;var er,Cc=class extends wA{constructor({messages:e,...t}){const n=new NA(e);super({...t,state:n}),Jt(this,er,void 0),this["~registerMessagesCallback"]=(r,i)=>Ue(this,er)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Ue(this,er)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Ue(this,er)["~registerErrorCallback"](r),fn(this,er,n)}};er=new WeakMap;function EA({experimental_throttle:e,resume:t=!1,...n}={}){const r=x.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:h=>{var p,g;return(g=(p=r.current).onToolCall)==null?void 0:g.call(p,h)},onData:h=>{var p,g;return(g=(p=r.current).onData)==null?void 0:g.call(p,h)},onFinish:h=>{var p,g;return(g=(p=r.current).onFinish)==null?void 0:g.call(p,h)},onError:h=>{var p,g;return(g=(p=r.current).onError)==null?void 0:g.call(p,h)},sendAutomaticallyWhen:h=>{var p,g,v;return(v=(g=(p=r.current).sendAutomaticallyWhen)==null?void 0:g.call(p,h))!=null?v:!1}},s=x.useRef("chat"in n?n.chat:new Cc(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Cc(i));const o=x.useCallback(h=>s.current["~registerMessagesCallback"](h,e),[e,s.current.id]),l=x.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),c=x.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),d=x.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),f=x.useCallback(h=>{typeof h=="function"&&(h=h(s.current.messages)),s.current.messages=h},[s]);return x.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:l,setMessages:f,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:d,resumeStream:s.current.resumeStream,status:c,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function Fm(e,t){const n=[...e];for(const r of t){if(!r||typeof r.name!="string")continue;const i=n.findIndex(s=>s.name===r.name);r._delete?i!==-1&&n.splice(i,1):i!==-1?n[i]=r:n.push(r)}return n}function Lm(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Bm(e,t,n){if(!(n!=null&&n.selectedText)){const i=CA(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const o=e.indexOf(i,s+1);let l;if(o===-1)l=s;else if(n.startLine&&n.startLine>0){const f=PA(e,n.startLine);l=DA(e,i,f)}else l=s;const c=e.slice(0,l),d=e.slice(l+i.length);return{original:e,modified:c+t+d}}if(n.startLine&&n.endLine){const o=zA(e,t,n.startLine,n.endLine);if(o)return o}const a=Tc(e,t);return a||{original:e,modified:t}}const r=Tc(e,t);return r||{original:e,modified:t}}function CA(e,t){let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n.name;if(typeof r!="string"||!r)return null;let i;try{i=JSON.parse(e)}catch{return null}const s=e.match(/\n(\s+)"/),a=s?s[1].length:2;if(!oo(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function oo(e,t,n){if(Array.isArray(e)){for(let r=0;r<e.length;r++){const i=e[r];if(i&&typeof i=="object"&&!Array.isArray(i)&&i.name===t)return e[r]=n,!0;if(oo(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(oo(r,t,n))return!0}return!1}function Tc(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)){const o=Object.keys(s).sort().join(","),l=Object.keys(a).sort().join(",");if(o===l)return null}}catch{}}catch{}const n=TA(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=IA(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function TA(e){const t=[],n=e.split(`
90
- `),r=n.find(s=>s.trim().length>0);if(!r)return t;const i=r.search(/\S/);for(const s of n){const a=s.search(/\S/);if(a<0||a!==i)continue;const o=s.match(/^\s*"([^"]+)"\s*:/);o&&t.push(o[1])}return[...new Set(t)]}function IA(e,t,n){const r=`"${n}"`,i=Ic(e,r);if(i.length===0)return null;const s=Ic(t,r);if(s.length===0)return null;const a=s[0],o=t.slice(a.start,a.end);let l=0;if(i.length>1){let d=-1;for(let f=0;f<i.length;f++){const h=e.slice(i[f].start,i[f].end),p=OA(h,o);p>d&&(d=p,l=f)}}const c=i[l];return e.slice(0,c.start)+o+e.slice(c.end)}function Ic(e,t){const n=[];let r=0;for(;;){const i=e.indexOf(t,r);if(i===-1)break;let s=i-1;for(;s>=0&&(e[s]===" "||e[s]===" ");)s--;const a=s<0?"":e[s];if(a!==""&&a!=="{"&&a!==","&&a!==`
91
- `&&a!=="\r"){r=i+1;continue}const o=e.indexOf(":",i+t.length);if(o===-1){r=i+1;continue}const l=o+1,c=AA(e,l);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function AA(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return-1;const n=e[t];if(n==='"'){let i=t+1;for(;i<e.length;){if(e[i]==="\\"){i+=2;continue}if(e[i]==='"')return i+1;i++}return-1}if(n==="["||n==="{"){const i=n,s=n==="["?"]":"}";let a=1,o=t+1,l=!1;for(;o<e.length&&a>0;){if(e[o]==="\\"&&l){o+=2;continue}e[o]==='"'&&(l=!l),l||(e[o]===i?a++:e[o]===s&&a--),o++}return a===0?o:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function zA(e,t,n,r){const i=e.split(`
92
- `);if(n<1||r<n||n>i.length)return null;const s=i.slice(0,n-1).join(`
93
- `),a=i.slice(r).join(`
94
- `),o=s+(s?`
95
- `:"")+t+(a?`
96
- `:"")+a;return{original:e,modified:o}}function OA(e,t){if(e===t)return 1;if(!e.length||!t.length)return 0;const n=3,r=new Set;for(let a=0;a<=e.length-n;a++)r.add(e.slice(a,a+n));let i=0;for(let a=0;a<=t.length-n;a++)r.has(t.slice(a,a+n))&&i++;const s=Math.max(e.length-n+1,t.length-n+1);return s>0?i/s:0}function PA(e,t){let n=0;const r=e.split(`
97
- `);for(let i=0;i<Math.min(t-1,r.length);i++)n+=r[i].length+1;return n}function DA(e,t,n){let r=-1,i=1/0,s=e.indexOf(t);for(;s!==-1;){const a=Math.abs(s-n);a<i&&(i=a,r=s),s=e.indexOf(t,s+1)}return r}function RA(e){const t=e[e.length-1][1];try{return JSON.parse(t),t}catch{}if(e.length>1){const n=e.map(r=>r[1]).join(`
98
- `);try{return JSON.parse(n),n}catch{}}return null}function MA(e,t,n){if(n==="global")return null;try{const r=JSON.parse(e),i=JSON.parse(t);if(n==="slides"&&Array.isArray(i.children))r.children=i.children;else if(n==="templates"&&Array.isArray(i.templates))r.props||(r.props={}),r.props.templates=Fm(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function $A(){const e=Oe(Z=>Z.threads),t=Oe(Z=>Z.activeThreadId),n=Oe(Z=>Z.updateThreadMessages),r=Oe(Z=>Z.updateThreadTitle),i=Oe(Z=>Z.clearContext),s=Oe(Z=>Z.contextAttachments),a=Oe(Z=>Z.scope),o=Oe(Z=>Z.model),l=Ne(Z=>Z.activeTab),c=Ne(Z=>Z.documents),d=Ne(Z=>Z.documentTypes),f=Ne(Z=>Z.setPendingDiff),h=Ne(Z=>Z.createDocument),p=Ne(Z=>Z.openDocument),g=x.useRef(e);g.current=e;const v=x.useRef(l);v.current=l;const _=x.useRef(c);_.current=c;const b=x.useRef(d);b.current=d;const E=x.useRef(t);E.current=t;const m=l?t[l]:void 0,O=x.useRef(m);O.current=m;const N=x.useRef([]),w=x.useRef([]),k=x.useRef({}),R=x.useRef({}),[,q]=x.useState(0),j=x.useCallback(()=>q(Z=>Z+1),[]),T=x.useRef(null);T.current||(T.current=new Mm({api:"/api/ai/chat"}));const z=x.useCallback(()=>{const Z=_.current.find(V=>V.name===v.current);return Z?{name:Z.name,text:Z.text}:void 0},[]),P=x.useCallback(Z=>k.current[Z]||[],[]),I=EA({transport:T.current,onError:()=>{N.current.shift(),w.current.shift(),i()},onFinish:({messages:Z})=>{var W,X;const V=O.current;if(V){n(V,Z);const Y=g.current[V];if(Y&&Y.title.startsWith("Chat ")){const re=Z.find(D=>D.role==="user");if(re){const D=((W=re.parts)==null?void 0:W.filter(de=>de.type==="text").map(de=>de.text).join(""))||"";if(D){const de=D.length>50?D.slice(0,50)+"...":D;r(V,de)}}}}const ne=N.current.shift()||[],S=w.current.shift()||"global",le=Z.filter(Y=>Y.role==="user"),B=le[le.length-1];B!=null&&B.id&&(k.current[B.id]=ne,R.current[B.id]=S);const y=Z.filter(Y=>Y.role==="assistant").pop();if(y){const re=[...(((X=y.parts)==null?void 0:X.filter(D=>D.type==="text").map(D=>D.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(re.length>0){const D=RA(re);if(D){const de=re[re.length-1][1],te=v.current;if(te){const ae=_.current.find(nt=>nt.name===te),ue=(ae==null?void 0:ae.text)||"",ge=ne[0],pe=MA(ue,D,S);!pe&&S!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${S}", falling back to text merge`);const{original:Pe,modified:De}=pe??Bm(ue,D,ge);f(te,Pe,De,Lm(de.replace(/\n$/,"")))}else{const ae=`ai-generated-${Date.now()}`;h(ae,D),p(ae)}}}}i()}});x.useEffect(()=>{const Z=I.messages.filter(V=>V.role==="user");for(let V=Z.length-1;V>=0;V--){const ne=Z[V].id;if(ne in k.current)break;N.current.length>0&&(k.current[ne]=N.current[0],R.current[ne]=w.current[0]||"global",j());break}},[I.messages,j]);const M=x.useCallback((Z,V)=>{N.current.push([...s]),w.current.push(a),i();const ne={text:Z};V!=null&&V.length&&(ne.files=V),I.sendMessage(ne,{body:{format:ht,context:s,activeDocument:z(),documentType:v.current&&b.current[v.current]||"application/json+report",scope:a,model:o}})},[I.sendMessage,s,z,i,a,o]),J=x.useCallback(Z=>R.current[Z],[]);return{messages:I.messages,sendMessage:M,status:I.status,error:I.error,setMessages:I.setMessages,stop:I.stop,getMessageContext:P,getMessageScope:J}}const Zm=x.createContext(null);function FA({children:e}){const t=$A();return u.jsx(Zm.Provider,{value:t,children:e})}function LA(){const e=x.useContext(Zm);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function BA(e){try{const t=JSON.parse(e.selectedText);if(t!=null&&t.name)return t.name}catch{}return e.propertyKey?e.propertyKey:e.jsonPath?(e.jsonPath.split(".").pop()??e.jsonPath).replace(/\[\d+\]/g,""):"selection"}function ZA(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function Vm({context:e,onRemove:t,variant:n="default"}){var c;const r=BA(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=ZA(e.selectedText),o=n==="sent",l=u.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md border pl-2 ${t?"pr-1":"pr-2"} py-1 text-xs max-w-[280px] transition-colors ${o?"border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/20":"border-primary/20 bg-primary/5 hover:bg-primary/10"}`,children:[u.jsx(tx,{className:`h-3 w-3 shrink-0 ${o?"text-primary-foreground/60":"text-primary/60"}`}),u.jsx("span",{className:"truncate font-medium",children:s}),t&&u.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-opacity cursor-pointer","aria-label":"Remove context",children:u.jsx(yn,{className:"h-3 w-3"})})]});return u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:l}),u.jsxs(Ke,{side:"top",className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),u.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:a}),e.jsonPath&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Yn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const Um=32,VA=10,Jm=9,Hm=13,UA=160,JA=6158,HA=8192,WA=8203,qA=8239,GA=8287,YA=12288,KA=65279;function XA(e){return/^[0-9A-Fa-f]$/.test(e)}function Cn(e){return e>="0"&&e<="9"}function QA(e){return e>=" "}function Ri(e){return`,:[]/{}()
99
- +`.includes(e)}function Ac(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function zc(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Oc=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Pc=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Dc(e){return`,[]/{}
100
- +`.includes(e)}function Rc(e){return Ji(e)||ez.test(e)}const ez=/^[[{\w-]$/;function tz(e){return e===`
101
- `||e==="\r"||e===" "||e==="\b"||e==="\f"}function Tn(e,t){const n=e.charCodeAt(t);return n===Um||n===VA||n===Jm||n===Hm}function nz(e,t){const n=e.charCodeAt(t);return n===Um||n===Jm||n===Hm}function rz(e,t){const n=e.charCodeAt(t);return n===UA||n===JA||n>=HA&&n<=WA||n===qA||n===GA||n===YA||n===KA}function Ji(e){return Wm(e)||lo(e)}function Wm(e){return e==='"'||e==="“"||e==="”"}function Mc(e){return e==='"'}function lo(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function $c(e){return e==="'"}function $r(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const r=e.lastIndexOf(t);return r!==-1?e.substring(0,r)+(n?"":e.substring(r+1)):e}function Mt(e,t){let n=e.length;if(!Tn(e,n-1))return e+t;for(;Tn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function iz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function sz(e){return/[,\n][ \t\r]*$/.test(e)}const az={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},oz={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
102
- `,r:"\r",t:" "};function Fc(e){let t=0,n="";c(["```","[```","{```"]),s()||I(),c(["```","```]","```}"]);const i=f(",");for(i&&a(),Rc(e[t])&&sz(n)?(i||(n=Mt(n,",")),b()):i&&(n=$r(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;P();function s(){a();const V=v()||_()||E()||O()||N()||k(!1)||R();return a(),V}function a(){let V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const ne=t;let S=o(V);do S=l(),S&&(S=o(V));while(S);return t>ne}function o(V){const ne=V?Tn:nz;let S="";for(;;)if(ne(e,t))S+=e[t],t++;else if(rz(e,t))S+=" ",t++;else break;return S.length>0?(n+=S,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!lz(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
103
- `;)t++;return!0}return!1}function c(V){if(d(V)){if(Ac(e[t]))for(;t<e.length&&zc(e[t]);)t++;return a(),!0}return!1}function d(V){o(!0);for(const ne of V){const S=t+ne.length;if(e.slice(t,S)===ne)return t=S,!0}return!1}function f(V){return e[t]===V?(n+=e[t],t++,!0):!1}function h(V){return e[t]===V?(t++,!0):!1}function p(){return h("\\")}function g(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),h(","),!0):!1}function v(){if(e[t]==="{"){n+="{",t++,a(),h(",")&&a();let V=!0;for(;t<e.length&&e[t]!=="}";){let ne;if(V?(ne=!0,V=!1):(ne=f(","),ne||(n=Mt(n,",")),a()),g(),!(E()||k(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=$r(n,","):M();break}a();const le=f(":"),B=t>=e.length;le||(Rc(e[t])||B?n=Mt(n,":"):J()),s()||(le||B?n+="null":J())}return e[t]==="}"?(n+="}",t++):n=Mt(n,"}"),!0}return!1}function _(){if(e[t]==="["){n+="[",t++,a(),h(",")&&a();let V=!0;for(;t<e.length&&e[t]!=="]";)if(V?V=!1:f(",")||(n=Mt(n,",")),g(),!s()){n=$r(n,",");break}return e[t]==="]"?(n+="]",t++):n=Mt(n,"]"),!0}return!1}function b(){let V=!0,ne=!0;for(;ne;)V?V=!1:f(",")||(n=Mt(n,",")),ne=s();ne||(n=$r(n,",")),n=`[
104
- ${n}
105
- ]`}function E(){let V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,S=e[t]==="\\";if(S&&(t++,S=!0),Ji(e[t])){const le=Mc(e[t])?Mc:$c(e[t])?$c:lo(e[t])?lo:Wm,B=t,y=n.length;let W='"';for(t++;;){if(t>=e.length){const X=q(t-1);return!V&&Ri(e.charAt(X))?(t=B,n=n.substring(0,y),E(!0)):(W=Mt(W,'"'),n+=W,!0)}if(t===ne)return W=Mt(W,'"'),n+=W,!0;if(le(e[t])){const X=t,Y=W.length;if(W+='"',t++,n+=W,a(!1),V||t>=e.length||Ri(e[t])||Ji(e[t])||Cn(e[t]))return m(),!0;const re=q(X-1),D=e.charAt(re);if(D===",")return t=B,n=n.substring(0,y),E(!1,re);if(Ri(D))return t=B,n=n.substring(0,y),E(!0);n=n.substring(0,y),t=X+1,W=`${W.substring(0,Y)}\\${W.substring(Y)}`}else if(V&&Dc(e[t])){if(e[t-1]===":"&&Oc.test(e.substring(B+1,t+2)))for(;t<e.length&&Pc.test(e[t]);)W+=e[t],t++;return W=Mt(W,'"'),n+=W,m(),!0}else if(e[t]==="\\"){const X=e.charAt(t+1);if(oz[X]!==void 0)W+=e.slice(t,t+2),t+=2;else if(X==="u"){let re=2;for(;re<6&&XA(e[t+re]);)re++;re===6?(W+=e.slice(t,t+6),t+=6):t+re>=e.length?t=e.length:Z()}else W+=X,t+=2}else{const X=e.charAt(t);X==='"'&&e[t-1]!=="\\"?(W+=`\\${X}`,t++):tz(X)?(W+=az[X],t++):(QA(X)||z(X),W+=X,t++)}S&&p()}}return!1}function m(){let V=!1;for(a();e[t]==="+";){V=!0,t++,a(),n=$r(n,'"',!0);const ne=n.length;E()?n=iz(n,ne,1):n=Mt(n,'"')}return V}function O(){const V=t;if(e[t]==="-"){if(t++,j())return T(V),!0;if(!Cn(e[t]))return t=V,!1}for(;Cn(e[t]);)t++;if(e[t]==="."){if(t++,j())return T(V),!0;if(!Cn(e[t]))return t=V,!1;for(;Cn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,j())return T(V),!0;if(!Cn(e[t]))return t=V,!1;for(;Cn(e[t]);)t++}if(!j())return t=V,!1;if(t>V){const ne=e.slice(V,t),S=/^0\d/.test(ne);return n+=S?`"${ne}"`:ne,!0}return!1}function N(){return w("true","true")||w("false","false")||w("null","null")||w("True","true")||w("False","false")||w("None","null")}function w(V,ne){return e.slice(t,t+V.length)===V?(n+=ne,t+=V.length,!0):!1}function k(V){const ne=t;if(Ac(e[t])){for(;t<e.length&&zc(e[t]);)t++;let S=t;for(;Tn(e,S);)S++;if(e[S]==="(")return t=S+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Dc(e[t])&&!Ji(e[t])&&(!V||e[t]!==":");)t++;if(e[t-1]===":"&&Oc.test(e.substring(ne,t+2)))for(;t<e.length&&Pc.test(e[t]);)t++;if(t>ne){for(;Tn(e,t-1)&&t>0;)t--;const S=e.slice(ne,t);return n+=S==="undefined"?"null":JSON.stringify(S),e[t]==='"'&&t++,!0}}function R(){if(e[t]==="/"){const V=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(V,t)),!0}}function q(V){let ne=V;for(;ne>0&&Tn(e,ne);)ne--;return ne}function j(){return t>=e.length||Ri(e[t])||Tn(e,t)}function T(V){n+=`${e.slice(V,t)}0`}function z(V){throw new Yn(`Invalid character ${JSON.stringify(V)}`,t)}function P(){throw new Yn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function I(){throw new Yn("Unexpected end of json string",e.length)}function M(){throw new Yn("Object key expected",t)}function J(){throw new Yn("Colon expected",t)}function Z(){const V=e.slice(t,t+6);throw new Yn(`Invalid unicode character "${V}"`,t)}}function lz(e,t){return e[t]==="*"&&e[t+1]==="/"}function uz({json:e,context:t,scope:n}){const[r,i]=x.useState(!1),[s,a]=x.useState(null),o=x.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return Fc(e)}catch{}const b=`{${e}}`;try{return JSON.parse(b),b}catch{}try{return Fc(b)}catch{return null}},[e]),l=x.useMemo(()=>Lm(o||e),[o,e]),c=Ne(b=>b.activeTab),d=Ne(b=>b.documents),f=Ne(b=>(b.acceptedApplyIds||[]).includes(l)),h=Ne(b=>b.setPendingDiff),p=Ne(b=>b.createDocument),g=Ne(b=>b.openDocument),v=x.useCallback(()=>{if(o){a(null);try{if(c){const b=d.find(w=>w.name===c),E=(b==null?void 0:b.text)||"";if(n==="templates")try{const w=JSON.parse(E),k=JSON.parse(o);if(Array.isArray(k.templates)){w.props||(w.props={}),w.props.templates=Fm(w.props.templates||[],k.templates);const R=JSON.stringify(w,null,2);h(c,E,R,l);return}}catch{}const m=t==null?void 0:t[0],{original:O,modified:N}=Bm(E,o,m);h(c,O,N,l)}else{const b=`ai-generated-${Date.now()}`;p(b,o),g(b)}}catch(b){a(b instanceof Error?b.message:"Merge failed")}}},[o,c,d,h,p,g,t,n,l]),_=x.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return u.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[u.jsxs("div",{className:"flex gap-1.5",children:[u.jsx(Se,{variant:"secondary",size:"sm",onClick:v,disabled:f||!o,children:f?"Applied":o?"Apply to Editor":"Invalid JSON"}),u.jsx(Se,{variant:"ghost",size:"sm",onClick:_,children:r?u.jsx(an,{className:"h-3.5 w-3.5"}):u.jsx(ks,{className:"h-3.5 w-3.5"})})]}),s&&u.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function cz({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=x.useState(null),[c,d]=x.useState(""),[f,h]=x.useState(null),p=x.useRef(null),g=(t==null?void 0:t.title)||"New Chat",v=g.length>24?g.slice(0,24)+"...":g;x.useEffect(()=>{o&&requestAnimationFrame(()=>{var k;return(k=p.current)==null?void 0:k.focus()})},[o]);const _=x.useCallback((k,R)=>{R.stopPropagation(),R.preventDefault(),l(k.id),d(k.title),h(null)},[]),b=x.useCallback(()=>{o&&c.trim()&&a(o,c.trim()),l(null),d("")},[o,c,a]),E=x.useCallback(()=>{l(null),d("")},[]),m=x.useCallback(k=>{k.stopPropagation(),k.key==="Enter"?(k.preventDefault(),b()):k.key==="Escape"&&(k.preventDefault(),E())},[b,E]),O=x.useCallback((k,R)=>{R.stopPropagation(),R.preventDefault(),h(k),l(null)},[]),N=x.useCallback(k=>{k.stopPropagation(),k.preventDefault(),f&&(s(f),h(null))},[f,s]),w=x.useCallback(k=>{k.stopPropagation(),k.preventDefault(),h(null)},[]);return u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(Ns,{onOpenChange:k=>{k||(l(null),h(null))},children:[u.jsx(Es,{asChild:!0,disabled:n,children:u.jsxs("button",{className:"flex items-center gap-1 text-sm font-semibold tracking-tight hover:text-foreground/80 transition-colors max-w-[180px] cursor-pointer",children:[u.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),u.jsx("span",{className:"truncate",children:v}),u.jsx(mi,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),u.jsxs(yi,{align:"start",className:"w-64",children:[e.map(k=>{const R=o===k.id;return f===k.id?u.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[u.jsx("span",{className:"text-destructive text-xs flex-1 truncate",children:"Delete this thread?"}),u.jsx("button",{className:"shrink-0 text-destructive hover:text-destructive/80 transition-colors cursor-pointer",onClick:N,children:u.jsx(an,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:w,children:u.jsx(yn,{className:"h-3.5 w-3.5"})})]},k.id):R?u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:j=>j.stopPropagation(),onPointerDown:j=>j.stopPropagation(),children:[u.jsx("input",{ref:p,type:"text",value:c,onChange:j=>d(j.target.value),onKeyDown:m,onBlur:b,className:"flex-1 min-w-0 text-sm rounded-sm border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),u.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:j=>{j.preventDefault(),b()},children:u.jsx(an,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:j=>{j.preventDefault(),E()},children:u.jsx(yn,{className:"h-3.5 w-3.5"})})]},k.id):u.jsxs($t,{onSelect:()=>r(k.id),className:`group ${k.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[u.jsx("span",{className:"truncate flex-1",children:k.title.length>30?k.title.slice(0,30)+"...":k.title}),u.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[u.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:j=>_(k,j),children:u.jsx(nx,{className:"h-3 w-3"})}),e.length>1&&u.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",onClick:j=>O(k.id,j),children:u.jsx(fo,{className:"h-3 w-3"})})]})]},k.id)}),u.jsx(mr,{}),u.jsxs($t,{onSelect:k=>{k.preventDefault();const R=i();R&&(l(R),d(vo()),h(null))},children:[u.jsx(nn,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),u.jsx(Se,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:u.jsx(nn,{className:"h-3.5 w-3.5"})})]})}const qm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),dz=Array.from(qm).join(","),fz=20*1024*1024,Lc=10;function pz(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t({type:"file",mediaType:e.type,filename:e.name,url:r.result}),r.onerror=n,r.readAsDataURL(e)})}function Bc(e){return Array.from(e).filter(t=>qm.has(t.type)&&t.size<=fz)}function Gm(e){return e.startsWith("image/")}function Zc(){var Q,he,ve;const e=Oe(F=>F.contextAttachments),t=Oe(F=>F.addContext),n=Oe(F=>F.removeContext),r=Oe(F=>F.scope),i=Oe(F=>F.setScope),s=Oe(F=>F.model),a=Oe(F=>F.setModel),o=Oe(F=>F.openChat),l=Oe(F=>F.closeChat),c=Oe(F=>F.threads),d=Oe(F=>F.activeThreadId),f=Oe(F=>F.createThread),h=Oe(F=>F.deleteThread),p=Oe(F=>F.switchThread),g=Oe(F=>F.updateThreadMessages),v=Oe(F=>F.updateThreadTitle),_=Oe(F=>F.deleteThreadsForDocument),b=Ne(F=>F.activeTab),E=Ne(F=>F.documents),{messages:m,sendMessage:O,status:N,error:w,setMessages:k,stop:R,getMessageContext:q,getMessageScope:j}=LA(),[T,z]=x.useState(""),[P,I]=x.useState([]),[M,J]=x.useState(!1),[Z,V]=x.useState(!1),ne=x.useRef(null),S=x.useRef(null),le=x.useRef(null),B=x.useCallback(async F=>{const me=Bc(F);if(me.length===0)return;const Te=await Promise.all(me.map(pz));I(Le=>{const rt=[...Le,...Te];return rt.length>Lc?rt.slice(0,Lc):rt})},[]),y=x.useCallback(F=>{I(me=>me.filter((Te,Le)=>Le!==F))},[]),W=x.useCallback(F=>{var Te;const me=(Te=F.clipboardData)==null?void 0:Te.files;if(me&&me.length>0){const Le=Bc(me);Le.length>0&&(F.preventDefault(),B(Le))}},[B]),X=x.useCallback(F=>{var Te;F.preventDefault(),V(!1);const me=(Te=F.dataTransfer)==null?void 0:Te.files;me&&me.length>0&&B(Array.from(me))},[B]),Y=x.useCallback(F=>{F.preventDefault(),V(!0)},[]),re=x.useCallback(()=>V(!1),[]),D=b?d[b]:void 0,de=D?c[D]:void 0,te=x.useMemo(()=>b?Object.values(c).filter(F=>F.documentName===b).sort((F,me)=>me.updatedAt-F.updatedAt):[],[c,b]);x.useEffect(()=>{b&&te.length===0&&f(b)},[b,te.length,f]);const ae=x.useRef(c);ae.current=c,x.useEffect(()=>{const F=new Set(E.map(Te=>Te.name)),me=new Set;for(const Te of Object.values(ae.current))!F.has(Te.documentName)&&Te.documentName!=="__migrated__"&&me.add(Te.documentName);for(const Te of me)_(Te)},[E,_]);const ue=x.useRef(null);x.useEffect(()=>{ue.current!==D&&(ue.current=D,k((de==null?void 0:de.messages)??[]))},[D,de,k]),x.useEffect(()=>{var F;(F=ne.current)==null||F.scrollIntoView({behavior:"smooth"})},[m,N]),x.useEffect(()=>{const F=me=>{var rt;const{documentName:Te,selection:Le}=me.detail;t({...Le,documentName:Te}),o(),(rt=S.current)==null||rt.focus()};return window.addEventListener("monaco-selection-to-ai",F),()=>window.removeEventListener("monaco-selection-to-ai",F)},[t,o]);const ge=N==="streaming",pe=N==="submitted"||ge,Pe=x.useCallback(F=>{F.preventDefault(),!(!T.trim()&&P.length===0||pe)&&(O(T,P.length>0?P:void 0),z(""),I([]))},[T,P,pe,O]),De=x.useCallback(F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),Pe(F))},[Pe]),nt=x.useCallback(()=>{m.length!==0&&J(!0)},[m.length]),C=x.useCallback(()=>{J(!1),k([]),D&&(g(D,[]),v(D,vo()))},[k,D,g,v]),[$,U]=x.useState(null),se=x.useCallback(F=>{U(F)},[]),A=x.useCallback(()=>{var rt,et;if(!$)return;const F=m.findIndex(at=>at.id===$);if(F===-1){U(null);return}const me=m[F],Te=new Set([F]);me.role==="user"&&((rt=m[F+1])==null?void 0:rt.role)==="assistant"?Te.add(F+1):me.role==="assistant"&&F>0&&((et=m[F-1])==null?void 0:et.role)==="user"&&Te.add(F-1);const Le=m.filter((at,un)=>!Te.has(un));k(Le),D&&g(D,Le),U(null)},[$,m,k,D,g]),K=x.useCallback(F=>{if(!pe){if(te.length<=1){nt();return}h(F)}},[pe,te.length,nt,h]),ee=x.useCallback(()=>{if(!(!b||pe))return f(b)},[b,pe,f]),xe=x.useCallback(F=>{pe||F===D||p(F)},[pe,D,p]),L=x.useCallback((F,me)=>{v(F,me)},[v]);return u.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[u.jsx(cz,{threads:te,activeThread:de,disabled:pe,onSwitch:xe,onCreate:ee,onDelete:K,onRename:L}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Se,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:nt,disabled:pe||m.length===0,children:"Clear"}),u.jsx(Se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:u.jsx(yn,{className:"h-3.5 w-3.5"})})]})]}),u.jsx(ri,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:u.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[m.length===0&&u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[u.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:u.jsx(il,{className:"h-5 w-5 text-primary"})}),u.jsx("p",{className:"text-sm font-medium text-foreground/80 mb-1",children:"JSON Assistant"}),u.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[200px] mb-4",children:"Generate, edit, and refine your JSON document definitions with AI."}),u.jsxs("div",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2.5 py-1.5",children:[u.jsx(ii,{shortcut:"mod+k"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),m.map((F,me)=>{let Te;if(F.role==="user"){const et=q(F.id);et&&et.length>0&&(Te=et)}else if(F.role==="assistant"){for(let et=me-1;et>=0;et--)if(m[et].role==="user"){Te=q(m[et].id);break}}const Le=ge&&me===m.length-1&&F.role==="assistant",rt=F.role==="user"?j(F.id):void 0;return u.jsx(hz,{msg:F,isStreaming:Le,context:Te,scope:rt,onDelete:pe?void 0:se},F.id)}),pe&&((Q=m[m.length-1])==null?void 0:Q.role)!=="assistant"&&u.jsx("div",{className:"flex justify-start",children:u.jsx("div",{className:"rounded-lg px-3 py-2 bg-muted/60 border border-border/40",children:u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(Fr,{className:"h-3.5 w-3.5 animate-spin text-primary"}),u.jsx("span",{children:"Thinking..."})]})})}),w&&!pe&&u.jsx("div",{className:"flex justify-start",children:u.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:w.message||"Something went wrong"})}),u.jsx("div",{ref:ne})]})}),u.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${Z?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:X,onDragOver:Y,onDragLeave:re,children:[e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((F,me)=>u.jsx(Vm,{context:F,onRemove:()=>n(me)},me))}),u.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u.jsx(xz,{model:s,setModel:a}),ht==="pptx"&&b&&u.jsx(bz,{scope:r,setScope:i,docSize:((ve=(he=E.find(F=>F.name===b))==null?void 0:he.text)==null?void 0:ve.length)??0})]}),P.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map((F,me)=>u.jsxs("div",{className:"relative group",children:[Gm(F.mediaType)?u.jsx("img",{src:F.url,alt:F.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):u.jsxs("div",{className:"h-14 px-2.5 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/60 max-w-[140px]",children:[u.jsx(Ta,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u.jsx("span",{className:"text-xs truncate text-muted-foreground",children:F.filename||"file"})]}),u.jsx("button",{type:"button",onClick:()=>y(me),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:u.jsx(yn,{className:"h-3 w-3"})})]},me))}),u.jsxs("form",{onSubmit:Pe,className:"flex items-end gap-2",children:[u.jsx("input",{ref:le,type:"file",accept:dz,multiple:!0,className:"hidden",onChange:F=>{F.target.files&&B(Array.from(F.target.files)),F.target.value=""}}),u.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var F;return(F=le.current)==null?void 0:F.click()},title:"Attach file",children:u.jsx(Ta,{className:"h-4 w-4"})}),u.jsx("textarea",{ref:S,value:T,onChange:F=>{z(F.target.value);const me=F.target;me.style.height="auto",me.style.height=`${Math.min(me.scrollHeight,128)}px`},onKeyDown:De,onPaste:W,placeholder:e.length>0?"Describe how to edit the selection...":r==="slides"?"Add, edit, or remove slides...":r==="templates"?"Edit template layouts and placeholders...":"Ask AI to generate or edit JSON...",className:"flex-1 min-h-[36px] max-h-32 resize-none overflow-y-auto rounded-lg border border-border/60 bg-background px-3 py-1.5 text-sm placeholder:text-muted-foreground placeholder:whitespace-nowrap placeholder:overflow-hidden placeholder:text-ellipsis focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:border-primary/50 transition-shadow",rows:1}),pe?u.jsx(Se,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:R,title:"Stop generating",children:u.jsx(zd,{className:"h-4 w-4"})}):u.jsx(Se,{type:"submit",size:"icon",disabled:!T.trim()&&P.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:u.jsx(il,{className:"h-4 w-4"})})]})]}),u.jsx(Ct,{open:M,onOpenChange:J,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Clear thread"}),u.jsx(on,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),u.jsxs(bn,{children:[u.jsx(al,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Se,{variant:"destructive",size:"sm",onClick:C,children:"Clear"})]})]})}),u.jsx(Ct,{open:$!==null,onOpenChange:F=>{F||U(null)},children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Vt,{children:[u.jsx(Ut,{children:"Delete message"}),u.jsx(on,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),u.jsxs(bn,{children:[u.jsx(al,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Se,{variant:"destructive",size:"sm",onClick:A,children:"Delete"})]})]})})]})}const hz=x.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,c;const a=((l=t.parts)==null?void 0:l.filter(d=>d.type==="text").map(d=>d.text).join(""))||"",o=((c=t.parts)==null?void 0:c.filter(d=>d.type==="file"))||[];return u.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:u.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?u.jsxs("div",{children:[o.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((d,f)=>Gm(d.mediaType)?u.jsx("img",{src:d.url,alt:d.filename||"image",className:"h-20 max-w-[160px] rounded-sm object-cover"},f):u.jsxs("div",{className:"flex items-center gap-1.5 rounded-sm bg-primary-foreground/20 px-2 py-1",children:[u.jsx(Ta,{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"text-xs truncate max-w-[120px]",children:d.filename||"file"})]},f))}),r&&r.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((d,f)=>u.jsx(Vm,{context:d,variant:"sent"},f))}),a&&u.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&u.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):u.jsx(mz,{text:a,isStreaming:n,context:r,scope:i}),s&&!n&&u.jsx("div",{className:"opacity-0 transition-opacity group-hover/msg:opacity-100 focus-within:opacity-100 mt-1",children:u.jsx("button",{type:"button","aria-label":"Delete message",onClick:()=>s(t.id),className:`p-0.5 rounded-sm cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:u.jsx(fo,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.msg===t.msg&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function mz({text:e,isStreaming:t,context:n,scope:r}){return t?u.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1",children:u.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm m-0 p-0 bg-transparent border-none",children:e})}):u.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert break-words [&_pre]:overflow-x-auto [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_h1]:my-2 [&_h2]:my-1.5 [&_h3]:my-1",children:u.jsx(Z1,{remarkPlugins:[tj],components:{pre:({children:i})=>u.jsx(u.Fragment,{children:i}),code:({className:i,children:s})=>{const a=i==null?void 0:i.startsWith("language-"),o=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!a)return u.jsx("code",{className:"rounded-sm bg-muted px-1 py-0.5 text-xs font-mono",children:s});const c=o==="json"||o==="jsonc";return u.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[u.jsx("span",{className:"font-mono",children:o||"code"}),!c&&u.jsx(vz,{text:l})]}),u.jsx("pre",{className:"p-3 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto m-0",children:u.jsx("code",{children:l})}),c&&u.jsx(uz,{json:l,context:n,scope:r})]})}},children:e})})}const gz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function xz({model:e,setModel:t}){return u.jsxs(ti,{value:e,onValueChange:n=>t(n),children:[u.jsx(fr,{className:"h-6 w-auto gap-1 border-none bg-muted/40 px-2 py-0 text-[10px] shadow-none focus:ring-0",children:u.jsx(ni,{})}),u.jsx(pr,{children:gz.map(n=>u.jsx(Pn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const Vc={global:"AI sees and edits the entire document",slides:"AI sees and edits only slides — templates stay unchanged",templates:"AI sees and edits only template layouts — slides stay unchanged"},yz=1e5;function bz({scope:e,setScope:t,docSize:n}){return u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Scope"}),u.jsx("div",{className:"flex items-center bg-muted/40 rounded-md p-0.5 gap-px",children:Object.keys(Vc).map(r=>u.jsxs(Ge,{children:[u.jsx(Ye,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded-sm text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),u.jsx(Ke,{side:"top",className:"text-xs max-w-[200px]",children:Vc[r]})]},r))})]}),e==="global"&&n>yz&&u.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[u.jsx(Dd,{className:"h-3 w-3 shrink-0"}),u.jsxs("span",{children:["Large doc — switch to"," ",u.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-warning/80",children:"slides"})," ","or"," ",u.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-warning/80",children:"templates"})]})]})]})}function vz({text:e}){const[t,n]=x.useState(!1),r=x.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return u.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function wz({discoveryData:e}){const t=vf(),n=fy(),r=Oe(j=>j.chatOpen),i=Oe(j=>j.toggleChat),[s,a]=x.useState(()=>{try{const j=localStorage.getItem("dev-env.sidebar-open");return n?!1:j?j==="true":!0}catch{return!n}}),[o,l]=x.useState(()=>{try{const j=localStorage.getItem("dev-env.preview-open");return j?j==="true":!0}catch{return!0}}),[c,d]=x.useState("editor"),[f,h]=x.useState(!1),p=150,[g,v]=x.useState(!s),[_,b]=x.useState(!1);x.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),x.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const E=x.useRef(n);x.useEffect(()=>{n&&!E.current&&s&&(b(!0),a(!1),setTimeout(()=>{v(!0),b(!1)},p)),!n&&E.current&&!s&&(b(!0),a(!0),setTimeout(()=>{v(!1),b(!1)},p)),E.current=n},[n,s]);const m=x.useCallback(()=>{if(t){h(j=>!j);return}b(!0),a(j=>!j),setTimeout(()=>{v(j=>!j),b(!1)},p)},[t]),O=x.useCallback(()=>l(j=>!j),[]),N=x.useRef(i),w=x.useRef(m),k=x.useRef(O);x.useEffect(()=>{N.current=i}),x.useEffect(()=>{w.current=m}),x.useEffect(()=>{k.current=O}),x.useEffect(()=>{const j=T=>{(T.metaKey||T.ctrlKey)&&(T.code==="KeyB"&&!T.shiftKey&&(T.preventDefault(),w.current()),T.code==="KeyJ"&&T.shiftKey&&(T.preventDefault(),T.stopPropagation(),N.current()),T.code==="KeyP"&&T.shiftKey&&(T.preventDefault(),k.current()))};return window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)},[]);const R=FA,q=[{key:"editor",icon:Ca,label:"Editor"},{key:"preview",icon:Rd,label:"Preview"},{key:"chat",icon:Md,label:"Chat"}];return t?u.jsx(R,{children:u.jsxs("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[u.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-sidebar shrink-0",children:[u.jsxs(xf,{open:f,onOpenChange:h,children:[u.jsx(oy,{asChild:!0,children:u.jsx(Se,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:u.jsx(Pd,{className:"h-4 w-4"})})}),u.jsx(So,{side:"left",className:"p-0 w-72",children:u.jsx(Tl,{discoveryData:e,onToggleSidebar:()=>h(!1),isCollapsed:!1})})]}),u.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:q.map(({key:j,icon:T,label:z})=>u.jsxs(Se,{variant:c===j?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>d(j),children:[u.jsx(T,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"hidden xs:inline",children:z})]},j))})]}),c!=="chat"&&u.jsx(Xl,{previewOpen:o,onTogglePreview:O}),u.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(Il,{})}),c==="preview"&&u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Al,{})}),c==="chat"&&u.jsx(Zc,{})]})]})}):u.jsx(R,{children:u.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[u.jsx("div",{className:G("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]",s?"w-64":"w-12"),children:u.jsx(Tl,{discoveryData:e,onToggleSidebar:m,isCollapsed:g,isAnimating:_})}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[u.jsx(Xl,{previewOpen:o,onTogglePreview:O}),u.jsxs(Hb,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[u.jsx(Qs,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(Il,{})})}),o&&u.jsxs(u.Fragment,{children:[u.jsx(Bl,{withHandle:!0}),u.jsx(Qs,{defaultSize:50,minSize:20,id:"preview",order:2,children:u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Al,{})})})]}),r&&u.jsxs(u.Fragment,{children:[u.jsx(Bl,{withHandle:!0}),u.jsx(Qs,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:u.jsx(Zc,{})})]})]})]})]})})}function kz(){const[e,t]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState(null),a=x.useCallback(async()=>{r(!0),s(null);try{const o=await fetch("/api/discovery/all");if(!o.ok)throw new Error(`Discovery failed: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(o){console.error("Discovery error:",o),s(o instanceof Error?o.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return x.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}let Mi=null;async function Sz(){const e=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!e.ok)throw new Error(`Failed to load plugins: ${e.statusText}`);const t=await e.json();if(!t.success)throw new Error(t.error||"Failed to load plugins");return t.data.loaded}function _z(){const[e,t]=x.useState(!1),[n,r]=x.useState(null),[i,s]=x.useState(0);return{loadPlugins:x.useCallback(async()=>{t(!0),r(null);try{Mi||(Mi=Sz().finally(()=>{Mi=null}));const o=await Mi;return s(o),!0}catch(o){return console.error("Plugin loading error:",o),r(o instanceof Error?o.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function jz(){const{data:e,loading:t,error:n}=kz(),{loadPlugins:r}=_z(),i=Lt(s=>s.applyPluginsWithValidation);return x.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Lt.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),u.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):u.jsx(sx,{children:u.jsx(ax,{children:u.jsx(ox,{children:u.jsx(lx,{children:u.jsx(ux,{children:u.jsx(Ux,{children:u.jsx(kf,{children:u.jsx("section",{className:"flex h-screen w-full flex-col",children:u.jsx("div",{className:"grow overflow-hidden",children:u.jsx(wz,{discoveryData:e})})})})})})})})})})}const Rz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:jz},Symbol.toStringTag,{value:"Module"}));export{Kt as B,Ct as D,Rz as H,Wr as L,sv as P,Gb as Q,Yr as S,ur as T,ip as a,ti as b,fr as c,ni as d,pr as e,Pn as f,Dz as g,gf as h,kt as i,Vt as j,Ut as k,Kb as l,By as p,Qb as u};
106
- //# sourceMappingURL=HomePage-CeUQIXch.js.map