@json-to-office/jto 0.33.2 → 0.35.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 (42) hide show
  1. package/dist/cli.js +214 -516
  2. package/dist/cli.js.map +1 -1
  3. package/dist/client/assets/HomePage-DgVVosCp.js +106 -0
  4. package/dist/client/assets/HomePage-DgVVosCp.js.map +1 -0
  5. package/dist/client/assets/{JsonEditorPage-GZV7oJD2.js → JsonEditorPage-13oxEHfY.js} +3 -3
  6. package/dist/client/assets/{JsonEditorPage-GZV7oJD2.js.map → JsonEditorPage-13oxEHfY.js.map} +1 -1
  7. package/dist/client/assets/{MonacoPluginProvider-btNzJ41o.js → MonacoPluginProvider-DiUyU9px.js} +3 -3
  8. package/dist/client/assets/{MonacoPluginProvider-btNzJ41o.js.map → MonacoPluginProvider-DiUyU9px.js.map} +1 -1
  9. package/dist/client/assets/editor-monaco-json-CTrPZKuA.js +24 -0
  10. package/dist/client/assets/{editor-monaco-json-rhvIaBDI.js.map → editor-monaco-json-CTrPZKuA.js.map} +1 -1
  11. package/dist/client/assets/{editor-Cugq4RzH.js → editor-ouhvdGgK.js} +2 -2
  12. package/dist/client/assets/{editor-Cugq4RzH.js.map → editor-ouhvdGgK.js.map} +1 -1
  13. package/dist/client/assets/{editor-refs-store-DeJZ8FB9.js → editor-refs-store-DNQzN0_z.js} +2 -2
  14. package/dist/client/assets/{editor-refs-store-DeJZ8FB9.js.map → editor-refs-store-DNQzN0_z.js.map} +1 -1
  15. package/dist/client/assets/index-CRuLxurM.js +5 -0
  16. package/dist/client/assets/index-CRuLxurM.js.map +1 -0
  17. package/dist/client/assets/index-CnUTzeor.css +1 -0
  18. package/dist/client/assets/preview-D3QYaLPp.js +4 -0
  19. package/dist/client/assets/preview-D3QYaLPp.js.map +1 -0
  20. package/dist/client/assets/{ui-vendor-Cs3OXpi7.js → ui-vendor-DyQLnWB8.js} +16 -11
  21. package/dist/client/assets/ui-vendor-DyQLnWB8.js.map +1 -0
  22. package/dist/client/index.html +3 -3
  23. package/dist/client/templates/Alternative deck 16_9.pptx.json +91 -49
  24. package/dist/client/templates/Company deck 16_9.pptx.json +134 -70
  25. package/dist/client/templates/Company deck 4_3.pptx.json +84 -44
  26. package/dist/client/templates/data-report-presentation.pptx.json +100 -52
  27. package/dist/client/templates/modern-annual-report-1.docx.json +207 -116
  28. package/dist/client/templates/modern-annual-report-2.docx.json +52 -37
  29. package/dist/client/templates/modern-annual-report-3.docx.json +40 -20
  30. package/dist/client/templates/tech-report.docx.json +96 -48
  31. package/dist/render-server.js +168 -106
  32. package/dist/render-server.js.map +1 -1
  33. package/package.json +7 -8
  34. package/dist/client/assets/HomePage-Cq6woGMG.js +0 -106
  35. package/dist/client/assets/HomePage-Cq6woGMG.js.map +0 -1
  36. package/dist/client/assets/editor-monaco-json-rhvIaBDI.js +0 -24
  37. package/dist/client/assets/index-C9ply7vX.css +0 -1
  38. package/dist/client/assets/index-C9uVroFQ.js +0 -5
  39. package/dist/client/assets/index-C9uVroFQ.js.map +0 -1
  40. package/dist/client/assets/preview-B_B09gpA.js +0 -3
  41. package/dist/client/assets/preview-B_B09gpA.js.map +0 -1
  42. package/dist/client/assets/ui-vendor-Cs3OXpi7.js.map +0 -1
@@ -0,0 +1,106 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-ouhvdGgK.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-CTrPZKuA.js","assets/index-CRuLxurM.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-Bq-7y_Sq.js","assets/ui-vendor-DyQLnWB8.js","assets/monaco-editor-BcgxPCqT.js","assets/state-vendor-ByFYl9bq.js","assets/index-CnUTzeor.css","assets/editor-refs-store-DNQzN0_z.js","assets/MonacoPluginProvider-DiUyU9px.js","assets/preview-D3QYaLPp.js"])))=>i.map(i=>d[i]);
2
+ var Um=Object.defineProperty;var Jm=(e,t,n)=>t in e?Um(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var el=(e,t,n)=>Jm(e,typeof t!="symbol"?t+"":t,n);import{r as x,j as u,c as je,R as Fc,g as la}from"./react-vendor-CTFDOf2G.js";import{b as Lc,c as ua,d as Bc,e as xs,f as ys,D as bs,O as vs,g as Hm,V as Wm,h as Zc,I as qm,i as Gm,j as Vc,k as Ym,l as Uc,m as Km,n as Xm,G as Qm,S as Jc,o as Hc,L as Wc,p as qc,q as Gc,r as _r,s as eg,t as tg,u as ng,v as Yc,w as Kc,x as Xc,y as Qc,z as ed,B as td,E as nd,F as rd,H as id,J as rg,K as ig,M as sg,N as sd,Q as od,U as ad,W as ld,X as ud,Y as cd,Z as dd,_ as fd,$ as pd,a0 as hd,a1 as og,a2 as md,a3 as ag,a4 as lg,a5 as gd,a6 as ug,a7 as cg,a8 as dg,a9 as fg,aa as pg,ab as hg,ac as mg,ad as xd,ae as yd,af as bd}from"./radix-ui-Bq-7y_Sq.js";import{c as G,u as jr,S as sn,A as Ji,T as Si,C as gg,E as xg,F as ot,a as yg,b as bg,d as qe,e as Ge,f as Ye,g as vd,_ as wd,h as _i,i as vg,j as wg,k as kg,l as Ir,s as Zs,W as kd,m as $i}from"./index-CRuLxurM.js";import{X as xn,C as hi,a as yn,b as Sg,d as mi,G as Sd,F as _g,e as Pn,f as _d,P as jg,g as Ng,h as jd,E as Nd,B as _o,H as Eg,T as jo,L as tl,i as Cg,j as Tg,S as Ed,I as Ig,k as Ag,l as No,m as zg,n as Og,o as Pg,p as Dg,q as Rg,r as Mg,s as $g,t as Fg,u as ws,v as Lg,M as Bg,w as Cd,x as nn,y as Zg,z as Vg,A as Td,D as Ug,J as Jg,K as Hg,N as Wg,R as qg,O as Gg,Q as Id,U as Yg,V as Eo,W as ca,Y as Ad,Z as Kg,_ as zd,$ as Lr,a0 as Xg,a1 as Qg,a2 as ex,a3 as nl,a4 as Co}from"./ui-vendor-DyQLnWB8.js";import{B as _e,u as tx,d as rl}from"./editor-refs-store-DNQzN0_z.js";import{u as Ce,i as nx,a as To,b as rn,g as rx,c as Bt,T as Od,d as ji,S as ix,O as sx,e as ox,M as ax,D as lx}from"./MonacoPluginProvider-DiUyU9px.js";import{u as da,a as ux,d as cx,p as dx,b as fx,e as px}from"./state-vendor-ByFYl9bq.js";import{b as hx}from"./query-vendor-Df8-oete.js";const Ct=Lc,mx=Bc,il=ua,Pd=x.forwardRef(({className:e,...t},n)=>u.jsx(vs,{ref:n,className:G("fixed inset-0 z-50 bg-black/50",e),...t}));Pd.displayName=vs.displayName;const kt=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(mx,{children:[u.jsx(Pd,{}),u.jsxs(xs,{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(ua,{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(xn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));kt.displayName=xs.displayName;const Ut=({className:e,...t})=>u.jsx("div",{className:G("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ut.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 Jt=x.forwardRef(({className:e,...t},n)=>u.jsx(ys,{ref:n,className:G("text-lg leading-none font-semibold tracking-tight",e),...t}));Jt.displayName=ys.displayName;const an=x.forwardRef(({className:e,...t},n)=>u.jsx(bs,{ref:n,className:G("text-muted-foreground text-sm",e),...t}));an.displayName=bs.displayName;const ei=Hm,gx=Qm,ti=Wm,hr=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zc,{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(qm,{asChild:!0,children:u.jsx(hi,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));hr.displayName=Zc.displayName;const Dd=x.forwardRef(({className:e,...t},n)=>u.jsx(Jc,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(Sg,{className:"h-4 w-4"})}));Dd.displayName=Jc.displayName;const Rd=x.forwardRef(({className:e,...t},n)=>u.jsx(Hc,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(hi,{className:"h-4 w-4"})}));Rd.displayName=Hc.displayName;const mr=x.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>u.jsx(Gm,{children:u.jsxs(Vc,{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(Dd,{}),u.jsx(Ym,{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(Rd,{})]})}));mr.displayName=Vc.displayName;const Md=x.forwardRef(({className:e,...t},n)=>u.jsx(Wc,{ref:n,className:G("px-2 py-1.5 text-sm font-semibold",e),...t}));Md.displayName=Wc.displayName;const Dn=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Uc,{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(Km,{children:u.jsx(yn,{className:"h-4 w-4"})})}),u.jsx(Xm,{children:t})]}));Dn.displayName=Uc.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 gr=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}));gr.displayName="Input";const yx=mi("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),sr=x.forwardRef(({className:e,...t},n)=>u.jsx(Gc,{ref:n,className:G(yx(),e),...t}));sr.displayName=Gc.displayName;const bx=mi("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:o}=Ce(da(T=>({documents:T.documents,documentTypes:T.documentTypes,activeTab:T.activeTab,createDocument:T.createDocument,openDocument:T.openDocument}))),{toast:a}=jr(),l=x.useMemo(()=>n.filter(T=>r[T.name]!=="application/json+theme"),[n,r]),[c,d]=x.useState(""),[f,p]=x.useState(""),[h,g]=x.useState("playground"),[v,S]=x.useState(!1),[y,j]=x.useState(null),[m,A]=x.useState(null),[C,w]=x.useState(null),N=()=>{j(null),A(null),w(null)};x.useEffect(()=>{if(!e)return;j(null),A(null),w(null);const T=l.map(z=>z.name),I=T.includes(i)?i:T[0]??"";p(I),d(T.find(z=>z!==I)??"")},[e]);const J=async()=>{const T=l.find(z=>z.name===c),I=l.find(z=>z.name===f);if(!(!T||!I)){S(!0),j(null),A(null),w(null);try{const z=await fetch(Ji.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:T.text,newDefinition:I.text,options:{author:h||"playground"}})}),O=await z.json();if(!z.ok||!O.success){const R=Array.isArray(O.errors)?`: ${O.errors.slice(0,3).map(Y=>Y.message||String(Y)).join("; ")}`:"";throw new Error((O.error||`Diff failed (${z.status})`)+R)}A(O.data.summary),w(O.data.document)}catch(z){j(z instanceof Error?z.message:"Diff failed")}finally{S(!1)}}},D=()=>{if(!C)return;const T=new Set(n.map(O=>O.name));let I=`${f}-redline`,z=2;for(;T.has(I);)I=`${f}-redline-${z++}`;s(I,JSON.stringify(C,null,2)),o(I),a({title:`Redline created: ${I}`}),t(!1)},_=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(Ut,{children:[u.jsxs(Jt,{className:"flex items-center gap-2",children:[u.jsx(Sd,{className:"size-4"}),"Compare documents"]}),u.jsx(an,{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(sr,{htmlFor:"diff-base",children:"Base (old)"}),u.jsxs(ei,{value:c,onValueChange:T=>{d(T),N()},children:[u.jsx(hr,{id:"diff-base",children:u.jsx(ti,{placeholder:"Select document"})}),u.jsx(mr,{children:l.map(T=>u.jsx(Dn,{value:T.name,children:T.name},T.name))})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(sr,{htmlFor:"diff-revised",children:"Revised (new)"}),u.jsxs(ei,{value:f,onValueChange:T=>{p(T),N()},children:[u.jsx(hr,{id:"diff-revised",children:u.jsx(ti,{placeholder:"Select document"})}),u.jsx(mr,{children:l.map(T=>u.jsx(Dn,{value:T.name,children:T.name},T.name))})]})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(sr,{htmlFor:"diff-author",children:"Revision author"}),u.jsx(gr,{id:"diff-author",value:h,onChange:T=>{g(T.target.value),N()},placeholder:"playground"})]}),y&&u.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}),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"]})]}),_===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,I)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.path," [",T.component,"] ",T.detail]},I))]}),m.notes.map((T,I)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",T]},I))]})]}),u.jsx(bn,{children:m&&_+m.untracked.length>0?u.jsxs(_e,{onClick:D,children:[u.jsx(_g,{className:"size-4 mr-1"}),"Open redline"]}):u.jsxs(_e,{onClick:J,disabled:v||!c||!f||c===f,children:[v&&u.jsx(sn,{className:"size-4 mr-1"}),"Compare"]})})]})})};var gi=e=>e.type==="checkbox",In=e=>e instanceof Date,pt=e=>e==null;const $d=e=>typeof e=="object";var et=e=>!pt(e)&&!Array.isArray(e)&&$d(e)&&!In(e),Fd=e=>et(e)&&e.target?gi(e.target)?e.target.checked:e.target.value:e,wx=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Ld=(e,t)=>e.has(wx(t)),kx=e=>{const t=e.constructor&&e.constructor.prototype;return et(t)&&t.hasOwnProperty("isPrototypeOf")},fa=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(!(fa&&(e instanceof Blob||r))&&(n||et(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 ks=e=>Array.isArray(e)?e.filter(Boolean):[],Qe=e=>e===void 0,le=(e,t,n)=>{if(!t||!et(e))return n;const r=ks(t.split(/[,[\].]+?/)).reduce((i,s)=>pt(i)?i:i[s],e);return Qe(r)||r===e?Qe(e[t])?n:e[t]:r},zt=e=>typeof e=="boolean",pa=e=>/^\w*$/.test(e),Bd=e=>ks(e.replace(/["|']|\]/g,"").split(/\.|\[/)),$e=(e,t,n)=>{let r=-1;const i=pa(t)?[t]:Bd(t),s=i.length,o=s-1;for(;++r<s;){const a=i[r];let l=n;if(r!==o){const c=e[a];l=et(c)||Array.isArray(c)?c:isNaN(+i[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=l,e=e[a]}return e};const Hi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Lt={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"},Zd=je.createContext(null),Ss=()=>je.useContext(Zd),Sx=e=>{const{children:t,...n}=e;return je.createElement(Zd.Provider,{value:n},t)};var Vd=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const o=s;return t._proxyFormState[o]!==Lt.all&&(t._proxyFormState[o]=!r||Lt.all),n&&(n[o]=!0),e[o]}});return i},bt=e=>et(e)&&!Object.keys(e).length,Ud=(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(o=>t[o]===(!r||Lt.all))},qr=e=>Array.isArray(e)?e:[e],Jd=(e,t,n)=>!e||!t||e===t||qr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function ha(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=Ss(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[o,a]=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,ha({disabled:r,next:f=>l.current&&Jd(d.current,f.name,s)&&Ud(f,c.current,n._updateFormState)&&a({...n._formState,...f}),subject:n._subjects.state}),je.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),je.useMemo(()=>Vd(o,n,c.current,!1),[o,n])}var Yt=e=>typeof e=="string",Hd=(e,t,n,r,i)=>Yt(e)?(r&&t.watch.add(e),le(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),le(n,s))):(r&&(t.watchAll=!0),n);function jx(e){const t=Ss(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:o}=e||{},a=je.useRef(r);a.current=r,ha({disabled:s,subject:n._subjects.values,next:d=>{Jd(a.current,d.name,o)&&c(yt(Hd(a.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=Ss(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,o=Ld(i._names.array,n),a=jx({control:i,name:n,defaultValue:le(i._formValues,n,le(i._defaultValues,n,e.defaultValue)),exact:!0}),l=_x({control:i,name:n,exact:!0}),c=je.useRef(i.register(n,{...e.rules,value:a,...zt(e.disabled)?{disabled:e.disabled}:{}})),d=je.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!le(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!le(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!le(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!le(l.validatingFields,n)},error:{enumerable:!0,get:()=>le(l.errors,n)}}),[l,n]),f=je.useMemo(()=>({name:n,value:a,...zt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p=>c.current.onChange({target:{value:Fd(p),name:n},type:Hi.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:le(i._formValues,n),name:n},type:Hi.BLUR}),ref:p=>{const h=le(i._fields,n);h&&p&&(h._f.ref={focus:()=>p.focus(),select:()=>p.select(),setCustomValidity:g=>p.setCustomValidity(g),reportValidity:()=>p.reportValidity()})}}),[n,i._formValues,r,l.disabled,a,i._fields]);return je.useEffect(()=>{const p=i._options.shouldUnregister||s,h=(g,v)=>{const S=le(i._fields,g);S&&S._f&&(S._f.mount=v)};if(h(n,!0),p){const g=yt(le(i._options.defaultValues,n));$e(i._defaultValues,n,g),Qe(le(i._formValues,n))&&$e(i._formValues,n,g)}return!o&&i.register(n),()=>{(o?p&&!i._state.action:p)?i.unregister(n):h(n,!1)}},[n,i,o,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}}:{},sl=e=>({isOnSubmit:!e||e===Lt.onSubmit,isOnBlur:e===Lt.onBlur,isOnChange:e===Lt.onChange,isOnAll:e===Lt.all,isOnTouch:e===Lt.onTouched}),ol=(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=le(e,i);if(s){const{_f:o,...a}=s;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],i)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(Gr(a,t))break}else if(et(a)&&Gr(a,t))break}}};var Tx=(e,t,n)=>{const r=qr(le(e,n));return $e(r,"root",t[n]),$e(e,n,r),e},ma=e=>e.type==="file",Gt=e=>typeof e=="function",Wi=e=>{if(!fa)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Fi=e=>Yt(e),ga=e=>e.type==="radio",qi=e=>e instanceof RegExp;const al={value:!1,isValid:!1},ll={value:!0,isValid:!0};var Wd=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&&!Qe(e[0].attributes.value)?Qe(e[0].value)||e[0].value===""?ll:{value:e[0].value,isValid:!0}:ll:al}return al};const ul={isValid:!1,value:null};var qd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,ul):ul;function cl(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 Bn=e=>et(e)&&!qi(e)?e:{value:e,message:""},dl=async(e,t,n,r,i,s)=>{const{ref:o,refs:a,required:l,maxLength:c,minLength:d,min:f,max:p,pattern:h,validate:g,name:v,valueAsNumber:S,mount:y}=e._f,j=le(n,v);if(!y||t.has(v))return{};const m=a?a[0]:o,A=I=>{i&&m.reportValidity&&(m.setCustomValidity(zt(I)?"":I||""),m.reportValidity())},C={},w=ga(o),N=gi(o),J=w||N,D=(S||ma(o))&&Qe(o.value)&&Qe(j)||Wi(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,_=Cx.bind(null,v,r,C),T=(I,z,O,R=tn.maxLength,Y=tn.minLength)=>{const H=I?z:O;C[v]={type:I?R:Y,message:H,ref:o,..._(I?R:Y,H)}};if(s?!Array.isArray(j)||!j.length:l&&(!J&&(D||pt(j))||zt(j)&&!j||N&&!Wd(a).isValid||w&&!qd(a).isValid)){const{value:I,message:z}=Fi(l)?{value:!!l,message:l}:Bn(l);if(I&&(C[v]={type:tn.required,message:z,ref:m,..._(tn.required,z)},!r))return A(z),C}if(!D&&(!pt(f)||!pt(p))){let I,z;const O=Bn(p),R=Bn(f);if(!pt(j)&&!isNaN(j)){const Y=o.valueAsNumber||j&&+j;pt(O.value)||(I=Y>O.value),pt(R.value)||(z=Y<R.value)}else{const Y=o.valueAsDate||new Date(j),H=k=>new Date(new Date().toDateString()+" "+k),$=o.type=="time",ee=o.type=="week";Yt(O.value)&&j&&(I=$?H(j)>H(O.value):ee?j>O.value:Y>new Date(O.value)),Yt(R.value)&&j&&(z=$?H(j)<H(R.value):ee?j<R.value:Y<new Date(R.value))}if((I||z)&&(T(!!I,O.message,R.message,tn.max,tn.min),!r))return A(C[v].message),C}if((c||d)&&!D&&(Yt(j)||s&&Array.isArray(j))){const I=Bn(c),z=Bn(d),O=!pt(I.value)&&j.length>+I.value,R=!pt(z.value)&&j.length<+z.value;if((O||R)&&(T(O,I.message,z.message),!r))return A(C[v].message),C}if(h&&!D&&Yt(j)){const{value:I,message:z}=Bn(h);if(qi(I)&&!j.match(I)&&(C[v]={type:tn.pattern,message:z,ref:o,..._(tn.pattern,z)},!r))return A(z),C}if(g){if(Gt(g)){const I=await g(j,n),z=cl(I,m);if(z&&(C[v]={...z,..._(tn.validate,z.message)},!r))return A(z.message),C}else if(et(g)){let I={};for(const z in g){if(!bt(I)&&!r)break;const O=cl(await g[z](j,n),m,z);O&&(I={...O,..._(z,O.message)},A(O.message),r&&(C[v]=I))}if(!bt(I)&&(C[v]={ref:m,...I},!r))return C}}return A(!0),C};function Ix(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Qe(e)?r++:e[t[r++]];return e}function Ax(e){for(const t in e)if(e.hasOwnProperty(t)&&!Qe(e[t]))return!1;return!0}function it(e,t){const n=Array.isArray(t)?t:pa(t)?[t]:Bd(t),r=n.length===1?e:Ix(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(et(r)&&bt(r)||Array.isArray(r)&&Ax(r))&&it(e,n.slice(0,-1)),e}var Vs=()=>{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=[]}}},Io=e=>pt(e)||!$d(e);function hn(e,t){if(Io(e)||Io(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 o=t[i];if(In(s)&&In(o)||et(s)&&et(o)||Array.isArray(s)&&Array.isArray(o)?!hn(s,o):s!==o)return!1}}return!0}var Gd=e=>e.type==="select-multiple",zx=e=>ga(e)||gi(e),Us=e=>Wi(e)&&e.isConnected,Yd=e=>{for(const t in e)if(Gt(e[t]))return!0;return!1};function Gi(e,t={}){const n=Array.isArray(e);if(et(e)||n)for(const r in e)Array.isArray(e[r])||et(e[r])&&!Yd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Gi(e[r],t[r])):pt(e[r])||(t[r]=!0);return t}function Kd(e,t,n){const r=Array.isArray(e);if(et(e)||r)for(const i in e)Array.isArray(e[i])||et(e[i])&&!Yd(e[i])?Qe(t)||Io(n[i])?n[i]=Array.isArray(e[i])?Gi(e[i],[]):{...Gi(e[i])}:Kd(e[i],pt(t)?{}:t[i],n[i]):n[i]=!hn(e[i],t[i]);return n}var Ar=(e,t)=>Kd(e,t,Gi(t)),Xd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Qe(e)?e:t?e===""?NaN:e&&+e:n&&Yt(e)?new Date(e):r?r(e):e;function Js(e){const t=e.ref;return ma(t)?t.files:ga(t)?qd(e.refs).value:Gd(t)?[...t.selectedOptions].map(({value:n})=>n):gi(t)?Wd(e.refs).value:Xd(Qe(t.value)?e.ref.value:t.value,e)}var Ox=(e,t,n,r)=>{const i={};for(const s of e){const o=le(t,s);o&&$e(i,s,o._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},zr=e=>Qe(e)?e:qi(e)?e.source:et(e)?qi(e.value)?e.value.source:e.value:e;const fl="AsyncFunction";var Px=e=>!!e&&!!e.validate&&!!(Gt(e.validate)&&e.validate.constructor.name===fl||et(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===fl)),Dx=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function pl(e,t,n){const r=le(e,n);if(r||pa(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),o=le(t,s),a=le(e,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};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)=>!ks(le(e,t)).length&&it(e,t);const $x={mode:Lt.onSubmit,reValidateMode:Lt.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=et(t.defaultValues)||et(t.values)?yt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:yt(i),o={action:!1,mount:!1,watch:!1},a={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:Vs(),array:Vs(),state:Vs()},p=sl(t.mode),h=sl(t.reValidateMode),g=t.criteriaMode===Lt.all,v=E=>M=>{clearTimeout(c),c=setTimeout(E,M)},S=async E=>{if(!t.disabled&&(d.isValid||E)){const M=t.resolver?bt((await J()).errors):await _(r,!0);M!==n.isValid&&f.state.next({isValid:M})}},y=(E,M)=>{!t.disabled&&(d.isValidating||d.validatingFields)&&((E||Array.from(a.mount)).forEach(F=>{F&&(M?$e(n.validatingFields,F,M):it(n.validatingFields,F))}),f.state.next({validatingFields:n.validatingFields,isValidating:!bt(n.validatingFields)}))},j=(E,M=[],F,ne,Q=!0,te=!0)=>{if(ne&&F&&!t.disabled){if(o.action=!0,te&&Array.isArray(le(r,E))){const de=F(le(r,E),ne.argA,ne.argB);Q&&$e(r,E,de)}if(te&&Array.isArray(le(n.errors,E))){const de=F(le(n.errors,E),ne.argA,ne.argB);Q&&$e(n.errors,E,de),Mx(n.errors,E)}if(d.touchedFields&&te&&Array.isArray(le(n.touchedFields,E))){const de=F(le(n.touchedFields,E),ne.argA,ne.argB);Q&&$e(n.touchedFields,E,de)}d.dirtyFields&&(n.dirtyFields=Ar(i,s)),f.state.next({name:E,isDirty:I(E,M),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else $e(s,E,M)},m=(E,M)=>{$e(n.errors,E,M),f.state.next({errors:n.errors})},A=E=>{n.errors=E,f.state.next({errors:n.errors,isValid:!1})},C=(E,M,F,ne)=>{const Q=le(r,E);if(Q){const te=le(s,E,Qe(F)?le(i,E):F);Qe(te)||ne&&ne.defaultChecked||M?$e(s,E,M?te:Js(Q._f)):R(E,te),o.mount&&S()}},w=(E,M,F,ne,Q)=>{let te=!1,de=!1;const ve={name:E};if(!t.disabled){const Z=!!(le(r,E)&&le(r,E)._f&&le(r,E)._f.disabled);if(!F||ne){d.isDirty&&(de=n.isDirty,n.isDirty=ve.isDirty=I(),te=de!==ve.isDirty);const K=Z||hn(le(i,E),M);de=!!(!Z&&le(n.dirtyFields,E)),K||Z?it(n.dirtyFields,E):$e(n.dirtyFields,E,!0),ve.dirtyFields=n.dirtyFields,te=te||d.dirtyFields&&de!==!K}if(F){const K=le(n.touchedFields,E);K||($e(n.touchedFields,E,F),ve.touchedFields=n.touchedFields,te=te||d.touchedFields&&K!==F)}te&&Q&&f.state.next(ve)}return te?ve:{}},N=(E,M,F,ne)=>{const Q=le(n.errors,E),te=d.isValid&&zt(M)&&n.isValid!==M;if(t.delayError&&F?(l=v(()=>m(E,F)),l(t.delayError)):(clearTimeout(c),l=null,F?$e(n.errors,E,F):it(n.errors,E)),(F?!hn(Q,F):Q)||!bt(ne)||te){const de={...ne,...te&&zt(M)?{isValid:M}:{},errors:n.errors,name:E};n={...n,...de},f.state.next(de)}},J=async E=>{y(E,!0);const M=await t.resolver(s,t.context,Ox(E||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(E),M},D=async E=>{const{errors:M}=await J(E);if(E)for(const F of E){const ne=le(M,F);ne?$e(n.errors,F,ne):it(n.errors,F)}else n.errors=M;return M},_=async(E,M,F={valid:!0})=>{for(const ne in E){const Q=E[ne];if(Q){const{_f:te,...de}=Q;if(te){const ve=a.array.has(te.name),Z=Q._f&&Px(Q._f);Z&&d.validatingFields&&y([ne],!0);const K=await dl(Q,a.disabled,s,g,t.shouldUseNativeValidation&&!M,ve);if(Z&&d.validatingFields&&y([ne]),K[te.name]&&(F.valid=!1,M))break;!M&&(le(K,te.name)?ve?Tx(n.errors,K,te.name):$e(n.errors,te.name,K[te.name]):it(n.errors,te.name))}!bt(de)&&await _(de,M,F)}}return F.valid},T=()=>{for(const E of a.unMount){const M=le(r,E);M&&(M._f.refs?M._f.refs.every(F=>!Us(F)):!Us(M._f.ref))&&re(E)}a.unMount=new Set},I=(E,M)=>!t.disabled&&(E&&M&&$e(s,E,M),!hn(oe(),i)),z=(E,M,F)=>Hd(E,a,{...o.mount?s:Qe(M)?i:Yt(E)?{[E]:M}:M},F,M),O=E=>ks(le(o.mount?s:i,E,t.shouldUnregister?le(i,E,[]):[])),R=(E,M,F={})=>{const ne=le(r,E);let Q=M;if(ne){const te=ne._f;te&&(!te.disabled&&$e(s,E,Xd(M,te)),Q=Wi(te.ref)&&pt(M)?"":M,Gd(te.ref)?[...te.ref.options].forEach(de=>de.selected=Q.includes(de.value)):te.refs?gi(te.ref)?te.refs.length>1?te.refs.forEach(de=>(!de.defaultChecked||!de.disabled)&&(de.checked=Array.isArray(Q)?!!Q.find(ve=>ve===de.value):Q===de.value)):te.refs[0]&&(te.refs[0].checked=!!Q):te.refs.forEach(de=>de.checked=de.value===Q):ma(te.ref)?te.ref.value="":(te.ref.value=Q,te.ref.type||f.values.next({name:E,values:{...s}})))}(F.shouldDirty||F.shouldTouch)&&w(E,Q,F.shouldTouch,F.shouldDirty,!0),F.shouldValidate&&k(E)},Y=(E,M,F)=>{for(const ne in M){const Q=M[ne],te=`${E}.${ne}`,de=le(r,te);(a.array.has(E)||et(Q)||de&&!de._f)&&!In(Q)?Y(te,Q,F):R(te,Q,F)}},H=(E,M,F={})=>{const ne=le(r,E),Q=a.array.has(E),te=yt(M);$e(s,E,te),Q?(f.array.next({name:E,values:{...s}}),(d.isDirty||d.dirtyFields)&&F.shouldDirty&&f.state.next({name:E,dirtyFields:Ar(i,s),isDirty:I(E,te)})):ne&&!ne._f&&!pt(te)?Y(E,te,F):R(E,te,F),ol(E,a)&&f.state.next({...n}),f.values.next({name:o.mount?E:void 0,values:{...s}})},$=async E=>{o.mount=!0;const M=E.target;let F=M.name,ne=!0;const Q=le(r,F),te=()=>M.type?Js(Q._f):Fd(E),de=ve=>{ne=Number.isNaN(ve)||In(ve)&&isNaN(ve.getTime())||hn(ve,le(s,F,ve))};if(Q){let ve,Z;const K=te(),ge=E.type===Hi.BLUR||E.type===Hi.FOCUS_OUT,Ne=!Dx(Q._f)&&!t.resolver&&!le(n.errors,F)&&!Q._f.deps||Rx(ge,le(n.touchedFields,F),n.isSubmitted,h,p),L=ol(F,a,ge);$e(s,F,K),ge?(Q._f.onBlur&&Q._f.onBlur(E),l&&l(0)):Q._f.onChange&&Q._f.onChange(E);const xe=w(F,K,ge,!1),ze=!bt(xe)||L;if(!ge&&f.values.next({name:F,type:E.type,values:{...s}}),Ne)return d.isValid&&(t.mode==="onBlur"&&ge?S():ge||S()),ze&&f.state.next({name:F,...L?{}:xe});if(!ge&&L&&f.state.next({...n}),t.resolver){const{errors:Be}=await J([F]);if(de(K),ne){const rt=pl(n.errors,r,F),tt=pl(Be,r,rt.name||F);ve=tt.error,F=tt.name,Z=bt(Be)}}else y([F],!0),ve=(await dl(Q,a.disabled,s,g,t.shouldUseNativeValidation))[F],y([F]),de(K),ne&&(ve?Z=!1:d.isValid&&(Z=await _(r,!0)));ne&&(Q._f.deps&&k(Q._f.deps),N(F,Z,ve,xe))}},ee=(E,M)=>{if(le(n.errors,M)&&E.focus)return E.focus(),1},k=async(E,M={})=>{let F,ne;const Q=qr(E);if(t.resolver){const te=await D(Qe(E)?E:Q);F=bt(te),ne=E?!Q.some(de=>le(te,de)):F}else E?(ne=(await Promise.all(Q.map(async te=>{const de=le(r,te);return await _(de&&de._f?{[te]:de}:de)}))).every(Boolean),!(!ne&&!n.isValid)&&S()):ne=F=await _(r);return f.state.next({...!Yt(E)||d.isValid&&F!==n.isValid?{}:{name:E},...t.resolver||!E?{isValid:F}:{},errors:n.errors}),M.shouldFocus&&!ne&&Gr(r,ee,E?Q:a.mount),ne},oe=E=>{const M={...o.mount?s:i};return Qe(E)?M:Yt(E)?le(M,E):E.map(F=>le(M,F))},q=(E,M)=>({invalid:!!le((M||n).errors,E),isDirty:!!le((M||n).dirtyFields,E),error:le((M||n).errors,E),isValidating:!!le(n.validatingFields,E),isTouched:!!le((M||n).touchedFields,E)}),b=E=>{E&&qr(E).forEach(M=>it(n.errors,M)),f.state.next({errors:E?n.errors:{}})},B=(E,M,F)=>{const ne=(le(r,E,{_f:{}})._f||{}).ref,Q=le(n.errors,E)||{},{ref:te,message:de,type:ve,...Z}=Q;$e(n.errors,E,{...Z,...M,ref:ne}),f.state.next({name:E,errors:n.errors,isValid:!1}),F&&F.shouldFocus&&ne&&ne.focus&&ne.focus()},V=(E,M)=>Gt(E)?f.values.subscribe({next:F=>E(z(void 0,M),F)}):z(E,M,!0),re=(E,M={})=>{for(const F of E?qr(E):a.mount)a.mount.delete(F),a.array.delete(F),M.keepValue||(it(r,F),it(s,F)),!M.keepError&&it(n.errors,F),!M.keepDirty&&it(n.dirtyFields,F),!M.keepTouched&&it(n.touchedFields,F),!M.keepIsValidating&&it(n.validatingFields,F),!t.shouldUnregister&&!M.keepDefaultValue&&it(i,F);f.values.next({values:{...s}}),f.state.next({...n,...M.keepDirty?{isDirty:I()}:{}}),!M.keepIsValid&&S()},se=({disabled:E,name:M,field:F,fields:ne})=>{(zt(E)&&o.mount||E||a.disabled.has(M))&&(E?a.disabled.add(M):a.disabled.delete(M),w(M,Js(F?F._f:le(ne,M)._f),!1,!1,!0))},P=(E,M={})=>{let F=le(r,E);const ne=zt(M.disabled)||zt(t.disabled);return $e(r,E,{...F||{},_f:{...F&&F._f?F._f:{ref:{name:E}},name:E,mount:!0,...M}}),a.mount.add(E),F?se({field:F,disabled:zt(M.disabled)?M.disabled:t.disabled,name:E}):C(E,!0,M.value),{...ne?{disabled:M.disabled||t.disabled}:{},...t.progressive?{required:!!M.required,min:zr(M.min),max:zr(M.max),minLength:zr(M.minLength),maxLength:zr(M.maxLength),pattern:zr(M.pattern)}:{},name:E,onChange:$,onBlur:$,ref:Q=>{if(Q){P(E,M),F=le(r,E);const te=Qe(Q.value)&&Q.querySelectorAll&&Q.querySelectorAll("input,select,textarea")[0]||Q,de=zx(te),ve=F._f.refs||[];if(de?ve.find(Z=>Z===te):te===F._f.ref)return;$e(r,E,{_f:{...F._f,...de?{refs:[...ve.filter(Us),te,...Array.isArray(le(i,E))?[{}]:[]],ref:{type:te.type,name:E}}:{ref:te}}}),C(E,!1,void 0,te)}else F=le(r,E,{}),F._f&&(F._f.mount=!1),(t.shouldUnregister||M.shouldUnregister)&&!(Ld(a.array,E)&&o.action)&&a.unMount.add(E)}}},ue=()=>t.shouldFocusError&&Gr(r,ee,a.mount),he=E=>{zt(E)&&(f.state.next({disabled:E}),Gr(r,(M,F)=>{const ne=le(r,F);ne&&(M.disabled=ne._f.disabled||E,Array.isArray(ne._f.refs)&&ne._f.refs.forEach(Q=>{Q.disabled=ne._f.disabled||E}))},0,!1))},ce=(E,M)=>async F=>{let ne;F&&(F.preventDefault&&F.preventDefault(),F.persist&&F.persist());let Q=yt(s);if(a.disabled.size)for(const te of a.disabled)$e(Q,te,void 0);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:te,values:de}=await J();n.errors=te,Q=de}else await _(r);if(it(n.errors,"root"),bt(n.errors)){f.state.next({errors:{}});try{await E(Q,F)}catch(te){ne=te}}else M&&await M({...n.errors},F),ue(),setTimeout(ue);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:bt(n.errors)&&!ne,submitCount:n.submitCount+1,errors:n.errors}),ne)throw ne},pe=(E,M={})=>{le(r,E)&&(Qe(M.defaultValue)?H(E,yt(le(i,E))):(H(E,M.defaultValue),$e(i,E,yt(M.defaultValue))),M.keepTouched||it(n.touchedFields,E),M.keepDirty||(it(n.dirtyFields,E),n.isDirty=M.defaultValue?I(E,yt(le(i,E))):I()),M.keepError||(it(n.errors,E),d.isValid&&S()),f.state.next({...n}))},me=(E,M={})=>{const F=E?yt(E):i,ne=yt(F),Q=bt(E),te=Q?i:ne;if(M.keepDefaultValues||(i=F),!M.keepValues){if(M.keepDirtyValues){const de=new Set([...a.mount,...Object.keys(Ar(i,s))]);for(const ve of Array.from(de))le(n.dirtyFields,ve)?$e(te,ve,le(s,ve)):H(ve,le(te,ve))}else{if(fa&&Qe(E))for(const de of a.mount){const ve=le(r,de);if(ve&&ve._f){const Z=Array.isArray(ve._f.refs)?ve._f.refs[0]:ve._f.ref;if(Wi(Z)){const K=Z.closest("form");if(K){K.reset();break}}}}r={}}s=t.shouldUnregister?M.keepDefaultValues?yt(i):{}:yt(te),f.array.next({values:{...te}}),f.values.next({values:{...te}})}a={mount:M.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!M.keepIsValid||!!M.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:M.keepSubmitCount?n.submitCount:0,isDirty:Q?!1:M.keepDirty?n.isDirty:!!(M.keepDefaultValues&&!hn(E,i)),isSubmitted:M.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:Q?{}:M.keepDirtyValues?M.keepDefaultValues&&s?Ar(i,s):n.dirtyFields:M.keepDefaultValues&&E?Ar(i,E):M.keepDirty?n.dirtyFields:{},touchedFields:M.keepTouched?n.touchedFields:{},errors:M.keepErrors?n.errors:{},isSubmitSuccessful:M.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},U=(E,M)=>me(Gt(E)?E(s):E,M);return{control:{register:P,unregister:re,getFieldState:q,handleSubmit:ce,setError:B,_executeSchema:J,_getWatch:z,_getDirty:I,_updateValid:S,_removeUnmounted:T,_updateFieldArray:j,_updateDisabledField:se,_getFieldArray:O,_reset:me,_resetDefaultValues:()=>Gt(t.defaultValues)&&t.defaultValues().then(E=>{U(E,t.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:E=>{n={...n,...E}},_disableForm:he,_subjects:f,_proxyFormState:d,_setErrors:A,get _fields(){return r},get _formValues(){return s},get _state(){return o},set _state(E){o=E},get _defaultValues(){return i},get _names(){return a},set _names(E){a=E},get _formState(){return n},set _formState(E){n=E},get _options(){return t},set _options(E){t={...t,...E}}},trigger:k,register:P,handleSubmit:ce,watch:V,setValue:H,getValues:oe,reset:U,resetField:pe,clearErrors:b,unregister:re,setError:B,setFocus:(E,M={})=>{const F=le(r,E),ne=F&&F._f;if(ne){const Q=ne.refs?ne.refs[0]:ne.ref;Q.focus&&(Q.focus(),M.shouldSelect&&Gt(Q.select)&&Q.select())}},getFieldState:q}}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,ha({subject:s._subjects.state,next:o=>{Ud(o,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),je.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),je.useEffect(()=>{if(s._proxyFormState.isDirty){const o=s._getDirty();o!==r.isDirty&&s._subjects.state.next({isDirty:o})}},[s,r.isDirty]),je.useEffect(()=>{e.values&&!hn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(o=>({...o}))):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=Vd(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,Qd=x.createContext({}),hl=({...e})=>u.jsx(Qd.Provider,{value:{name:e.name},children:u.jsx(Ex,{...e})}),_s=()=>{const e=x.useContext(Qd),t=x.useContext(ef),{getFieldState:n,formState:r}=Ss(),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}},ef=x.createContext({}),Ao=x.forwardRef(({className:e,...t},n)=>{const r=x.useId();return u.jsx(ef.Provider,{value:{id:r},children:u.jsx("div",{ref:n,className:G("space-y-2",e),...t})})});Ao.displayName="FormItem";const zo=x.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=_s();return u.jsx(sr,{ref:n,className:G(r&&"text-destructive",e),htmlFor:i,...t})});zo.displayName="FormLabel";const Oo=x.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=_s();return u.jsx(_r,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Oo.displayName="FormControl";const tf=x.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=_s();return u.jsx("p",{ref:n,id:r,className:G("text-muted-foreground text-[0.8rem]",e),...t})});tf.displayName="FormDescription";const Po=x.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=_s(),o=i?String(i==null?void 0:i.message):t;return o?u.jsx("p",{ref:r,id:s,className:G("text-destructive text-[0.8rem] font-medium",e),...n,children:o}):null});Po.displayName="FormMessage";function xa(){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 nf=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Vx=(e=nf())=>ux()(cx(dx((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,o)=>o!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),o={id:i,documentName:r,title:xa(),messages:[],createdAt:s,updatedAt:s};return t(a=>({threads:{...a.threads,[i]:o},activeThreadId:{...a.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const o=Object.fromEntries(Object.entries(i.threads).filter(([c])=>c!==r)),a=s.documentName,l={...i.activeThreadId};if(l[a]===r){const c=Object.values(o).filter(d=>d.documentName===a);c.length>0?(c.sort((d,f)=>f.updatedAt-d.updatedAt),l[a]=c[0].id):delete l[a]}t({threads:o,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(o=>({activeThreadId:{...o.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},o={...i.activeThreadId};for(const[a,l]of Object.entries(s))l.documentName===r&&delete s[a];return delete o[r],{threads:s,activeThreadId:o}})},renameThreadsForDocument:(r,i)=>{t(s=>{const o={...s.threads},a={...s.activeThreadId};for(const[l,c]of Object.entries(o))c.documentName===r&&(o[l]={...c,documentName:i});return r in a&&(a[i]=a[r],delete a[r]),{threads:o,activeThreadId:a}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:fx(()=>nx),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}}))),rf=x.createContext(void 0),Ux=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Vx(nf())),u.jsx(rf.Provider,{value:t.current,children:e})},Re=e=>{const t=x.useContext(rf);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return px(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=Si.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=Si.Optional(Si.String({description:"Template selection"})));const s=Si.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:o=>{const a=[];if(!gg(s,o))for(const c of xg(s,o))a.push({path:c.path.replace(/^\//,""),message:c.message});const l=o;if(e!=="delete"&&l.name){const c=l.name.trim();c?(l.name=c,t(c)||a.push({path:"name",message:"Document with this name already exists"})):a.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)||a.push({path:"template",message:"You must select a valid template"})),{success:a.length===0,data:a.length===0?l:void 0,errors:a}}}}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"}}),Zn="__empty__";function Gx({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:o}){const[a,l]=x.useState(!1),[c,d]=x.useState(null),[f,p]=x.useState("idle"),{toast:h}=jr(),g=qx(o),{documents:v,openTabs:S,createDocument:y,renameDocument:j,deleteDocument:m,openDocument:A,closeDocument:C}=Ce(oe=>oe),{updateTheme:w,removeTheme:N}=To(oe=>oe),J=Re(oe=>oe.renameThreadsForDocument),D=Re(oe=>oe.deleteThreadsForDocument),_=x.useMemo(()=>o?s||[]:i||[],[o,i,s]),T=x.useMemo(()=>{const oe={current:[],downstream:[]};return _.forEach(q=>{oe[q.location]&&oe[q.location].push(q)}),oe},[_]),I=x.useMemo(()=>_.map(oe=>({name:oe.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[_]),z=x.useMemo(()=>Hx(e,oe=>Jx(oe,v,r),I),[e,v,r,I]),O=z.schema,R=x.useMemo(()=>{const oe=new Map;return _.forEach(q=>oe.set(q.path,q)),oe},[_]),Y=Zn,H=Lx({resolver:Bx(z.validate),defaultValues:Wx(e,void 0,r)}),[$,ee]=x.useState(Y);x.useEffect(()=>{if($&&$!==Zn&&e==="create"){const oe=R.get($);if(oe){d(null),p("loading");let q=!1;return fetch(`/api/discovery/${o?"themes":"documents"}/${encodeURIComponent(oe.name)}/content`).then(b=>{if(!b.ok)throw new Error(`Failed to fetch content: ${b.statusText}`);return b.text()}).then(b=>{if(q)return;const B=JSON.parse(b);d(JSON.stringify(B,null,2)),p("idle")}).catch(b=>{q||(console.error("Failed to copy template:",b),d(null),p("error"))}),()=>{q=!0}}}p("idle")},[$,e,R,o]),x.useEffect(()=>{t&&(H.reset(),d(null),p("idle"),ee(Y))},[H,t]);const k=H.handleSubmit(async({name:oe,template:q})=>{l(!0);try{if(await new Promise(b=>setTimeout(b,200)),e==="create"){const b=$?R.get($):_.find(pe=>pe.name===q);let B,V=oe;if(!!$&&$!==Zn&&c===null){h({title:f==="loading"?"Template still loading":`Could not copy ${(b==null?void 0:b.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(o){const pe=V.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),me=ot==="docx"?yg(pe):{name:pe,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}};B=c||JSON.stringify(me,null,2);const U=`.${ot}.theme.json`;V.endsWith(U)||(V=V.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),V+=U)}else{const pe=b;B=c||JSON.stringify(ot==="docx"?{name:"docx",props:{theme:(pe==null?void 0:pe.theme)||"default",metadata:{title:(pe==null?void 0:pe.title)||V.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(pe==null?void 0:pe.title)||V.replace(/\.(json|js)$/i,""),theme:(pe==null?void 0:pe.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 me=ot==="docx"?".docx.json":".pptx.json";!V.endsWith(me)&&!V.endsWith(".json")&&(V+=me)}const se=V.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),P=se?se[0]:"",ue=V.slice(0,V.length-P.length);let he=V,ce=1;for(;v.some(pe=>pe.name===he);)ce++,he=`${ue} (${ce})${P}`;V=he,y(V,B),A(V),o&&w(V,B)}else if(e==="update"){const b=r,B=oe,V=S.includes(b);V&&C(b),j(b,B),J(b,B),V&&A(B)}else if(e==="delete"){const b=r;C(b),m(b),D(b),o&&N(b)}n()}finally{l(!1)}});return u.jsx(Zx,{...H,children:u.jsxs("form",{onSubmit:k,children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:g[e].title}),u.jsx(an,{children:g[e].description})]}),u.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[O.properties&&"name"in O.properties&&u.jsx(hl,{control:H.control,name:"name",render:({field:oe})=>u.jsxs(Ao,{children:[u.jsx(zo,{children:"Name"}),u.jsx(Oo,{children:u.jsx(gr,{placeholder:"Enter a name or select a template below",autoComplete:"off",...oe})}),u.jsx(Po,{})]})}),e==="create"&&u.jsx(hl,{control:H.control,name:"template",render:({field:oe})=>u.jsxs(Ao,{children:[u.jsx(zo,{children:o?"Base Theme":"Base Document"}),u.jsxs(ei,{onValueChange:q=>{if(q===Zn)oe.onChange(void 0),H.setValue("name",""),ee(Zn),d(null);else{const b=R.get(q);b&&(oe.onChange(b.name),H.setValue("name",b.name),ee(q))}},defaultValue:Y,children:[u.jsx(Oo,{children:u.jsx(hr,{children:u.jsx(ti,{placeholder:`Select a discovered ${o?"theme":"document"}`})})}),u.jsxs(mr,{className:"max-h-[300px]",children:[u.jsxs(Dn,{value:Zn,children:["Empty ",o?"theme":"document"]}),Object.entries(T).map(([q,b])=>b.length===0?null:u.jsxs(gx,{children:[u.jsx(Md,{children:q==="current"?"📁 Current Directory":"📦 Project"}),b.map(B=>{let V;return B.title&&B.title!==B.name?V=B.title:B.description&&(V=B.description.length>40?B.description.substring(0,40)+"...":B.description),u.jsx(Dn,{value:B.path,className:"pl-6",children:u.jsxs("span",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:B.name}),V&&u.jsx("span",{className:"text-muted-foreground text-xs",children:V})]})},B.path)})]},q))]})]}),u.jsxs(tf,{children:["Start empty or select a discovered"," ",o?"theme":"document"," as a starting point"]}),u.jsx(Po,{})]})})]}),u.jsx(bn,{children:u.jsx(_e,{type:"submit",variant:g[e].buttonVariant,disabled:a,children:a?u.jsxs(u.Fragment,{children:[u.jsx(sn,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):g[e].button})})]})})}const Yi=je.memo(Gx);function cn(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}function ya({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 Do({children:e,count:t,actions:n,className:r}){return u.jsxs("div",{className:G("flex h-6 shrink-0 items-center gap-1.5 px-1 select-none",r),children:[u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] text-sidebar-foreground/70 uppercase",children:e}),t!==void 0&&u.jsx("span",{className:"text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:t}),n&&u.jsx("div",{className:"ml-auto flex items-center gap-0.5",children:n})]})}const $t=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}));$t.displayName="RailIconButton";function ml({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 gl({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=eg,Kx=tg,Xx=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(Qc,{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(Pn,{className:"ml-auto h-4 w-4"})]}));Xx.displayName=Qc.displayName;const Qx=x.forwardRef(({className:e,...t},n)=>u.jsx(ed,{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=ed.displayName;const sf=x.forwardRef(({className:e,...t},n)=>u.jsx(ng,{children:u.jsx(Yc,{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})}));sf.displayName=Yc.displayName;const of=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Xc,{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}));of.displayName=Xc.displayName;const ey=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(td,{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(nd,{children:u.jsx(yn,{className:"h-4 w-4"})})}),t]}));ey.displayName=td.displayName;const ty=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(rd,{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(nd,{children:u.jsx(_d,{className:"h-4 w-4 fill-current"})})}),t]}));ty.displayName=rd.displayName;const ny=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(id,{ref:r,className:G("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ny.displayName=id.displayName;const af=x.forwardRef(({className:e,...t},n)=>u.jsx(Kc,{ref:n,className:G("bg-border -mx-1 my-1 h-px",e),...t}));af.displayName=Kc.displayName;const lf=({className:e,...t})=>u.jsx("span",{className:G("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});lf.displayName="ContextMenuShortcut";const js=rg,Ns=ig,ry=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(ud,{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(Pn,{className:"ml-auto"})]}));ry.displayName=ud.displayName;const iy=x.forwardRef(({className:e,...t},n)=>u.jsx(cd,{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=cd.displayName;const xi=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(sg,{children:u.jsx(sd,{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})}));xi.displayName=sd.displayName;const Ft=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(od,{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}));Ft.displayName=od.displayName;const sy=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(dd,{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(fd,{children:u.jsx(yn,{className:"h-4 w-4"})})}),t]}));sy.displayName=dd.displayName;const oy=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(pd,{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(fd,{children:u.jsx(_d,{className:"h-2 w-2 fill-current"})})}),t]}));oy.displayName=pd.displayName;const uf=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(ld,{ref:r,className:G("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));uf.displayName=ld.displayName;const xr=x.forwardRef(({className:e,...t},n)=>u.jsx(ad,{ref:n,className:G("bg-muted -mx-1 my-1 h-px",e),...t}));xr.displayName=ad.displayName;const cf=({className:e,...t})=>u.jsx("span",{className:G("ml-auto text-xs tracking-widest opacity-60",e),...t});cf.displayName="DropdownMenuShortcut";const df=x.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>u.jsx(hd,{ref:i,decorative:n,orientation:t,className:G("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));df.displayName=hd.displayName;const ff=Lc,ay=og,ly=Bc,pf=x.forwardRef(({className:e,...t},n)=>u.jsx(vs,{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}));pf.displayName=vs.displayName;const uy=mi("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"}}),ba=x.forwardRef(({side:e="right",className:t,children:n,...r},i)=>u.jsxs(ly,{children:[u.jsx(pf,{}),u.jsxs(xs,{ref:i,className:G(uy({side:e}),t),...r,children:[u.jsxs(ua,{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(xn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));ba.displayName=xs.displayName;const cy=x.forwardRef(({className:e,...t},n)=>u.jsx(ys,{ref:n,className:G("text-foreground text-lg font-semibold",e),...t}));cy.displayName=ys.displayName;const dy=x.forwardRef(({className:e,...t},n)=>u.jsx(bs,{ref:n,className:G("text-muted-foreground text-sm",e),...t}));dy.displayName=bs.displayName;function Yr({className:e,...t}){return u.jsx("div",{className:G("bg-primary/10 animate-pulse rounded-md",e),...t})}const Hs=768,Ws=1200;function hf(e){return typeof window<"u"?window.innerWidth<e:!1}function mf(){const[e,t]=x.useState(()=>hf(Hs));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Hs-1}px)`),r=()=>{t(window.innerWidth<Hs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function fy(){const[e,t]=x.useState(()=>hf(Ws));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ws-1}px)`),r=()=>{t(window.innerWidth<Ws)};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",gf=x.createContext(null);function Es(){const e=x.useContext(gf);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const xf=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...o},a)=>{const l=mf(),[c,d]=x.useState(!1),[f,p]=x.useState(e),h=t??f,g=x.useCallback(j=>{const m=typeof j=="function"?j(h):j;n?n(m):p(m),document.cookie=`${py}=${m}; path=/; max-age=${hy}`},[n,h]),v=x.useCallback(()=>l?d(j=>!j):g(j=>!j),[l,g,d]);x.useEffect(()=>{const j=A=>{var N;const C=A;if(!C)return!1;const w=(N=C.tagName)==null?void 0:N.toLowerCase();return w==="input"||w==="textarea"||w==="select"||C.isContentEditable?!0:!!(C.closest&&C.closest(".monaco-editor"))},m=A=>{const C=A.metaKey||A.ctrlKey,w=A.key.toLowerCase();if(C&&w===yy){A.preventDefault(),v();return}C&&w==="s"&&!j(A.target)&&(A.preventDefault(),v())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[v]);const S=h?"expanded":"collapsed",y=x.useMemo(()=>({state:S,open:h,setOpen:g,isMobile:l,openMobile:c,setOpenMobile:d,toggleSidebar:v}),[S,h,g,l,c,d,v]);return u.jsx(gf.Provider,{value:y,children:u.jsx(bg,{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:a,...o,children:s})})})});xf.displayName="SidebarProvider";const yf=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},o)=>{const{isMobile:a,state:l,openMobile:c,setOpenMobile:d}=Es();return n==="none"?u.jsx("div",{className:G("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:o,...s,children:i}):a?u.jsx(ff,{open:c,onOpenChange:d,...s,children:u.jsx(ba,{"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:o,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})})]})});yf.displayName="Sidebar";const by=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=Es();return u.jsxs(_e,{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(jg,{}),u.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});by.displayName="SidebarTrigger";const vy=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Es();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(gr,{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 Ro=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}));Ro.displayName="SidebarHeader";const bf=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}));bf.displayName="SidebarFooter";const Sy=x.forwardRef(({className:e,...t},n)=>u.jsx(df,{ref:n,"data-sidebar":"separator",className:G("bg-sidebar-border mx-2 w-auto",e),...t}));Sy.displayName="SidebarSeparator";const Mo=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}));Mo.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?_r:"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?_r:"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 Br=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}));Br.displayName="SidebarMenu";const vf=x.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,"data-sidebar":"menu-item",className:G("group/menu-item relative",e),...t}));vf.displayName="SidebarMenuItem";const Cy=mi("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"}}),wf=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...o},a)=>{const l=e?_r:"button",{isMobile:c,state:d}=Es(),f=u.jsx(l,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:G(Cy({variant:n,size:r}),s),...o});return i?(typeof i=="string"&&(i={children:i}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:f}),u.jsx(Ye,{side:"right",align:"center",hidden:d!=="collapsed"||c,...i})]})):f});wf.displayName="SidebarMenuButton";const kf=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?_r:"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})});kf.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 o=e?_r:"a";return u.jsx(o,{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),[o,a]=x.useState(!1),[l,c]=x.useState(!1),[d,f]=x.useState(!1),p=Ce(q=>q.openDocument),h=Ce(q=>q.documentTypes),g=Ce(q=>q.activeTab),v=rn(q=>q.name),S=rn(q=>q.text),y=rn(q=>q.isGenerating),m=(h[e.name]||"application/json+report")==="application/json+theme",A=g===e.name,[C,w]=x.useState(v),[N,J]=x.useState(S),D=100,_=0;x.useEffect(()=>{const q=setTimeout(()=>{v&&S?(w(v),J(S)):y||(w(""),J(""))},y?D:_);return()=>clearTimeout(q)},[v,S,y]);const T=C===e.name,I=q=>{var B;const b=new Set;try{const V=JSON.parse(q);(B=V.props)!=null&&B.theme&&b.add(V.props.theme),V.children&&Array.isArray(V.children)&&V.children.forEach(re=>{var se;re.name==="docx"&&((se=re.props)!=null&&se.theme)&&b.add(re.props.theme)})}catch{}return b},z=x.useMemo(()=>{if(!m||!N)return!1;try{const q=JSON.parse(e.text),b=rx(q);if(b)return I(N).has(b)}catch{}return!1},[m,N,e.text]),O=x.useCallback(()=>{c(!1)},[]),R=x.useCallback(()=>{f(!1)},[]),Y=A?null:T?"preview":z?"in-use":null,H=A?"Editing":T?"In preview":z?"Used by preview":null,$=x.useMemo(()=>[{key:"open",label:"Open",shortcut:Py?"⌘⏎":"⌃⏎",run:()=>p(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,p]),ee=m?Ng:jd,k=i||o,oe=u.jsxs(wf,{size:"sm",ref:r,"aria-label":H?`${e.name} — ${H}`: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",k&&"bg-sidebar-accent/60 text-sidebar-foreground",A&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),title:H?`${e.name} — ${H}`:e.name,onClick:()=>{p(e.name)},onKeyDown:q=>{var b;(q.ctrlKey||q.metaKey)&&q.key==="Enter"?(p(e.name),q.preventDefault()):q.key==="Enter"?(c(!0),q.preventDefault()):q.key==="Backspace"||q.key==="Delete"?(f(!0),q.preventDefault()):q.key==="Escape"&&((b=r.current)==null||b.blur(),q.preventDefault())},children:[A&&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(ee,{className:G("size-3.5 shrink-0",m?"text-accent2":"text-sidebar-foreground/60",A&&!m&&"text-sidebar-accent-foreground/70")}),!t&&u.jsx("span",{className:"flex-1 truncate",children:u.jsx(ya,{text:e.name,query:n})}),t&&Y&&u.jsx(ml,{tone:Y,className:"absolute top-1 right-1 size-1.5 ring-2 ring-[hsl(var(--sidebar))]"})]});return u.jsxs(vf,{children:[u.jsxs(Yx,{onOpenChange:s,children:[u.jsx(Kx,{className:"block",children:t?u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:oe}),u.jsx(Ye,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[u.jsx("div",{children:e.name}),u.jsx("div",{className:"opacity-70",children:H??(m?"Theme":"Document")})]})})]}):oe}),u.jsx(sf,{className:"w-44",children:$.map(q=>u.jsxs(je.Fragment,{children:[q.separatorBefore&&u.jsx(af,{}),u.jsxs(of,{onClick:q.run,className:G(q.danger&&"text-destructive focus:text-destructive"),children:[q.label,q.shortcut&&u.jsx(lf,{children:q.shortcut})]})]},q.key))})]}),!t&&u.jsxs(u.Fragment,{children:[Y&&u.jsx(ml,{tone:Y,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",o&&"opacity-0")}),u.jsxs(js,{onOpenChange:a,children:[u.jsx(Ns,{asChild:!0,children:u.jsx(kf,{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(Nd,{})})}),u.jsx(xi,{side:"right",align:"start",className:"w-44",children:$.map(q=>u.jsxs(je.Fragment,{children:[q.separatorBefore&&u.jsx(xr,{}),u.jsxs(Ft,{onClick:q.run,className:G(q.danger&&"text-destructive focus:text-destructive"),children:[q.label,q.shortcut&&u.jsx(cf,{children:q.shortcut})]})]},q.key))})]})]}),u.jsx(Ct,{open:l,onOpenChange:c,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:q=>{var b;q.preventDefault(),(b=r.current)==null||b.focus()},children:u.jsx(Yi,{mode:"update",shouldReset:!l,postSubmit:O,selectedName:e.name})})}),u.jsx(Ct,{open:d,onOpenChange:f,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:q=>{var b;q.preventDefault(),(b=r.current)==null||b.focus()},children:u.jsx(Yi,{mode:"delete",shouldReset:!d,postSubmit:R,selectedName:e.name})})})]})}const Ni=je.memo(Dy);function Ry(e,t=!1){const n=e.length;let r=0,i="",s=0,o=16,a=0,l=0,c=0,d=0,f=0;function p(m,A){let C=0,w=0;for(;C<m;){let N=e.charCodeAt(r);if(N>=48&&N<=57)w=w*16+N-48;else if(N>=65&&N<=70)w=w*16+N-65+10;else if(N>=97&&N<=102)w=w*16+N-97+10;else break;r++,C++}return C<m&&(w=-1),w}function h(m){r=m,i="",s=0,o=16,f=0}function g(){let m=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&Vn(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46)if(r++,r<e.length&&Vn(e.charCodeAt(r)))for(r++;r<e.length&&Vn(e.charCodeAt(r));)r++;else return f=3,e.substring(m,r);let A=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&&Vn(e.charCodeAt(r))){for(r++;r<e.length&&Vn(e.charCodeAt(r));)r++;A=r}else f=3;return e.substring(m,A)}function v(){let m="",A=r;for(;;){if(r>=n){m+=e.substring(A,r),f=2;break}const C=e.charCodeAt(r);if(C===34){m+=e.substring(A,r),r++;break}if(C===92){if(m+=e.substring(A,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 N=p(4);N>=0?m+=String.fromCharCode(N):f=4;break;default:f=5}A=r;continue}if(C>=0&&C<=31)if(Or(C)){m+=e.substring(A,r),f=2;break}else f=6;r++}return m}function S(){if(i="",f=0,s=r,l=a,d=c,r>=n)return s=n,o=17;let m=e.charCodeAt(r);if(qs(m)){do r++,i+=String.fromCharCode(m),m=e.charCodeAt(r);while(qs(m));return o=15}if(Or(m))return r++,i+=String.fromCharCode(m),m===13&&e.charCodeAt(r)===10&&(r++,i+=`
4
+ `),a++,c=r,o=14;switch(m){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=v(),o=10;case 47:const A=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!Or(e.charCodeAt(r));)r++;return i=e.substring(A,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;const C=n-1;let w=!1;for(;r<C;){const N=e.charCodeAt(r);if(N===42&&e.charCodeAt(r+1)===47){r+=2,w=!0;break}r++,Or(N)&&(N===13&&e.charCodeAt(r)===10&&r++,a++,c=r)}return w||(r++,f=1),i=e.substring(A,r),o=13}return i+=String.fromCharCode(m),r++,o=16;case 45:if(i+=String.fromCharCode(m),r++,r===n||!Vn(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=g(),o=11;default:for(;r<n&&y(m);)r++,m=e.charCodeAt(r);if(s!==r){switch(i=e.substring(s,r),i){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return i+=String.fromCharCode(m),r++,o=16}}function y(m){if(qs(m)||Or(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 j(){let m;do m=S();while(m>=12&&m<=15);return m}return{setPosition:h,getPosition:()=>r,scan:t?j:S,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>s,getTokenLength:()=>r-s,getTokenStartLine:()=>l,getTokenStartCharacter:()=>s-d,getTokenError:()=>f}}function qs(e){return e===32||e===9}function Or(e){return e===10||e===13}function Vn(e){return e>=48&&e<=57}var xl;(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"})(xl||(xl={}));new Array(20).fill(0).map((e,t)=>" ".repeat(t));const Un=200;new Array(Un).fill(0).map((e,t)=>`
5
+ `+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>`\r
6
+ `+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>`
7
+ `+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>`\r
8
+ `+" ".repeat(t));var Ki;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Ki||(Ki={}));function My(e,t=[],n=Ki.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}$y(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:Fy(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 a=r.children[0];return a&&delete a.parent,a}function $y(e,t,n=Ki.DEFAULT){const r=Ry(e,!1),i=[];let s=0;function o(O){return O?()=>s===0&&O(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(O){return O?R=>s===0&&O(R,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(O){return O?R=>s===0&&O(R,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(O){return O?()=>{s>0?s++:O(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(s=1)}:()=>!0}function d(O){return O?()=>{s>0&&s--,s===0&&O(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const f=c(t.onObjectBegin),p=l(t.onObjectProperty),h=d(t.onObjectEnd),g=c(t.onArrayBegin),v=d(t.onArrayEnd),S=l(t.onLiteralValue),y=a(t.onSeparator),j=o(t.onComment),m=a(t.onError),A=n&&n.disallowComments,C=n&&n.allowTrailingComma;function w(){for(;;){const O=r.scan();switch(r.getTokenError()){case 4:N(14);break;case 5:N(15);break;case 3:N(13);break;case 1:A||N(11);break;case 2:N(12);break;case 6:N(16);break}switch(O){case 12:case 13:A?N(10):j();break;case 16:N(1);break;case 15:case 14:break;default:return O}}}function N(O,R=[],Y=[]){if(m(O),R.length+Y.length>0){let H=r.getToken();for(;H!==17;){if(R.indexOf(H)!==-1){w();break}else if(Y.indexOf(H)!==-1)break;H=w()}}}function J(O){const R=r.getTokenValue();return O?S(R):(p(R),i.push(R)),w(),!0}function D(){switch(r.getToken()){case 11:const O=r.getTokenValue();let R=Number(O);isNaN(R)&&(N(2),R=0),S(R);break;case 7:S(null);break;case 8:S(!0);break;case 9:S(!1);break;default:return!1}return w(),!0}function _(){return r.getToken()!==10?(N(3,[],[2,5]),!1):(J(!1),r.getToken()===6?(y(":"),w(),z()||N(4,[],[2,5])):N(5,[],[2,5]),i.pop(),!0)}function T(){f(),w();let O=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(O||N(4,[],[]),y(","),w(),r.getToken()===2&&C)break}else O&&N(6,[],[]);_()||N(4,[],[2,5]),O=!0}return h(),r.getToken()!==2?N(7,[2],[]):w(),!0}function I(){g(),w();let O=!0,R=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(R||N(4,[],[]),y(","),w(),r.getToken()===4&&C)break}else R&&N(6,[],[]);O?(i.push(0),O=!1):i[i.length-1]++,z()||N(4,[],[4,5]),R=!0}return v(),O||i.pop(),r.getToken()!==4?N(8,[4],[]):w(),!0}function z(){switch(r.getToken()){case 3:return I();case 1:return T();case 10:return J(!0);default:return D()}}return w(),r.getToken()===17?n.allowEmptyContent?!0:(N(4,[],[]),!1):z()?(r.getToken()!==17&&N(9,[],[]),!0):(N(4,[],[]),!1)}function Fy(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 yl;(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"})(yl||(yl={}));var bl;(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"})(bl||(bl={}));const Ly=My;var vl;(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"})(vl||(vl={}));const By=60,Zy=/§jtoc:\d+§/g;function Oe(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 $o(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=By,n=!1){const r=e.replace(Zy,"…"),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 Vy(e){const t=Et(Oe(e,"columns"));if(t.length>0)return`${Math.max(0,...t.map(i=>Et(Oe(i,"cells")).length))}×${t.length}`;const n=Et(Oe(e,"rows"));if(n.length>0){const r=n[0],i=(r==null?void 0:r.type)==="array"?Et(r).length:Et(Oe(r,"cells")).length;return i>0?`${n.length}×${i}`:`${n.length} rows`}}function Uy(e){const t=st(Oe(e,"alt"));if(t)return vt(t);const n=st(Oe(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 Jy(e,t){var r;const n=st(Oe(t,"text"));switch(e){case"heading":{const i=$o(Oe(t,"level"))??1;return{label:n?vt(n):"heading",detail:`H${i}`}}case"text":return{label:n?vt(n):"text",detail:st(Oe(t,"style"))};case"paragraph":return{label:n?vt(n):"paragraph"};case"chart":case"highcharts":{const i=st(Oe(t,"title"))??st(Oe(Oe(t,"options"),"title"));return{label:i?vt(i):e,detail:st(Oe(t,"type"))}}case"table":return{label:"table",detail:Vy(t)};case"image":return{label:Uy(t)};case"shape":return{label:st(Oe(t,"type"))??"shape"};case"list":{const i=Et(Oe(t,"items"));return{label:"list",detail:i.length>0?`${i.length} items`:void 0}}case"section":{const i=st(Oe(Oe(t,"meta"),"title"))??st(Oe(t,"title"));return{label:i?vt(i):"section"}}case"statistic":{const i=st(Oe(t,"value"))??((r=$o(Oe(t,"value")))==null?void 0:r.toString()),s=st(Oe(t,"label"));return{label:vt(s??i??"statistic"),detail:i}}default:return{label:n?vt(n):e}}}function yr(e){if(e.type!=="object")return null;const t=st(Oe(e,"name"));return t?{name:t,props:Oe(e,"props"),childrenArr:Oe(e,"children")}:null}function Hy(e){let t;for(const n of Et(e)){const r=yr(n);if(!r)continue;const i=st(Oe(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 Xi(e,t,n){let{label:r,detail:i}=Jy(t.name,t.props);return r===t.name&&t.childrenArr&&(r=Hy(t.childrenArr)??r),{id:"",kind:t.name,label:r,detail:i,start:e.offset,end:e.offset+e.length,children:Sf(t.childrenArr),reorder:n}}function Sf(e){if(!e||e.type!=="array")return[];const t=`arr@${e.offset}`,n=[];for(const r of Et(e)){const i=yr(r);i&&n.push(Xi(r,i,{groupId:t,sliceStart:r.offset,sliceEnd:r.offset+r.length}))}return n}function Wy(e){const t=Oe(e,"props"),n=st(Oe(Oe(t,"meta"),"title"));if(n)return vt(n,48,!0);let r;const i=(a,l)=>{l&&(!r||a<r.rank)&&(r={rank:a,text:l})},s=Oe(t,"placeholders");if((s==null?void 0:s.type)==="object"&&s.children)for(const a of s.children){if(a.type!=="property"||!a.children)continue;const[l,c]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:"",f=c?yr(c):null,p=f?st(Oe(f.props,"text")):void 0;i(d==="title"?0:d==="subtitle"||d.startsWith("heading")?1:2,p)}const o=(a,l)=>{const c=yr(a);if(c){if(c.name==="text"||c.name==="heading"){const d=st(Oe(c.props,"text"));if(d){const f=st(Oe(c.props,"style"))??"";i(f==="title"?0:f.startsWith("heading")?1:2,d)}}if(l<1)for(const d of Et(c.childrenArr))o(d,l+1)}};for(const a of Et(Oe(e,"children")))o(a,0);return r?vt(r.text,48,!0):void 0}function qy(e){const t=Oe(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[];let i=0;for(const s of Et(t)){const o=yr(s);if(!o)continue;const a={groupId:n,sliceStart:s.offset,sliceEnd:s.offset+s.length};o.name==="slide"?(i+=1,r.push({id:"",kind:"slide",label:Wy(s)??`Slide ${i}`,detail:`${i}`,start:s.offset,end:s.offset+s.length,children:Sf(o.childrenArr),reorder:a})):r.push(Xi(s,o,a))}return r}function Gy(e){const t=Oe(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[],i=[];for(const o of Et(t)){const a=yr(o);if(!a)continue;const l={groupId:n,sliceStart:o.offset,sliceEnd:o.offset+o.length},c=()=>i.length?i[i.length-1].node.children:r;if(a.name==="heading"){const d=$o(Oe(a.props,"level"))??1;for(;i.length&&i[i.length-1].level>=d;)i.pop();const f=Xi(o,a,l);c().push(f),i.push({level:d,node:f})}else c().push(Xi(o,a,l))}const s=o=>{o.children.forEach(s);const a=o.children[o.children.length-1];o.kind==="heading"&&a&&(o.end=Math.max(o.end,a.end),o.reorder&&a.reorder&&(o.reorder.sliceEnd=Math.max(o.reorder.sliceEnd,a.reorder.sliceEnd)))};return r.forEach(s),r}function wl(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 Yy(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 o=[];if(i.type==="object"&&i.children)for(const a of i.children){if(a.type!=="property"||!a.children)continue;const[l,c]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:void 0;!d||!c||o.push({id:"",kind:"key",label:d,detail:wl(c),start:a.offset,end:a.offset+a.length,children:[]})}t.push({id:"",kind:"key",label:s,detail:o.length===0?wl(i):void 0,start:n.offset,end:n.offset+n.length,children:o})}return t}function kl(e,t,n){if(!e.trim())return[];const r=Ly(e,[],{allowTrailingComma:!0});if(!r)return[];const i=n==="theme"?Yy(r):t==="pptx"?qy(r):Gy(r);return _f(i,""),i}function _f(e,t){e.forEach((n,r)=>{n.id=t?`${t}.${r}`:`${r}`,_f(n.children,n.id)})}function jf(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 Ky(e,t){const n=new Set;for(const r of t)for(const i of jf(e,r))n.add(i);return n}function Xy(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 o=i.map(d=>e.slice(d.sliceStart,d.sliceEnd)),a=[];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;a.push(f)}const l=o.map((d,f)=>f);l.splice(r,0,l.splice(n,1)[0]);let c="";return l.forEach((d,f)=>{c+=o[d],f<a.length&&(c+=a[f])}),{start:i[0].sliceStart,end:i[i.length-1].sliceEnd,text:c}}const Qy={slide:Pg,heading:Og,text:jo,paragraph:zg,chart:No,highcharts:No,table:Ag,image:Ig,shape:Ed,list:Tg,toc:Cg,section:tl,columns:tl,"text-box":jo,statistic:Eg,key:_o};function eb(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 tb(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(0,t)}function nb(){const{activeTab:e,documentTypes:t}=Ce(da(D=>({activeTab:D.activeTab,documentTypes:D.documentTypes}))),n=Ce(D=>{var _;return D.activeTab?(_=D.documents.find(T=>T.name===D.activeTab))==null?void 0:_.text:void 0}),r=tx(D=>e?D.editors.get(e)??null:null),i=e&&t[e]==="application/json+theme"?"theme":"document",[s,o]=x.useState(()=>{try{const D=localStorage.getItem("dev-env.outline-open");return D?D==="true":!0}catch{return!0}});x.useEffect(()=>{try{localStorage.setItem("dev-env.outline-open",String(s))}catch{}},[s]);const[a,l]=x.useState([]),[c,d]=x.useState(null),[f,p]=x.useState(()=>new Set),[h,g]=x.useState(()=>new Set),[v,S]=x.useState(null),y=x.useRef(a);y.current=a;const j=x.useRef(null),m=x.useRef(null),A=x.useCallback(()=>{var T;if(!e){l([]);return}const D=((T=r==null?void 0:r.editor.getModel())==null?void 0:T.getValue())??n??"",_=kl(D,ot,i);if(l(_),m.current!==e){m.current=e;const I=new Set;if(i==="document"&&ot==="docx")for(const z of _)z.kind==="heading"&&I.add(z.id);g(I),d(null)}},[e,r,n,i]);x.useEffect(()=>{A();const D=r==null?void 0:r.editor.getModel();if(!D)return;const _=rl(A,300),T=D.onDidChangeContent(()=>_());return()=>{_.cancel(),T.dispose()}},[A,r]),x.useEffect(()=>{if(!r)return;const{editor:D}=r,_=rl(()=>{const I=D.getModel(),z=D.getPosition();if(!I||!z)return;const O=I.getOffsetAt(z),R=jf(y.current,O);if(R.length===0){d(null);return}d(R[R.length-1]);const Y=R.slice(0,-1);Y.length&&g(H=>{if(Y.every(ee=>H.has(ee)))return H;const $=new Set(H);for(const ee of Y)$.add(ee);return $})},150),T=D.onDidChangeCursorPosition(()=>_());return()=>{_.cancel(),T.dispose()}},[r]),x.useEffect(()=>{if(!c||!j.current)return;const D=j.current.querySelector(`[data-oid="${CSS.escape(c)}"]`);D==null||D.scrollIntoView({block:"nearest"})},[c]),x.useEffect(()=>{if(!r){p(new Set);return}const{editor:D,monaco:_}=r,T=()=>{const z=D.getModel();if(!z)return;const O=_.editor.getModelMarkers({resource:z.uri}).filter(R=>R.severity===_.MarkerSeverity.Error).map(R=>z.getOffsetAt({lineNumber:R.startLineNumber,column:R.startColumn}));p(Ky(y.current,O))};T();const I=_.editor.onDidChangeMarkers(z=>{const O=D.getModel();O&&z.some(R=>R.toString()===O.uri.toString())&&T()});return()=>I.dispose()},[r,a]);const C=x.useCallback(D=>{g(_=>{const T=new Set(_);return T.has(D)?T.delete(D):T.add(D),T})},[]),w=x.useCallback(D=>{if(d(D.id),!r)return;const{editor:_,monaco:T}=r,I=_.getModel();if(!I)return;const z=I.getPositionAt(D.start),O=I.getPositionAt(D.end),R=new T.Range(z.lineNumber,z.column,O.lineNumber,O.column);_.revealRangeNearTopIfOutsideViewport(R,T.editor.ScrollType.Smooth),_.setPosition(z),_.focus();const Y=_.deltaDecorations([],[{range:R,options:{className:"jto-outline-flash"}}]);window.setTimeout(()=>_.deltaDecorations(Y,[]),700)},[r]),N=x.useCallback(D=>{var b;if(!r||!D.overId)return;const{editor:_,monaco:T,collapse:I}=r,z=_.getModel();if(!z)return;const O=z.getValue(),R=kl(O,ot,i),Y=D.parentId?((b=eb(R,D.parentId))==null?void 0:b.children)??[]:R,H=Y.findIndex(B=>B.id===D.dragId),$=Y.findIndex(B=>B.id===D.overId);if(H===-1||$===-1)return;let ee=$+(D.overHalf==="after"?1:0);H<ee&&(ee-=1);const k=Xy(O,Y,H,ee);if(!k)return;const oe=z.getPositionAt(k.start),q=z.getPositionAt(k.end);_.executeEdits("outline-reorder",[{range:new T.Range(oe.lineNumber,oe.column,q.lineNumber,q.column),text:k.text}]),I==null||I.resyncDecorations()},[r,i]),J=x.useMemo(()=>{const D=[],_=(T,I,z)=>{var Y,H;const O=(H=(Y=T[0])==null?void 0:Y.reorder)==null?void 0:H.groupId,R=T.length>1&&O!==void 0&&T.every($=>{var ee;return((ee=$.reorder)==null?void 0:ee.groupId)===O});T.forEach($=>{const ee=Qy[$.kind]??Dg,k=$.children.length>0,oe=h.has($.id),q=c===$.id,b=(v==null?void 0:v.overId)===$.id;D.push(u.jsxs("div",{"data-oid":$.id,role:"treeitem","aria-selected":q,"aria-expanded":k?oe:void 0,tabIndex:0,draggable:R,onClick:()=>w($),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),w($)),B.key==="ArrowRight"&&k&&!oe&&C($.id),B.key==="ArrowLeft"&&k&&oe&&C($.id)},onDragStart:B=>{B.dataTransfer.setData("text/plain",$.id),B.dataTransfer.effectAllowed="move",S({dragId:$.id,parentId:z,overId:null,overHalf:"before"})},onDragOver:B=>{if(!v||v.dragId===$.id||tb(v.dragId)!==z)return;B.preventDefault(),B.dataTransfer.dropEffect="move";const V=B.currentTarget.getBoundingClientRect(),re=B.clientY<V.top+V.height/2?"before":"after";(v.overId!==$.id||v.overHalf!==re)&&S({...v,overId:$.id,overHalf:re})},onDrop:B=>{B.preventDefault(),v&&N({...v,overId:$.id,overHalf:v.overHalf}),S(null)},onDragEnd:()=>S(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",q&&"bg-sidebar-accent font-medium text-sidebar-foreground",b&&(v==null?void 0:v.overHalf)==="before"&&"shadow-[inset_0_2px_0_hsl(var(--ring))]",b&&(v==null?void 0:v.overHalf)==="after"&&"shadow-[inset_0_-2px_0_hsl(var(--ring))]"),style:{paddingLeft:4+I*12},children:[k?u.jsx("span",{role:"button","aria-label":oe?"Collapse":"Expand",onClick:B=>{B.stopPropagation(),C($.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(Pn,{className:G("size-3 transition-transform",oe&&"rotate-90")})}):u.jsx("span",{className:"size-3.5 shrink-0"}),$.kind==="slide"&&u.jsx("span",{className:"w-3 shrink-0 text-right text-[10px] tabular-nums text-sidebar-foreground/50",children:$.detail}),u.jsx(ee,{className:"size-3.5 shrink-0 text-sidebar-foreground/55"}),u.jsx("span",{className:"min-w-0 flex-1 truncate",children:$.label}),$.kind!=="slide"&&$.detail&&u.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/50",children:$.detail}),f.has($.id)&&u.jsx("span",{"aria-label":"Contains validation errors",className:"bg-destructive size-1.5 shrink-0 rounded-full"})]},$.id)),k&&oe&&_($.children,I+1,$.id)})};return _(a,0,""),D},[a,h,c,f,v,w,C,N]);return e?u.jsxs("section",{className:"mt-3 shrink-0",children:[u.jsx(Do,{count:a.length||void 0,actions:u.jsx($t,{"aria-label":s?"Collapse outline":"Expand outline","aria-expanded":s,onClick:()=>o(D=>!D),children:u.jsx(Pn,{className:G("transition-transform",s&&"rotate-90")})}),children:"Outline"}),s&&(a.length>0?u.jsx("div",{ref:j,role:"tree","aria-label":"Document outline",className:"max-h-[45vh] overflow-y-auto",children:J}):u.jsx("p",{className:"px-2 py-1 text-[12px] leading-tight text-sidebar-foreground/60",children:"No structure to show yet."}))]}):null}const rb=x.memo(nb);async function ib(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const ni=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(md,{ref:r,className:G("relative overflow-hidden",e),...n,children:[u.jsx(ag,{className:"h-full w-full rounded-[inherit]",children:t}),u.jsx(Nf,{}),u.jsx(lg,{})]}));ni.displayName=md.displayName;const Nf=x.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(gd,{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(ug,{className:"bg-border relative flex-1 rounded-full"})}));Nf.displayName=gd.displayName;function va({className:e,...t}){return u.jsx(cg,{"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(dg,{"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=mi("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"}}),or=x.forwardRef(({className:e,variant:t,...n},r)=>u.jsx("div",{ref:r,role:"alert",className:G(sb({variant:t}),e),...n}));or.displayName="Alert";const ob=x.forwardRef(({className:e,...t},n)=>u.jsx("h5",{ref:n,className:G("mb-1 font-medium leading-none tracking-tight",e),...t}));ob.displayName="AlertTitle";const ar=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:G("text-sm [&_p]:leading-relaxed",e),...t}));ar.displayName="AlertDescription";const Qi=x.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=x.useState(n<2),o=t!==null&&typeof t=="object",a=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=o?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:[o&&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(hi,{className:"h-3 w-3"}):u.jsx(Pn,{className:"h-3 w-3"})}),!o&&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:":"})]}),o?u.jsxs("span",{className:"text-muted-foreground",children:[a?"[":"{",!i&&u.jsxs("span",{className:"mx-1 text-xs",children:[d," ",a?"items":"properties"]}),!i&&(a?"]":"}")]}):c(),!o&&!r&&u.jsx("span",{className:"text-muted-foreground",children:","})]}),o&&i&&u.jsxs("div",{className:"ml-4",children:[a?t.map((f,p)=>u.jsx(Qi,{keyName:String(p),value:f,depth:n+1,isLast:p===t.length-1},p)):Object.entries(t).map(([f,p],h,g)=>u.jsx(Qi,{keyName:f,value:p,depth:n+1,isLast:h===g.length-1},f)),u.jsx("div",{className:"ml-4",children:u.jsxs("span",{className:"text-muted-foreground",children:[a?"]":"}",!r&&","]})})]})]})});Qi.displayName="JsonNode";const es=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(or,{variant:"destructive",className:r,children:u.jsx(ar,{children:n})}):e?u.jsx(ni,{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(Qi,{value:e})})}):u.jsx(or,{className:r,children:u.jsx(ar,{children:"No schema available"})}));es.displayName="SchemaViewer";function ab({plugins:e,initialFocusedPlugin:t}){var m,A;const n=Bt(C=>C.togglePlugin),r=Bt(C=>C.isPluginSelected),i=Bt(C=>C.selectedPlugins),s=Bt(C=>C.isApplyingPlugins),[o,a]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState("properties");x.useEffect(()=>{if(t){const C=e.find(w=>w.name===t);if(C){a(C);return}}e.length>0&&!o&&a(e[0])},[t,e]);const p=x.useMemo(()=>{const C={current:[],downstream:[],upstream:[]};return e.forEach(w=>{C[w.location]&&C[w.location].push(w)}),C},[e]),h=async(C,w)=>{o&&(await ib(o.name,C.props),c(w),setTimeout(()=>c(null),2e3))},g=C=>{switch(C){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return C}},v=C=>{switch(C){case"current":return u.jsx(Bg,{className:"size-3"});case"downstream":return u.jsx(Lg,{className:"size-3"});case"upstream":return u.jsx(jd,{className:"size-3"});default:return null}},S=((m=o==null?void 0:o.schema)==null?void 0:m.properties)&&Object.keys(o.schema.properties).length>0,y=(A=o==null?void 0:o.schema)==null?void 0:A.jsonSchema,j=(o==null?void 0:o.examples)&&o.examples.length>0;return u.jsxs(u.Fragment,{children:[u.jsxs(Ut,{children:[u.jsxs(Jt,{className:"flex items-center gap-2",children:[u.jsx(Rg,{className:"size-5 text-warning"}),"Plugins",u.jsxs(Kt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),u.jsxs(an,{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(ni,{className:"h-full",children:u.jsx("div",{className:"p-2 space-y-3",children:Object.entries(p).map(([C,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(C),g(C)]}),u.jsx("div",{className:"space-y-0.5",children:w.map(N=>{const J=r(N.name),D=(o==null?void 0:o.name)===N.name;return u.jsxs("button",{onClick:()=>a(N),className:G("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",D?"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",J?"bg-warning":"bg-muted-foreground/30")}),u.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.name})]},N.name)})})]},C))})})}),o?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:o.name}),o.version&&u.jsxs(Kt,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",o.version]})]}),o.description&&u.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:o.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(o.name)?"On":"Off"}),u.jsx(va,{checked:r(o.name),onCheckedChange:()=>n(o),disabled:s,"aria-label":`Toggle ${o.name}`})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[v(o.location),u.jsx("span",{children:g(o.location)}),u.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),u.jsx("span",{className:"font-mono truncate",children:o.relativePath})]})]}),u.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&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(_o,{className:"size-3.5"}),"Properties"]})}),y&&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(Mg,{className:"size-3.5"}),"Schema"]})}),j&&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($g,{className:"size-3.5"}),"Examples",u.jsx(Kt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:o.examples.length})]})})]}),u.jsx(ni,{className:"flex-1",children:u.jsxs("div",{className:"p-5",children:[d==="properties"&&S&&u.jsx("div",{className:"space-y-1",children:Object.entries(o.schema.properties).map(([C,w])=>u.jsx(lb,{name:C,prop:w},C))}),d==="schema"&&y&&u.jsx(es,{schema:o.schema.jsonSchema,loading:!1,className:"h-[420px]"}),d==="examples"&&j&&o.examples.map((C,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:[C.title&&u.jsx("span",{className:"font-medium text-sm truncate",children:C.title}),!C.title&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",w+1]})]}),u.jsx(_e,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>h(C,w),children:l===w?u.jsxs(u.Fragment,{children:[u.jsx(Fg,{className:"size-3 mr-1 text-success"}),"Copied"]}):u.jsxs(u.Fragment,{children:[u.jsx(ws,{className:"size-3 mr-1"}),"Copy"]})})]}),C.description&&u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:C.description}),u.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(C.props,null,2)})]},w)),!S&&!y&&!j&&u.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[u.jsx(_o,{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 o;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(hi,{className:"size-3 text-muted-foreground flex-none"}):u.jsx(Pn,{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((a,l)=>u.jsxs("span",{children:[l>0&&", ",u.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(a)})]},l))]}),((o=t.items)==null?void 0:o.type)&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const ub=fg,cb=pg,db=hg,fb={current:"Current directory",downstream:"Project"};function Gs({id:e,label:t,count:n,open:r,onToggle:i,children:s}){return u.jsxs(ub,{open:r,children:[u.jsxs(cb,{onClick:()=>i(e),className:G("flex h-7 w-full 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:[u.jsx(Pn,{className:G("size-3 shrink-0 transition-transform duration-150 ease-out",r&&"rotate-90")}),u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:t}),u.jsx("span",{className:"ml-auto text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:n})]}),u.jsx(db,{children:u.jsx("div",{className:"border-sidebar-border/70 mt-0.5 ml-[13px] border-l pl-1",children:s})})]})}function Sl({location:e}){return u.jsx("div",{className:"px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:fb[e]??e})}function _l({name:e,subtitle:t,added:n,query:r,onSelect:i}){return u.jsxs("button",{type:"button",onClick:i,title:t?`${e} — ${t}`:e,"aria-label":n?`Open ${e}`:`Add ${e} to workspace`,className:G("group/row flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm px-2","text-[13px] transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none","text-sidebar-foreground/70"),children:[u.jsx("span",{className:"truncate",children:u.jsx(ya,{text:e,query:r})}),n?u.jsx("span",{className:"ml-auto shrink-0 text-[10px] tracking-[0.06em] text-sidebar-foreground/65 uppercase",children:"Open"}):u.jsx(nn,{"aria-hidden":!0,className:"ml-auto 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 pb({documents:e,themes:t,plugins:n,openNames:r,query:i,expandedGroups:s,onToggleGroup:o,onQuickAdd:a,onShowPluginDetails:l,isPluginSelected:c,onTogglePlugin:d,isApplyingPlugins:f,selectedPluginCount:p}){const h=y=>i?!0:s.has(y),g=x.useMemo(()=>jl(e),[e]),v=x.useMemo(()=>jl(t),[t]);return e.length>0||t.length>0||n.length>0?u.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.length>0&&u.jsx(Gs,{id:"library-documents",label:"Project documents",count:e.length,open:h("library-documents"),onToggle:o,children:g.map(([y,j])=>u.jsxs(je.Fragment,{children:[g.length>1&&u.jsx(Sl,{location:y}),j.map(m=>u.jsx(_l,{name:m.name,subtitle:m.title,added:r.has(m.name),query:i,onSelect:()=>a(m.name,!1)},m.path||m.name))]},y))}),t.length>0&&u.jsx(Gs,{id:"library-themes",label:"Project themes",count:t.length,open:h("library-themes"),onToggle:o,children:v.map(([y,j])=>u.jsxs(je.Fragment,{children:[v.length>1&&u.jsx(Sl,{location:y}),j.map(m=>u.jsx(_l,{name:m.name,subtitle:m.description,added:r.has(m.name),query:i,onSelect:()=>a(m.name,!0)},m.path||m.name))]},y))}),n.length>0&&u.jsx(Gs,{id:"library-plugins",label:"Plugins",count:`${p}/${n.length}`,open:h("library-plugins"),onToggle:o,children:n.map(y=>{const j=c(y.name),m=`plugin-switch-${y.filePath||y.name}`;return u.jsxs("div",{title:y.description?`${y.name} — ${y.description}`:y.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:m,className:G("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]",j?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:u.jsx("span",{className:"truncate",children:u.jsx(ya,{text:y.name,query:i})})}),u.jsx($t,{"aria-label":`Details for ${y.name}`,onClick:A=>{A.stopPropagation(),l(y.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:u.jsx(Cd,{})}),u.jsx(va,{id:m,checked:j,onCheckedChange:()=>d(y),disabled:f,className:"shrink-0","aria-label":`Toggle ${y.name} plugin`})]},y.filePath||y.name)})})]}):null}function jl(e){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))}function Ef({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 hb({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 ri({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(hb,{className:t,children:r.map((i,s)=>u.jsx(Ef,{children:i},s))})}function mb({className:e}={}){const{theme:t,setTheme:n}=vd(),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(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(_e,{variant:"ghost",size:"icon",onClick:i,className:e,children:[u.jsx(Zg,{className:"hidden dark:block"}),u.jsx(Vg,{className:"block dark:hidden"}),u.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),u.jsx(Ye,{children:u.jsx("p",{children:"Toggle theme"})})]})}function gb({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:o,openDocument:a}=Ce(da(U=>({documents:U.documents,documentTypes:U.documentTypes,createDocument:U.createDocument,openDocument:U.openDocument}))),l=To(U=>U.updateTheme),c=To(U=>U.removeTheme),d=x.useContext(Od),[f,p]=x.useState(!1),[h,g]=x.useState(!1),[v,S]=x.useState(!1),[y,j]=x.useState(null),m=Bt(U=>U.togglePlugin),A=Bt(U=>U.isPluginSelected),C=Bt(U=>U.selectedPlugins),w=Bt(U=>U.isApplyingPlugins),[N,J]=x.useState(!1),[D,_]=x.useState(new Set(["library-documents"])),[T,I]=x.useState(""),z=x.useRef(null),{toast:O}=jr(),R=i.filter(U=>s[U.name]!=="application/json+theme"),Y=i.filter(U=>s[U.name]==="application/json+theme"),H=x.useCallback(()=>{p(!1)},[]),$=x.useCallback(()=>{g(!1)},[]),ee=x.useRef(new Map);x.useEffect(()=>{const U=ee.current,Te=new Map;Y.forEach(X=>{Te.set(X.name,X.text),U.get(X.name)!==X.text&&l(X.name,X.text)}),U.forEach((X,we)=>{Te.has(we)||c(we)}),ee.current=Te},[Y,l,c]);const k=x.useRef(!1);x.useEffect(()=>{if(k.current||!d)return;k.current=!0;const U=new Set(Y.map(X=>X.name));Object.keys(d.getState().customThemes).forEach(X=>{U.has(X)||c(X)})},[Y,c,d]);const oe=x.useCallback(U=>{_(Te=>{const X=new Set(Te);return X.has(U)?X.delete(U):X.add(U),X})},[]),{resolvedTheme:q}=vd(),b=q==="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",B=x.useCallback(async(U,Te)=>{if(i.some(X=>X.name===U)){a(U);return}try{const X=await fetch(`/api/discovery/${Te?"themes":"documents"}/${encodeURIComponent(U)}/content`);if(!X.ok)throw new Error(X.statusText);const we=await X.text(),E=JSON.parse(we);o(U,JSON.stringify(E,null,2)),a(U),O({title:`Added ${Te?"theme":"document"}: ${U}`})}catch{O({title:"Failed to load",description:`Could not load ${U}`,variant:"destructive"})}},[i,o,a,O]);x.useEffect(()=>{if(n)return;const U=Te=>{var E,M,F,ne,Q;if(Te.key!=="/"||Te.metaKey||Te.ctrlKey||Te.altKey)return;const X=Te.target,we=(E=X==null?void 0:X.tagName)==null?void 0:E.toLowerCase();we==="input"||we==="textarea"||we==="select"||X!=null&&X.isContentEditable||(M=X==null?void 0:X.closest)!=null&&M.call(X,".monaco-editor")||(F=z.current)!=null&&F.closest('[aria-hidden="true"], [inert]')||(Te.preventDefault(),(ne=z.current)==null||ne.focus(),(Q=z.current)==null||Q.select())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[n]);const V=T.trim(),re=x.useMemo(()=>new Set(i.map(U=>U.name)),[i]),se=x.useMemo(()=>R.filter(U=>cn(U.name,V)),[R,V]),P=x.useMemo(()=>Y.filter(U=>cn(U.name,V)),[Y,V]),ue=x.useMemo(()=>((e==null?void 0:e.documents)??[]).filter(U=>cn(U.name,V)||cn(U.title??"",V)),[e,V]),he=x.useMemo(()=>((e==null?void 0:e.themes)??[]).filter(U=>cn(U.name,V)||cn(U.description??"",V)),[e,V]),ce=x.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter(U=>cn(U.name,V)||cn(U.description??"",V)),[e,V]),pe=V.length>0&&se.length===0&&P.length===0&&ue.length===0&&he.length===0&&ce.length===0,me=G("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return u.jsxs(u.Fragment,{children:[u.jsxs(yf,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?u.jsxs(u.Fragment,{children:[u.jsx(Ro,{className:G("gap-0 p-1.5",me),children:u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:u.jsx(Td,{})})}),u.jsxs(Ye,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Expand sidebar"}),u.jsx(ri,{shortcut:"mod+b"})]})]})}),u.jsxs(Mo,{className:G("gap-2 px-1 py-1",me),children:[u.jsxs(Br,{className:"items-center gap-0.5",children:[R.map(U=>u.jsx(Ni,{document:U,compact:!0},U.name)),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"right",children:"New document"})]})]}),u.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),u.jsxs(Br,{className:"items-center gap-0.5",children:[Y.map(U=>u.jsx(Ni,{document:U,compact:!0},U.name)),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{className:"size-7","aria-label":"New theme",onClick:()=>g(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"right",children:"New theme"})]})]})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs(Ro,{className:G("gap-0 p-2",me),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:b,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:u.jsx(Ug,{})})}),u.jsxs(Ye,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Collapse sidebar"}),u.jsx(ri,{shortcut:"mod+b"})]})]})]}),u.jsxs("div",{className:"relative mt-2",children:[u.jsx(Jg,{"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:z,type:"text",value:T,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:U=>I(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),I(""),U.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")}),V?u.jsx($t,{"aria-label":"Clear filter",onClick:()=>{var U;I(""),(U=z.current)==null||U.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:u.jsx(xn,{})}):u.jsx(Ef,{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(Mo,{className:G("gap-0 px-2 pb-2",me),children:pe?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 “",V,"”"]}),u.jsx("button",{type:"button",onClick:()=>{var U;I(""),(U=z.current)==null||U.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:[(se.length>0||!V)&&u.jsxs("section",{children:[u.jsx(Do,{count:(V?se.length:R.length)||void 0,actions:u.jsxs(u.Fragment,{children:[ot==="docx"&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"Compare documents",disabled:R.length<2,onClick:()=>J(!0),children:u.jsx(Sd,{})})}),u.jsx(Ye,{side:"bottom",children:R.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),u.jsx(Br,{className:"gap-0.5",children:se.length>0?se.map(U=>u.jsx(Ni,{document:U,query:V},U.name)):u.jsx(gl,{icon:nn,label:"New document",onClick:()=>p(!0)})})]}),(P.length>0||!V)&&u.jsxs("section",{className:"mt-3",children:[u.jsx(Do,{count:(V?P.length:Y.length)||void 0,actions:u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"New theme",onClick:()=>g(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"bottom",children:"New theme"})]}),children:"Themes"}),u.jsx(Br,{className:"gap-0.5",children:P.length>0?P.map(U=>u.jsx(Ni,{document:U,query:V},U.name)):u.jsx(gl,{icon:nn,label:"New theme",onClick:()=>g(!0)})})]}),!V&&u.jsx(rb,{}),(ue.length>0||he.length>0||ce.length>0)&&u.jsx("div",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:u.jsx(pb,{documents:ue,themes:he,plugins:ce,openNames:re,query:V,expandedGroups:D,onToggleGroup:oe,onQuickAdd:B,onShowPluginDetails:U=>{j(U),S(!0)},isPluginSelected:A,onTogglePlugin:m,isApplyingPlugins:w,selectedPluginCount:C.size})})]})})]}),u.jsx(bf,{className:G("border-sidebar-border/70 gap-0 border-t p-1.5",me),children:u.jsx("div",{className:G("flex items-center",n?"justify-center":"justify-start"),children:u.jsx(mb,{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:f,onOpenChange:p,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Yi,{mode:"create",shouldReset:!f,postSubmit:H,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),u.jsx(Ct,{open:h,onOpenChange:g,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Yi,{mode:"create",shouldReset:!h,postSubmit:$,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),u.jsx(Ct,{open:v,onOpenChange:U=>{S(U),U||j(null)},children:u.jsx(kt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:u.jsx(ab,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:y})})}),u.jsx(vx,{open:N,onOpenChange:J})]})}const Nl=x.memo(gb),xb=x.lazy(()=>wd(()=>import("./editor-ouhvdGgK.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function El(){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(sn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:u.jsx(xb,{})})}const yb=x.lazy(()=>wd(()=>import("./preview-D3QYaLPp.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function Cl(){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(sn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:u.jsx(yb,{})})}const{createElement:br,createContext:bb,forwardRef:Cf,useCallback:gt,useContext:Tf,useEffect:zn,useImperativeHandle:If,useLayoutEffect:vb,useMemo:wb,useRef:wt,useState:lr}=Fc,Tl=Fc[`useId${Math.random()}`.slice(0,5)],kb=vb,Cs=bb(null);Cs.displayName="PanelGroupContext";const On=kb,Sb=typeof Tl=="function"?Tl:()=>null;let _b=0;function wa(e=null){const t=Sb(),n=wt(e||t||null);return n.current===null&&(n.current=""+_b++),e??n.current}function Af({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:o,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:p,style:h,tagName:g="div",...v}){const S=Tf(Cs);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:y,expandPanel:j,getPanelSize:m,getPanelStyle:A,groupId:C,isPanelCollapsed:w,reevaluatePanelConstraints:N,registerPanel:J,resizePanel:D,unregisterPanel:_}=S,T=wa(o),I=wt({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:T,idIsFromProps:o!==void 0,order:p});wt({didLogMissingDefaultSizeWarning:!1}),On(()=>{const{callbacks:O,constraints:R}=I.current,Y={...R};I.current.id=T,I.current.idIsFromProps=o!==void 0,I.current.order=p,O.onCollapse=c,O.onExpand=d,O.onResize=f,R.collapsedSize=n,R.collapsible=r,R.defaultSize=i,R.maxSize=a,R.minSize=l,(Y.collapsedSize!==R.collapsedSize||Y.collapsible!==R.collapsible||Y.maxSize!==R.maxSize||Y.minSize!==R.minSize)&&N(I.current,Y)}),On(()=>{const O=I.current;return J(O),()=>{_(O)}},[p,T,J,_]),If(s,()=>({collapse:()=>{y(I.current)},expand:O=>{j(I.current,O)},getId(){return T},getSize(){return m(I.current)},isCollapsed(){return w(I.current)},isExpanded(){return!w(I.current)},resize:O=>{D(I.current,O)}}),[y,j,m,w,T,D]);const z=A(I.current,i);return br(g,{...v,children:e,className:t,id:o,style:{...z,...h},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":C,"data-panel-id":T,"data-panel-size":parseFloat(""+z.flexGrow).toFixed(1)})}const zf=Cf((e,t)=>br(Af,{...e,forwardedRef:t}));Af.displayName="Panel";zf.displayName="forwardRef(Panel)";let Fo=null,An=null;function jb(e,t){if(t){const n=(t&Mf)!==0,r=(t&$f)!==0,i=(t&Ff)!==0,s=(t&Lf)!==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 Nb(){An!==null&&(document.head.removeChild(An),Fo=null,An=null)}function Ys(e,t){const n=jb(e,t);Fo!==n&&(Fo=n,An===null&&(An=document.createElement("style"),document.head.appendChild(An)),An.innerHTML=`*{cursor: ${n}!important;}`)}function Of(e){return e.type==="keydown"}function Pf(e){return e.type.startsWith("pointer")}function Df(e){return e.type.startsWith("mouse")}function Ts(e){if(Pf(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Df(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Eb(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Cb(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 Tb(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:zl(e),b:zl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ee(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Al(Il(n.a)),b:Al(Il(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const Ib=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ab(e){var t;const n=getComputedStyle((t=Rf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function zb(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Ab(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"||Ib.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Il(e){let t=e.length;for(;t--;){const n=e[t];if(Ee(n,"Missing node"),zb(n))return n}return null}function Al(e){return e&&Number(getComputedStyle(e).zIndex)||0}function zl(e){const t=[];for(;e;)t.push(e),e=Rf(e);return t}function Rf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Mf=1,$f=2,Ff=4,Lf=8,Ob=Eb()==="coarse";let Zt=[],ur=!1,mn=new Map,Is=new Map;const ii=new Set;function Pb(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=mn.get(o))!==null&&s!==void 0?s:0;return mn.set(o,l+1),ii.add(a),ts(),function(){var d;Is.delete(e),ii.delete(a);const f=(d=mn.get(o))!==null&&d!==void 0?d:1;if(mn.set(o,f-1),ts(),f===1&&mn.delete(o),Zt.includes(a)){const p=Zt.indexOf(a);p>=0&&Zt.splice(p,1),Sa(),i("up",!0,null)}}}function Ol(e){const{target:t}=e,{x:n,y:r}=Ts(e);ur=!0,ka({target:t,x:n,y:r}),ts(),Zt.length>0&&(ns("down",e),e.preventDefault(),e.stopPropagation())}function Pr(e){const{x:t,y:n}=Ts(e);if(ur&&e.buttons===0&&(ur=!1,ns("up",e)),!ur){const{target:r}=e;ka({target:r,x:t,y:n})}ns("move",e),Sa(),Zt.length>0&&e.preventDefault()}function Jn(e){const{target:t}=e,{x:n,y:r}=Ts(e);Is.clear(),ur=!1,Zt.length>0&&e.preventDefault(),ns("up",e),ka({target:t,x:n,y:r}),Sa(),ts()}function ka({target:e,x:t,y:n}){Zt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),ii.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:l,left:c,right:d,top:f}=a,p=Ob?o.coarse:o.fine;if(t>=c-p&&t<=d+p&&n>=f-p&&n<=l+p){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Tb(r,s)>0){let g=r,v=!1;for(;g&&!g.contains(s);){if(Cb(g.getBoundingClientRect(),a)){v=!0;break}g=g.parentElement}if(v)return}Zt.push(i)}})}function Ks(e,t){Is.set(e,t)}function Sa(){let e=!1,t=!1;Zt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;Is.forEach(r=>{n|=r}),e&&t?Ys("intersection",n):e?Ys("horizontal",n):t?Ys("vertical",n):Nb()}function ts(){mn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Jn),n.removeEventListener("pointerdown",Ol),n.removeEventListener("pointerleave",Pr),n.removeEventListener("pointermove",Pr)}),window.removeEventListener("pointerup",Jn),window.removeEventListener("pointercancel",Jn),ii.size>0&&(ur?(Zt.length>0&&mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Jn),n.addEventListener("pointerleave",Pr),n.addEventListener("pointermove",Pr))}),window.addEventListener("pointerup",Jn),window.addEventListener("pointercancel",Jn)):mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",Ol,{capture:!0}),n.addEventListener("pointermove",Pr))}))}function ns(e,t){ii.forEach(n=>{const{setResizeHandlerState:r}=n,i=Zt.includes(n);r(e,i,t)})}function Db(){const[e,t]=lr(0);return gt(()=>t(n=>n+1),[])}function Ee(e,t){if(!e)throw console.error(t),Error(t)}const _a=10;function Rn(e,t,n=_a){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function on(e,t,n=_a){return Rn(e,t,n)===0}function Nt(e,t,n){return Rn(e,t,n)===0}function Rb(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 nr({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ee(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(Rn(n,a)<0)if(s){const l=(i+a)/2;Rn(n,l)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(_a)),n}function Zr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Nt(e,0))return t;const o=[...t],[a,l]=r;Ee(a!=null,"Invalid first pivot index"),Ee(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const f=e<0?l:a,p=n[f];Ee(p,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:v=0}=p;if(g){const S=t[f];if(Ee(S!=null,`Previous layout not found for panel index ${f}`),Nt(S,h)){const y=v-S;Rn(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{const f=e<0?a:l,p=n[f];Ee(p,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:v=0}=p;if(g){const S=t[f];if(Ee(S!=null,`Previous layout not found for panel index ${f}`),Nt(S,v)){const y=S-h;Rn(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{const f=e<0?1:-1;let p=e<0?l:a,h=0;for(;;){const v=t[p];Ee(v!=null,`Previous layout not found for panel index ${p}`);const y=nr({panelConstraints:n,panelIndex:p,size:100})-v;if(h+=y,p+=f,p<0||p>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-g:g}{let p=e<0?a:l;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(c),g=t[p];Ee(g!=null,`Previous layout not found for panel index ${p}`);const v=g-h,S=nr({panelConstraints:n,panelIndex:p,size:v});if(!Nt(g,S)&&(c+=g-S,o[p]=S,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(Rb(i,o))return i;{const f=e<0?l:a,p=t[f];Ee(p!=null,`Previous layout not found for panel index ${f}`);const h=p+c,g=nr({panelConstraints:n,panelIndex:f,size:h});if(o[f]=g,!Nt(g,h)){let v=h-g,y=e<0?l:a;for(;y>=0&&y<n.length;){const j=o[y];Ee(j!=null,`Previous layout not found for panel index ${y}`);const m=j+v,A=nr({panelConstraints:n,panelIndex:y,size:m});if(Nt(j,A)||(v-=A-j,o[y]=A),Nt(v,0))break;e>0?y--:y++}}}const d=o.reduce((f,p)=>p+f,0);return Nt(d,100)?o:i}function Mb({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];Ee(a!=null,"No pivot index found"),t.forEach((f,p)=>{const{constraints:h}=f,{maxSize:g=100,minSize:v=0}=h;p===a?(r=v,i=g):(s+=v,o+=g)});const l=Math.min(i,100-s),c=Math.max(r,100-o),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function si(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Bf(e,t,n=document){const i=si(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function Zf(e,t,n){const r=Bf(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Vf(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 As(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function $b(e,t,n,r=document){var i,s,o,a;const l=As(t,r),c=si(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,p=(o=(a=n[d+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null;return[f,p]}function Fb({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){wt({didWarnAboutMissingResizeHandle:!1}),On(()=>{if(!s)return;const a=si(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:d,valueNow:f}=Mb({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),p=a[l];if(p!=null){const h=i[l];Ee(h,`No panel data found for index "${l}"`),p.setAttribute("aria-controls",h.id),p.setAttribute("aria-valuemax",""+Math.round(c)),p.setAttribute("aria-valuemin",""+Math.round(d)),p.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{a.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 a=t.current;Ee(a,"Eager values not found");const{panelDataArray:l}=a,c=Vf(n,s);Ee(c!=null,`No group found for id "${n}"`);const d=si(n,s);Ee(d,`No resize handles found for group id "${n}"`);const f=d.map(p=>{const h=p.getAttribute("data-panel-resize-handle-id");Ee(h,"Resize handle element has no handle id attribute");const[g,v]=$b(n,h,l,s);if(g==null||v==null)return()=>{};const S=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();const j=l.findIndex(m=>m.id===g);if(j>=0){const m=l[j];Ee(m,`No panel data found for index ${j}`);const A=r[j],{collapsedSize:C=0,collapsible:w,minSize:N=0}=m.constraints;if(A!=null&&w){const J=Zr({delta:Nt(A,C)?N-C:C-A,initialLayout:r,panelConstraints:l.map(D=>D.constraints),pivotIndices:Zf(n,h,s),prevLayout:r,trigger:"keyboard"});r!==J&&o(J)}}break}}};return p.addEventListener("keydown",S),()=>{p.removeEventListener("keydown",S)}});return()=>{f.forEach(p=>p())}},[s,e,t,n,r,i,o])}function Pl(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 Uf(e,t){const n=e==="horizontal",{x:r,y:i}=Ts(t);return n?r:i}function Lb(e,t,n,r,i){const s=n==="horizontal",o=As(t,i);Ee(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute("data-panel-group-id");Ee(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=Uf(n,e),d=Vf(a,i);Ee(d,`No group element found for id "${a}"`);const f=d.getBoundingClientRect(),p=s?f.width:f.height;return(c-l)/p*100}function Bb(e,t,n,r,i,s){if(Of(e)){const o=n==="horizontal";let a=0;e.shiftKey?a=100:i!=null?a=i:a=10;let l=0;switch(e.key){case"ArrowDown":l=o?0:a;break;case"ArrowLeft":l=o?-a:0;break;case"ArrowRight":l=o?a:0;break;case"ArrowUp":l=o?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:Lb(e,t,n,r,s)}function Zb({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 o=n[s];Ee(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;a!=null&&(r++,t[s]=a,i-=a)}for(let s=0;s<e.length;s++){const o=n[s];Ee(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function Hn(e,t,n){t.forEach((r,i)=>{const s=e[i];Ee(s,`Panel data not found for index ${i}`);const{callbacks:o,constraints:a,id:l}=s,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:p,onExpand:h,onResize:g}=o;g&&g(r,f),d&&(p||h)&&(h&&(f==null||on(f,c))&&!on(r,c)&&h(),p&&(f==null||!on(f,c))&&on(r,c)&&p())}})}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 Vb({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const o=n[i];let a;return o==null?a=e!=null?e.toPrecision(s):"1":r.length===1?a="1":a=o.toPrecision(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Ub(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function Dl(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 Jf(e){return`react-resizable-panels:${e}`}function Hf(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 Wf(e,t){try{const n=Jf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Jb(e,t,n){var r,i;const s=(r=Wf(e,n))!==null&&r!==void 0?r:{},o=Hf(t);return(i=s[o])!==null&&i!==void 0?i:null}function Hb(e,t,n,r,i){var s;const o=Jf(e),a=Hf(t),l=(s=Wf(e,i))!==null&&s!==void 0?s:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(o,JSON.stringify(l))}catch(c){console.error(c)}}function Rl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,o)=>s+o,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 o=n[s];Ee(o!=null,`No layout data found for index ${s}`);const a=100/r*o;n[s]=a}let i=0;for(let s=0;s<t.length;s++){const o=n[s];Ee(o!=null,`No layout data found for index ${s}`);const a=nr({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!Nt(i,0))for(let s=0;s<t.length;s++){const o=n[s];Ee(o!=null,`No layout data found for index ${s}`);const a=o+i,l=nr({panelConstraints:t,panelIndex:s,size:a});if(o!==l&&(i-=l-o,n[s]=l,Nt(i,0)))break}return n}const Wb=100,Vr={getItem:e=>(Dl(Vr),Vr.getItem(e)),setItem:(e,t)=>{Dl(Vr),Vr.setItem(e,t)}},Ml={};function qf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=Vr,style:c,tagName:d="div",...f}){const p=wa(s),h=wt(null),[g,v]=lr(null),[S,y]=lr([]),j=Db(),m=wt({}),A=wt(new Map),C=wt(0),w=wt({autoSaveId:e,direction:r,dragState:g,id:p,keyboardResizeBy:a,onLayout:o,storage:l}),N=wt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});wt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),If(i,()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:b}=N.current;return b},setLayout:b=>{const{onLayout:B}=w.current,{layout:V,panelDataArray:re}=N.current,se=Rl({layout:b,panelConstraints:re.map(P=>P.constraints)});Pl(V,se)||(y(se),N.current.layout=se,B&&B(se),Hn(re,se,m.current))}}),[]),On(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=g,w.current.id=p,w.current.onLayout=o,w.current.storage=l}),Fb({committedValuesRef:w,eagerValuesRef:N,groupId:p,layout:S,panelDataArray:N.current.panelDataArray,setLayout:y,panelGroupElement:h.current}),zn(()=>{const{panelDataArray:b}=N.current;if(e){if(S.length===0||S.length!==b.length)return;let B=Ml[e];B==null&&(B=Ub(Hb,Wb),Ml[e]=B);const V=[...b],re=new Map(A.current);B(e,V,re,S,l)}},[e,S,l]),zn(()=>{});const J=gt(b=>{const{onLayout:B}=w.current,{layout:V,panelDataArray:re}=N.current;if(b.constraints.collapsible){const se=re.map(ce=>ce.constraints),{collapsedSize:P=0,panelSize:ue,pivotIndices:he}=jn(re,b,V);if(Ee(ue!=null,`Panel size not found for panel "${b.id}"`),!on(ue,P)){A.current.set(b.id,ue);const pe=Xn(re,b)===re.length-1?ue-P:P-ue,me=Zr({delta:pe,initialLayout:V,panelConstraints:se,pivotIndices:he,prevLayout:V,trigger:"imperative-api"});Ci(V,me)||(y(me),N.current.layout=me,B&&B(me),Hn(re,me,m.current))}}},[]),D=gt((b,B)=>{const{onLayout:V}=w.current,{layout:re,panelDataArray:se}=N.current;if(b.constraints.collapsible){const P=se.map(U=>U.constraints),{collapsedSize:ue=0,panelSize:he=0,minSize:ce=0,pivotIndices:pe}=jn(se,b,re),me=B??ce;if(on(he,ue)){const U=A.current.get(b.id),Te=U!=null&&U>=me?U:me,we=Xn(se,b)===se.length-1?he-Te:Te-he,E=Zr({delta:we,initialLayout:re,panelConstraints:P,pivotIndices:pe,prevLayout:re,trigger:"imperative-api"});Ci(re,E)||(y(E),N.current.layout=E,V&&V(E),Hn(se,E,m.current))}}},[]),_=gt(b=>{const{layout:B,panelDataArray:V}=N.current,{panelSize:re}=jn(V,b,B);return Ee(re!=null,`Panel size not found for panel "${b.id}"`),re},[]),T=gt((b,B)=>{const{panelDataArray:V}=N.current,re=Xn(V,b);return Vb({defaultSize:B,dragState:g,layout:S,panelData:V,panelIndex:re})},[g,S]),I=gt(b=>{const{layout:B,panelDataArray:V}=N.current,{collapsedSize:re=0,collapsible:se,panelSize:P}=jn(V,b,B);return Ee(P!=null,`Panel size not found for panel "${b.id}"`),se===!0&&on(P,re)},[]),z=gt(b=>{const{layout:B,panelDataArray:V}=N.current,{collapsedSize:re=0,collapsible:se,panelSize:P}=jn(V,b,B);return Ee(P!=null,`Panel size not found for panel "${b.id}"`),!se||Rn(P,re)>0},[]),O=gt(b=>{const{panelDataArray:B}=N.current;B.push(b),B.sort((V,re)=>{const se=V.order,P=re.order;return se==null&&P==null?0:se==null?-1:P==null?1:se-P}),N.current.panelDataArrayChanged=!0,j()},[j]);On(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:b,onLayout:B,storage:V}=w.current,{layout:re,panelDataArray:se}=N.current;let P=null;if(b){const he=Jb(b,se,V);he&&(A.current=new Map(Object.entries(he.expandToSizes)),P=he.layout)}P==null&&(P=Zb({panelDataArray:se}));const ue=Rl({layout:P,panelConstraints:se.map(he=>he.constraints)});Pl(re,ue)||(y(ue),N.current.layout=ue,B&&B(ue),Hn(se,ue,m.current))}}),On(()=>{const b=N.current;return()=>{b.layout=[]}},[]);const R=gt(b=>{let B=!1;const V=h.current;return V&&window.getComputedStyle(V,null).getPropertyValue("direction")==="rtl"&&(B=!0),function(se){se.preventDefault();const P=h.current;if(!P)return()=>null;const{direction:ue,dragState:he,id:ce,keyboardResizeBy:pe,onLayout:me}=w.current,{layout:U,panelDataArray:Te}=N.current,{initialLayout:X}=he??{},we=Zf(ce,b,P);let E=Bb(se,b,ue,he,pe,P);const M=ue==="horizontal";M&&B&&(E=-E);const F=Te.map(te=>te.constraints),ne=Zr({delta:E,initialLayout:X??U,panelConstraints:F,pivotIndices:we,prevLayout:U,trigger:Of(se)?"keyboard":"mouse-or-touch"}),Q=!Ci(U,ne);(Pf(se)||Df(se))&&C.current!=E&&(C.current=E,!Q&&E!==0?M?Ks(b,E<0?Mf:$f):Ks(b,E<0?Ff:Lf):Ks(b,0)),Q&&(y(ne),N.current.layout=ne,me&&me(ne),Hn(Te,ne,m.current))}},[]),Y=gt((b,B)=>{const{onLayout:V}=w.current,{layout:re,panelDataArray:se}=N.current,P=se.map(U=>U.constraints),{panelSize:ue,pivotIndices:he}=jn(se,b,re);Ee(ue!=null,`Panel size not found for panel "${b.id}"`);const pe=Xn(se,b)===se.length-1?ue-B:B-ue,me=Zr({delta:pe,initialLayout:re,panelConstraints:P,pivotIndices:he,prevLayout:re,trigger:"imperative-api"});Ci(re,me)||(y(me),N.current.layout=me,V&&V(me),Hn(se,me,m.current))},[]),H=gt((b,B)=>{const{layout:V,panelDataArray:re}=N.current,{collapsedSize:se=0,collapsible:P}=B,{collapsedSize:ue=0,collapsible:he,maxSize:ce=100,minSize:pe=0}=b.constraints,{panelSize:me}=jn(re,b,V);me!=null&&(P&&he&&on(me,se)?on(se,ue)||Y(b,ue):me<pe?Y(b,pe):me>ce&&Y(b,ce))},[Y]),$=gt((b,B)=>{const{direction:V}=w.current,{layout:re}=N.current;if(!h.current)return;const se=As(b,h.current);Ee(se,`Drag handle element not found for id "${b}"`);const P=Uf(V,B);v({dragHandleId:b,dragHandleRect:se.getBoundingClientRect(),initialCursorPosition:P,initialLayout:re})},[]),ee=gt(()=>{v(null)},[]),k=gt(b=>{const{panelDataArray:B}=N.current,V=Xn(B,b);V>=0&&(B.splice(V,1),delete m.current[b.id],N.current.panelDataArrayChanged=!0,j())},[j]),oe=wb(()=>({collapsePanel:J,direction:r,dragState:g,expandPanel:D,getPanelSize:_,getPanelStyle:T,groupId:p,isPanelCollapsed:I,isPanelExpanded:z,reevaluatePanelConstraints:H,registerPanel:O,registerResizeHandle:R,resizePanel:Y,startDragging:$,stopDragging:ee,unregisterPanel:k,panelGroupElement:h.current}),[J,g,r,D,_,T,p,I,z,H,O,R,Y,$,ee,k]),q={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return br(Cs.Provider,{value:oe},br(d,{...f,children:t,className:n,id:s,ref:h,style:{...q,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const Gf=Cf((e,t)=>br(qf,{...e,forwardedRef:t}));qf.displayName="PanelGroup";Gf.displayName="forwardRef(PanelGroup)";function Xn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function jn(e,t,n){const r=Xn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],o=n[r];return{...t.constraints,panelSize:o,pivotIndices:s}}function qb({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){zn(()=>{if(e||n==null||r==null)return;const i=As(t,r);if(i==null)return;const s=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const a=i.getAttribute("data-panel-group-id");Ee(a,`No group element found for id "${a}"`);const l=si(a,r),c=Bf(a,t,r);Ee(c!==null,`No resize element found for id "${t}"`);const d=o.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 Yf({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:o,onFocus:a,style:l={},tabIndex:c=0,tagName:d="div",...f}){var p,h;const g=wt(null),v=wt({onDragging:o});zn(()=>{v.current.onDragging=o});const S=Tf(Cs);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:j,registerResizeHandle:m,startDragging:A,stopDragging:C,panelGroupElement:w}=S,N=wa(i),[J,D]=lr("inactive"),[_,T]=lr(!1),[I,z]=lr(null),O=wt({state:J});On(()=>{O.current.state=J}),zn(()=>{if(n)z(null);else{const $=m(N);z(()=>$)}},[n,N,m]);const R=(p=r==null?void 0:r.coarse)!==null&&p!==void 0?p:15,Y=(h=r==null?void 0:r.fine)!==null&&h!==void 0?h:5;return zn(()=>{if(n||I==null)return;const $=g.current;return Ee($,"Element ref not attached"),Pb(N,$,y,{coarse:R,fine:Y},(k,oe,q)=>{if(oe)switch(k){case"down":{D("drag"),Ee(q,'Expected event to be defined for "down" action'),A(N,q);const{onDragging:b}=v.current;b&&b(!0);break}case"move":{const{state:b}=O.current;b!=="drag"&&D("hover"),Ee(q,'Expected event to be defined for "move" action'),I(q);break}case"up":{D("hover"),C();const{onDragging:b}=v.current;b&&b(!1);break}}else D("inactive")})},[R,y,n,Y,m,N,I,A,C]),qb({disabled:n,handleId:N,resizeHandler:I,panelGroupElement:w}),br(d,{...f,children:e,className:t,id:i,onBlur:()=>{T(!1),s==null||s()},onFocus:()=>{T(!0),a==null||a()},ref:g,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":y,"data-panel-group-id":j,"data-resize-handle":"","data-resize-handle-active":J==="drag"?"pointer":_?"keyboard":void 0,"data-resize-handle-state":J,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":N})}Yf.displayName="PanelResizeHandle";const Gb=({className:e,...t})=>u.jsx(Gf,{className:G("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Xs=zf,$l=({withHandle:e,className:t,...n})=>u.jsx(Yf,{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(Hg,{className:"h-2.5 w-2.5"})})}),Kf=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}));Kf.displayName="Textarea";class Yb{constructor(t){el(this,"client");this.client=hx.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 Kb=new Yb;function Xb(){const e=x.useRef(null),t=x.useCallback(async(r,i,s,o,a)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{o==null||o("parsing","Validating JSON structure...");let c;try{c=JSON.parse(i)}catch(w){throw new Error(`Invalid JSON: ${w instanceof Error?w.message:"Unknown parse error"}`)}o==null||o("building",`Building ${_i.toLowerCase()} structure...`);const d={jsonDefinition:c,options:{...a,sourceName:r}};d.customThemes=s??{},o==null||o("rendering",`Generating ${ot.toUpperCase()} content...`);const f={"Content-Type":"application/json"};a!=null&&a.bypassCache&&(f["X-Bypass-Cache"]="true");const p=await fetch(Ji.generate,{method:"POST",headers:f,body:JSON.stringify(d),signal:l.signal}),h=await p.json();if(!p.ok||!h.success){const w=h.error||h.message||`API request failed with status: ${p.status}`;throw new Error(w)}const{data:g,cache:v,warnings:S}=h,y=v.status==="HIT"?"HIT":v.status==="MISS"?"MISS":"UNKNOWN",j=y==="HIT"?`Served from cache (Hit rate: ${v.hitRate})`:`Generated fresh ${_i.toLowerCase()}`;o==null||o("finalizing",j);const m=globalThis.atob(g.document),A=new Uint8Array(m.length);for(let w=0;w<m.length;w++)A[w]=m.charCodeAt(w);const C=new Blob([A],{type:g.contentType});if(C.size===0)throw new Error(`Received empty ${_i.toLowerCase()} from API`);return{name:r,text:i,blob:C,filename:g.filename,fileId:g.fileId,cacheStatus:y,cacheHitRate:v.hitRate,warnings:S}}catch(c){throw c instanceof Error&&c.name==="AbortError"?new Error(`${_i} generation was cancelled`):c}finally{e.current===l&&(e.current=null)}},[]),n=x.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,generateDocument:t,cancelGeneration:n}}function Qb(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 o of i){let a=o.message;if(o.context&&Object.keys(o.context).length>0){const l=Object.entries(o.context).map(([c,d])=>`${c}: ${JSON.stringify(d)}`).join(", ");a+=` (${l})`}s.push(a)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function ev({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=je.useState("custom");je.useEffect(()=>{e&&s("custom")},[e]);const o=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),a=[{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(Ut,{children:[u.jsx(Jt,{children:"Non-safe fonts in this document"}),u.jsxs(an,{children:[o," ",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:a.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(_e,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),u.jsx(_e,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}const Fl=ot==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Qs={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function tv({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:o,isGenerating:a,isRendering:l,onShowCacheMetrics:c,onShowSchemas:d,onShowFonts:f,documentText:p,editorDocumentText:h,warnings:g,renderingLibrary:v,setRenderingLibrary:S,onToggleChat:y,chatOpen:j,onTogglePreview:m,previewOpen:A}){const C=v!=="docxjs",[w,N]=x.useState(!1),[J,D]=x.useState(!1),[_,T]=x.useState(!1),[I,z]=x.useState(!1),[O,R]=x.useState(!1),[Y,H]=x.useState(!1),[$,ee]=x.useState(null),{toast:k}=jr(),{generateDocument:oe}=Xb(),q=x.useContext(Od),b=x.useCallback(()=>{const X={},{customThemes:we}=q.getState();return Object.values(we).forEach(E=>{E.valid&&E.parsed&&(X[E.name]=E.parsed)}),X},[q]),B=je.useMemo(()=>{if(!p)return[];try{const X=JSON.parse(p);return[...(ot==="pptx"?vg:wg)(X)].filter(E=>!kg(E))}catch{return[]}},[p]),[V,re]=x.useState(!1),se=x.useCallback(async()=>{if(t){N(!0);try{await new Promise(X=>setTimeout(X,100)),Li(`${e}${Ir}`,t)}finally{setTimeout(()=>N(!1),500)}}},[t,e]),P=x.useCallback(async()=>{if(t){if(B.length===0){await se();return}re(!0)}},[t,B.length,se]),ue=x.useCallback(async X=>{var we;if(p){N(!0);try{const E=await oe(e,p,b(),void 0,{bypassCache:!0,fonts:{mode:X}});if(E.blob.size===0)k({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{Li(`${e}${Ir}`,E.blob);const M=(we=E.warnings)==null?void 0:we.find(F=>{var ne,Q;return((ne=F.context)==null?void 0:ne.code)==="FONT_MODE_SUBSTITUTED"||((Q=F.context)==null?void 0:Q.code)==="FONT_MODE_CUSTOM"});M&&k({title:X==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:M.message})}}catch(E){k({title:"Export failed",description:E instanceof Error?E.message:String(E),variant:"destructive"})}finally{setTimeout(()=>N(!1),500)}}},[p,e,oe,k,b]),he=x.useCallback(async()=>{if(!(!g||g.length===0)){D(!0);try{const X=Qb(g);if(!X){k({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const we=await oe("warnings",JSON.stringify(X,null,2),{});we&&typeof we=="object"&&"blob"in we&&we.blob&&(Li(`${e}-warnings${Ir}`,we.blob),k({title:"Warnings downloaded",description:`Downloaded warnings document with ${g.length} warning(s).`}))}catch(X){console.error("Failed to generate warnings document:",X),k({title:"Download failed",description:X instanceof Error?X.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>D(!1),500)}}},[g,e,oe,k]),ce=x.useCallback(async()=>{const X=r==null?void 0:r.current;if(X!=null&&X.src){T(!0);try{await new Promise(E=>{let M=null,F=!1;const ne=()=>{M&&(clearTimeout(M),M=null),X.removeEventListener("load",te),X.removeEventListener("error",de)},Q=()=>{F||(F=!0,ne(),E())},te=()=>Q(),de=()=>Q();X.addEventListener("load",te),X.addEventListener("error",de),M=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),Q()},5e3);const ve=X.src,Z=ve.includes("?")?"&":"?",K=Date.now();X.src=`${ve}${Z}_reload=${K}`})}catch(we){console.error("Iframe reload failed:",we)}finally{T(!1)}}},[r]),pe=x.useCallback(async()=>{z(!0);try{await Kb.delete(`/${ot}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),k({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(X){console.error("Failed to clear cache:",X),k({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{z(!1)}},[k]),me=h??p,U=x.useCallback(()=>{var E,M;if(!me){k({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(me)}catch{k({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}H(!0);const X=(async()=>{const F=await fetch(`/api/${ot}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:me,customThemes:b(),options:{sourceName:e}})});if(!F.ok){let Q=`Request failed with status ${F.status}`;try{const te=await F.json(),de=te.error??te.message;typeof de=="string"&&de&&(Q=de)}catch{}throw new Error(Q)}const ne=await F.json();return JSON.stringify(ne.data,null,2)})();let we;typeof ClipboardItem<"u"&&((E=navigator.clipboard)!=null&&E.write)?we=navigator.clipboard.write([new ClipboardItem({"text/plain":X.then(F=>new Blob([F],{type:"text/plain"}))})]):(M=navigator.clipboard)!=null&&M.writeText?we=X.then(F=>navigator.clipboard.writeText(F)):we=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await we,k({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(F){let ne=null;try{ne=await X}catch(Q){console.error("Error fetching standard components:",Q),k({title:"Failed to get standard components",description:Q instanceof Error?Q.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",F),ee(ne)}finally{H(!1)}})()},[me,e,b,k]),Te=x.useCallback(async()=>{if($!=null)try{await navigator.clipboard.writeText($),k({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),ee(null)}catch{k({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[$,k]);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(qe,{children:[u.jsx(Ge,{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(Cd,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),u.jsx(Ye,{className:"max-w-sm",children:u.jsxs("p",{className:"text-sm",children:["Preview uses"," ",ot==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",Ir," to verify fidelity."]})})]})]}),u.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||C)&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(_e,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:o,"aria-label":"Render preview",disabled:a||l||A===!1,children:[l?u.jsx(sn,{size:"sm"}):u.jsx(Wg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),u.jsx(Ye,{children:u.jsx("p",{children:A===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),ot==="docx"&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[u.jsx(sr,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),u.jsx(va,{checked:i,onCheckedChange:s,disabled:C})]})}),u.jsx(Ye,{children:u.jsx("p",{children:C?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:ce,disabled:_||a||l,children:_?u.jsx(sn,{size:"sm"}):u.jsx(qg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsx("p",{children:_?"Reloading...":"Reload"})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(_e,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||w||a,onClick:P,children:[w?u.jsx(sn,{size:"sm"}):u.jsx(Gg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),u.jsx(Ye,{children:u.jsxs("p",{children:["Download ",Ir]})})]}),g&&g.length>0&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(_e,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:J||a,onClick:he,children:J?u.jsx(sn,{size:"sm"}):u.jsx(Id,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsxs("p",{children:["Download warnings (",g.length,")"]})})]}),v&&S&&u.jsxs(ei,{value:v,onValueChange:S,children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(hr,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:u.jsx(ti,{placeholder:"Renderer"})})}),u.jsx(Ye,{children:u.jsx("p",{children:"Select the rendering library"})})]}),u.jsx(mr,{className:"text-sidebar-foreground",children:Fl.map(X=>u.jsxs(Dn,{value:X,children:[u.jsxs(qe,{children:[u.jsx(Ge,{tabIndex:-1,children:Qs[X][0]}),u.jsx(Ye,{children:Qs[X][1]})]})," ",X]},X))})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(js,{children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ns,{asChild:!0,children:u.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7",children:u.jsx(Nd,{className:"h-3.5 w-3.5"})})})}),u.jsx(Ye,{children:u.jsx("p",{children:"More actions"})})]}),u.jsxs(xi,{align:"end",className:"w-52",children:[d&&u.jsxs(Ft,{onClick:d,children:[u.jsx(Yg,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),f&&u.jsxs(Ft,{onClick:f,children:[u.jsx(jo,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),c&&u.jsxs(Ft,{onClick:c,children:[u.jsx(No,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),me?u.jsxs(Ft,{onClick:U,disabled:Y,children:[u.jsx(Eo,{className:"h-4 w-4 mr-2"}),Y?"Copying...":"Copy standard components"]}):u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx("span",{className:"block",children:u.jsxs(Ft,{disabled:!0,children:[u.jsx(Eo,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),u.jsx(Ye,{side:"left",children:u.jsx("p",{children:"No document selected — open or select a document first"})})]}),u.jsx(xr,{}),u.jsxs(Ft,{onClick:()=>R(!0),disabled:I,className:"text-destructive focus:text-destructive",children:[u.jsx(ca,{className:"h-4 w-4 mr-2"}),I?"Clearing...":"Clear all caches"]}),v&&S&&u.jsxs(u.Fragment,{children:[u.jsx(xr,{className:"lg:hidden"}),Fl.map(X=>u.jsxs(Ft,{className:"lg:hidden",onClick:()=>S(X),children:[u.jsx("span",{className:"mr-2",children:v===X?"●":"○"}),Qs[X][0]," ",X]},X))]})]})]}),m&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(_e,{variant:A?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:m,children:A?u.jsx(Ad,{className:"h-3.5 w-3.5"}):u.jsx(Kg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[A?"Hide":"Show"," Preview"," ",u.jsx(ri,{shortcut:"mod+shift+p"})]})})]}),y&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(_e,{variant:j?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:y,children:u.jsx(zd,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[j?"Close":"Open"," AI Chat"," ",u.jsx(ri,{shortcut:"mod+shift+j"})]})})]})]})]}),u.jsx(ev,{open:V,onClose:()=>re(!1),nonSafeFonts:B,onChoose:ue}),u.jsx(Ct,{open:$!=null,onOpenChange:X=>{X||ee(null)},children:u.jsxs(kt,{className:"max-w-lg",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Standard components"}),u.jsx(an,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),u.jsx(Kf,{readOnly:!0,value:$??"",className:"h-64 font-mono text-xs",onFocus:X=>X.currentTarget.select()}),u.jsxs(bn,{children:[u.jsx(_e,{variant:"outline",size:"sm",onClick:()=>ee(null),children:"Close"}),u.jsx(_e,{size:"sm",onClick:Te,children:"Copy to clipboard"})]})]})}),u.jsx(Ct,{open:O,onOpenChange:R,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear all caches?"}),u.jsx(an,{children:"This will clear the document, component, and rasterized-visual caches. Next generation will be uncached."})]}),u.jsxs(bn,{children:[u.jsx(_e,{variant:"outline",size:"sm",onClick:()=>R(!1),children:"Cancel"}),u.jsx(_e,{variant:"destructive",size:"sm",disabled:I,onClick:async()=>{await pe(),R(!1)},children:I?u.jsx(sn,{size:"sm"}):"Clear"})]})]})})]})}const nv=je.memo(tv),Xf=mg,ja=x.forwardRef(({className:e,...t},n)=>u.jsx(xd,{ref:n,className:G("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));ja.displayName=xd.displayName;const cr=x.forwardRef(({className:e,...t},n)=>u.jsx(yd,{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}));cr.displayName=yd.displayName;const dr=x.forwardRef(({className:e,...t},n)=>u.jsx(bd,{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}));dr.displayName=bd.displayName;async function rv(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 iv(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 sv(e){const t=iv(e);return rv(t)}const ov=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=x.useState(n),[s,o]=x.useState(null),[a,l]=x.useState(null),[c,d]=x.useState(!1),[f,p]=x.useState(!1),[h,g]=x.useState(null),[v,S]=x.useState(null),[y,j]=x.useState(!1),{toast:m}=jr(),A=Bt(z=>z.selectedPlugins),C=Array.from(A);x.useEffect(()=>{n&&i(n)},[n]);const w=x.useCallback(async()=>{d(!0),g(null);try{const z=await Zs.fetchDocumentSchema(C);o(z)}catch(z){const O=z instanceof Error?z.message:"Failed to load document schema";g(O),m({variant:"destructive",title:"Error loading schema",description:O})}finally{d(!1)}},[C,m]),N=x.useCallback(async()=>{if(!a){p(!0),S(null);try{const z=await Zs.fetchThemeSchema();l(z)}catch(z){const O=z instanceof Error?z.message:"Failed to load theme schema";S(O),m({variant:"destructive",title:"Error loading schema",description:O})}finally{p(!1)}}},[a,m]),[J,D]=x.useState([]);x.useEffect(()=>{e||(o(null),g(null))},[e]),x.useEffect(()=>{if(!e)return;const z=C.length!==J.length||C.some((O,R)=>O!==J[R]);r==="document"?(!s||z)&&(z&&(Zs.clearPluginSchemaCache(),D([...C])),c||w()):r==="theme"&&!a&&!f&&N()},[r,e,s,a,c,f,C,J,w,N]);const _=C.length,T=r==="document"?s:a,I=async()=>{if(T)try{await sv(T)&&(j(!0),m({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>j(!1),2e3))}catch(z){console.error("Copy failed:",z)}};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(Ut,{children:u.jsx(Jt,{children:"Schema Viewer"})}),u.jsxs(Xf,{value:r,onValueChange:z=>i(z),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ja,{children:[u.jsxs(cr,{value:"document",className:"flex items-center gap-1",children:["Document",_>0&&u.jsxs(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",_]})]}),u.jsx(cr,{value:"theme",children:"Theme"})]}),u.jsx("div",{className:"ml-auto",children:u.jsx(_e,{variant:"ghost",size:"icon",onClick:I,disabled:y||!T,"aria-label":"Copy schema",children:y?u.jsx(yn,{className:"h-4 w-4"}):u.jsx(ws,{className:"h-4 w-4"})})})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[u.jsx(dr,{value:"document",className:"h-full",children:u.jsx(es,{schema:s,loading:c,error:h||void 0})}),u.jsx(dr,{value:"theme",className:"h-full",children:u.jsx(es,{schema:a,loading:f,error:v||void 0})})]})]})]})})};function Qf(e,t,n){if(t.length===0)return n;const r=Ll(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],l=i[o],c=Ll(l,a);i[o]=c,i=c}return i[t[t.length-1]]=n,r}function Ll(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const Bl=2*1024*1024,Zl=12*1024*1024;function av(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 lv(e){let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function rs(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.round(e/1024)} KB`}function uv(e,t){if(t.length===0)return{ok:!1,message:`"${e}" is empty.`};if(t.length>Bl)return{ok:!1,message:`"${e}" is ${rs(t.length)}. The limit is ${rs(Bl)} per font, because the bytes travel inside the document JSON.`};const n=av(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:lv(t)}}const cv=new Set(["italic","oblique"]);function dv(e){const t=e.replace(/\.[^.]+$/,""),n=t.split(/[-_\s]+/).filter(Boolean),r=new Map;for(const[o,a]of Object.entries(kd))r.set(a.toLowerCase(),Number(o));let i=400,s=!1;for(;n.length>1;){const o=n[n.length-1].toLowerCase();if(cv.has(o)){s=!0,n.pop();continue}const a=r.get(o);if(a!==void 0){i=a,n.pop();continue}break}return{family:n.join(" ")||t,weight:i,italic:s}}function fv(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 pv(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 hv(e,t,n,r){const i=((e==null?void 0:e.sources)??[]).filter(a=>{const l=pv(a);return l?!n.some(c=>c.weight===l.weight&&c.italic===l.italic):!0}),s=n.map(a=>({kind:"data",data:a.data,weight:a.weight,italic:a.italic})),o=r??(e==null?void 0:e.category);return{id:(e==null?void 0:e.id)??t,family:t,...o?{category:o}:{},sources:[...i,...s]}}function mv(e,t){let n=Array.isArray(e)?[...e]:[];for(const r of t){const i=r.sources.filter(o=>o.kind==="data").map(o=>({data:o.data,weight:o.weight??400,italic:o.italic??!1}));if(i.length===0)continue;const s=n.find(o=>{var a;return((a=o==null?void 0:o.family)==null?void 0:a.toLowerCase())===r.family.toLowerCase()});n=fv(n,hv(s,r.family,i,r.category))}return n}function gv(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 xv(e){const t=new TextEncoder().encode(e).length;return t<=Zl?null:`Adding this font would push the document to ${rs(t)}, past the ${rs(Zl)} limit. Remove a font from props.fontRegistry, or use fewer weights.`}const Vl=new Set,yv=(e,t,n)=>`${e.toLowerCase()}|${t}|${n?"i":"r"}`;function bv(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 vv(e,t,n,r){const i=yv(e,n,r);if(!Vl.has(i))try{if(typeof FontFace>"u"||!(document!=null&&document.fonts))return;const s=bv(t),o=new FontFace(e,s.buffer,{weight:String(n),style:r?"italic":"normal"});await o.load(),document.fonts.add(o),Vl.add(i)}catch{}}const wv={safe:[],google:[]};function Ul(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)))??[]),o=new Set([...s,...i]);if(r&&o.size===s.size)return;const a=[...o].sort((f,p)=>f-p).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${a}&display=swap`,c=r??document.createElement("link");r||(c.id=n,c.rel="stylesheet",document.head.appendChild(c)),c.href=l,c.dataset.weights=[...o].sort((f,p)=>f-p).join(",")}function kv(){const e=Ce(i=>i.activeTab),t=Ce(i=>i.documents),n=Ce(i=>i.documentTypes),r=Ce(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(l=>l.name===e);if(!s)return{ok:!1,error:"Active theme not found"};let o;try{o=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active theme is not valid JSON: ${l.message}`}}const a=i(o);return r(e,JSON.stringify(a,null,2)),{ok:!0,name:e}},[e,t,n,r])}function Sv(){const e=Ce(r=>r.activeTab),t=Ce(r=>r.documents),n=Ce(r=>r.saveDocument);return x.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active document not found"};let o;try{o=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active document is not valid JSON: ${l.message}`}}const a=Qf(o,r,i);return n(e,JSON.stringify(a,null,2)),{ok:!0,name:e}},[e,t,n])}function _v(){const e=Ce(i=>i.activeTab),t=Ce(i=>i.documents),n=Ce(i=>i.documentTypes),r=Ce(i=>i.saveDocument);return x.useCallback(i=>{var f;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"};let o;try{o=JSON.parse(s.text)}catch(p){return{ok:!1,error:`Active document is not valid JSON: ${p.message}`}}const a=mv((f=o==null?void 0:o.props)==null?void 0:f.fontRegistry,i),l=Qf(o,["props","fontRegistry"],a),c=JSON.stringify(l,null,2),d=xv(c);return d?{ok:!1,error:d}:(r(e,c),{ok:!0,name:e})},[e,t,n,r])}function jv(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 Jl(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Nv=({open:e,onOpenChange:t})=>{const n=$i(P=>P.open),r=$i(P=>P.contextual),i=$i(P=>P.close),s=e??n,o=r,a=x.useCallback(P=>{t&&t(P),P||i()},[t,i]),[l,c]=x.useState(wv),[d,f]=x.useState(!1),[p,h]=x.useState(""),[g,v]=x.useState("safe"),[S,y]=x.useState(null),[j,m]=x.useState(null),[A,C]=x.useState(!1),[w,N]=x.useState(!1),[J,D]=x.useState(""),[_,T]=x.useState([]),I=x.useRef(null),{toast:z}=jr(),O=kv(),R=Sv(),Y=_v(),H=Ce(P=>P.activeTab),$=Ce(P=>P.documentTypes),ee=H&&$[H]==="application/json+theme",k=!!o||ee;x.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(f(!0),fetch(Ji.fonts.catalog).then(P=>P.json()).then(P=>c(P)).catch(P=>{z({variant:"destructive",title:"Font catalog unavailable",description:P.message})}).finally(()=>f(!1))))},[s,l,z]),x.useEffect(()=>{if(!(g!=="google"||l.google.length===0))for(const P of l.google)Ul(P.family,P.weights)},[g,l]);const oe=x.useMemo(()=>l.safe.filter(P=>P.toLowerCase().includes(p.toLowerCase())),[l.safe,p]),q=x.useMemo(()=>l.google.filter(P=>P.family.toLowerCase().includes(p.toLowerCase())),[l.google,p]),b=x.useCallback(async P=>{try{await navigator.clipboard.writeText(P),m(P),setTimeout(()=>m(null),1500)}catch{z({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[z]),B=x.useCallback(async(P,ue,he)=>{y(P);try{const ce=O(pe=>(jv(pe,he,P),pe));if(!ce.ok){z({variant:"destructive",title:"Could not insert font",description:ce.error});return}z({title:"Font inserted",description:`${P} set as ${he} font in "${ce.name}".`})}finally{y(null)}},[O,z]),V=x.useCallback(async P=>{if(o){y(P);try{const ue=R(o.jsonPath,P);if(!ue.ok){z({variant:"destructive",title:"Could not insert font",description:ue.error});return}z({title:"Font inserted",description:`${P} set at ${Jl(o.jsonPath)}.`}),a(!1)}finally{y(null)}}},[o,R,z,a]),re=x.useCallback(async P=>{if(!(!P||P.length===0)){C(!0);try{const ue=[];for(const ce of Array.from(P)){const pe=new Uint8Array(await ce.arrayBuffer()),me=uv(ce.name,pe);if(!me.ok){z({variant:"destructive",title:"Font rejected",description:me.message});continue}ue.push({identity:dv(ce.name),base64:me.base64})}if(ue.length===0)return;const he=Y(ue.map(({identity:ce,base64:pe})=>({id:ce.family,family:ce.family,sources:[{kind:"data",data:pe,weight:ce.weight,italic:ce.italic}]})));if(!he.ok){z({variant:"destructive",title:"Could not register font",description:he.error});return}for(const{identity:ce,base64:pe}of ue)vv(ce.family,pe,ce.weight,ce.italic),z({title:`Added ${ce.family}`,description:`Registered at weight ${ce.weight}${ce.italic?" italic":""} in props.fontRegistry. Reference it as "${ce.family}".`})}catch(ue){z({variant:"destructive",title:"Upload failed",description:ue.message})}finally{C(!1),I.current&&(I.current.value="")}}},[Y,z]),se=x.useCallback(async()=>{var ue,he;const P=J.trim();if(P){N(!0),T([]);try{const ce=await fetch(Ji.fonts.materialize,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({family:P,weights:[400,700],italics:!1})});if(ce.status===429)throw new Error("Too many font fetches — the playground allows 20 every 15 minutes. Try again shortly.");if(!ce.ok){const X=await ce.json().catch(()=>({}));throw new Error(X.error??`Materialize failed (${ce.status})`)}const pe=await ce.json();T(pe.warnings??[]);const me=(ue=l.google.find(X=>X.family.toLowerCase()===pe.family.toLowerCase()))==null?void 0:ue.category,U=gv(pe,me);if(!U){z({variant:"destructive",title:"Nothing to embed",description:((he=pe.warnings)==null?void 0:he.join(" · "))||`Google Fonts has no family named "${P}".`});return}const Te=Y([U]);if(!Te.ok){z({variant:"destructive",title:"Could not register font",description:Te.error});return}Ul(pe.family,[400,700]),z({title:`Added ${pe.family}`,description:`Embedded ${U.sources.length} weight(s) in props.fontRegistry.`})}catch(ce){z({variant:"destructive",title:"Google Fonts fetch failed",description:ce.message})}finally{N(!1)}}},[J,l.google,Y,z]);return u.jsx(Ct,{open:s,onOpenChange:a,children:u.jsxs(kt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ut,{children:u.jsx(Jt,{children:o?`Font for ${Jl(o.jsonPath)}`:"Fonts"})}),!o&&!ee&&g!=="custom"&&u.jsx(or,{children:u.jsxs(ar,{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(Xf,{value:g,onValueChange:P=>v(P),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ja,{children:[u.jsxs(cr,{value:"safe",children:["Safe",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),u.jsxs(cr,{value:"google",children:["Google",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]}),u.jsx(cr,{value:"custom",children:"Custom"})]}),u.jsx(gr,{type:"search",placeholder:"Search fonts...",value:p,onChange:P=>h(P.target.value),className:"ml-auto max-w-xs"})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[u.jsx(dr,{value:"safe",className:"m-0",children:d&&oe.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(Lr,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:oe.map(P=>u.jsx(Hl,{family:P,meta:u.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${P}", sans-serif`},onCopy:()=>b(P),copied:j===P,contextual:!!o,onUseThis:()=>V(P),onInsertHeading:()=>B(P,"safe","heading"),onInsertBody:()=>B(P,"safe","body"),applying:S===P,disabled:!k},P))})}),u.jsx(dr,{value:"google",className:"m-0",children:d&&q.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(Lr,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:q.map(P=>u.jsx(Hl,{family:P.family,meta:u.jsxs("span",{className:"text-xs",children:[P.category," · ",P.weights.length," weights"]}),previewStyle:{fontFamily:`"${P.family}", sans-serif`},onCopy:()=>b(P.family),copied:j===P.family,contextual:!!o,onUseThis:()=>V(P.family),onInsertHeading:()=>B(P.family,"google","heading"),onInsertBody:()=>B(P.family,"google","body"),applying:S===P.family,disabled:!k,extraAction:u.jsx(Cv,{family:P.family,weights:P.weights,hasItalic:P.hasItalic})},P.family))})}),u.jsx(dr,{value:"custom",className:"m-0 flex flex-col gap-6",children:ee?u.jsx(or,{children:u.jsxs(ar,{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:P=>P.preventDefault(),onDrop:P=>{P.preventDefault(),re(P.dataTransfer.files)},className:"rounded-md border border-dashed p-6 text-center",children:[u.jsx("input",{ref:I,type:"file",accept:".ttf,.otf,font/ttf,font/otf",multiple:!0,className:"hidden",onChange:P=>void re(P.target.files)}),u.jsxs(_e,{variant:"secondary",disabled:A,onClick:()=>{var P;return(P=I.current)==null?void 0:P.click()},children:[A?u.jsx(Lr,{className:"animate-spin mr-2 h-4 w-4"}):u.jsx(Xg,{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(gr,{placeholder:"e.g. Geist",value:J,onChange:P=>D(P.target.value),onKeyDown:P=>{P.key==="Enter"&&se()}}),u.jsxs(_e,{onClick:()=>void se(),disabled:w||J.trim()==="",children:[w&&u.jsx(Lr,{className:"animate-spin mr-2 h-4 w-4"}),"Embed"]})]}),_.length>0&&u.jsx(or,{children:u.jsx(ar,{className:"text-xs",children:_.join(" · ")})})]})]})})]})]})]})})},Ev="The quick brown fox jumps over the lazy dog",Cv=({family:e,weights:t,hasItalic:n})=>{const r=x.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return u.jsxs(js,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(_e,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),u.jsxs(xi,{align:"end",className:"min-w-[260px]",children:[u.jsxs(uf,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),u.jsx(xr,{}),r.map(i=>{const s=kd[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)})]})]})},Hl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:o,onInsertHeading:a,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:Ev}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?u.jsx(_e,{size:"sm",onClick:o,disabled:c||d,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):u.jsxs(u.Fragment,{children:[u.jsx(_e,{size:"sm",variant:"secondary",onClick:a,disabled:c||d,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),u.jsx(_e,{size:"sm",variant:"secondary",onClick:l,disabled:c||d,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),f,u.jsx(_e,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?u.jsx(yn,{className:"h-4 w-4"}):u.jsx(ws,{className:"h-4 w-4"})})]})]});function Wl({previewOpen:e,onTogglePreview:t}){const n=rn(D=>D.name||""),r=rn(D=>D.blob),i=rn(D=>D.isGenerating),s=rn(D=>D.text),o=rn(D=>D.warnings),a=rn(D=>D.isRendering),l=ji(D=>D.autoReload),c=ji(D=>D.renderingLibrary),d=ji(D=>D.setSettings),f=ji(D=>D.useGlobalPreviewHeader??!0),p=Ce(D=>D.activeTab),h=Ce(D=>D.documentTypes),g=p&&h[p]==="application/json+theme"?"theme":"document",v=Ce(D=>{var _;return D.activeTab&&D.documentTypes[D.activeTab]!=="application/json+theme"?(_=D.documents.find(T=>T.name===D.activeTab))==null?void 0:_.text:void 0}),S=Re(D=>D.chatOpen),y=Re(D=>D.toggleChat),[j,m]=je.useState(!1),A=$i(D=>D.openFor);if(!f)return null;const C=x.useCallback(()=>d({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,d]),w=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),N=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),J=(n==null?void 0:n.trim())||"Preview";return u.jsxs("div",{className:"sticky top-0 z-20",children:[u.jsx(nv,{name:J,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:C,onManualRender:w,isGenerating:i,isRendering:!!a,onShowCacheMetrics:N,onShowSchemas:()=>m(!0),onShowFonts:()=>A(),documentText:s,editorDocumentText:v,warnings:o,renderingLibrary:c,setRenderingLibrary:D=>d({renderingLibrary:D}),onToggleChat:y,chatOpen:S,onTogglePreview:t,previewOpen:e}),u.jsx(ov,{open:j,onOpenChange:m,defaultTab:g==="theme"?"theme":"document"}),u.jsx(Nv,{})]})}function Tv(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Iv=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Av=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zv={};function ql(e,t){return(zv.jsx?Av:Iv).test(e)}const Ov=/[ \t\n\f\r]/g;function Pv(e){return typeof e=="object"?e.type==="text"?Gl(e.value):!1:Gl(e)}function Gl(e){return e.replace(Ov,"")===""}class yi{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}yi.prototype.normal={};yi.prototype.property={};yi.prototype.space=void 0;function ep(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new yi(n,r,t)}function Lo(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 Dv=0;const Se=Fn(),nt=Fn(),Bo=Fn(),ie=Fn(),Ze=Fn(),fr=Fn(),jt=Fn();function Fn(){return 2**++Dv}const Zo=Object.freeze(Object.defineProperty({__proto__:null,boolean:Se,booleanish:nt,commaOrSpaceSeparated:jt,commaSeparated:fr,number:ie,overloadedBoolean:Bo,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),eo=Object.keys(Zo);class Na extends St{constructor(t,n,r,i){let s=-1;if(super(t,n),Yl(this,"space",i),typeof r=="number")for(;++s<eo.length;){const o=eo[s];Yl(this,eo[s],(r&Zo[o])===Zo[o])}}}Na.prototype.defined=!0;function Yl(e,t,n){n&&(e[t]=n)}function Nr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Na(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Lo(r)]=r,n[Lo(s.attribute)]=r}return new yi(t,n,e.space)}const tp=Nr({properties:{ariaActiveDescendant:null,ariaAtomic:nt,ariaAutoComplete:null,ariaBusy:nt,ariaChecked:nt,ariaColCount:ie,ariaColIndex:ie,ariaColSpan:ie,ariaControls:Ze,ariaCurrent:null,ariaDescribedBy:Ze,ariaDetails:null,ariaDisabled:nt,ariaDropEffect:Ze,ariaErrorMessage:null,ariaExpanded:nt,ariaFlowTo:Ze,ariaGrabbed:nt,ariaHasPopup:null,ariaHidden:nt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ze,ariaLevel:ie,ariaLive:null,ariaModal:nt,ariaMultiLine:nt,ariaMultiSelectable:nt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:ie,ariaPressed:nt,ariaReadOnly:nt,ariaRelevant:null,ariaRequired:nt,ariaRoleDescription:Ze,ariaRowCount:ie,ariaRowIndex:ie,ariaRowSpan:ie,ariaSelected:nt,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 np(e,t){return t in e?e[t]:t}function rp(e,t){return np(e,t.toLowerCase())}const Rv=Nr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:fr,acceptCharset:Ze,accessKey:Ze,action:null,allow:null,allowFullScreen:Se,allowPaymentRequest:Se,allowUserMedia:Se,alt:null,as:null,async:Se,autoCapitalize:null,autoComplete:Ze,autoFocus:Se,autoPlay:Se,blocking:Ze,capture:null,charSet:null,checked:Se,cite:null,className:Ze,cols:ie,colSpan:null,content:null,contentEditable:nt,controls:Se,controlsList:Ze,coords:ie|fr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Se,defer:Se,dir:null,dirName:null,disabled:Se,download:Bo,draggable:nt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Se,formTarget:null,headers:Ze,height:ie,hidden:Bo,high:ie,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:Se,inputMode:null,integrity:null,is:null,isMap:Se,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:Se,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Se,low:ie,manifest:null,max:null,maxLength:ie,media:null,method:null,min:null,minLength:ie,multiple:Se,muted:Se,name:null,nonce:null,noModule:Se,noValidate:Se,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:Se,optimum:ie,pattern:null,ping:Ze,placeholder:null,playsInline:Se,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Se,referrerPolicy:null,rel:Ze,required:Se,reversed:Se,rows:ie,rowSpan:ie,sandbox:Ze,scope:null,scoped:Se,seamless:Se,selected:Se,shadowRootClonable:Se,shadowRootDelegatesFocus:Se,shadowRootMode:null,shape:null,size:ie,sizes:null,slot:null,span:ie,spellCheck:nt,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:Se,useMap:null,value:nt,width:ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,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:Se,declare:Se,event:null,face:null,frame:null,frameBorder:null,hSpace:ie,leftMargin:ie,link:null,longDesc:null,lowSrc:null,marginHeight:ie,marginWidth:ie,noResize:Se,noHref:Se,noShade:Se,noWrap:Se,object:null,profile:null,prompt:null,rev:null,rightMargin:ie,rules:null,scheme:null,scrolling:nt,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:Se,disableRemotePlayback:Se,prefix:null,property:null,results:ie,security:null,unselectable:null},space:"html",transform:rp}),Mv=Nr({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:Ze,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:Se,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:fr,g2:fr,glyphName:fr,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:Ze,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:np}),ip=Nr({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()}}),sp=Nr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rp}),op=Nr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),$v={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"},Fv=/[A-Z]/g,Kl=/-[a-z]/g,Lv=/^data[-\w.:]+$/i;function Bv(e,t){const n=Lo(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"&&Lv.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Kl,Vv);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Kl.test(s)){let o=s.replace(Fv,Zv);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Na}return new i(r,t)}function Zv(e){return"-"+e.toLowerCase()}function Vv(e){return e.charAt(1).toUpperCase()}const Uv=ep([tp,Rv,ip,sp,op],"html"),Ea=ep([tp,Mv,ip,sp,op],"svg");function Jv(e){return e.join(" ").trim()}var Wn={},to,Xl;function Hv(){if(Xl)return to;Xl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
10
+ `,c="/",d="*",f="",p="comment",h="declaration";function g(S,y){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];y=y||{};var j=1,m=1;function A(O){var R=O.match(t);R&&(j+=R.length);var Y=O.lastIndexOf(l);m=~Y?O.length-Y:m+O.length}function C(){var O={line:j,column:m};return function(R){return R.position=new w(O),D(),R}}function w(O){this.start=O,this.end={line:j,column:m},this.source=y.source}w.prototype.content=S;function N(O){var R=new Error(y.source+":"+j+":"+m+": "+O);if(R.reason=O,R.filename=y.source,R.line=j,R.column=m,R.source=S,!y.silent)throw R}function J(O){var R=O.exec(S);if(R){var Y=R[0];return A(Y),S=S.slice(Y.length),R}}function D(){J(n)}function _(O){var R;for(O=O||[];R=T();)R!==!1&&O.push(R);return O}function T(){var O=C();if(!(c!=S.charAt(0)||d!=S.charAt(1))){for(var R=2;f!=S.charAt(R)&&(d!=S.charAt(R)||c!=S.charAt(R+1));)++R;if(R+=2,f===S.charAt(R-1))return N("End of comment missing");var Y=S.slice(2,R-2);return m+=2,A(Y),S=S.slice(R),m+=2,O({type:p,comment:Y})}}function I(){var O=C(),R=J(r);if(R){if(T(),!J(i))return N("property missing ':'");var Y=J(s),H=O({type:h,property:v(R[0].replace(e,f)),value:Y?v(Y[0].replace(e,f)):f});return J(o),H}}function z(){var O=[];_(O);for(var R;R=I();)R!==!1&&(O.push(R),_(O));return O}return D(),z()}function v(S){return S?S.replace(a,f):f}return to=g,to}var Ql;function Wv(){if(Ql)return Wn;Ql=1;var e=Wn&&Wn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Wn,"__esModule",{value:!0}),Wn.default=n;const t=e(Hv());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:d}=l;a?i(c,d,l):d&&(s=s||{},s[c]=d)}),s}return Wn}var Dr={},eu;function qv(){if(eu)return Dr;eu=1,Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.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)},o=function(c,d){return d.toUpperCase()},a=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,a):c=c.replace(r,a),c.replace(t,o))};return Dr.camelCase=l,Dr}var Rr,tu;function Gv(){if(tu)return Rr;tu=1;var e=Rr&&Rr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Wv()),n=qv();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Rr=r,Rr}var Yv=Gv();const Kv=la(Yv),ap=lp("end"),Ca=lp("start");function lp(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 Xv(e){const t=Ca(e),n=ap(e);if(t&&n)return{start:t,end:n}}function Kr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?nu(e.position):"start"in e||"end"in e?nu(e):"line"in e||"column"in e?Vo(e):""}function Vo(e){return ru(e&&e.line)+":"+ru(e&&e.column)}function nu(e){return Vo(e&&e.start)+"-"+Vo(e&&e.end)}function ru(e){return e&&typeof e=="number"?e:1}class ut extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!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&&(o=!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 a=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=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.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=o&&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}}ut.prototype.file="";ut.prototype.name="";ut.prototype.reason="";ut.prototype.message="";ut.prototype.stack="";ut.prototype.column=void 0;ut.prototype.line=void 0;ut.prototype.ancestors=void 0;ut.prototype.cause=void 0;ut.prototype.fatal=void 0;ut.prototype.place=void 0;ut.prototype.ruleId=void 0;ut.prototype.source=void 0;const Ta={}.hasOwnProperty,Qv=new Map,ew=/[A-Z]/g,tw=new Set(["table","tbody","thead","tfoot","tr"]),nw=new Set(["td","th"]),up="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function rw(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=dw(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=cw(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"?Ea:Uv,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=cp(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function cp(e,t,n){if(t.type==="element")return iw(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return sw(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return aw(e,t,n);if(t.type==="mdxjsEsm")return ow(e,t);if(t.type==="root")return lw(e,t,n);if(t.type==="text")return uw(e,t)}function iw(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Ea,e.schema=i),e.ancestors.push(t);const s=fp(e,t.tagName,!1),o=fw(e,t);let a=Aa(e,t);return tw.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!Pv(l):!0})),dp(e,o,s,t),Ia(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function sw(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 ow(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);oi(e,t.position)}function aw(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Ea,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:fp(e,t.name,!0),o=pw(e,t),a=Aa(e,t);return dp(e,o,s,t),Ia(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function lw(e,t,n){const r={};return Ia(r,Aa(e,t)),e.create(t,e.Fragment,r,n)}function uw(e,t){return t.value}function dp(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ia(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function cw(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function dw(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Ca(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function fw(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ta.call(t.properties,i)){const s=hw(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&nw.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function pw(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 o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.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 a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else oi(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Aa(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Qv;for(;++r<t.children.length;){const s=t.children[r];let o;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;o=l+"-"+c,i.set(l,c+1)}}const a=cp(e,s,o);a!==void 0&&n.push(a)}return n}function hw(e,t,n){const r=Bv(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Tv(n):Jv(n)),r.property==="style"){let i=typeof n=="object"?n:mw(e,String(n));return e.stylePropertyNameCase==="css"&&(i=gw(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?$v[r.property]||r.property:r.attribute,n]}}function mw(e,t){try{return Kv(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new ut("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=up+"#cannot-parse-style-attribute",i}}function fp(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=ql(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}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 Ta.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 ut("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=up+"#cannot-handle-mdx-estrees-without-createevaluater",n}function gw(e){const t={};let n;for(n in e)Ta.call(e,n)&&(t[xw(n)]=e[n]);return t}function xw(e){let t=e.replace(ew,yw);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function yw(e){return"-"+e.toLowerCase()}const no={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"]},bw={};function za(e,t){const n=bw,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return pp(e,r,i)}function pp(e,t,n){if(vw(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 iu(e.children,t,n)}return Array.isArray(e)?iu(e,t,n):""}function iu(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=pp(e[i],t,n);return r.join("")}function vw(e){return!!(e&&typeof e=="object")}const su=document.createElement("i");function Oa(e){const t="&"+e+";";su.innerHTML=t;const n=su.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,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ot(e,t){return e.length>0?(Tt(e,e.length,0,t),e):t}const ou={}.hasOwnProperty;function hp(e){const t={};let n=-1;for(;++n<e.length;)ww(t,e[n]);return t}function ww(e,t){let n;for(n in t){const i=(ou.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){ou.call(i,o)||(i[o]=[]);const a=s[o];kw(i[o],Array.isArray(a)?a:a?[a]:[])}}}function kw(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 mp(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 Vt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ht=kn(/[A-Za-z]/),lt=kn(/[\dA-Za-z]/),Sw=kn(/[#-'*+\--9=?A-Z^-~]/);function is(e){return e!==null&&(e<32||e===127)}const Uo=kn(/\d/),_w=kn(/[\dA-Fa-f]/),jw=kn(/[!-/:-@[-`{-~]/);function ye(e){return e!==null&&e<-2}function Le(e){return e!==null&&(e<0||e===32)}function Ae(e){return e===-2||e===-1||e===32}const zs=kn(new RegExp("\\p{P}|\\p{S}","u")),Mn=kn(/\s/);function kn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Er(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&lt(e.charCodeAt(n+1))&&lt(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function De(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ae(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ae(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const Nw={tokenize:Ew};function Ew(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),De(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return ye(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const Cw={tokenize:Tw},au={tokenize:Iw};function Tw(e){const t=this,n=[];let r=0,i,s,o;return a;function a(m){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,l,c)(m)}return c(m)}function l(m){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&j();const A=t.events.length;let C=A,w;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){w=t.events[C][1].end;break}y(r);let N=A;for(;N<t.events.length;)t.events[N][1].end={...w},N++;return Tt(t.events,C+1,0,t.events.slice(A)),t.events.length=N,c(m)}return a(m)}function c(m){if(r===n.length){if(!i)return p(m);if(i.currentConstruct&&i.currentConstruct.concrete)return g(m);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(au,d,f)(m)}function d(m){return i&&j(),y(r),p(m)}function f(m){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(m)}function p(m){return t.containerState={},e.attempt(au,h,g)(m)}function h(m){return r++,n.push([t.currentConstruct,t.containerState]),p(m)}function g(m){if(m===null){i&&j(),y(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){S(e.exit("chunkFlow"),!0),y(0),e.consume(m);return}return ye(m)?(e.consume(m),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(m),v)}function S(m,A){const C=t.sliceStream(m);if(A&&C.push(null),m.previous=s,s&&(s.next=m),s=m,i.defineSkip(m.start),i.write(C),t.parser.lazy[m.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const N=t.events.length;let J=N,D,_;for(;J--;)if(t.events[J][0]==="exit"&&t.events[J][1].type==="chunkFlow"){if(D){_=t.events[J][1].end;break}D=!0}for(y(r),w=N;w<t.events.length;)t.events[w][1].end={..._},w++;Tt(t.events,J+1,0,t.events.slice(N)),t.events.length=w}}function y(m){let A=n.length;for(;A-- >m;){const C=n[A];t.containerState=C[1],C[0].exit.call(t,e)}n.length=m}function j(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Iw(e,t,n){return De(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function vr(e){if(e===null||Le(e)||Mn(e))return 1;if(zs(e))return 2}function Os(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 Jo={name:"attention",resolveAll:Aw,tokenize:zw};function Aw(e,t){let n=-1,r,i,s,o,a,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},p={...e[n][1].start};lu(f,-l),lu(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.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",o,t],["exit",o,t],["enter",s,t]]),c=Ot(c,Os(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Ot(c,[["exit",s,t],["enter",a,t],["exit",a,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 zw(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=vr(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),d=vr(l),f=!d||d===2&&i||n.includes(l),p=!i||i===2&&d||n.includes(r);return c._open=!!(s===42?f:f&&(i||!p)),c._close=!!(s===42?p:p&&(d||!f)),t(l)}}function lu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ow={name:"autolink",tokenize:Pw};function Pw(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return ht(h)?(e.consume(h),o):h===64?n(h):c(h)}function o(h){return h===43||h===45||h===46||lt(h)?(r=1,a(h)):c(h)}function a(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||lt(h))&&r++<32?(e.consume(h),a):(r=0,c(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||is(h)?n(h):(e.consume(h),l)}function c(h){return h===64?(e.consume(h),d):Sw(h)?(e.consume(h),c):n(h)}function d(h){return lt(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||lt(h))&&r++<63){const g=h===45?p:f;return e.consume(h),g}return n(h)}}const bi={partial:!0,tokenize:Dw};function Dw(e,t,n){return r;function r(s){return Ae(s)?De(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ye(s)?t(s):n(s)}}const gp={continuation:{tokenize:Mw},exit:$w,name:"blockQuote",tokenize:Rw};function Rw(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ae(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Mw(e,t,n){const r=this;return i;function i(o){return Ae(o)?De(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(gp,t,n)(o)}}function $w(e){e.exit("blockQuote")}const xp={name:"characterEscape",tokenize:Fw};function Fw(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 jw(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const yp={name:"characterReference",tokenize:Lw};function Lw(e,t,n){const r=this;let i=0,s,o;return a;function a(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,o=lt,d(f))}function c(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=_w,d):(e.enter("characterReferenceValue"),s=7,o=Uo,d(f))}function d(f){if(f===59&&i){const p=e.exit("characterReferenceValue");return o===lt&&!Oa(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<s?(e.consume(f),d):n(f)}}const uu={partial:!0,tokenize:Zw},cu={concrete:!0,name:"codeFenced",tokenize:Bw};function Bw(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(w){return c(w)}function c(w){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===a?(o++,e.consume(w),d):o<3?n(w):(e.exit("codeFencedFenceSequence"),Ae(w)?De(e,f,"whitespace")(w):f(w))}function f(w){return w===null||ye(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(uu,v,A)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||ye(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(w)):Ae(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),De(e,h,"whitespace")(w)):w===96&&w===a?n(w):(e.consume(w),p)}function h(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===a?n(w):(e.consume(w),g)}function v(w){return e.attempt(i,A,S)(w)}function S(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),y}function y(w){return s>0&&Ae(w)?De(e,j,"linePrefix",s+1)(w):j(w)}function j(w){return w===null||ye(w)?e.check(uu,v,A)(w):(e.enter("codeFlowValue"),m(w))}function m(w){return w===null||ye(w)?(e.exit("codeFlowValue"),j(w)):(e.consume(w),m)}function A(w){return e.exit("codeFenced"),t(w)}function C(w,N,J){let D=0;return _;function _(R){return w.enter("lineEnding"),w.consume(R),w.exit("lineEnding"),T}function T(R){return w.enter("codeFencedFence"),Ae(R)?De(w,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):I(R)}function I(R){return R===a?(w.enter("codeFencedFenceSequence"),z(R)):J(R)}function z(R){return R===a?(D++,w.consume(R),z):D>=o?(w.exit("codeFencedFenceSequence"),Ae(R)?De(w,O,"whitespace")(R):O(R)):J(R)}function O(R){return R===null||ye(R)?(w.exit("codeFencedFence"),N(R)):J(R)}}}function Zw(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const ro={name:"codeIndented",tokenize:Uw},Vw={partial:!0,tokenize:Jw};function Uw(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),De(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?o(c):n(c)}function o(c){return c===null?l(c):ye(c)?e.attempt(Vw,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||ye(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function Jw(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):ye(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):De(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):ye(o)?i(o):n(o)}}const Hw={name:"codeText",previous:qw,resolve:Ww,tokenize:Gw};function Ww(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 qw(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Gw(e,t,n){let r=0,i,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(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 Yw{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&&Mr(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),Mr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Mr(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);Mr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Mr(this.left,n.reverse())}}}function Mr(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 bp(e){const t={};let n=-1,r,i,s,o,a,l,c;const d=new Yw(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,Kw(d,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},a=d.slice(i,n),a.unshift(r),d.splice(i,n-i+1,a))}}return Tt(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function Kw(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let d,f,p=-1,h=n,g=0,v=0;const S=[v];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(v=p+1,S.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const y=a.slice(S[p],S[p+1]),j=s.pop();l.push([j,j+y.length-1]),e.splice(j,2,y)}for(l.reverse(),p=-1;++p<l.length;)c[g+l[p][0]]=g+l[p][1],g+=l[p][1]-l[p][0]-1;return c}const Xw={resolve:e0,tokenize:t0},Qw={partial:!0,tokenize:n0};function e0(e){return bp(e),e}function t0(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):ye(a)?e.check(Qw,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function n0(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),De(e,s,"linePrefix")}function s(o){if(o===null||ye(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function vp(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(y),e.exit(s),p):y===null||y===32||y===41||is(y)?n(y):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(y))}function p(y){return y===62?(e.enter(s),e.consume(y),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===62?(e.exit("chunkString"),e.exit(a),p(y)):y===null||y===60||ye(y)?n(y):(e.consume(y),y===92?g:h)}function g(y){return y===60||y===62||y===92?(e.consume(y),h):h(y)}function v(y){return!d&&(y===null||y===41||Le(y))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(y)):d<c&&y===40?(e.consume(y),d++,v):y===41?(e.consume(y),d--,v):y===null||y===32||y===40||is(y)?n(y):(e.consume(y),y===92?S:v)}function S(y){return y===40||y===41||y===92?(e.consume(y),v):v(y)}}function wp(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),d}function d(h){return a>999||h===null||h===91||h===93&&!l||h===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):ye(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||ye(h)||a++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!Ae(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,f):f(h)}}function kp(e,t,n,r,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),c(p))}function c(p){return p===o?(e.exit(s),l(o)):p===null?n(p):ye(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),De(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===o||p===null||ye(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?f:d)}function f(p){return p===o||p===92?(e.consume(p),d):d(p)}}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):Ae(i)?De(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const r0={name:"definition",tokenize:s0},i0={partial:!0,tokenize:o0};function s0(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),o(h)}function o(h){return wp.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return i=Vt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Le(h)?Xr(e,c)(h):c(h)}function c(h){return vp(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(i0,f,f)(h)}function f(h){return Ae(h)?De(e,p,"whitespace")(h):p(h)}function p(h){return h===null||ye(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function o0(e,t,n){return r;function r(a){return Le(a)?Xr(e,i)(a):n(a)}function i(a){return kp(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ae(a)?De(e,o,"whitespace")(a):o(a)}function o(a){return a===null||ye(a)?t(a):n(a)}}const a0={name:"hardBreakEscape",tokenize:l0};function l0(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 u0={name:"headingAtx",resolve:c0,tokenize:d0};function c0(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 d0(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Le(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||ye(d)?(e.exit("atxHeading"),t(d)):Ae(d)?De(e,a,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),a(d))}function c(d){return d===null||d===35||Le(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),c)}}const f0=["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"],du=["pre","script","style","textarea"],p0={concrete:!0,name:"htmlFlow",resolveTo:g0,tokenize:x0},h0={partial:!0,tokenize:b0},m0={partial:!0,tokenize:y0};function g0(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 x0(e,t,n){const r=this;let i,s,o,a,l;return c;function c(b){return d(b)}function d(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),f}function f(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,v):b===63?(e.consume(b),i=3,r.interrupt?t:k):ht(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function p(b){return b===45?(e.consume(b),i=2,h):b===91?(e.consume(b),i=5,a=0,g):ht(b)?(e.consume(b),i=4,r.interrupt?t:k):n(b)}function h(b){return b===45?(e.consume(b),r.interrupt?t:k):n(b)}function g(b){const B="CDATA[";return b===B.charCodeAt(a++)?(e.consume(b),a===B.length?r.interrupt?t:I:g):n(b)}function v(b){return ht(b)?(e.consume(b),o=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||Le(b)){const B=b===47,V=o.toLowerCase();return!B&&!s&&du.includes(V)?(i=1,r.interrupt?t(b):I(b)):f0.includes(o.toLowerCase())?(i=6,B?(e.consume(b),y):r.interrupt?t(b):I(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?j(b):m(b))}return b===45||lt(b)?(e.consume(b),o+=String.fromCharCode(b),S):n(b)}function y(b){return b===62?(e.consume(b),r.interrupt?t:I):n(b)}function j(b){return Ae(b)?(e.consume(b),j):_(b)}function m(b){return b===47?(e.consume(b),_):b===58||b===95||ht(b)?(e.consume(b),A):Ae(b)?(e.consume(b),m):_(b)}function A(b){return b===45||b===46||b===58||b===95||lt(b)?(e.consume(b),A):C(b)}function C(b){return b===61?(e.consume(b),w):Ae(b)?(e.consume(b),C):m(b)}function w(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),l=b,N):Ae(b)?(e.consume(b),w):J(b)}function N(b){return b===l?(e.consume(b),l=null,D):b===null||ye(b)?n(b):(e.consume(b),N)}function J(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Le(b)?C(b):(e.consume(b),J)}function D(b){return b===47||b===62||Ae(b)?m(b):n(b)}function _(b){return b===62?(e.consume(b),T):n(b)}function T(b){return b===null||ye(b)?I(b):Ae(b)?(e.consume(b),T):n(b)}function I(b){return b===45&&i===2?(e.consume(b),Y):b===60&&i===1?(e.consume(b),H):b===62&&i===4?(e.consume(b),oe):b===63&&i===3?(e.consume(b),k):b===93&&i===5?(e.consume(b),ee):ye(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(h0,q,z)(b)):b===null||ye(b)?(e.exit("htmlFlowData"),z(b)):(e.consume(b),I)}function z(b){return e.check(m0,O,q)(b)}function O(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),R}function R(b){return b===null||ye(b)?z(b):(e.enter("htmlFlowData"),I(b))}function Y(b){return b===45?(e.consume(b),k):I(b)}function H(b){return b===47?(e.consume(b),o="",$):I(b)}function $(b){if(b===62){const B=o.toLowerCase();return du.includes(B)?(e.consume(b),oe):I(b)}return ht(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),$):I(b)}function ee(b){return b===93?(e.consume(b),k):I(b)}function k(b){return b===62?(e.consume(b),oe):b===45&&i===2?(e.consume(b),k):I(b)}function oe(b){return b===null||ye(b)?(e.exit("htmlFlowData"),q(b)):(e.consume(b),oe)}function q(b){return e.exit("htmlFlow"),t(b)}}function y0(e,t,n){const r=this;return i;function i(o){return ye(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function b0(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(bi,t,n)}}const v0={name:"htmlText",tokenize:w0};function w0(e,t,n){const r=this;let i,s,o;return a;function a(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),l}function l(k){return k===33?(e.consume(k),c):k===47?(e.consume(k),C):k===63?(e.consume(k),m):ht(k)?(e.consume(k),J):n(k)}function c(k){return k===45?(e.consume(k),d):k===91?(e.consume(k),s=0,g):ht(k)?(e.consume(k),j):n(k)}function d(k){return k===45?(e.consume(k),h):n(k)}function f(k){return k===null?n(k):k===45?(e.consume(k),p):ye(k)?(o=f,H(k)):(e.consume(k),f)}function p(k){return k===45?(e.consume(k),h):f(k)}function h(k){return k===62?Y(k):k===45?p(k):f(k)}function g(k){const oe="CDATA[";return k===oe.charCodeAt(s++)?(e.consume(k),s===oe.length?v:g):n(k)}function v(k){return k===null?n(k):k===93?(e.consume(k),S):ye(k)?(o=v,H(k)):(e.consume(k),v)}function S(k){return k===93?(e.consume(k),y):v(k)}function y(k){return k===62?Y(k):k===93?(e.consume(k),y):v(k)}function j(k){return k===null||k===62?Y(k):ye(k)?(o=j,H(k)):(e.consume(k),j)}function m(k){return k===null?n(k):k===63?(e.consume(k),A):ye(k)?(o=m,H(k)):(e.consume(k),m)}function A(k){return k===62?Y(k):m(k)}function C(k){return ht(k)?(e.consume(k),w):n(k)}function w(k){return k===45||lt(k)?(e.consume(k),w):N(k)}function N(k){return ye(k)?(o=N,H(k)):Ae(k)?(e.consume(k),N):Y(k)}function J(k){return k===45||lt(k)?(e.consume(k),J):k===47||k===62||Le(k)?D(k):n(k)}function D(k){return k===47?(e.consume(k),Y):k===58||k===95||ht(k)?(e.consume(k),_):ye(k)?(o=D,H(k)):Ae(k)?(e.consume(k),D):Y(k)}function _(k){return k===45||k===46||k===58||k===95||lt(k)?(e.consume(k),_):T(k)}function T(k){return k===61?(e.consume(k),I):ye(k)?(o=T,H(k)):Ae(k)?(e.consume(k),T):D(k)}function I(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),i=k,z):ye(k)?(o=I,H(k)):Ae(k)?(e.consume(k),I):(e.consume(k),O)}function z(k){return k===i?(e.consume(k),i=void 0,R):k===null?n(k):ye(k)?(o=z,H(k)):(e.consume(k),z)}function O(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||Le(k)?D(k):(e.consume(k),O)}function R(k){return k===47||k===62||Le(k)?D(k):n(k)}function Y(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function H(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),$}function $(k){return Ae(k)?De(e,ee,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):ee(k)}function ee(k){return e.enter("htmlTextData"),o(k)}}const Pa={name:"labelEnd",resolveAll:j0,resolveTo:N0,tokenize:E0},k0={tokenize:C0},S0={tokenize:T0},_0={tokenize:I0};function j0(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 N0(e,t){let n=e.length,r=0,i,s,o,a;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(o){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"&&(o=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[o][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=Ot(a,e.slice(s+1,s+r+3)),a=Ot(a,[["enter",d,t]]),a=Ot(a,Os(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Ot(a,[["exit",d,t],e[o-2],e[o-1],["exit",c,t]]),a=Ot(a,e.slice(o+1)),a=Ot(a,[["exit",l,t]]),Tt(e,s,e.length,a),e}function E0(e,t,n){const r=this;let i=r.events.length,s,o;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 a;function a(p){return s?s._inactive?f(p):(o=r.parser.defined.includes(Vt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(k0,d,o?d:f)(p):p===91?e.attempt(S0,d,o?c:f)(p):o?d(p):f(p)}function c(p){return e.attempt(_0,d,f)(p)}function d(p){return t(p)}function f(p){return s._balanced=!0,n(p)}}function C0(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 Le(f)?Xr(e,s)(f):s(f)}function s(f){return f===41?d(f):vp(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return Le(f)?Xr(e,l)(f):d(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?kp(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function c(f){return Le(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 T0(e,t,n){const r=this;return i;function i(a){return wp.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Vt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function I0(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 A0={name:"labelStartImage",resolveAll:Pa.resolveAll,tokenize:z0};function z0(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const O0={name:"labelStartLink",resolveAll:Pa.resolveAll,tokenize:P0};function P0(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const io={name:"lineEnding",tokenize:D0};function D0(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),De(e,t,"linePrefix")}}const Bi={name:"thematicBreak",tokenize:R0};function R0(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(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"),Ae(c)?De(e,a,"whitespace")(c):a(c))}}const xt={continuation:{tokenize:L0},exit:Z0,name:"list",tokenize:F0},M0={partial:!0,tokenize:V0},$0={partial:!0,tokenize:B0};function F0(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,o=0;return a;function a(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Uo(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Bi,n,c)(h):c(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return Uo(h)&&++o<10?(e.consume(h),l):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):n(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(bi,r.interrupt?n:d,e.attempt(M0,p,f))}function d(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function f(h){return Ae(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function L0(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(bi,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,De(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ae(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt($0,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,De(e,e.attempt(xt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function B0(e,t,n){const r=this;return De(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Z0(e){e.exit(this.containerState.type)}function V0(e,t,n){const r=this;return De(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ae(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const fu={name:"setextUnderline",resolveTo:U0,tokenize:J0};function U0(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 o={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",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function J0(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,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ae(c)?De(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ye(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const H0={tokenize:W0};function W0(e){const t=this,n=e.attempt(bi,r,e.attempt(this.parser.constructs.flowInitial,i,De(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Xw,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 q0={resolveAll:_p()},G0=Sp("string"),Y0=Sp("text");function Sp(e){return{resolveAll:_p(e==="text"?K0:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(d){return c(d)?s(d):a(d)}function a(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 p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function _p(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 K0(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,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},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 X0={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:gp},Q0={91:r0},ek={[-2]:ro,[-1]:ro,32:ro},tk={35:u0,42:Bi,45:[fu,Bi],60:p0,61:fu,95:Bi,96:cu,126:cu},nk={38:yp,92:xp},rk={[-5]:io,[-4]:io,[-3]:io,33:A0,38:yp,42:Jo,60:[Ow,v0],91:O0,92:[a0,xp],93:Pa,95:Jo,96:Hw},ik={null:[Jo,q0]},sk={null:[42,95]},ok={null:[]},ak=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:sk,contentInitial:Q0,disable:ok,document:X0,flow:tk,flowInitial:ek,insideSpan:ik,string:nk,text:rk},Symbol.toStringTag,{value:"Module"}));function lk(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 o=[],a=[];const l={attempt:N(C),check:N(w),consume:j,enter:m,exit:A,interrupt:N(w,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function f(T){return o=Ot(o,T),S(),o[o.length-1]!==null?[]:(J(t,0),c.events=Os(s,c.events,c),c.events)}function p(T,I){return ck(h(T),I)}function h(T){return uk(o,T)}function g(){const{_bufferIndex:T,_index:I,line:z,column:O,offset:R}=r;return{_bufferIndex:T,_index:I,line:z,column:O,offset:R}}function v(T){i[T.line]=T.column,_()}function S(){let T;for(;r._index<o.length;){const I=o[r._index];if(typeof I=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<I.length;)y(I.charCodeAt(r._bufferIndex));else y(I)}}function y(T){d=d(T)}function j(T){ye(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,_()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=T}function m(T,I){const z=I||{};return z.type=T,z.start=g(),c.events.push(["enter",z,c]),a.push(z),z}function A(T){const I=a.pop();return I.end=g(),c.events.push(["exit",I,c]),I}function C(T,I){J(T,I.from)}function w(T,I){I.restore()}function N(T,I){return z;function z(O,R,Y){let H,$,ee,k;return Array.isArray(O)?q(O):"tokenize"in O?q([O]):oe(O);function oe(re){return se;function se(P){const ue=P!==null&&re[P],he=P!==null&&re.null,ce=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(he)?he:he?[he]:[]];return q(ce)(P)}}function q(re){return H=re,$=0,re.length===0?Y:b(re[$])}function b(re){return se;function se(P){return k=D(),ee=re,re.partial||(c.currentConstruct=re),re.name&&c.parser.constructs.disable.null.includes(re.name)?V():re.tokenize.call(I?Object.assign(Object.create(c),I):c,l,B,V)(P)}}function B(re){return T(ee,k),R}function V(re){return k.restore(),++$<H.length?b(H[$]):Y}}}function J(T,I){T.resolveAll&&!s.includes(T)&&s.push(T),T.resolve&&Tt(c.events,I,c.events.length-I,T.resolve(c.events.slice(I),c)),T.resolveTo&&(c.events=T.resolveTo(c.events,c))}function D(){const T=g(),I=c.previous,z=c.currentConstruct,O=c.events.length,R=Array.from(a);return{from:O,restore:Y};function Y(){r=T,c.previous=I,c.currentConstruct=z,c.events.length=O,a=R,_()}}function _(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function uk(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function ck(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
11
+ `;break}case-3:{o=`\r
12
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function dk(e){const r={constructs:hp([ak,...(e||{}).extensions||[]]),content:i(Nw),defined:[],document:i(Cw),flow:i(H0),lazy:{},string:i(G0),text:i(Y0)};return r;function i(s){return o;function o(a){return lk(r,s,a)}}}function fk(e){for(;!bp(e););return e}const pu=/[\0\t\n\r]/g;function pk(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,d,f,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(pu.lastIndex=f,c=pu.exec(s),p=c&&c.index!==void 0?c.index:s.length,h=s.charCodeAt(p),!c){t=s.slice(f);break}if(h===10&&f===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<p&&(l.push(s.slice(f,p)),e+=p-f),h){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=p+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const hk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function mk(e){return e.replace(hk,gk)}function gk(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return mp(n.slice(s?2:1),s?16:10)}return Oa(n)||e}const jp={}.hasOwnProperty;function xk(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),yk(n)(fk(dk(n).document().write(pk()(e,t,!0))))}function yk(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(M),autolinkProtocol:D,autolinkEmail:D,atxHeading:s(Te),blockQuote:s(he),characterEscape:D,characterReference:D,codeFenced:s(ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(ce,o),codeText:s(pe,o),codeTextData:D,data:D,codeFlowValue:D,definition:s(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(U),hardBreakEscape:s(X),hardBreakTrailing:s(X),htmlFlow:s(we,o),htmlFlowData:D,htmlText:s(we,o),htmlTextData:D,image:s(E),label:o,link:s(M),listItem:s(ne),listItemValue:p,listOrdered:s(F,f),listUnordered:s(F),paragraph:s(Q),reference:b,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Te),strong:s(te),thematicBreak:s(ve)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ue,autolinkProtocol:P,blockQuote:l(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:re,characterReference:se,codeFenced:l(S),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:_,codeIndented:l(y),codeText:l(R),codeTextData:_,data:_,definition:l(),definitionDestinationString:A,definitionLabelString:j,definitionTitleString:m,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(z),htmlFlowData:_,htmlText:l(O),htmlTextData:_,image:l(H),label:ee,labelText:$,lineEnding:T,link:l(Y),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:k,resourceTitleString:oe,resource:q,setextHeading:l(J),setextHeadingLineSequence:N,setextHeadingText:w,strong:l(),thematicBreak:l()}};Np(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(Z){let K={type:"root",children:[]};const ge={stack:[K],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:d,data:n},Ne=[];let L=-1;for(;++L<Z.length;)if(Z[L][1].type==="listOrdered"||Z[L][1].type==="listUnordered")if(Z[L][0]==="enter")Ne.push(L);else{const xe=Ne.pop();L=i(Z,xe,L)}for(L=-1;++L<Z.length;){const xe=t[Z[L][0]];jp.call(xe,Z[L][1].type)&&xe[Z[L][1].type].call(Object.assign({sliceSerialize:Z[L][2].sliceSerialize},ge),Z[L][1])}if(ge.tokenStack.length>0){const xe=ge.tokenStack[ge.tokenStack.length-1];(xe[1]||hu).call(ge,void 0,xe[0])}for(K.position={start:dn(Z.length>0?Z[0][1].start:{line:1,column:1,offset:0}),end:dn(Z.length>0?Z[Z.length-2][1].end:{line:1,column:1,offset:0})},L=-1;++L<t.transforms.length;)K=t.transforms[L](K)||K;return K}function i(Z,K,ge){let Ne=K-1,L=-1,xe=!1,ze,Be,rt,tt;for(;++Ne<=ge;){const at=Z[Ne];switch(at[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{at[0]==="enter"?L++:L--,tt=void 0;break}case"lineEndingBlank":{at[0]==="enter"&&(ze&&!tt&&!L&&!rt&&(rt=Ne),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!L&&at[0]==="enter"&&at[1].type==="listItemPrefix"||L===-1&&at[0]==="exit"&&(at[1].type==="listUnordered"||at[1].type==="listOrdered")){if(ze){let un=Ne;for(Be=void 0;un--;){const en=Z[un];if(en[1].type==="lineEnding"||en[1].type==="lineEndingBlank"){if(en[0]==="exit")continue;Be&&(Z[Be][1].type="lineEndingBlank",xe=!0),en[1].type="lineEnding",Be=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&&(!Be||rt<Be)&&(ze._spread=!0),ze.end=Object.assign({},Be?Z[Be][1].start:at[1].end),Z.splice(Be||Ne,0,["exit",ze,at[2]]),Ne++,ge++}if(at[1].type==="listItemPrefix"){const un={type:"listItem",_spread:!1,start:Object.assign({},at[1].start),end:void 0};ze=un,Z.splice(Ne,0,["enter",un,at[2]]),Ne++,ge++,rt=void 0,tt=!0}}}return Z[K][1]._spread=xe,ge}function s(Z,K){return ge;function ge(Ne){a.call(this,Z(Ne),Ne),K&&K.call(this,Ne)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(Z,K,ge){this.stack[this.stack.length-1].children.push(Z),this.stack.push(Z),this.tokenStack.push([K,ge||void 0]),Z.position={start:dn(K.start),end:void 0}}function l(Z){return K;function K(ge){Z&&Z.call(this,ge),c.call(this,ge)}}function c(Z,K){const ge=this.stack.pop(),Ne=this.tokenStack.pop();if(Ne)Ne[0].type!==Z.type&&(K?K.call(this,Z,Ne[0]):(Ne[1]||hu).call(this,Z,Ne[0]));else throw new Error("Cannot close `"+Z.type+"` ("+Kr({start:Z.start,end:Z.end})+"): it’s not open");ge.position.end=dn(Z.end)}function d(){return za(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(Z){if(this.data.expectingFirstListItemValue){const K=this.stack[this.stack.length-2];K.start=Number.parseInt(this.sliceSerialize(Z),10),this.data.expectingFirstListItemValue=void 0}}function h(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.lang=Z}function g(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.meta=Z}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.value=Z.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.value=Z.replace(/(\r?\n|\r)$/g,"")}function j(Z){const K=this.resume(),ge=this.stack[this.stack.length-1];ge.label=K,ge.identifier=Vt(this.sliceSerialize(Z)).toLowerCase()}function m(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.title=Z}function A(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.url=Z}function C(Z){const K=this.stack[this.stack.length-1];if(!K.depth){const ge=this.sliceSerialize(Z).length;K.depth=ge}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function N(Z){const K=this.stack[this.stack.length-1];K.depth=this.sliceSerialize(Z).codePointAt(0)===61?1:2}function J(){this.data.setextHeadingSlurpLineEnding=void 0}function D(Z){const ge=this.stack[this.stack.length-1].children;let Ne=ge[ge.length-1];(!Ne||Ne.type!=="text")&&(Ne=de(),Ne.position={start:dn(Z.start),end:void 0},ge.push(Ne)),this.stack.push(Ne)}function _(Z){const K=this.stack.pop();K.value+=this.sliceSerialize(Z),K.position.end=dn(Z.end)}function T(Z){const K=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=K.children[K.children.length-1];ge.position.end=dn(Z.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(K.type)&&(D.call(this,Z),_.call(this,Z))}function I(){this.data.atHardBreak=!0}function z(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.value=Z}function O(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.value=Z}function R(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.value=Z}function Y(){const Z=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";Z.type+="Reference",Z.referenceType=K,delete Z.url,delete Z.title}else delete Z.identifier,delete Z.label;this.data.referenceType=void 0}function H(){const Z=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";Z.type+="Reference",Z.referenceType=K,delete Z.url,delete Z.title}else delete Z.identifier,delete Z.label;this.data.referenceType=void 0}function $(Z){const K=this.sliceSerialize(Z),ge=this.stack[this.stack.length-2];ge.label=mk(K),ge.identifier=Vt(K).toLowerCase()}function ee(){const Z=this.stack[this.stack.length-1],K=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const Ne=Z.children;ge.children=Ne}else ge.alt=K}function k(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.url=Z}function oe(){const Z=this.resume(),K=this.stack[this.stack.length-1];K.title=Z}function q(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function B(Z){const K=this.resume(),ge=this.stack[this.stack.length-1];ge.label=K,ge.identifier=Vt(this.sliceSerialize(Z)).toLowerCase(),this.data.referenceType="full"}function V(Z){this.data.characterReferenceType=Z.type}function re(Z){const K=this.sliceSerialize(Z),ge=this.data.characterReferenceType;let Ne;ge?(Ne=mp(K,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ne=Oa(K);const L=this.stack[this.stack.length-1];L.value+=Ne}function se(Z){const K=this.stack.pop();K.position.end=dn(Z.end)}function P(Z){_.call(this,Z);const K=this.stack[this.stack.length-1];K.url=this.sliceSerialize(Z)}function ue(Z){_.call(this,Z);const K=this.stack[this.stack.length-1];K.url="mailto:"+this.sliceSerialize(Z)}function he(){return{type:"blockquote",children:[]}}function ce(){return{type:"code",lang:null,meta:null,value:""}}function pe(){return{type:"inlineCode",value:""}}function me(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function U(){return{type:"emphasis",children:[]}}function Te(){return{type:"heading",depth:0,children:[]}}function X(){return{type:"break"}}function we(){return{type:"html",value:""}}function E(){return{type:"image",title:null,url:"",alt:null}}function M(){return{type:"link",title:null,url:"",children:[]}}function F(Z){return{type:"list",ordered:Z.type==="listOrdered",start:null,spread:Z._spread,children:[]}}function ne(Z){return{type:"listItem",spread:Z._spread,checked:null,children:[]}}function Q(){return{type:"paragraph",children:[]}}function te(){return{type:"strong",children:[]}}function de(){return{type:"text",value:""}}function ve(){return{type:"thematicBreak"}}}function dn(e){return{line:e.line,column:e.column,offset:e.offset}}function Np(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Np(e,r):bk(e,r)}}function bk(e,t){let n;for(n in t)if(jp.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 hu(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 vk(e){const t=this;t.parser=n;function n(r){return xk(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function wk(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 kk(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
13
+ `}]}function Sk(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 _k(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jk(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nk(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Er(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function Ek(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 Ck(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Ep(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 o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function Tk(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Ep(e,t);const i={src:Er(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 Ik(e,t){const n={src:Er(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 Ak(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 zk(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Ep(e,t);const i={href:Er(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 Ok(e,t){const n={href:Er(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 Pk(e,t,n){const r=e.all(t),i=n?Dk(n):Cp(t),s={},o=[];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 a=-1;for(;++a<r.length;){const d=r[a];(i||a!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
15
+ `}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
16
+ `});const c={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,c),e.applyData(t,c)}function Dk(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=Cp(n[r])}return t}function Cp(e){const t=e.spread;return t??e.children.length>1}function Rk(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 o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.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 Mk(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $k(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Fk(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Lk(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Ca(t.children[1]),l=ap(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Bk(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const c=[];for(;++l<a;){const f=t.children[l],p={},h=o?o[l]:void 0;h&&(p.align=h);let g={type:"element",tagName:s,properties:p,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 Zk(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const mu=9,gu=32;function Vk(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(xu(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(xu(t.slice(i),i>0,!1)),s.join("")}function xu(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===mu||s===gu;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===mu||s===gu;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Uk(e,t){const n={type:"text",value:Vk(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Jk(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Hk={blockquote:wk,break:kk,code:Sk,delete:_k,emphasis:jk,footnoteReference:Nk,heading:Ek,html:Ck,imageReference:Tk,image:Ik,inlineCode:Ak,linkReference:zk,link:Ok,listItem:Pk,list:Rk,paragraph:Mk,root:$k,strong:Fk,table:Lk,tableCell:Zk,tableRow:Bk,text:Uk,thematicBreak:Jk,toml:Ti,yaml:Ti,definition:Ti,footnoteDefinition:Ti};function Ti(){}const Tp=-1,Ps=0,Qr=1,ss=2,Da=3,Ra=4,Ma=5,$a=6,Ip=7,Ap=8,yu=typeof self=="object"?self:globalThis,Wk=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case Ps:case Tp:return n(o,i);case Qr:{const a=n([],i);for(const l of o)a.push(r(l));return a}case ss:{const a=n({},i);for(const[l,c]of o)a[r(l)]=r(c);return a}case Da:return n(new Date(o),i);case Ra:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case Ma:{const a=n(new Map,i);for(const[l,c]of o)a.set(r(l),r(c));return a}case $a:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case Ip:{const{name:a,message:l}=o;return n(new yu[a](l),i)}case Ap:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new yu[s](o),i)};return r},bu=e=>Wk(new Map,e)(0),qn="",{toString:qk}={},{keys:Gk}=Object,$r=e=>{const t=typeof e;if(t!=="object"||!e)return[Ps,t];const n=qk.call(e).slice(8,-1);switch(n){case"Array":return[Qr,qn];case"Object":return[ss,qn];case"Date":return[Da,qn];case"RegExp":return[Ra,qn];case"Map":return[Ma,qn];case"Set":return[$a,qn];case"DataView":return[Qr,n]}return n.includes("Array")?[Qr,n]:n.includes("Error")?[Ip,n]:[ss,n]},Ii=([e,t])=>e===Ps&&(t==="function"||t==="symbol"),Yk=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=$r(o);switch(a){case Ps:{let d=o;switch(l){case"bigint":a=Ap,d=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);d=null;break;case"undefined":return i([Tp],o)}return i([a,d],o)}case Qr:{if(l){let p=o;return l==="DataView"?p=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(o)),i([l,[...p]],o)}const d=[],f=i([a,d],o);for(const p of o)d.push(s(p));return f}case ss:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const d=[],f=i([a,d],o);for(const p of Gk(o))(e||!Ii($r(o[p])))&&d.push([s(p),s(o[p])]);return f}case Da:return i([a,o.toISOString()],o);case Ra:{const{source:d,flags:f}=o;return i([a,{source:d,flags:f}],o)}case Ma:{const d=[],f=i([a,d],o);for(const[p,h]of o)(e||!(Ii($r(p))||Ii($r(h))))&&d.push([s(p),s(h)]);return f}case $a:{const d=[],f=i([a,d],o);for(const p of o)(e||!Ii($r(p)))&&d.push(s(p));return f}}const{message:c}=o;return i([a,{name:l,message:c}],o)};return s},vu=(e,{json:t,lossy:n}={})=>{const r=[];return Yk(!(t||n),!!t,new Map,r)(e),r},os=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?bu(vu(e,t)):structuredClone(e):(e,t)=>bu(vu(e,t));function Kk(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 Xk(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Qk(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Kk,r=e.options.footnoteBackLabel||Xk,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];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(),p=Er(f.toLowerCase());let h=0;const g=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){g.length>0&&g.push({type:"text",value:" "});let j=typeof n=="string"?n:n(l,h);typeof j=="string"&&(j={type:"text",value:j}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const S=d[d.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const j=S.children[S.children.length-1];j&&j.type==="text"?j.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...g)}else d.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(c,y),a.push(y)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...os(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
17
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
18
+ `}]}}const Ds=function(e){if(e==null)return r1;if(typeof e=="function")return Rs(e);if(typeof e=="object")return Array.isArray(e)?e1(e):t1(e);if(typeof e=="string")return n1(e);throw new Error("Expected function, string, or object as test")};function e1(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ds(e[n]);return Rs(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function t1(e){const t=e;return Rs(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function n1(e){return Rs(t);function t(n){return n&&n.type===e}}function Rs(e){return t;function t(n,r,i){return!!(i1(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function r1(){return!0}function i1(e){return e!==null&&typeof e=="object"&&"type"in e}const zp=[],s1=!0,Ho=!1,o1="skip";function Op(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Ds(i),o=r?-1:1;a(e,void 0,[])();function a(l,c,d){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=zp,g,v,S;if((!t||s(l,c,d[d.length-1]||void 0))&&(h=a1(n(l,d)),h[0]===Ho))return h;if("children"in l&&l.children){const y=l;if(y.children&&h[0]!==o1)for(v=(r?y.children.length:-1)+o,S=d.concat(y);v>-1&&v<y.children.length;){const j=y.children[v];if(g=a(j,v,S)(),g[0]===Ho)return g;v=typeof g[1]=="number"?g[1]:v+o}}return h}}}function a1(e){return Array.isArray(e)?e:typeof e=="number"?[s1,e]:e==null?zp:[e]}function Fa(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),Op(e,s,a,i);function a(l,c){const d=c[c.length-1],f=d?d.children.indexOf(l):void 0;return o(l,f,d)}}const Wo={}.hasOwnProperty,l1={};function u1(e,t){const n=t||l1,r=new Map,i=new Map,s=new Map,o={...Hk,...n.handlers},a={all:c,applyData:d1,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:c1,wrap:p1};return Fa(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:i,p=String(d.identifier).toUpperCase();f.has(p)||f.set(p,d)}}),a;function l(d,f){const p=d.type,h=a.handlers[p];if(Wo.call(a.handlers,p)&&h)return h(a,d,f);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in d){const{children:v,...S}=d,y=os(S);return y.children=a.all(d),y}return os(d)}return(a.options.unknownHandler||f1)(a,d,f)}function c(d){const f=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const g=a.one(p[h],d);if(g){if(h&&p[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=wu(g.value)),!Array.isArray(g)&&g.type==="element")){const v=g.children[0];v&&v.type==="text"&&(v.value=wu(v.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function c1(e,t){e.position&&(t.position=Xv(e))}function d1(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 o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}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 f1(e,t){const n=t.data||{},r="value"in t&&!(Wo.call(n,"hProperties")||Wo.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 p1(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 wu(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ku(e,t){const n=u1(e,t),r=n.one(e,void 0),i=Qk(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 h1(e,t){return e&&"run"in e?async function(n,r){const i=ku(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ku(n,{file:r,...e||t})}}function Su(e){if(e)throw e}var so,_u;function m1(){if(_u)return so;_u=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 p;for(p in c);return typeof p>"u"||e.call(c,p)},o=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},a=function(c,d){if(d==="__proto__")if(e.call(c,d)){if(r)return r(c,d).value}else return;return c[d]};return so=function l(){var c,d,f,p,h,g,v=arguments[0],S=1,y=arguments.length,j=!1;for(typeof v=="boolean"&&(j=v,v=arguments[1]||{},S=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});S<y;++S)if(c=arguments[S],c!=null)for(d in c)f=a(v,d),p=a(c,d),v!==p&&(j&&p&&(s(p)||(h=i(p)))?(h?(h=!1,g=f&&i(f)?f:[]):g=f&&s(f)?f:{},o(v,{name:d,newValue:l(j,g,p)})):typeof p<"u"&&o(v,{name:d,newValue:p}));return v},so}var g1=m1();const oo=la(g1);function qo(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 x1(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...c){const d=e[++s];let f=-1;if(l){o(l);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,d?y1(d,a)(...c):o(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 y1(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(c){const d=c;if(a&&n)throw d;return i(d)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const Wt={basename:b1,dirname:v1,extname:w1,join:k1,sep:"/"};function b1(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');vi(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 o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function v1(e){if(vi(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 w1(e){vi(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===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 k1(...e){let t=-1,n;for(;++t<e.length;)vi(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":S1(n)}function S1(e){vi(e);const t=e.codePointAt(0)===47;let n=_1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function _1(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-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=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function vi(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const j1={cwd:N1};function N1(){return"/"}function Go(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function E1(e){if(typeof e=="string")e=new URL(e);else if(!Go(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 C1(e)}function C1(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 ao=["history","path","basename","stem","extname","dirname"];class Pp{constructor(t){let n;t?Go(t)?n={path:t}:typeof t=="string"||T1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":j1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ao.length;){const s=ao[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)ao.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Wt.basename(this.path):void 0}set basename(t){uo(t,"basename"),lo(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){ju(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(lo(t,"extname"),ju(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){Go(t)&&(t=E1(t)),uo(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){uo(t,"stem"),lo(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 ut(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 lo(e,t){if(e&&e.includes(Wt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Wt.sep+"`")}function uo(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ju(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function T1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const I1=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},A1={}.hasOwnProperty;class La extends I1{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=x1()}copy(){const t=new La;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(oo(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(po("data",this.frozen),this.namespace[t]=n,this):A1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(po("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 co("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),co("process",this.parser||this.Parser),fo("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Ai(t),l=r.parse(a);r.run(l,a,function(d,f,p){if(d||!f||!p)return c(d);const h=f,g=r.stringify(h,p);P1(g)?p.value=g:p.result=g,c(d,p)});function c(d,f){d||!f?o(d):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),co("processSync",this.parser||this.Parser),fo("processSync",this.compiler||this.Compiler),this.process(t,i),Eu("processSync","process",n),r;function i(s,o){n=!0,Su(s),r=o}}run(t,n,r){Nu(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(o,a){const l=Ai(n);i.run(t,l,c);function c(d,f,p){const h=f||t;d?a(d):o?o(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Eu("runSync","run",r),i;function s(o,a){Su(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=Ai(n),i=this.compiler||this.Compiler;return fo("stringify",i),Nu(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(po("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(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 o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(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");a(c.plugins),c.settings&&(i.settings=oo(!0,i.settings,c.settings))}function a(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,p=-1;for(;++f<r.length;)if(r[f][0]===c){p=f;break}if(p===-1)r.push([c,...d]);else if(d.length>0){let[h,...g]=d;const v=r[p][1];qo(v)&&qo(h)&&(h=oo(!0,v,h)),r[p]=[c,h,...g]}}}}const z1=new La().freeze();function co(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function fo(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function po(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 Nu(e){if(!qo(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Eu(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ai(e){return O1(e)?e:new Pp(e)}function O1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function P1(e){return typeof e=="string"||D1(e)}function D1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const R1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Cu=[],Tu={allowDangerousHtml:!0},M1=/^(https?|ircs?|mailto|xmpp)$/i,$1=[{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 F1(e){const t=L1(e),n=B1(e);return Z1(t.runSync(t.parse(n),n),e)}function L1(e){const t=e.rehypePlugins||Cu,n=e.remarkPlugins||Cu,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Tu}:Tu;return z1().use(vk).use(n).use(h1,r).use(t)}function B1(e){const t=e.children||"",n=new Pp;return typeof t=="string"&&(n.value=t),n}function Z1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||V1;for(const d of $1)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+R1+d.id,void 0);return Fa(e,c),rw(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return o?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in no)if(Object.hasOwn(no,h)&&Object.hasOwn(d.properties,h)){const g=d.properties[h],v=no[h];(v===null||v.includes(d.tagName))&&(d.properties[h]=l(String(g||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return a&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function V1(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||M1.test(e.slice(0,t))?e:""}function Iu(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 U1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function J1(e,t,n){const i=Ds((n||{}).ignore||[]),s=H1(t);let o=-1;for(;++o<s.length;)Op(e,"text",a);function a(c,d){let f=-1,p;for(;++f<d.length;){const h=d[f],g=p?p.children:void 0;if(i(h,g?g.indexOf(h):void 0,p))return;p=h}if(p)return l(c,d)}function l(c,d){const f=d[d.length-1],p=s[o][0],h=s[o][1];let g=0;const S=f.children.indexOf(c);let y=!1,j=[];p.lastIndex=0;let m=p.exec(c.value);for(;m;){const A=m.index,C={index:m.index,input:m.input,stack:[...d,c]};let w=h(...m,C);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?p.lastIndex=A+1:(g!==A&&j.push({type:"text",value:c.value.slice(g,A)}),Array.isArray(w)?j.push(...w):w&&j.push(w),g=A+m[0].length,y=!0),!p.global)break;m=p.exec(c.value)}return y?(g<c.value.length&&j.push({type:"text",value:c.value.slice(g)}),f.children.splice(S,1,...j)):j=[c],S+j.length}}function H1(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([W1(i[0]),q1(i[1])])}return t}function W1(e){return typeof e=="string"?new RegExp(U1(e),"g"):e}function q1(e){return typeof e=="function"?e:function(){return e}}const ho="phrasing",mo=["autolink","link","image","label"];function G1(){return{transforms:[nS],enter:{literalAutolink:K1,literalAutolinkEmail:go,literalAutolinkHttp:go,literalAutolinkWww:go},exit:{literalAutolink:tS,literalAutolinkEmail:eS,literalAutolinkHttp:X1,literalAutolinkWww:Q1}}}function Y1(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ho,notInConstruct:mo},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ho,notInConstruct:mo},{character:":",before:"[ps]",after:"\\/",inConstruct:ho,notInConstruct:mo}]}}function K1(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function go(e){this.config.enter.autolinkProtocol.call(this,e)}function X1(e){this.config.exit.autolinkProtocol.call(this,e)}function Q1(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 eS(e){this.config.exit.autolinkEmail.call(this,e)}function tS(e){this.exit(e)}function nS(e){J1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,rS],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),iS]],{ignore:["link","linkReference"]})}function rS(e,t,n,r,i){let s="";if(!Dp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!sS(n)))return!1;const o=oS(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function iS(e,t,n,r){return!Dp(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function sS(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 oS(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=Iu(e,"(");let s=Iu(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 Dp(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Mn(n)||zs(n))&&(!t||n!==47)}Rp.peek=mS;function aS(){this.buffer()}function lS(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function uS(){this.buffer()}function cS(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function dS(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Vt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function fS(e){this.exit(e)}function pS(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Vt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function hS(e){this.exit(e)}function mS(){return"["}function Rp(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function gS(){return{enter:{gfmFootnoteCallString:aS,gfmFootnoteCall:lS,gfmFootnoteDefinitionLabelString:uS,gfmFootnoteDefinition:cS},exit:{gfmFootnoteCallString:dS,gfmFootnoteCall:fS,gfmFootnoteDefinitionLabelString:pS,gfmFootnoteDefinition:hS}}}function xS(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Rp},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const c=s.enter("footnoteDefinition"),d=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),d(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
23
+ `:" ")+s.indentLines(s.containerFlow(r,a.current()),t?Mp:yS))),c(),l}}function yS(e,t,n){return t===0?e:Mp(e,t,n)}function Mp(e,t,n){return(n?"":" ")+e}const bS=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];$p.peek=_S;function vS(){return{canContainEols:["delete"],enter:{strikethrough:kS},exit:{strikethrough:SS}}}function wS(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:bS}],handlers:{delete:$p}}}function kS(e){this.enter({type:"delete",children:[]},e)}function SS(e){this.exit(e)}function $p(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function _S(){return"~"}function jS(e){return e.length}function NS(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||jS,s=[],o=[],a=[],l=[];let c=0,d=-1;for(;++d<e.length;){const v=[],S=[];let y=-1;for(e[d].length>c&&(c=e[d].length);++y<e[d].length;){const j=ES(e[d][y]);if(n.alignDelimiters!==!1){const m=i(j);S[y]=m,(l[y]===void 0||m>l[y])&&(l[y]=m)}v.push(j)}o[d]=v,a[d]=S}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<c;)s[f]=Au(r[f]);else{const v=Au(r);for(;++f<c;)s[f]=v}f=-1;const p=[],h=[];for(;++f<c;){const v=s[f];let S="",y="";v===99?(S=":",y=":"):v===108?S=":":v===114&&(y=":");let j=n.alignDelimiters===!1?1:Math.max(1,l[f]-S.length-y.length);const m=S+"-".repeat(j)+y;n.alignDelimiters!==!1&&(j=S.length+j+y.length,j>l[f]&&(l[f]=j),h[f]=j),p[f]=m}o.splice(1,0,p),a.splice(1,0,h),d=-1;const g=[];for(;++d<o.length;){const v=o[d],S=a[d];f=-1;const y=[];for(;++f<c;){const j=v[f]||"";let m="",A="";if(n.alignDelimiters!==!1){const C=l[f]-(S[f]||0),w=s[f];w===114?m=" ".repeat(C):w===99?C%2?(m=" ".repeat(C/2+.5),A=" ".repeat(C/2-.5)):(m=" ".repeat(C/2),A=m):A=" ".repeat(C)}n.delimiterStart!==!1&&!f&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&j==="")&&(n.delimiterStart!==!1||f)&&y.push(" "),n.alignDelimiters!==!1&&y.push(m),y.push(j),n.alignDelimiters!==!1&&y.push(A),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||f!==c-1)&&y.push("|")}g.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return g.join(`
24
+ `)}function ES(e){return e==null?"":String(e)}function Au(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 CS(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),TS);return i(),o}function TS(e,t,n){return">"+(n?"":" ")+e}function IS(e,t){return zu(e,t.inConstruct,!0)&&!zu(e,t.notInConstruct,!1)}function zu(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 Ou(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
25
+ `&&IS(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
26
+ `}function AS(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function zS(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 OS(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 PS(e,t,n,r){const i=OS(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(zS(e,n)){const f=n.enter("codeIndented"),p=n.indentLines(s,DS);return f(),p}const a=n.createTracker(r),l=i.repeat(Math.max(AS(s,i)+1,3)),c=n.enter("codeFenced");let d=a.move(l);if(e.lang){const f=n.enter(`codeFencedLang${o}`);d+=a.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...a.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${o}`);d+=a.move(" "),d+=a.move(n.safe(e.meta,{before:d,after:`
27
+ `,encode:["`"],...a.current()})),f()}return d+=a.move(`
28
+ `),s&&(d+=a.move(s+`
29
+ `)),d+=a.move(l),c(),d}function DS(e,t,n){return(n?"":" ")+e}function Ba(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 RS(e,t,n,r){const i=Ba(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=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("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
30
+ `,...l.current()}))),a(),e.title&&(a=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),a()),o(),c}function MS(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 ai(e){return"&#x"+e.toString(16).toUpperCase()+";"}function as(e,t,n){const r=vr(e),i=vr(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}}Fp.peek=$S;function Fp(e,t,n,r){const i=MS(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),d=as(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=ai(c)+l.slice(1));const f=l.charCodeAt(l.length-1),p=as(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+ai(f));const h=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},a+l+h}function $S(e,t,n){return n.options.emphasis||"*"}function FS(e,t){let n=!1;return Fa(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ho}),!!((!e.depth||e.depth<3)&&za(e)&&(t.options.setext||n))}function LS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(FS(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
31
+ `,after:`
32
+ `});return f(),d(),p+`
33
+ `+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
34
+ `))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
35
+ `,...s.current()});return/^[\t ]/.test(c)&&(c=ai(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),a(),c}Lp.peek=BS;function Lp(e){return e.value||""}function BS(){return"<"}Bp.peek=ZS;function Bp(e,t,n,r){const i=Ba(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=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("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=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),a()),c+=l.move(")"),o(),c}function ZS(){return"!"}Zp.peek=VS;function Zp(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!c||c!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function VS(){return"!"}Vp.peek=US;function Vp(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 o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.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 US(){return"`"}function Up(e,t){const n=za(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))}Jp.peek=JS;function Jp(e,t,n,r){const i=Ba(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(Up(e,n)){const d=n.stack;n.stack=[],a=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(e,{before:f,after:">",...o.current()})),f+=o.move(">"),a(),n.stack=d,f}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=o.move(" "+i),c+=o.move(n.safe(e.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),a(),c}function JS(e,t,n){return Up(e,n)?"<":"["}Hp.peek=HS;function Hp(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!c||c!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function HS(){return"["}function Za(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 WS(e){const t=Za(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 qS(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 Wp(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 GS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?qS(n):Za(n);const a=e.ordered?o==="."?")":".":WS(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&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),Wp(n)===o&&d){let f=-1;for(;++f<e.children.length;){const p=e.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const c=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),c}function YS(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 KS(e,t,n,r){const i=YS(n);let s=n.bulletCurrent||Za(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 o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),d);return l(),c;function d(f,p,h){return p?(h?"":" ".repeat(o))+f:(h?s:s+" ".repeat(o-s.length))+f}}function XS(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const QS=Ds(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function e_(e,t,n,r){return(e.children.some(function(o){return QS(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function t_(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}qp.peek=n_;function qp(e,t,n,r){const i=t_(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),d=as(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=ai(c)+l.slice(1));const f=l.charCodeAt(l.length-1),p=as(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+ai(f));const h=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},a+l+h}function n_(e,t,n){return n.options.strong||"*"}function r_(e,t,n,r){return n.safe(e.value,r)}function i_(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 s_(e,t,n){const r=(Wp(n)+(n.options.ruleSpaces?" ":"")).repeat(i_(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Gp={blockquote:CS,break:Ou,code:PS,definition:RS,emphasis:Fp,hardBreak:Ou,heading:LS,html:Lp,image:Bp,imageReference:Zp,inlineCode:Vp,link:Jp,linkReference:Hp,list:GS,listItem:KS,paragraph:XS,root:e_,strong:qp,text:r_,thematicBreak:s_};function o_(){return{enter:{table:a_,tableData:Pu,tableHeader:Pu,tableRow:u_},exit:{codeText:c_,table:l_,tableData:xo,tableHeader:xo,tableRow:xo}}}function a_(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 l_(e){this.exit(e),this.data.inTable=void 0}function u_(e){this.enter({type:"tableRow",children:[]},e)}function xo(e){this.exit(e)}function Pu(e){this.enter({type:"tableCell",children:[]},e)}function c_(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,d_));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function d_(e,t){return t==="|"?t:e}function f_(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:p,table:o,tableCell:l,tableRow:a}};function o(h,g,v,S){return c(d(h,v,S),h.align)}function a(h,g,v,S){const y=f(h,v,S),j=c([y]);return j.slice(0,j.indexOf(`
37
+ `))}function l(h,g,v,S){const y=v.enter("tableCell"),j=v.enter("phrasing"),m=v.containerPhrasing(h,{...S,before:s,after:s});return j(),y(),m}function c(h,g){return NS(h,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function d(h,g,v){const S=h.children;let y=-1;const j=[],m=g.enter("table");for(;++y<S.length;)j[y]=f(S[y],g,v);return m(),j}function f(h,g,v){const S=h.children;let y=-1;const j=[],m=g.enter("tableRow");for(;++y<S.length;)j[y]=l(S[y],h,g,v);return m(),j}function p(h,g,v){let S=Gp.inlineCode(h,g,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function p_(){return{exit:{taskListCheckValueChecked:Du,taskListCheckValueUnchecked:Du,paragraph:m_}}}function h_(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:g_}}}function Du(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function m_(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,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===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 g_(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=Gp.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(d){return d+o}}function x_(){return[G1(),gS(),vS(),o_(),p_()]}function y_(e){return{extensions:[Y1(),xS(e),wS(),f_(e),h_()]}}const b_={tokenize:j_,partial:!0},Yp={tokenize:N_,partial:!0},Kp={tokenize:E_,partial:!0},Xp={tokenize:C_,partial:!0},v_={tokenize:T_,partial:!0},Qp={name:"wwwAutolink",tokenize:S_,previous:th},eh={name:"protocolAutolink",tokenize:__,previous:nh},ln={name:"emailAutolink",tokenize:k_,previous:rh},Qt={};function w_(){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,eh];Qt[104]=[ln,eh];Qt[87]=[ln,Qp];Qt[119]=[ln,Qp];function k_(e,t,n){const r=this;let i,s;return o;function o(f){return!Yo(f)||!rh.call(r,r.previous)||Va(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return Yo(f)?(e.consume(f),a):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(v_,d,c)(f):f===45||f===95||lt(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&&ht(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function S_(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!th.call(r,r.previous)||Va(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(b_,e.attempt(Yp,e.attempt(Kp,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function __(e,t,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&nh.call(r,r.previous)&&!Va(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(ht(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="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||is(f)||Le(f)||Mn(f)||zs(f)?n(f):e.attempt(Yp,e.attempt(Kp,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function j_(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function N_(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(Xp,l,a)(c):c===null||Le(c)||Mn(c)||c!==45&&zs(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function E_(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Xp,t,s)(o):o===null||Le(o)||Mn(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function C_(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Le(a)||Mn(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Le(a)||Mn(a)?t(a):r(a)}function s(a){return ht(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):ht(a)?(e.consume(a),o):n(a)}}function T_(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return lt(s)?n(s):t(s)}}function th(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Le(e)}function nh(e){return!ht(e)}function rh(e){return!(e===47||Yo(e))}function Yo(e){return e===43||e===45||e===46||e===95||lt(e)}function Va(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 I_={tokenize:$_,partial:!0};function A_(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:D_,continuation:{tokenize:R_},exit:M_}},text:{91:{name:"gfmFootnoteCall",tokenize:P_},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:z_,resolveTo:O_}}}}function z_(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Vt(r.sliceSerialize({start:o.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 O_(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)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[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",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function P_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(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&&!o||f===null||f===91||Le(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Vt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Le(f)||(o=!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 D_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;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(o>999||g===93&&!a||g===null||g===91||Le(g))return n(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Vt(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Le(g)||(a=!0),o++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),o++,d):d(g)}function p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),De(e,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return t(g)}}function R_(e,t,n){return e.check(bi,t,e.attempt(I_,t,n))}function M_(e){e.exit("gfmFootnoteDefinition")}function $_(e,t,n){const r=this;return De(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function F_(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(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",d,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",f,a]],h=a.parser.constructs.insideSpan.null;h&&Tt(p,p.length,0,Os(h,o.slice(c+1,l),a)),Tt(p,p.length,0,[["exit",f,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",d,a]]),Tt(o,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,d=this.events;let f=0;return p;function p(g){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const v=vr(c);if(g===126)return f>1?l(g):(o.consume(g),f++,h);if(f<2&&!n)return l(g);const S=o.exit("strikethroughSequenceTemporary"),y=vr(g);return S._open=!y||y===2&&!!v,S._close=!v||v===2&&!!y,a(g)}}}class L_{constructor(){this.map=[]}add(t,n,r){B_(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[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 B_(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 Z_(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 V_(){return{flow:{null:{name:"table",tokenize:U_,resolveAll:J_}}}}function U_(e,t,n){const r=this;let i=0,s=0,o;return a;function a(_){let T=r.events.length-1;for(;T>-1;){const O=r.events[T][1].type;if(O==="lineEnding"||O==="linePrefix")T--;else break}const I=T>-1?r.events[T][1].type:null,z=I==="tableHead"||I==="tableRow"?w:l;return z===w&&r.parser.lazy[r.now().line]?n(_):z(_)}function l(_){return e.enter("tableHead"),e.enter("tableRow"),c(_)}function c(_){return _===124||(o=!0,s+=1),d(_)}function d(_){return _===null?n(_):ye(_)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),h):n(_):Ae(_)?De(e,d,"whitespace")(_):(s+=1,o&&(o=!1,i+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),o=!0,d):(e.enter("data"),f(_)))}function f(_){return _===null||_===124||Le(_)?(e.exit("data"),d(_)):(e.consume(_),_===92?p:f)}function p(_){return _===92||_===124?(e.consume(_),f):f(_)}function h(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),o=!1,Ae(_)?De(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):g(_))}function g(_){return _===45||_===58?S(_):_===124?(o=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),v):C(_)}function v(_){return Ae(_)?De(e,S,"whitespace")(_):S(_)}function S(_){return _===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),y):_===45?(s+=1,y(_)):_===null||ye(_)?A(_):C(_)}function y(_){return _===45?(e.enter("tableDelimiterFiller"),j(_)):C(_)}function j(_){return _===45?(e.consume(_),j):_===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),m):(e.exit("tableDelimiterFiller"),m(_))}function m(_){return Ae(_)?De(e,A,"whitespace")(_):A(_)}function A(_){return _===124?g(_):_===null||ye(_)?!o||i!==s?C(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):C(_)}function C(_){return n(_)}function w(_){return e.enter("tableRow"),N(_)}function N(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),N):_===null||ye(_)?(e.exit("tableRow"),t(_)):Ae(_)?De(e,N,"whitespace")(_):(e.enter("data"),J(_))}function J(_){return _===null||_===124||Le(_)?(e.exit("data"),N(_)):(e.consume(_),_===92?D:J)}function D(_){return _===92||_===124?(e.consume(_),J):J(_)}}function J_(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,d,f;const p=new L_;for(;++n<e.length;){const h=e[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(Ru(p,t,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.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,o[2]===0&&(s[1]!==0&&(o[0]=o[1],f=zi(p,t,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=zi(p,t,s,i,void 0,f)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],f=zi(p,t,s,i,n,f)):o[1]!==0&&(f=zi(p,t,o,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Ru(p,t,l,c,d),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Z_(t.events,n))}return e}function zi(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Qn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Qn(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Qn(t.events,n[2]),d=Qn(t.events,n[3]),f={type:a,start:Object.assign({},c),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[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({},Qn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Ru(e,t,n,r,i){const s=[],o=Qn(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Qn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const H_={name:"tasklistCheck",tokenize:q_};function W_(){return{text:{91:H_}}}function q_(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 Le(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return ye(l)?t(l):Ae(l)?e.check({tokenize:G_},t,n)(l):n(l)}}function G_(e,t,n){return De(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Y_(e){return hp([w_(),A_(),F_(e),V_(),W_()])}const K_={};function X_(e){const t=this,n=e||K_,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Y_(n)),s.push(x_()),o.push(y_(n))}var ih="vercel.ai.error",Q_=Symbol.for(ih),Mu,$u,Xt=class sh extends($u=Error,Mu=Q_,$u){constructor({name:t,message:n,cause:r}){super(n),this[Mu]=!0,this.name=t,this.cause=r}static isInstance(t){return sh.hasMarker(t,ih)}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 oh(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var ah="AI_InvalidArgumentError",lh=`vercel.ai.error.${ah}`,ej=Symbol.for(lh),Fu,Lu,tj=class extends(Lu=Xt,Fu=ej,Lu){constructor({message:e,cause:t,argument:n}){super({name:ah,message:e,cause:t}),this[Fu]=!0,this.argument=n}static isInstance(e){return Xt.hasMarker(e,lh)}},uh="AI_JSONParseError",ch=`vercel.ai.error.${uh}`,nj=Symbol.for(ch),Bu,Zu,Vu=class extends(Zu=Xt,Bu=nj,Zu){constructor({text:e,cause:t}){super({name:uh,message:`JSON parsing failed: Text: ${e}.
38
+ Error message: ${oh(t)}`,cause:t}),this[Bu]=!0,this.text=e}static isInstance(e){return Xt.hasMarker(e,ch)}},dh="AI_TypeValidationError",fh=`vercel.ai.error.${dh}`,rj=Symbol.for(fh),Uu,Ju,wr=class Ko extends(Ju=Xt,Uu=rj,Ju){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:dh,message:`${i}: Value: ${JSON.stringify(t)}.
39
+ Error message: ${oh(n)}`,cause:n}),this[Uu]=!0,this.value=t,this.context=r}static isInstance(t){return Xt.hasMarker(t,fh)}static wrap({value:t,cause:n,context:r}){var i,s,o;return Ko.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)&&((o=n.context)==null?void 0:o.entityId)===(r==null?void 0:r.entityId)?n:new Ko({value:t,cause:n,context:r})}};function W(e,t,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);const c=o.prototype,d=Object.keys(c);for(let f=0;f<d.length;f++){const p=d[f];p in a||(a[p]=c[p].bind(a))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function o(a){var l;const c=n!=null&&n.Parent?new s:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class pr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ph extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const hh={};function vn(e){return hh}function mh(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 Xo(e,t){return typeof t=="bigint"?t.toString():t}function Ms(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ua(e){return e==null}function Ja(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function ij(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,o=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const Hu=Symbol("evaluating");function Pe(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Hu)return r===void 0&&(r=Hu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ln(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 Wu(e){return JSON.stringify(e)}function sj(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const gh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function li(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const oj=Ms(()=>{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 kr(e){if(li(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(li(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function xh(e){return kr(e)?{...e}:Array.isArray(e)?[...e]:e}const aj=new Set(["string","number","symbol"]);function Sr(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 lj(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const uj={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 cj(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 o={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=n.shape[a])}return Ln(this,"shape",o),o},checks:[]});return _n(e,s)}function dj(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 o={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return Ln(this,"shape",o),o},checks:[]});return _n(e,s)}function fj(e,t){if(!kr(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 o in t)if(Object.getOwnPropertyDescriptor(s,o)!==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 Ln(this,"shape",s),s}});return _n(e,i)}function pj(e,t){if(!kr(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 Ln(this,"shape",r),r}});return _n(e,n)}function hj(e,t){const n=Sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Ln(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return _n(e,n)}function mj(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 o=Sn(t._zod.def,{get shape(){const a=t._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=e?new e({type:"optional",innerType:a[c]}):a[c];return Ln(this,"shape",l),l},checks:[]});return _n(t,o)}function gj(e,t,n){const r=Sn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new e({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new e({type:"nonoptional",innerType:i[o]});return Ln(this,"shape",s),s}});return _n(t,r)}function rr(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 ir(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,o,a,l,c;const r={...e,path:e.path??[]};if(!e.message){const d=Oi((o=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,e))??Oi((a=t==null?void 0:t.error)==null?void 0:a.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 Ha(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ui(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const yh=(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,Xo,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bh=W("$ZodError",yh),vh=W("$ZodError",yh,{Parent:Error});function xj(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 yj(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(o=>r({issues:o}));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 o=n,a=0;for(;a<s.path.length;){const l=s.path[a];a===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(s))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(e),n}const Wa=e=>(t,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new pr;if(o.issues.length){const a=new((i==null?void 0:i.Err)??e)(o.issues.map(l=>wn(l,s,vn())));throw gh(a,i==null?void 0:i.callee),a}return o.value},qa=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??e)(o.issues.map(l=>wn(l,s,vn())));throw gh(a,i==null?void 0:i.callee),a}return o.value},$s=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 pr;return s.issues.length?{success:!1,error:new(e??bh)(s.issues.map(o=>wn(o,i,vn())))}:{success:!0,data:s.value}},bj=$s(vh),Fs=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(o=>wn(o,i,vn())))}:{success:!0,data:s.value}},vj=Fs(vh),wj=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Wa(e)(t,n,i)},kj=e=>(t,n,r)=>Wa(e)(t,n,r),Sj=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return qa(e)(t,n,i)},_j=e=>async(t,n,r)=>qa(e)(t,n,r),jj=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return $s(e)(t,n,i)},Nj=e=>(t,n,r)=>$s(e)(t,n,r),Ej=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Fs(e)(t,n,i)},Cj=e=>async(t,n,r)=>Fs(e)(t,n,r),Tj=/^[cC][^\s-]{8,}$/,Ij=/^[0-9a-z]+$/,Aj=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,zj=/^[0-9a-vA-V]{20}$/,Oj=/^[A-Za-z0-9]{27}$/,Pj=/^[a-zA-Z0-9_-]{21}$/,Dj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Rj=/^([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)$/,Mj=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$j="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Fj(){return new RegExp($j,"u")}const Lj=/^(?:(?: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])$/,Bj=/^(([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}|:))$/,Zj=/^((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])$/,Vj=/^(([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])$/,Uj=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wh=/^[A-Za-z0-9_-]*$/,Jj=/^\+[1-9]\d{6,14}$/,kh="(?:(?:\\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])))",Hj=new RegExp(`^${kh}$`);function Sh(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 Wj(e){return new RegExp(`^${Sh(e)}$`)}function qj(e){const t=Sh({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(`^${kh}T(?:${r})$`)}const Gj=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}$`)},Yj=/^-?\d+$/,_h=/^-?\d+(?:\.\d+)?$/,Kj=/^(?:true|false)$/i,Xj=/^null$/i,Qj=/^[^A-Z]*$/,eN=/^[^a-z]*$/,_t=W("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jh={number:"number",bigint:"bigint",object:"date"},Nh=W("$ZodCheckLessThan",(e,t)=>{_t.init(e,t);const n=jh[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})}}),Eh=W("$ZodCheckGreaterThan",(e,t)=>{_t.init(e,t);const n=jh[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})}}),tN=W("$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):ij(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})}}),nN=W("$ZodCheckNumberFormat",(e,t)=>{var o;_t.init(e,t),t.format=t.format||"float64";const n=(o=t.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=uj[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=i,l.maximum=s,n&&(l.pattern=Yj)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.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}):a.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&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),rN=W("$ZodCheckMaxLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Ua(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 o=Ha(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),iN=W("$ZodCheckMinLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Ua(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 o=Ha(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),sN=W("$ZodCheckLengthEquals",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Ua(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 o=Ha(i),a=s>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ls=W("$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=()=>{})}),oN=W("$ZodCheckRegex",(e,t)=>{Ls.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})}}),aN=W("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Qj),Ls.init(e,t)}),lN=W("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=eN),Ls.init(e,t)}),uN=W("$ZodCheckIncludes",(e,t)=>{_t.init(e,t);const n=Sr(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})}}),cN=W("$ZodCheckStartsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`^${Sr(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})}}),dN=W("$ZodCheckEndsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`.*${Sr(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})}}),fN=W("$ZodCheckOverwrite",(e,t)=>{_t.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class pN{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(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}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 hN={major:4,minor:3,patch:6},He=W("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hN;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const o of s._zod.onattach)o(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=(a,l,c)=>{let d=rr(a),f;for(const p of l){if(p._zod.def.when){if(!p._zod.def.when(a))continue}else if(d)continue;const h=a.issues.length,g=p._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new pr;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,a.issues.length!==h&&(d||(d=rr(a,h)))});else{if(a.issues.length===h)continue;d||(d=rr(a,h))}}return f?f.then(()=>a):a},o=(a,l,c)=>{if(rr(a))return a.aborted=!0,a;const d=s(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new pr;return d.then(f=>e._zod.parse(f,c))}return e._zod.parse(d,c)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const d=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,l)):o(d,a,l)}const c=e._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new pr;return c.then(d=>s(d,r,l))}return s(c,r,l)}}Pe(e,"~standard",()=>({validate:s=>{var o;try{const a=bj(e,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return vj(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}))}),Ga=W("$ZodString",(e,t)=>{var n;He.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Gj(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}}),Ke=W("$ZodStringFormat",(e,t)=>{Ls.init(e,t),Ga.init(e,t)}),mN=W("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Rj),Ke.init(e,t)}),gN=W("$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());Ke.init(e,t)}),xN=W("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mj),Ke.init(e,t)}),yN=W("$ZodURL",(e,t)=>{Ke.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})}}}),bN=W("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fj()),Ke.init(e,t)}),vN=W("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Pj),Ke.init(e,t)}),wN=W("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Tj),Ke.init(e,t)}),kN=W("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ij),Ke.init(e,t)}),SN=W("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Aj),Ke.init(e,t)}),_N=W("$ZodXID",(e,t)=>{t.pattern??(t.pattern=zj),Ke.init(e,t)}),jN=W("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Oj),Ke.init(e,t)}),NN=W("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=qj(t)),Ke.init(e,t)}),EN=W("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Hj),Ke.init(e,t)}),CN=W("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Wj(t)),Ke.init(e,t)}),TN=W("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Dj),Ke.init(e,t)}),IN=W("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Lj),Ke.init(e,t),e._zod.bag.format="ipv4"}),AN=W("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Bj),Ke.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})}}}),zN=W("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Zj),Ke.init(e,t)}),ON=W("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Vj),Ke.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 o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>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 Ch(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const PN=W("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Uj),Ke.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ch(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function DN(e){if(!wh.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ch(n)}const RN=W("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=wh),Ke.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{DN(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),MN=W("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jj),Ke.init(e,t)});function $N(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 FN=W("$ZodJWT",(e,t)=>{Ke.init(e,t),e._zod.check=n=>{$N(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Th=W("$ZodNumber",(e,t)=>{He.init(e,t),e._zod.pattern=e._zod.bag.pattern??_h,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}}),LN=W("$ZodNumberFormat",(e,t)=>{nN.init(e,t),Th.init(e,t)}),BN=W("$ZodBoolean",(e,t)=>{He.init(e,t),e._zod.pattern=Kj,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}}),ZN=W("$ZodNull",(e,t)=>{He.init(e,t),e._zod.pattern=Xj,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}}),VN=W("$ZodUnknown",(e,t)=>{He.init(e,t),e._zod.parse=n=>n}),UN=W("$ZodNever",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Gu(e,t,n){e.issues.length&&t.issues.push(...ir(n,e.issues)),t.value[n]=e.value}const JN=W("$ZodArray",(e,t)=>{He.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 o=0;o<i.length;o++){const a=i[o],l=t.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(c=>Gu(c,n,o))):Gu(l,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function ls(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...ir(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Ih(e){var r,i,s,o;const t=Object.keys(e.shape);for(const a of t)if(!((o=(s=(i=(r=e.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=lj(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ah(e,t,n,r,i,s){const o=[],a=i.keySet,l=i.catchall._zod,c=l.def.type,d=l.optout==="optional";for(const f in t){if(a.has(f))continue;if(c==="never"){o.push(f);continue}const p=l.run({value:t[f],issues:[]},r);p instanceof Promise?e.push(p.then(h=>ls(h,n,f,t,d))):ls(p,n,f,t,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const HN=W("$ZodObject",(e,t)=>{He.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=Ms(()=>Ih(t));Pe(e._zod,"propValues",()=>{const a=t.shape,l={};for(const c in a){const d=a[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=li,s=t.catchall;let o;e._zod.parse=(a,l)=>{o??(o=r.value);const c=a.value;if(!i(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};const d=[],f=o.shape;for(const p of o.keys){const h=f[p],g=h._zod.optout==="optional",v=h._zod.run({value:c[p],issues:[]},l);v instanceof Promise?d.push(v.then(S=>ls(S,a,p,c,g))):ls(v,a,p,c,g)}return s?Ah(d,c,a,l,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),WN=W("$ZodObjectJIT",(e,t)=>{HN.init(e,t);const n=e._zod.parse,r=Ms(()=>Ih(t)),i=p=>{var m;const h=new pN(["shape","payload","ctx"]),g=r.value,v=A=>{const C=Wu(A);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};h.write("const input = payload.value;");const S=Object.create(null);let y=0;for(const A of g.keys)S[A]=`key_${y++}`;h.write("const newResult = {};");for(const A of g.keys){const C=S[A],w=Wu(A),N=p[A],J=((m=N==null?void 0:N._zod)==null?void 0:m.optout)==="optional";h.write(`const ${C} = ${v(A)};`),J?h.write(`
42
+ if (${C}.issues.length) {
43
+ if (${w} in input) {
44
+ payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
45
+ ...iss,
46
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
47
+ })));
48
+ }
49
+ }
50
+
51
+ if (${C}.value === undefined) {
52
+ if (${w} in input) {
53
+ newResult[${w}] = undefined;
54
+ }
55
+ } else {
56
+ newResult[${w}] = ${C}.value;
57
+ }
58
+
59
+ `):h.write(`
60
+ if (${C}.issues.length) {
61
+ payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
62
+ ...iss,
63
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
64
+ })));
65
+ }
66
+
67
+ if (${C}.value === undefined) {
68
+ if (${w} in input) {
69
+ newResult[${w}] = undefined;
70
+ }
71
+ } else {
72
+ newResult[${w}] = ${C}.value;
73
+ }
74
+
75
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const j=h.compile();return(A,C)=>j(p,A,C)};let s;const o=li,a=!hh.jitless,c=a&&oj.value,d=t.catchall;let f;e._zod.parse=(p,h)=>{f??(f=r.value);const g=p.value;return o(g)?a&&c&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),d?Ah([],g,p,h,f,e):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});function Yu(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=>!rr(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(o=>wn(o,r,vn())))}),t)}const zh=W("$ZodUnion",(e,t)=>{He.init(e,t),Pe(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Pe(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Pe(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Pe(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=>Ja(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 o=!1;const a=[];for(const l of t.options){const c=l._zod.run({value:i.value,issues:[]},s);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(l=>Yu(l,i,e,s)):Yu(a,i,e,s)}}),qN=W("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,zh.init(e,t);const n=e._zod.parse;Pe(e._zod,"propValues",()=>{const i={};for(const s of t.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,l]of Object.entries(o)){i[a]||(i[a]=new Set);for(const c of l)i[a].add(c)}}return i});const r=Ms(()=>{var o;const i=t.options,s=new Map;for(const a of i){const l=(o=a._zod.propValues)==null?void 0:o[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const c of l){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,a)}}return s});e._zod.parse=(i,s)=>{const o=i.value;if(!li(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),i;const a=r.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),GN=W("$ZodIntersection",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([l,c])=>Ku(n,l,c)):Ku(n,s,o)}});function Qo(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(kr(e)&&kr(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 o=Qo(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.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],o=Qo(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ku(e,t,n){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&e.issues.push({...i,keys:s}),rr(e))return e;const o=Qo(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const YN=W("$ZodRecord",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!kr(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],o=t.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.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(...ir(c,f.issues)),n.value[c]=f.value})):(d.issues.length&&n.issues.push(...ir(c,d.issues)),n.value[c]=d.value)}let l;for(const c in i)a.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 a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let l=t.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&_h.test(a)&&l.issues.length){const f=t.keyType._zod.run({value:Number(a),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[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>wn(f,r,vn())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...ir(a,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...ir(a,d.issues)),n.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),KN=W("$ZodEnum",(e,t)=>{He.init(e,t);const n=mh(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>aj.has(typeof i)).map(i=>typeof i=="string"?Sr(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:e}),i}}),XN=W("$ZodLiteral",(e,t)=>{if(He.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"?Sr(r):r?Sr(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}}),QN=W("$ZodTransform",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ph(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new pr;return n.value=i,n}});function Xu(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Oh=W("$ZodOptional",(e,t)=>{He.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Pe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Pe(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ja(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=>Xu(s,n.value)):Xu(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),eE=W("$ZodExactOptional",(e,t)=>{Oh.init(e,t),Pe(e._zod,"values",()=>t.innerType._zod.values),Pe(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),tE=W("$ZodNullable",(e,t)=>{He.init(e,t),Pe(e._zod,"optin",()=>t.innerType._zod.optin),Pe(e._zod,"optout",()=>t.innerType._zod.optout),Pe(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ja(n.source)}|null)$`):void 0}),Pe(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)}),nE=W("$ZodDefault",(e,t)=>{He.init(e,t),e._zod.optin="optional",Pe(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=>Qu(s,t)):Qu(i,t)}});function Qu(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const rE=W("$ZodPrefault",(e,t)=>{He.init(e,t),e._zod.optin="optional",Pe(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))}),iE=W("$ZodNonOptional",(e,t)=>{He.init(e,t),Pe(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=>ec(s,e)):ec(i,e)}});function ec(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 sE=W("$ZodCatch",(e,t)=>{He.init(e,t),Pe(e._zod,"optin",()=>t.innerType._zod.optin),Pe(e._zod,"optout",()=>t.innerType._zod.optout),Pe(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(o=>wn(o,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)}}),oE=W("$ZodPipe",(e,t)=>{He.init(e,t),Pe(e._zod,"values",()=>t.in._zod.values),Pe(e._zod,"optin",()=>t.in._zod.optin),Pe(e._zod,"optout",()=>t.out._zod.optout),Pe(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(o=>Pi(o,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 aE=W("$ZodReadonly",(e,t)=>{He.init(e,t),Pe(e._zod,"propValues",()=>t.innerType._zod.propValues),Pe(e._zod,"values",()=>t.innerType._zod.values),Pe(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Pe(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(tc):tc(i)}});function tc(e){return e.value=Object.freeze(e.value),e}const lE=W("$ZodLazy",(e,t)=>{He.init(e,t),Pe(e._zod,"innerType",()=>t.getter()),Pe(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),Pe(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),Pe(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),Pe(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)}),uE=W("$ZodCustom",(e,t)=>{_t.init(e,t),He.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=>nc(s,n,r,e));nc(i,n,r,e)}});function nc(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(ui(i))}}var rc;class cE{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 dE(){return new cE}(rc=globalThis).__zod_globalRegistry??(rc.__zod_globalRegistry=dE());const Ur=globalThis.__zod_globalRegistry;function fE(e,t){return new e({type:"string",...fe(t)})}function pE(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...fe(t)})}function ic(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...fe(t)})}function hE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...fe(t)})}function mE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...fe(t)})}function gE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...fe(t)})}function xE(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...fe(t)})}function yE(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...fe(t)})}function bE(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...fe(t)})}function vE(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...fe(t)})}function wE(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...fe(t)})}function kE(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...fe(t)})}function SE(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...fe(t)})}function _E(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...fe(t)})}function jE(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...fe(t)})}function NE(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...fe(t)})}function EE(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...fe(t)})}function CE(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...fe(t)})}function TE(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...fe(t)})}function IE(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...fe(t)})}function AE(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...fe(t)})}function zE(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...fe(t)})}function OE(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...fe(t)})}function PE(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...fe(t)})}function DE(e,t){return new e({type:"string",format:"date",check:"string_format",...fe(t)})}function RE(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...fe(t)})}function ME(e,t){return new e({type:"string",format:"duration",check:"string_format",...fe(t)})}function $E(e,t){return new e({type:"number",checks:[],...fe(t)})}function FE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...fe(t)})}function LE(e,t){return new e({type:"boolean",...fe(t)})}function BE(e,t){return new e({type:"null",...fe(t)})}function ZE(e){return new e({type:"unknown"})}function VE(e,t){return new e({type:"never",...fe(t)})}function sc(e,t){return new Nh({check:"less_than",...fe(t),value:e,inclusive:!1})}function yo(e,t){return new Nh({check:"less_than",...fe(t),value:e,inclusive:!0})}function oc(e,t){return new Eh({check:"greater_than",...fe(t),value:e,inclusive:!1})}function bo(e,t){return new Eh({check:"greater_than",...fe(t),value:e,inclusive:!0})}function ac(e,t){return new tN({check:"multiple_of",...fe(t),value:e})}function Ph(e,t){return new rN({check:"max_length",...fe(t),maximum:e})}function us(e,t){return new iN({check:"min_length",...fe(t),minimum:e})}function Dh(e,t){return new sN({check:"length_equals",...fe(t),length:e})}function UE(e,t){return new oN({check:"string_format",format:"regex",...fe(t),pattern:e})}function JE(e){return new aN({check:"string_format",format:"lowercase",...fe(e)})}function HE(e){return new lN({check:"string_format",format:"uppercase",...fe(e)})}function WE(e,t){return new uN({check:"string_format",format:"includes",...fe(t),includes:e})}function qE(e,t){return new cN({check:"string_format",format:"starts_with",...fe(t),prefix:e})}function GE(e,t){return new dN({check:"string_format",format:"ends_with",...fe(t),suffix:e})}function Cr(e){return new fN({check:"overwrite",tx:e})}function YE(e){return Cr(t=>t.normalize(e))}function KE(){return Cr(e=>e.trim())}function XE(){return Cr(e=>e.toLowerCase())}function QE(){return Cr(e=>e.toUpperCase())}function eC(){return Cr(e=>sj(e))}function tC(e,t,n){return new e({type:"array",element:t,...fe(n)})}function nC(e,t,n){const r=fe(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function rC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...fe(n)})}function iC(e){const t=sC(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(ui(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(ui(i))}},e(n.value,n)));return t}function sC(e,t){const n=new _t({check:"custom",...fe(t)});return n._zod.check=e,n}function cs(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)??Ur,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 Ve(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 o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=(f=(d=e._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,p);else{const g=o.schema,v=t.processors[i.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);v(e,t,g,p)}const h=e._zod.parent;h&&(o.ref||(o.ref=h),Ve(h,t,p),t.seen.get(h).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(o.schema,l),t.io==="input"&&dt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ds(e,t){var o,a,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=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const p=r.get(f);if(p&&p!==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 S=(v=e.external.registry.get(d[0]))==null?void 0:v.id,y=e.external.uri??(m=>m);if(S)return{ref:y(S)};const j=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=j,{defId:j,ref:`${y("__shared")}#/${f}/${j}`}}if(d[1]===n)return{ref:"#"};const h=`#/${f}/`,g=d[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:h+g}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:p,defId:h}=i(d);f.def={...f.schema},h&&(f.defId=h);const g=f.schema;for(const v in g)delete g[v];g.$ref=p};if(e.cycles==="throw")for(const d of e.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.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 h=(l=e.external.registry.get(d[0]))==null?void 0:l.id;if(t!==d[0]&&h){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 fs(e,t){var o,a,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,p={...f},h=d.ref;if(d.ref=null,h){r(h);const v=e.seen.get(h),S=v.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(S)):Object.assign(f,S),Object.assign(f,p),c._zod.parent===h)for(const j in f)j==="$ref"||j==="allOf"||j in p||delete f[j];if(S.$ref&&v.def)for(const j in f)j==="$ref"||j==="allOf"||j in v.def&&JSON.stringify(f[j])===JSON.stringify(v.def[j])&&delete f[j]}const g=c._zod.parent;if(g&&g!==h){r(g);const v=e.seen.get(g);if(v!=null&&v.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const S in f)S==="$ref"||S==="allOf"||S in v.def&&JSON.stringify(f[S])===JSON.stringify(v.def[S])&&delete f[S]}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,(o=e.external)!=null&&o.uri){const c=(a=e.external.registry.get(t))==null?void 0:a.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:ps(t,"input",e.processors),output:ps(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function dt(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 dt(r.element,n);if(r.type==="set")return dt(r.valueType,n);if(r.type==="lazy")return dt(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 dt(r.innerType,n);if(r.type==="intersection")return dt(r.left,n)||dt(r.right,n);if(r.type==="record"||r.type==="map")return dt(r.keyType,n)||dt(r.valueType,n);if(r.type==="pipe")return dt(r.in,n)||dt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(dt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(dt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(dt(i,n))return!0;return!!(r.rest&&dt(r.rest,n))}return!1}const oC=(e,t={})=>n=>{const r=cs({...n,processors:t});return Ve(e,r),ds(r,e),fs(r,e)},ps=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=cs({...i??{},target:s,io:t,processors:n});return Ve(e,o),ds(o,e),fs(o,e)},aC={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Rh=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=aC[a]??a,i.format===""&&delete i.format,a==="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}))])}},Mh=(e,t,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.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 o=="number"&&(i.maximum=o,typeof c=="number"&&t.target!=="draft-04"&&(c<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},$h=(e,t,n,r)=>{n.type="boolean"},lC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},uC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Fh=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},cC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},dC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Lh=(e,t,n,r)=>{n.not={}},fC=(e,t,n,r)=>{},Bh=(e,t,n,r)=>{},pC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Zh=(e,t,n,r)=>{const i=e._zod.def,s=mh(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},Vh=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},hC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},mC=(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},gC=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:l}=e._zod.bag;o!==void 0&&(s.minLength=o),a!==void 0&&(s.maxLength=a),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)},xC=(e,t,n,r)=>{n.type="boolean"},Uh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},yC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Jh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},bC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},vC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Hh=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ve(s.element,t,{...r,path:[...r.path,"items"]})},Wh=(e,t,n,r)=>{var c;const i=n,s=e._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=Ve(o[d],t,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].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=Ve(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},qh=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,o=i.options.map((a,l)=>Ve(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=o:n.anyOf=o},Gh=(e,t,n,r)=>{const i=e._zod.def,s=Ve(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=Ve(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=l},wC=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((p,h)=>Ve(p,t,{...r,path:[...r.path,o,h]})),c=s.rest?Ve(s.rest,t,{...r,path:[...r.path,a,...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)},Yh=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(s.mode==="loose"&&l&&l.size>0){const d=Ve(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=Ve(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Ve(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},Kh=(e,t,n,r)=>{const i=e._zod.def,s=Ve(i.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Xh=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Qh=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},em=(e,t,n,r)=>{const i=e._zod.def;Ve(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)))},tm=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},nm=(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;Ve(s,t,r);const o=t.seen.get(e);o.ref=s},rm=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},kC=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Ya=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},im=(e,t,n,r)=>{const i=e._zod.innerType;Ve(i,t,r);const s=t.seen.get(e);s.ref=i},lc={string:Rh,number:Mh,boolean:$h,bigint:lC,symbol:uC,null:Fh,undefined:cC,void:dC,never:Lh,any:fC,unknown:Bh,date:pC,enum:Zh,literal:Vh,nan:hC,template_literal:mC,file:gC,success:xC,custom:Uh,function:yC,transform:Jh,map:bC,set:vC,array:Hh,object:Wh,union:qh,intersection:Gh,tuple:wC,record:Yh,nullable:Kh,nonoptional:Xh,default:Qh,prefault:em,catch:tm,pipe:nm,readonly:rm,promise:kC,optional:Ya,lazy:im};function SC(e,t){if("_idmap"in e){const r=e,i=cs({...t,processors:lc}),s={};for(const l of r._idmap.entries()){const[c,d]=l;Ve(d,i)}const o={},a={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=a;for(const l of r._idmap.entries()){const[c,d]=l;ds(i,d),o[c]=fs(i,d)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[l]:s}}return{schemas:o}}const n=cs({...t,processors:lc});return Ve(e,n),ds(n,e),fs(n,e)}const _C=W("ZodISODateTime",(e,t)=>{NN.init(e,t),Xe.init(e,t)});function jC(e){return PE(_C,e)}const NC=W("ZodISODate",(e,t)=>{EN.init(e,t),Xe.init(e,t)});function EC(e){return DE(NC,e)}const CC=W("ZodISOTime",(e,t)=>{CN.init(e,t),Xe.init(e,t)});function TC(e){return RE(CC,e)}const IC=W("ZodISODuration",(e,t)=>{TN.init(e,t),Xe.init(e,t)});function AC(e){return ME(IC,e)}const zC=(e,t)=>{bh.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>yj(e,n)},flatten:{value:n=>xj(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Xo,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Xo,2)}},isEmpty:{get(){return e.issues.length===0}}})},Pt=W("ZodError",zC,{Parent:Error}),OC=Wa(Pt),PC=qa(Pt),DC=$s(Pt),sm=Fs(Pt),RC=wj(Pt),MC=kj(Pt),$C=Sj(Pt),FC=_j(Pt),LC=jj(Pt),BC=Nj(Pt),ZC=Ej(Pt),VC=Cj(Pt),We=W("ZodType",(e,t)=>(He.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ps(e,"input"),output:ps(e,"output")}}),e.toJSONSchema=oC(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)=>OC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>DC(e,n,r),e.parseAsync=async(n,r)=>PC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>sm(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>RC(e,n,r),e.decode=(n,r)=>MC(e,n,r),e.encodeAsync=async(n,r)=>$C(e,n,r),e.decodeAsync=async(n,r)=>FC(e,n,r),e.safeEncode=(n,r)=>LC(e,n,r),e.safeDecode=(n,r)=>BC(e,n,r),e.safeEncodeAsync=async(n,r)=>ZC(e,n,r),e.safeDecodeAsync=async(n,r)=>VC(e,n,r),e.refine=(n,r)=>e.check(FT(n,r)),e.superRefine=n=>e.check(LT(n)),e.overwrite=n=>e.check(Cr(n)),e.optional=()=>dc(e),e.exactOptional=()=>jT(e),e.nullable=()=>fc(e),e.nullish=()=>dc(fc(e)),e.nonoptional=n=>AT(e,n),e.array=()=>Tr(e),e.or=n=>mt([e,n]),e.and=n=>bT(e,n),e.transform=n=>pc(e,ST(n)),e.default=n=>CT(e,n),e.prefault=n=>IT(e,n),e.catch=n=>OT(e,n),e.pipe=n=>pc(e,n),e.readonly=()=>RT(e),e.describe=n=>{const r=e.clone();return Ur.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Ur.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Ur.get(e);const r=e.clone();return Ur.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),om=W("_ZodString",(e,t)=>{Ga.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Rh(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(UE(...r)),e.includes=(...r)=>e.check(WE(...r)),e.startsWith=(...r)=>e.check(qE(...r)),e.endsWith=(...r)=>e.check(GE(...r)),e.min=(...r)=>e.check(us(...r)),e.max=(...r)=>e.check(Ph(...r)),e.length=(...r)=>e.check(Dh(...r)),e.nonempty=(...r)=>e.check(us(1,...r)),e.lowercase=r=>e.check(JE(r)),e.uppercase=r=>e.check(HE(r)),e.trim=()=>e.check(KE()),e.normalize=(...r)=>e.check(YE(...r)),e.toLowerCase=()=>e.check(XE()),e.toUpperCase=()=>e.check(QE()),e.slugify=()=>e.check(eC())}),UC=W("ZodString",(e,t)=>{Ga.init(e,t),om.init(e,t),e.email=n=>e.check(pE(JC,n)),e.url=n=>e.check(yE(HC,n)),e.jwt=n=>e.check(OE(aT,n)),e.emoji=n=>e.check(bE(WC,n)),e.guid=n=>e.check(ic(uc,n)),e.uuid=n=>e.check(hE(Di,n)),e.uuidv4=n=>e.check(mE(Di,n)),e.uuidv6=n=>e.check(gE(Di,n)),e.uuidv7=n=>e.check(xE(Di,n)),e.nanoid=n=>e.check(vE(qC,n)),e.guid=n=>e.check(ic(uc,n)),e.cuid=n=>e.check(wE(GC,n)),e.cuid2=n=>e.check(kE(YC,n)),e.ulid=n=>e.check(SE(KC,n)),e.base64=n=>e.check(IE(iT,n)),e.base64url=n=>e.check(AE(sT,n)),e.xid=n=>e.check(_E(XC,n)),e.ksuid=n=>e.check(jE(QC,n)),e.ipv4=n=>e.check(NE(eT,n)),e.ipv6=n=>e.check(EE(tT,n)),e.cidrv4=n=>e.check(CE(nT,n)),e.cidrv6=n=>e.check(TE(rT,n)),e.e164=n=>e.check(zE(oT,n)),e.datetime=n=>e.check(jC(n)),e.date=n=>e.check(EC(n)),e.time=n=>e.check(TC(n)),e.duration=n=>e.check(AC(n))});function ae(e){return fE(UC,e)}const Xe=W("ZodStringFormat",(e,t)=>{Ke.init(e,t),om.init(e,t)}),JC=W("ZodEmail",(e,t)=>{xN.init(e,t),Xe.init(e,t)}),uc=W("ZodGUID",(e,t)=>{mN.init(e,t),Xe.init(e,t)}),Di=W("ZodUUID",(e,t)=>{gN.init(e,t),Xe.init(e,t)}),HC=W("ZodURL",(e,t)=>{yN.init(e,t),Xe.init(e,t)}),WC=W("ZodEmoji",(e,t)=>{bN.init(e,t),Xe.init(e,t)}),qC=W("ZodNanoID",(e,t)=>{vN.init(e,t),Xe.init(e,t)}),GC=W("ZodCUID",(e,t)=>{wN.init(e,t),Xe.init(e,t)}),YC=W("ZodCUID2",(e,t)=>{kN.init(e,t),Xe.init(e,t)}),KC=W("ZodULID",(e,t)=>{SN.init(e,t),Xe.init(e,t)}),XC=W("ZodXID",(e,t)=>{_N.init(e,t),Xe.init(e,t)}),QC=W("ZodKSUID",(e,t)=>{jN.init(e,t),Xe.init(e,t)}),eT=W("ZodIPv4",(e,t)=>{IN.init(e,t),Xe.init(e,t)}),tT=W("ZodIPv6",(e,t)=>{AN.init(e,t),Xe.init(e,t)}),nT=W("ZodCIDRv4",(e,t)=>{zN.init(e,t),Xe.init(e,t)}),rT=W("ZodCIDRv6",(e,t)=>{ON.init(e,t),Xe.init(e,t)}),iT=W("ZodBase64",(e,t)=>{PN.init(e,t),Xe.init(e,t)}),sT=W("ZodBase64URL",(e,t)=>{RN.init(e,t),Xe.init(e,t)}),oT=W("ZodE164",(e,t)=>{MN.init(e,t),Xe.init(e,t)}),aT=W("ZodJWT",(e,t)=>{FN.init(e,t),Xe.init(e,t)}),am=W("ZodNumber",(e,t)=>{Th.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Mh(e,r,i),e.gt=(r,i)=>e.check(oc(r,i)),e.gte=(r,i)=>e.check(bo(r,i)),e.min=(r,i)=>e.check(bo(r,i)),e.lt=(r,i)=>e.check(sc(r,i)),e.lte=(r,i)=>e.check(yo(r,i)),e.max=(r,i)=>e.check(yo(r,i)),e.int=r=>e.check(cc(r)),e.safe=r=>e.check(cc(r)),e.positive=r=>e.check(oc(0,r)),e.nonnegative=r=>e.check(bo(0,r)),e.negative=r=>e.check(sc(0,r)),e.nonpositive=r=>e.check(yo(0,r)),e.multipleOf=(r,i)=>e.check(ac(r,i)),e.step=(r,i)=>e.check(ac(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 lT(e){return $E(am,e)}const uT=W("ZodNumberFormat",(e,t)=>{LN.init(e,t),am.init(e,t)});function cc(e){return FE(uT,e)}const cT=W("ZodBoolean",(e,t)=>{BN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$h(e,n,r)});function ft(e){return LE(cT,e)}const dT=W("ZodNull",(e,t)=>{ZN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Fh(e,n,r)});function fT(e){return BE(dT,e)}const pT=W("ZodUnknown",(e,t)=>{VN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bh()});function qt(){return ZE(pT)}const hT=W("ZodNever",(e,t)=>{UN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lh(e,n,r)});function lm(e){return VE(hT,e)}const mT=W("ZodArray",(e,t)=>{JN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(us(n,r)),e.nonempty=n=>e.check(us(1,n)),e.max=(n,r)=>e.check(Ph(n,r)),e.length=(n,r)=>e.check(Dh(n,r)),e.unwrap=()=>e.element});function Tr(e,t){return tC(mT,e,t)}const um=W("ZodObject",(e,t)=>{WN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wh(e,n,r,i),Pe(e,"shape",()=>t.shape),e.keyof=()=>dm(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:lm()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>fj(e,n),e.safeExtend=n=>pj(e,n),e.merge=n=>hj(e,n),e.pick=n=>cj(e,n),e.omit=n=>dj(e,n),e.partial=(...n)=>mj(fm,e,n[0]),e.required=(...n)=>gj(pm,e,n[0])});function Fe(e,t){const n={type:"object",shape:e??{},...fe(t)};return new um(n)}function Ue(e,t){return new um({type:"object",shape:e,catchall:lm(),...fe(t)})}const cm=W("ZodUnion",(e,t)=>{zh.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qh(e,n,r,i),e.options=t.options});function mt(e,t){return new cm({type:"union",options:e,...fe(t)})}const gT=W("ZodDiscriminatedUnion",(e,t)=>{cm.init(e,t),qN.init(e,t)});function xT(e,t,n){return new gT({type:"union",options:t,discriminator:e,...fe(n)})}const yT=W("ZodIntersection",(e,t)=>{GN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gh(e,n,r,i)});function bT(e,t){return new yT({type:"intersection",left:e,right:t})}const vT=W("ZodRecord",(e,t)=>{YN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yh(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function ci(e,t,n){return new vT({type:"record",keyType:e,valueType:t,...fe(n)})}const ea=W("ZodEnum",(e,t)=>{KN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Zh(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 o of r)if(n.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new ea({...t,checks:[],...fe(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new ea({...t,checks:[],...fe(i),entries:s})}});function dm(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ea({type:"enum",entries:n,...fe(t)})}const wT=W("ZodLiteral",(e,t)=>{XN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vh(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 wT({type:"literal",values:Array.isArray(e)?e:[e],...fe(t)})}const kT=W("ZodTransform",(e,t)=>{QN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ph(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(ui(s,n.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push(ui(o))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function ST(e){return new kT({type:"transform",transform:e})}const fm=W("ZodOptional",(e,t)=>{Oh.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ya(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new fm({type:"optional",innerType:e})}const _T=W("ZodExactOptional",(e,t)=>{eE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ya(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function jT(e){return new _T({type:"optional",innerType:e})}const NT=W("ZodNullable",(e,t)=>{tE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function fc(e){return new NT({type:"nullable",innerType:e})}const ET=W("ZodDefault",(e,t)=>{nE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function CT(e,t){return new ET({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():xh(t)}})}const TT=W("ZodPrefault",(e,t)=>{rE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>em(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function IT(e,t){return new TT({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():xh(t)}})}const pm=W("ZodNonOptional",(e,t)=>{iE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function AT(e,t){return new pm({type:"nonoptional",innerType:e,...fe(t)})}const zT=W("ZodCatch",(e,t)=>{sE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function OT(e,t){return new zT({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const PT=W("ZodPipe",(e,t)=>{oE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nm(e,n,r,i),e.in=t.in,e.out=t.out});function pc(e,t){return new PT({type:"pipe",in:e,out:t})}const DT=W("ZodReadonly",(e,t)=>{aE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rm(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function RT(e){return new DT({type:"readonly",innerType:e})}const MT=W("ZodLazy",(e,t)=>{lE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>im(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function $T(e){return new MT({type:"lazy",getter:e})}const Ka=W("ZodCustom",(e,t)=>{uE.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Uh(e,n)});function hm(e,t){return nC(Ka,e??(()=>!0),t)}function FT(e,t={}){return rC(Ka,e,t)}function LT(e){return iC(e)}function hs(e,t={}){const n=new Ka({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 di;(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 o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},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 o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},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(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(di||(di={}));var hc;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(hc||(hc={}));di.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);di.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 ms 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 o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof ms))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,di.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()}}ms.create=e=>new ms(e);var mc;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(mc||(mc={}));var ke;(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"})(ke||(ke={}));class gc 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 vo(e){}function BT(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=vo,onError:n=vo,onRetry:r=vo,onComment:i}=e;let s="",o=!0,a,l="",c="";function d(v){const S=o?v.replace(/^\xEF\xBB\xBF/,""):v,[y,j]=ZT(`${s}${S}`);for(const m of y)f(m);s=j,o=!1}function f(v){if(v===""){h();return}if(v.startsWith(":")){i&&i(v.slice(v.startsWith(": ")?2:1));return}const S=v.indexOf(":");if(S!==-1){const y=v.slice(0,S),j=v[S+1]===" "?2:1,m=v.slice(S+j);p(y,m,v);return}p(v,"",v)}function p(v,S,y){switch(v){case"event":c=S;break;case"data":l=`${l}${S}
78
+ `;break;case"id":a=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new gc(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:y}));break;default:n(new gc(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:S,line:y}));break}}function h(){l.length>0&&t({id:a,event:c||void 0,data:l.endsWith(`
79
+ `)?l.slice(0,-1):l}),a=void 0,l="",c=""}function g(v={}){s&&v.consume&&f(s),o=!0,a=void 0,l="",c="",s=""}return{feed:d,reset:g}}function ZT(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
80
+ `,r);let o=-1;if(i!==-1&&s!==-1?o=Math.min(i,s):i!==-1?i===e.length-1?o=-1:o=i:s!==-1&&(o=s),o===-1){n=e.slice(r);break}else{const a=e.slice(r,o);t.push(a),r=o+1,e[r-1]==="\r"&&e[r]===`
81
+ `&&r++}}return[t,n]}class VT extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=BT({onEvent:o=>{s.enqueue(o)},onError(o){t==="terminate"?s.error(o):typeof t=="function"&&t(o)},onRetry:n,onComment:r})},transform(s){i.feed(s)}})}}var wi=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,o=new Array(t);for(let a=0;a<t;a++)o[a]=n[Math.random()*s|0];return o.join("")};if(e==null)return i;if(n.includes(r))throw new tj({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},UT=wi();function Gn(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 JT=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,HT=/"(?: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 xc(e){const t=JSON.parse(e);return t===null||typeof t!="object"||JT.test(e)===!1&&HT.test(e)===!1?t:WT(t)}function WT(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 qT(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return xc(e)}try{return xc(e)}finally{Error.stackTraceLimit=t}}function Xa(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:Xa(e)}var GT=Symbol("Let zodToJsonSchema decide on which parser to use"),yc={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"},YT=e=>typeof e=="string"?{...yc,name:e}:{...yc,...e};function It(){return{}}function KT(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)!==ke.ZodAny&&(s.items=Me(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 XT(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 QT(){return{type:"boolean"}}function mm(e,t){return Me(e.type._def,t)}var eI=(e,t)=>Me(e.innerType._def,t);function gm(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>gm(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 tI(e)}}var tI=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 nI(e,t){return{...Me(e.innerType._def,t),default:e.defaultValue()}}function rI(e,t){return t.effectStrategy==="input"?Me(e.schema._def,t):It()}function iI(e){return{type:"string",enum:Array.from(e.values)}}var sI=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function oI(e,t){const n=[Me(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Me(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(sI(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:o,...a}=i;s=a}r.push(s)}}),r.length?{allOf:r}:void 0}function aI(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 wo=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:()=>(wo===void 0&&(wo=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),wo),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 xm(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":ct(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":ct(n,r.regex,r.message,t);break;case"cuid":ct(n,Dt.cuid,r.message,t);break;case"cuid2":ct(n,Dt.cuid2,r.message,t);break;case"startsWith":ct(n,RegExp(`^${ko(r.value,t)}`),r.message,t);break;case"endsWith":ct(n,RegExp(`${ko(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":{ct(n,RegExp(ko(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":ct(n,Dt.base64url,r.message,t);break;case"jwt":ct(n,Dt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ct(n,Dt.ipv4Cidr,r.message,t),r.version!=="v4"&&ct(n,Dt.ipv6Cidr,r.message,t);break}case"emoji":ct(n,Dt.emoji(),r.message,t);break;case"ulid":{ct(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":{ct(n,Dt.base64,r.message,t);break}}break}case"nanoid":ct(n,Dt.nanoid,r.message,t)}return n}function ko(e,t){return t.patternStrategy==="escape"?uI(e):e}var lI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function uI(e){let t="";for(let n=0;n<e.length;n++)lI.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 ct(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:bc(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=bc(t,r)}function bc(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="",o=!1,a=!1,l=!1;for(let c=0;c<i.length;c++){if(o){s+=i[c],o=!1;continue}if(r.i){if(a){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+=a?`${i[c]}\r
84
+ `:`[${i[c]}\r
85
+ ]`;continue}s+=i[c],i[c]==="\\"?o=!0:a&&i[c]==="]"?a=!1:!a&&i[c]==="["&&(a=!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 ym(e,t){var n,r,i,s,o,a;const l={type:"object",additionalProperties:(n=Me(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===ke.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...d}=xm(e.keyType._def,t);return{...l,propertyNames:d}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===ke.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((o=e.keyType)==null?void 0:o._def.typeName)===ke.ZodBranded&&e.keyType._def.type._def.typeName===ke.ZodString&&((a=e.keyType._def.type._def.checks)!=null&&a.length)){const{type:c,...d}=mm(e.keyType._def,t);return{...l,propertyNames:d}}}return l}function cI(e,t){if(t.mapStrategy==="record")return ym(e,t);const n=Me(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||It(),r=Me(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 dI(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 fI(){return{not:It()}}function pI(){return{type:"null"}}var ta={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hI(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in ta&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const o=ta[s._def.typeName];return o&&!i.includes(o)?[...i,o]: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 o=typeof s._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];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,o,a)=>a.indexOf(s)===o);return{type:i.length>1?i:i[0],enum:n.reduce((s,o)=>s.includes(o._def.value)?s:[...s,o._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 mI(e,t)}var mI=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Me(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 gI(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[ta[e.innerType._def.typeName],"null"]};const n=Me(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function xI(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 yI(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const o in i){let a=i[o];if(a===void 0||a._def===void 0)continue;const l=vI(a),c=Me(a._def,{...t,currentPath:[...t.currentPath,"properties",o],propertyPath:[...t.currentPath,"properties",o]});c!==void 0&&(n.properties[o]=c,l||r.push(o))}r.length&&(n.required=r);const s=bI(e,t);return s!==void 0&&(n.additionalProperties=s),n}function bI(e,t){if(e.catchall._def.typeName!=="ZodNever")return Me(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 vI(e){try{return e.isOptional()}catch{return!0}}var wI=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Me(e.innerType._def,t);const r=Me(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:It()},r]}:It()},kI=(e,t)=>{if(t.pipeStrategy==="input")return Me(e.in._def,t);if(t.pipeStrategy==="output")return Me(e.out._def,t);const n=Me(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Me(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function SI(e,t){return Me(e.type._def,t)}function _I(e,t){const r={type:"array",uniqueItems:!0,items:Me(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 jI(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Me(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Me(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Me(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function NI(){return{not:It()}}function EI(){return It()}var CI=(e,t)=>Me(e.innerType._def,t),TI=(e,t,n)=>{switch(t){case ke.ZodString:return xm(e,n);case ke.ZodNumber:return xI(e);case ke.ZodObject:return yI(e,n);case ke.ZodBigInt:return XT(e);case ke.ZodBoolean:return QT();case ke.ZodDate:return gm(e,n);case ke.ZodUndefined:return NI();case ke.ZodNull:return pI();case ke.ZodArray:return KT(e,n);case ke.ZodUnion:case ke.ZodDiscriminatedUnion:return hI(e,n);case ke.ZodIntersection:return oI(e,n);case ke.ZodTuple:return jI(e,n);case ke.ZodRecord:return ym(e,n);case ke.ZodLiteral:return aI(e);case ke.ZodEnum:return iI(e);case ke.ZodNativeEnum:return dI(e);case ke.ZodNullable:return gI(e,n);case ke.ZodOptional:return wI(e,n);case ke.ZodMap:return cI(e,n);case ke.ZodSet:return _I(e,n);case ke.ZodLazy:return()=>e.getter()._def;case ke.ZodPromise:return SI(e,n);case ke.ZodNaN:case ke.ZodNever:return fI();case ke.ZodEffects:return rI(e,n);case ke.ZodAny:return It();case ke.ZodUnknown:return EI();case ke.ZodDefault:return nI(e,n);case ke.ZodBranded:return mm(e,n);case ke.ZodReadonly:return CI(e,n);case ke.ZodCatch:return eI(e,n);case ke.ZodPipeline:return kI(e,n);case ke.ZodFunction:case ke.ZodVoid:case ke.ZodSymbol:return;default:return(r=>{})()}},II=(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 Me(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!==GT)return l}if(i&&!n){const l=AI(i,t);if(l!==void 0)return l}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const o=TI(e,e.typeName,t),a=typeof o=="function"?Me(o(),t):o;if(a&&zI(e,t,a),t.postProcess){const l=t.postProcess(a,e,t);return s.jsonSchema=a,l}return s.jsonSchema=a,a}var AI=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:II(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}},zI=(e,t,n)=>(e.description&&(n.description=e.description),n),OI=e=>{const t=YT(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}]))}},PI=(e,t)=>{var n;const r=OI(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[d,f])=>{var p;return{...c,[d]:(p=Me(f._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?p:It()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,o=(n=Me(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:It(),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(o.title=a);const l=s===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:o}};return l.$schema="http://json-schema.org/draft-07/schema#",l},na=Symbol.for("vercel.ai.schema");function DI(e){let t;return()=>(t==null&&(t=e()),t)}function Bs(e,{validate:t}={}){return{[na]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function RI(e){return typeof e=="object"&&e!==null&&na in e&&e[na]===!0&&"jsonSchema"in e&&"validate"in e}function Qa(e){return e==null?Bs({properties:{},additionalProperties:!1}):RI(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?bm(e):MI(e):e()}function MI(e){return Bs(()=>Xa(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 wr({value:t,cause:n.issues})}}})}function $I(e,t){var n;const r=(n=void 0)!=null?n:!1;return Bs(()=>PI(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 FI(e,t){var n;const r=(n=void 0)!=null?n:!1;return Bs(()=>Xa(SC(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await sm(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function LI(e){return"_zod"in e}function bm(e,t){return LI(e)?FI(e):$I(e)}async function vc({value:e,schema:t,context:n}){const r=await fi({value:e,schema:t,context:n});if(!r.success)throw wr.wrap({value:e,cause:r.error,context:n});return r.value}async function fi({value:e,schema:t,context:n}){const r=Qa(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:wr.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:wr.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function $n({text:e,schema:t}){try{const n=qT(e);return t==null?{success:!0,value:n,rawValue:n}:await fi({value:n,schema:t})}catch(n){return{success:!1,error:Vu.isInstance(n)?n:new Vu({text:e,cause:n}),rawValue:void 0}}}function BI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new VT).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await $n({text:n,schema:t}))}}))}async function pn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var ZI=Object.defineProperty,VI=(e,t)=>{for(var n in t)ZI(e,n,{get:t[n],enumerable:!0})},vm="AI_NoObjectGeneratedError",wm=`vercel.ai.error.${vm}`,UI=Symbol.for(wm),km,gn=class extends Xt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:vm,message:e,cause:t}),this[km]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Xt.hasMarker(e,wm)}};km=UI;var Sm="AI_UIMessageStreamError",_m=`vercel.ai.error.${Sm}`,JI=Symbol.for(_m),jm,Yn=class extends Xt{constructor({chunkType:e,chunkId:t,message:n}){super({name:Sm,message:n}),this[jm]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Xt.hasMarker(e,_m)}};jm=JI;var Nm=mt([ae(),hs(Uint8Array),hs(ArrayBuffer),hm(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),pi=$T(()=>mt([fT(),ae(),lT(),ft(),ci(ae(),pi.optional()),Tr(pi)])),Ie=ci(ae(),ci(ae(),pi.optional())),Em=Fe({type:be("text"),text:ae(),providerOptions:Ie.optional()}),HI=Fe({type:be("image"),image:mt([Nm,hs(URL)]),mediaType:ae().optional(),providerOptions:Ie.optional()}),Cm=Fe({type:be("file"),data:mt([Nm,hs(URL)]),filename:ae().optional(),mediaType:ae(),providerOptions:Ie.optional()}),WI=Fe({type:be("reasoning"),text:ae(),providerOptions:Ie.optional()}),qI=Fe({type:be("tool-call"),toolCallId:ae(),toolName:ae(),input:qt(),providerOptions:Ie.optional(),providerExecuted:ft().optional()}),GI=xT("type",[Fe({type:be("text"),value:ae(),providerOptions:Ie.optional()}),Fe({type:be("json"),value:pi,providerOptions:Ie.optional()}),Fe({type:be("execution-denied"),reason:ae().optional(),providerOptions:Ie.optional()}),Fe({type:be("error-text"),value:ae(),providerOptions:Ie.optional()}),Fe({type:be("error-json"),value:pi,providerOptions:Ie.optional()}),Fe({type:be("content"),value:Tr(mt([Fe({type:be("text"),text:ae(),providerOptions:Ie.optional()}),Fe({type:be("media"),data:ae(),mediaType:ae()}),Fe({type:be("file-data"),data:ae(),mediaType:ae(),filename:ae().optional(),providerOptions:Ie.optional()}),Fe({type:be("file-url"),url:ae(),providerOptions:Ie.optional()}),Fe({type:be("file-id"),fileId:mt([ae(),ci(ae(),ae())]),providerOptions:Ie.optional()}),Fe({type:be("image-data"),data:ae(),mediaType:ae(),providerOptions:Ie.optional()}),Fe({type:be("image-url"),url:ae(),providerOptions:Ie.optional()}),Fe({type:be("image-file-id"),fileId:mt([ae(),ci(ae(),ae())]),providerOptions:Ie.optional()}),Fe({type:be("custom"),providerOptions:Ie.optional()})]))})]),Tm=Fe({type:be("tool-result"),toolCallId:ae(),toolName:ae(),output:GI,providerOptions:Ie.optional()}),YI=Fe({type:be("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),KI=Fe({type:be("tool-approval-response"),approvalId:ae(),approved:ft(),reason:ae().optional()}),XI=Fe({role:be("system"),content:ae(),providerOptions:Ie.optional()}),QI=Fe({role:be("user"),content:mt([ae(),Tr(mt([Em,HI,Cm]))]),providerOptions:Ie.optional()}),eA=Fe({role:be("assistant"),content:mt([ae(),Tr(mt([Em,Cm,WI,qI,Tm,YI]))]),providerOptions:Ie.optional()}),tA=Fe({role:be("tool"),content:Tr(mt([Tm,KI])),providerOptions:Ie.optional()});mt([XI,QI,eA,tA]);function Im(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,o=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),a=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);o&&a?n[r]=Im(s,i):n[r]=i}return n}var nA={};VI(nA,{array:()=>oA,choice:()=>aA,json:()=>lA,object:()=>sA,text:()=>iA});function rA(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 o(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"&&o(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"&&o(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"&&o(c,l)):n=l;break}}}let a=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{a+='"';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":{a+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{a+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?a+="true".slice(d.length):"false".startsWith(d)?a+="false".slice(d.length):"null".startsWith(d)&&(a+="null".slice(d.length))}}return a}async function ki(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await $n({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await $n({text:rA(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var iA=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),sA=({schema:e,name:t,description:n})=>{const r=Qa(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 o=await $n({text:i});if(!o.success)throw new gn({message:"No object generated: could not parse the response.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=await fi({value:o.value,schema:r});if(!a.success)throw new gn({message:"No object generated: response did not match schema.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});return a.value},async parsePartialOutput({text:i}){const s=await ki(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},oA=({element:e,name:t,description:n})=>{const r=Qa(e);return{name:"array",responseFormat:pn(r.jsonSchema).then(i=>{const{$schema:s,...o}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:o}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},s){const o=await $n({text:i});if(!o.success)throw new gn({message:"No object generated: could not parse the response.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=o.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))throw new gn({message:"No object generated: response did not match schema.",cause:new wr({value:a,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 a.elements){const c=await fi({value:l,schema:r});if(!c.success)throw new gn({message:"No object generated: response did not match schema.",cause:c.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason})}return a.elements},async parsePartialOutput({text:i}){const s=await ki(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const o=s.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))return;const a=s.state==="repaired-parse"&&o.elements.length>0?o.elements.slice(0,-1):o.elements,l=[];for(const c of a){const d=await fi({value:c,schema:r});d.success&&l.push(d.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},o){if(s!=null)for(;i<s.length;i++)o.enqueue(s[i])}})}}},aA=({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 $n({text:r});if(!s.success)throw new gn({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const o=s.value;if(o==null||typeof o!="object"||!("result"in o)||typeof o.result!="string"||!e.includes(o.result))throw new gn({message:"No object generated: response did not match schema.",cause:new wr({value:o,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return o.result},async parsePartialOutput({text:r}){const i=await ki(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 o=e.filter(a=>a.startsWith(s.result));return i.state==="successful-parse"?o.includes(s.result)?{partial:s.result}:void 0:o.length===1?{partial:o[0]}:void 0}}},createElementStreamTransform(){}}),lA=({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 $n({text:n});if(!i.success)throw new gn({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 ki(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(){}});wi({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 uA=DI(()=>bm(mt([Ue({type:be("text-start"),id:ae(),providerMetadata:Ie.optional()}),Ue({type:be("text-delta"),id:ae(),delta:ae(),providerMetadata:Ie.optional()}),Ue({type:be("text-end"),id:ae(),providerMetadata:Ie.optional()}),Ue({type:be("error"),errorText:ae()}),Ue({type:be("tool-input-start"),toolCallId:ae(),toolName:ae(),providerExecuted:ft().optional(),providerMetadata:Ie.optional(),dynamic:ft().optional(),title:ae().optional()}),Ue({type:be("tool-input-delta"),toolCallId:ae(),inputTextDelta:ae()}),Ue({type:be("tool-input-available"),toolCallId:ae(),toolName:ae(),input:qt(),providerExecuted:ft().optional(),providerMetadata:Ie.optional(),dynamic:ft().optional(),title:ae().optional()}),Ue({type:be("tool-input-error"),toolCallId:ae(),toolName:ae(),input:qt(),providerExecuted:ft().optional(),providerMetadata:Ie.optional(),dynamic:ft().optional(),errorText:ae(),title:ae().optional()}),Ue({type:be("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),Ue({type:be("tool-output-available"),toolCallId:ae(),output:qt(),providerExecuted:ft().optional(),providerMetadata:Ie.optional(),dynamic:ft().optional(),preliminary:ft().optional()}),Ue({type:be("tool-output-error"),toolCallId:ae(),errorText:ae(),providerExecuted:ft().optional(),providerMetadata:Ie.optional(),dynamic:ft().optional()}),Ue({type:be("tool-output-denied"),toolCallId:ae()}),Ue({type:be("reasoning-start"),id:ae(),providerMetadata:Ie.optional()}),Ue({type:be("reasoning-delta"),id:ae(),delta:ae(),providerMetadata:Ie.optional()}),Ue({type:be("reasoning-end"),id:ae(),providerMetadata:Ie.optional()}),Ue({type:be("source-url"),sourceId:ae(),url:ae(),title:ae().optional(),providerMetadata:Ie.optional()}),Ue({type:be("source-document"),sourceId:ae(),mediaType:ae(),title:ae(),filename:ae().optional(),providerMetadata:Ie.optional()}),Ue({type:be("file"),url:ae(),mediaType:ae(),providerMetadata:Ie.optional()}),Ue({type:hm(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:ae().optional(),data:qt(),transient:ft().optional()}),Ue({type:be("start-step")}),Ue({type:be("finish-step")}),Ue({type:be("start"),messageId:ae().optional(),messageMetadata:qt().optional()}),Ue({type:be("finish"),finishReason:dm(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:qt().optional()}),Ue({type:be("abort"),reason:ae().optional()}),Ue({type:be("message-metadata"),messageMetadata:qt()})])));function cA(e){return e.type.startsWith("data-")}function ra(e){return e.type.startsWith("tool-")}function dA(e){return e.type==="dynamic-tool"}function gs(e){return ra(e)||dA(e)}function wc(e){return e.type.split("-").slice(1).join("-")}function fA({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 pA({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:o}){return e.pipeThrough(new TransformStream({async transform(a,l){await r(async({state:c,write:d})=>{var f,p,h,g;function v(m){const C=c.message.parts.filter(gs).find(w=>w.toolCallId===m);if(C==null)throw new Yn({chunkType:"tool-invocation",chunkId:m,message:`No tool invocation found for tool call ID "${m}".`});return C}function S(m){var A;const C=c.message.parts.find(J=>ra(J)&&J.toolCallId===m.toolCallId),w=m,N=C;if(C!=null){C.state=m.state,N.input=w.input,N.output=w.output,N.errorText=w.errorText,N.rawInput=w.rawInput,N.preliminary=w.preliminary,m.title!==void 0&&(N.title=m.title),N.providerExecuted=(A=w.providerExecuted)!=null?A:C.providerExecuted;const J=w.providerMetadata;if(J!=null)if(m.state==="output-available"||m.state==="output-error"){const D=C;D.resultProviderMetadata=J}else C.callProviderMetadata=J}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 y(m){var A,C;const w=c.message.parts.find(D=>D.type==="dynamic-tool"&&D.toolCallId===m.toolCallId),N=m,J=w;if(w!=null){w.state=m.state,J.toolName=m.toolName,J.input=N.input,J.output=N.output,J.errorText=N.errorText,J.rawInput=(A=N.rawInput)!=null?A:J.rawInput,J.preliminary=N.preliminary,m.title!==void 0&&(J.title=m.title),J.providerExecuted=(C=N.providerExecuted)!=null?C:w.providerExecuted;const D=N.providerMetadata;if(D!=null)if(m.state==="output-available"||m.state==="output-error"){const _=w;_.resultProviderMetadata=D}else w.callProviderMetadata=D}else c.message.parts.push({type:"dynamic-tool",toolName:m.toolName,toolCallId:m.toolCallId,state:m.state,input:N.input,output:N.output,errorText:N.errorText,preliminary:N.preliminary,providerExecuted:N.providerExecuted,title:m.title,...N.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:N.providerMetadata}:{},...N.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:N.providerMetadata}:{}})}async function j(m){if(m!=null){const A=c.message.metadata!=null?Im(c.message.metadata,m):m;t!=null&&await vc({value:A,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=A}}switch(a.type){case"text-start":{const m={type:"text",text:"",providerMetadata:a.providerMetadata,state:"streaming"};c.activeTextParts[a.id]=m,c.message.parts.push(m),d();break}case"text-delta":{const m=c.activeTextParts[a.id];if(m==null)throw new Yn({chunkType:"text-delta",chunkId:a.id,message:`Received text-delta for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});m.text+=a.delta,m.providerMetadata=(f=a.providerMetadata)!=null?f:m.providerMetadata,d();break}case"text-end":{const m=c.activeTextParts[a.id];if(m==null)throw new Yn({chunkType:"text-end",chunkId:a.id,message:`Received text-end for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});m.state="done",m.providerMetadata=(p=a.providerMetadata)!=null?p:m.providerMetadata,delete c.activeTextParts[a.id],d();break}case"reasoning-start":{const m={type:"reasoning",text:"",providerMetadata:a.providerMetadata,state:"streaming"};c.activeReasoningParts[a.id]=m,c.message.parts.push(m),d();break}case"reasoning-delta":{const m=c.activeReasoningParts[a.id];if(m==null)throw new Yn({chunkType:"reasoning-delta",chunkId:a.id,message:`Received reasoning-delta for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});m.text+=a.delta,m.providerMetadata=(h=a.providerMetadata)!=null?h:m.providerMetadata,d();break}case"reasoning-end":{const m=c.activeReasoningParts[a.id];if(m==null)throw new Yn({chunkType:"reasoning-end",chunkId:a.id,message:`Received reasoning-end for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});m.providerMetadata=(g=a.providerMetadata)!=null?g:m.providerMetadata,m.state="done",delete c.activeReasoningParts[a.id],d();break}case"file":{c.message.parts.push({type:"file",mediaType:a.mediaType,url:a.url,...a.providerMetadata!=null?{providerMetadata:a.providerMetadata}:{}}),d();break}case"source-url":{c.message.parts.push({type:"source-url",sourceId:a.sourceId,url:a.url,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"source-document":{c.message.parts.push({type:"source-document",sourceId:a.sourceId,mediaType:a.mediaType,title:a.title,filename:a.filename,providerMetadata:a.providerMetadata}),d();break}case"tool-input-start":{const m=c.message.parts.filter(ra);c.partialToolCalls[a.toolCallId]={text:"",toolName:a.toolName,index:m.length,dynamic:a.dynamic,title:a.title},a.dynamic?y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}):S({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"tool-input-delta":{const m=c.partialToolCalls[a.toolCallId];if(m==null)throw new Yn({chunkType:"tool-input-delta",chunkId:a.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${a.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});m.text+=a.inputTextDelta;const{value:A}=await ki(m.text);m.dynamic?y({toolCallId:a.toolCallId,toolName:m.toolName,state:"input-streaming",input:A,title:m.title}):S({toolCallId:a.toolCallId,toolName:m.toolName,state:"input-streaming",input:A,title:m.title}),d();break}case"tool-input-available":{a.dynamic?y({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}):S({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}),d(),s&&!a.providerExecuted&&await s({toolCall:a});break}case"tool-input-error":{const m=c.message.parts.filter(gs).find(C=>C.toolCallId===a.toolCallId);(m!=null?m.type==="dynamic-tool":!!a.dynamic)?y({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):S({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:void 0,rawInput:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),d();break}case"tool-approval-request":{const m=v(a.toolCallId);m.state="approval-requested",m.approval={id:a.approvalId},d();break}case"tool-output-denied":{const m=v(a.toolCallId);m.state="output-denied",d();break}case"tool-output-available":{const m=v(a.toolCallId);m.type==="dynamic-tool"?y({toolCallId:a.toolCallId,toolName:m.toolName,state:"output-available",input:m.input,output:a.output,preliminary:a.preliminary,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:m.title}):S({toolCallId:a.toolCallId,toolName:wc(m),state:"output-available",input:m.input,output:a.output,providerExecuted:a.providerExecuted,preliminary:a.preliminary,providerMetadata:a.providerMetadata,title:m.title}),d();break}case"tool-output-error":{const m=v(a.toolCallId);m.type==="dynamic-tool"?y({toolCallId:a.toolCallId,toolName:m.toolName,state:"output-error",input:m.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:m.title}):S({toolCallId:a.toolCallId,toolName:wc(m),state:"output-error",input:m.input,rawInput:m.rawInput,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.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":{a.messageId!=null&&(c.message.id=a.messageId),await j(a.messageMetadata),(a.messageId!=null||a.messageMetadata!=null)&&d();break}case"finish":{a.finishReason!=null&&(c.finishReason=a.finishReason),await j(a.messageMetadata),a.messageMetadata!=null&&d();break}case"message-metadata":{await j(a.messageMetadata),a.messageMetadata!=null&&d();break}case"error":{i==null||i(new Error(a.errorText));break}default:if(cA(a)){if((n==null?void 0:n[a.type])!=null){const C=c.message.parts.findIndex(N=>"id"in N&&"data"in N&&N.id===a.id&&N.type===a.type),w=C>=0?C:c.message.parts.length;await vc({value:a.data,schema:n[a.type],context:{field:`message.parts[${w}].data`,entityName:a.type,entityId:a.id}})}const m=a;if(m.transient){o==null||o(m);break}const A=m.id!=null?c.message.parts.find(C=>m.type===C.type&&m.id===C.id):void 0;A!=null?A.data=m.data:c.message.parts.push(m),o==null||o(m),d()}}l.enqueue(a)})}}))}async function hA({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()}}wi({prefix:"aitxt",size:24});wi({prefix:"aiobj",size:24});var mA=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()})}};wi({prefix:"aiobj",size:24});async function gA(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,o)=>{const a=new FileReader;a.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},a.onerror=l=>o(l),a.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var xA=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){var n,r,i,s,o;const a=await pn(this.body),l=await pn(this.headers),c=await pn(this.credentials),d={...Gn(l),...Gn(t.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...a,...t.body},headers:d,credentials:c,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),p=(r=f==null?void 0:f.api)!=null?r:this.api,h=(f==null?void 0:f.headers)!==void 0?Gn(f.headers):d,g=(f==null?void 0:f.body)!==void 0?f.body:{...a,...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,y=await((s=this.fetch)!=null?s:globalThis.fetch)(p,{method:"POST",headers:{"Content-Type":"application/json",...h},body:JSON.stringify(g),credentials:v,signal:e});if(!y.ok)throw new Error((o=await y.text())!=null?o:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,n,r,i,s;const o=await pn(this.body),a=await pn(this.headers),l=await pn(this.credentials),c={...Gn(a),...Gn(e.headers)},d=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...o,...e.body},headers:c,credentials:l,requestMetadata:e.metadata})),f=(n=d==null?void 0:d.api)!=null?n:`${this.api}/${e.chatId}/stream`,p=(d==null?void 0:d.headers)!==void 0?Gn(d.headers):c,h=(r=d==null?void 0:d.credentials)!=null?r:l,v=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"GET",headers:p,credentials:h});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)}},Am=class extends xA{constructor(e={}){super(e)}processResponseStream(e){return BI({stream:e,schema:uA}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},yA=class{constructor({generateId:e=UT,id:t=e(),transport:n=new Am,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:o,onToolCall:a,onFinish:l,onData:c,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new mA,this.sendMessage=async(f,p)=>{var h,g,v,S;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...p});return}let y;if("text"in f||"files"in f?y={parts:[...Array.isArray(f.files)?f.files:await gA(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:y=f,f.messageId!=null){const j=this.state.messages.findIndex(m=>m.id===f.messageId);if(j===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[j].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,j+1),this.state.replaceMessage(j,{...y,id:f.messageId,role:(g=y.role)!=null?g:"user",metadata:f.metadata})}else this.state.pushMessage({...y,id:(v=y.id)!=null?v:this.generateId(),role:(S=y.role)!=null?S:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...p})},this.regenerate=async({messageId:f,...p}={})=>{const h=f==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===f);if(h===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...p})},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:p,reason:h,options:g})=>this.jobExecutor.run(async()=>{const v=this.state.messages,S=v[v.length-1],y=j=>gs(j)&&j.state==="approval-requested"&&j.approval.id===f?{...j,state:"approval-responded",approval:{id:f,approved:p,reason:h}}:j;this.state.replaceMessage(v.length-1,{...S,parts:S.parts.map(y)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(y)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(j=>{var m;j&&this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...g})})}),this.addToolOutput=async({state:f="output-available",toolCallId:p,output:h,errorText:g,options:v})=>this.jobExecutor.run(async()=>{const S=this.state.messages,y=S[S.length-1],j=m=>gs(m)&&m.toolCallId===p?{...m,state:f,output:h,errorText:g}:m;this.state.replaceMessage(S.length-1,{...y,parts:y.parts.map(j)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(j)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(m=>{var A;m&&this.makeRequest({trigger:"submit-message",messageId:(A=this.lastMessage)==null?void 0:A.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=o,this.onToolCall=a,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,o,a;let l;if(e==="resume-stream")try{const h=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(h==null)return;l=h}catch(h){this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h});return}this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let d=!1,f=!1,p=!1;try{const h={state:fA({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=h;let g;e==="resume-stream"?g=l:g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});const v=S=>this.jobExecutor.run(()=>S({state:h.state,write:()=>{var y;this.setStatus({status:"streaming"}),h.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await hA({stream:pA({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:S=>{throw S}}),onError:S=>{throw S}}),this.setStatus({status:"ready"})}catch(h){if(d||h.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;p=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(o=this.onFinish)==null||o.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:p,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}!p&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(a=this.lastMessage)==null?void 0:a.id,metadata:t,headers:n,body:r})}},So,kc;function bA(){if(kc)return So;kc=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(...o){clearTimeout(r);const a=Date.now(),l=a-i,c=n-l;c<=0?(i=a,t.apply(this,o)):r=setTimeout(()=>{i=Date.now(),t.apply(this,o)},c)}}return So=e,So}var vA=bA();const wA=la(vA);var zm=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Je=(e,t,n)=>(zm(e,t,"read from private field"),n?n.call(e):t.get(e)),Ht=(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)=>(zm(e,t,"write to private field"),t.set(e,n),n);function kA(e,t){return t!=null?wA(e,t):e}var At,Zi,Vi,Jr,Hr,Wr,er,ia,sa,SA=class{constructor(e=[]){Ht(this,At,void 0),Ht(this,Zi,"ready"),Ht(this,Vi,void 0),Ht(this,Jr,new Set),Ht(this,Hr,new Set),Ht(this,Wr,new Set),this.pushMessage=t=>{fn(this,At,Je(this,At).concat(t)),Je(this,er).call(this)},this.popMessage=()=>{fn(this,At,Je(this,At).slice(0,-1)),Je(this,er).call(this)},this.replaceMessage=(t,n)=>{fn(this,At,[...Je(this,At).slice(0,t),this.snapshot(n),...Je(this,At).slice(t+1)]),Je(this,er).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?kA(t,n):t;return Je(this,Jr).add(r),()=>{Je(this,Jr).delete(r)}},this["~registerStatusCallback"]=t=>(Je(this,Hr).add(t),()=>{Je(this,Hr).delete(t)}),this["~registerErrorCallback"]=t=>(Je(this,Wr).add(t),()=>{Je(this,Wr).delete(t)}),Ht(this,er,()=>{Je(this,Jr).forEach(t=>t())}),Ht(this,ia,()=>{Je(this,Hr).forEach(t=>t())}),Ht(this,sa,()=>{Je(this,Wr).forEach(t=>t())}),fn(this,At,e)}get status(){return Je(this,Zi)}set status(e){fn(this,Zi,e),Je(this,ia).call(this)}get error(){return Je(this,Vi)}set error(e){fn(this,Vi,e),Je(this,sa).call(this)}get messages(){return Je(this,At)}set messages(e){fn(this,At,[...e]),Je(this,er).call(this)}};At=new WeakMap;Zi=new WeakMap;Vi=new WeakMap;Jr=new WeakMap;Hr=new WeakMap;Wr=new WeakMap;er=new WeakMap;ia=new WeakMap;sa=new WeakMap;var tr,Sc=class extends yA{constructor({messages:e,...t}){const n=new SA(e);super({...t,state:n}),Ht(this,tr,void 0),this["~registerMessagesCallback"]=(r,i)=>Je(this,tr)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Je(this,tr)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Je(this,tr)["~registerErrorCallback"](r),fn(this,tr,n)}};tr=new WeakMap;function _A({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:p=>{var h,g;return(g=(h=r.current).onToolCall)==null?void 0:g.call(h,p)},onData:p=>{var h,g;return(g=(h=r.current).onData)==null?void 0:g.call(h,p)},onFinish:p=>{var h,g;return(g=(h=r.current).onFinish)==null?void 0:g.call(h,p)},onError:p=>{var h,g;return(g=(h=r.current).onError)==null?void 0:g.call(h,p)},sendAutomaticallyWhen:p=>{var h,g,v;return(v=(g=(h=r.current).sendAutomaticallyWhen)==null?void 0:g.call(h,p))!=null?v:!1}},s=x.useRef("chat"in n?n.chat:new Sc(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Sc(i));const a=x.useCallback(p=>s.current["~registerMessagesCallback"](p,e),[e,s.current.id]),l=x.useSyncExternalStore(a,()=>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(p=>{typeof p=="function"&&(p=p(s.current.messages)),s.current.messages=p},[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 Om(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 Pm(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 Dm(e,t,n){if(!(n!=null&&n.selectedText)){const i=jA(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const a=e.indexOf(i,s+1);let l;if(a===-1)l=s;else if(n.startLine&&n.startLine>0){const f=AA(e,n.startLine);l=zA(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 a=TA(e,t,n.startLine,n.endLine);if(a)return a}const o=_c(e,t);return o||{original:e,modified:t}}const r=_c(e,t);return r||{original:e,modified:t}}function jA(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+)"/),o=s?s[1].length:2;if(!oa(i,r,n))return null;const a=JSON.stringify(i,null,o);return{original:e,modified:a}}function oa(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(oa(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(oa(r,t,n))return!0}return!1}function _c(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const o=JSON.parse(e);if(o&&typeof o=="object"&&!Array.isArray(o)){const a=Object.keys(s).sort().join(","),l=Object.keys(o).sort().join(",");if(a===l)return null}}catch{}}catch{}const n=NA(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const o=EA(r,t,s);o&&(r=o,i=!0)}return i?{original:e,modified:r}:null}function NA(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 o=s.search(/\S/);if(o<0||o!==i)continue;const a=s.match(/^\s*"([^"]+)"\s*:/);a&&t.push(a[1])}return[...new Set(t)]}function EA(e,t,n){const r=`"${n}"`,i=jc(e,r);if(i.length===0)return null;const s=jc(t,r);if(s.length===0)return null;const o=s[0],a=t.slice(o.start,o.end);let l=0;if(i.length>1){let d=-1;for(let f=0;f<i.length;f++){const p=e.slice(i[f].start,i[f].end),h=IA(p,a);h>d&&(d=h,l=f)}}const c=i[l];return e.slice(0,c.start)+a+e.slice(c.end)}function jc(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 o=s<0?"":e[s];if(o!==""&&o!=="{"&&o!==","&&o!==`
91
+ `&&o!=="\r"){r=i+1;continue}const a=e.indexOf(":",i+t.length);if(a===-1){r=i+1;continue}const l=a+1,c=CA(e,l);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function CA(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 o=1,a=t+1,l=!1;for(;a<e.length&&o>0;){if(e[a]==="\\"&&l){a+=2;continue}e[a]==='"'&&(l=!l),l||(e[a]===i?o++:e[a]===s&&o--),a++}return o===0?a:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function TA(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
+ `),o=i.slice(r).join(`
94
+ `),a=s+(s?`
95
+ `:"")+t+(o?`
96
+ `:"")+o;return{original:e,modified:a}}function IA(e,t){if(e===t)return 1;if(!e.length||!t.length)return 0;const n=3,r=new Set;for(let o=0;o<=e.length-n;o++)r.add(e.slice(o,o+n));let i=0;for(let o=0;o<=t.length-n;o++)r.has(t.slice(o,o+n))&&i++;const s=Math.max(e.length-n+1,t.length-n+1);return s>0?i/s:0}function AA(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 zA(e,t,n){let r=-1,i=1/0,s=e.indexOf(t);for(;s!==-1;){const o=Math.abs(s-n);o<i&&(i=o,r=s),s=e.indexOf(t,s+1)}return r}function OA(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 PA(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=Om(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function DA(){const e=Re(H=>H.threads),t=Re(H=>H.activeThreadId),n=Re(H=>H.updateThreadMessages),r=Re(H=>H.updateThreadTitle),i=Re(H=>H.clearContext),s=Re(H=>H.contextAttachments),o=Re(H=>H.scope),a=Re(H=>H.model),l=Ce(H=>H.activeTab),c=Ce(H=>H.documents),d=Ce(H=>H.documentTypes),f=Ce(H=>H.setPendingDiff),p=Ce(H=>H.createDocument),h=Ce(H=>H.openDocument),g=x.useRef(e);g.current=e;const v=x.useRef(l);v.current=l;const S=x.useRef(c);S.current=c;const y=x.useRef(d);y.current=d;const j=x.useRef(t);j.current=t;const m=l?t[l]:void 0,A=x.useRef(m);A.current=m;const C=x.useRef([]),w=x.useRef([]),N=x.useRef({}),J=x.useRef({}),[,D]=x.useState(0),_=x.useCallback(()=>D(H=>H+1),[]),T=x.useRef(null);T.current||(T.current=new Am({api:"/api/ai/chat"}));const I=x.useCallback(()=>{const H=S.current.find($=>$.name===v.current);return H?{name:H.name,text:H.text}:void 0},[]),z=x.useCallback(H=>N.current[H]||[],[]),O=_A({transport:T.current,onError:()=>{C.current.shift(),w.current.shift(),i()},onFinish:({messages:H})=>{var B,V;const $=A.current;if($){n($,H);const re=g.current[$];if(re&&re.title.startsWith("Chat ")){const se=H.find(P=>P.role==="user");if(se){const P=((B=se.parts)==null?void 0:B.filter(ue=>ue.type==="text").map(ue=>ue.text).join(""))||"";if(P){const ue=P.length>50?P.slice(0,50)+"...":P;r($,ue)}}}}const ee=C.current.shift()||[],k=w.current.shift()||"global",oe=H.filter(re=>re.role==="user"),q=oe[oe.length-1];q!=null&&q.id&&(N.current[q.id]=ee,J.current[q.id]=k);const b=H.filter(re=>re.role==="assistant").pop();if(b){const se=[...(((V=b.parts)==null?void 0:V.filter(P=>P.type==="text").map(P=>P.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(se.length>0){const P=OA(se);if(P){const ue=se[se.length-1][1],he=v.current;if(he){const ce=S.current.find(we=>we.name===he),pe=(ce==null?void 0:ce.text)||"",me=ee[0],U=PA(pe,P,k);!U&&k!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${k}", falling back to text merge`);const{original:Te,modified:X}=U??Dm(pe,P,me);f(he,Te,X,Pm(ue.replace(/\n$/,"")))}else{const ce=`ai-generated-${Date.now()}`;p(ce,P),h(ce)}}}}i()}});x.useEffect(()=>{const H=O.messages.filter($=>$.role==="user");for(let $=H.length-1;$>=0;$--){const ee=H[$].id;if(ee in N.current)break;C.current.length>0&&(N.current[ee]=C.current[0],J.current[ee]=w.current[0]||"global",_());break}},[O.messages,_]);const R=x.useCallback((H,$)=>{C.current.push([...s]),w.current.push(o),i();const ee={text:H};$!=null&&$.length&&(ee.files=$),O.sendMessage(ee,{body:{format:ot,context:s,activeDocument:I(),documentType:v.current&&y.current[v.current]||"application/json+report",scope:o,model:a}})},[O.sendMessage,s,I,i,o,a]),Y=x.useCallback(H=>J.current[H],[]);return{messages:O.messages,sendMessage:R,status:O.status,error:O.error,setMessages:O.setMessages,stop:O.stop,getMessageContext:z,getMessageScope:Y}}const Rm=x.createContext(null);function RA({children:e}){const t=DA();return u.jsx(Rm.Provider,{value:t,children:e})}function MA(){const e=x.useContext(Rm);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function $A(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 FA(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function Mm({context:e,onRemove:t,variant:n="default"}){var c;const r=$A(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,o=FA(e.selectedText),a=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 ${a?"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(Qg,{className:`h-3 w-3 shrink-0 ${a?"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(xn,{className:"h-3 w-3"})})]});return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:l}),u.jsxs(Ye,{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:o}),e.jsonPath&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Kn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const $m=32,LA=10,Fm=9,Lm=13,BA=160,ZA=6158,VA=8192,UA=8203,JA=8239,HA=8287,WA=12288,qA=65279;function GA(e){return/^[0-9A-Fa-f]$/.test(e)}function Cn(e){return e>="0"&&e<="9"}function YA(e){return e>=" "}function Ri(e){return`,:[]/{}()
99
+ +`.includes(e)}function Nc(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Ec(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Cc=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Tc=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Ic(e){return`,[]/{}
100
+ +`.includes(e)}function Ac(e){return Ui(e)||KA.test(e)}const KA=/^[[{\w-]$/;function XA(e){return e===`
101
+ `||e==="\r"||e===" "||e==="\b"||e==="\f"}function Tn(e,t){const n=e.charCodeAt(t);return n===$m||n===LA||n===Fm||n===Lm}function QA(e,t){const n=e.charCodeAt(t);return n===$m||n===Fm||n===Lm}function ez(e,t){const n=e.charCodeAt(t);return n===BA||n===ZA||n>=VA&&n<=UA||n===JA||n===HA||n===WA||n===qA}function Ui(e){return Bm(e)||aa(e)}function Bm(e){return e==='"'||e==="“"||e==="”"}function zc(e){return e==='"'}function aa(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function Oc(e){return e==="'"}function Fr(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 tz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function nz(e){return/[,\n][ \t\r]*$/.test(e)}const rz={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},iz={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
102
+ `,r:"\r",t:" "};function Pc(e){let t=0,n="";c(["```","[```","{```"]),s()||O(),c(["```","```]","```}"]);const i=f(",");for(i&&o(),Ac(e[t])&&nz(n)?(i||(n=Mt(n,",")),y()):i&&(n=Fr(n,","));e[t]==="}"||e[t]==="]";)t++,o();if(t>=e.length)return n;z();function s(){o();const $=v()||S()||j()||A()||C()||N(!1)||J();return o(),$}function o(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const ee=t;let k=a($);do k=l(),k&&(k=a($));while(k);return t>ee}function a($){const ee=$?Tn:QA;let k="";for(;;)if(ee(e,t))k+=e[t],t++;else if(ez(e,t))k+=" ",t++;else break;return k.length>0?(n+=k,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!sz(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($){if(d($)){if(Nc(e[t]))for(;t<e.length&&Ec(e[t]);)t++;return o(),!0}return!1}function d($){a(!0);for(const ee of $){const k=t+ee.length;if(e.slice(t,k)===ee)return t=k,!0}return!1}function f($){return e[t]===$?(n+=e[t],t++,!0):!1}function p($){return e[t]===$?(t++,!0):!1}function h(){return p("\\")}function g(){return o(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,o(),p(","),!0):!1}function v(){if(e[t]==="{"){n+="{",t++,o(),p(",")&&o();let $=!0;for(;t<e.length&&e[t]!=="}";){let ee;if($?(ee=!0,$=!1):(ee=f(","),ee||(n=Mt(n,",")),o()),g(),!(j()||N(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=Fr(n,","):R();break}o();const oe=f(":"),q=t>=e.length;oe||(Ac(e[t])||q?n=Mt(n,":"):Y()),s()||(oe||q?n+="null":Y())}return e[t]==="}"?(n+="}",t++):n=Mt(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,o(),p(",")&&o();let $=!0;for(;t<e.length&&e[t]!=="]";)if($?$=!1:f(",")||(n=Mt(n,",")),g(),!s()){n=Fr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Mt(n,"]"),!0}return!1}function y(){let $=!0,ee=!0;for(;ee;)$?$=!1:f(",")||(n=Mt(n,",")),ee=s();ee||(n=Fr(n,",")),n=`[
104
+ ${n}
105
+ ]`}function j(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,k=e[t]==="\\";if(k&&(t++,k=!0),Ui(e[t])){const oe=zc(e[t])?zc:Oc(e[t])?Oc:aa(e[t])?aa:Bm,q=t,b=n.length;let B='"';for(t++;;){if(t>=e.length){const V=D(t-1);return!$&&Ri(e.charAt(V))?(t=q,n=n.substring(0,b),j(!0)):(B=Mt(B,'"'),n+=B,!0)}if(t===ee)return B=Mt(B,'"'),n+=B,!0;if(oe(e[t])){const V=t,re=B.length;if(B+='"',t++,n+=B,o(!1),$||t>=e.length||Ri(e[t])||Ui(e[t])||Cn(e[t]))return m(),!0;const se=D(V-1),P=e.charAt(se);if(P===",")return t=q,n=n.substring(0,b),j(!1,se);if(Ri(P))return t=q,n=n.substring(0,b),j(!0);n=n.substring(0,b),t=V+1,B=`${B.substring(0,re)}\\${B.substring(re)}`}else if($&&Ic(e[t])){if(e[t-1]===":"&&Cc.test(e.substring(q+1,t+2)))for(;t<e.length&&Tc.test(e[t]);)B+=e[t],t++;return B=Mt(B,'"'),n+=B,m(),!0}else if(e[t]==="\\"){const V=e.charAt(t+1);if(iz[V]!==void 0)B+=e.slice(t,t+2),t+=2;else if(V==="u"){let se=2;for(;se<6&&GA(e[t+se]);)se++;se===6?(B+=e.slice(t,t+6),t+=6):t+se>=e.length?t=e.length:H()}else B+=V,t+=2}else{const V=e.charAt(t);V==='"'&&e[t-1]!=="\\"?(B+=`\\${V}`,t++):XA(V)?(B+=rz[V],t++):(YA(V)||I(V),B+=V,t++)}k&&h()}}return!1}function m(){let $=!1;for(o();e[t]==="+";){$=!0,t++,o(),n=Fr(n,'"',!0);const ee=n.length;j()?n=tz(n,ee,1):n=Mt(n,'"')}return $}function A(){const $=t;if(e[t]==="-"){if(t++,_())return T($),!0;if(!Cn(e[t]))return t=$,!1}for(;Cn(e[t]);)t++;if(e[t]==="."){if(t++,_())return T($),!0;if(!Cn(e[t]))return t=$,!1;for(;Cn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,_())return T($),!0;if(!Cn(e[t]))return t=$,!1;for(;Cn(e[t]);)t++}if(!_())return t=$,!1;if(t>$){const ee=e.slice($,t),k=/^0\d/.test(ee);return n+=k?`"${ee}"`:ee,!0}return!1}function C(){return w("true","true")||w("false","false")||w("null","null")||w("True","true")||w("False","false")||w("None","null")}function w($,ee){return e.slice(t,t+$.length)===$?(n+=ee,t+=$.length,!0):!1}function N($){const ee=t;if(Nc(e[t])){for(;t<e.length&&Ec(e[t]);)t++;let k=t;for(;Tn(e,k);)k++;if(e[k]==="(")return t=k+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Ic(e[t])&&!Ui(e[t])&&(!$||e[t]!==":");)t++;if(e[t-1]===":"&&Cc.test(e.substring(ee,t+2)))for(;t<e.length&&Tc.test(e[t]);)t++;if(t>ee){for(;Tn(e,t-1)&&t>0;)t--;const k=e.slice(ee,t);return n+=k==="undefined"?"null":JSON.stringify(k),e[t]==='"'&&t++,!0}}function J(){if(e[t]==="/"){const $=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring($,t)),!0}}function D($){let ee=$;for(;ee>0&&Tn(e,ee);)ee--;return ee}function _(){return t>=e.length||Ri(e[t])||Tn(e,t)}function T($){n+=`${e.slice($,t)}0`}function I($){throw new Kn(`Invalid character ${JSON.stringify($)}`,t)}function z(){throw new Kn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function O(){throw new Kn("Unexpected end of json string",e.length)}function R(){throw new Kn("Object key expected",t)}function Y(){throw new Kn("Colon expected",t)}function H(){const $=e.slice(t,t+6);throw new Kn(`Invalid unicode character "${$}"`,t)}}function sz(e,t){return e[t]==="*"&&e[t+1]==="/"}function oz({json:e,context:t,scope:n}){const[r,i]=x.useState(!1),[s,o]=x.useState(null),a=x.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return Pc(e)}catch{}const y=`{${e}}`;try{return JSON.parse(y),y}catch{}try{return Pc(y)}catch{return null}},[e]),l=x.useMemo(()=>Pm(a||e),[a,e]),c=Ce(y=>y.activeTab),d=Ce(y=>y.documents),f=Ce(y=>(y.acceptedApplyIds||[]).includes(l)),p=Ce(y=>y.setPendingDiff),h=Ce(y=>y.createDocument),g=Ce(y=>y.openDocument),v=x.useCallback(()=>{if(a){o(null);try{if(c){const y=d.find(w=>w.name===c),j=(y==null?void 0:y.text)||"";if(n==="templates")try{const w=JSON.parse(j),N=JSON.parse(a);if(Array.isArray(N.templates)){w.props||(w.props={}),w.props.templates=Om(w.props.templates||[],N.templates);const J=JSON.stringify(w,null,2);p(c,j,J,l);return}}catch{}const m=t==null?void 0:t[0],{original:A,modified:C}=Dm(j,a,m);p(c,A,C,l)}else{const y=`ai-generated-${Date.now()}`;h(y,a),g(y)}}catch(y){o(y instanceof Error?y.message:"Merge failed")}}},[a,c,d,p,h,g,t,n,l]),S=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(_e,{variant:"secondary",size:"sm",onClick:v,disabled:f||!a,children:f?"Applied":a?"Apply to Editor":"Invalid JSON"}),u.jsx(_e,{variant:"ghost",size:"sm",onClick:S,children:r?u.jsx(yn,{className:"h-3.5 w-3.5"}):u.jsx(ws,{className:"h-3.5 w-3.5"})})]}),s&&u.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function az({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:o}){const[a,l]=x.useState(null),[c,d]=x.useState(""),[f,p]=x.useState(null),h=x.useRef(null),g=(t==null?void 0:t.title)||"New Chat",v=g.length>24?g.slice(0,24)+"...":g;x.useEffect(()=>{a&&requestAnimationFrame(()=>{var N;return(N=h.current)==null?void 0:N.focus()})},[a]);const S=x.useCallback((N,J)=>{J.stopPropagation(),J.preventDefault(),l(N.id),d(N.title),p(null)},[]),y=x.useCallback(()=>{a&&c.trim()&&o(a,c.trim()),l(null),d("")},[a,c,o]),j=x.useCallback(()=>{l(null),d("")},[]),m=x.useCallback(N=>{N.stopPropagation(),N.key==="Enter"?(N.preventDefault(),y()):N.key==="Escape"&&(N.preventDefault(),j())},[y,j]),A=x.useCallback((N,J)=>{J.stopPropagation(),J.preventDefault(),p(N),l(null)},[]),C=x.useCallback(N=>{N.stopPropagation(),N.preventDefault(),f&&(s(f),p(null))},[f,s]),w=x.useCallback(N=>{N.stopPropagation(),N.preventDefault(),p(null)},[]);return u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(js,{onOpenChange:N=>{N||(l(null),p(null))},children:[u.jsx(Ns,{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(hi,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),u.jsxs(xi,{align:"start",className:"w-64",children:[e.map(N=>{const J=a===N.id;return f===N.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:C,children:u.jsx(yn,{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(xn,{className:"h-3.5 w-3.5"})})]},N.id):J?u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:_=>_.stopPropagation(),onPointerDown:_=>_.stopPropagation(),children:[u.jsx("input",{ref:h,type:"text",value:c,onChange:_=>d(_.target.value),onKeyDown:m,onBlur:y,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:_=>{_.preventDefault(),y()},children:u.jsx(yn,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:_=>{_.preventDefault(),j()},children:u.jsx(xn,{className:"h-3.5 w-3.5"})})]},N.id):u.jsxs(Ft,{onSelect:()=>r(N.id),className:`group ${N.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[u.jsx("span",{className:"truncate flex-1",children:N.title.length>30?N.title.slice(0,30)+"...":N.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:_=>S(N,_),children:u.jsx(ex,{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:_=>A(N.id,_),children:u.jsx(ca,{className:"h-3 w-3"})})]})]},N.id)}),u.jsx(xr,{}),u.jsxs(Ft,{onSelect:N=>{N.preventDefault();const J=i();J&&(l(J),d(xa()),p(null))},children:[u.jsx(nn,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),u.jsx(_e,{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 Zm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),lz=Array.from(Zm).join(","),uz=20*1024*1024,Dc=10;function cz(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 Rc(e){return Array.from(e).filter(t=>Zm.has(t.type)&&t.size<=uz)}function Vm(e){return e.startsWith("image/")}function Mc(){var K,ge,Ne;const e=Re(L=>L.contextAttachments),t=Re(L=>L.addContext),n=Re(L=>L.removeContext),r=Re(L=>L.scope),i=Re(L=>L.setScope),s=Re(L=>L.model),o=Re(L=>L.setModel),a=Re(L=>L.openChat),l=Re(L=>L.closeChat),c=Re(L=>L.threads),d=Re(L=>L.activeThreadId),f=Re(L=>L.createThread),p=Re(L=>L.deleteThread),h=Re(L=>L.switchThread),g=Re(L=>L.updateThreadMessages),v=Re(L=>L.updateThreadTitle),S=Re(L=>L.deleteThreadsForDocument),y=Ce(L=>L.activeTab),j=Ce(L=>L.documents),{messages:m,sendMessage:A,status:C,error:w,setMessages:N,stop:J,getMessageContext:D,getMessageScope:_}=MA(),[T,I]=x.useState(""),[z,O]=x.useState([]),[R,Y]=x.useState(!1),[H,$]=x.useState(!1),ee=x.useRef(null),k=x.useRef(null),oe=x.useRef(null),q=x.useCallback(async L=>{const xe=Rc(L);if(xe.length===0)return;const ze=await Promise.all(xe.map(cz));O(Be=>{const rt=[...Be,...ze];return rt.length>Dc?rt.slice(0,Dc):rt})},[]),b=x.useCallback(L=>{O(xe=>xe.filter((ze,Be)=>Be!==L))},[]),B=x.useCallback(L=>{var ze;const xe=(ze=L.clipboardData)==null?void 0:ze.files;if(xe&&xe.length>0){const Be=Rc(xe);Be.length>0&&(L.preventDefault(),q(Be))}},[q]),V=x.useCallback(L=>{var ze;L.preventDefault(),$(!1);const xe=(ze=L.dataTransfer)==null?void 0:ze.files;xe&&xe.length>0&&q(Array.from(xe))},[q]),re=x.useCallback(L=>{L.preventDefault(),$(!0)},[]),se=x.useCallback(()=>$(!1),[]),P=y?d[y]:void 0,ue=P?c[P]:void 0,he=x.useMemo(()=>y?Object.values(c).filter(L=>L.documentName===y).sort((L,xe)=>xe.updatedAt-L.updatedAt):[],[c,y]);x.useEffect(()=>{y&&he.length===0&&f(y)},[y,he.length,f]);const ce=x.useRef(c);ce.current=c,x.useEffect(()=>{const L=new Set(j.map(ze=>ze.name)),xe=new Set;for(const ze of Object.values(ce.current))!L.has(ze.documentName)&&ze.documentName!=="__migrated__"&&xe.add(ze.documentName);for(const ze of xe)S(ze)},[j,S]);const pe=x.useRef(null);x.useEffect(()=>{pe.current!==P&&(pe.current=P,N((ue==null?void 0:ue.messages)??[]))},[P,ue,N]),x.useEffect(()=>{var L;(L=ee.current)==null||L.scrollIntoView({behavior:"smooth"})},[m,C]),x.useEffect(()=>{const L=xe=>{var rt;const{documentName:ze,selection:Be}=xe.detail;t({...Be,documentName:ze}),a(),(rt=k.current)==null||rt.focus()};return window.addEventListener("monaco-selection-to-ai",L),()=>window.removeEventListener("monaco-selection-to-ai",L)},[t,a]);const me=C==="streaming",U=C==="submitted"||me,Te=x.useCallback(L=>{L.preventDefault(),!(!T.trim()&&z.length===0||U)&&(A(T,z.length>0?z:void 0),I(""),O([]))},[T,z,U,A]),X=x.useCallback(L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),Te(L))},[Te]),we=x.useCallback(()=>{m.length!==0&&Y(!0)},[m.length]),E=x.useCallback(()=>{Y(!1),N([]),P&&(g(P,[]),v(P,xa()))},[N,P,g,v]),[M,F]=x.useState(null),ne=x.useCallback(L=>{F(L)},[]),Q=x.useCallback(()=>{var rt,tt;if(!M)return;const L=m.findIndex(at=>at.id===M);if(L===-1){F(null);return}const xe=m[L],ze=new Set([L]);xe.role==="user"&&((rt=m[L+1])==null?void 0:rt.role)==="assistant"?ze.add(L+1):xe.role==="assistant"&&L>0&&((tt=m[L-1])==null?void 0:tt.role)==="user"&&ze.add(L-1);const Be=m.filter((at,un)=>!ze.has(un));N(Be),P&&g(P,Be),F(null)},[M,m,N,P,g]),te=x.useCallback(L=>{if(!U){if(he.length<=1){we();return}p(L)}},[U,he.length,we,p]),de=x.useCallback(()=>{if(!(!y||U))return f(y)},[y,U,f]),ve=x.useCallback(L=>{U||L===P||h(L)},[U,P,h]),Z=x.useCallback((L,xe)=>{v(L,xe)},[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(az,{threads:he,activeThread:ue,disabled:U,onSwitch:ve,onCreate:de,onDelete:te,onRename:Z}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(_e,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:we,disabled:U||m.length===0,children:"Clear"}),u.jsx(_e,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:u.jsx(xn,{className:"h-3.5 w-3.5"})})]})]}),u.jsx(ni,{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(nl,{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(ri,{shortcut:"mod+k"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),m.map((L,xe)=>{let ze;if(L.role==="user"){const tt=D(L.id);tt&&tt.length>0&&(ze=tt)}else if(L.role==="assistant"){for(let tt=xe-1;tt>=0;tt--)if(m[tt].role==="user"){ze=D(m[tt].id);break}}const Be=me&&xe===m.length-1&&L.role==="assistant",rt=L.role==="user"?_(L.id):void 0;return u.jsx(dz,{msg:L,isStreaming:Be,context:ze,scope:rt,onDelete:U?void 0:ne},L.id)}),U&&((K=m[m.length-1])==null?void 0:K.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(Lr,{className:"h-3.5 w-3.5 animate-spin text-primary"}),u.jsx("span",{children:"Thinking..."})]})})}),w&&!U&&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:ee})]})}),u.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${H?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:V,onDragOver:re,onDragLeave:se,children:[e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((L,xe)=>u.jsx(Mm,{context:L,onRemove:()=>n(xe)},xe))}),u.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u.jsx(hz,{model:s,setModel:o}),ot==="pptx"&&y&&u.jsx(gz,{scope:r,setScope:i,docSize:((Ne=(ge=j.find(L=>L.name===y))==null?void 0:ge.text)==null?void 0:Ne.length)??0})]}),z.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:z.map((L,xe)=>u.jsxs("div",{className:"relative group",children:[Vm(L.mediaType)?u.jsx("img",{src:L.url,alt:L.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(Co,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u.jsx("span",{className:"text-xs truncate text-muted-foreground",children:L.filename||"file"})]}),u.jsx("button",{type:"button",onClick:()=>b(xe),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(xn,{className:"h-3 w-3"})})]},xe))}),u.jsxs("form",{onSubmit:Te,className:"flex items-end gap-2",children:[u.jsx("input",{ref:oe,type:"file",accept:lz,multiple:!0,className:"hidden",onChange:L=>{L.target.files&&q(Array.from(L.target.files)),L.target.value=""}}),u.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var L;return(L=oe.current)==null?void 0:L.click()},title:"Attach file",children:u.jsx(Co,{className:"h-4 w-4"})}),u.jsx("textarea",{ref:k,value:T,onChange:L=>{I(L.target.value);const xe=L.target;xe.style.height="auto",xe.style.height=`${Math.min(xe.scrollHeight,128)}px`},onKeyDown:X,onPaste:B,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}),U?u.jsx(_e,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:J,title:"Stop generating",children:u.jsx(Ed,{className:"h-4 w-4"})}):u.jsx(_e,{type:"submit",size:"icon",disabled:!T.trim()&&z.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:u.jsx(nl,{className:"h-4 w-4"})})]})]}),u.jsx(Ct,{open:R,onOpenChange:Y,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear thread"}),u.jsx(an,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),u.jsxs(bn,{children:[u.jsx(il,{asChild:!0,children:u.jsx(_e,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(_e,{variant:"destructive",size:"sm",onClick:E,children:"Clear"})]})]})}),u.jsx(Ct,{open:M!==null,onOpenChange:L=>{L||F(null)},children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Delete message"}),u.jsx(an,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),u.jsxs(bn,{children:[u.jsx(il,{asChild:!0,children:u.jsx(_e,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(_e,{variant:"destructive",size:"sm",onClick:Q,children:"Delete"})]})]})})]})}const dz=x.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,c;const o=((l=t.parts)==null?void 0:l.filter(d=>d.type==="text").map(d=>d.text).join(""))||"",a=((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:[a.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:a.map((d,f)=>Vm(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(Co,{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(Mm,{context:d,variant:"sent"},f))}),o&&u.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:o}),i&&i!=="global"&&u.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):u.jsx(fz,{text:o,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(ca,{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 fz({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(F1,{remarkPlugins:[X_],components:{pre:({children:i})=>u.jsx(u.Fragment,{children:i}),code:({className:i,children:s})=>{const o=i==null?void 0:i.startsWith("language-"),a=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!o)return u.jsx("code",{className:"rounded-sm bg-muted px-1 py-0.5 text-xs font-mono",children:s});const c=a==="json"||a==="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:a||"code"}),!c&&u.jsx(xz,{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(oz,{json:l,context:n,scope:r})]})}},children:e})})}const pz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function hz({model:e,setModel:t}){return u.jsxs(ei,{value:e,onValueChange:n=>t(n),children:[u.jsx(hr,{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(ti,{})}),u.jsx(mr,{children:pz.map(n=>u.jsx(Dn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const $c={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"},mz=1e5;function gz({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($c).map(r=>u.jsxs(qe,{children:[u.jsx(Ge,{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(Ye,{side:"top",className:"text-xs max-w-[200px]",children:$c[r]})]},r))})]}),e==="global"&&n>mz&&u.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[u.jsx(Id,{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 xz({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 yz({discoveryData:e}){const t=mf(),n=fy(),r=Re(_=>_.chatOpen),i=Re(_=>_.toggleChat),[s,o]=x.useState(()=>{try{const _=localStorage.getItem("dev-env.sidebar-open");return n?!1:_?_==="true":!0}catch{return!n}}),[a,l]=x.useState(()=>{try{const _=localStorage.getItem("dev-env.preview-open");return _?_==="true":!0}catch{return!0}}),[c,d]=x.useState("editor"),[f,p]=x.useState(!1),h=150,[g,v]=x.useState(!s),[S,y]=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(a))}catch{}},[a]);const j=x.useRef(n);x.useEffect(()=>{n&&!j.current&&s&&(y(!0),o(!1),setTimeout(()=>{v(!0),y(!1)},h)),!n&&j.current&&!s&&(y(!0),o(!0),setTimeout(()=>{v(!1),y(!1)},h)),j.current=n},[n,s]);const m=x.useCallback(()=>{if(t){p(_=>!_);return}y(!0),o(_=>!_),setTimeout(()=>{v(_=>!_),y(!1)},h)},[t]),A=x.useCallback(()=>l(_=>!_),[]),C=x.useRef(i),w=x.useRef(m),N=x.useRef(A);x.useEffect(()=>{C.current=i}),x.useEffect(()=>{w.current=m}),x.useEffect(()=>{N.current=A}),x.useEffect(()=>{const _=T=>{(T.metaKey||T.ctrlKey)&&(T.code==="KeyB"&&!T.shiftKey&&(T.preventDefault(),w.current()),T.code==="KeyJ"&&T.shiftKey&&(T.preventDefault(),T.stopPropagation(),C.current()),T.code==="KeyP"&&T.shiftKey&&(T.preventDefault(),N.current()))};return window.addEventListener("keydown",_,!0),()=>window.removeEventListener("keydown",_,!0)},[]);const J=RA,D=[{key:"editor",icon:Eo,label:"Editor"},{key:"preview",icon:Ad,label:"Preview"},{key:"chat",icon:zd,label:"Chat"}];return t?u.jsx(J,{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(ff,{open:f,onOpenChange:p,children:[u.jsx(ay,{asChild:!0,children:u.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:u.jsx(Td,{className:"h-4 w-4"})})}),u.jsx(ba,{side:"left",className:"p-0 w-72",children:u.jsx(Nl,{discoveryData:e,onToggleSidebar:()=>p(!1),isCollapsed:!1})})]}),u.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:D.map(({key:_,icon:T,label:I})=>u.jsxs(_e,{variant:c===_?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>d(_),children:[u.jsx(T,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"hidden xs:inline",children:I})]},_))})]}),c!=="chat"&&u.jsx(Wl,{previewOpen:a,onTogglePreview:A}),u.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(El,{})}),c==="preview"&&u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Cl,{})}),c==="chat"&&u.jsx(Mc,{})]})]})}):u.jsx(J,{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(Nl,{discoveryData:e,onToggleSidebar:m,isCollapsed:g,isAnimating:S})}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[u.jsx(Wl,{previewOpen:a,onTogglePreview:A}),u.jsxs(Gb,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[u.jsx(Xs,{defaultSize:a?50:100,minSize:20,id:"editor",order:1,children:u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(El,{})})}),a&&u.jsxs(u.Fragment,{children:[u.jsx($l,{withHandle:!0}),u.jsx(Xs,{defaultSize:50,minSize:20,id:"preview",order:2,children:u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Cl,{})})})]}),r&&u.jsxs(u.Fragment,{children:[u.jsx($l,{withHandle:!0}),u.jsx(Xs,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:u.jsx(Mc,{})})]})]})]})]})})}function bz(){const[e,t]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState(null),o=x.useCallback(async()=>{r(!0),s(null);try{const a=await fetch("/api/discovery/all");if(!a.ok)throw new Error(`Discovery failed: ${a.statusText}`);const l=await a.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(a){console.error("Discovery error:",a),s(a instanceof Error?a.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return x.useEffect(()=>{o()},[o]),{data:e,loading:n,error:i,refetch:o}}let Mi=null;async function vz(){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 wz(){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=vz().finally(()=>{Mi=null}));const a=await Mi;return s(a),!0}catch(a){return console.error("Plugin loading error:",a),r(a instanceof Error?a.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function kz(){const{data:e,loading:t,error:n}=bz(),{loadPlugins:r}=wz(),i=Bt(s=>s.applyPluginsWithValidation);return x.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const o=Bt.getState().selectedPlugins;o.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(o)),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(ix,{children:u.jsx(sx,{children:u.jsx(ox,{children:u.jsx(ax,{children:u.jsx(lx,{children:u.jsx(Ux,{children:u.jsx(xf,{children:u.jsx("section",{className:"flex h-screen w-full flex-col",children:u.jsx("div",{className:"grow overflow-hidden",children:u.jsx(yz,{discoveryData:e})})})})})})})})})})}const zz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:kz},Symbol.toStringTag,{value:"Module"}));export{Kt as B,Ct as D,zz as H,nv as P,Yr as S,dr as T,Xf as a,df as b,kt as c,Ut as d,Jt as e,Xb as u};
106
+ //# sourceMappingURL=HomePage-DgVVosCp.js.map