@json-to-office/jto 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +115 -5
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/HomePage-BTmw2QAf.js +99 -0
- package/dist/client/assets/HomePage-BTmw2QAf.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-B9IVUEsa.js → JsonEditorPage-CRONWw-J.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-B9IVUEsa.js.map → JsonEditorPage-CRONWw-J.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-B20CKO2l.js → MonacoPluginProvider-DhOIgTne.js} +3 -3
- package/dist/client/assets/{MonacoPluginProvider-B20CKO2l.js.map → MonacoPluginProvider-DhOIgTne.js.map} +1 -1
- package/dist/client/assets/{button-B_SFRCrX.js → button-ebCBEwlw.js} +2 -2
- package/dist/client/assets/{button-B_SFRCrX.js.map → button-ebCBEwlw.js.map} +1 -1
- package/dist/client/assets/{editor-B6lP0ii6.js → editor-CB9BVJGn.js} +2 -2
- package/dist/client/assets/{editor-B6lP0ii6.js.map → editor-CB9BVJGn.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-ZXrPUjb-.js → editor-monaco-json-DaGk8WIJ.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-ZXrPUjb-.js.map → editor-monaco-json-DaGk8WIJ.js.map} +1 -1
- package/dist/client/assets/index-Cy63RxyT.js +5 -0
- package/dist/client/assets/index-Cy63RxyT.js.map +1 -0
- package/dist/client/assets/index-DiQf3mCW.css +1 -0
- package/dist/client/assets/{preview-CuW78gw0.js → preview-B4bcm38l.js} +2 -2
- package/dist/client/assets/{preview-CuW78gw0.js.map → preview-B4bcm38l.js.map} +1 -1
- package/dist/client/assets/radix-ui-BQBCrmlJ.js +51 -0
- package/dist/client/assets/{radix-ui-BiXCNJNt.js.map → radix-ui-BQBCrmlJ.js.map} +1 -1
- package/dist/client/assets/{state-vendor-DTum9m7F.js → state-vendor-ByFYl9bq.js} +2 -2
- package/dist/client/assets/{state-vendor-DTum9m7F.js.map → state-vendor-ByFYl9bq.js.map} +1 -1
- package/dist/client/assets/{ui-vendor-D3QbouTA.js → ui-vendor-HKNXoiLD.js} +54 -44
- package/dist/client/assets/ui-vendor-HKNXoiLD.js.map +1 -0
- package/dist/client/index.html +5 -5
- package/package.json +5 -5
- package/dist/client/assets/HomePage-UtourY26.js +0 -99
- package/dist/client/assets/HomePage-UtourY26.js.map +0 -1
- package/dist/client/assets/index-CCAjuRfZ.js +0 -5
- package/dist/client/assets/index-CCAjuRfZ.js.map +0 -1
- package/dist/client/assets/index-DMEmT8G4.css +0 -1
- package/dist/client/assets/radix-ui-BiXCNJNt.js +0 -51
- package/dist/client/assets/ui-vendor-D3QbouTA.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-CB9BVJGn.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-DaGk8WIJ.js","assets/index-Cy63RxyT.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-BQBCrmlJ.js","assets/ui-vendor-HKNXoiLD.js","assets/monaco-editor-BcgxPCqT.js","assets/state-vendor-ByFYl9bq.js","assets/index-DiQf3mCW.css","assets/MonacoPluginProvider-DhOIgTne.js","assets/button-ebCBEwlw.js","assets/preview-B4bcm38l.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var cm=Object.defineProperty;var dm=(e,t,n)=>t in e?cm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mo=(e,t,n)=>dm(e,typeof t!="symbol"?t+"":t,n);import{r as y,j as u,c as Ee,R as cc,g as Ua}from"./react-vendor-CTFDOf2G.js";import{b as dc,c as Ja,d as fc,e as pc,f as ts,g as ns,D as rs,O as is,h as fm,V as pm,i as hc,I as hm,j as mm,k as mc,l as gm,m as gc,n as xm,o as ym,G as bm,S as xc,p as yc,L as bc,q as vc,r as wc,s as or,t as vm,u as wm,v as km,w as kc,x as Sc,y as _c,z as jc,A as Nc,B as Cc,E as Ec,F as Ic,H as zc,J as Tc,K as Ac,M as Sm,N as _m,Q as Pc,U as jm,W as Nm,X as Cm,Y as Em,Z as Im,_ as zm,$ as Tm,a0 as Am,a1 as Pm,a2 as Oc,a3 as Dc,a4 as Rc,a5 as Mc,a6 as $c,a7 as Fc,a8 as Lc,a9 as Zc,aa as Bc,ab as Om,ac as Vc,ad as Uc,ae as Jc}from"./radix-ui-BQBCrmlJ.js";import{c as H,u as Xr,S as Yt,A as Hc,T as oi,C as Dm,E as Rm,F as yt,a as Mm,b as We,d as Ge,e as Ke,f as qc,s as Ns,_ as Wc,g as li,h as $m,i as Fm,j as Lm,k as fr,l as vi,W as Zm}from"./index-Cy63RxyT.js";import{X as Nn,C as on,a as un,b as Bm,d as Qr,G as Gc,F as Vm,e as ss,f as Kc,P as Um,g as $o,h as la,i as Yc,S as Xc,B as Fo,j as Jm,k as Hm,l as qm,m as as,n as Wm,M as Gm,o as Km,p as Ym,q as Qc,r as Xm,s as Lo,t as zi,u as Qm,I as ed,v as eg,w as tg,R as ng,x as rg,T as td,E as ig,y as sg,z as ag,A as og,D as nd,H as Ha,J as rd,K as lg,L as id,N as ua,O as ug,Q as cg,U as Zo,V as ca,W as dg}from"./ui-vendor-HKNXoiLD.js";import{B as we}from"./button-ebCBEwlw.js";import{u as Ae,i as fg,a as da,b as vn,g as fa,c as Dt,T as sd,d as ui,S as pg,O as hg,e as mg,M as gg,D as xg}from"./MonacoPluginProvider-DhOIgTne.js";import{u as ad,a as yg,d as bg,p as vg,b as wg,e as kg}from"./state-vendor-ByFYl9bq.js";import{b as Sg}from"./query-vendor-Df8-oete.js";const It=dc,Bo=fc,_g=pc,Vo=Ja,od=y.forwardRef(({className:e,...t},n)=>u.jsx(is,{ref:n,className:H("fixed inset-0 z-50 bg-black/80",e),...t}));od.displayName=is.displayName;const St=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(_g,{children:[u.jsx(od,{}),u.jsxs(ts,{ref:r,className:H("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(Ja,{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(Nn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));St.displayName=ts.displayName;const Ut=({className:e,...t})=>u.jsx("div",{className:H("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ut.displayName="DialogHeader";const Cn=({className:e,...t})=>u.jsx("div",{className:H("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Cn.displayName="DialogFooter";const Jt=y.forwardRef(({className:e,...t},n)=>u.jsx(ns,{ref:n,className:H("text-lg leading-none font-semibold tracking-tight",e),...t}));Jt.displayName=ns.displayName;const cn=y.forwardRef(({className:e,...t},n)=>u.jsx(rs,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));cn.displayName=rs.displayName;const Rr=fm,jg=bm,Mr=pm,er=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(hc,{ref:r,className:H("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-md border bg-transparent px-3 py-2 text-sm shadow-sm 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(hm,{asChild:!0,children:u.jsx(on,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));er.displayName=hc.displayName;const ld=y.forwardRef(({className:e,...t},n)=>u.jsx(xc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(Bm,{className:"h-4 w-4"})}));ld.displayName=xc.displayName;const ud=y.forwardRef(({className:e,...t},n)=>u.jsx(yc,{ref:n,className:H("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(on,{className:"h-4 w-4"})}));ud.displayName=yc.displayName;const tr=y.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>u.jsx(mm,{children:u.jsxs(mc,{ref:i,className:H("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-md 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(ld,{}),u.jsx(gm,{className:H("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(ud,{})]})}));tr.displayName=mc.displayName;const cd=y.forwardRef(({className:e,...t},n)=>u.jsx(bc,{ref:n,className:H("px-2 py-1.5 text-sm font-semibold",e),...t}));cd.displayName=bc.displayName;const En=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gc,{ref:r,className:H("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(xm,{children:u.jsx(un,{className:"h-4 w-4"})})}),u.jsx(ym,{children:t})]}));En.displayName=gc.displayName;const Ng=y.forwardRef(({className:e,...t},n)=>u.jsx(vc,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));Ng.displayName=vc.displayName;const ei=y.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:H("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm 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 md:text-sm",e),ref:r,...n}));ei.displayName="Input";const Cg=Qr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Gn=y.forwardRef(({className:e,...t},n)=>u.jsx(wc,{ref:n,className:H(Cg(),e),...t}));Gn.displayName=wc.displayName;const Eg=Qr("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Vt({className:e,variant:t,...n}){return u.jsx("div",{className:H(Eg({variant:t}),e),...n})}const Ig=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:a}=Ae(ad(I=>({documents:I.documents,documentTypes:I.documentTypes,activeTab:I.activeTab,createDocument:I.createDocument,openDocument:I.openDocument}))),{toast:o}=Xr(),l=y.useMemo(()=>n.filter(I=>r[I.name]!=="application/json+theme"),[n,r]),[c,f]=y.useState(""),[d,p]=y.useState(""),[h,m]=y.useState("playground"),[w,S]=y.useState(!1),[x,_]=y.useState(null),[g,z]=y.useState(null),[E,k]=y.useState(null),C=()=>{_(null),z(null),k(null)};y.useEffect(()=>{if(!e)return;_(null),z(null),k(null);const I=l.map(B=>B.name),A=I.includes(i)?i:I[0]??"";p(A),f(I.find(B=>B!==A)??"")},[e]);const $=async()=>{const I=l.find(B=>B.name===c),A=l.find(B=>B.name===d);if(!(!I||!A)){S(!0),_(null),z(null),k(null);try{const B=await fetch(Hc.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:I.text,newDefinition:A.text,options:{author:h||"playground"}})}),D=await B.json();if(!B.ok||!D.success){const T=Array.isArray(D.errors)?`: ${D.errors.slice(0,3).map(P=>P.message||String(P)).join("; ")}`:"";throw new Error((D.error||`Diff failed (${B.status})`)+T)}z(D.data.summary),k(D.data.document)}catch(B){_(B instanceof Error?B.message:"Diff failed")}finally{S(!1)}}},K=()=>{if(!E)return;const I=new Set(n.map(D=>D.name));let A=`${d}-redline`,B=2;for(;I.has(A);)A=`${d}-redline-${B++}`;s(A,JSON.stringify(E,null,2)),a(A),o({title:`Redline created: ${A}`}),t(!1)},N=g?g.tracked.modified+g.tracked.inserted+g.tracked.deleted:0;return u.jsx(It,{open:e,onOpenChange:t,children:u.jsxs(St,{className:"sm:max-w-[560px]",children:[u.jsxs(Ut,{children:[u.jsxs(Jt,{className:"flex items-center gap-2",children:[u.jsx(Gc,{className:"size-4"}),"Compare documents"]}),u.jsx(cn,{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(Gn,{htmlFor:"diff-base",children:"Base (old)"}),u.jsxs(Rr,{value:c,onValueChange:I=>{f(I),C()},children:[u.jsx(er,{id:"diff-base",children:u.jsx(Mr,{placeholder:"Select document"})}),u.jsx(tr,{children:l.map(I=>u.jsx(En,{value:I.name,children:I.name},I.name))})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Gn,{htmlFor:"diff-revised",children:"Revised (new)"}),u.jsxs(Rr,{value:d,onValueChange:I=>{p(I),C()},children:[u.jsx(er,{id:"diff-revised",children:u.jsx(Mr,{placeholder:"Select document"})}),u.jsx(tr,{children:l.map(I=>u.jsx(En,{value:I.name,children:I.name},I.name))})]})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(Gn,{htmlFor:"diff-author",children:"Revision author"}),u.jsx(ei,{id:"diff-author",value:h,onChange:I=>{m(I.target.value),C()},placeholder:"playground"})]}),x&&u.jsx("p",{className:"text-sm text-destructive",role:"alert",children:x}),g&&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(Vt,{variant:"secondary",children:[g.tracked.inserted," inserted"]}),u.jsxs(Vt,{variant:"secondary",children:[g.tracked.deleted," deleted"]}),u.jsxs(Vt,{variant:"secondary",children:[g.tracked.modified," modified"]}),u.jsxs("span",{className:"text-muted-foreground text-xs",children:[g.unchangedBlocks," blocks unchanged"]})]}),N===0&&g.untracked.length===0&&u.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),g.untracked.length>0&&u.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[u.jsxs("p",{className:"font-medium text-amber-600 dark:text-amber-500",children:[g.untracked.length," change(s) not expressible as tracked changes:"]}),g.untracked.map((I,A)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:[I.path," [",I.component,"] ",I.detail]},A))]}),g.notes.map((I,A)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",I]},A))]})]}),u.jsx(Cn,{children:g&&N+g.untracked.length>0?u.jsxs(we,{onClick:K,children:[u.jsx(Vm,{className:"size-4 mr-1"}),"Open redline"]}):u.jsxs(we,{onClick:$,disabled:w||!c||!d||c===d,children:[w&&u.jsx(Yt,{className:"size-4 mr-1"}),"Compare"]})})]})})};var ti=e=>e.type==="checkbox",kn=e=>e instanceof Date,ct=e=>e==null;const dd=e=>typeof e=="object";var Xe=e=>!ct(e)&&!Array.isArray(e)&&dd(e)&&!kn(e),fd=e=>Xe(e)&&e.target?ti(e.target)?e.target.checked:e.target.value:e,zg=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,pd=(e,t)=>e.has(zg(t)),Tg=e=>{const t=e.constructor&&e.constructor.prototype;return Xe(t)&&t.hasOwnProperty("isPrototypeOf")},qa=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mt(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(!(qa&&(e instanceof Blob||r))&&(n||Xe(e)))if(t=n?[]:{},!n&&!Tg(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=mt(e[i]));else return e;return t}var os=e=>Array.isArray(e)?e.filter(Boolean):[],Ye=e=>e===void 0,ae=(e,t,n)=>{if(!t||!Xe(e))return n;const r=os(t.split(/[,[\].]+?/)).reduce((i,s)=>ct(i)?i:i[s],e);return Ye(r)||r===e?Ye(e[t])?n:e[t]:r},Ct=e=>typeof e=="boolean",Wa=e=>/^\w*$/.test(e),hd=e=>os(e.replace(/["|']|\]/g,"").split(/\.|\[/)),De=(e,t,n)=>{let r=-1;const i=Wa(t)?[t]:hd(t),s=i.length,a=s-1;for(;++r<s;){const o=i[r];let l=n;if(r!==a){const c=e[o];l=Xe(c)||Array.isArray(c)?c:isNaN(+i[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=l,e=e[o]}return e};const Ti={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ot={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Gt={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},md=Ee.createContext(null),ls=()=>Ee.useContext(md),Ag=e=>{const{children:t,...n}=e;return Ee.createElement(md.Provider,{value:n},t)};var gd=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const a=s;return t._proxyFormState[a]!==Ot.all&&(t._proxyFormState[a]=!r||Ot.all),n&&(n[a]=!0),e[a]}});return i},gt=e=>Xe(e)&&!Object.keys(e).length,xd=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return gt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(a=>t[a]===(!r||Ot.all))},zr=e=>Array.isArray(e)?e:[e],yd=(e,t,n)=>!e||!t||e===t||zr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Ga(e){const t=Ee.useRef(e);t.current=e,Ee.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function Pg(e){const t=ls(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[a,o]=Ee.useState(n._formState),l=Ee.useRef(!0),c=Ee.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=Ee.useRef(i);return f.current=i,Ga({disabled:r,next:d=>l.current&&yd(f.current,d.name,s)&&xd(d,c.current,n._updateFormState)&&o({...n._formState,...d}),subject:n._subjects.state}),Ee.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),Ee.useMemo(()=>gd(a,n,c.current,!1),[a,n])}var Bt=e=>typeof e=="string",bd=(e,t,n,r,i)=>Bt(e)?(r&&t.watch.add(e),ae(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),ae(n,s))):(r&&(t.watchAll=!0),n);function Og(e){const t=ls(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:a}=e||{},o=Ee.useRef(r);o.current=r,Ga({disabled:s,subject:n._subjects.values,next:f=>{yd(o.current,f.name,a)&&c(mt(bd(o.current,n._names,f.values||n._formValues,!1,i)))}});const[l,c]=Ee.useState(n._getWatch(r,i));return Ee.useEffect(()=>n._removeUnmounted()),l}function Dg(e){const t=ls(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,a=pd(i._names.array,n),o=Og({control:i,name:n,defaultValue:ae(i._formValues,n,ae(i._defaultValues,n,e.defaultValue)),exact:!0}),l=Pg({control:i,name:n,exact:!0}),c=Ee.useRef(i.register(n,{...e.rules,value:o,...Ct(e.disabled)?{disabled:e.disabled}:{}})),f=Ee.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ae(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!ae(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ae(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ae(l.validatingFields,n)},error:{enumerable:!0,get:()=>ae(l.errors,n)}}),[l,n]),d=Ee.useMemo(()=>({name:n,value:o,...Ct(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p=>c.current.onChange({target:{value:fd(p),name:n},type:Ti.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:ae(i._formValues,n),name:n},type:Ti.BLUR}),ref:p=>{const h=ae(i._fields,n);h&&p&&(h._f.ref={focus:()=>p.focus(),select:()=>p.select(),setCustomValidity:m=>p.setCustomValidity(m),reportValidity:()=>p.reportValidity()})}}),[n,i._formValues,r,l.disabled,o,i._fields]);return Ee.useEffect(()=>{const p=i._options.shouldUnregister||s,h=(m,w)=>{const S=ae(i._fields,m);S&&S._f&&(S._f.mount=w)};if(h(n,!0),p){const m=mt(ae(i._options.defaultValues,n));De(i._defaultValues,n,m),Ye(ae(i._formValues,n))&&De(i._formValues,n,m)}return!a&&i.register(n),()=>{(a?p&&!i._state.action:p)?i.unregister(n):h(n,!1)}},[n,i,a,s]),Ee.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),Ee.useMemo(()=>({field:d,formState:l,fieldState:f}),[d,l,f])}const Rg=e=>e.render(Dg(e));var Mg=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Uo=e=>({isOnSubmit:!e||e===Ot.onSubmit,isOnBlur:e===Ot.onBlur,isOnChange:e===Ot.onChange,isOnAll:e===Ot.all,isOnTouch:e===Ot.onTouched}),Jo=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Tr=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=ae(e,i);if(s){const{_f:a,...o}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],i)&&!r)return!0;if(a.ref&&t(a.ref,a.name)&&!r)return!0;if(Tr(o,t))break}else if(Xe(o)&&Tr(o,t))break}}};var $g=(e,t,n)=>{const r=zr(ae(e,n));return De(r,"root",t[n]),De(e,n,r),e},Ka=e=>e.type==="file",Zt=e=>typeof e=="function",Ai=e=>{if(!qa)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},wi=e=>Bt(e),Ya=e=>e.type==="radio",Pi=e=>e instanceof RegExp;const Ho={value:!1,isValid:!1},qo={value:!0,isValid:!0};var vd=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&&!Ye(e[0].attributes.value)?Ye(e[0].value)||e[0].value===""?qo:{value:e[0].value,isValid:!0}:qo:Ho}return Ho};const Wo={isValid:!1,value:null};var wd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,Wo):Wo;function Go(e,t,n="validate"){if(wi(e)||Array.isArray(e)&&e.every(wi)||Ct(e)&&!e)return{type:n,message:wi(e)?e:"",ref:t}}var On=e=>Xe(e)&&!Pi(e)?e:{value:e,message:""},Ko=async(e,t,n,r,i,s)=>{const{ref:a,refs:o,required:l,maxLength:c,minLength:f,min:d,max:p,pattern:h,validate:m,name:w,valueAsNumber:S,mount:x}=e._f,_=ae(n,w);if(!x||t.has(w))return{};const g=o?o[0]:a,z=A=>{i&&g.reportValidity&&(g.setCustomValidity(Ct(A)?"":A||""),g.reportValidity())},E={},k=Ya(a),C=ti(a),$=k||C,K=(S||Ka(a))&&Ye(a.value)&&Ye(_)||Ai(a)&&a.value===""||_===""||Array.isArray(_)&&!_.length,N=Mg.bind(null,w,r,E),I=(A,B,D,T=Gt.maxLength,P=Gt.minLength)=>{const J=A?B:D;E[w]={type:A?T:P,message:J,ref:a,...N(A?T:P,J)}};if(s?!Array.isArray(_)||!_.length:l&&(!$&&(K||ct(_))||Ct(_)&&!_||C&&!vd(o).isValid||k&&!wd(o).isValid)){const{value:A,message:B}=wi(l)?{value:!!l,message:l}:On(l);if(A&&(E[w]={type:Gt.required,message:B,ref:g,...N(Gt.required,B)},!r))return z(B),E}if(!K&&(!ct(d)||!ct(p))){let A,B;const D=On(p),T=On(d);if(!ct(_)&&!isNaN(_)){const P=a.valueAsNumber||_&&+_;ct(D.value)||(A=P>D.value),ct(T.value)||(B=P<T.value)}else{const P=a.valueAsDate||new Date(_),J=v=>new Date(new Date().toDateString()+" "+v),R=a.type=="time",q=a.type=="week";Bt(D.value)&&_&&(A=R?J(_)>J(D.value):q?_>D.value:P>new Date(D.value)),Bt(T.value)&&_&&(B=R?J(_)<J(T.value):q?_<T.value:P<new Date(T.value))}if((A||B)&&(I(!!A,D.message,T.message,Gt.max,Gt.min),!r))return z(E[w].message),E}if((c||f)&&!K&&(Bt(_)||s&&Array.isArray(_))){const A=On(c),B=On(f),D=!ct(A.value)&&_.length>+A.value,T=!ct(B.value)&&_.length<+B.value;if((D||T)&&(I(D,A.message,B.message),!r))return z(E[w].message),E}if(h&&!K&&Bt(_)){const{value:A,message:B}=On(h);if(Pi(A)&&!_.match(A)&&(E[w]={type:Gt.pattern,message:B,ref:a,...N(Gt.pattern,B)},!r))return z(B),E}if(m){if(Zt(m)){const A=await m(_,n),B=Go(A,g);if(B&&(E[w]={...B,...N(Gt.validate,B.message)},!r))return z(B.message),E}else if(Xe(m)){let A={};for(const B in m){if(!gt(A)&&!r)break;const D=Go(await m[B](_,n),g,B);D&&(A={...D,...N(B,D.message)},z(D.message),r&&(E[w]=A))}if(!gt(A)&&(E[w]={ref:g,...A},!r))return E}}return z(!0),E};function Fg(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Ye(e)?r++:e[t[r++]];return e}function Lg(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ye(e[t]))return!1;return!0}function rt(e,t){const n=Array.isArray(t)?t:Wa(t)?[t]:hd(t),r=n.length===1?e:Fg(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Xe(r)&>(r)||Array.isArray(r)&&Lg(r))&&rt(e,n.slice(0,-1)),e}var Cs=()=>{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=[]}}},pa=e=>ct(e)||!dd(e);function sn(e,t){if(pa(e)||pa(t))return e===t;if(kn(e)&&kn(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const a=t[i];if(kn(s)&&kn(a)||Xe(s)&&Xe(a)||Array.isArray(s)&&Array.isArray(a)?!sn(s,a):s!==a)return!1}}return!0}var kd=e=>e.type==="select-multiple",Zg=e=>Ya(e)||ti(e),Es=e=>Ai(e)&&e.isConnected,Sd=e=>{for(const t in e)if(Zt(e[t]))return!0;return!1};function Oi(e,t={}){const n=Array.isArray(e);if(Xe(e)||n)for(const r in e)Array.isArray(e[r])||Xe(e[r])&&!Sd(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Oi(e[r],t[r])):ct(e[r])||(t[r]=!0);return t}function _d(e,t,n){const r=Array.isArray(e);if(Xe(e)||r)for(const i in e)Array.isArray(e[i])||Xe(e[i])&&!Sd(e[i])?Ye(t)||pa(n[i])?n[i]=Array.isArray(e[i])?Oi(e[i],[]):{...Oi(e[i])}:_d(e[i],ct(t)?{}:t[i],n[i]):n[i]=!sn(e[i],t[i]);return n}var pr=(e,t)=>_d(e,t,Oi(t)),jd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ye(e)?e:t?e===""?NaN:e&&+e:n&&Bt(e)?new Date(e):r?r(e):e;function Is(e){const t=e.ref;return Ka(t)?t.files:Ya(t)?wd(e.refs).value:kd(t)?[...t.selectedOptions].map(({value:n})=>n):ti(t)?vd(e.refs).value:jd(Ye(t.value)?e.ref.value:t.value,e)}var Bg=(e,t,n,r)=>{const i={};for(const s of e){const a=ae(t,s);a&&De(i,s,a._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},hr=e=>Ye(e)?e:Pi(e)?e.source:Xe(e)?Pi(e.value)?e.value.source:e.value:e;const Yo="AsyncFunction";var Vg=e=>!!e&&!!e.validate&&!!(Zt(e.validate)&&e.validate.constructor.name===Yo||Xe(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===Yo)),Ug=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Xo(e,t,n){const r=ae(e,n);if(r||Wa(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),a=ae(t,s),o=ae(e,s);if(a&&!Array.isArray(a)&&n!==s)return{name:n};if(o&&o.type)return{name:s,error:o};i.pop()}return{name:n}}var Jg=(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,Hg=(e,t)=>!os(ae(e,t)).length&&rt(e,t);const qg={mode:Ot.onSubmit,reValidateMode:Ot.onChange,shouldFocusError:!0};function Wg(e={}){let t={...qg,...e},n={submitCount:0,isDirty:!1,isLoading:Zt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=Xe(t.defaultValues)||Xe(t.values)?mt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:mt(i),a={action:!1,mount:!1,watch:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:Cs(),array:Cs(),state:Cs()},p=Uo(t.mode),h=Uo(t.reValidateMode),m=t.criteriaMode===Ot.all,w=j=>O=>{clearTimeout(c),c=setTimeout(j,O)},S=async j=>{if(!t.disabled&&(f.isValid||j)){const O=t.resolver?gt((await $()).errors):await N(r,!0);O!==n.isValid&&d.state.next({isValid:O})}},x=(j,O)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((j||Array.from(o.mount)).forEach(Z=>{Z&&(O?De(n.validatingFields,Z,O):rt(n.validatingFields,Z))}),d.state.next({validatingFields:n.validatingFields,isValidating:!gt(n.validatingFields)}))},_=(j,O=[],Z,re,ee=!0,Q=!0)=>{if(re&&Z&&!t.disabled){if(a.action=!0,Q&&Array.isArray(ae(r,j))){const pe=Z(ae(r,j),re.argA,re.argB);ee&&De(r,j,pe)}if(Q&&Array.isArray(ae(n.errors,j))){const pe=Z(ae(n.errors,j),re.argA,re.argB);ee&&De(n.errors,j,pe),Hg(n.errors,j)}if(f.touchedFields&&Q&&Array.isArray(ae(n.touchedFields,j))){const pe=Z(ae(n.touchedFields,j),re.argA,re.argB);ee&&De(n.touchedFields,j,pe)}f.dirtyFields&&(n.dirtyFields=pr(i,s)),d.state.next({name:j,isDirty:A(j,O),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else De(s,j,O)},g=(j,O)=>{De(n.errors,j,O),d.state.next({errors:n.errors})},z=j=>{n.errors=j,d.state.next({errors:n.errors,isValid:!1})},E=(j,O,Z,re)=>{const ee=ae(r,j);if(ee){const Q=ae(s,j,Ye(Z)?ae(i,j):Z);Ye(Q)||re&&re.defaultChecked||O?De(s,j,O?Q:Is(ee._f)):T(j,Q),a.mount&&S()}},k=(j,O,Z,re,ee)=>{let Q=!1,pe=!1;const ve={name:j};if(!t.disabled){const L=!!(ae(r,j)&&ae(r,j)._f&&ae(r,j)._f.disabled);if(!Z||re){f.isDirty&&(pe=n.isDirty,n.isDirty=ve.isDirty=A(),Q=pe!==ve.isDirty);const G=L||sn(ae(i,j),O);pe=!!(!L&&ae(n.dirtyFields,j)),G||L?rt(n.dirtyFields,j):De(n.dirtyFields,j,!0),ve.dirtyFields=n.dirtyFields,Q=Q||f.dirtyFields&&pe!==!G}if(Z){const G=ae(n.touchedFields,j);G||(De(n.touchedFields,j,Z),ve.touchedFields=n.touchedFields,Q=Q||f.touchedFields&&G!==Z)}Q&&ee&&d.state.next(ve)}return Q?ve:{}},C=(j,O,Z,re)=>{const ee=ae(n.errors,j),Q=f.isValid&&Ct(O)&&n.isValid!==O;if(t.delayError&&Z?(l=w(()=>g(j,Z)),l(t.delayError)):(clearTimeout(c),l=null,Z?De(n.errors,j,Z):rt(n.errors,j)),(Z?!sn(ee,Z):ee)||!gt(re)||Q){const pe={...re,...Q&&Ct(O)?{isValid:O}:{},errors:n.errors,name:j};n={...n,...pe},d.state.next(pe)}},$=async j=>{x(j,!0);const O=await t.resolver(s,t.context,Bg(j||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return x(j),O},K=async j=>{const{errors:O}=await $(j);if(j)for(const Z of j){const re=ae(O,Z);re?De(n.errors,Z,re):rt(n.errors,Z)}else n.errors=O;return O},N=async(j,O,Z={valid:!0})=>{for(const re in j){const ee=j[re];if(ee){const{_f:Q,...pe}=ee;if(Q){const ve=o.array.has(Q.name),L=ee._f&&Vg(ee._f);L&&f.validatingFields&&x([re],!0);const G=await Ko(ee,o.disabled,s,m,t.shouldUseNativeValidation&&!O,ve);if(L&&f.validatingFields&&x([re]),G[Q.name]&&(Z.valid=!1,O))break;!O&&(ae(G,Q.name)?ve?$g(n.errors,G,Q.name):De(n.errors,Q.name,G[Q.name]):rt(n.errors,Q.name))}!gt(pe)&&await N(pe,O,Z)}}return Z.valid},I=()=>{for(const j of o.unMount){const O=ae(r,j);O&&(O._f.refs?O._f.refs.every(Z=>!Es(Z)):!Es(O._f.ref))&&ne(j)}o.unMount=new Set},A=(j,O)=>!t.disabled&&(j&&O&&De(s,j,O),!sn(fe(),i)),B=(j,O,Z)=>bd(j,o,{...a.mount?s:Ye(O)?i:Bt(j)?{[j]:O}:O},Z,O),D=j=>os(ae(a.mount?s:i,j,t.shouldUnregister?ae(i,j,[]):[])),T=(j,O,Z={})=>{const re=ae(r,j);let ee=O;if(re){const Q=re._f;Q&&(!Q.disabled&&De(s,j,jd(O,Q)),ee=Ai(Q.ref)&&ct(O)?"":O,kd(Q.ref)?[...Q.ref.options].forEach(pe=>pe.selected=ee.includes(pe.value)):Q.refs?ti(Q.ref)?Q.refs.length>1?Q.refs.forEach(pe=>(!pe.defaultChecked||!pe.disabled)&&(pe.checked=Array.isArray(ee)?!!ee.find(ve=>ve===pe.value):ee===pe.value)):Q.refs[0]&&(Q.refs[0].checked=!!ee):Q.refs.forEach(pe=>pe.checked=pe.value===ee):Ka(Q.ref)?Q.ref.value="":(Q.ref.value=ee,Q.ref.type||d.values.next({name:j,values:{...s}})))}(Z.shouldDirty||Z.shouldTouch)&&k(j,ee,Z.shouldTouch,Z.shouldDirty,!0),Z.shouldValidate&&v(j)},P=(j,O,Z)=>{for(const re in O){const ee=O[re],Q=`${j}.${re}`,pe=ae(r,Q);(o.array.has(j)||Xe(ee)||pe&&!pe._f)&&!kn(ee)?P(Q,ee,Z):T(Q,ee,Z)}},J=(j,O,Z={})=>{const re=ae(r,j),ee=o.array.has(j),Q=mt(O);De(s,j,Q),ee?(d.array.next({name:j,values:{...s}}),(f.isDirty||f.dirtyFields)&&Z.shouldDirty&&d.state.next({name:j,dirtyFields:pr(i,s),isDirty:A(j,Q)})):re&&!re._f&&!ct(Q)?P(j,Q,Z):T(j,Q,Z),Jo(j,o)&&d.state.next({...n}),d.values.next({name:a.mount?j:void 0,values:{...s}})},R=async j=>{a.mount=!0;const O=j.target;let Z=O.name,re=!0;const ee=ae(r,Z),Q=()=>O.type?Is(ee._f):fd(j),pe=ve=>{re=Number.isNaN(ve)||kn(ve)&&isNaN(ve.getTime())||sn(ve,ae(s,Z,ve))};if(ee){let ve,L;const G=Q(),he=j.type===Ti.BLUR||j.type===Ti.FOCUS_OUT,Se=!Ug(ee._f)&&!t.resolver&&!ae(n.errors,Z)&&!ee._f.deps||Jg(he,ae(n.touchedFields,Z),n.isSubmitted,h,p),M=Jo(Z,o,he);De(s,Z,G),he?(ee._f.onBlur&&ee._f.onBlur(j),l&&l(0)):ee._f.onChange&&ee._f.onChange(j);const me=k(Z,G,he,!1),Ce=!gt(me)||M;if(!he&&d.values.next({name:Z,type:j.type,values:{...s}}),Se)return f.isValid&&(t.mode==="onBlur"&&he?S():he||S()),Ce&&d.state.next({name:Z,...M?{}:me});if(!he&&M&&d.state.next({...n}),t.resolver){const{errors:$e}=await $([Z]);if(pe(G),re){const nt=Xo(n.errors,r,Z),et=Xo($e,r,nt.name||Z);ve=et.error,Z=et.name,L=gt($e)}}else x([Z],!0),ve=(await Ko(ee,o.disabled,s,m,t.shouldUseNativeValidation))[Z],x([Z]),pe(G),re&&(ve?L=!1:f.isValid&&(L=await N(r,!0)));re&&(ee._f.deps&&v(ee._f.deps),C(Z,L,ve,me))}},q=(j,O)=>{if(ae(n.errors,O)&&j.focus)return j.focus(),1},v=async(j,O={})=>{let Z,re;const ee=zr(j);if(t.resolver){const Q=await K(Ye(j)?j:ee);Z=gt(Q),re=j?!ee.some(pe=>ae(Q,pe)):Z}else j?(re=(await Promise.all(ee.map(async Q=>{const pe=ae(r,Q);return await N(pe&&pe._f?{[Q]:pe}:pe)}))).every(Boolean),!(!re&&!n.isValid)&&S()):re=Z=await N(r);return d.state.next({...!Bt(j)||f.isValid&&Z!==n.isValid?{}:{name:j},...t.resolver||!j?{isValid:Z}:{},errors:n.errors}),O.shouldFocus&&!re&&Tr(r,q,j?ee:o.mount),re},fe=j=>{const O={...a.mount?s:i};return Ye(j)?O:Bt(j)?ae(O,j):j.map(Z=>ae(O,Z))},ue=(j,O)=>({invalid:!!ae((O||n).errors,j),isDirty:!!ae((O||n).dirtyFields,j),error:ae((O||n).errors,j),isValidating:!!ae(n.validatingFields,j),isTouched:!!ae((O||n).touchedFields,j)}),b=j=>{j&&zr(j).forEach(O=>rt(n.errors,O)),d.state.next({errors:j?n.errors:{}})},Y=(j,O,Z)=>{const re=(ae(r,j,{_f:{}})._f||{}).ref,ee=ae(n.errors,j)||{},{ref:Q,message:pe,type:ve,...L}=ee;De(n.errors,j,{...L,...O,ref:re}),d.state.next({name:j,errors:n.errors,isValid:!1}),Z&&Z.shouldFocus&&re&&re.focus&&re.focus()},oe=(j,O)=>Zt(j)?d.values.subscribe({next:Z=>j(B(void 0,O),Z)}):B(j,O,!0),ne=(j,O={})=>{for(const Z of j?zr(j):o.mount)o.mount.delete(Z),o.array.delete(Z),O.keepValue||(rt(r,Z),rt(s,Z)),!O.keepError&&rt(n.errors,Z),!O.keepDirty&&rt(n.dirtyFields,Z),!O.keepTouched&&rt(n.touchedFields,Z),!O.keepIsValidating&&rt(n.validatingFields,Z),!t.shouldUnregister&&!O.keepDefaultValue&&rt(i,Z);d.values.next({values:{...s}}),d.state.next({...n,...O.keepDirty?{isDirty:A()}:{}}),!O.keepIsValid&&S()},ie=({disabled:j,name:O,field:Z,fields:re})=>{(Ct(j)&&a.mount||j||o.disabled.has(O))&&(j?o.disabled.add(O):o.disabled.delete(O),k(O,Is(Z?Z._f:ae(re,O)._f),!1,!1,!0))},W=(j,O={})=>{let Z=ae(r,j);const re=Ct(O.disabled)||Ct(t.disabled);return De(r,j,{...Z||{},_f:{...Z&&Z._f?Z._f:{ref:{name:j}},name:j,mount:!0,...O}}),o.mount.add(j),Z?ie({field:Z,disabled:Ct(O.disabled)?O.disabled:t.disabled,name:j}):E(j,!0,O.value),{...re?{disabled:O.disabled||t.disabled}:{},...t.progressive?{required:!!O.required,min:hr(O.min),max:hr(O.max),minLength:hr(O.minLength),maxLength:hr(O.maxLength),pattern:hr(O.pattern)}:{},name:j,onChange:R,onBlur:R,ref:ee=>{if(ee){W(j,O),Z=ae(r,j);const Q=Ye(ee.value)&&ee.querySelectorAll&&ee.querySelectorAll("input,select,textarea")[0]||ee,pe=Zg(Q),ve=Z._f.refs||[];if(pe?ve.find(L=>L===Q):Q===Z._f.ref)return;De(r,j,{_f:{...Z._f,...pe?{refs:[...ve.filter(Es),Q,...Array.isArray(ae(i,j))?[{}]:[]],ref:{type:Q.type,name:j}}:{ref:Q}}}),E(j,!1,void 0,Q)}else Z=ae(r,j,{}),Z._f&&(Z._f.mount=!1),(t.shouldUnregister||O.shouldUnregister)&&!(pd(o.array,j)&&a.action)&&o.unMount.add(j)}}},F=()=>t.shouldFocusError&&Tr(r,q,o.mount),te=j=>{Ct(j)&&(d.state.next({disabled:j}),Tr(r,(O,Z)=>{const re=ae(r,Z);re&&(O.disabled=re._f.disabled||j,Array.isArray(re._f.refs)&&re._f.refs.forEach(ee=>{ee.disabled=re._f.disabled||j}))},0,!1))},V=(j,O)=>async Z=>{let re;Z&&(Z.preventDefault&&Z.preventDefault(),Z.persist&&Z.persist());let ee=mt(s);if(o.disabled.size)for(const Q of o.disabled)De(ee,Q,void 0);if(d.state.next({isSubmitting:!0}),t.resolver){const{errors:Q,values:pe}=await $();n.errors=Q,ee=pe}else await N(r);if(rt(n.errors,"root"),gt(n.errors)){d.state.next({errors:{}});try{await j(ee,Z)}catch(Q){re=Q}}else O&&await O({...n.errors},Z),F(),setTimeout(F);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:gt(n.errors)&&!re,submitCount:n.submitCount+1,errors:n.errors}),re)throw re},de=(j,O={})=>{ae(r,j)&&(Ye(O.defaultValue)?J(j,mt(ae(i,j))):(J(j,O.defaultValue),De(i,j,mt(O.defaultValue))),O.keepTouched||rt(n.touchedFields,j),O.keepDirty||(rt(n.dirtyFields,j),n.isDirty=O.defaultValue?A(j,mt(ae(i,j))):A()),O.keepError||(rt(n.errors,j),f.isValid&&S()),d.state.next({...n}))},le=(j,O={})=>{const Z=j?mt(j):i,re=mt(Z),ee=gt(j),Q=ee?i:re;if(O.keepDefaultValues||(i=Z),!O.keepValues){if(O.keepDirtyValues){const pe=new Set([...o.mount,...Object.keys(pr(i,s))]);for(const ve of Array.from(pe))ae(n.dirtyFields,ve)?De(Q,ve,ae(s,ve)):J(ve,ae(Q,ve))}else{if(qa&&Ye(j))for(const pe of o.mount){const ve=ae(r,pe);if(ve&&ve._f){const L=Array.isArray(ve._f.refs)?ve._f.refs[0]:ve._f.ref;if(Ai(L)){const G=L.closest("form");if(G){G.reset();break}}}}r={}}s=t.shouldUnregister?O.keepDefaultValues?mt(i):{}:mt(Q),d.array.next({values:{...Q}}),d.values.next({values:{...Q}})}o={mount:O.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!f.isValid||!!O.keepIsValid||!!O.keepDirtyValues,a.watch=!!t.shouldUnregister,d.state.next({submitCount:O.keepSubmitCount?n.submitCount:0,isDirty:ee?!1:O.keepDirty?n.isDirty:!!(O.keepDefaultValues&&!sn(j,i)),isSubmitted:O.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ee?{}:O.keepDirtyValues?O.keepDefaultValues&&s?pr(i,s):n.dirtyFields:O.keepDefaultValues&&j?pr(i,j):O.keepDirty?n.dirtyFields:{},touchedFields:O.keepTouched?n.touchedFields:{},errors:O.keepErrors?n.errors:{},isSubmitSuccessful:O.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},ye=(j,O)=>le(Zt(j)?j(s):j,O);return{control:{register:W,unregister:ne,getFieldState:ue,handleSubmit:V,setError:Y,_executeSchema:$,_getWatch:B,_getDirty:A,_updateValid:S,_removeUnmounted:I,_updateFieldArray:_,_updateDisabledField:ie,_getFieldArray:D,_reset:le,_resetDefaultValues:()=>Zt(t.defaultValues)&&t.defaultValues().then(j=>{ye(j,t.resetOptions),d.state.next({isLoading:!1})}),_updateFormState:j=>{n={...n,...j}},_disableForm:te,_subjects:d,_proxyFormState:f,_setErrors:z,get _fields(){return r},get _formValues(){return s},get _state(){return a},set _state(j){a=j},get _defaultValues(){return i},get _names(){return o},set _names(j){o=j},get _formState(){return n},set _formState(j){n=j},get _options(){return t},set _options(j){t={...t,...j}}},trigger:v,register:W,handleSubmit:V,watch:oe,setValue:J,getValues:fe,reset:ye,resetField:de,clearErrors:b,unregister:ne,setError:Y,setFocus:(j,O={})=>{const Z=ae(r,j),re=Z&&Z._f;if(re){const ee=re.refs?re.refs[0]:re.ref;ee.focus&&(ee.focus(),O.shouldSelect&&Zt(ee.select)&&ee.select())}},getFieldState:ue}}function Gg(e={}){const t=Ee.useRef(void 0),n=Ee.useRef(void 0),[r,i]=Ee.useState({isDirty:!1,isValidating:!1,isLoading:Zt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Zt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Wg(e),formState:r});const s=t.current.control;return s._options=e,Ga({subject:s._subjects.state,next:a=>{xd(a,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),Ee.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Ee.useEffect(()=>{if(s._proxyFormState.isDirty){const a=s._getDirty();a!==r.isDirty&&s._subjects.state.next({isDirty:a})}},[s,r.isDirty]),Ee.useEffect(()=>{e.values&&!sn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(a=>({...a}))):s._resetDefaultValues()},[e.values,s]),Ee.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Ee.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()}),Ee.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=gd(r,s),t.current}function Kg(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 Yg=Ag,Nd=y.createContext({}),Qo=({...e})=>u.jsx(Nd.Provider,{value:{name:e.name},children:u.jsx(Rg,{...e})}),us=()=>{const e=y.useContext(Nd),t=y.useContext(Cd),{getFieldState:n,formState:r}=ls(),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}},Cd=y.createContext({}),ha=y.forwardRef(({className:e,...t},n)=>{const r=y.useId();return u.jsx(Cd.Provider,{value:{id:r},children:u.jsx("div",{ref:n,className:H("space-y-2",e),...t})})});ha.displayName="FormItem";const ma=y.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=us();return u.jsx(Gn,{ref:n,className:H(r&&"text-destructive",e),htmlFor:i,...t})});ma.displayName="FormLabel";const ga=y.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=us();return u.jsx(or,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});ga.displayName="FormControl";const Ed=y.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=us();return u.jsx("p",{ref:n,id:r,className:H("text-muted-foreground text-[0.8rem]",e),...t})});Ed.displayName="FormDescription";const xa=y.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=us(),a=i?String(i==null?void 0:i.message):t;return a?u.jsx("p",{ref:r,id:s,className:H("text-destructive text-[0.8rem] font-medium",e),...n,children:a}):null});xa.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 Id=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Xg=(e=Id())=>yg()(bg(vg((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,a)=>a!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),a={id:i,documentName:r,title:Xa(),messages:[],createdAt:s,updatedAt:s};return t(o=>({threads:{...o.threads,[i]:a},activeThreadId:{...o.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const a=Object.fromEntries(Object.entries(i.threads).filter(([c])=>c!==r)),o=s.documentName,l={...i.activeThreadId};if(l[o]===r){const c=Object.values(a).filter(f=>f.documentName===o);c.length>0?(c.sort((f,d)=>d.updatedAt-f.updatedAt),l[o]=c[0].id):delete l[o]}t({threads:a,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(a=>({activeThreadId:{...a.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const a=s.threads[r];return a?{threads:{...s.threads,[r]:{...a,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},a={...i.activeThreadId};for(const[o,l]of Object.entries(s))l.documentName===r&&delete s[o];return delete a[r],{threads:s,activeThreadId:a}})},renameThreadsForDocument:(r,i)=>{t(s=>{const a={...s.threads},o={...s.activeThreadId};for(const[l,c]of Object.entries(a))c.documentName===r&&(a[l]={...c,documentName:i});return r in o&&(o[i]=o[r],delete o[r]),{threads:a,activeThreadId:o}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:wg(()=>fg),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}}))),zd=y.createContext(void 0),Qg=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=Xg(Id())),u.jsx(zd.Provider,{value:t.current,children:e})},Te=e=>{const t=y.useContext(zd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return kg(t,e)};function ex(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function tx(e,t,n){const r={},i=[];e!=="delete"&&(r.name=oi.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=oi.Optional(oi.String({description:"Template selection"})));const s=oi.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:a=>{const o=[];if(!Dm(s,a))for(const c of Rm(s,a))o.push({path:c.path.replace(/^\//,""),message:c.message});const l=a;if(e!=="delete"&&l.name){const c=l.name.trim();c?(l.name=c,t(c)||o.push({path:"name",message:"Document with this name already exists"})):o.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&l.template&&(n.some(c=>c.name===l.template)||o.push({path:"template",message:"You must select a valid template"})),{success:o.length===0,data:o.length===0?l:void 0,errors:o}}}}function nx(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const rx=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"}}),mr="__empty__";function ix({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:a}){const[o,l]=y.useState(!1),[c,f]=y.useState(null),d=rx(a),{documents:p,openTabs:h,createDocument:m,renameDocument:w,deleteDocument:S,openDocument:x,closeDocument:_}=Ae(R=>R),{updateTheme:g,removeTheme:z}=da(R=>R),E=Te(R=>R.renameThreadsForDocument),k=Te(R=>R.deleteThreadsForDocument),C=y.useMemo(()=>a?s||[]:i||[],[a,i,s]),$=y.useMemo(()=>{const R={current:[],downstream:[]};return C.forEach(q=>{R[q.location]&&R[q.location].push(q)}),R},[C]),K=y.useMemo(()=>C.map(R=>({name:R.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[C]),N=y.useMemo(()=>tx(e,R=>ex(R,p,r),K),[e,p,r,K]),I=N.schema,A=y.useMemo(()=>{const R=new Map;return C.forEach(q=>R.set(q.path,q)),R},[C]),B=mr,D=Gg({resolver:Kg(N.validate),defaultValues:nx(e,void 0,r)}),[T,P]=y.useState(B);y.useEffect(()=>{if(T&&T!==mr&&e==="create"){const R=A.get(T);R&&fetch(`/api/discovery/${a?"themes":"documents"}/${encodeURIComponent(R.name)}/content`).then(q=>{if(!q.ok)throw new Error(`Failed to fetch content: ${q.statusText}`);return q.text()}).then(q=>{try{const v=JSON.parse(q);f(JSON.stringify(v,null,2))}catch(v){console.error("Invalid JSON content received:",v),f(null)}}).catch(q=>{console.error("Failed to fetch content:",q),f(null)})}},[T,e,A,a]),y.useEffect(()=>{t&&(D.reset(),f(null),P(B))},[D,t]);const J=D.handleSubmit(async({name:R,template:q})=>{l(!0);try{if(await new Promise(v=>setTimeout(v,200)),e==="create"){const v=T?A.get(T):C.find(W=>W.name===q);let fe,ue=R;if(a){const W=ue.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-");fe=c||JSON.stringify(yt==="docx"?{name:W,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:{family:"Calibri",size:28},body:{family:"Calibri",size:11}},page:{size:"A4"}}:{name:W,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}},null,2);const te=`.${yt}.theme.json`;ue.endsWith(te)||(ue=ue.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),ue+=te)}else{const W=v;fe=c||JSON.stringify(yt==="docx"?{name:"docx",props:{theme:(W==null?void 0:W.theme)||"default",metadata:{title:(W==null?void 0:W.title)||ue.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(W==null?void 0:W.title)||ue.replace(/\.(json|js)$/i,""),theme:(W==null?void 0:W.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 F=yt==="docx"?".docx.json":".pptx.json";!ue.endsWith(F)&&!ue.endsWith(".json")&&(ue+=F)}const b=ue.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),Y=b?b[0]:"",oe=ue.slice(0,ue.length-Y.length);let ne=ue,ie=1;for(;p.some(W=>W.name===ne);)ie++,ne=`${oe} (${ie})${Y}`;ue=ne,m(ue,fe),x(ue),a&&g(ue,fe)}else if(e==="update"){const v=r,fe=R,ue=h.includes(v);ue&&_(v),w(v,fe),E(v,fe),ue&&x(fe)}else if(e==="delete"){const v=r;_(v),S(v),k(v),a&&z(v)}n()}finally{l(!1)}});return u.jsx(Yg,{...D,children:u.jsxs("form",{onSubmit:J,children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:d[e].title}),u.jsx(cn,{children:d[e].description})]}),u.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[I.properties&&"name"in I.properties&&u.jsx(Qo,{control:D.control,name:"name",render:({field:R})=>u.jsxs(ha,{children:[u.jsx(ma,{children:"Name"}),u.jsx(ga,{children:u.jsx(ei,{placeholder:"Enter a name or select a template below",autoComplete:"off",...R})}),u.jsx(xa,{})]})}),e==="create"&&u.jsx(Qo,{control:D.control,name:"template",render:({field:R})=>u.jsxs(ha,{children:[u.jsx(ma,{children:a?"Base Theme":"Base Document"}),u.jsxs(Rr,{onValueChange:q=>{if(q===mr)R.onChange(void 0),D.setValue("name",""),P(mr),f(null);else{const v=A.get(q);v&&(R.onChange(v.name),D.setValue("name",v.name),P(q))}},defaultValue:B,children:[u.jsx(ga,{children:u.jsx(er,{children:u.jsx(Mr,{placeholder:`Select a discovered ${a?"theme":"document"}`})})}),u.jsxs(tr,{className:"max-h-[300px]",children:[u.jsxs(En,{value:mr,children:["Empty ",a?"theme":"document"]}),Object.entries($).map(([q,v])=>v.length===0?null:u.jsxs(jg,{children:[u.jsx(cd,{children:q==="current"?"📁 Current Directory":"📦 Project"}),v.map(fe=>{let ue;return fe.title&&fe.title!==fe.name?ue=fe.title:fe.description&&(ue=fe.description.length>40?fe.description.substring(0,40)+"...":fe.description),u.jsx(En,{value:fe.path,className:"pl-6",children:u.jsxs("span",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:fe.name}),ue&&u.jsx("span",{className:"text-muted-foreground text-xs",children:ue})]})},fe.path)})]},q))]})]}),u.jsxs(Ed,{children:["Start empty or select a discovered"," ",a?"theme":"document"," as a starting point"]}),u.jsx(xa,{})]})})]}),u.jsx(Cn,{children:u.jsx(we,{type:"submit",variant:d[e].buttonVariant,disabled:o,children:o?u.jsxs(u.Fragment,{children:[u.jsx(Yt,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):d[e].button})})]})})}const Di=Ee.memo(ix),sx=vm,ax=wm,ox=y.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(jc,{ref:i,className:H("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(ss,{className:"ml-auto h-4 w-4"})]}));ox.displayName=jc.displayName;const lx=y.forwardRef(({className:e,...t},n)=>u.jsx(Nc,{ref:n,className:H("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-md border p-1 shadow-lg",e),...t}));lx.displayName=Nc.displayName;const Td=y.forwardRef(({className:e,...t},n)=>u.jsx(km,{children:u.jsx(kc,{ref:n,className:H("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-md border p-1 shadow-md",e),...t})}));Td.displayName=kc.displayName;const kr=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Sc,{ref:r,className:H("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}));kr.displayName=Sc.displayName;const ux=y.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(Cc,{ref:i,className:H("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(Ec,{children:u.jsx(un,{className:"h-4 w-4"})})}),t]}));ux.displayName=Cc.displayName;const cx=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ic,{ref:r,className:H("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(Ec,{children:u.jsx(Kc,{className:"h-4 w-4 fill-current"})})}),t]}));cx.displayName=Ic.displayName;const dx=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(zc,{ref:r,className:H("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));dx.displayName=zc.displayName;const ya=y.forwardRef(({className:e,...t},n)=>u.jsx(_c,{ref:n,className:H("bg-border -mx-1 my-1 h-px",e),...t}));ya.displayName=_c.displayName;const ki=({className:e,...t})=>u.jsx("span",{className:H("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});ki.displayName="ContextMenuShortcut";const Ad=y.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>u.jsx(Tc,{ref:i,decorative:n,orientation:t,className:H("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ad.displayName=Tc.displayName;const Pd=dc,fx=fc,px=pc,Od=y.forwardRef(({className:e,...t},n)=>u.jsx(is,{className:H("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/80",e),...t,ref:n}));Od.displayName=is.displayName;const hx=Qr("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"}}),Qa=y.forwardRef(({side:e="right",className:t,children:n,...r},i)=>u.jsxs(px,{children:[u.jsx(Od,{}),u.jsxs(ts,{ref:i,className:H(hx({side:e}),t),...r,children:[u.jsxs(Ja,{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(Nn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));Qa.displayName=ts.displayName;const mx=y.forwardRef(({className:e,...t},n)=>u.jsx(ns,{ref:n,className:H("text-foreground text-lg font-semibold",e),...t}));mx.displayName=ns.displayName;const gx=y.forwardRef(({className:e,...t},n)=>u.jsx(rs,{ref:n,className:H("text-muted-foreground text-sm",e),...t}));gx.displayName=rs.displayName;function Ar({className:e,...t}){return u.jsx("div",{className:H("bg-primary/10 animate-pulse rounded-md",e),...t})}const zs=768,Ts=1200;function Dd(e){return typeof window<"u"?window.innerWidth<e:!1}function Rd(){const[e,t]=y.useState(()=>Dd(zs));return y.useEffect(()=>{const n=window.matchMedia(`(max-width: ${zs-1}px)`),r=()=>{t(window.innerWidth<zs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function xx(){const[e,t]=y.useState(()=>Dd(Ts));return y.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ts-1}px)`),r=()=>{t(window.innerWidth<Ts)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const yx="sidebar_state",bx=60*60*24*7,vx="16rem",wx="18rem",kx="3rem",Sx="b",Md=y.createContext(null);function cs(){const e=y.useContext(Md);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const $d=y.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...a},o)=>{const l=Rd(),[c,f]=y.useState(!1),[d,p]=y.useState(e),h=t??d,m=y.useCallback(_=>{const g=typeof _=="function"?_(h):_;n?n(g):p(g),document.cookie=`${yx}=${g}; path=/; max-age=${bx}`},[n,h]),w=y.useCallback(()=>l?f(_=>!_):m(_=>!_),[l,m,f]);y.useEffect(()=>{const _=z=>{var C;const E=z;if(!E)return!1;const k=(C=E.tagName)==null?void 0:C.toLowerCase();return k==="input"||k==="textarea"||k==="select"||E.isContentEditable?!0:!!(E.closest&&E.closest(".monaco-editor"))},g=z=>{const E=z.metaKey||z.ctrlKey,k=z.key.toLowerCase();if(E&&k===Sx){z.preventDefault(),w();return}E&&k==="s"&&!_(z.target)&&(z.preventDefault(),w())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[w]);const S=h?"expanded":"collapsed",x=y.useMemo(()=>({state:S,open:h,setOpen:m,isMobile:l,openMobile:c,setOpenMobile:f,toggleSidebar:w}),[S,h,m,l,c,f,w]);return u.jsx(Md.Provider,{value:x,children:u.jsx(Mm,{delayDuration:0,children:u.jsx("div",{style:{"--sidebar-width":vx,"--sidebar-width-icon":kx,...i},className:H("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:o,...a,children:s})})})});$d.displayName="SidebarProvider";const Fd=y.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},a)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:f}=cs();return n==="none"?u.jsx("div",{className:H("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:a,...s,children:i}):o?u.jsx(Pd,{open:c,onOpenChange:f,...s,children:u.jsx(Qa,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":wx},side:e,children:u.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):u.jsxs("div",{ref:a,className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[u.jsx("div",{className:H("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:H("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})})]})});Fd.displayName="Sidebar";const _x=y.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=cs();return u.jsxs(we,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:H("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[u.jsx(Um,{}),u.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});_x.displayName="SidebarTrigger";const jx=y.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=cs();return u.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:H("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})});jx.displayName="SidebarRail";const Nx=y.forwardRef(({className:e,...t},n)=>u.jsx("main",{ref:n,className:H("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}));Nx.displayName="SidebarInset";const Cx=y.forwardRef(({className:e,...t},n)=>u.jsx(ei,{ref:n,"data-sidebar":"input",className:H("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));Cx.displayName="SidebarInput";const Ld=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"header",className:H("flex flex-col gap-2 p-2",e),...t}));Ld.displayName="SidebarHeader";const Zd=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"footer",className:H("flex flex-col gap-2 p-2",e),...t}));Zd.displayName="SidebarFooter";const Bd=y.forwardRef(({className:e,...t},n)=>u.jsx(Ad,{ref:n,"data-sidebar":"separator",className:H("bg-sidebar-border mx-2 w-auto",e),...t}));Bd.displayName="SidebarSeparator";const Vd=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"content",className:H("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Vd.displayName="SidebarContent";const Si=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group",className:H("relative flex w-full min-w-0 flex-col p-2",e),...t}));Si.displayName="SidebarGroup";const _i=y.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?or:"div";return u.jsx(i,{ref:r,"data-sidebar":"group-label",className:H("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})});_i.displayName="SidebarGroupLabel";const Ex=y.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?or:"button";return u.jsx(i,{ref:r,"data-sidebar":"group-action",className:H("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})});Ex.displayName="SidebarGroupAction";const Sr=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group-content",className:H("w-full text-sm",e),...t}));Sr.displayName="SidebarGroupContent";const ba=y.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu",className:H("flex w-full min-w-0 flex-col gap-1",e),...t}));ba.displayName="SidebarMenu";const Ud=y.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,"data-sidebar":"menu-item",className:H("group/menu-item relative",e),...t}));Ud.displayName="SidebarMenuItem";const Ix=Qr("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"}}),Jd=y.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...a},o)=>{const l=e?or:"button",{isMobile:c,state:f}=cs(),d=u.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:H(Ix({variant:n,size:r}),s),...a});return i?(typeof i=="string"&&(i={children:i}),u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:d}),u.jsx(Ke,{side:"right",align:"center",hidden:f!=="collapsed"||c,...i})]})):d});Jd.displayName="SidebarMenuButton";const zx=y.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?or:"button";return u.jsx(s,{ref:i,"data-sidebar":"menu-action",className:H("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})});zx.displayName="SidebarMenuAction";const Tx=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:H("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}));Tx.displayName="SidebarMenuBadge";const Ax=y.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=y.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return u.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:H("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&u.jsx(Ar,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),u.jsx(Ar,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Ax.displayName="SidebarMenuSkeleton";const Px=y.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:H("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}));Px.displayName="SidebarMenuSub";const Ox=y.forwardRef(({...e},t)=>u.jsx("li",{ref:t,...e}));Ox.displayName="SidebarMenuSubItem";const Dx=y.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const a=e?or:"a";return u.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:H("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})});Dx.displayName="SidebarMenuSubButton";function ji(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 Rx=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function Mx({document:e,indicator:t,compact:n=!1}){const r=y.useRef(null),[i,s]=y.useState(!1),[a,o]=y.useState(!1),[l,c]=y.useState(!1),{openDocument:f,documentTypes:d,activeTab:p}=Ae(T=>T),{name:h,text:m,isGenerating:w}=vn(T=>T),x=(d[e.name]||"application/json+report")==="application/json+theme",_=p===e.name,[g,z]=y.useState(h),[E,k]=y.useState(m),C=100,$=0;y.useEffect(()=>{const T=setTimeout(()=>{h&&m?(z(h),k(m)):w||(z(""),k(""))},w?C:$);return()=>clearTimeout(T)},[h,m,w]);const K=g===e.name,N=T=>{var J;const P=new Set;try{const R=JSON.parse(T);(J=R.props)!=null&&J.theme&&P.add(R.props.theme),R.children&&Array.isArray(R.children)&&R.children.forEach(q=>{var v;q.name==="docx"&&((v=q.props)!=null&&v.theme)&&P.add(q.props.theme)})}catch{}return P},I=y.useMemo(()=>{if(!x||!E)return!1;try{const T=JSON.parse(e.text),P=fa(T);if(P)return N(E).has(P)}catch{}return!1},[x,E,e.text,e.name,g]),A=y.useCallback(()=>{o(!1)},[]),B=y.useCallback(()=>{c(!1)},[]),D=u.jsxs(Jd,{variant:"default",size:"default",ref:r,className:H("text-sidebar-foreground focus:bg-accent focus:text-accent-foreground w-full",n?"justify-center px-1":"justify-start gap-2",i&&"bg-accent text-accent-foreground",_&&(n?"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-green-50 border-l-2 border-green-500 text-green-700 dark:bg-green-900/20 dark:border-green-400 dark:text-green-300"),K&&!_&&(n?"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"bg-blue-50 border-l-2 border-blue-500 text-blue-700 dark:bg-blue-900/20 dark:border-blue-400 dark:text-blue-300"),I&&!_&&!K&&(n?"bg-purple-50 text-purple-700 dark:bg-purple-900/20 dark:text-purple-300":"bg-purple-50 border-l-2 border-purple-500 text-purple-700 dark:bg-purple-900/20 dark:border-purple-400 dark:text-purple-300")),title:e.name,onClick:()=>{f(e.name)},onKeyDown:T=>{var P;(T.ctrlKey||T.metaKey)&&T.key==="Enter"?(f(e.name),T.preventDefault()):T.key==="Enter"?(o(!0),T.preventDefault()):T.key==="Backspace"||T.key==="Delete"?(c(!0),T.preventDefault()):T.key==="Escape"&&((P=r.current)==null||P.blur(),T.preventDefault())},children:[_?u.jsx($o,{className:H("size-4","text-green-600 dark:text-green-400")}):K?u.jsx($o,{className:H("size-4","text-blue-600 dark:text-blue-400")}):x?u.jsx(la,{className:"size-4 text-purple-600 dark:text-purple-400"}):u.jsx(Yc,{className:"size-4 text-blue-600 dark:text-blue-400"}),!n&&u.jsx("span",{className:H("truncate flex-1",x&&!_&&!K&&!I&&"text-purple-700 dark:text-purple-300",(_||K||I)&&"font-medium"),children:e.name})]});return u.jsxs(Ud,{children:[u.jsxs(sx,{onOpenChange:s,children:[u.jsx(ax,{children:n?u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:D}),u.jsx(Ke,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[e.name,x?u.jsx("div",{className:"opacity-70",children:"Theme"}):u.jsx("div",{className:"opacity-70",children:"Document"})]})})]}):D}),u.jsxs(Td,{children:[u.jsxs(kr,{onClick:()=>f(e.name),children:["Open",u.jsx(ki,{children:Rx?"⌘⏎":"⌃⏎"})]}),u.jsx(ya,{}),u.jsx(kr,{disabled:!e,onClick:()=>{e&&ji(e.name,new Blob([e.text],{type:e.type}))},children:"Download..."}),u.jsx(ya,{}),u.jsxs(kr,{onClick:()=>o(!0),children:["Rename...",u.jsx(ki,{children:"⏎"})]}),u.jsxs(kr,{onClick:()=>c(!0),children:["Delete",u.jsx(ki,{children:"⌫"})]})]})]}),u.jsx(It,{open:a,onOpenChange:o,children:u.jsx(St,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var P;T.preventDefault(),(P=r.current)==null||P.focus()},children:u.jsx(Di,{mode:"update",shouldReset:!a,postSubmit:A,selectedName:e.name})})}),u.jsx(It,{open:l,onOpenChange:c,children:u.jsx(St,{className:"sm:max-w-[425px]",onCloseAutoFocus:T=>{var P;T.preventDefault(),(P=r.current)==null||P.focus()},children:u.jsx(Di,{mode:"delete",shouldReset:!l,postSubmit:B,selectedName:e.name})})})]})}const el=Ee.memo(Mx);async function $x(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const $r=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ac,{ref:r,className:H("relative overflow-hidden",e),...n,children:[u.jsx(Sm,{className:"h-full w-full rounded-[inherit]",children:t}),u.jsx(Hd,{}),u.jsx(_m,{})]}));$r.displayName=Ac.displayName;const Hd=y.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Pc,{ref:r,orientation:t,className:H("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(jm,{className:"bg-border relative flex-1 rounded-full"})}));Hd.displayName=Pc.displayName;function eo({className:e,...t}){return u.jsx(Nm,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:u.jsx(Cm,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const Fx=Qr("relative w-full rounded-lg 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-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Ri=y.forwardRef(({className:e,variant:t,...n},r)=>u.jsx("div",{ref:r,role:"alert",className:H(Fx({variant:t}),e),...n}));Ri.displayName="Alert";const Lx=y.forwardRef(({className:e,...t},n)=>u.jsx("h5",{ref:n,className:H("mb-1 font-medium leading-none tracking-tight",e),...t}));Lx.displayName="AlertTitle";const Mi=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:H("text-sm [&_p]:leading-relaxed",e),...t}));Mi.displayName="AlertDescription";const $i=y.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=y.useState(n<2),a=t!==null&&typeof t=="object",o=Array.isArray(t),l=()=>s(!i),c=()=>t===null?u.jsx("span",{className:"text-orange-500",children:"null"}):t===void 0?u.jsx("span",{className:"text-gray-500",children:"undefined"}):typeof t=="boolean"?u.jsx("span",{className:"text-blue-500",children:String(t)}):typeof t=="number"?u.jsx("span",{className:"text-green-500",children:t}):typeof t=="string"?t.startsWith("http")?u.jsxs("span",{className:"text-purple-500",children:['"',t,'"']}):t.startsWith("#/")?u.jsxs("span",{className:"text-cyan-500",children:['"',t,'"']}):u.jsxs("span",{className:"text-amber-600",children:['"',t,'"']}):null,f=a?Object.keys(t).length:0;return u.jsxs("div",{className:H("text-sm",n>0&&"ml-4"),children:[u.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded px-1 py-0.5",children:[a&&u.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded p-0.5","aria-label":i?"Collapse":"Expand",children:i?u.jsx(on,{className:"h-3 w-3"}):u.jsx(ss,{className:"h-3 w-3"})}),!a&&u.jsx("span",{className:"w-4"}),e&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:['"',e,'"']}),u.jsx("span",{className:"mx-1",children:":"})]}),a?u.jsxs("span",{className:"text-muted-foreground",children:[o?"[":"{",!i&&u.jsxs("span",{className:"mx-1 text-xs",children:[f," ",o?"items":"properties"]}),!i&&(o?"]":"}")]}):c(),!a&&!r&&u.jsx("span",{className:"text-muted-foreground",children:","})]}),a&&i&&u.jsxs("div",{className:"ml-4",children:[o?t.map((d,p)=>u.jsx($i,{keyName:String(p),value:d,depth:n+1,isLast:p===t.length-1},p)):Object.entries(t).map(([d,p],h,m)=>u.jsx($i,{keyName:d,value:p,depth:n+1,isLast:h===m.length-1},d)),u.jsx("div",{className:"ml-4",children:u.jsxs("span",{className:"text-muted-foreground",children:[o?"]":"}",!r&&","]})})]})]})});$i.displayName="JsonNode";const Fi=y.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?u.jsxs("div",{className:H("space-y-4",r),children:[u.jsx(Ar,{className:"h-8 w-64"}),u.jsx(Ar,{className:"h-4 w-full"}),u.jsx(Ar,{className:"h-64 w-full"})]}):n?u.jsx(Ri,{variant:"destructive",className:r,children:u.jsx(Mi,{children:n})}):e?u.jsx($r,{className:H("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($i,{value:e})})}):u.jsx(Ri,{className:r,children:u.jsx(Mi,{children:"No schema available"})}));Fi.displayName="SchemaViewer";function Zx({plugins:e,initialFocusedPlugin:t}){var g,z;const n=Dt(E=>E.togglePlugin),r=Dt(E=>E.isPluginSelected),i=Dt(E=>E.selectedPlugins),s=Dt(E=>E.isApplyingPlugins),[a,o]=y.useState(null),[l,c]=y.useState(null),[f,d]=y.useState("properties");y.useEffect(()=>{if(t){const E=e.find(k=>k.name===t);if(E){o(E);return}}e.length>0&&!a&&o(e[0])},[t,e]);const p=y.useMemo(()=>{const E={current:[],downstream:[],upstream:[]};return e.forEach(k=>{E[k.location]&&E[k.location].push(k)}),E},[e]),h=async(E,k)=>{a&&(await $x(a.name,E.props),c(k),setTimeout(()=>c(null),2e3))},m=E=>{switch(E){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return E}},w=E=>{switch(E){case"current":return u.jsx(Gm,{className:"size-3"});case"downstream":return u.jsx(Wm,{className:"size-3"});case"upstream":return u.jsx(Yc,{className:"size-3"});default:return null}},S=((g=a==null?void 0:a.schema)==null?void 0:g.properties)&&Object.keys(a.schema.properties).length>0,x=(z=a==null?void 0:a.schema)==null?void 0:z.jsonSchema,_=(a==null?void 0:a.examples)&&a.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(Xc,{className:"size-5 text-amber-600 dark:text-amber-400"}),"Plugins",u.jsxs(Vt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),u.jsxs(cn,{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($r,{className:"h-full",children:u.jsx("div",{className:"p-2 space-y-3",children:Object.entries(p).map(([E,k])=>k.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:[w(E),m(E)]}),u.jsx("div",{className:"space-y-0.5",children:k.map(C=>{const $=r(C.name),K=(a==null?void 0:a.name)===C.name;return u.jsxs("button",{onClick:()=>o(C),className:H("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",K?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[u.jsx("div",{className:H("size-1.5 rounded-full flex-none transition-colors",$?"bg-amber-500 dark:bg-amber-400":"bg-muted-foreground/30")}),u.jsx("span",{className:"text-sm font-medium truncate flex-1",children:C.name})]},C.name)})})]},E))})})}),a?u.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[u.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("h3",{className:"text-base font-semibold truncate",children:a.name}),a.version&&u.jsxs(Vt,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",a.version]})]}),a.description&&u.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:a.description})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:r(a.name)?"On":"Off"}),u.jsx(eo,{checked:r(a.name),onCheckedChange:()=>n(a),disabled:s,"aria-label":`Toggle ${a.name}`})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[w(a.location),u.jsx("span",{children:m(a.location)}),u.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),u.jsx("span",{className:"font-mono truncate",children:a.relativePath})]})]}),u.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&u.jsx("button",{onClick:()=>d("properties"),className:H("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="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(Fo,{className:"size-3.5"}),"Properties"]})}),x&&u.jsx("button",{onClick:()=>d("schema"),className:H("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="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(Jm,{className:"size-3.5"}),"Schema"]})}),_&&u.jsx("button",{onClick:()=>d("examples"),className:H("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",f==="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(Hm,{className:"size-3.5"}),"Examples",u.jsx(Vt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:a.examples.length})]})})]}),u.jsx($r,{className:"flex-1",children:u.jsxs("div",{className:"p-5",children:[f==="properties"&&S&&u.jsx("div",{className:"space-y-1",children:Object.entries(a.schema.properties).map(([E,k])=>u.jsx(Bx,{name:E,prop:k},E))}),f==="schema"&&x&&u.jsx(Fi,{schema:a.schema.jsonSchema,loading:!1,className:"h-[420px]"}),f==="examples"&&_&&a.examples.map((E,k)=>u.jsxs("div",{className:H(k>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:[E.title&&u.jsx("span",{className:"font-medium text-sm truncate",children:E.title}),!E.title&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",k+1]})]}),u.jsx(we,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>h(E,k),children:l===k?u.jsxs(u.Fragment,{children:[u.jsx(qm,{className:"size-3 mr-1 text-green-600"}),"Copied"]}):u.jsxs(u.Fragment,{children:[u.jsx(as,{className:"size-3 mr-1"}),"Copy"]})})]}),E.description&&u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:E.description}),u.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(E.props,null,2)})]},k)),!S&&!x&&!_&&u.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[u.jsx(Fo,{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 Bx({name:e,prop:t}){var a;const[n,r]=y.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:H("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(on,{className:"size-3 text-muted-foreground flex-none"}):u.jsx(ss,{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(Vt,{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-red-500 font-medium flex-none",children:"required"}),u.jsx("span",{className:"flex-1"}),t.default!==void 0&&u.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&u.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&u.jsx("p",{children:t.description}),t.enum&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((o,l)=>u.jsxs("span",{children:[l>0&&", ",u.jsx("code",{className:"bg-muted px-1 rounded",children:JSON.stringify(o)})]},l))]}),((a=t.items)==null?void 0:a.type)&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const As=Em,Ps=Im,Os=zm,to=Tm,no=Am,Vx=y.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs($c,{ref:i,className:H("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(ss,{className:"ml-auto"})]}));Vx.displayName=$c.displayName;const Ux=y.forwardRef(({className:e,...t},n)=>u.jsx(Fc,{ref:n,className:H("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-md border p-1 shadow-lg",e),...t}));Ux.displayName=Fc.displayName;const ds=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Pm,{children:u.jsx(Oc,{ref:r,sideOffset:t,className:H("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md 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})}));ds.displayName=Oc.displayName;const Kt=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Dc,{ref:r,className:H("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}));Kt.displayName=Dc.displayName;const Jx=y.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(Lc,{ref:i,className:H("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(Zc,{children:u.jsx(un,{className:"h-4 w-4"})})}),t]}));Jx.displayName=Lc.displayName;const Hx=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Bc,{ref:r,className:H("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(Zc,{children:u.jsx(Kc,{className:"h-2 w-2 fill-current"})})}),t]}));Hx.displayName=Bc.displayName;const qd=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Mc,{ref:r,className:H("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));qd.displayName=Mc.displayName;const Fr=y.forwardRef(({className:e,...t},n)=>u.jsx(Rc,{ref:n,className:H("bg-muted -mx-1 my-1 h-px",e),...t}));Fr.displayName=Rc.displayName;function qx(){const{theme:e,setTheme:t}=qc(),n=e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,r=y.useCallback(()=>{t(n==="dark"?"light":"dark")},[n,t]);return u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(we,{variant:"ghost",size:"icon",onClick:r,children:[u.jsx(Km,{className:"hidden dark:block"}),u.jsx(Ym,{className:"block dark:hidden"}),u.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:"Toggle theme"})})]})}const Wd=Om,ro=y.forwardRef(({className:e,...t},n)=>u.jsx(Vc,{ref:n,className:H("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-lg p-1",e),...t}));ro.displayName=Vc.displayName;const Lr=y.forwardRef(({className:e,...t},n)=>u.jsx(Uc,{ref:n,className:H("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-md 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 data-[state=active]:shadow",e),...t}));Lr.displayName=Uc.displayName;const Zr=y.forwardRef(({className:e,...t},n)=>u.jsx(Jc,{ref:n,className:H("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));Zr.displayName=Jc.displayName;async function Wx(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 Gx(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 Kx(e){const t=Gx(e);return Wx(t)}const Gd=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=y.useState(n),[s,a]=y.useState(null),[o,l]=y.useState(null),[c,f]=y.useState(!1),[d,p]=y.useState(!1),[h,m]=y.useState(null),[w,S]=y.useState(null),[x,_]=y.useState(!1),{toast:g}=Xr(),z=Dt(B=>B.selectedPlugins),E=Array.from(z);y.useEffect(()=>{n&&i(n)},[n]);const k=y.useCallback(async()=>{f(!0),m(null);try{const B=await Ns.fetchDocumentSchema(E);a(B)}catch(B){const D=B instanceof Error?B.message:"Failed to load document schema";m(D),g({variant:"destructive",title:"Error loading schema",description:D})}finally{f(!1)}},[E,g]),C=y.useCallback(async()=>{if(!o){p(!0),S(null);try{const B=await Ns.fetchThemeSchema();l(B)}catch(B){const D=B instanceof Error?B.message:"Failed to load theme schema";S(D),g({variant:"destructive",title:"Error loading schema",description:D})}finally{p(!1)}}},[o,g]),[$,K]=y.useState([]);y.useEffect(()=>{e||(a(null),m(null))},[e]),y.useEffect(()=>{if(!e)return;const B=E.length!==$.length||E.some((D,T)=>D!==$[T]);r==="document"?(!s||B)&&(B&&(Ns.clearPluginSchemaCache(),K([...E])),c||k()):r==="theme"&&!o&&!d&&C()},[r,e,s,o,c,d,E,$,k,C]);const N=E.length,I=r==="document"?s:o,A=async()=>{if(I)try{await Kx(I)&&(_(!0),g({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>_(!1),2e3))}catch(B){console.error("Copy failed:",B)}};return u.jsx(It,{open:e,onOpenChange:t,children:u.jsxs(St,{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(Wd,{value:r,onValueChange:B=>i(B),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ro,{children:[u.jsxs(Lr,{value:"document",className:"flex items-center gap-1",children:["Document",N>0&&u.jsxs(Vt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",N]})]}),u.jsx(Lr,{value:"theme",children:"Theme"})]}),u.jsx("div",{className:"ml-auto",children:u.jsx(we,{variant:"ghost",size:"icon",onClick:A,disabled:x||!I,"aria-label":"Copy schema",children:x?u.jsx(un,{className:"h-4 w-4"}):u.jsx(as,{className:"h-4 w-4"})})})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[u.jsx(Zr,{value:"document",className:"h-full",children:u.jsx(Fi,{schema:s,loading:c,error:h||void 0})}),u.jsx(Zr,{value:"theme",className:"h-full",children:u.jsx(Fi,{schema:o,loading:d,error:w||void 0})})]})]})]})})};function Yx({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:a,openDocument:o}=Ae(ad(F=>({documents:F.documents,documentTypes:F.documentTypes,createDocument:F.createDocument,openDocument:F.openDocument}))),l=da(F=>F.updateTheme),c=da(F=>F.removeTheme),f=y.useContext(sd),[d,p]=y.useState(!1),[h,m]=y.useState(!1),[w,S]=y.useState(!1),[x,_]=y.useState(null),g=Dt(F=>F.togglePlugin),z=Dt(F=>F.isPluginSelected),E=Dt(F=>F.selectedPlugins),k=Dt(F=>F.isApplyingPlugins),[C,$]=y.useState(!1),[K,N]=y.useState(!1),[I,A]=y.useState(new Set(["current-docs","current-themes"])),{toast:B}=Xr(),D=i.filter(F=>s[F.name]!=="application/json+theme"),T=i.filter(F=>s[F.name]==="application/json+theme"),P=y.useMemo(()=>{if(!e)return{current:[],downstream:[]};const F={current:[],downstream:[]};return e.documents.forEach(te=>{F[te.location]&&F[te.location].push(te)}),F},[e]),J=y.useMemo(()=>{if(!e)return{current:[],downstream:[]};const F={current:[],downstream:[]};return e.themes.forEach(te=>{F[te.location]&&F[te.location].push(te)}),F},[e]),R=y.useMemo(()=>{const F=new Set;return D.forEach(te=>{try{const V=JSON.parse(te.text);V.children&&Array.isArray(V.children)&&V.children.forEach(de=>{var le;de.name==="docx"&&((le=de.props)!=null&&le.theme)&&F.add(de.props.theme)})}catch{}}),F},[D]),q=y.useCallback(()=>{p(!1)},[]),v=y.useCallback(()=>{m(!1)},[]),fe=y.useRef(new Map);y.useEffect(()=>{const F=fe.current,te=new Map;T.forEach(V=>{te.set(V.name,V.text),F.get(V.name)!==V.text&&l(V.name,V.text)}),F.forEach((V,de)=>{te.has(de)||c(de)}),fe.current=te},[T,l,c]);const ue=y.useRef(!1);y.useEffect(()=>{if(ue.current||!f)return;ue.current=!0;const F=new Set(T.map(V=>V.name));Object.keys(f.getState().customThemes).forEach(V=>{F.has(V)||c(V)})},[T,c,f]);const b=F=>{A(te=>{const V=new Set(te);return V.has(F)?V.delete(F):V.add(F),V})},Y=Ae(F=>F.activeTab),oe=Y&&s[Y]==="application/json+theme"?"theme":"document",{resolvedTheme:ne}=qc(),ie=ne==="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",W=y.useCallback(async(F,te)=>{if(i.some(V=>V.name===F)){o(F);return}try{const V=await fetch(`/api/discovery/${te?"themes":"documents"}/${encodeURIComponent(F)}/content`);if(!V.ok)throw new Error(V.statusText);const de=await V.text(),le=JSON.parse(de);a(F,JSON.stringify(le,null,2)),o(F),B({title:`Added ${te?"theme":"document"}: ${F}`})}catch{B({title:"Failed to load",description:`Could not load ${F}`,variant:"destructive"})}},[i,a,o,B]);return u.jsxs(u.Fragment,{children:[u.jsxs(Fd,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[u.jsx(Ld,{children:u.jsx("div",{className:H("flex items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-between"),children:n?u.jsx(we,{variant:"ghost",size:"icon","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:u.jsx(Qc,{className:"h-4 w-4"})}):u.jsxs(u.Fragment,{children:[u.jsx("a",{href:"/",className:"flex items-center pl-2",children:u.jsx("img",{src:ie,alt:"WiseAir logo",className:"h-5 w-auto max-w-[120px] shrink-0"})}),u.jsx("div",{className:"flex items-center gap-1",children:u.jsx(we,{variant:"ghost",size:"icon","aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:u.jsx(Xm,{className:"h-4 w-4"})})})]})})}),u.jsxs(Vd,{className:H("h-full transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100"),children:[u.jsxs(Si,{children:[u.jsxs(_i,{className:H("flex items-center",n?"justify-center":"justify-between"),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[!n&&u.jsx(Lo,{className:"size-3"}),!n&&u.jsx("span",{children:"Active Documents"})]}),u.jsxs("div",{className:"flex items-center gap-0.5",children:[yt==="docx"&&!n&&u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{className:"h-6 w-6 p-0 flex-shrink-0",variant:"ghost",size:"icon","aria-label":"Compare documents",disabled:D.length<2,onClick:()=>N(!0),children:u.jsx(Gc,{className:"size-4"})})}),u.jsx(Ke,{side:"bottom",children:u.jsx("span",{className:"text-xs",children:D.length<2?"Compare needs two documents":"Compare documents (redline)"})})]}),u.jsxs(It,{open:d,onOpenChange:p,children:[u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Bo,{asChild:!0,children:u.jsx(we,{className:H("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:u.jsx(zi,{className:n?"size-3.5":"size-4"})})})}),u.jsx(Ke,{side:n?"right":"bottom",children:u.jsx("span",{className:"text-xs",children:"New Document"})})]}),u.jsx(St,{className:"sm:max-w-[525px]",children:u.jsx(Di,{mode:"create",shouldReset:!d,postSubmit:q,discoveredDocuments:(e==null?void 0:e.documents)||[]})})]})]})]}),n?u.jsx(Sr,{children:u.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:D.map(F=>{const te=Y===F.name;return u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("button",{onClick:()=>o(F.name),"aria-label":F.name,className:H("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",te?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[te&&u.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-green-500 dark:bg-green-400"}),F.name.replace(/\.[^.]+$/,"").slice(0,2).toUpperCase()]})}),u.jsx(Ke,{side:"right",children:u.jsx("span",{className:"text-xs",children:F.name})})]},F.name)})})}):u.jsx(Sr,{children:u.jsx(ba,{children:D.length>0?D.map((F,te)=>u.jsx(el,{document:F,compact:n},`doc-${te}`)):u.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No active documents. Click + to create one."})})})]}),u.jsx(Bd,{}),u.jsxs(Si,{children:[u.jsxs(_i,{className:H("flex items-center",n?"justify-center":"justify-between"),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[!n&&u.jsx(la,{className:"size-3 text-purple-600 dark:text-purple-400"}),!n&&u.jsx("span",{children:"Active Themes"})]}),u.jsxs(It,{open:h,onOpenChange:m,children:[u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Bo,{asChild:!0,children:u.jsx(we,{className:H("p-0 flex-shrink-0",n?"mx-auto h-8 w-8 rounded border border-dashed border-sidebar-foreground/20 hover:border-sidebar-foreground/40":"h-6 w-6"),variant:"ghost",size:"icon",children:u.jsx(zi,{className:n?"size-3.5":"size-4"})})})}),u.jsx(Ke,{side:n?"right":"bottom",children:u.jsx("span",{className:"text-xs",children:"New Theme"})})]}),u.jsx(St,{className:"sm:max-w-[525px]",children:u.jsx(Di,{mode:"create",shouldReset:!h,postSubmit:v,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})]})]}),n?u.jsx(Sr,{children:u.jsx("div",{className:"flex flex-col items-center gap-0.5 px-0.5",children:T.map(F=>{const te=Y===F.name;let V=null;try{const le=JSON.parse(F.text);V=fa(le)}catch{}const de=V?R.has(V):!1;return u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("button",{onClick:()=>o(F.name),"aria-label":F.name,className:H("relative w-8 h-8 rounded flex items-center justify-center text-[11px] font-bold transition-colors cursor-pointer",te?"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300":de?"bg-purple-50 text-purple-600 dark:bg-purple-900/20 dark:text-purple-400":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[te&&u.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-0.5 rounded-full bg-purple-500 dark:bg-purple-400"}),(V||F.name).charAt(0).toUpperCase()]})}),u.jsx(Ke,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[F.name,de&&u.jsx("div",{className:"opacity-70",children:"In use"})]})})]},F.name)})})}):u.jsx(Sr,{children:u.jsx(ba,{children:T.length>0?T.map((F,te)=>{let V=null;try{const le=JSON.parse(F.text);V=fa(le)}catch{}const de=V?R.has(V):!1;return u.jsx(el,{document:F,compact:n,indicator:de?"in-use":void 0},`theme-${te}`)}):u.jsxs("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No active themes."," ",e&&e.themes.length>0?"Click + to add one.":"No themes discovered in project."]})})})]}),!n&&e&&(e.documents.length>0||e.themes.length>0)&&u.jsxs(Si,{className:"mt-2 border-t pt-4",children:[u.jsxs(_i,{className:"flex items-center mb-2 gap-2",children:[u.jsx(Qm,{className:"size-3"}),u.jsx("span",{children:"Discovered Resources"})]}),u.jsxs(u.Fragment,{children:[Object.entries(P).map(([F,te])=>{if(te.length===0)return null;const V=`${F}-docs`,de=I.has(V);return u.jsxs(As,{open:de,children:[u.jsxs(Ps,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>b(V),children:[u.jsx(on,{className:H("size-3 transition-transform",!de&&"-rotate-90")}),u.jsx(Lo,{className:"size-3"}),F==="current"?"Current Directory":"Project"," ","Documents (",te.length,")"]}),u.jsx(Os,{children:u.jsx("div",{className:"pl-4 space-y-0.5",children:te.map((le,ye)=>{const Oe=i.some(qe=>qe.name===le.name);return u.jsxs("button",{onClick:()=>W(le.name,!1),className:H("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-blue-400/60 dark:border-blue-500/40","hover:bg-accent hover:text-accent-foreground",Oe&&"opacity-50"),children:[u.jsx("div",{className:"font-medium truncate",children:le.name}),le.title&&u.jsx("div",{className:"text-xs text-muted-foreground truncate",children:le.title})]},ye)})})})]},V)}),Object.entries(J).map(([F,te])=>{if(te.length===0)return null;const V=`${F}-themes`,de=I.has(V);return u.jsxs(As,{open:de,children:[u.jsxs(Ps,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>b(V),children:[u.jsx(on,{className:H("size-3 transition-transform",!de&&"-rotate-90")}),u.jsx(la,{className:"size-3"}),F==="current"?"Current Directory":"Project"," ","Themes (",te.length,")"]}),u.jsx(Os,{children:u.jsx("div",{className:"pl-4 space-y-0.5",children:te.map((le,ye)=>{const Oe=i.some(qe=>qe.name===le.name);return u.jsxs("button",{onClick:()=>W(le.name,!0),className:H("w-full text-left py-1 px-2 rounded text-sm transition-colors","border-l-2 border-purple-400/60 dark:border-purple-500/40","hover:bg-accent hover:text-accent-foreground",Oe&&"opacity-50"),children:[u.jsx("div",{className:"font-medium truncate",children:le.name}),le.description&&u.jsx("div",{className:"text-xs text-muted-foreground truncate",children:le.description})]},ye)})})})]},V)}),e&&e.plugins.length>0&&u.jsxs(As,{open:I.has("plugins"),children:[u.jsxs(Ps,{className:"flex items-center gap-1 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer w-full",onClick:()=>b("plugins"),children:[u.jsx(on,{className:H("size-3 transition-transform",!I.has("plugins")&&"-rotate-90")}),u.jsx(Xc,{className:"size-3 text-amber-600 dark:text-amber-400"}),"Plugins (",E.size,"/",e.plugins.length,")"]}),u.jsx(Os,{children:u.jsx("div",{className:"pl-4 space-y-0.5",children:e.plugins.map((F,te)=>{const V=z(F.name);return u.jsxs("div",{className:H("py-1 px-2 text-sm border-l-2 flex items-center gap-2 group transition-colors",V?"border-amber-500 dark:border-amber-400 text-foreground":"border-amber-400/30 dark:border-amber-500/20 text-muted-foreground"),children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"font-medium truncate",children:F.name}),F.description&&u.jsx("div",{className:"text-xs opacity-70 truncate",children:F.description})]}),u.jsx("button",{className:"flex-none size-5 flex items-center justify-center rounded-sm opacity-0 group-hover:opacity-100 hover:bg-accent transition-all cursor-pointer",title:`View details for ${F.name}`,onClick:de=>{de.stopPropagation(),_(F.name),S(!0)},children:u.jsx(ed,{className:"size-3 text-muted-foreground"})}),u.jsx(eo,{checked:V,onCheckedChange:()=>g(F),disabled:k,className:"flex-none scale-[0.8]","aria-label":`Toggle ${F.name} plugin`})]},te)})})})]})]})]})]}),u.jsx(Zd,{children:u.jsx("div",{className:H("flex w-full items-center transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100",n?"justify-center":"justify-end pr-2"),children:u.jsx(qx,{})})}),u.jsx(It,{open:w,onOpenChange:F=>{S(F),F||_(null)},children:u.jsx(St,{className:"sm:max-w-5xl max-h-[85vh] overflow-hidden",children:u.jsx(Zx,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:x})})})]}),u.jsx(Gd,{open:C,onOpenChange:$,defaultTab:oe==="theme"?"theme":"document"}),u.jsx(Ig,{open:K,onOpenChange:N})]})}const tl=y.memo(Yx),Xx=y.lazy(()=>Wc(()=>import("./editor-CB9BVJGn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function nl(){return u.jsx(y.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(Yt,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:u.jsx(Xx,{})})}const Qx=y.lazy(()=>Wc(()=>import("./preview-B4bcm38l.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function rl(){return u.jsx(y.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(Yt,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:u.jsx(Qx,{})})}const{createElement:nr,createContext:ey,forwardRef:Kd,useCallback:pt,useContext:Yd,useEffect:_n,useImperativeHandle:Xd,useLayoutEffect:ty,useMemo:ny,useRef:xt,useState:Kn}=cc,il=cc[`useId${Math.random()}`.slice(0,5)],ry=ty,fs=ey(null);fs.displayName="PanelGroupContext";const jn=ry,iy=typeof il=="function"?il:()=>null;let sy=0;function io(e=null){const t=iy(),n=xt(e||t||null);return n.current===null&&(n.current=""+sy++),e??n.current}function Qd({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:a,maxSize:o,minSize:l,onCollapse:c,onExpand:f,onResize:d,order:p,style:h,tagName:m="div",...w}){const S=Yd(fs);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:_,getPanelSize:g,getPanelStyle:z,groupId:E,isPanelCollapsed:k,reevaluatePanelConstraints:C,registerPanel:$,resizePanel:K,unregisterPanel:N}=S,I=io(a),A=xt({callbacks:{onCollapse:c,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:o,minSize:l},id:I,idIsFromProps:a!==void 0,order:p});xt({didLogMissingDefaultSizeWarning:!1}),jn(()=>{const{callbacks:D,constraints:T}=A.current,P={...T};A.current.id=I,A.current.idIsFromProps=a!==void 0,A.current.order=p,D.onCollapse=c,D.onExpand=f,D.onResize=d,T.collapsedSize=n,T.collapsible=r,T.defaultSize=i,T.maxSize=o,T.minSize=l,(P.collapsedSize!==T.collapsedSize||P.collapsible!==T.collapsible||P.maxSize!==T.maxSize||P.minSize!==T.minSize)&&C(A.current,P)}),jn(()=>{const D=A.current;return $(D),()=>{N(D)}},[p,I,$,N]),Xd(s,()=>({collapse:()=>{x(A.current)},expand:D=>{_(A.current,D)},getId(){return I},getSize(){return g(A.current)},isCollapsed(){return k(A.current)},isExpanded(){return!k(A.current)},resize:D=>{K(A.current,D)}}),[x,_,g,k,I,K]);const B=z(A.current,i);return nr(m,{...w,children:e,className:t,id:a,style:{...B,...h},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":E,"data-panel-id":I,"data-panel-size":parseFloat(""+B.flexGrow).toFixed(1)})}const ef=Kd((e,t)=>nr(Qd,{...e,forwardedRef:t}));Qd.displayName="Panel";ef.displayName="forwardRef(Panel)";let va=null,Sn=null;function ay(e,t){if(t){const n=(t&af)!==0,r=(t&of)!==0,i=(t&lf)!==0,s=(t&uf)!==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 oy(){Sn!==null&&(document.head.removeChild(Sn),va=null,Sn=null)}function Ds(e,t){const n=ay(e,t);va!==n&&(va=n,Sn===null&&(Sn=document.createElement("style"),document.head.appendChild(Sn)),Sn.innerHTML=`*{cursor: ${n}!important;}`)}function tf(e){return e.type==="keydown"}function nf(e){return e.type.startsWith("pointer")}function rf(e){return e.type.startsWith("mouse")}function ps(e){if(nf(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(rf(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function ly(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function uy(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 cy(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:ol(e),b:ol(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;_e(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:al(sl(n.a)),b:al(sl(n.b))};if(i.a===i.b){const s=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let o=s.length;for(;o--;){const l=s[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(i.a-i.b)}const dy=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function fy(e){var t;const n=getComputedStyle((t=sf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function py(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||fy(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"||dy.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function sl(e){let t=e.length;for(;t--;){const n=e[t];if(_e(n,"Missing node"),py(n))return n}return null}function al(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ol(e){const t=[];for(;e;)t.push(e),e=sf(e);return t}function sf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const af=1,of=2,lf=4,uf=8,hy=ly()==="coarse";let Rt=[],Yn=!1,an=new Map,hs=new Map;const Br=new Set;function my(e,t,n,r,i){var s;const{ownerDocument:a}=t,o={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=an.get(a))!==null&&s!==void 0?s:0;return an.set(a,l+1),Br.add(o),Li(),function(){var f;hs.delete(e),Br.delete(o);const d=(f=an.get(a))!==null&&f!==void 0?f:1;if(an.set(a,d-1),Li(),d===1&&an.delete(a),Rt.includes(o)){const p=Rt.indexOf(o);p>=0&&Rt.splice(p,1),ao(),i("up",!0,null)}}}function ll(e){const{target:t}=e,{x:n,y:r}=ps(e);Yn=!0,so({target:t,x:n,y:r}),Li(),Rt.length>0&&(Zi("down",e),e.preventDefault(),e.stopPropagation())}function gr(e){const{x:t,y:n}=ps(e);if(Yn&&e.buttons===0&&(Yn=!1,Zi("up",e)),!Yn){const{target:r}=e;so({target:r,x:t,y:n})}Zi("move",e),ao(),Rt.length>0&&e.preventDefault()}function Dn(e){const{target:t}=e,{x:n,y:r}=ps(e);hs.clear(),Yn=!1,Rt.length>0&&e.preventDefault(),Zi("up",e),so({target:t,x:n,y:r}),ao(),Li()}function so({target:e,x:t,y:n}){Rt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Br.forEach(i=>{const{element:s,hitAreaMargins:a}=i,o=s.getBoundingClientRect(),{bottom:l,left:c,right:f,top:d}=o,p=hy?a.coarse:a.fine;if(t>=c-p&&t<=f+p&&n>=d-p&&n<=l+p){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&cy(r,s)>0){let m=r,w=!1;for(;m&&!m.contains(s);){if(uy(m.getBoundingClientRect(),o)){w=!0;break}m=m.parentElement}if(w)return}Rt.push(i)}})}function Rs(e,t){hs.set(e,t)}function ao(){let e=!1,t=!1;Rt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;hs.forEach(r=>{n|=r}),e&&t?Ds("intersection",n):e?Ds("horizontal",n):t?Ds("vertical",n):oy()}function Li(){an.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Dn),n.removeEventListener("pointerdown",ll),n.removeEventListener("pointerleave",gr),n.removeEventListener("pointermove",gr)}),window.removeEventListener("pointerup",Dn),window.removeEventListener("pointercancel",Dn),Br.size>0&&(Yn?(Rt.length>0&&an.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Dn),n.addEventListener("pointerleave",gr),n.addEventListener("pointermove",gr))}),window.addEventListener("pointerup",Dn),window.addEventListener("pointercancel",Dn)):an.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",ll,{capture:!0}),n.addEventListener("pointermove",gr))}))}function Zi(e,t){Br.forEach(n=>{const{setResizeHandlerState:r}=n,i=Rt.includes(n);r(e,i,t)})}function gy(){const[e,t]=Kn(0);return pt(()=>t(n=>n+1),[])}function _e(e,t){if(!e)throw console.error(t),Error(t)}const oo=10;function In(e,t,n=oo){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Xt(e,t,n=oo){return In(e,t,n)===0}function kt(e,t,n){return In(e,t,n)===0}function xy(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(!kt(i,s,n))return!1}return!0}function Hn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];_e(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:a=100,minSize:o=0}=r;if(In(n,o)<0)if(s){const l=(i+o)/2;In(n,l)<0?n=i:n=o}else n=o;return n=Math.min(a,n),n=parseFloat(n.toFixed(oo)),n}function _r({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(kt(e,0))return t;const a=[...t],[o,l]=r;_e(o!=null,"Invalid first pivot index"),_e(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const d=e<0?l:o,p=n[d];_e(p,`Panel constraints not found for index ${d}`);const{collapsedSize:h=0,collapsible:m,minSize:w=0}=p;if(m){const S=t[d];if(_e(S!=null,`Previous layout not found for panel index ${d}`),kt(S,h)){const x=w-S;In(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?o:l,p=n[d];_e(p,`No panel constraints found for index ${d}`);const{collapsedSize:h=0,collapsible:m,minSize:w=0}=p;if(m){const S=t[d];if(_e(S!=null,`Previous layout not found for panel index ${d}`),kt(S,w)){const x=S-h;In(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const d=e<0?1:-1;let p=e<0?l:o,h=0;for(;;){const w=t[p];_e(w!=null,`Previous layout not found for panel index ${p}`);const x=Hn({panelConstraints:n,panelIndex:p,size:100})-w;if(h+=x,p+=d,p<0||p>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-m:m}{let p=e<0?o:l;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(c),m=t[p];_e(m!=null,`Previous layout not found for panel index ${p}`);const w=m-h,S=Hn({panelConstraints:n,panelIndex:p,size:w});if(!kt(m,S)&&(c+=m-S,a[p]=S,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(xy(i,a))return i;{const d=e<0?l:o,p=t[d];_e(p!=null,`Previous layout not found for panel index ${d}`);const h=p+c,m=Hn({panelConstraints:n,panelIndex:d,size:h});if(a[d]=m,!kt(m,h)){let w=h-m,x=e<0?l:o;for(;x>=0&&x<n.length;){const _=a[x];_e(_!=null,`Previous layout not found for panel index ${x}`);const g=_+w,z=Hn({panelConstraints:n,panelIndex:x,size:g});if(kt(_,z)||(w-=z-_,a[x]=z),kt(w,0))break;e>0?x--:x++}}}const f=a.reduce((d,p)=>p+d,0);return kt(f,100)?a:i}function yy({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,a=0;const o=n[0];_e(o!=null,"No pivot index found"),t.forEach((d,p)=>{const{constraints:h}=d,{maxSize:m=100,minSize:w=0}=h;p===o?(r=w,i=m):(s+=w,a+=m)});const l=Math.min(i,100-s),c=Math.max(r,100-a),f=e[o];return{valueMax:l,valueMin:c,valueNow:f}}function Vr(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function cf(e,t,n=document){const i=Vr(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function df(e,t,n){const r=cf(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function ff(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 ms(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function by(e,t,n,r=document){var i,s,a,o;const l=ms(t,r),c=Vr(e,r),f=l?c.indexOf(l):-1,d=(i=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,p=(a=(o=n[f+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[d,p]}function vy({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:a}){xt({didWarnAboutMissingResizeHandle:!1}),jn(()=>{if(!s)return;const o=Vr(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:f,valueNow:d}=yy({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),p=o[l];if(p!=null){const h=i[l];_e(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(f)),p.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{o.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),_n(()=>{if(!s)return;const o=t.current;_e(o,"Eager values not found");const{panelDataArray:l}=o,c=ff(n,s);_e(c!=null,`No group found for id "${n}"`);const f=Vr(n,s);_e(f,`No resize handles found for group id "${n}"`);const d=f.map(p=>{const h=p.getAttribute("data-panel-resize-handle-id");_e(h,"Resize handle element has no handle id attribute");const[m,w]=by(n,h,l,s);if(m==null||w==null)return()=>{};const S=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const _=l.findIndex(g=>g.id===m);if(_>=0){const g=l[_];_e(g,`No panel data found for index ${_}`);const z=r[_],{collapsedSize:E=0,collapsible:k,minSize:C=0}=g.constraints;if(z!=null&&k){const $=_r({delta:kt(z,E)?C-E:E-z,initialLayout:r,panelConstraints:l.map(K=>K.constraints),pivotIndices:df(n,h,s),prevLayout:r,trigger:"keyboard"});r!==$&&a($)}}break}}};return p.addEventListener("keydown",S),()=>{p.removeEventListener("keydown",S)}});return()=>{d.forEach(p=>p())}},[s,e,t,n,r,i,a])}function ul(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 pf(e,t){const n=e==="horizontal",{x:r,y:i}=ps(t);return n?r:i}function wy(e,t,n,r,i){const s=n==="horizontal",a=ms(t,i);_e(a,`No resize handle element found for id "${t}"`);const o=a.getAttribute("data-panel-group-id");_e(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=pf(n,e),f=ff(o,i);_e(f,`No group element found for id "${o}"`);const d=f.getBoundingClientRect(),p=s?d.width:d.height;return(c-l)/p*100}function ky(e,t,n,r,i,s){if(tf(e)){const a=n==="horizontal";let o=0;e.shiftKey?o=100:i!=null?o=i:o=10;let l=0;switch(e.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:wy(e,t,n,r,s)}function Sy({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;o!=null&&(r++,t[s]=o,i-=o)}for(let s=0;s<e.length;s++){const a=n[s];_e(a,`Panel constraints not found for index ${s}`);const{defaultSize:o}=a;if(o!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function Rn(e,t,n){t.forEach((r,i)=>{const s=e[i];_e(s,`Panel data not found for index ${i}`);const{callbacks:a,constraints:o,id:l}=s,{collapsedSize:c=0,collapsible:f}=o,d=n[l];if(d==null||r!==d){n[l]=r;const{onCollapse:p,onExpand:h,onResize:m}=a;m&&m(r,d),f&&(p||h)&&(h&&(d==null||Xt(d,c))&&!Xt(r,c)&&h(),p&&(d==null||!Xt(d,c))&&Xt(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 _y({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const a=n[i];let o;return a==null?o=e!=null?e.toPrecision(s):"1":r.length===1?o="1":o=a.toPrecision(s),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function jy(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function cl(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 hf(e){return`react-resizable-panels:${e}`}function mf(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 gf(e,t){try{const n=hf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Ny(e,t,n){var r,i;const s=(r=gf(e,n))!==null&&r!==void 0?r:{},a=mf(t);return(i=s[a])!==null&&i!==void 0?i:null}function Cy(e,t,n,r,i){var s;const a=hf(e),o=mf(t),l=(s=gf(e,i))!==null&&s!==void 0?s:{};l[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(l))}catch(c){console.error(c)}}function dl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,a)=>s+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!kt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=100/r*a;n[s]=o}let i=0;for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=Hn({panelConstraints:t,panelIndex:s,size:a});a!=o&&(i+=a-o,n[s]=o)}if(!kt(i,0))for(let s=0;s<t.length;s++){const a=n[s];_e(a!=null,`No layout data found for index ${s}`);const o=a+i,l=Hn({panelConstraints:t,panelIndex:s,size:o});if(a!==l&&(i-=l-a,n[s]=l,kt(i,0)))break}return n}const Ey=100,jr={getItem:e=>(cl(jr),jr.getItem(e)),setItem:(e,t)=>{cl(jr),jr.setItem(e,t)}},fl={};function xf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=jr,style:c,tagName:f="div",...d}){const p=io(s),h=xt(null),[m,w]=Kn(null),[S,x]=Kn([]),_=gy(),g=xt({}),z=xt(new Map),E=xt(0),k=xt({autoSaveId:e,direction:r,dragState:m,id:p,keyboardResizeBy:o,onLayout:a,storage:l}),C=xt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});xt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Xd(i,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:b}=C.current;return b},setLayout:b=>{const{onLayout:Y}=k.current,{layout:oe,panelDataArray:ne}=C.current,ie=dl({layout:b,panelConstraints:ne.map(W=>W.constraints)});ul(oe,ie)||(x(ie),C.current.layout=ie,Y&&Y(ie),Rn(ne,ie,g.current))}}),[]),jn(()=>{k.current.autoSaveId=e,k.current.direction=r,k.current.dragState=m,k.current.id=p,k.current.onLayout=a,k.current.storage=l}),vy({committedValuesRef:k,eagerValuesRef:C,groupId:p,layout:S,panelDataArray:C.current.panelDataArray,setLayout:x,panelGroupElement:h.current}),_n(()=>{const{panelDataArray:b}=C.current;if(e){if(S.length===0||S.length!==b.length)return;let Y=fl[e];Y==null&&(Y=jy(Cy,Ey),fl[e]=Y);const oe=[...b],ne=new Map(z.current);Y(e,oe,ne,S,l)}},[e,S,l]),_n(()=>{});const $=pt(b=>{const{onLayout:Y}=k.current,{layout:oe,panelDataArray:ne}=C.current;if(b.constraints.collapsible){const ie=ne.map(V=>V.constraints),{collapsedSize:W=0,panelSize:F,pivotIndices:te}=gn(ne,b,oe);if(_e(F!=null,`Panel size not found for panel "${b.id}"`),!Xt(F,W)){z.current.set(b.id,F);const de=Bn(ne,b)===ne.length-1?F-W:W-F,le=_r({delta:de,initialLayout:oe,panelConstraints:ie,pivotIndices:te,prevLayout:oe,trigger:"imperative-api"});ci(oe,le)||(x(le),C.current.layout=le,Y&&Y(le),Rn(ne,le,g.current))}}},[]),K=pt((b,Y)=>{const{onLayout:oe}=k.current,{layout:ne,panelDataArray:ie}=C.current;if(b.constraints.collapsible){const W=ie.map(ye=>ye.constraints),{collapsedSize:F=0,panelSize:te=0,minSize:V=0,pivotIndices:de}=gn(ie,b,ne),le=Y??V;if(Xt(te,F)){const ye=z.current.get(b.id),Oe=ye!=null&&ye>=le?ye:le,Qe=Bn(ie,b)===ie.length-1?te-Oe:Oe-te,j=_r({delta:Qe,initialLayout:ne,panelConstraints:W,pivotIndices:de,prevLayout:ne,trigger:"imperative-api"});ci(ne,j)||(x(j),C.current.layout=j,oe&&oe(j),Rn(ie,j,g.current))}}},[]),N=pt(b=>{const{layout:Y,panelDataArray:oe}=C.current,{panelSize:ne}=gn(oe,b,Y);return _e(ne!=null,`Panel size not found for panel "${b.id}"`),ne},[]),I=pt((b,Y)=>{const{panelDataArray:oe}=C.current,ne=Bn(oe,b);return _y({defaultSize:Y,dragState:m,layout:S,panelData:oe,panelIndex:ne})},[m,S]),A=pt(b=>{const{layout:Y,panelDataArray:oe}=C.current,{collapsedSize:ne=0,collapsible:ie,panelSize:W}=gn(oe,b,Y);return _e(W!=null,`Panel size not found for panel "${b.id}"`),ie===!0&&Xt(W,ne)},[]),B=pt(b=>{const{layout:Y,panelDataArray:oe}=C.current,{collapsedSize:ne=0,collapsible:ie,panelSize:W}=gn(oe,b,Y);return _e(W!=null,`Panel size not found for panel "${b.id}"`),!ie||In(W,ne)>0},[]),D=pt(b=>{const{panelDataArray:Y}=C.current;Y.push(b),Y.sort((oe,ne)=>{const ie=oe.order,W=ne.order;return ie==null&&W==null?0:ie==null?-1:W==null?1:ie-W}),C.current.panelDataArrayChanged=!0,_()},[_]);jn(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:b,onLayout:Y,storage:oe}=k.current,{layout:ne,panelDataArray:ie}=C.current;let W=null;if(b){const te=Ny(b,ie,oe);te&&(z.current=new Map(Object.entries(te.expandToSizes)),W=te.layout)}W==null&&(W=Sy({panelDataArray:ie}));const F=dl({layout:W,panelConstraints:ie.map(te=>te.constraints)});ul(ne,F)||(x(F),C.current.layout=F,Y&&Y(F),Rn(ie,F,g.current))}}),jn(()=>{const b=C.current;return()=>{b.layout=[]}},[]);const T=pt(b=>{let Y=!1;const oe=h.current;return oe&&window.getComputedStyle(oe,null).getPropertyValue("direction")==="rtl"&&(Y=!0),function(ie){ie.preventDefault();const W=h.current;if(!W)return()=>null;const{direction:F,dragState:te,id:V,keyboardResizeBy:de,onLayout:le}=k.current,{layout:ye,panelDataArray:Oe}=C.current,{initialLayout:qe}=te??{},Qe=df(V,b,W);let j=ky(ie,b,F,te,de,W);const O=F==="horizontal";O&&Y&&(j=-j);const Z=Oe.map(Q=>Q.constraints),re=_r({delta:j,initialLayout:qe??ye,panelConstraints:Z,pivotIndices:Qe,prevLayout:ye,trigger:tf(ie)?"keyboard":"mouse-or-touch"}),ee=!ci(ye,re);(nf(ie)||rf(ie))&&E.current!=j&&(E.current=j,!ee&&j!==0?O?Rs(b,j<0?af:of):Rs(b,j<0?lf:uf):Rs(b,0)),ee&&(x(re),C.current.layout=re,le&&le(re),Rn(Oe,re,g.current))}},[]),P=pt((b,Y)=>{const{onLayout:oe}=k.current,{layout:ne,panelDataArray:ie}=C.current,W=ie.map(ye=>ye.constraints),{panelSize:F,pivotIndices:te}=gn(ie,b,ne);_e(F!=null,`Panel size not found for panel "${b.id}"`);const de=Bn(ie,b)===ie.length-1?F-Y:Y-F,le=_r({delta:de,initialLayout:ne,panelConstraints:W,pivotIndices:te,prevLayout:ne,trigger:"imperative-api"});ci(ne,le)||(x(le),C.current.layout=le,oe&&oe(le),Rn(ie,le,g.current))},[]),J=pt((b,Y)=>{const{layout:oe,panelDataArray:ne}=C.current,{collapsedSize:ie=0,collapsible:W}=Y,{collapsedSize:F=0,collapsible:te,maxSize:V=100,minSize:de=0}=b.constraints,{panelSize:le}=gn(ne,b,oe);le!=null&&(W&&te&&Xt(le,ie)?Xt(ie,F)||P(b,F):le<de?P(b,de):le>V&&P(b,V))},[P]),R=pt((b,Y)=>{const{direction:oe}=k.current,{layout:ne}=C.current;if(!h.current)return;const ie=ms(b,h.current);_e(ie,`Drag handle element not found for id "${b}"`);const W=pf(oe,Y);w({dragHandleId:b,dragHandleRect:ie.getBoundingClientRect(),initialCursorPosition:W,initialLayout:ne})},[]),q=pt(()=>{w(null)},[]),v=pt(b=>{const{panelDataArray:Y}=C.current,oe=Bn(Y,b);oe>=0&&(Y.splice(oe,1),delete g.current[b.id],C.current.panelDataArrayChanged=!0,_())},[_]),fe=ny(()=>({collapsePanel:$,direction:r,dragState:m,expandPanel:K,getPanelSize:N,getPanelStyle:I,groupId:p,isPanelCollapsed:A,isPanelExpanded:B,reevaluatePanelConstraints:J,registerPanel:D,registerResizeHandle:T,resizePanel:P,startDragging:R,stopDragging:q,unregisterPanel:v,panelGroupElement:h.current}),[$,m,r,K,N,I,p,A,B,J,D,T,P,R,q,v]),ue={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return nr(fs.Provider,{value:fe},nr(f,{...d,children:t,className:n,id:s,ref:h,style:{...ue,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const yf=Kd((e,t)=>nr(xf,{...e,forwardedRef:t}));xf.displayName="PanelGroup";yf.displayName="forwardRef(PanelGroup)";function Bn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function gn(e,t,n){const r=Bn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:s}}function Iy({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){_n(()=>{if(e||n==null||r==null)return;const i=ms(t,r);if(i==null)return;const s=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const o=i.getAttribute("data-panel-group-id");_e(o,`No group element found for id "${o}"`);const l=Vr(o,r),c=cf(o,t,r);_e(c!==null,`No resize element found for id "${t}"`);const f=a.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[f].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function bf({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:a,onFocus:o,style:l={},tabIndex:c=0,tagName:f="div",...d}){var p,h;const m=xt(null),w=xt({onDragging:a});_n(()=>{w.current.onDragging=a});const S=Yd(fs);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:x,groupId:_,registerResizeHandle:g,startDragging:z,stopDragging:E,panelGroupElement:k}=S,C=io(i),[$,K]=Kn("inactive"),[N,I]=Kn(!1),[A,B]=Kn(null),D=xt({state:$});jn(()=>{D.current.state=$}),_n(()=>{if(n)B(null);else{const R=g(C);B(()=>R)}},[n,C,g]);const T=(p=r==null?void 0:r.coarse)!==null&&p!==void 0?p:15,P=(h=r==null?void 0:r.fine)!==null&&h!==void 0?h:5;return _n(()=>{if(n||A==null)return;const R=m.current;return _e(R,"Element ref not attached"),my(C,R,x,{coarse:T,fine:P},(v,fe,ue)=>{if(fe)switch(v){case"down":{K("drag"),_e(ue,'Expected event to be defined for "down" action'),z(C,ue);const{onDragging:b}=w.current;b&&b(!0);break}case"move":{const{state:b}=D.current;b!=="drag"&&K("hover"),_e(ue,'Expected event to be defined for "move" action'),A(ue);break}case"up":{K("hover"),E();const{onDragging:b}=w.current;b&&b(!1);break}}else K("inactive")})},[T,x,n,P,g,C,A,z,E]),Iy({disabled:n,handleId:C,resizeHandler:A,panelGroupElement:k}),nr(f,{...d,children:e,className:t,id:i,onBlur:()=>{I(!1),s==null||s()},onFocus:()=>{I(!0),o==null||o()},ref:m,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":x,"data-panel-group-id":_,"data-resize-handle":"","data-resize-handle-active":$==="drag"?"pointer":N?"keyboard":void 0,"data-resize-handle-state":$,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":C})}bf.displayName="PanelResizeHandle";const zy=({className:e,...t})=>u.jsx(yf,{className:H("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Ms=ef,pl=({withHandle:e,className:t,...n})=>u.jsx(bf,{className:H("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(eg,{className:"h-2.5 w-2.5"})})});function Ty({children:e,className:t}){return u.jsx("kbd",{className:H("inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1 rounded border border-border bg-background text-[11px] font-mono font-medium text-muted-foreground shadow-[0_1px_0_0] shadow-border/50 leading-none select-none",t),children:e})}function Ay({children:e,className:t}){return u.jsx("span",{className:H("inline-flex items-center gap-0.5",t),children:e})}const di=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function wa({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return di?"⌘":"Ctrl";case"shift":return di?"⇧":"Shift";case"alt":return di?"⌥":"Alt";case"ctrl":return di?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return u.jsx(Ay,{className:t,children:r.map((i,s)=>u.jsx(Ty,{children:i},s))})}class Py{constructor(t){Mo(this,"client");this.client=Sg.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 Oy=new Py;function Dy(){const e=y.useRef(null),t=y.useCallback(async(r,i,s,a,o)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{a==null||a("parsing","Validating JSON structure...");let c;try{c=JSON.parse(i)}catch(k){throw new Error(`Invalid JSON: ${k instanceof Error?k.message:"Unknown parse error"}`)}a==null||a("building",`Building ${li.toLowerCase()} structure...`);const f={jsonDefinition:c,options:o||{}};f.customThemes=s??{},a==null||a("rendering",`Generating ${yt.toUpperCase()} content...`);const d={"Content-Type":"application/json"};o!=null&&o.bypassCache&&(d["X-Bypass-Cache"]="true");const p=await fetch(Hc.generate,{method:"POST",headers:d,body:JSON.stringify(f),signal:l.signal}),h=await p.json();if(!p.ok||!h.success){const k=h.error||h.message||`API request failed with status: ${p.status}`;throw new Error(k)}const{data:m,cache:w,warnings:S}=h,x=w.status==="HIT"?"HIT":w.status==="MISS"?"MISS":"UNKNOWN",_=x==="HIT"?`Served from cache (Hit rate: ${w.hitRate})`:`Generated fresh ${li.toLowerCase()}`;a==null||a("finalizing",_);const g=globalThis.atob(m.document),z=new Uint8Array(g.length);for(let k=0;k<g.length;k++)z[k]=g.charCodeAt(k);const E=new Blob([z],{type:m.contentType});if(E.size===0)throw new Error(`Received empty ${li.toLowerCase()} from API`);return{name:r,text:i,blob:E,filename:m.filename,fileId:m.fileId,cacheStatus:x,cacheHitRate:w.hitRate,warnings:S}}catch(c){throw c instanceof Error&&c.name==="AbortError"?new Error(`${li} generation was cancelled`):c}finally{e.current===l&&(e.current=null)}},[]),n=y.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,generateDocument:t,cancelGeneration:n}}function Ry(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const a of i){let o=a.message;if(a.context&&Object.keys(a.context).length>0){const l=Object.entries(a.context).map(([c,f])=>`${c}: ${JSON.stringify(f)}`).join(", ");o+=` (${l})`}s.push(o)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function My({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=Ee.useState("custom");Ee.useEffect(()=>{e&&s("custom")},[e]);const a=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),o=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return u.jsx(It,{open:e,onOpenChange:l=>!l&&t(),children:u.jsxs(St,{className:"max-w-md",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Non-safe fonts in this document"}),u.jsxs(cn,{children:[a," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),u.jsx("div",{className:"grid gap-2 py-2",children:o.map(l=>{const c=i===l.value;return u.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${c?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${c?"border-primary":"border-muted-foreground/50"}`,children:c&&u.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),u.jsx("span",{className:"text-sm font-medium",children:l.title})]}),u.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),u.jsxs(Cn,{children:[u.jsx(we,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),u.jsx(we,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}const hl=yt==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],$s={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function $y({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:a,isGenerating:o,isRendering:l,onShowCacheMetrics:c,onShowSchemas:f,onShowFonts:d,documentText:p,warnings:h,renderingLibrary:m,setRenderingLibrary:w,onToggleChat:S,chatOpen:x,onTogglePreview:_,previewOpen:g}){const z=m!=="docxjs",[E,k]=y.useState(!1),[C,$]=y.useState(!1),[K,N]=y.useState(!1),[I,A]=y.useState(!1),[B,D]=y.useState(!1),[T,P]=y.useState(!1),{toast:J}=Xr(),{generateDocument:R}=Dy(),q=y.useContext(sd),v=y.useCallback(()=>{const V={},{customThemes:de}=q.getState();return Object.values(de).forEach(le=>{le.valid&&le.parsed&&(V[le.name]=le.parsed)}),V},[q]),fe=Ee.useMemo(()=>{if(!p)return[];try{const V=JSON.parse(p);return[...(yt==="pptx"?$m:Fm)(V)].filter(le=>!Lm(le))}catch{return[]}},[p]),[ue,b]=y.useState(!1),Y=y.useCallback(async()=>{if(t){k(!0);try{await new Promise(V=>setTimeout(V,100)),ji(`${e}${fr}`,t)}finally{setTimeout(()=>k(!1),500)}}},[t,e]),oe=y.useCallback(async()=>{if(t){if(fe.length===0){await Y();return}b(!0)}},[t,fe.length,Y]),ne=y.useCallback(async V=>{var de;if(p){k(!0);try{const le=await R(e,p,v(),void 0,{bypassCache:!0,fonts:{mode:V}});if(le.blob.size===0)J({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{ji(`${e}${fr}`,le.blob);const ye=(de=le.warnings)==null?void 0:de.find(Oe=>{var qe,Qe;return((qe=Oe.context)==null?void 0:qe.code)==="FONT_MODE_SUBSTITUTED"||((Qe=Oe.context)==null?void 0:Qe.code)==="FONT_MODE_CUSTOM"});ye&&J({title:V==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:ye.message})}}catch(le){J({title:"Export failed",description:le instanceof Error?le.message:String(le),variant:"destructive"})}finally{setTimeout(()=>k(!1),500)}}},[p,e,R,J,v]),ie=y.useCallback(async()=>{if(!(!h||h.length===0)){$(!0);try{const V=Ry(h);if(!V){J({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const de=await R("warnings",JSON.stringify(V,null,2),{});de&&typeof de=="object"&&"blob"in de&&de.blob&&(ji(`${e}-warnings${fr}`,de.blob),J({title:"Warnings downloaded",description:`Downloaded warnings document with ${h.length} warning(s).`}))}catch(V){console.error("Failed to generate warnings document:",V),J({title:"Download failed",description:V instanceof Error?V.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>$(!1),500)}}},[h,e,R,J]),W=y.useCallback(async()=>{const V=r==null?void 0:r.current;if(V!=null&&V.src){N(!0);try{await new Promise(le=>{let ye=null,Oe=!1;const qe=()=>{ye&&(clearTimeout(ye),ye=null),V.removeEventListener("load",j),V.removeEventListener("error",O)},Qe=()=>{Oe||(Oe=!0,qe(),le())},j=()=>Qe(),O=()=>Qe();V.addEventListener("load",j),V.addEventListener("error",O),ye=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),Qe()},5e3);const Z=V.src,re=Z.includes("?")?"&":"?",ee=Date.now();V.src=`${Z}${re}_reload=${ee}`})}catch(de){console.error("Iframe reload failed:",de)}finally{N(!1)}}},[r]),F=y.useCallback(async()=>{A(!0);try{await Oy.delete(`/${yt}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),J({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(V){console.error("Failed to clear cache:",V),J({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{A(!1)}},[J]),te=y.useCallback(async()=>{if(!p){J({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}P(!0);try{const V=await fetch(`/api/${yt}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:p})});if(!V.ok){let ye=`Request failed with status ${V.status}`;try{const Oe=await V.json();Oe.message&&(ye=Oe.message)}catch{}J({title:"Failed to get standard components",description:ye,variant:"destructive"});return}const de=await V.json(),le=JSON.stringify(de.data,null,2);await navigator.clipboard.writeText(le),J({title:"Copied to clipboard",description:"Standard modules JSON has been copied"})}catch(V){console.error("Error copying standard components:",V),J({title:"Error",description:V instanceof Error?V.message:"Failed to copy standard components",variant:"destructive"})}finally{P(!1)}},[p,J]);return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-sidebar 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(We,{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 hover:bg-muted/60 shrink-0",children:u.jsx(ed,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),u.jsx(Ke,{className:"max-w-sm",children:u.jsxs("p",{className:"text-sm",children:["Preview uses"," ",yt==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",fr," to verify fidelity."]})})]})]}),u.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||z)&&u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(we,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:a,"aria-label":"Render preview",disabled:o||l||g===!1,children:[l?u.jsx(Yt,{size:"sm"}):u.jsx(tg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),u.jsx(Ke,{children:u.jsx("p",{children:g===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),yt==="docx"&&u.jsxs(We,{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(Gn,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),u.jsx(eo,{checked:i,onCheckedChange:s,disabled:z})]})}),u.jsx(Ke,{children:u.jsx("p",{children:z?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:W,disabled:K||o||l,children:K?u.jsx(Yt,{size:"sm"}):u.jsx(ng,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsx("p",{children:K?"Reloading...":"Reload"})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(we,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||E||o,onClick:oe,children:[E?u.jsx(Yt,{size:"sm"}):u.jsx(rg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download ",fr]})})]}),h&&h.length>0&&u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:"outline",size:"icon",className:"h-7 w-7 bg-amber-50 dark:bg-amber-950 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800 hover:bg-amber-100 dark:hover:bg-amber-900",disabled:C||o,onClick:ie,children:C?u.jsx(Yt,{size:"sm"}):u.jsx(td,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("p",{children:["Download warnings (",h.length,")"]})})]}),m&&w&&u.jsxs(Rr,{value:m,onValueChange:w,children:[u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(er,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:u.jsx(Mr,{placeholder:"Renderer"})})}),u.jsx(Ke,{children:u.jsx("p",{children:"Select the rendering library"})})]}),u.jsx(tr,{className:"text-sidebar-foreground",children:hl.map(V=>u.jsxs(En,{value:V,children:[u.jsxs(We,{children:[u.jsx(Ge,{tabIndex:-1,children:$s[V][0]}),u.jsx(Ke,{children:$s[V][1]})]})," ",V]},V))})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(to,{children:[u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(no,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7",children:u.jsx(ig,{className:"h-3.5 w-3.5"})})})}),u.jsx(Ke,{children:u.jsx("p",{children:"More actions"})})]}),u.jsxs(ds,{align:"end",className:"w-52",children:[f&&u.jsxs(Kt,{onClick:f,children:[u.jsx(sg,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),d&&u.jsxs(Kt,{onClick:d,children:[u.jsx(ag,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),c&&u.jsxs(Kt,{onClick:c,children:[u.jsx(og,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),u.jsxs(Kt,{onClick:te,disabled:!p||T,children:[u.jsx(nd,{className:"h-4 w-4 mr-2"}),T?"Copying...":"Copy standard components"]}),u.jsx(Fr,{}),u.jsxs(Kt,{onClick:()=>D(!0),disabled:I,className:"text-destructive focus:text-destructive",children:[u.jsx(Ha,{className:"h-4 w-4 mr-2"}),I?"Clearing...":"Clear all caches"]}),m&&w&&u.jsxs(u.Fragment,{children:[u.jsx(Fr,{className:"lg:hidden"}),hl.map(V=>u.jsxs(Kt,{className:"lg:hidden",onClick:()=>w(V),children:[u.jsx("span",{className:"mr-2",children:m===V?"●":"○"}),$s[V][0]," ",V]},V))]})]})]}),_&&u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:g?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:_,children:g?u.jsx(rd,{className:"h-3.5 w-3.5"}):u.jsx(lg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[g?"Hide":"Show"," Preview"," ",u.jsx(wa,{shortcut:"mod+shift+p"})]})})]}),S&&u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(we,{variant:x?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:S,children:u.jsx(id,{className:"h-3.5 w-3.5"})})}),u.jsx(Ke,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[x?"Close":"Open"," AI Chat"," ",u.jsx(wa,{shortcut:"mod+shift+j"})]})})]})]})]}),u.jsx(My,{open:ue,onClose:()=>b(!1),nonSafeFonts:fe,onChoose:ne}),u.jsx(It,{open:B,onOpenChange:D,children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear all caches?"}),u.jsx(cn,{children:"This will clear document and component caches. Next generation will be uncached."})]}),u.jsxs(Cn,{children:[u.jsx(we,{variant:"outline",size:"sm",onClick:()=>D(!1),children:"Cancel"}),u.jsx(we,{variant:"destructive",size:"sm",disabled:I,onClick:async()=>{await F(),D(!1)},children:I?u.jsx(Yt,{size:"sm"}):"Clear"})]})]})})]})}const Fy=Ee.memo($y);function Ly(e,t,n){if(t.length===0)return n;const r=ml(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const a=t[s],o=t[s+1],l=i[a],c=ml(l,o);i[a]=c,i=c}return i[t[t.length-1]]=n,r}function ml(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const Zy={safe:[],google:[]};function By(e,t){var f;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((f=r==null?void 0:r.dataset.weights)==null?void 0:f.split(",").map(Number).filter(d=>!Number.isNaN(d)))??[]),a=new Set([...s,...i]);if(r&&a.size===s.size)return;const o=[...a].sort((d,p)=>d-p).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${o}&display=swap`,c=r??document.createElement("link");r||(c.id=n,c.rel="stylesheet",document.head.appendChild(c)),c.href=l,c.dataset.weights=[...a].sort((d,p)=>d-p).join(",")}function Vy(){const e=Ae(i=>i.activeTab),t=Ae(i=>i.documents),n=Ae(i=>i.documentTypes),r=Ae(i=>i.saveDocument);return y.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 a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active theme is not valid JSON: ${l.message}`}}const o=i(a);return r(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n,r])}function Uy(){const e=Ae(r=>r.activeTab),t=Ae(r=>r.documents),n=Ae(r=>r.saveDocument);return y.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 a;try{a=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active document is not valid JSON: ${l.message}`}}const o=Ly(a,r,i);return n(e,JSON.stringify(o,null,2)),{ok:!0,name:e}},[e,t,n])}function Jy(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 gl(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const Hy=({open:e,onOpenChange:t})=>{const n=vi(P=>P.open),r=vi(P=>P.contextual),i=vi(P=>P.close),s=e??n,a=r,o=y.useCallback(P=>{t&&t(P),P||i()},[t,i]),[l,c]=y.useState(Zy),[f,d]=y.useState(!1),[p,h]=y.useState(""),[m,w]=y.useState("safe"),[S,x]=y.useState(null),[_,g]=y.useState(null),{toast:z}=Xr(),E=Vy(),k=Uy(),C=Ae(P=>P.activeTab),$=Ae(P=>P.documentTypes),K=C&&$[C]==="application/json+theme",N=!!a||K;y.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(d(!0),fetch("/api/fonts/catalog").then(P=>P.json()).then(P=>c(P)).catch(P=>{z({variant:"destructive",title:"Font catalog unavailable",description:P.message})}).finally(()=>d(!1))))},[s,l,z]),y.useEffect(()=>{if(!(m!=="google"||l.google.length===0))for(const P of l.google)By(P.family,P.weights)},[m,l]);const I=y.useMemo(()=>l.safe.filter(P=>P.toLowerCase().includes(p.toLowerCase())),[l.safe,p]),A=y.useMemo(()=>l.google.filter(P=>P.family.toLowerCase().includes(p.toLowerCase())),[l.google,p]),B=y.useCallback(async P=>{try{await navigator.clipboard.writeText(P),g(P),setTimeout(()=>g(null),1500)}catch{z({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[z]),D=y.useCallback(async(P,J,R)=>{x(P);try{const q=E(v=>(Jy(v,R,P),v));if(!q.ok){z({variant:"destructive",title:"Could not insert font",description:q.error});return}z({title:"Font inserted",description:`${P} set as ${R} font in "${q.name}".`})}finally{x(null)}},[E,z]),T=y.useCallback(async P=>{if(a){x(P);try{const J=k(a.jsonPath,P);if(!J.ok){z({variant:"destructive",title:"Could not insert font",description:J.error});return}z({title:"Font inserted",description:`${P} set at ${gl(a.jsonPath)}.`}),o(!1)}finally{x(null)}}},[a,k,z,o]);return u.jsx(It,{open:s,onOpenChange:o,children:u.jsxs(St,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ut,{children:u.jsx(Jt,{children:a?`Font for ${gl(a.jsonPath)}`:"Fonts"})}),!a&&!K&&u.jsx(Ri,{children:u.jsxs(Mi,{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(Wd,{value:m,onValueChange:P=>w(P),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(ro,{children:[u.jsxs(Lr,{value:"safe",children:["Safe",u.jsx(Vt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),u.jsxs(Lr,{value:"google",children:["Google",u.jsx(Vt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]})]}),u.jsx(ei,{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(Zr,{value:"safe",className:"m-0",children:f&&I.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(ua,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:I.map(P=>u.jsx(xl,{family:P,meta:u.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${P}", sans-serif`},onCopy:()=>B(P),copied:_===P,contextual:!!a,onUseThis:()=>T(P),onInsertHeading:()=>D(P,"safe","heading"),onInsertBody:()=>D(P,"safe","body"),applying:S===P,disabled:!N},P))})}),u.jsx(Zr,{value:"google",className:"m-0",children:f&&A.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(ua,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:A.map(P=>u.jsx(xl,{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:_===P.family,contextual:!!a,onUseThis:()=>T(P.family),onInsertHeading:()=>D(P.family,"google","heading"),onInsertBody:()=>D(P.family,"google","body"),applying:S===P.family,disabled:!N,extraAction:u.jsx(Wy,{family:P.family,weights:P.weights,hasItalic:P.hasItalic})},P.family))})})]})]})]})})},qy="The quick brown fox jumps over the lazy dog",Wy=({family:e,weights:t,hasItalic:n})=>{const r=y.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return u.jsxs(to,{children:[u.jsx(no,{asChild:!0,children:u.jsx(we,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),u.jsxs(ds,{align:"end",className:"min-w-[260px]",children:[u.jsxs(qd,{className:"text-xs text-muted-foreground",children:[r.length," weight",r.length===1?"":"s",n?" · italic available":""]}),u.jsx(Fr,{}),r.map(i=>{const s=Zm[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)})]})]})},xl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:a,onInsertHeading:o,onInsertBody:l,applying:c,disabled:f,extraAction:d})=>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:qy}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?u.jsx(we,{size:"sm",onClick:a,disabled:c||f,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):u.jsxs(u.Fragment,{children:[u.jsx(we,{size:"sm",variant:"secondary",onClick:o,disabled:c||f,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),u.jsx(we,{size:"sm",variant:"secondary",onClick:l,disabled:c||f,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),d,u.jsx(we,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?u.jsx(un,{className:"h-4 w-4"}):u.jsx(as,{className:"h-4 w-4"})})]})]});function yl({previewOpen:e,onTogglePreview:t}){const n=vn($=>$.name||""),r=vn($=>$.blob),i=vn($=>$.isGenerating),s=vn($=>$.text),a=vn($=>$.warnings),o=vn($=>$.isRendering),l=ui($=>$.autoReload),c=ui($=>$.renderingLibrary),f=ui($=>$.setSettings),d=ui($=>$.useGlobalPreviewHeader??!0),p=Ae($=>$.activeTab),h=Ae($=>$.documentTypes),m=p&&h[p]==="application/json+theme"?"theme":"document",w=Te($=>$.chatOpen),S=Te($=>$.toggleChat),[x,_]=Ee.useState(!1),g=vi($=>$.openFor);if(!d)return null;const z=y.useCallback(()=>f({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,f]),E=y.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),k=y.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),C=(n==null?void 0:n.trim())||"Preview";return u.jsxs("div",{className:"sticky top-0 z-20",children:[u.jsx(Fy,{name:C,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:z,onManualRender:E,isGenerating:i,isRendering:!!o,onShowCacheMetrics:k,onShowSchemas:()=>_(!0),onShowFonts:()=>g(),documentText:s,warnings:a,renderingLibrary:c,setRenderingLibrary:$=>f({renderingLibrary:$}),onToggleChat:S,chatOpen:w,onTogglePreview:t,previewOpen:e}),u.jsx(Gd,{open:x,onOpenChange:_,defaultTab:m==="theme"?"theme":"document"}),u.jsx(Hy,{})]})}function Gy(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Ky=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Yy=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Xy={};function bl(e,t){return(Xy.jsx?Yy:Ky).test(e)}const Qy=/[ \t\n\f\r]/g;function eb(e){return typeof e=="object"?e.type==="text"?vl(e.value):!1:vl(e)}function vl(e){return e.replace(Qy,"")===""}class ni{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ni.prototype.normal={};ni.prototype.property={};ni.prototype.space=void 0;function vf(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new ni(n,r,t)}function ka(e){return e.toLowerCase()}class bt{constructor(t,n){this.attribute=n,this.property=t}}bt.prototype.attribute="";bt.prototype.booleanish=!1;bt.prototype.boolean=!1;bt.prototype.commaOrSpaceSeparated=!1;bt.prototype.commaSeparated=!1;bt.prototype.defined=!1;bt.prototype.mustUseProperty=!1;bt.prototype.number=!1;bt.prototype.overloadedBoolean=!1;bt.prototype.property="";bt.prototype.spaceSeparated=!1;bt.prototype.space=void 0;let tb=0;const ke=An(),tt=An(),Sa=An(),X=An(),Fe=An(),Xn=An(),wt=An();function An(){return 2**++tb}const _a=Object.freeze(Object.defineProperty({__proto__:null,boolean:ke,booleanish:tt,commaOrSpaceSeparated:wt,commaSeparated:Xn,number:X,overloadedBoolean:Sa,spaceSeparated:Fe},Symbol.toStringTag,{value:"Module"})),Fs=Object.keys(_a);class lo extends bt{constructor(t,n,r,i){let s=-1;if(super(t,n),wl(this,"space",i),typeof r=="number")for(;++s<Fs.length;){const a=Fs[s];wl(this,Fs[s],(r&_a[a])===_a[a])}}}lo.prototype.defined=!0;function wl(e,t,n){n&&(e[t]=n)}function lr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new lo(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ka(r)]=r,n[ka(s.attribute)]=r}return new ni(t,n,e.space)}const wf=lr({properties:{ariaActiveDescendant:null,ariaAtomic:tt,ariaAutoComplete:null,ariaBusy:tt,ariaChecked:tt,ariaColCount:X,ariaColIndex:X,ariaColSpan:X,ariaControls:Fe,ariaCurrent:null,ariaDescribedBy:Fe,ariaDetails:null,ariaDisabled:tt,ariaDropEffect:Fe,ariaErrorMessage:null,ariaExpanded:tt,ariaFlowTo:Fe,ariaGrabbed:tt,ariaHasPopup:null,ariaHidden:tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Fe,ariaLevel:X,ariaLive:null,ariaModal:tt,ariaMultiLine:tt,ariaMultiSelectable:tt,ariaOrientation:null,ariaOwns:Fe,ariaPlaceholder:null,ariaPosInSet:X,ariaPressed:tt,ariaReadOnly:tt,ariaRelevant:null,ariaRequired:tt,ariaRoleDescription:Fe,ariaRowCount:X,ariaRowIndex:X,ariaRowSpan:X,ariaSelected:tt,ariaSetSize:X,ariaSort:null,ariaValueMax:X,ariaValueMin:X,ariaValueNow:X,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function kf(e,t){return t in e?e[t]:t}function Sf(e,t){return kf(e,t.toLowerCase())}const nb=lr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Xn,acceptCharset:Fe,accessKey:Fe,action:null,allow:null,allowFullScreen:ke,allowPaymentRequest:ke,allowUserMedia:ke,alt:null,as:null,async:ke,autoCapitalize:null,autoComplete:Fe,autoFocus:ke,autoPlay:ke,blocking:Fe,capture:null,charSet:null,checked:ke,cite:null,className:Fe,cols:X,colSpan:null,content:null,contentEditable:tt,controls:ke,controlsList:Fe,coords:X|Xn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ke,defer:ke,dir:null,dirName:null,disabled:ke,download:Sa,draggable:tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ke,formTarget:null,headers:Fe,height:X,hidden:Sa,high:X,href:null,hrefLang:null,htmlFor:Fe,httpEquiv:Fe,id:null,imageSizes:null,imageSrcSet:null,inert:ke,inputMode:null,integrity:null,is:null,isMap:ke,itemId:null,itemProp:Fe,itemRef:Fe,itemScope:ke,itemType:Fe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ke,low:X,manifest:null,max:null,maxLength:X,media:null,method:null,min:null,minLength:X,multiple:ke,muted:ke,name:null,nonce:null,noModule:ke,noValidate:ke,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ke,optimum:X,pattern:null,ping:Fe,placeholder:null,playsInline:ke,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ke,referrerPolicy:null,rel:Fe,required:ke,reversed:ke,rows:X,rowSpan:X,sandbox:Fe,scope:null,scoped:ke,seamless:ke,selected:ke,shadowRootClonable:ke,shadowRootDelegatesFocus:ke,shadowRootMode:null,shape:null,size:X,sizes:null,slot:null,span:X,spellCheck:tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:X,step:null,style:null,tabIndex:X,target:null,title:null,translate:null,type:null,typeMustMatch:ke,useMap:null,value:tt,width:X,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Fe,axis:null,background:null,bgColor:null,border:X,borderColor:null,bottomMargin:X,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ke,declare:ke,event:null,face:null,frame:null,frameBorder:null,hSpace:X,leftMargin:X,link:null,longDesc:null,lowSrc:null,marginHeight:X,marginWidth:X,noResize:ke,noHref:ke,noShade:ke,noWrap:ke,object:null,profile:null,prompt:null,rev:null,rightMargin:X,rules:null,scheme:null,scrolling:tt,standby:null,summary:null,text:null,topMargin:X,valueType:null,version:null,vAlign:null,vLink:null,vSpace:X,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ke,disableRemotePlayback:ke,prefix:null,property:null,results:X,security:null,unselectable:null},space:"html",transform:Sf}),rb=lr({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:wt,accentHeight:X,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:X,amplitude:X,arabicForm:null,ascent:X,attributeName:null,attributeType:null,azimuth:X,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:X,by:null,calcMode:null,capHeight:X,className:Fe,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:X,diffuseConstant:X,direction:null,display:null,dur:null,divisor:X,dominantBaseline:null,download:ke,dx:null,dy:null,edgeMode:null,editable:null,elevation:X,enableBackground:null,end:null,event:null,exponent:X,externalResourcesRequired:null,fill:null,fillOpacity:X,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:Xn,g2:Xn,glyphName:Xn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:X,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:X,horizOriginX:X,horizOriginY:X,id:null,ideographic:X,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:X,k:X,k1:X,k2:X,k3:X,k4:X,kernelMatrix:wt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:X,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:X,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:X,overlineThickness:X,paintOrder:null,panose1:null,path:null,pathLength:X,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Fe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:X,pointsAtY:X,pointsAtZ:X,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:wt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:wt,rev:wt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:wt,requiredFeatures:wt,requiredFonts:wt,requiredFormats:wt,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:X,specularExponent:X,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:X,strikethroughThickness:X,string:null,stroke:null,strokeDashArray:wt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:X,strokeOpacity:X,strokeWidth:null,style:null,surfaceScale:X,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:wt,tabIndex:X,tableValues:null,target:null,targetX:X,targetY:X,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:wt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:X,underlineThickness:X,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:X,values:null,vAlphabetic:X,vMathematical:X,vectorEffect:null,vHanging:X,vIdeographic:X,version:null,vertAdvY:X,vertOriginX:X,vertOriginY:X,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:X,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:kf}),_f=lr({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()}}),jf=lr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Sf}),Nf=lr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),ib={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"},sb=/[A-Z]/g,kl=/-[a-z]/g,ab=/^data[-\w.:]+$/i;function ob(e,t){const n=ka(t);let r=t,i=bt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ab.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(kl,ub);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!kl.test(s)){let a=s.replace(sb,lb);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=lo}return new i(r,t)}function lb(e){return"-"+e.toLowerCase()}function ub(e){return e.charAt(1).toUpperCase()}const cb=vf([wf,nb,_f,jf,Nf],"html"),uo=vf([wf,rb,_f,jf,Nf],"svg");function db(e){return e.join(" ").trim()}var Mn={},Ls,Sl;function fb(){if(Sl)return Ls;Sl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
|
|
3
|
+
`,c="/",f="*",d="",p="comment",h="declaration";function m(S,x){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];x=x||{};var _=1,g=1;function z(D){var T=D.match(t);T&&(_+=T.length);var P=D.lastIndexOf(l);g=~P?D.length-P:g+D.length}function E(){var D={line:_,column:g};return function(T){return T.position=new k(D),K(),T}}function k(D){this.start=D,this.end={line:_,column:g},this.source=x.source}k.prototype.content=S;function C(D){var T=new Error(x.source+":"+_+":"+g+": "+D);if(T.reason=D,T.filename=x.source,T.line=_,T.column=g,T.source=S,!x.silent)throw T}function $(D){var T=D.exec(S);if(T){var P=T[0];return z(P),S=S.slice(P.length),T}}function K(){$(n)}function N(D){var T;for(D=D||[];T=I();)T!==!1&&D.push(T);return D}function I(){var D=E();if(!(c!=S.charAt(0)||f!=S.charAt(1))){for(var T=2;d!=S.charAt(T)&&(f!=S.charAt(T)||c!=S.charAt(T+1));)++T;if(T+=2,d===S.charAt(T-1))return C("End of comment missing");var P=S.slice(2,T-2);return g+=2,z(P),S=S.slice(T),g+=2,D({type:p,comment:P})}}function A(){var D=E(),T=$(r);if(T){if(I(),!$(i))return C("property missing ':'");var P=$(s),J=D({type:h,property:w(T[0].replace(e,d)),value:P?w(P[0].replace(e,d)):d});return $(a),J}}function B(){var D=[];N(D);for(var T;T=A();)T!==!1&&(D.push(T),N(D));return D}return K(),B()}function w(S){return S?S.replace(o,d):d}return Ls=m,Ls}var _l;function pb(){if(_l)return Mn;_l=1;var e=Mn&&Mn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.default=n;const t=e(fb());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:f}=l;o?i(c,f,l):f&&(s=s||{},s[c]=f)}),s}return Mn}var xr={},jl;function hb(){if(jl)return xr;jl=1,Object.defineProperty(xr,"__esModule",{value:!0}),xr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},a=function(c,f){return f.toUpperCase()},o=function(c,f){return"".concat(f,"-")},l=function(c,f){return f===void 0&&(f={}),s(c)?c:(c=c.toLowerCase(),f.reactCompat?c=c.replace(i,o):c=c.replace(r,o),c.replace(t,a))};return xr.camelCase=l,xr}var yr,Nl;function mb(){if(Nl)return yr;Nl=1;var e=yr&&yr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(pb()),n=hb();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,yr=r,yr}var gb=mb();const xb=Ua(gb),Cf=Ef("end"),co=Ef("start");function Ef(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 yb(e){const t=co(e),n=Cf(e);if(t&&n)return{start:t,end:n}}function Pr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Cl(e.position):"start"in e||"end"in e?Cl(e):"line"in e||"column"in e?ja(e):""}function ja(e){return El(e&&e.line)+":"+El(e&&e.column)}function Cl(e){return ja(e&&e.start)+"-"+ja(e&&e.end)}function El(e){return e&&typeof e=="number"?e:1}class at extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=Pr(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}at.prototype.file="";at.prototype.name="";at.prototype.reason="";at.prototype.message="";at.prototype.stack="";at.prototype.column=void 0;at.prototype.line=void 0;at.prototype.ancestors=void 0;at.prototype.cause=void 0;at.prototype.fatal=void 0;at.prototype.place=void 0;at.prototype.ruleId=void 0;at.prototype.source=void 0;const fo={}.hasOwnProperty,bb=new Map,vb=/[A-Z]/g,wb=new Set(["table","tbody","thead","tfoot","tr"]),kb=new Set(["td","th"]),If="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Sb(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=Tb(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=zb(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"?uo:cb,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=zf(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function zf(e,t,n){if(t.type==="element")return _b(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return jb(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Cb(e,t,n);if(t.type==="mdxjsEsm")return Nb(e,t);if(t.type==="root")return Eb(e,t,n);if(t.type==="text")return Ib(e,t)}function _b(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=uo,e.schema=i),e.ancestors.push(t);const s=Af(e,t.tagName,!1),a=Ab(e,t);let o=ho(e,t);return wb.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!eb(l):!0})),Tf(e,a,s,t),po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function jb(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)}Ur(e,t.position)}function Nb(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ur(e,t.position)}function Cb(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=uo,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Af(e,t.name,!0),a=Pb(e,t),o=ho(e,t);return Tf(e,a,s,t),po(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Eb(e,t,n){const r={};return po(r,ho(e,t)),e.create(t,e.Fragment,r,n)}function Ib(e,t){return t.value}function Tf(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function po(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function zb(e,t,n){return r;function r(i,s,a,o){const c=Array.isArray(a.children)?n:t;return o?c(s,a,o):c(s,a)}}function Tb(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),l=co(r);return t(i,s,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function Ab(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&fo.call(t.properties,i)){const s=Ob(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&kb.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Pb(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Ur(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else Ur(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function ho(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:bb;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;a=l+"-"+c,i.set(l,c+1)}}const o=zf(e,s,a);o!==void 0&&n.push(o)}return n}function Ob(e,t,n){const r=ob(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Gy(n):db(n)),r.property==="style"){let i=typeof n=="object"?n:Db(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Rb(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?ib[r.property]||r.property:r.attribute,n]}}function Db(e,t){try{return xb(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new at("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=If+"#cannot-parse-style-attribute",i}}function Af(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=bl(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=bl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return fo.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ur(e)}function Ur(e,t){const n=new at("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=If+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Rb(e){const t={};let n;for(n in e)fo.call(e,n)&&(t[Mb(n)]=e[n]);return t}function Mb(e){let t=e.replace(vb,$b);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function $b(e){return"-"+e.toLowerCase()}const Zs={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"]},Fb={};function mo(e,t){const n=Fb,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Pf(e,r,i)}function Pf(e,t,n){if(Lb(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 Il(e.children,t,n)}return Array.isArray(e)?Il(e,t,n):""}function Il(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Pf(e[i],t,n);return r.join("")}function Lb(e){return!!(e&&typeof e=="object")}const zl=document.createElement("i");function go(e){const t="&"+e+";";zl.innerHTML=t;const n=zl.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function _t(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Et(e,t){return e.length>0?(_t(e,e.length,0,t),e):t}const Tl={}.hasOwnProperty;function Of(e){const t={};let n=-1;for(;++n<e.length;)Zb(t,e[n]);return t}function Zb(e,t){let n;for(n in t){const i=(Tl.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Tl.call(i,a)||(i[a]=[]);const o=s[a];Bb(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Bb(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);_t(e,0,0,r)}function Df(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 Mt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const dt=pn(/[A-Za-z]/),st=pn(/[\dA-Za-z]/),Vb=pn(/[#-'*+\--9=?A-Z^-~]/);function Bi(e){return e!==null&&(e<32||e===127)}const Na=pn(/\d/),Ub=pn(/[\dA-Fa-f]/),Jb=pn(/[!-/:-@[-`{-~]/);function ge(e){return e!==null&&e<-2}function Me(e){return e!==null&&(e<0||e===32)}function Ne(e){return e===-2||e===-1||e===32}const gs=pn(new RegExp("\\p{P}|\\p{S}","u")),zn=pn(/\s/);function pn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ur(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&st(e.charCodeAt(n+1))&&st(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ze(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Ne(l)?(e.enter(n),o(l)):t(l)}function o(l){return Ne(l)&&s++<i?(e.consume(l),o):(e.exit(n),t(l))}}const Hb={tokenize:qb};function qb(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ze(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return ge(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Wb={tokenize:Gb},Al={tokenize:Kb};function Gb(e){const t=this,n=[];let r=0,i,s,a;return o;function o(g){if(r<n.length){const z=n[r];return t.containerState=z[1],e.attempt(z[0].continuation,l,c)(g)}return c(g)}function l(g){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const z=t.events.length;let E=z,k;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){k=t.events[E][1].end;break}x(r);let C=z;for(;C<t.events.length;)t.events[C][1].end={...k},C++;return _t(t.events,E+1,0,t.events.slice(z)),t.events.length=C,c(g)}return o(g)}function c(g){if(r===n.length){if(!i)return p(g);if(i.currentConstruct&&i.currentConstruct.concrete)return m(g);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Al,f,d)(g)}function f(g){return i&&_(),x(r),p(g)}function d(g){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(g)}function p(g){return t.containerState={},e.attempt(Al,h,m)(g)}function h(g){return r++,n.push([t.currentConstruct,t.containerState]),p(g)}function m(g){if(g===null){i&&_(),x(0),e.consume(g);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(g)}function w(g){if(g===null){S(e.exit("chunkFlow"),!0),x(0),e.consume(g);return}return ge(g)?(e.consume(g),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(g),w)}function S(g,z){const E=t.sliceStream(g);if(z&&E.push(null),g.previous=s,s&&(s.next=g),s=g,i.defineSkip(g.start),i.write(E),t.parser.lazy[g.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<a&&(!i.events[k][1].end||i.events[k][1].end.offset>a))return;const C=t.events.length;let $=C,K,N;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){if(K){N=t.events[$][1].end;break}K=!0}for(x(r),k=C;k<t.events.length;)t.events[k][1].end={...N},k++;_t(t.events,$+1,0,t.events.slice(C)),t.events.length=k}}function x(g){let z=n.length;for(;z-- >g;){const E=n[z];t.containerState=E[1],E[0].exit.call(t,e)}n.length=g}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Kb(e,t,n){return ze(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function rr(e){if(e===null||Me(e)||zn(e))return 1;if(gs(e))return 2}function xs(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 Ca={name:"attention",resolveAll:Yb,tokenize:Xb};function Yb(e,t){let n=-1,r,i,s,a,o,l,c,f;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 d={...e[r][1].end},p={...e[n][1].start};Pl(d,-l),Pl(p,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},o={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:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Et(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Et(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),c=Et(c,xs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Et(c,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,c=Et(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,_t(e,r-1,n-r+3,c),n=r+c.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Xb(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=rr(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const c=e.exit("attentionSequence"),f=rr(l),d=!f||f===2&&i||n.includes(l),p=!i||i===2&&f||n.includes(r);return c._open=!!(s===42?d:d&&(i||!p)),c._close=!!(s===42?p:p&&(f||!d)),t(l)}}function Pl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Qb={name:"autolink",tokenize:ev};function ev(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 dt(h)?(e.consume(h),a):h===64?n(h):c(h)}function a(h){return h===43||h===45||h===46||st(h)?(r=1,o(h)):c(h)}function o(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||st(h))&&r++<32?(e.consume(h),o):(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||Bi(h)?n(h):(e.consume(h),l)}function c(h){return h===64?(e.consume(h),f):Vb(h)?(e.consume(h),c):n(h)}function f(h){return st(h)?d(h):n(h)}function d(h){return h===46?(e.consume(h),r=0,f):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||st(h))&&r++<63){const m=h===45?p:d;return e.consume(h),m}return n(h)}}const ri={partial:!0,tokenize:tv};function tv(e,t,n){return r;function r(s){return Ne(s)?ze(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||ge(s)?t(s):n(s)}}const Rf={continuation:{tokenize:rv},exit:iv,name:"blockQuote",tokenize:nv};function nv(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return Ne(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function rv(e,t,n){const r=this;return i;function i(a){return Ne(a)?ze(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Rf,t,n)(a)}}function iv(e){e.exit("blockQuote")}const Mf={name:"characterEscape",tokenize:sv};function sv(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 Jb(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const $f={name:"characterReference",tokenize:av};function av(e,t,n){const r=this;let i=0,s,a;return o;function o(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,a=st,f(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Ub,f):(e.enter("characterReferenceValue"),s=7,a=Na,f(d))}function f(d){if(d===59&&i){const p=e.exit("characterReferenceValue");return a===st&&!go(r.sliceSerialize(p))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&i++<s?(e.consume(d),f):n(d)}}const Ol={partial:!0,tokenize:lv},Dl={concrete:!0,name:"codeFenced",tokenize:ov};function ov(e,t,n){const r=this,i={partial:!0,tokenize:E};let s=0,a=0,o;return l;function l(k){return c(k)}function c(k){const C=r.events[r.events.length-1];return s=C&&C[1].type==="linePrefix"?C[2].sliceSerialize(C[1],!0).length:0,o=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(k)}function f(k){return k===o?(a++,e.consume(k),f):a<3?n(k):(e.exit("codeFencedFenceSequence"),Ne(k)?ze(e,d,"whitespace")(k):d(k))}function d(k){return k===null||ge(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Ol,w,z)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(k))}function p(k){return k===null||ge(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ne(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ze(e,h,"whitespace")(k)):k===96&&k===o?n(k):(e.consume(k),p)}function h(k){return k===null||ge(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||ge(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===o?n(k):(e.consume(k),m)}function w(k){return e.attempt(i,z,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Ne(k)?ze(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||ge(k)?e.check(Ol,w,z)(k):(e.enter("codeFlowValue"),g(k))}function g(k){return k===null||ge(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),g)}function z(k){return e.exit("codeFenced"),t(k)}function E(k,C,$){let K=0;return N;function N(T){return k.enter("lineEnding"),k.consume(T),k.exit("lineEnding"),I}function I(T){return k.enter("codeFencedFence"),Ne(T)?ze(k,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):A(T)}function A(T){return T===o?(k.enter("codeFencedFenceSequence"),B(T)):$(T)}function B(T){return T===o?(K++,k.consume(T),B):K>=a?(k.exit("codeFencedFenceSequence"),Ne(T)?ze(k,D,"whitespace")(T):D(T)):$(T)}function D(T){return T===null||ge(T)?(k.exit("codeFencedFence"),C(T)):$(T)}}}function lv(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Bs={name:"codeIndented",tokenize:cv},uv={partial:!0,tokenize:dv};function cv(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ze(e,s,"linePrefix",5)(c)}function s(c){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(c):n(c)}function a(c){return c===null?l(c):ge(c)?e.attempt(uv,a,l)(c):(e.enter("codeFlowValue"),o(c))}function o(c){return c===null||ge(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),o)}function l(c){return e.exit("codeIndented"),t(c)}}function dv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):ge(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ze(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):ge(a)?i(a):n(a)}}const fv={name:"codeText",previous:hv,resolve:pv,tokenize:mv};function pv(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 hv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function mv(e,t,n){let r=0,i,s;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),o(d)}function o(d){return d===96?(e.consume(d),r++,o):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,f(d)):ge(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||ge(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function f(d){return d===96?(e.consume(d),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class gv{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&&br(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),br(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),br(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);br(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);br(this.left,n.reverse())}}}function br(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 Ff(e){const t={};let n=-1,r,i,s,a,o,l,c;const f=new gv(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.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,xv(f,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=f.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return _t(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!c}function xv(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],c={};let f,d,p=-1,h=n,m=0,w=0;const S=[w];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),d&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=h,h=h.next}for(h=n;++p<o.length;)o[p][0]==="exit"&&o[p-1][0]==="enter"&&o[p][1].type===o[p-1][1].type&&o[p][1].start.line!==o[p][1].end.line&&(w=p+1,S.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const x=o.slice(S[p],S[p+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),p=-1;++p<l.length;)c[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return c}const yv={resolve:vv,tokenize:wv},bv={partial:!0,tokenize:kv};function vv(e){return Ff(e),e}function wv(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):ge(o)?e.check(bv,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function kv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ze(e,s,"linePrefix")}function s(a){if(a===null||ge(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Lf(e,t,n,r,i,s,a,o,l){const c=l||Number.POSITIVE_INFINITY;let f=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),p):x===null||x===32||x===41||Bi(x)?n(x):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),w(x))}function p(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(x))}function h(x){return x===62?(e.exit("chunkString"),e.exit(o),p(x)):x===null||x===60||ge(x)?n(x):(e.consume(x),x===92?m:h)}function m(x){return x===60||x===62||x===92?(e.consume(x),h):h(x)}function w(x){return!f&&(x===null||x===41||Me(x))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(x)):f<c&&x===40?(e.consume(x),f++,w):x===41?(e.consume(x),f--,w):x===null||x===32||x===40||Bi(x)?n(x):(e.consume(x),x===92?S:w)}function S(x){return x===40||x===41||x===92?(e.consume(x),w):w(x)}}function Zf(e,t,n,r,i,s){const a=this;let o=0,l;return c;function c(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),f}function f(h){return o>999||h===null||h===91||h===93&&!l||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):ge(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===null||h===91||h===93||ge(h)||o++>999?(e.exit("chunkString"),f(h)):(e.consume(h),l||(l=!Ne(h)),h===92?p:d)}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,d):d(h)}}function Bf(e,t,n,r,i,s){let a;return o;function o(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,l):n(p)}function l(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),c(p))}function c(p){return p===a?(e.exit(s),l(a)):p===null?n(p):ge(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),ze(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||ge(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?d:f)}function d(p){return p===a||p===92?(e.consume(p),f):f(p)}}function Or(e,t){let n;return r;function r(i){return ge(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ne(i)?ze(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Sv={name:"definition",tokenize:jv},_v={partial:!0,tokenize:Nv};function jv(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),a(h)}function a(h){return Zf.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=Mt(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 Me(h)?Or(e,c)(h):c(h)}function c(h){return Lf(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(_v,d,d)(h)}function d(h){return Ne(h)?ze(e,p,"whitespace")(h):p(h)}function p(h){return h===null||ge(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Nv(e,t,n){return r;function r(o){return Me(o)?Or(e,i)(o):n(o)}function i(o){return Bf(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Ne(o)?ze(e,a,"whitespace")(o):a(o)}function a(o){return o===null||ge(o)?t(o):n(o)}}const Cv={name:"hardBreakEscape",tokenize:Ev};function Ev(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return ge(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Iv={name:"headingAtx",resolve:zv,tokenize:Tv};function zv(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"},_t(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Tv(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),s(f)}function s(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Me(f)?(e.exit("atxHeadingSequence"),o(f)):n(f)}function o(f){return f===35?(e.enter("atxHeadingSequence"),l(f)):f===null||ge(f)?(e.exit("atxHeading"),t(f)):Ne(f)?ze(e,o,"whitespace")(f):(e.enter("atxHeadingText"),c(f))}function l(f){return f===35?(e.consume(f),l):(e.exit("atxHeadingSequence"),o(f))}function c(f){return f===null||f===35||Me(f)?(e.exit("atxHeadingText"),o(f)):(e.consume(f),c)}}const Av=["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"],Rl=["pre","script","style","textarea"],Pv={concrete:!0,name:"htmlFlow",resolveTo:Rv,tokenize:Mv},Ov={partial:!0,tokenize:Fv},Dv={partial:!0,tokenize:$v};function Rv(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 Mv(e,t,n){const r=this;let i,s,a,o,l;return c;function c(b){return f(b)}function f(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),d}function d(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,w):b===63?(e.consume(b),i=3,r.interrupt?t:v):dt(b)?(e.consume(b),a=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,o=0,m):dt(b)?(e.consume(b),i=4,r.interrupt?t:v):n(b)}function h(b){return b===45?(e.consume(b),r.interrupt?t:v):n(b)}function m(b){const Y="CDATA[";return b===Y.charCodeAt(o++)?(e.consume(b),o===Y.length?r.interrupt?t:A:m):n(b)}function w(b){return dt(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||Me(b)){const Y=b===47,oe=a.toLowerCase();return!Y&&!s&&Rl.includes(oe)?(i=1,r.interrupt?t(b):A(b)):Av.includes(a.toLowerCase())?(i=6,Y?(e.consume(b),x):r.interrupt?t(b):A(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?_(b):g(b))}return b===45||st(b)?(e.consume(b),a+=String.fromCharCode(b),S):n(b)}function x(b){return b===62?(e.consume(b),r.interrupt?t:A):n(b)}function _(b){return Ne(b)?(e.consume(b),_):N(b)}function g(b){return b===47?(e.consume(b),N):b===58||b===95||dt(b)?(e.consume(b),z):Ne(b)?(e.consume(b),g):N(b)}function z(b){return b===45||b===46||b===58||b===95||st(b)?(e.consume(b),z):E(b)}function E(b){return b===61?(e.consume(b),k):Ne(b)?(e.consume(b),E):g(b)}function k(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),l=b,C):Ne(b)?(e.consume(b),k):$(b)}function C(b){return b===l?(e.consume(b),l=null,K):b===null||ge(b)?n(b):(e.consume(b),C)}function $(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Me(b)?E(b):(e.consume(b),$)}function K(b){return b===47||b===62||Ne(b)?g(b):n(b)}function N(b){return b===62?(e.consume(b),I):n(b)}function I(b){return b===null||ge(b)?A(b):Ne(b)?(e.consume(b),I):n(b)}function A(b){return b===45&&i===2?(e.consume(b),P):b===60&&i===1?(e.consume(b),J):b===62&&i===4?(e.consume(b),fe):b===63&&i===3?(e.consume(b),v):b===93&&i===5?(e.consume(b),q):ge(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Ov,ue,B)(b)):b===null||ge(b)?(e.exit("htmlFlowData"),B(b)):(e.consume(b),A)}function B(b){return e.check(Dv,D,ue)(b)}function D(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),T}function T(b){return b===null||ge(b)?B(b):(e.enter("htmlFlowData"),A(b))}function P(b){return b===45?(e.consume(b),v):A(b)}function J(b){return b===47?(e.consume(b),a="",R):A(b)}function R(b){if(b===62){const Y=a.toLowerCase();return Rl.includes(Y)?(e.consume(b),fe):A(b)}return dt(b)&&a.length<8?(e.consume(b),a+=String.fromCharCode(b),R):A(b)}function q(b){return b===93?(e.consume(b),v):A(b)}function v(b){return b===62?(e.consume(b),fe):b===45&&i===2?(e.consume(b),v):A(b)}function fe(b){return b===null||ge(b)?(e.exit("htmlFlowData"),ue(b)):(e.consume(b),fe)}function ue(b){return e.exit("htmlFlow"),t(b)}}function $v(e,t,n){const r=this;return i;function i(a){return ge(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Fv(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ri,t,n)}}const Lv={name:"htmlText",tokenize:Zv};function Zv(e,t,n){const r=this;let i,s,a;return o;function o(v){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(v),l}function l(v){return v===33?(e.consume(v),c):v===47?(e.consume(v),E):v===63?(e.consume(v),g):dt(v)?(e.consume(v),$):n(v)}function c(v){return v===45?(e.consume(v),f):v===91?(e.consume(v),s=0,m):dt(v)?(e.consume(v),_):n(v)}function f(v){return v===45?(e.consume(v),h):n(v)}function d(v){return v===null?n(v):v===45?(e.consume(v),p):ge(v)?(a=d,J(v)):(e.consume(v),d)}function p(v){return v===45?(e.consume(v),h):d(v)}function h(v){return v===62?P(v):v===45?p(v):d(v)}function m(v){const fe="CDATA[";return v===fe.charCodeAt(s++)?(e.consume(v),s===fe.length?w:m):n(v)}function w(v){return v===null?n(v):v===93?(e.consume(v),S):ge(v)?(a=w,J(v)):(e.consume(v),w)}function S(v){return v===93?(e.consume(v),x):w(v)}function x(v){return v===62?P(v):v===93?(e.consume(v),x):w(v)}function _(v){return v===null||v===62?P(v):ge(v)?(a=_,J(v)):(e.consume(v),_)}function g(v){return v===null?n(v):v===63?(e.consume(v),z):ge(v)?(a=g,J(v)):(e.consume(v),g)}function z(v){return v===62?P(v):g(v)}function E(v){return dt(v)?(e.consume(v),k):n(v)}function k(v){return v===45||st(v)?(e.consume(v),k):C(v)}function C(v){return ge(v)?(a=C,J(v)):Ne(v)?(e.consume(v),C):P(v)}function $(v){return v===45||st(v)?(e.consume(v),$):v===47||v===62||Me(v)?K(v):n(v)}function K(v){return v===47?(e.consume(v),P):v===58||v===95||dt(v)?(e.consume(v),N):ge(v)?(a=K,J(v)):Ne(v)?(e.consume(v),K):P(v)}function N(v){return v===45||v===46||v===58||v===95||st(v)?(e.consume(v),N):I(v)}function I(v){return v===61?(e.consume(v),A):ge(v)?(a=I,J(v)):Ne(v)?(e.consume(v),I):K(v)}function A(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),i=v,B):ge(v)?(a=A,J(v)):Ne(v)?(e.consume(v),A):(e.consume(v),D)}function B(v){return v===i?(e.consume(v),i=void 0,T):v===null?n(v):ge(v)?(a=B,J(v)):(e.consume(v),B)}function D(v){return v===null||v===34||v===39||v===60||v===61||v===96?n(v):v===47||v===62||Me(v)?K(v):(e.consume(v),D)}function T(v){return v===47||v===62||Me(v)?K(v):n(v)}function P(v){return v===62?(e.consume(v),e.exit("htmlTextData"),e.exit("htmlText"),t):n(v)}function J(v){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),R}function R(v){return Ne(v)?ze(e,q,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):q(v)}function q(v){return e.enter("htmlTextData"),a(v)}}const xo={name:"labelEnd",resolveAll:Jv,resolveTo:Hv,tokenize:qv},Bv={tokenize:Wv},Vv={tokenize:Gv},Uv={tokenize:Kv};function Jv(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&&_t(e,0,e.length,n),e}function Hv(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",l,t],["enter",c,t]],o=Et(o,e.slice(s+1,s+r+3)),o=Et(o,[["enter",f,t]]),o=Et(o,xs(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Et(o,[["exit",f,t],e[a-2],e[a-1],["exit",c,t]]),o=Et(o,e.slice(a+1)),o=Et(o,[["exit",l,t]]),_t(e,s,e.length,o),e}function qv(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(p){return s?s._inactive?d(p):(a=r.parser.defined.includes(Mt(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(Bv,f,a?f:d)(p):p===91?e.attempt(Vv,f,a?c:d)(p):a?f(p):d(p)}function c(p){return e.attempt(Uv,f,d)(p)}function f(p){return t(p)}function d(p){return s._balanced=!0,n(p)}}function Wv(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Me(d)?Or(e,s)(d):s(d)}function s(d){return d===41?f(d):Lf(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return Me(d)?Or(e,l)(d):f(d)}function o(d){return n(d)}function l(d){return d===34||d===39||d===40?Bf(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):f(d)}function c(d){return Me(d)?Or(e,f)(d):f(d)}function f(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Gv(e,t,n){const r=this;return i;function i(o){return Zf.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(Mt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function Kv(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 Yv={name:"labelStartImage",resolveAll:xo.resolveAll,tokenize:Xv};function Xv(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Qv={name:"labelStartLink",resolveAll:xo.resolveAll,tokenize:ew};function ew(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Vs={name:"lineEnding",tokenize:tw};function tw(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ze(e,t,"linePrefix")}}const Ni={name:"thematicBreak",tokenize:nw};function nw(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),a(c)}function a(c){return i=c,o(c)}function o(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||ge(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ne(c)?ze(e,o,"whitespace")(c):o(c))}}const ht={continuation:{tokenize:aw},exit:lw,name:"list",tokenize:sw},rw={partial:!0,tokenize:uw},iw={partial:!0,tokenize:ow};function sw(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(h){const m=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Na(h)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Ni,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 Na(h)&&++a<10?(e.consume(h),l):(!r.interrupt||a<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(ri,r.interrupt?n:f,e.attempt(rw,p,d))}function f(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function d(h){return Ne(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 aw(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ri,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ze(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!Ne(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(iw,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ze(e,e.attempt(ht,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function ow(e,t,n){const r=this;return ze(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function lw(e){e.exit(this.containerState.type)}function uw(e,t,n){const r=this;return ze(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Ne(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const Ml={name:"setextUnderline",resolveTo:cw,tokenize:dw};function cw(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function dw(e,t,n){const r=this;let i;return s;function s(c){let f=r.events.length,d;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){d=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,a(c)):n(c)}function a(c){return e.enter("setextHeadingLineSequence"),o(c)}function o(c){return c===i?(e.consume(c),o):(e.exit("setextHeadingLineSequence"),Ne(c)?ze(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||ge(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const fw={tokenize:pw};function pw(e){const t=this,n=e.attempt(ri,r,e.attempt(this.parser.constructs.flowInitial,i,ze(e,e.attempt(this.parser.constructs.flow,i,e.attempt(yv,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 hw={resolveAll:Uf()},mw=Vf("string"),gw=Vf("text");function Vf(e){return{resolveAll:Uf(e==="text"?xw:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(f){return c(f)?s(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),l}function l(f){return c(f)?(n.exit("data"),s(f)):(n.consume(f),l)}function c(f){if(f===null)return!0;const d=i[f];let p=-1;if(d)for(;++p<d.length;){const h=d[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Uf(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 xw(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(c===-2)l=!0,o++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const c={type:n===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const yw={42:ht,43:ht,45:ht,48:ht,49:ht,50:ht,51:ht,52:ht,53:ht,54:ht,55:ht,56:ht,57:ht,62:Rf},bw={91:Sv},vw={[-2]:Bs,[-1]:Bs,32:Bs},ww={35:Iv,42:Ni,45:[Ml,Ni],60:Pv,61:Ml,95:Ni,96:Dl,126:Dl},kw={38:$f,92:Mf},Sw={[-5]:Vs,[-4]:Vs,[-3]:Vs,33:Yv,38:$f,42:Ca,60:[Qb,Lv],91:Qv,92:[Cv,Mf],93:xo,95:Ca,96:fv},_w={null:[Ca,hw]},jw={null:[42,95]},Nw={null:[]},Cw=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:jw,contentInitial:bw,disable:Nw,document:yw,flow:ww,flowInitial:vw,insideSpan:_w,string:kw,text:Sw},Symbol.toStringTag,{value:"Module"}));function Ew(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:C(E),check:C(k),consume:_,enter:g,exit:z,interrupt:C(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:w,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:d};let f=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(I){return a=Et(a,I),S(),a[a.length-1]!==null?[]:($(t,0),c.events=xs(s,c.events,c),c.events)}function p(I,A){return zw(h(I),A)}function h(I){return Iw(a,I)}function m(){const{_bufferIndex:I,_index:A,line:B,column:D,offset:T}=r;return{_bufferIndex:I,_index:A,line:B,column:D,offset:T}}function w(I){i[I.line]=I.column,N()}function S(){let I;for(;r._index<a.length;){const A=a[r._index];if(typeof A=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<A.length;)x(A.charCodeAt(r._bufferIndex));else x(A)}}function x(I){f=f(I)}function _(I){ge(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,N()):I!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=I}function g(I,A){const B=A||{};return B.type=I,B.start=m(),c.events.push(["enter",B,c]),o.push(B),B}function z(I){const A=o.pop();return A.end=m(),c.events.push(["exit",A,c]),A}function E(I,A){$(I,A.from)}function k(I,A){A.restore()}function C(I,A){return B;function B(D,T,P){let J,R,q,v;return Array.isArray(D)?ue(D):"tokenize"in D?ue([D]):fe(D);function fe(ne){return ie;function ie(W){const F=W!==null&&ne[W],te=W!==null&&ne.null,V=[...Array.isArray(F)?F:F?[F]:[],...Array.isArray(te)?te:te?[te]:[]];return ue(V)(W)}}function ue(ne){return J=ne,R=0,ne.length===0?P:b(ne[R])}function b(ne){return ie;function ie(W){return v=K(),q=ne,ne.partial||(c.currentConstruct=ne),ne.name&&c.parser.constructs.disable.null.includes(ne.name)?oe():ne.tokenize.call(A?Object.assign(Object.create(c),A):c,l,Y,oe)(W)}}function Y(ne){return I(q,v),T}function oe(ne){return v.restore(),++R<J.length?b(J[R]):P}}}function $(I,A){I.resolveAll&&!s.includes(I)&&s.push(I),I.resolve&&_t(c.events,A,c.events.length-A,I.resolve(c.events.slice(A),c)),I.resolveTo&&(c.events=I.resolveTo(c.events,c))}function K(){const I=m(),A=c.previous,B=c.currentConstruct,D=c.events.length,T=Array.from(o);return{from:D,restore:P};function P(){r=I,c.previous=A,c.currentConstruct=B,c.events.length=D,o=T,N()}}function N(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Iw(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function zw(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
|
|
4
|
+
`;break}case-3:{a=`\r
|
|
5
|
+
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Tw(e){const r={constructs:Of([Cw,...(e||{}).extensions||[]]),content:i(Hb),defined:[],document:i(Wb),flow:i(fw),lazy:{},string:i(mw),text:i(gw)};return r;function i(s){return a;function a(o){return Ew(r,s,o)}}}function Aw(e){for(;!Ff(e););return e}const $l=/[\0\t\n\r]/g;function Pw(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const l=[];let c,f,d,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if($l.lastIndex=d,c=$l.exec(s),p=c&&c.index!==void 0?c.index:s.length,h=s.charCodeAt(p),!c){t=s.slice(d);break}if(h===10&&d===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<p&&(l.push(s.slice(d,p)),e+=p-d),h){case 0:{l.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,l.push(-2);e++<f;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=p+1}return o&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Ow=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Dw(e){return e.replace(Ow,Rw)}function Rw(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Df(n.slice(s?2:1),s?16:10)}return go(n)||e}const Jf={}.hasOwnProperty;function Mw(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),$w(n)(Aw(Tw(n).document().write(Pw()(e,t,!0))))}function $w(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(O),autolinkProtocol:K,autolinkEmail:K,atxHeading:s(Oe),blockQuote:s(te),characterEscape:K,characterReference:K,codeFenced:s(V),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(V,a),codeText:s(de,a),codeTextData:K,data:K,codeFlowValue:K,definition:s(le),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(ye),hardBreakEscape:s(qe),hardBreakTrailing:s(qe),htmlFlow:s(Qe,a),htmlFlowData:K,htmlText:s(Qe,a),htmlTextData:K,image:s(j),label:a,link:s(O),listItem:s(re),listItemValue:p,listOrdered:s(Z,d),listUnordered:s(Z),paragraph:s(ee),reference:b,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Oe),strong:s(Q),thematicBreak:s(ve)},exit:{atxHeading:l(),atxHeadingSequence:E,autolink:l(),autolinkEmail:F,autolinkProtocol:W,blockQuote:l(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:ne,characterReference:ie,codeFenced:l(S),codeFencedFence:w,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:N,codeIndented:l(x),codeText:l(T),codeTextData:N,data:N,definition:l(),definitionDestinationString:z,definitionLabelString:_,definitionTitleString:g,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(B),htmlFlowData:N,htmlText:l(D),htmlTextData:N,image:l(J),label:q,labelText:R,lineEnding:I,link:l(P),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Y,resourceDestinationString:v,resourceTitleString:fe,resource:ue,setextHeading:l($),setextHeadingLineSequence:C,setextHeadingText:k,strong:l(),thematicBreak:l()}};Hf(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(L){let G={type:"root",children:[]};const he={stack:[G],tokenStack:[],config:t,enter:o,exit:c,buffer:a,resume:f,data:n},Se=[];let M=-1;for(;++M<L.length;)if(L[M][1].type==="listOrdered"||L[M][1].type==="listUnordered")if(L[M][0]==="enter")Se.push(M);else{const me=Se.pop();M=i(L,me,M)}for(M=-1;++M<L.length;){const me=t[L[M][0]];Jf.call(me,L[M][1].type)&&me[L[M][1].type].call(Object.assign({sliceSerialize:L[M][2].sliceSerialize},he),L[M][1])}if(he.tokenStack.length>0){const me=he.tokenStack[he.tokenStack.length-1];(me[1]||Fl).call(he,void 0,me[0])}for(G.position={start:tn(L.length>0?L[0][1].start:{line:1,column:1,offset:0}),end:tn(L.length>0?L[L.length-2][1].end:{line:1,column:1,offset:0})},M=-1;++M<t.transforms.length;)G=t.transforms[M](G)||G;return G}function i(L,G,he){let Se=G-1,M=-1,me=!1,Ce,$e,nt,et;for(;++Se<=he;){const it=L[Se];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?M++:M--,et=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(Ce&&!et&&!M&&!nt&&(nt=Se),et=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:et=void 0}if(!M&&it[0]==="enter"&&it[1].type==="listItemPrefix"||M===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(Ce){let en=Se;for($e=void 0;en--;){const Wt=L[en];if(Wt[1].type==="lineEnding"||Wt[1].type==="lineEndingBlank"){if(Wt[0]==="exit")continue;$e&&(L[$e][1].type="lineEndingBlank",me=!0),Wt[1].type="lineEnding",$e=en}else if(!(Wt[1].type==="linePrefix"||Wt[1].type==="blockQuotePrefix"||Wt[1].type==="blockQuotePrefixWhitespace"||Wt[1].type==="blockQuoteMarker"||Wt[1].type==="listItemIndent"))break}nt&&(!$e||nt<$e)&&(Ce._spread=!0),Ce.end=Object.assign({},$e?L[$e][1].start:it[1].end),L.splice($e||Se,0,["exit",Ce,it[2]]),Se++,he++}if(it[1].type==="listItemPrefix"){const en={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};Ce=en,L.splice(Se,0,["enter",en,it[2]]),Se++,he++,nt=void 0,et=!0}}}return L[G][1]._spread=me,he}function s(L,G){return he;function he(Se){o.call(this,L(Se),Se),G&&G.call(this,Se)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(L,G,he){this.stack[this.stack.length-1].children.push(L),this.stack.push(L),this.tokenStack.push([G,he||void 0]),L.position={start:tn(G.start),end:void 0}}function l(L){return G;function G(he){L&&L.call(this,he),c.call(this,he)}}function c(L,G){const he=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==L.type&&(G?G.call(this,L,Se[0]):(Se[1]||Fl).call(this,L,Se[0]));else throw new Error("Cannot close `"+L.type+"` ("+Pr({start:L.start,end:L.end})+"): it’s not open");he.position.end=tn(L.end)}function f(){return mo(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(L){if(this.data.expectingFirstListItemValue){const G=this.stack[this.stack.length-2];G.start=Number.parseInt(this.sliceSerialize(L),10),this.data.expectingFirstListItemValue=void 0}}function h(){const L=this.resume(),G=this.stack[this.stack.length-1];G.lang=L}function m(){const L=this.resume(),G=this.stack[this.stack.length-1];G.meta=L}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const L=this.resume(),G=this.stack[this.stack.length-1];G.value=L.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const L=this.resume(),G=this.stack[this.stack.length-1];G.value=L.replace(/(\r?\n|\r)$/g,"")}function _(L){const G=this.resume(),he=this.stack[this.stack.length-1];he.label=G,he.identifier=Mt(this.sliceSerialize(L)).toLowerCase()}function g(){const L=this.resume(),G=this.stack[this.stack.length-1];G.title=L}function z(){const L=this.resume(),G=this.stack[this.stack.length-1];G.url=L}function E(L){const G=this.stack[this.stack.length-1];if(!G.depth){const he=this.sliceSerialize(L).length;G.depth=he}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function C(L){const G=this.stack[this.stack.length-1];G.depth=this.sliceSerialize(L).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function K(L){const he=this.stack[this.stack.length-1].children;let Se=he[he.length-1];(!Se||Se.type!=="text")&&(Se=pe(),Se.position={start:tn(L.start),end:void 0},he.push(Se)),this.stack.push(Se)}function N(L){const G=this.stack.pop();G.value+=this.sliceSerialize(L),G.position.end=tn(L.end)}function I(L){const G=this.stack[this.stack.length-1];if(this.data.atHardBreak){const he=G.children[G.children.length-1];he.position.end=tn(L.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(G.type)&&(K.call(this,L),N.call(this,L))}function A(){this.data.atHardBreak=!0}function B(){const L=this.resume(),G=this.stack[this.stack.length-1];G.value=L}function D(){const L=this.resume(),G=this.stack[this.stack.length-1];G.value=L}function T(){const L=this.resume(),G=this.stack[this.stack.length-1];G.value=L}function P(){const L=this.stack[this.stack.length-1];if(this.data.inReference){const G=this.data.referenceType||"shortcut";L.type+="Reference",L.referenceType=G,delete L.url,delete L.title}else delete L.identifier,delete L.label;this.data.referenceType=void 0}function J(){const L=this.stack[this.stack.length-1];if(this.data.inReference){const G=this.data.referenceType||"shortcut";L.type+="Reference",L.referenceType=G,delete L.url,delete L.title}else delete L.identifier,delete L.label;this.data.referenceType=void 0}function R(L){const G=this.sliceSerialize(L),he=this.stack[this.stack.length-2];he.label=Dw(G),he.identifier=Mt(G).toLowerCase()}function q(){const L=this.stack[this.stack.length-1],G=this.resume(),he=this.stack[this.stack.length-1];if(this.data.inReference=!0,he.type==="link"){const Se=L.children;he.children=Se}else he.alt=G}function v(){const L=this.resume(),G=this.stack[this.stack.length-1];G.url=L}function fe(){const L=this.resume(),G=this.stack[this.stack.length-1];G.title=L}function ue(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function Y(L){const G=this.resume(),he=this.stack[this.stack.length-1];he.label=G,he.identifier=Mt(this.sliceSerialize(L)).toLowerCase(),this.data.referenceType="full"}function oe(L){this.data.characterReferenceType=L.type}function ne(L){const G=this.sliceSerialize(L),he=this.data.characterReferenceType;let Se;he?(Se=Df(G,he==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=go(G);const M=this.stack[this.stack.length-1];M.value+=Se}function ie(L){const G=this.stack.pop();G.position.end=tn(L.end)}function W(L){N.call(this,L);const G=this.stack[this.stack.length-1];G.url=this.sliceSerialize(L)}function F(L){N.call(this,L);const G=this.stack[this.stack.length-1];G.url="mailto:"+this.sliceSerialize(L)}function te(){return{type:"blockquote",children:[]}}function V(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function le(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ye(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function qe(){return{type:"break"}}function Qe(){return{type:"html",value:""}}function j(){return{type:"image",title:null,url:"",alt:null}}function O(){return{type:"link",title:null,url:"",children:[]}}function Z(L){return{type:"list",ordered:L.type==="listOrdered",start:null,spread:L._spread,children:[]}}function re(L){return{type:"listItem",spread:L._spread,checked:null,children:[]}}function ee(){return{type:"paragraph",children:[]}}function Q(){return{type:"strong",children:[]}}function pe(){return{type:"text",value:""}}function ve(){return{type:"thematicBreak"}}}function tn(e){return{line:e.line,column:e.column,offset:e.offset}}function Hf(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Hf(e,r):Fw(e,r)}}function Fw(e,t){let n;for(n in t)if(Jf.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 Fl(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Pr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Pr({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Pr({start:t.start,end:t.end})+") is still open")}function Lw(e){const t=this;t.parser=n;function n(r){return Mw(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Zw(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 Bw(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
6
|
+
`}]}function Vw(e,t){const n=t.value?t.value+`
|
|
7
|
+
`:"",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 Uw(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Jw(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Hw(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=ur(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,o=e.footnoteCounts.get(r);o===void 0?(o=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function qw(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 Ww(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function qf(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function Gw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return qf(e,t);const i={src:ur(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 Kw(e,t){const n={src:ur(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 Yw(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 Xw(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return qf(e,t);const i={href:ur(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 Qw(e,t){const n={href:ur(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 e0(e,t,n){const r=e.all(t),i=n?t0(n):Wf(t),s={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let d;f&&f.type==="element"&&f.tagName==="p"?d=f:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const f=r[o];(i||o!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
|
|
8
|
+
`}),f.type==="element"&&f.tagName==="p"&&!i?a.push(...f.children):a.push(f)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
|
|
9
|
+
`});const c={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,c),e.applyData(t,c)}function t0(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=Wf(n[r])}return t}function Wf(e){const t=e.spread;return t??e.children.length>1}function n0(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function r0(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function i0(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function s0(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function a0(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=co(t.children[1]),l=Cf(t.children[t.children.length-1]);o&&l&&(a.position={start:o,end:l}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function o0(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let l=-1;const c=[];for(;++l<o;){const d=t.children[l],p={},h=a?a[l]:void 0;h&&(p.align=h);let m={type:"element",tagName:s,properties:p,children:[]};d&&(m.children=e.all(d),e.patch(d,m),m=e.applyData(d,m)),c.push(m)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,f),e.applyData(t,f)}function l0(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Ll=9,Zl=32;function u0(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(Bl(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(Bl(t.slice(i),i>0,!1)),s.join("")}function Bl(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===Ll||s===Zl;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===Ll||s===Zl;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function c0(e,t){const n={type:"text",value:u0(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function d0(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const f0={blockquote:Zw,break:Bw,code:Vw,delete:Uw,emphasis:Jw,footnoteReference:Hw,heading:qw,html:Ww,imageReference:Gw,image:Kw,inlineCode:Yw,linkReference:Xw,link:Qw,listItem:e0,list:n0,paragraph:r0,root:i0,strong:s0,table:a0,tableCell:l0,tableRow:o0,text:c0,thematicBreak:d0,toml:fi,yaml:fi,definition:fi,footnoteDefinition:fi};function fi(){}const Gf=-1,ys=0,Dr=1,Vi=2,yo=3,bo=4,vo=5,wo=6,Kf=7,Yf=8,Vl=typeof self=="object"?self:globalThis,p0=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case ys:case Gf:return n(a,i);case Dr:{const o=n([],i);for(const l of a)o.push(r(l));return o}case Vi:{const o=n({},i);for(const[l,c]of a)o[r(l)]=r(c);return o}case yo:return n(new Date(a),i);case bo:{const{source:o,flags:l}=a;return n(new RegExp(o,l),i)}case vo:{const o=n(new Map,i);for(const[l,c]of a)o.set(r(l),r(c));return o}case wo:{const o=n(new Set,i);for(const l of a)o.add(r(l));return o}case Kf:{const{name:o,message:l}=a;return n(new Vl[o](l),i)}case Yf:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(new Vl[s](a),i)};return r},Ul=e=>p0(new Map,e)(0),$n="",{toString:h0}={},{keys:m0}=Object,vr=e=>{const t=typeof e;if(t!=="object"||!e)return[ys,t];const n=h0.call(e).slice(8,-1);switch(n){case"Array":return[Dr,$n];case"Object":return[Vi,$n];case"Date":return[yo,$n];case"RegExp":return[bo,$n];case"Map":return[vo,$n];case"Set":return[wo,$n];case"DataView":return[Dr,n]}return n.includes("Array")?[Dr,n]:n.includes("Error")?[Kf,n]:[Vi,n]},pi=([e,t])=>e===ys&&(t==="function"||t==="symbol"),g0=(e,t,n,r)=>{const i=(a,o)=>{const l=r.push(a)-1;return n.set(o,l),l},s=a=>{if(n.has(a))return n.get(a);let[o,l]=vr(a);switch(o){case ys:{let f=a;switch(l){case"bigint":o=Yf,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);f=null;break;case"undefined":return i([Gf],a)}return i([o,f],a)}case Dr:{if(l){let p=a;return l==="DataView"?p=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(a)),i([l,[...p]],a)}const f=[],d=i([o,f],a);for(const p of a)f.push(s(p));return d}case Vi:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const f=[],d=i([o,f],a);for(const p of m0(a))(e||!pi(vr(a[p])))&&f.push([s(p),s(a[p])]);return d}case yo:return i([o,a.toISOString()],a);case bo:{const{source:f,flags:d}=a;return i([o,{source:f,flags:d}],a)}case vo:{const f=[],d=i([o,f],a);for(const[p,h]of a)(e||!(pi(vr(p))||pi(vr(h))))&&f.push([s(p),s(h)]);return d}case wo:{const f=[],d=i([o,f],a);for(const p of a)(e||!pi(vr(p)))&&f.push(s(p));return d}}const{message:c}=a;return i([o,{name:l,message:c}],a)};return s},Jl=(e,{json:t,lossy:n}={})=>{const r=[];return g0(!(t||n),!!t,new Map,r)(e),r},Ui=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ul(Jl(e,t)):structuredClone(e):(e,t)=>Ul(Jl(e,t));function x0(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 y0(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function b0(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||x0,r=e.options.footnoteBackLabel||y0,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const f=e.all(c),d=String(c.identifier).toUpperCase(),p=ur(d.toLowerCase());let h=0;const m=[],w=e.footnoteCounts.get(d);for(;w!==void 0&&++h<=w;){m.length>0&&m.push({type:"text",value:" "});let _=typeof n=="string"?n:n(l,h);typeof _=="string"&&(_={type:"text",value:_}),m.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(_)?_:[_]})}const S=f[f.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const _=S.children[S.children.length-1];_&&_.type==="text"?_.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else f.push(...m);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(c,x),o.push(x)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Ui(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
10
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
|
|
11
|
+
`}]}}const bs=function(e){if(e==null)return S0;if(typeof e=="function")return vs(e);if(typeof e=="object")return Array.isArray(e)?v0(e):w0(e);if(typeof e=="string")return k0(e);throw new Error("Expected function, string, or object as test")};function v0(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=bs(e[n]);return vs(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function w0(e){const t=e;return vs(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function k0(e){return vs(t);function t(n){return n&&n.type===e}}function vs(e){return t;function t(n,r,i){return!!(_0(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function S0(){return!0}function _0(e){return e!==null&&typeof e=="object"&&"type"in e}const Xf=[],j0=!0,Ea=!1,N0="skip";function Qf(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=bs(i),a=r?-1:1;o(e,void 0,[])();function o(l,c,f){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const h=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=Xf,m,w,S;if((!t||s(l,c,f[f.length-1]||void 0))&&(h=C0(n(l,f)),h[0]===Ea))return h;if("children"in l&&l.children){const x=l;if(x.children&&h[0]!==N0)for(w=(r?x.children.length:-1)+a,S=f.concat(x);w>-1&&w<x.children.length;){const _=x.children[w];if(m=o(_,w,S)(),m[0]===Ea)return m;w=typeof m[1]=="number"?m[1]:w+a}}return h}}}function C0(e){return Array.isArray(e)?e:typeof e=="number"?[j0,e]:e==null?Xf:[e]}function ko(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),Qf(e,s,o,i);function o(l,c){const f=c[c.length-1],d=f?f.children.indexOf(l):void 0;return a(l,d,f)}}const Ia={}.hasOwnProperty,E0={};function I0(e,t){const n=t||E0,r=new Map,i=new Map,s=new Map,a={...f0,...n.handlers},o={all:c,applyData:T0,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:n,patch:z0,wrap:P0};return ko(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const d=f.type==="definition"?r:i,p=String(f.identifier).toUpperCase();d.has(p)||d.set(p,f)}}),o;function l(f,d){const p=f.type,h=o.handlers[p];if(Ia.call(o.handlers,p)&&h)return h(o,f,d);if(o.options.passThrough&&o.options.passThrough.includes(p)){if("children"in f){const{children:w,...S}=f,x=Ui(S);return x.children=o.all(f),x}return Ui(f)}return(o.options.unknownHandler||A0)(o,f,d)}function c(f){const d=[];if("children"in f){const p=f.children;let h=-1;for(;++h<p.length;){const m=o.one(p[h],f);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Hl(m.value)),!Array.isArray(m)&&m.type==="element")){const w=m.children[0];w&&w.type==="text"&&(w.value=Hl(w.value))}Array.isArray(m)?d.push(...m):d.push(m)}}}return d}}function z0(e,t){e.position&&(t.position=yb(e))}function T0(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,Ui(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function A0(e,t){const n=t.data||{},r="value"in t&&!(Ia.call(n,"hProperties")||Ia.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 P0(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
12
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
13
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
14
|
+
`}),n}function Hl(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ql(e,t){const n=I0(e,t),r=n.one(e,void 0),i=b0(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
15
|
+
`},i),s}function O0(e,t){return e&&"run"in e?async function(n,r){const i=ql(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ql(n,{file:r,...e||t})}}function Wl(e){if(e)throw e}var Us,Gl;function D0(){if(Gl)return Us;Gl=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 f=e.call(c,"constructor"),d=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!f&&!d)return!1;var p;for(p in c);return typeof p>"u"||e.call(c,p)},a=function(c,f){n&&f.name==="__proto__"?n(c,f.name,{enumerable:!0,configurable:!0,value:f.newValue,writable:!0}):c[f.name]=f.newValue},o=function(c,f){if(f==="__proto__")if(e.call(c,f)){if(r)return r(c,f).value}else return;return c[f]};return Us=function l(){var c,f,d,p,h,m,w=arguments[0],S=1,x=arguments.length,_=!1;for(typeof w=="boolean"&&(_=w,w=arguments[1]||{},S=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});S<x;++S)if(c=arguments[S],c!=null)for(f in c)d=o(w,f),p=o(c,f),w!==p&&(_&&p&&(s(p)||(h=i(p)))?(h?(h=!1,m=d&&i(d)?d:[]):m=d&&s(d)?d:{},a(w,{name:f,newValue:l(_,m,p)})):typeof p<"u"&&a(w,{name:f,newValue:p}));return w},Us}var R0=D0();const Js=Ua(R0);function za(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 M0(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(l,...c){const f=e[++s];let d=-1;if(l){a(l);return}for(;++d<i.length;)(c[d]===null||c[d]===void 0)&&(c[d]=i[d]);i=c,f?$0(f,o)(...c):a(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function $0(e,t){let n;return r;function r(...a){const o=e.length>a.length;let l;o&&a.push(i);try{l=e.apply(this,a)}catch(c){const f=c;if(o&&n)throw f;return i(f)}o||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const Ft={basename:F0,dirname:L0,extname:Z0,join:B0,sep:"/"};function F0(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ii(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,o=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(r=i):(o=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function L0(e){if(ii(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 Z0(e){ii(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),o===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function B0(...e){let t=-1,n;for(;++t<e.length;)ii(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":V0(n)}function V0(e){ii(e);const t=e.codePointAt(0)===47;let n=U0(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function U0(e,t){let n="",r=0,i=-1,s=0,a=-1,o,l;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function ii(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const J0={cwd:H0};function H0(){return"/"}function Ta(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function q0(e){if(typeof e=="string")e=new URL(e);else if(!Ta(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 W0(e)}function W0(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 Hs=["history","path","basename","stem","extname","dirname"];class ep{constructor(t){let n;t?Ta(t)?n={path:t}:typeof t=="string"||G0(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":J0.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Hs.length;){const s=Hs[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)Hs.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ft.basename(this.path):void 0}set basename(t){Ws(t,"basename"),qs(t,"basename"),this.path=Ft.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ft.dirname(this.path):void 0}set dirname(t){Kl(this.basename,"dirname"),this.path=Ft.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ft.extname(this.path):void 0}set extname(t){if(qs(t,"extname"),Kl(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=Ft.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ta(t)&&(t=q0(t)),Ws(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ft.basename(this.path,this.extname):void 0}set stem(t){Ws(t,"stem"),qs(t,"stem"),this.path=Ft.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 at(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 qs(e,t){if(e&&e.includes(Ft.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ft.sep+"`")}function Ws(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Kl(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function G0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const K0=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},Y0={}.hasOwnProperty;class So extends K0{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=M0()}copy(){const t=new So;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Js(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Ys("data",this.frozen),this.namespace[t]=n,this):Y0.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Ys("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=hi(t),r=this.parser||this.Parser;return Gs("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Gs("process",this.parser||this.Parser),Ks("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=hi(t),l=r.parse(o);r.run(l,o,function(f,d,p){if(f||!d||!p)return c(f);const h=d,m=r.stringify(h,p);ek(m)?p.value=m:p.result=m,c(f,p)});function c(f,d){f||!d?a(f):s?s(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),Gs("processSync",this.parser||this.Parser),Ks("processSync",this.compiler||this.Compiler),this.process(t,i),Xl("processSync","process",n),r;function i(s,a){n=!0,Wl(s),r=a}}run(t,n,r){Yl(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,o){const l=hi(n);i.run(t,l,c);function c(f,d,p){const h=d||t;f?o(f):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),Xl("runSync","run",r),i;function s(a,o){Wl(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=hi(n),i=this.compiler||this.Compiler;return Ks("stringify",i),Yl(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Ys("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[f,...d]=c;l(f,d)}else a(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function a(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(c.plugins),c.settings&&(i.settings=Js(!0,i.settings,c.settings))}function o(c){let f=-1;if(c!=null)if(Array.isArray(c))for(;++f<c.length;){const d=c[f];s(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,f){let d=-1,p=-1;for(;++d<r.length;)if(r[d][0]===c){p=d;break}if(p===-1)r.push([c,...f]);else if(f.length>0){let[h,...m]=f;const w=r[p][1];za(w)&&za(h)&&(h=Js(!0,w,h)),r[p]=[c,h,...m]}}}}const X0=new So().freeze();function Gs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ks(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Ys(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 Yl(e){if(!za(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Xl(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function hi(e){return Q0(e)?e:new ep(e)}function Q0(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function ek(e){return typeof e=="string"||tk(e)}function tk(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const nk="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ql=[],eu={allowDangerousHtml:!0},rk=/^(https?|ircs?|mailto|xmpp)$/i,ik=[{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 sk(e){const t=ak(e),n=ok(e);return lk(t.runSync(t.parse(n),n),e)}function ak(e){const t=e.rehypePlugins||Ql,n=e.remarkPlugins||Ql,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...eu}:eu;return X0().use(Lw).use(n).use(O0,r).use(t)}function ok(e){const t=e.children||"",n=new ep;return typeof t=="string"&&(n.value=t),n}function lk(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||uk;for(const f of ik)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+nk+f.id,void 0);return ko(e,c),Sb(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(f,d,p){if(f.type==="raw"&&p&&typeof d=="number")return a?p.children.splice(d,1):p.children[d]={type:"text",value:f.value},d;if(f.type==="element"){let h;for(h in Zs)if(Object.hasOwn(Zs,h)&&Object.hasOwn(f.properties,h)){const m=f.properties[h],w=Zs[h];(w===null||w.includes(f.tagName))&&(f.properties[h]=l(String(m||""),h,f))}}if(f.type==="element"){let h=n?!n.includes(f.tagName):s?s.includes(f.tagName):!1;if(!h&&r&&typeof d=="number"&&(h=!r(f,d,p)),h&&p&&typeof d=="number")return o&&f.children?p.children.splice(d,1,...f.children):p.children.splice(d,1),d}}}function uk(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||rk.test(e.slice(0,t))?e:""}function tu(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 ck(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function dk(e,t,n){const i=bs((n||{}).ignore||[]),s=fk(t);let a=-1;for(;++a<s.length;)Qf(e,"text",o);function o(c,f){let d=-1,p;for(;++d<f.length;){const h=f[d],m=p?p.children:void 0;if(i(h,m?m.indexOf(h):void 0,p))return;p=h}if(p)return l(c,f)}function l(c,f){const d=f[f.length-1],p=s[a][0],h=s[a][1];let m=0;const S=d.children.indexOf(c);let x=!1,_=[];p.lastIndex=0;let g=p.exec(c.value);for(;g;){const z=g.index,E={index:g.index,input:g.input,stack:[...f,c]};let k=h(...g,E);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?p.lastIndex=z+1:(m!==z&&_.push({type:"text",value:c.value.slice(m,z)}),Array.isArray(k)?_.push(...k):k&&_.push(k),m=z+g[0].length,x=!0),!p.global)break;g=p.exec(c.value)}return x?(m<c.value.length&&_.push({type:"text",value:c.value.slice(m)}),d.children.splice(S,1,..._)):_=[c],S+_.length}}function fk(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([pk(i[0]),hk(i[1])])}return t}function pk(e){return typeof e=="string"?new RegExp(ck(e),"g"):e}function hk(e){return typeof e=="function"?e:function(){return e}}const Xs="phrasing",Qs=["autolink","link","image","label"];function mk(){return{transforms:[kk],enter:{literalAutolink:xk,literalAutolinkEmail:ea,literalAutolinkHttp:ea,literalAutolinkWww:ea},exit:{literalAutolink:wk,literalAutolinkEmail:vk,literalAutolinkHttp:yk,literalAutolinkWww:bk}}}function gk(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Xs,notInConstruct:Qs},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Xs,notInConstruct:Qs},{character:":",before:"[ps]",after:"\\/",inConstruct:Xs,notInConstruct:Qs}]}}function xk(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function ea(e){this.config.enter.autolinkProtocol.call(this,e)}function yk(e){this.config.exit.autolinkProtocol.call(this,e)}function bk(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 vk(e){this.config.exit.autolinkEmail.call(this,e)}function wk(e){this.exit(e)}function kk(e){dk(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Sk],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),_k]],{ignore:["link","linkReference"]})}function Sk(e,t,n,r,i){let s="";if(!tp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!jk(n)))return!1;const a=Nk(n+r);if(!a[0])return!1;const o={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function _k(e,t,n,r){return!tp(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function jk(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 Nk(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=tu(e,"(");let s=tu(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 tp(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||zn(n)||gs(n))&&(!t||n!==47)}np.peek=Dk;function Ck(){this.buffer()}function Ek(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Ik(){this.buffer()}function zk(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Tk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ak(e){this.exit(e)}function Pk(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ok(e){this.exit(e)}function Dk(){return"["}function np(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=i.move("]"),s}function Rk(){return{enter:{gfmFootnoteCallString:Ck,gfmFootnoteCall:Ek,gfmFootnoteDefinitionLabelString:Ik,gfmFootnoteDefinition:zk},exit:{gfmFootnoteCallString:Tk,gfmFootnoteCall:Ak,gfmFootnoteDefinitionLabelString:Pk,gfmFootnoteDefinition:Ok}}}function Mk(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:np},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const o=s.createTracker(a);let l=o.move("[^");const c=s.enter("footnoteDefinition"),f=s.enter("label");return l+=o.move(s.safe(s.associationId(r),{before:l,after:"]"})),f(),l+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),l+=o.move((t?`
|
|
16
|
+
`:" ")+s.indentLines(s.containerFlow(r,o.current()),t?rp:$k))),c(),l}}function $k(e,t,n){return t===0?e:rp(e,t,n)}function rp(e,t,n){return(n?"":" ")+e}const Fk=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ip.peek=Uk;function Lk(){return{canContainEols:["delete"],enter:{strikethrough:Bk},exit:{strikethrough:Vk}}}function Zk(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Fk}],handlers:{delete:ip}}}function Bk(e){this.enter({type:"delete",children:[]},e)}function Vk(e){this.exit(e)}function ip(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function Uk(){return"~"}function Jk(e){return e.length}function Hk(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Jk,s=[],a=[],o=[],l=[];let c=0,f=-1;for(;++f<e.length;){const w=[],S=[];let x=-1;for(e[f].length>c&&(c=e[f].length);++x<e[f].length;){const _=qk(e[f][x]);if(n.alignDelimiters!==!1){const g=i(_);S[x]=g,(l[x]===void 0||g>l[x])&&(l[x]=g)}w.push(_)}a[f]=w,o[f]=S}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)s[d]=nu(r[d]);else{const w=nu(r);for(;++d<c;)s[d]=w}d=-1;const p=[],h=[];for(;++d<c;){const w=s[d];let S="",x="";w===99?(S=":",x=":"):w===108?S=":":w===114&&(x=":");let _=n.alignDelimiters===!1?1:Math.max(1,l[d]-S.length-x.length);const g=S+"-".repeat(_)+x;n.alignDelimiters!==!1&&(_=S.length+_+x.length,_>l[d]&&(l[d]=_),h[d]=_),p[d]=g}a.splice(1,0,p),o.splice(1,0,h),f=-1;const m=[];for(;++f<a.length;){const w=a[f],S=o[f];d=-1;const x=[];for(;++d<c;){const _=w[d]||"";let g="",z="";if(n.alignDelimiters!==!1){const E=l[d]-(S[d]||0),k=s[d];k===114?g=" ".repeat(E):k===99?E%2?(g=" ".repeat(E/2+.5),z=" ".repeat(E/2-.5)):(g=" ".repeat(E/2),z=g):z=" ".repeat(E)}n.delimiterStart!==!1&&!d&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||d)&&x.push(" "),n.alignDelimiters!==!1&&x.push(g),x.push(_),n.alignDelimiters!==!1&&x.push(z),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&x.push("|")}m.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return m.join(`
|
|
17
|
+
`)}function qk(e){return e==null?"":String(e)}function nu(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 Wk(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),Gk);return i(),a}function Gk(e,t,n){return">"+(n?"":" ")+e}function Kk(e,t){return ru(e,t.inConstruct,!0)&&!ru(e,t.notInConstruct,!1)}function ru(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 iu(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
18
|
+
`&&Kk(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
19
|
+
`}function Yk(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function Xk(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 Qk(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 eS(e,t,n,r){const i=Qk(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(Xk(e,n)){const d=n.enter("codeIndented"),p=n.indentLines(s,tS);return d(),p}const o=n.createTracker(r),l=i.repeat(Math.max(Yk(s,i)+1,3)),c=n.enter("codeFenced");let f=o.move(l);if(e.lang){const d=n.enter(`codeFencedLang${a}`);f+=o.move(n.safe(e.lang,{before:f,after:" ",encode:["`"],...o.current()})),d()}if(e.lang&&e.meta){const d=n.enter(`codeFencedMeta${a}`);f+=o.move(" "),f+=o.move(n.safe(e.meta,{before:f,after:`
|
|
20
|
+
`,encode:["`"],...o.current()})),d()}return f+=o.move(`
|
|
21
|
+
`),s&&(f+=o.move(s+`
|
|
22
|
+
`)),f+=o.move(l),c(),f}function tS(e,t,n){return(n?"":" ")+e}function _o(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 nS(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
|
|
23
|
+
`,...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),a(),c}function rS(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 Jr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ji(e,t,n){const r=rr(e),i=rr(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}}sp.peek=iS;function sp(e,t,n,r){const i=rS(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),f=Ji(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=Jr(c)+l.slice(1));const d=l.charCodeAt(l.length-1),p=Ji(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+Jr(d));const h=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function iS(e,t,n){return n.options.emphasis||"*"}function sS(e,t){let n=!1;return ko(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ea}),!!((!e.depth||e.depth<3)&&mo(e)&&(t.options.setext||n))}function aS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(sS(e,n)){const f=n.enter("headingSetext"),d=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
24
|
+
`,after:`
|
|
25
|
+
`});return d(),f(),p+`
|
|
26
|
+
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
27
|
+
`))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(a+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
|
|
28
|
+
`,...s.current()});return/^[\t ]/.test(c)&&(c=Jr(c.charCodeAt(0))+c.slice(1)),c=c?a+" "+c:a,n.options.closeAtx&&(c+=" "+a),l(),o(),c}ap.peek=oS;function ap(e){return e.value||""}function oS(){return"<"}op.peek=lS;function op(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),o()),c+=l.move(")"),a(),c}function lS(){return"!"}lp.peek=uS;function lp(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function uS(){return"!"}up.peek=cS;function up(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],o=n.compilePattern(a);let l;if(a.atBreak)for(;l=o.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function cS(){return"`"}function cp(e,t){const n=mo(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))}dp.peek=dS;function dp(e,t,n,r){const i=_o(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,l;if(cp(e,n)){const f=n.stack;n.stack=[],o=n.enter("autolink");let d=a.move("<");return d+=a.move(n.containerPhrasing(e,{before:d,after:">",...a.current()})),d+=a.move(">"),o(),n.stack=f,d}o=n.enter("link"),l=n.enter("label");let c=a.move("[");return c+=a.move(n.containerPhrasing(e,{before:c,after:"](",...a.current()})),c+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=a.move("<"),c+=a.move(n.safe(e.url,{before:c,after:">",...a.current()})),c+=a.move(">")):(l=n.enter("destinationRaw"),c+=a.move(n.safe(e.url,{before:c,after:e.title?" ":")",...a.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=a.move(" "+i),c+=a.move(n.safe(e.title,{before:c,after:i,...a.current()})),c+=a.move(i),l()),c+=a.move(")"),o(),c}function dS(e,t,n){return cp(e,n)?"<":"["}fp.peek=fS;function fp(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),a();const f=n.stack;n.stack=[],a=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return a(),n.stack=f,s(),i==="full"||!c||c!==d?l+=o.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function fS(){return"["}function jo(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 pS(e){const t=jo(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 hS(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 pp(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 mS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?hS(n):jo(n);const o=e.ordered?a==="."?")":".":pS(n);let l=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&f&&(!f.children||!f.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),pp(n)===a&&f){let d=-1;for(;++d<e.children.length;){const p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),n.bulletCurrent=a;const c=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),c}function gS(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 xS(e,t,n,r){const i=gS(n);let s=n.bulletCurrent||jo(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),f);return l(),c;function f(d,p,h){return p?(h?"":" ".repeat(a))+d:(h?s:s+" ".repeat(a-s.length))+d}}function yS(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const bS=bs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function vS(e,t,n,r){return(e.children.some(function(a){return bS(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function wS(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}hp.peek=kS;function hp(e,t,n,r){const i=wS(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let l=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const c=l.charCodeAt(0),f=Ji(r.before.charCodeAt(r.before.length-1),c,i);f.inside&&(l=Jr(c)+l.slice(1));const d=l.charCodeAt(l.length-1),p=Ji(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+Jr(d));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},o+l+h}function kS(e,t,n){return n.options.strong||"*"}function SS(e,t,n,r){return n.safe(e.value,r)}function _S(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 jS(e,t,n){const r=(pp(n)+(n.options.ruleSpaces?" ":"")).repeat(_S(n));return n.options.ruleSpaces?r.slice(0,-1):r}const mp={blockquote:Wk,break:iu,code:eS,definition:nS,emphasis:sp,hardBreak:iu,heading:aS,html:ap,image:op,imageReference:lp,inlineCode:up,link:dp,linkReference:fp,list:mS,listItem:xS,paragraph:yS,root:vS,strong:hp,text:SS,thematicBreak:jS};function NS(){return{enter:{table:CS,tableData:su,tableHeader:su,tableRow:IS},exit:{codeText:zS,table:ES,tableData:ta,tableHeader:ta,tableRow:ta}}}function CS(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 ES(e){this.exit(e),this.data.inTable=void 0}function IS(e){this.enter({type:"tableRow",children:[]},e)}function ta(e){this.exit(e)}function su(e){this.enter({type:"tableCell",children:[]},e)}function zS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,TS));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function TS(e,t){return t==="|"?t:e}function AS(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
29
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:l,tableRow:o}};function a(h,m,w,S){return c(f(h,w,S),h.align)}function o(h,m,w,S){const x=d(h,w,S),_=c([x]);return _.slice(0,_.indexOf(`
|
|
30
|
+
`))}function l(h,m,w,S){const x=w.enter("tableCell"),_=w.enter("phrasing"),g=w.containerPhrasing(h,{...S,before:s,after:s});return _(),x(),g}function c(h,m){return Hk(h,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function f(h,m,w){const S=h.children;let x=-1;const _=[],g=m.enter("table");for(;++x<S.length;)_[x]=d(S[x],m,w);return g(),_}function d(h,m,w){const S=h.children;let x=-1;const _=[],g=m.enter("tableRow");for(;++x<S.length;)_[x]=l(S[x],h,m,w);return g(),_}function p(h,m,w){let S=mp.inlineCode(h,m,w);return w.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function PS(){return{exit:{taskListCheckValueChecked:au,taskListCheckValueUnchecked:au,paragraph:DS}}}function OS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:RS}}}function au(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function DS(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function RS(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let l=mp.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(f){return f+a}}function MS(){return[mk(),Rk(),Lk(),NS(),PS()]}function $S(e){return{extensions:[gk(),Mk(e),Zk(),AS(e),OS()]}}const FS={tokenize:JS,partial:!0},gp={tokenize:HS,partial:!0},xp={tokenize:qS,partial:!0},yp={tokenize:WS,partial:!0},LS={tokenize:GS,partial:!0},bp={name:"wwwAutolink",tokenize:VS,previous:wp},vp={name:"protocolAutolink",tokenize:US,previous:kp},Qt={name:"emailAutolink",tokenize:BS,previous:Sp},qt={};function ZS(){return{text:qt}}let xn=48;for(;xn<123;)qt[xn]=Qt,xn++,xn===58?xn=65:xn===91&&(xn=97);qt[43]=Qt;qt[45]=Qt;qt[46]=Qt;qt[95]=Qt;qt[72]=[Qt,vp];qt[104]=[Qt,vp];qt[87]=[Qt,bp];qt[119]=[Qt,bp];function BS(e,t,n){const r=this;let i,s;return a;function a(d){return!Aa(d)||!Sp.call(r,r.previous)||No(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(d))}function o(d){return Aa(d)?(e.consume(d),o):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(LS,f,c)(d):d===45||d===95||st(d)?(s=!0,e.consume(d),l):f(d)}function c(d){return e.consume(d),i=!0,l}function f(d){return s&&i&&dt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function VS(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!wp.call(r,r.previous)||No(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(FS,e.attempt(gp,e.attempt(xp,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function US(e,t,n){const r=this;let i="",s=!1;return a;function a(d){return(d===72||d===104)&&kp.call(r,r.previous)&&!No(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),o):n(d)}function o(d){if(dt(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),o;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||Bi(d)||Me(d)||zn(d)||gs(d)?n(d):e.attempt(gp,e.attempt(xp,f),n)(d)}function f(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function JS(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function HS(e,t,n){let r,i,s;return a;function a(c){return c===46||c===95?e.check(yp,l,o)(c):c===null||Me(c)||zn(c)||c!==45&&gs(c)?l(c):(s=!0,e.consume(c),a)}function o(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),a}function l(c){return i||r||!s?n(c):t(c)}}function qS(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(yp,t,s)(a):a===null||Me(a)||zn(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function WS(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||Me(o)||zn(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Me(o)||zn(o)?t(o):r(o)}function s(o){return dt(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):dt(o)?(e.consume(o),a):n(o)}}function GS(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return st(s)?n(s):t(s)}}function wp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Me(e)}function kp(e){return!dt(e)}function Sp(e){return!(e===47||Aa(e))}function Aa(e){return e===43||e===45||e===46||e===95||st(e)}function No(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 KS={tokenize:i1,partial:!0};function YS(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:t1,continuation:{tokenize:n1},exit:r1}},text:{91:{name:"gfmFootnoteCall",tokenize:e1},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:XS,resolveTo:QS}}}}function XS(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return n(l);const c=Mt(r.sliceSerialize({start:a.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function QS(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function e1(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!a||d===null||d===91||Me(d))return n(d);if(d===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Mt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return Me(d)||(a=!0),s++,e.consume(d),d===92?f:c}function f(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function t1(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(m)}function f(m){if(a>999||m===93&&!o||m===null||m===91||Me(m))return n(m);if(m===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=Mt(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Me(m)||(o=!0),a++,e.consume(m),m===92?d:f}function d(m){return m===91||m===92||m===93?(e.consume(m),a++,f):f(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),ze(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function n1(e,t,n){return e.check(ri,t,e.attempt(KS,t,n))}function r1(e){e.exit("gfmFootnoteDefinition")}function i1(e,t,n){const r=this;return ze(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function s1(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let c=l;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[l][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},d={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},p=[["enter",f,o],["enter",a[c][1],o],["exit",a[c][1],o],["enter",d,o]],h=o.parser.constructs.insideSpan.null;h&&_t(p,p.length,0,xs(h,a.slice(c+1,l),o)),_t(p,p.length,0,[["exit",d,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",f,o]]),_t(a,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const c=this.previous,f=this.events;let d=0;return p;function p(m){return c===126&&f[f.length-1][1].type!=="characterEscape"?l(m):(a.enter("strikethroughSequenceTemporary"),h(m))}function h(m){const w=rr(c);if(m===126)return d>1?l(m):(a.consume(m),d++,h);if(d<2&&!n)return l(m);const S=a.exit("strikethroughSequenceTemporary"),x=rr(m);return S._open=!x||x===2&&!!w,S._close=!w||w===2&&!!x,o(m)}}}class a1{constructor(){this.map=[]}add(t,n,r){o1(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function o1(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 l1(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 u1(){return{flow:{null:{name:"table",tokenize:c1,resolveAll:d1}}}}function c1(e,t,n){const r=this;let i=0,s=0,a;return o;function o(N){let I=r.events.length-1;for(;I>-1;){const D=r.events[I][1].type;if(D==="lineEnding"||D==="linePrefix")I--;else break}const A=I>-1?r.events[I][1].type:null,B=A==="tableHead"||A==="tableRow"?k:l;return B===k&&r.parser.lazy[r.now().line]?n(N):B(N)}function l(N){return e.enter("tableHead"),e.enter("tableRow"),c(N)}function c(N){return N===124||(a=!0,s+=1),f(N)}function f(N){return N===null?n(N):ge(N)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),h):n(N):Ne(N)?ze(e,f,"whitespace")(N):(s+=1,a&&(a=!1,i+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),a=!0,f):(e.enter("data"),d(N)))}function d(N){return N===null||N===124||Me(N)?(e.exit("data"),f(N)):(e.consume(N),N===92?p:d)}function p(N){return N===92||N===124?(e.consume(N),d):d(N)}function h(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(e.enter("tableDelimiterRow"),a=!1,Ne(N)?ze(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):m(N))}function m(N){return N===45||N===58?S(N):N===124?(a=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),w):E(N)}function w(N){return Ne(N)?ze(e,S,"whitespace")(N):S(N)}function S(N){return N===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),x):N===45?(s+=1,x(N)):N===null||ge(N)?z(N):E(N)}function x(N){return N===45?(e.enter("tableDelimiterFiller"),_(N)):E(N)}function _(N){return N===45?(e.consume(N),_):N===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(N))}function g(N){return Ne(N)?ze(e,z,"whitespace")(N):z(N)}function z(N){return N===124?m(N):N===null||ge(N)?!a||i!==s?E(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):E(N)}function E(N){return n(N)}function k(N){return e.enter("tableRow"),C(N)}function C(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),C):N===null||ge(N)?(e.exit("tableRow"),t(N)):Ne(N)?ze(e,C,"whitespace")(N):(e.enter("data"),$(N))}function $(N){return N===null||N===124||Me(N)?(e.exit("data"),C(N)):(e.consume(N),N===92?K:$)}function K(N){return N===92||N===124?(e.consume(N),$):$(N)}}function d1(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,c,f,d;const p=new a1;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(o=!1,l!==0&&(ou(p,t,l,c,f),f=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,f={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",f,t]])),i=m.type==="tableDelimiterRow"?2:f?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],d=mi(p,t,s,i,void 0,d),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],d=mi(p,t,s,i,void 0,d)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],d=mi(p,t,s,i,n,d)):a[1]!==0&&(d=mi(p,t,a,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&ou(p,t,l,c,f),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=l1(t.events,n))}return e}function mi(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Vn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Vn(t.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Vn(t.events,n[2]),f=Vn(t.events,n[3]),d={type:o,start:Object.assign({},c),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",d,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 m=n[2]+1,w=n[3]-n[2]-1;e.add(m,w,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},Vn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function ou(e,t,n,r,i){const s=[],a=Vn(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Vn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const f1={name:"tasklistCheck",tokenize:h1};function p1(){return{text:{91:f1}}}function h1(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 Me(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(l)}function o(l){return ge(l)?t(l):Ne(l)?e.check({tokenize:m1},t,n)(l):n(l)}}function m1(e,t,n){return ze(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function g1(e){return Of([ZS(),YS(),s1(e),u1(),p1()])}const x1={};function y1(e){const t=this,n=e||x1,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(g1(n)),s.push(MS()),a.push($S(n))}var _p="vercel.ai.error",b1=Symbol.for(_p),lu,uu,Ht=class jp extends(uu=Error,lu=b1,uu){constructor({name:t,message:n,cause:r}){super(n),this[lu]=!0,this.name=t,this.cause=r}static isInstance(t){return jp.hasMarker(t,_p)}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 Np(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Cp="AI_InvalidArgumentError",Ep=`vercel.ai.error.${Cp}`,v1=Symbol.for(Ep),cu,du,w1=class extends(du=Ht,cu=v1,du){constructor({message:e,cause:t,argument:n}){super({name:Cp,message:e,cause:t}),this[cu]=!0,this.argument=n}static isInstance(e){return Ht.hasMarker(e,Ep)}},Ip="AI_JSONParseError",zp=`vercel.ai.error.${Ip}`,k1=Symbol.for(zp),fu,pu,hu=class extends(pu=Ht,fu=k1,pu){constructor({text:e,cause:t}){super({name:Ip,message:`JSON parsing failed: Text: ${e}.
|
|
31
|
+
Error message: ${Np(t)}`,cause:t}),this[fu]=!0,this.text=e}static isInstance(e){return Ht.hasMarker(e,zp)}},Tp="AI_TypeValidationError",Ap=`vercel.ai.error.${Tp}`,S1=Symbol.for(Ap),mu,gu,ir=class Pa extends(gu=Ht,mu=S1,gu){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:Tp,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
32
|
+
Error message: ${Np(n)}`,cause:n}),this[mu]=!0,this.value=t,this.context=r}static isInstance(t){return Ht.hasMarker(t,Ap)}static wrap({value:t,cause:n,context:r}){var i,s,a;return Pa.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===(r==null?void 0:r.field)&&((s=n.context)==null?void 0:s.entityName)===(r==null?void 0:r.entityName)&&((a=n.context)==null?void 0:a.entityId)===(r==null?void 0:r.entityId)?n:new Pa({value:t,cause:n,context:r})}};function U(e,t,n){function r(o,l){if(o._zod||Object.defineProperty(o,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),o._zod.traits.has(e))return;o._zod.traits.add(e),t(o,l);const c=a.prototype,f=Object.keys(c);for(let d=0;d<f.length;d++){const p=f[d];p in o||(o[p]=c[p].bind(o))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function a(o){var l;const c=n!=null&&n.Parent?new s:this;r(c,o),(l=c._zod).deferred??(l.deferred=[]);for(const f of c._zod.deferred)f();return c}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:o=>{var l,c;return n!=null&&n.Parent&&o instanceof n.Parent?!0:(c=(l=o==null?void 0:o._zod)==null?void 0:l.traits)==null?void 0:c.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class Qn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Pp extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Op={};function dn(e){return Op}function Dp(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 Oa(e,t){return typeof t=="bigint"?t.toString():t}function ws(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Co(e){return e==null}function Eo(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _1(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=n>i?n:i,a=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return a%o/10**s}const xu=Symbol("evaluating");function Ie(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xu)return r===void 0&&(r=xu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Pn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function hn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function yu(e){return JSON.stringify(e)}function j1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Rp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Hr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const N1=ws(()=>{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 sr(e){if(Hr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Hr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Mp(e){return sr(e)?{...e}:Array.isArray(e)?[...e]:e}const C1=new Set(["string","number","symbol"]);function ar(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mn(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 ce(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 E1(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const I1={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 z1(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=hn(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return Pn(this,"shape",a),a},checks:[]});return mn(e,s)}function T1(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=hn(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return Pn(this,"shape",a),a},checks:[]});return mn(e,s)}function A1(e,t){if(!sr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=hn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Pn(this,"shape",s),s}});return mn(e,i)}function P1(e,t){if(!sr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=hn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Pn(this,"shape",r),r}});return mn(e,n)}function O1(e,t){const n=hn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Pn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return mn(e,n)}function D1(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=hn(t._zod.def,{get shape(){const o=t._zod.def.shape,l={...o};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:o[c]}):o[c])}else for(const c in o)l[c]=e?new e({type:"optional",innerType:o[c]}):o[c];return Pn(this,"shape",l),l},checks:[]});return mn(t,a)}function R1(e,t,n){const r=hn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const a in n){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(const a in i)s[a]=new e({type:"nonoptional",innerType:i[a]});return Pn(this,"shape",s),s}});return mn(t,r)}function qn(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 Wn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function gi(e){return typeof e=="string"?e:e==null?void 0:e.message}function fn(e,t,n){var i,s,a,o,l,c;const r={...e,path:e.path??[]};if(!e.message){const f=gi((a=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:a.call(s,e))??gi((o=t==null?void 0:t.error)==null?void 0:o.call(t,e))??gi((l=n.customError)==null?void 0:l.call(n,e))??gi((c=n.localeError)==null?void 0:c.call(n,e))??"Invalid input";r.message=f}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Io(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function qr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const $p=(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,Oa,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fp=U("$ZodError",$p),Lp=U("$ZodError",$p,{Parent:Error});function M1(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 $1(e,t=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let a=n,o=0;for(;o<s.path.length;){const l=s.path[o];o===s.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(s))):a[l]=a[l]||{_errors:[]},a=a[l],o++}}};return r(e),n}const zo=e=>(t,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new Qn;if(a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>fn(l,s,dn())));throw Rp(o,i==null?void 0:i.callee),o}return a.value},To=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const o=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>fn(l,s,dn())));throw Rp(o,i==null?void 0:i.callee),o}return a.value},ks=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 Qn;return s.issues.length?{success:!1,error:new(e??Fp)(s.issues.map(a=>fn(a,i,dn())))}:{success:!0,data:s.value}},F1=ks(Lp),Ss=e=>async(t,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>fn(a,i,dn())))}:{success:!0,data:s.value}},L1=Ss(Lp),Z1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return zo(e)(t,n,i)},B1=e=>(t,n,r)=>zo(e)(t,n,r),V1=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return To(e)(t,n,i)},U1=e=>async(t,n,r)=>To(e)(t,n,r),J1=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ks(e)(t,n,i)},H1=e=>(t,n,r)=>ks(e)(t,n,r),q1=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ss(e)(t,n,i)},W1=e=>async(t,n,r)=>Ss(e)(t,n,r),G1=/^[cC][^\s-]{8,}$/,K1=/^[0-9a-z]+$/,Y1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,X1=/^[0-9a-vA-V]{20}$/,Q1=/^[A-Za-z0-9]{27}$/,e_=/^[a-zA-Z0-9_-]{21}$/,t_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,n_=/^([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})$/,bu=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)$/,r_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,i_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function s_(){return new RegExp(i_,"u")}const a_=/^(?:(?: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])$/,o_=/^(([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}|:))$/,l_=/^((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])$/,u_=/^(([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])$/,c_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zp=/^[A-Za-z0-9_-]*$/,d_=/^\+[1-9]\d{6,14}$/,Bp="(?:(?:\\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])))",f_=new RegExp(`^${Bp}$`);function Vp(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 p_(e){return new RegExp(`^${Vp(e)}$`)}function h_(e){const t=Vp({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(`^${Bp}T(?:${r})$`)}const m_=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}$`)},g_=/^-?\d+$/,Up=/^-?\d+(?:\.\d+)?$/,x_=/^(?:true|false)$/i,y_=/^null$/i,b_=/^[^A-Z]*$/,v_=/^[^a-z]*$/,vt=U("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Jp={number:"number",bigint:"bigint",object:"date"},Hp=U("$ZodCheckLessThan",(e,t)=>{vt.init(e,t);const n=Jp[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})}}),qp=U("$ZodCheckGreaterThan",(e,t)=>{vt.init(e,t);const n=Jp[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})}}),w_=U("$ZodCheckMultipleOf",(e,t)=>{vt.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):_1(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})}}),k_=U("$ZodCheckNumberFormat",(e,t)=>{var a;vt.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[i,s]=I1[t.format];e._zod.onattach.push(o=>{const l=o._zod.bag;l.format=t.format,l.minimum=i,l.maximum=s,n&&(l.pattern=g_)}),e._zod.check=o=>{const l=o.value;if(n){if(!Number.isInteger(l)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?o.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<i&&o.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&o.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),S_=U("$ZodCheckMaxLength",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Co(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const a=Io(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),__=U("$ZodCheckMinLength",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Co(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const a=Io(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),j_=U("$ZodCheckLengthEquals",(e,t)=>{var n;vt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Co(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const a=Io(i),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),_s=U("$ZodCheckStringFormat",(e,t)=>{var n,r;vt.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=()=>{})}),N_=U("$ZodCheckRegex",(e,t)=>{_s.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})}}),C_=U("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=b_),_s.init(e,t)}),E_=U("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=v_),_s.init(e,t)}),I_=U("$ZodCheckIncludes",(e,t)=>{vt.init(e,t);const n=ar(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})}}),z_=U("$ZodCheckStartsWith",(e,t)=>{vt.init(e,t);const n=new RegExp(`^${ar(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})}}),T_=U("$ZodCheckEndsWith",(e,t)=>{vt.init(e,t);const n=new RegExp(`.*${ar(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})}}),A_=U("$ZodCheckOverwrite",(e,t)=>{vt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class P_{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(`
|
|
33
|
+
`).filter(a=>a),i=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(i)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,i.join(`
|
|
34
|
+
`))}}const O_={major:4,minor:3,patch:6},Ve=U("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=O_;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const s=(o,l,c)=>{let f=qn(o),d;for(const p of l){if(p._zod.def.when){if(!p._zod.def.when(o))continue}else if(f)continue;const h=o.issues.length,m=p._zod.check(o);if(m instanceof Promise&&(c==null?void 0:c.async)===!1)throw new Qn;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,o.issues.length!==h&&(f||(f=qn(o,h)))});else{if(o.issues.length===h)continue;f||(f=qn(o,h))}}return d?d.then(()=>o):o},a=(o,l,c)=>{if(qn(o))return o.aborted=!0,o;const f=s(l,r,c);if(f instanceof Promise){if(c.async===!1)throw new Qn;return f.then(d=>e._zod.parse(d,c))}return e._zod.parse(f,c)};e._zod.run=(o,l)=>{if(l.skipChecks)return e._zod.parse(o,l);if(l.direction==="backward"){const f=e._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(d=>a(d,o,l)):a(f,o,l)}const c=e._zod.parse(o,l);if(c instanceof Promise){if(l.async===!1)throw new Qn;return c.then(f=>s(f,r,l))}return s(c,r,l)}}Ie(e,"~standard",()=>({validate:s=>{var a;try{const o=F1(e,s);return o.success?{value:o.data}:{issues:(a=o.error)==null?void 0:a.issues}}catch{return L1(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}))}),Ao=U("$ZodString",(e,t)=>{var n;Ve.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??m_(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}}),Je=U("$ZodStringFormat",(e,t)=>{_s.init(e,t),Ao.init(e,t)}),D_=U("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=n_),Je.init(e,t)}),R_=U("$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=bu(r))}else t.pattern??(t.pattern=bu());Je.init(e,t)}),M_=U("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=r_),Je.init(e,t)}),$_=U("$ZodURL",(e,t)=>{Je.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})}}}),F_=U("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=s_()),Je.init(e,t)}),L_=U("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=e_),Je.init(e,t)}),Z_=U("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=G1),Je.init(e,t)}),B_=U("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=K1),Je.init(e,t)}),V_=U("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Y1),Je.init(e,t)}),U_=U("$ZodXID",(e,t)=>{t.pattern??(t.pattern=X1),Je.init(e,t)}),J_=U("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Q1),Je.init(e,t)}),H_=U("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=h_(t)),Je.init(e,t)}),q_=U("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=f_),Je.init(e,t)}),W_=U("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=p_(t)),Je.init(e,t)}),G_=U("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=t_),Je.init(e,t)}),K_=U("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=a_),Je.init(e,t),e._zod.bag.format="ipv4"}),Y_=U("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=o_),Je.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})}}}),X_=U("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=l_),Je.init(e,t)}),Q_=U("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=u_),Je.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Wp(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ej=U("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=c_),Je.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Wp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function tj(e){if(!Zp.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Wp(n)}const nj=U("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zp),Je.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{tj(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),rj=U("$ZodE164",(e,t)=>{t.pattern??(t.pattern=d_),Je.init(e,t)});function ij(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 sj=U("$ZodJWT",(e,t)=>{Je.init(e,t),e._zod.check=n=>{ij(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Gp=U("$ZodNumber",(e,t)=>{Ve.init(e,t),e._zod.pattern=e._zod.bag.pattern??Up,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}}),aj=U("$ZodNumberFormat",(e,t)=>{k_.init(e,t),Gp.init(e,t)}),oj=U("$ZodBoolean",(e,t)=>{Ve.init(e,t),e._zod.pattern=x_,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}}),lj=U("$ZodNull",(e,t)=>{Ve.init(e,t),e._zod.pattern=y_,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}}),uj=U("$ZodUnknown",(e,t)=>{Ve.init(e,t),e._zod.parse=n=>n}),cj=U("$ZodNever",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function vu(e,t,n){e.issues.length&&t.issues.push(...Wn(n,e.issues)),t.value[n]=e.value}const dj=U("$ZodArray",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let a=0;a<i.length;a++){const o=i[a],l=t.element._zod.run({value:o,issues:[]},r);l instanceof Promise?s.push(l.then(c=>vu(c,n,a))):vu(l,n,a)}return s.length?Promise.all(s).then(()=>n):n}});function Hi(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Wn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Kp(e){var r,i,s,a;const t=Object.keys(e.shape);for(const o of t)if(!((a=(s=(i=(r=e.shape)==null?void 0:r[o])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&a.has("$ZodType")))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=E1(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Yp(e,t,n,r,i,s){const a=[],o=i.keySet,l=i.catchall._zod,c=l.def.type,f=l.optout==="optional";for(const d in t){if(o.has(d))continue;if(c==="never"){a.push(d);continue}const p=l.run({value:t[d],issues:[]},r);p instanceof Promise?e.push(p.then(h=>Hi(h,n,d,t,f))):Hi(p,n,d,t,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const fj=U("$ZodObject",(e,t)=>{Ve.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const o=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...o};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=ws(()=>Kp(t));Ie(e._zod,"propValues",()=>{const o=t.shape,l={};for(const c in o){const f=o[c]._zod;if(f.values){l[c]??(l[c]=new Set);for(const d of f.values)l[c].add(d)}}return l});const i=Hr,s=t.catchall;let a;e._zod.parse=(o,l)=>{a??(a=r.value);const c=o.value;if(!i(c))return o.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),o;o.value={};const f=[],d=a.shape;for(const p of a.keys){const h=d[p],m=h._zod.optout==="optional",w=h._zod.run({value:c[p],issues:[]},l);w instanceof Promise?f.push(w.then(S=>Hi(S,o,p,c,m))):Hi(w,o,p,c,m)}return s?Yp(f,c,o,l,r.value,e):f.length?Promise.all(f).then(()=>o):o}}),pj=U("$ZodObjectJIT",(e,t)=>{fj.init(e,t);const n=e._zod.parse,r=ws(()=>Kp(t)),i=p=>{var g;const h=new P_(["shape","payload","ctx"]),m=r.value,w=z=>{const E=yu(z);return`shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`};h.write("const input = payload.value;");const S=Object.create(null);let x=0;for(const z of m.keys)S[z]=`key_${x++}`;h.write("const newResult = {};");for(const z of m.keys){const E=S[z],k=yu(z),C=p[z],$=((g=C==null?void 0:C._zod)==null?void 0:g.optout)==="optional";h.write(`const ${E} = ${w(z)};`),$?h.write(`
|
|
35
|
+
if (${E}.issues.length) {
|
|
36
|
+
if (${k} in input) {
|
|
37
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
38
|
+
...iss,
|
|
39
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (${E}.value === undefined) {
|
|
45
|
+
if (${k} in input) {
|
|
46
|
+
newResult[${k}] = undefined;
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
newResult[${k}] = ${E}.value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
`):h.write(`
|
|
53
|
+
if (${E}.issues.length) {
|
|
54
|
+
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
55
|
+
...iss,
|
|
56
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (${E}.value === undefined) {
|
|
61
|
+
if (${k} in input) {
|
|
62
|
+
newResult[${k}] = undefined;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
newResult[${k}] = ${E}.value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
`)}h.write("payload.value = newResult;"),h.write("return payload;");const _=h.compile();return(z,E)=>_(p,z,E)};let s;const a=Hr,o=!Op.jitless,c=o&&N1.value,f=t.catchall;let d;e._zod.parse=(p,h)=>{d??(d=r.value);const m=p.value;return a(m)?o&&c&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),f?Yp([],m,p,h,d,e):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function wu(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=>!qn(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(a=>fn(a,r,dn())))}),t)}const Xp=U("$ZodUnion",(e,t)=>{Ve.init(e,t),Ie(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ie(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ie(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ie(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=>Eo(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(n)return r(i,s);let a=!1;const o=[];for(const l of t.options){const c=l._zod.run({value:i.value,issues:[]},s);if(c instanceof Promise)o.push(c),a=!0;else{if(c.issues.length===0)return c;o.push(c)}}return a?Promise.all(o).then(l=>wu(l,i,e,s)):wu(o,i,e,s)}}),hj=U("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Xp.init(e,t);const n=e._zod.parse;Ie(e._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[o,l]of Object.entries(a)){i[o]||(i[o]=new Set);for(const c of l)i[o].add(c)}}return i});const r=ws(()=>{var a;const i=t.options,s=new Map;for(const o of i){const l=(a=o._zod.propValues)==null?void 0:a[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const c of l){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});e._zod.parse=(i,s)=>{const a=i.value;if(!Hr(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;const o=r.value.get(a==null?void 0:a[t.discriminator]);return o?o._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),mj=U("$ZodIntersection",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([l,c])=>ku(n,l,c)):ku(n,s,a)}});function Da(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(sr(e)&&sr(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),i={...e,...t};for(const s of r){const a=Da(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=a.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],s=t[r],a=Da(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ku(e,t,n){const r=new Map;let i;for(const o of t.issues)if(o.code==="unrecognized_keys"){i??(i=o);for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(o);for(const o of n.issues)if(o.code==="unrecognized_keys")for(const l of o.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(o);const s=[...r].filter(([,o])=>o.l&&o.r).map(([o])=>o);if(s.length&&i&&e.issues.push({...i,keys:s}),qn(e))return e;const a=Da(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const gj=U("$ZodRecord",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!sr(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],a=t.keyType._zod.values;if(a){n.value={};const o=new Set;for(const c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){o.add(typeof c=="number"?c.toString():c);const f=t.valueType._zod.run({value:i[c],issues:[]},r);f instanceof Promise?s.push(f.then(d=>{d.issues.length&&n.issues.push(...Wn(c,d.issues)),n.value[c]=d.value})):(f.issues.length&&n.issues.push(...Wn(c,f.issues)),n.value[c]=f.value)}let l;for(const c in i)o.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const o of Reflect.ownKeys(i)){if(o==="__proto__")continue;let l=t.keyType._zod.run({value:o,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof o=="string"&&Up.test(o)&&l.issues.length){const d=t.keyType._zod.run({value:Number(o),issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[o]=i[o]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>fn(d,r,dn())),input:o,path:[o],inst:e});continue}const f=t.valueType._zod.run({value:i[o],issues:[]},r);f instanceof Promise?s.push(f.then(d=>{d.issues.length&&n.issues.push(...Wn(o,d.issues)),n.value[l.value]=d.value})):(f.issues.length&&n.issues.push(...Wn(o,f.issues)),n.value[l.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),xj=U("$ZodEnum",(e,t)=>{Ve.init(e,t);const n=Dp(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>C1.has(typeof i)).map(i=>typeof i=="string"?ar(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}}),yj=U("$ZodLiteral",(e,t)=>{if(Ve.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"?ar(r):r?ar(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}}),bj=U("$ZodTransform",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Pp(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(n.value=a,n));if(i instanceof Promise)throw new Qn;return n.value=i,n}});function Su(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Qp=U("$ZodOptional",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Eo(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=>Su(s,n.value)):Su(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),vj=U("$ZodExactOptional",(e,t)=>{Qp.init(e,t),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),wj=U("$ZodNullable",(e,t)=>{Ve.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Eo(n.source)}|null)$`):void 0}),Ie(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)}),kj=U("$ZodDefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",Ie(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=>_u(s,t)):_u(i,t)}});function _u(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Sj=U("$ZodPrefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",Ie(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))}),_j=U("$ZodNonOptional",(e,t)=>{Ve.init(e,t),Ie(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=>ju(s,e)):ju(i,e)}});function ju(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 jj=U("$ZodCatch",(e,t)=>{Ve.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(a=>fn(a,r,dn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>fn(s,r,dn()))},input:n.value}),n.issues=[]),n)}}),Nj=U("$ZodPipe",(e,t)=>{Ve.init(e,t),Ie(e._zod,"values",()=>t.in._zod.values),Ie(e._zod,"optin",()=>t.in._zod.optin),Ie(e._zod,"optout",()=>t.out._zod.optout),Ie(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>xi(a,t.in,r)):xi(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>xi(s,t.out,r)):xi(i,t.out,r)}});function xi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Cj=U("$ZodReadonly",(e,t)=>{Ve.init(e,t),Ie(e._zod,"propValues",()=>t.innerType._zod.propValues),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Ie(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(Nu):Nu(i)}});function Nu(e){return e.value=Object.freeze(e.value),e}const Ej=U("$ZodLazy",(e,t)=>{Ve.init(e,t),Ie(e._zod,"innerType",()=>t.getter()),Ie(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),Ie(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),Ie(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),Ie(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)}),Ij=U("$ZodCustom",(e,t)=>{vt.init(e,t),Ve.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=>Cu(s,n,r,e));Cu(i,n,r,e)}});function Cu(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(qr(i))}}var Eu;class zj{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 Tj(){return new zj}(Eu=globalThis).__zod_globalRegistry??(Eu.__zod_globalRegistry=Tj());const Nr=globalThis.__zod_globalRegistry;function Aj(e,t){return new e({type:"string",...ce(t)})}function Pj(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ce(t)})}function Iu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ce(t)})}function Oj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ce(t)})}function Dj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ce(t)})}function Rj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ce(t)})}function Mj(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ce(t)})}function $j(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ce(t)})}function Fj(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ce(t)})}function Lj(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ce(t)})}function Zj(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ce(t)})}function Bj(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ce(t)})}function Vj(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ce(t)})}function Uj(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ce(t)})}function Jj(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ce(t)})}function Hj(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ce(t)})}function qj(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ce(t)})}function Wj(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ce(t)})}function Gj(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ce(t)})}function Kj(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ce(t)})}function Yj(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ce(t)})}function Xj(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ce(t)})}function Qj(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ce(t)})}function eN(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ce(t)})}function tN(e,t){return new e({type:"string",format:"date",check:"string_format",...ce(t)})}function nN(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ce(t)})}function rN(e,t){return new e({type:"string",format:"duration",check:"string_format",...ce(t)})}function iN(e,t){return new e({type:"number",checks:[],...ce(t)})}function sN(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ce(t)})}function aN(e,t){return new e({type:"boolean",...ce(t)})}function oN(e,t){return new e({type:"null",...ce(t)})}function lN(e){return new e({type:"unknown"})}function uN(e,t){return new e({type:"never",...ce(t)})}function zu(e,t){return new Hp({check:"less_than",...ce(t),value:e,inclusive:!1})}function na(e,t){return new Hp({check:"less_than",...ce(t),value:e,inclusive:!0})}function Tu(e,t){return new qp({check:"greater_than",...ce(t),value:e,inclusive:!1})}function ra(e,t){return new qp({check:"greater_than",...ce(t),value:e,inclusive:!0})}function Au(e,t){return new w_({check:"multiple_of",...ce(t),value:e})}function eh(e,t){return new S_({check:"max_length",...ce(t),maximum:e})}function qi(e,t){return new __({check:"min_length",...ce(t),minimum:e})}function th(e,t){return new j_({check:"length_equals",...ce(t),length:e})}function cN(e,t){return new N_({check:"string_format",format:"regex",...ce(t),pattern:e})}function dN(e){return new C_({check:"string_format",format:"lowercase",...ce(e)})}function fN(e){return new E_({check:"string_format",format:"uppercase",...ce(e)})}function pN(e,t){return new I_({check:"string_format",format:"includes",...ce(t),includes:e})}function hN(e,t){return new z_({check:"string_format",format:"starts_with",...ce(t),prefix:e})}function mN(e,t){return new T_({check:"string_format",format:"ends_with",...ce(t),suffix:e})}function cr(e){return new A_({check:"overwrite",tx:e})}function gN(e){return cr(t=>t.normalize(e))}function xN(){return cr(e=>e.trim())}function yN(){return cr(e=>e.toLowerCase())}function bN(){return cr(e=>e.toUpperCase())}function vN(){return cr(e=>j1(e))}function wN(e,t,n){return new e({type:"array",element:t,...ce(n)})}function kN(e,t,n){const r=ce(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function SN(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ce(n)})}function _N(e){const t=jN(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(qr(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(qr(i))}},e(n.value,n)));return t}function jN(e,t){const n=new vt({check:"custom",...ce(t)});return n._zod.check=e,n}function Wi(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)??Nr,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 Le(e,t,n={path:[],schemaPath:[]}){var f,d;var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const o=(d=(f=e._zod).toJSONSchema)==null?void 0:d.call(f);if(o)a.schema=o;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,p);else{const m=a.schema,w=t.processors[i.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);w(e,t,m,p)}const h=e._zod.parent;h&&(a.ref||(a.ref=h),Le(h,t,p),t.seen.get(h).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&<(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Gi(e,t){var a,o,l,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const f of e.seen.entries()){const d=(a=e.metadataRegistry.get(f[0]))==null?void 0:a.id;if(d){const p=r.get(d);if(p&&p!==f[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(d,f[0])}}const i=f=>{var w;const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(w=e.external.registry.get(f[0]))==null?void 0:w.id,x=e.external.uri??(g=>g);if(S)return{ref:x(S)};const _=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=_,{defId:_,ref:`${x("__shared")}#/${d}/${_}`}}if(f[1]===n)return{ref:"#"};const h=`#/${d}/`,m=f[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:h+m}},s=f=>{if(f[1].schema.$ref)return;const d=f[1],{ref:p,defId:h}=i(f);d.def={...d.schema},h&&(d.defId=h);const m=d.schema;for(const w in m)delete m[w];m.$ref=p};if(e.cycles==="throw")for(const f of e.seen.entries()){const d=f[1];if(d.cycle)throw new Error(`Cycle detected: #/${(o=d.cycle)==null?void 0:o.join("/")}/<root>
|
|
69
|
+
|
|
70
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of e.seen.entries()){const d=f[1];if(t===f[0]){s(f);continue}if(e.external){const h=(l=e.external.registry.get(f[0]))==null?void 0:l.id;if(t!==f[0]&&h){s(f);continue}}if((c=e.metadataRegistry.get(f[0]))==null?void 0:c.id){s(f);continue}if(d.cycle){s(f);continue}if(d.count>1&&e.reused==="ref"){s(f);continue}}}function Ki(e,t){var a,o,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const f=e.seen.get(c);if(f.ref===null)return;const d=f.def??f.schema,p={...d},h=f.ref;if(f.ref=null,h){r(h);const w=e.seen.get(h),S=w.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(S)):Object.assign(d,S),Object.assign(d,p),c._zod.parent===h)for(const _ in d)_==="$ref"||_==="allOf"||_ in p||delete d[_];if(S.$ref&&w.def)for(const _ in d)_==="$ref"||_==="allOf"||_ in w.def&&JSON.stringify(d[_])===JSON.stringify(w.def[_])&&delete d[_]}const m=c._zod.parent;if(m&&m!==h){r(m);const w=e.seen.get(m);if(w!=null&&w.schema.$ref&&(d.$ref=w.schema.$ref,w.def))for(const S in d)S==="$ref"||S==="allOf"||S in w.def&&JSON.stringify(d[S])===JSON.stringify(w.def[S])&&delete d[S]}e.override({zodSchema:c,jsonSchema:d,path:f.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const c=(o=e.external.registry.get(t))==null?void 0:o.id;if(!c)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(c)}Object.assign(i,n.def??n.schema);const s=((l=e.external)==null?void 0:l.defs)??{};for(const c of e.seen.entries()){const f=c[1];f.def&&f.defId&&(s[f.defId]=f.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:Yi(t,"input",e.processors),output:Yi(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function lt(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 lt(r.element,n);if(r.type==="set")return lt(r.valueType,n);if(r.type==="lazy")return lt(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 lt(r.innerType,n);if(r.type==="intersection")return lt(r.left,n)||lt(r.right,n);if(r.type==="record"||r.type==="map")return lt(r.keyType,n)||lt(r.valueType,n);if(r.type==="pipe")return lt(r.in,n)||lt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(lt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(lt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(lt(i,n))return!0;return!!(r.rest&<(r.rest,n))}return!1}const NN=(e,t={})=>n=>{const r=Wi({...n,processors:t});return Le(e,r),Gi(r,e),Ki(r,e)},Yi=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=Wi({...i??{},target:s,io:t,processors:n});return Le(e,a),Gi(a,e),Ki(a,e)},CN={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nh=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:a,format:o,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),o&&(i.format=CN[o]??o,i.format===""&&delete i.format,o==="time"&&delete i.format),c&&(i.contentEncoding=c),l&&l.size>0){const f=[...l];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},rh=(e,t,n,r)=>{const i=n,{minimum:s,maximum:a,format:o,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:f}=e._zod.bag;typeof o=="string"&&o.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof s=="number"&&(i.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c),typeof a=="number"&&(i.maximum=a,typeof c=="number"&&t.target!=="draft-04"&&(c<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},ih=(e,t,n,r)=>{n.type="boolean"},EN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},IN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},sh=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},zN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},TN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},ah=(e,t,n,r)=>{n.not={}},AN=(e,t,n,r)=>{},oh=(e,t,n,r)=>{},PN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},lh=(e,t,n,r)=>{const i=e._zod.def,s=Dp(i.entries);s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},uh=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},ON=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},DN=(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},RN=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:o,mime:l}=e._zod.bag;a!==void 0&&(s.minLength=a),o!==void 0&&(s.maxLength=o),l?l.length===1?(s.contentMediaType=l[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(i,s)},MN=(e,t,n,r)=>{n.type="boolean"},ch=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},$N=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},dh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},FN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},LN=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},fh=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:a,maximum:o}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof o=="number"&&(i.maxItems=o),i.type="array",i.items=Le(s.element,t,{...r,path:[...r.path,"items"]})},ph=(e,t,n,r)=>{var c;const i=n,s=e._zod.def;i.type="object",i.properties={};const a=s.shape;for(const f in a)i.properties[f]=Le(a[f],t,{...r,path:[...r.path,"properties",f]});const o=new Set(Object.keys(a)),l=new Set([...o].filter(f=>{const d=s.shape[f]._zod;return t.io==="input"?d.optin===void 0:d.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=Le(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},hh=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,a=i.options.map((o,l)=>Le(o,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=a:n.anyOf=a},mh=(e,t,n,r)=>{const i=e._zod.def,s=Le(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Le(i.right,t,{...r,path:[...r.path,"allOf",1]}),o=c=>"allOf"in c&&Object.keys(c).length===1,l=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=l},ZN=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((p,h)=>Le(p,t,{...r,path:[...r.path,a,h]})),c=s.rest?Le(s.rest,t,{...r,path:[...r.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=l,c&&(i.items=c)):t.target==="openapi-3.0"?(i.items={anyOf:l},c&&i.items.anyOf.push(c),i.minItems=l.length,c||(i.maxItems=l.length)):(i.items=l,c&&(i.additionalItems=c));const{minimum:f,maximum:d}=e._zod.bag;typeof f=="number"&&(i.minItems=f),typeof d=="number"&&(i.maxItems=d)},gh=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const a=s.keyType,o=a._zod.bag,l=o==null?void 0:o.patterns;if(s.mode==="loose"&&l&&l.size>0){const f=Le(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of l)i.patternProperties[d.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Le(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Le(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=a._zod.values;if(c){const f=[...c].filter(d=>typeof d=="string"||typeof d=="number");f.length>0&&(i.required=f)}},xh=(e,t,n,r)=>{const i=e._zod.def,s=Le(i.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},yh=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},bh=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},vh=(e,t,n,r)=>{const i=e._zod.def;Le(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)))},wh=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},kh=(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;Le(s,t,r);const a=t.seen.get(e);a.ref=s},Sh=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},BN=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Po=(e,t,n,r)=>{const i=e._zod.def;Le(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},_h=(e,t,n,r)=>{const i=e._zod.innerType;Le(i,t,r);const s=t.seen.get(e);s.ref=i},Pu={string:nh,number:rh,boolean:ih,bigint:EN,symbol:IN,null:sh,undefined:zN,void:TN,never:ah,any:AN,unknown:oh,date:PN,enum:lh,literal:uh,nan:ON,template_literal:DN,file:RN,success:MN,custom:ch,function:$N,transform:dh,map:FN,set:LN,array:fh,object:ph,union:hh,intersection:mh,tuple:ZN,record:gh,nullable:xh,nonoptional:yh,default:bh,prefault:vh,catch:wh,pipe:kh,readonly:Sh,promise:BN,optional:Po,lazy:_h};function VN(e,t){if("_idmap"in e){const r=e,i=Wi({...t,processors:Pu}),s={};for(const l of r._idmap.entries()){const[c,f]=l;Le(f,i)}const a={},o={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=o;for(const l of r._idmap.entries()){const[c,f]=l;Gi(i,f),a[c]=Ki(i,f)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:s}}return{schemas:a}}const n=Wi({...t,processors:Pu});return Le(e,n),Gi(n,e),Ki(n,e)}const UN=U("ZodISODateTime",(e,t)=>{H_.init(e,t),He.init(e,t)});function JN(e){return eN(UN,e)}const HN=U("ZodISODate",(e,t)=>{q_.init(e,t),He.init(e,t)});function qN(e){return tN(HN,e)}const WN=U("ZodISOTime",(e,t)=>{W_.init(e,t),He.init(e,t)});function GN(e){return nN(WN,e)}const KN=U("ZodISODuration",(e,t)=>{G_.init(e,t),He.init(e,t)});function YN(e){return rN(KN,e)}const XN=(e,t)=>{Fp.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>$1(e,n)},flatten:{value:n=>M1(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Oa,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Oa,2)}},isEmpty:{get(){return e.issues.length===0}}})},zt=U("ZodError",XN,{Parent:Error}),QN=zo(zt),eC=To(zt),tC=ks(zt),jh=Ss(zt),nC=Z1(zt),rC=B1(zt),iC=V1(zt),sC=U1(zt),aC=J1(zt),oC=H1(zt),lC=q1(zt),uC=W1(zt),Ue=U("ZodType",(e,t)=>(Ve.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Yi(e,"input"),output:Yi(e,"output")}}),e.toJSONSchema=NN(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(hn(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)=>mn(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>QN(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>tC(e,n,r),e.parseAsync=async(n,r)=>eC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>jh(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>nC(e,n,r),e.decode=(n,r)=>rC(e,n,r),e.encodeAsync=async(n,r)=>iC(e,n,r),e.decodeAsync=async(n,r)=>sC(e,n,r),e.safeEncode=(n,r)=>aC(e,n,r),e.safeDecode=(n,r)=>oC(e,n,r),e.safeEncodeAsync=async(n,r)=>lC(e,n,r),e.safeDecodeAsync=async(n,r)=>uC(e,n,r),e.refine=(n,r)=>e.check(sE(n,r)),e.superRefine=n=>e.check(aE(n)),e.overwrite=n=>e.check(cr(n)),e.optional=()=>Ru(e),e.exactOptional=()=>JC(e),e.nullable=()=>Mu(e),e.nullish=()=>Ru(Mu(e)),e.nonoptional=n=>YC(e,n),e.array=()=>dr(e),e.or=n=>ft([e,n]),e.and=n=>FC(e,n),e.transform=n=>$u(e,VC(n)),e.default=n=>WC(e,n),e.prefault=n=>KC(e,n),e.catch=n=>QC(e,n),e.pipe=n=>$u(e,n),e.readonly=()=>nE(e),e.describe=n=>{const r=e.clone();return Nr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=Nr.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Nr.get(e);const r=e.clone();return Nr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Nh=U("_ZodString",(e,t)=>{Ao.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(r,i,s)=>nh(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(cN(...r)),e.includes=(...r)=>e.check(pN(...r)),e.startsWith=(...r)=>e.check(hN(...r)),e.endsWith=(...r)=>e.check(mN(...r)),e.min=(...r)=>e.check(qi(...r)),e.max=(...r)=>e.check(eh(...r)),e.length=(...r)=>e.check(th(...r)),e.nonempty=(...r)=>e.check(qi(1,...r)),e.lowercase=r=>e.check(dN(r)),e.uppercase=r=>e.check(fN(r)),e.trim=()=>e.check(xN()),e.normalize=(...r)=>e.check(gN(...r)),e.toLowerCase=()=>e.check(yN()),e.toUpperCase=()=>e.check(bN()),e.slugify=()=>e.check(vN())}),cC=U("ZodString",(e,t)=>{Ao.init(e,t),Nh.init(e,t),e.email=n=>e.check(Pj(dC,n)),e.url=n=>e.check($j(fC,n)),e.jwt=n=>e.check(Qj(CC,n)),e.emoji=n=>e.check(Fj(pC,n)),e.guid=n=>e.check(Iu(Ou,n)),e.uuid=n=>e.check(Oj(yi,n)),e.uuidv4=n=>e.check(Dj(yi,n)),e.uuidv6=n=>e.check(Rj(yi,n)),e.uuidv7=n=>e.check(Mj(yi,n)),e.nanoid=n=>e.check(Lj(hC,n)),e.guid=n=>e.check(Iu(Ou,n)),e.cuid=n=>e.check(Zj(mC,n)),e.cuid2=n=>e.check(Bj(gC,n)),e.ulid=n=>e.check(Vj(xC,n)),e.base64=n=>e.check(Kj(_C,n)),e.base64url=n=>e.check(Yj(jC,n)),e.xid=n=>e.check(Uj(yC,n)),e.ksuid=n=>e.check(Jj(bC,n)),e.ipv4=n=>e.check(Hj(vC,n)),e.ipv6=n=>e.check(qj(wC,n)),e.cidrv4=n=>e.check(Wj(kC,n)),e.cidrv6=n=>e.check(Gj(SC,n)),e.e164=n=>e.check(Xj(NC,n)),e.datetime=n=>e.check(JN(n)),e.date=n=>e.check(qN(n)),e.time=n=>e.check(GN(n)),e.duration=n=>e.check(YN(n))});function se(e){return Aj(cC,e)}const He=U("ZodStringFormat",(e,t)=>{Je.init(e,t),Nh.init(e,t)}),dC=U("ZodEmail",(e,t)=>{M_.init(e,t),He.init(e,t)}),Ou=U("ZodGUID",(e,t)=>{D_.init(e,t),He.init(e,t)}),yi=U("ZodUUID",(e,t)=>{R_.init(e,t),He.init(e,t)}),fC=U("ZodURL",(e,t)=>{$_.init(e,t),He.init(e,t)}),pC=U("ZodEmoji",(e,t)=>{F_.init(e,t),He.init(e,t)}),hC=U("ZodNanoID",(e,t)=>{L_.init(e,t),He.init(e,t)}),mC=U("ZodCUID",(e,t)=>{Z_.init(e,t),He.init(e,t)}),gC=U("ZodCUID2",(e,t)=>{B_.init(e,t),He.init(e,t)}),xC=U("ZodULID",(e,t)=>{V_.init(e,t),He.init(e,t)}),yC=U("ZodXID",(e,t)=>{U_.init(e,t),He.init(e,t)}),bC=U("ZodKSUID",(e,t)=>{J_.init(e,t),He.init(e,t)}),vC=U("ZodIPv4",(e,t)=>{K_.init(e,t),He.init(e,t)}),wC=U("ZodIPv6",(e,t)=>{Y_.init(e,t),He.init(e,t)}),kC=U("ZodCIDRv4",(e,t)=>{X_.init(e,t),He.init(e,t)}),SC=U("ZodCIDRv6",(e,t)=>{Q_.init(e,t),He.init(e,t)}),_C=U("ZodBase64",(e,t)=>{ej.init(e,t),He.init(e,t)}),jC=U("ZodBase64URL",(e,t)=>{nj.init(e,t),He.init(e,t)}),NC=U("ZodE164",(e,t)=>{rj.init(e,t),He.init(e,t)}),CC=U("ZodJWT",(e,t)=>{sj.init(e,t),He.init(e,t)}),Ch=U("ZodNumber",(e,t)=>{Gp.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(r,i,s)=>rh(e,r,i),e.gt=(r,i)=>e.check(Tu(r,i)),e.gte=(r,i)=>e.check(ra(r,i)),e.min=(r,i)=>e.check(ra(r,i)),e.lt=(r,i)=>e.check(zu(r,i)),e.lte=(r,i)=>e.check(na(r,i)),e.max=(r,i)=>e.check(na(r,i)),e.int=r=>e.check(Du(r)),e.safe=r=>e.check(Du(r)),e.positive=r=>e.check(Tu(0,r)),e.nonnegative=r=>e.check(ra(0,r)),e.negative=r=>e.check(zu(0,r)),e.nonpositive=r=>e.check(na(0,r)),e.multipleOf=(r,i)=>e.check(Au(r,i)),e.step=(r,i)=>e.check(Au(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 EC(e){return iN(Ch,e)}const IC=U("ZodNumberFormat",(e,t)=>{aj.init(e,t),Ch.init(e,t)});function Du(e){return sN(IC,e)}const zC=U("ZodBoolean",(e,t)=>{oj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ih(e,n,r)});function ut(e){return aN(zC,e)}const TC=U("ZodNull",(e,t)=>{lj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sh(e,n,r)});function AC(e){return oN(TC,e)}const PC=U("ZodUnknown",(e,t)=>{uj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oh()});function Lt(){return lN(PC)}const OC=U("ZodNever",(e,t)=>{cj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ah(e,n,r)});function Eh(e){return uN(OC,e)}const DC=U("ZodArray",(e,t)=>{dj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(qi(n,r)),e.nonempty=n=>e.check(qi(1,n)),e.max=(n,r)=>e.check(eh(n,r)),e.length=(n,r)=>e.check(th(n,r)),e.unwrap=()=>e.element});function dr(e,t){return wN(DC,e,t)}const Ih=U("ZodObject",(e,t)=>{pj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ph(e,n,r,i),Ie(e,"shape",()=>t.shape),e.keyof=()=>Th(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Lt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Lt()}),e.strict=()=>e.clone({...e._zod.def,catchall:Eh()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>A1(e,n),e.safeExtend=n=>P1(e,n),e.merge=n=>O1(e,n),e.pick=n=>z1(e,n),e.omit=n=>T1(e,n),e.partial=(...n)=>D1(Ah,e,n[0]),e.required=(...n)=>R1(Ph,e,n[0])});function Re(e,t){const n={type:"object",shape:e??{},...ce(t)};return new Ih(n)}function Ze(e,t){return new Ih({type:"object",shape:e,catchall:Eh(),...ce(t)})}const zh=U("ZodUnion",(e,t)=>{Xp.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hh(e,n,r,i),e.options=t.options});function ft(e,t){return new zh({type:"union",options:e,...ce(t)})}const RC=U("ZodDiscriminatedUnion",(e,t)=>{zh.init(e,t),hj.init(e,t)});function MC(e,t,n){return new RC({type:"union",options:t,discriminator:e,...ce(n)})}const $C=U("ZodIntersection",(e,t)=>{mj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mh(e,n,r,i)});function FC(e,t){return new $C({type:"intersection",left:e,right:t})}const LC=U("ZodRecord",(e,t)=>{gj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gh(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Wr(e,t,n){return new LC({type:"record",keyType:e,valueType:t,...ce(n)})}const Ra=U("ZodEnum",(e,t)=>{xj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(r,i,s)=>lh(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const s={};for(const a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Ra({...t,checks:[],...ce(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new Ra({...t,checks:[],...ce(i),entries:s})}});function Th(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ra({type:"enum",entries:n,...ce(t)})}const ZC=U("ZodLiteral",(e,t)=>{yj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uh(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 xe(e,t){return new ZC({type:"literal",values:Array.isArray(e)?e:[e],...ce(t)})}const BC=U("ZodTransform",(e,t)=>{bj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dh(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Pp(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(qr(s,n.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(qr(a))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function VC(e){return new BC({type:"transform",transform:e})}const Ah=U("ZodOptional",(e,t)=>{Qp.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Po(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ru(e){return new Ah({type:"optional",innerType:e})}const UC=U("ZodExactOptional",(e,t)=>{vj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Po(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function JC(e){return new UC({type:"optional",innerType:e})}const HC=U("ZodNullable",(e,t)=>{wj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Mu(e){return new HC({type:"nullable",innerType:e})}const qC=U("ZodDefault",(e,t)=>{kj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function WC(e,t){return new qC({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Mp(t)}})}const GC=U("ZodPrefault",(e,t)=>{Sj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function KC(e,t){return new GC({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Mp(t)}})}const Ph=U("ZodNonOptional",(e,t)=>{_j.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function YC(e,t){return new Ph({type:"nonoptional",innerType:e,...ce(t)})}const XC=U("ZodCatch",(e,t)=>{jj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function QC(e,t){return new XC({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const eE=U("ZodPipe",(e,t)=>{Nj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kh(e,n,r,i),e.in=t.in,e.out=t.out});function $u(e,t){return new eE({type:"pipe",in:e,out:t})}const tE=U("ZodReadonly",(e,t)=>{Cj.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function nE(e){return new tE({type:"readonly",innerType:e})}const rE=U("ZodLazy",(e,t)=>{Ej.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_h(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function iE(e){return new rE({type:"lazy",getter:e})}const Oo=U("ZodCustom",(e,t)=>{Ij.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ch(e,n)});function Oh(e,t){return kN(Oo,e??(()=>!0),t)}function sE(e,t={}){return SN(Oo,e,t)}function aE(e){return _N(e)}function Xi(e,t={}){const n=new Oo({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...ce(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 Gr;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Gr||(Gr={}));var Fu;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Fu||(Fu={}));Gr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Gr.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 Qi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(n(a))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Qi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Gr.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()}}Qi.create=e=>new Qi(e);var Lu;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Lu||(Lu={}));var be;(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"})(be||(be={}));class Zu 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 ia(e){}function oE(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=ia,onError:n=ia,onRetry:r=ia,onComment:i}=e;let s="",a=!0,o,l="",c="";function f(w){const S=a?w.replace(/^\xEF\xBB\xBF/,""):w,[x,_]=lE(`${s}${S}`);for(const g of x)d(g);s=_,a=!1}function d(w){if(w===""){h();return}if(w.startsWith(":")){i&&i(w.slice(w.startsWith(": ")?2:1));return}const S=w.indexOf(":");if(S!==-1){const x=w.slice(0,S),_=w[S+1]===" "?2:1,g=w.slice(S+_);p(x,g,w);return}p(w,"",w)}function p(w,S,x){switch(w){case"event":c=S;break;case"data":l=`${l}${S}
|
|
71
|
+
`;break;case"id":o=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new Zu(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:x}));break;default:n(new Zu(`Unknown field "${w.length>20?`${w.slice(0,20)}…`:w}"`,{type:"unknown-field",field:w,value:S,line:x}));break}}function h(){l.length>0&&t({id:o,event:c||void 0,data:l.endsWith(`
|
|
72
|
+
`)?l.slice(0,-1):l}),o=void 0,l="",c=""}function m(w={}){s&&w.consume&&d(s),a=!0,o=void 0,l="",c="",s=""}return{feed:f,reset:m}}function lE(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
|
|
73
|
+
`,r);let a=-1;if(i!==-1&&s!==-1?a=Math.min(i,s):i!==-1?i===e.length-1?a=-1:a=i:s!==-1&&(a=s),a===-1){n=e.slice(r);break}else{const o=e.slice(r,a);t.push(o),r=a+1,e[r-1]==="\r"&&e[r]===`
|
|
74
|
+
`&&r++}}return[t,n]}class uE extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=oE({onEvent:a=>{s.enqueue(a)},onError(a){t==="terminate"?s.error(a):typeof t=="function"&&t(a)},onRetry:n,onComment:r})},transform(s){i.feed(s)}})}}var si=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,a=new Array(t);for(let o=0;o<t;o++)a[o]=n[Math.random()*s|0];return a.join("")};if(e==null)return i;if(n.includes(r))throw new w1({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},cE=si();function Fn(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 dE=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,fE=/"(?: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 Bu(e){const t=JSON.parse(e);return t===null||typeof t!="object"||dE.test(e)===!1&&fE.test(e)===!1?t:pE(t)}function pE(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 hE(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Bu(e)}try{return Bu(e)}finally{Error.stackTraceLimit=t}}function Do(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]=yn(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(yn):yn(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(yn)),e.allOf!=null&&(e.allOf=e.allOf.map(yn)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(yn));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=yn(t[n]);return e}function yn(e){return typeof e=="boolean"?e:Do(e)}var mE=Symbol("Let zodToJsonSchema decide on which parser to use"),Vu={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"},gE=e=>typeof e=="string"?{...Vu,name:e}:{...Vu,...e};function jt(){return{}}function xE(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)!==be.ZodAny&&(s.items=Pe(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 yE(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 bE(){return{type:"boolean"}}function Dh(e,t){return Pe(e.type._def,t)}var vE=(e,t)=>Pe(e.innerType._def,t);function Rh(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>Rh(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 wE(e)}}var wE=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 kE(e,t){return{...Pe(e.innerType._def,t),default:e.defaultValue()}}function SE(e,t){return t.effectStrategy==="input"?Pe(e.schema._def,t):jt()}function _E(e){return{type:"string",enum:Array.from(e.values)}}var jE=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function NE(e,t){const n=[Pe(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Pe(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(jE(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:a,...o}=i;s=o}r.push(s)}}),r.length?{allOf:r}:void 0}function CE(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 sa=void 0,Tt={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:()=>(sa===void 0&&(sa=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),sa),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 Mh(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":At(n,"email",r.message,t);break;case"format:idn-email":At(n,"idn-email",r.message,t);break;case"pattern:zod":ot(n,Tt.email,r.message,t);break}break;case"url":At(n,"uri",r.message,t);break;case"uuid":At(n,"uuid",r.message,t);break;case"regex":ot(n,r.regex,r.message,t);break;case"cuid":ot(n,Tt.cuid,r.message,t);break;case"cuid2":ot(n,Tt.cuid2,r.message,t);break;case"startsWith":ot(n,RegExp(`^${aa(r.value,t)}`),r.message,t);break;case"endsWith":ot(n,RegExp(`${aa(r.value,t)}$`),r.message,t);break;case"datetime":At(n,"date-time",r.message,t);break;case"date":At(n,"date",r.message,t);break;case"time":At(n,"time",r.message,t);break;case"duration":At(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":{ot(n,RegExp(aa(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&At(n,"ipv4",r.message,t),r.version!=="v4"&&At(n,"ipv6",r.message,t);break}case"base64url":ot(n,Tt.base64url,r.message,t);break;case"jwt":ot(n,Tt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ot(n,Tt.ipv4Cidr,r.message,t),r.version!=="v4"&&ot(n,Tt.ipv6Cidr,r.message,t);break}case"emoji":ot(n,Tt.emoji(),r.message,t);break;case"ulid":{ot(n,Tt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{At(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ot(n,Tt.base64,r.message,t);break}}break}case"nanoid":ot(n,Tt.nanoid,r.message,t)}return n}function aa(e,t){return t.patternStrategy==="escape"?IE(e):e}var EE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function IE(e){let t="";for(let n=0;n<e.length;n++)EE.has(e[n])||(t+="\\"),t+=e[n];return t}function At(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 ot(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:Uu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Uu(t,r)}function Uu(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source;let s="",a=!1,o=!1,l=!1;for(let c=0;c<i.length;c++){if(a){s+=i[c],a=!1;continue}if(r.i){if(o){if(i[c].match(/[a-z]/)){l?(s+=i[c],s+=`${i[c-2]}-${i[c]}`.toUpperCase(),l=!1):i[c+1]==="-"&&((n=i[c+2])!=null&&n.match(/[a-z]/))?(s+=i[c],l=!0):s+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){s+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){s+=`(^|(?<=[\r
|
|
75
|
+
]))`;continue}else if(i[c]==="$"){s+=`($|(?=[\r
|
|
76
|
+
]))`;continue}}if(r.s&&i[c]==="."){s+=o?`${i[c]}\r
|
|
77
|
+
`:`[${i[c]}\r
|
|
78
|
+
]`;continue}s+=i[c],i[c]==="\\"?a=!0:o&&i[c]==="]"?o=!1:!o&&i[c]==="["&&(o=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return s}function $h(e,t){var n,r,i,s,a,o;const l={type:"object",additionalProperties:(n=Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===be.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...f}=Mh(e.keyType._def,t);return{...l,propertyNames:f}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===be.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===be.ZodBranded&&e.keyType._def.type._def.typeName===be.ZodString&&((o=e.keyType._def.type._def.checks)!=null&&o.length)){const{type:c,...f}=Dh(e.keyType._def,t);return{...l,propertyNames:f}}}return l}function zE(e,t){if(t.mapStrategy==="record")return $h(e,t);const n=Pe(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||jt(),r=Pe(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||jt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function TE(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 AE(){return{not:jt()}}function PE(){return{type:"null"}}var Ma={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function OE(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Ma&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const a=Ma[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,s)=>{const a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){const i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return DE(e,t)}var DE=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Pe(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 RE(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Ma[e.innerType._def.typeName],"null"]};const n=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function ME(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 $E(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const a in i){let o=i[a];if(o===void 0||o._def===void 0)continue;const l=LE(o),c=Pe(o._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});c!==void 0&&(n.properties[a]=c,l||r.push(a))}r.length&&(n.required=r);const s=FE(e,t);return s!==void 0&&(n.additionalProperties=s),n}function FE(e,t){if(e.catchall._def.typeName!=="ZodNever")return Pe(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 LE(e){try{return e.isOptional()}catch{return!0}}var ZE=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Pe(e.innerType._def,t);const r=Pe(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:jt()},r]}:jt()},BE=(e,t)=>{if(t.pipeStrategy==="input")return Pe(e.in._def,t);if(t.pipeStrategy==="output")return Pe(e.out._def,t);const n=Pe(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Pe(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function VE(e,t){return Pe(e.type._def,t)}function UE(e,t){const r={type:"array",uniqueItems:!0,items:Pe(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 JE(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Pe(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Pe(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function HE(){return{not:jt()}}function qE(){return jt()}var WE=(e,t)=>Pe(e.innerType._def,t),GE=(e,t,n)=>{switch(t){case be.ZodString:return Mh(e,n);case be.ZodNumber:return ME(e);case be.ZodObject:return $E(e,n);case be.ZodBigInt:return yE(e);case be.ZodBoolean:return bE();case be.ZodDate:return Rh(e,n);case be.ZodUndefined:return HE();case be.ZodNull:return PE();case be.ZodArray:return xE(e,n);case be.ZodUnion:case be.ZodDiscriminatedUnion:return OE(e,n);case be.ZodIntersection:return NE(e,n);case be.ZodTuple:return JE(e,n);case be.ZodRecord:return $h(e,n);case be.ZodLiteral:return CE(e);case be.ZodEnum:return _E(e);case be.ZodNativeEnum:return TE(e);case be.ZodNullable:return RE(e,n);case be.ZodOptional:return ZE(e,n);case be.ZodMap:return zE(e,n);case be.ZodSet:return UE(e,n);case be.ZodLazy:return()=>e.getter()._def;case be.ZodPromise:return VE(e,n);case be.ZodNaN:case be.ZodNever:return AE();case be.ZodEffects:return SE(e,n);case be.ZodAny:return jt();case be.ZodUnknown:return qE();case be.ZodDefault:return kE(e,n);case be.ZodBranded:return Dh(e,n);case be.ZodReadonly:return WE(e,n);case be.ZodCatch:return vE(e,n);case be.ZodPipeline:return BE(e,n);case be.ZodFunction:case be.ZodVoid:case be.ZodSymbol:return;default:return(r=>{})()}},KE=(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 Pe(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!==mE)return l}if(i&&!n){const l=YE(i,t);if(l!==void 0)return l}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=GE(e,e.typeName,t),o=typeof a=="function"?Pe(a(),t):a;if(o&&XE(e,t,o),t.postProcess){const l=t.postProcess(o,e,t);return s.jsonSchema=o,l}return s.jsonSchema=o,o}var YE=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:KE(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`),jt()):t.$refStrategy==="seen"?jt():void 0}},XE=(e,t,n)=>(e.description&&(n.description=e.description),n),QE=e=>{const t=gE(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}]))}},eI=(e,t)=>{var n;const r=QE(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[f,d])=>{var p;return{...c,[f]:(p=Pe(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?p:jt()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,a=(n=Pe(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:jt(),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(a.title=o);const l=s===void 0?i?{...a,[r.definitionPath]:i}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},$a=Symbol.for("vercel.ai.schema");function tI(e){let t;return()=>(t==null&&(t=e()),t)}function js(e,{validate:t}={}){return{[$a]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function nI(e){return typeof e=="object"&&e!==null&&$a in e&&e[$a]===!0&&"jsonSchema"in e&&"validate"in e}function Ro(e){return e==null?js({properties:{},additionalProperties:!1}):nI(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?Fh(e):rI(e):e()}function rI(e){return js(()=>Do(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 ir({value:t,cause:n.issues})}}})}function iI(e,t){var n;const r=(n=void 0)!=null?n:!1;return js(()=>eI(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 sI(e,t){var n;const r=(n=void 0)!=null?n:!1;return js(()=>Do(VN(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await jh(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function aI(e){return"_zod"in e}function Fh(e,t){return aI(e)?sI(e):iI(e)}async function Ju({value:e,schema:t,context:n}){const r=await Kr({value:e,schema:t,context:n});if(!r.success)throw ir.wrap({value:e,cause:r.error,context:n});return r.value}async function Kr({value:e,schema:t,context:n}){const r=Ro(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:ir.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:ir.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function Tn({text:e,schema:t}){try{const n=hE(e);return t==null?{success:!0,value:n,rawValue:n}:await Kr({value:n,schema:t})}catch(n){return{success:!1,error:hu.isInstance(n)?n:new hu({text:e,cause:n}),rawValue:void 0}}}function oI({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new uE).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await Tn({text:n,schema:t}))}}))}async function rn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var lI=Object.defineProperty,uI=(e,t)=>{for(var n in t)lI(e,n,{get:t[n],enumerable:!0})},Lh="AI_NoObjectGeneratedError",Zh=`vercel.ai.error.${Lh}`,cI=Symbol.for(Zh),Bh,ln=class extends Ht{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:Lh,message:e,cause:t}),this[Bh]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Ht.hasMarker(e,Zh)}};Bh=cI;var Vh="AI_UIMessageStreamError",Uh=`vercel.ai.error.${Vh}`,dI=Symbol.for(Uh),Jh,Ln=class extends Ht{constructor({chunkType:e,chunkId:t,message:n}){super({name:Vh,message:n}),this[Jh]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Ht.hasMarker(e,Uh)}};Jh=dI;var Hh=ft([se(),Xi(Uint8Array),Xi(ArrayBuffer),Oh(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Yr=iE(()=>ft([AC(),se(),EC(),ut(),Wr(se(),Yr.optional()),dr(Yr)])),je=Wr(se(),Wr(se(),Yr.optional())),qh=Re({type:xe("text"),text:se(),providerOptions:je.optional()}),fI=Re({type:xe("image"),image:ft([Hh,Xi(URL)]),mediaType:se().optional(),providerOptions:je.optional()}),Wh=Re({type:xe("file"),data:ft([Hh,Xi(URL)]),filename:se().optional(),mediaType:se(),providerOptions:je.optional()}),pI=Re({type:xe("reasoning"),text:se(),providerOptions:je.optional()}),hI=Re({type:xe("tool-call"),toolCallId:se(),toolName:se(),input:Lt(),providerOptions:je.optional(),providerExecuted:ut().optional()}),mI=MC("type",[Re({type:xe("text"),value:se(),providerOptions:je.optional()}),Re({type:xe("json"),value:Yr,providerOptions:je.optional()}),Re({type:xe("execution-denied"),reason:se().optional(),providerOptions:je.optional()}),Re({type:xe("error-text"),value:se(),providerOptions:je.optional()}),Re({type:xe("error-json"),value:Yr,providerOptions:je.optional()}),Re({type:xe("content"),value:dr(ft([Re({type:xe("text"),text:se(),providerOptions:je.optional()}),Re({type:xe("media"),data:se(),mediaType:se()}),Re({type:xe("file-data"),data:se(),mediaType:se(),filename:se().optional(),providerOptions:je.optional()}),Re({type:xe("file-url"),url:se(),providerOptions:je.optional()}),Re({type:xe("file-id"),fileId:ft([se(),Wr(se(),se())]),providerOptions:je.optional()}),Re({type:xe("image-data"),data:se(),mediaType:se(),providerOptions:je.optional()}),Re({type:xe("image-url"),url:se(),providerOptions:je.optional()}),Re({type:xe("image-file-id"),fileId:ft([se(),Wr(se(),se())]),providerOptions:je.optional()}),Re({type:xe("custom"),providerOptions:je.optional()})]))})]),Gh=Re({type:xe("tool-result"),toolCallId:se(),toolName:se(),output:mI,providerOptions:je.optional()}),gI=Re({type:xe("tool-approval-request"),approvalId:se(),toolCallId:se()}),xI=Re({type:xe("tool-approval-response"),approvalId:se(),approved:ut(),reason:se().optional()}),yI=Re({role:xe("system"),content:se(),providerOptions:je.optional()}),bI=Re({role:xe("user"),content:ft([se(),dr(ft([qh,fI,Wh]))]),providerOptions:je.optional()}),vI=Re({role:xe("assistant"),content:ft([se(),dr(ft([qh,Wh,pI,hI,Gh,gI]))]),providerOptions:je.optional()}),wI=Re({role:xe("tool"),content:dr(ft([Gh,xI])),providerOptions:je.optional()});ft([yI,bI,vI,wI]);function Kh(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const i=t[r];if(i===void 0)continue;const s=r in e?e[r]:void 0,a=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),o=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);a&&o?n[r]=Kh(s,i):n[r]=i}return n}var kI={};uI(kI,{array:()=>NI,choice:()=>CI,json:()=>EI,object:()=>jI,text:()=>_I});function SI(e){const t=["ROOT"];let n=-1,r=null;function i(l,c,f){switch(l){case'"':{n=c,t.pop(),t.push(f),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=c,r=c,t.pop(),t.push(f),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(f),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(f),t.push("INSIDE_NUMBER");break}case"{":{n=c,t.pop(),t.push(f),t.push("INSIDE_OBJECT_START");break}case"[":{n=c,t.pop(),t.push(f),t.push("INSIDE_ARRAY_START");break}}}function s(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}function a(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}for(let l=0;l<e.length;l++){const c=e[l];switch(t[t.length-1]){case"ROOT":i(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=l,t.pop();break}default:{n=l,i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(r,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(c,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(c,l)):n=l;break}}}let o=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const f=e.substring(r,e.length);"true".startsWith(f)?o+="true".slice(f.length):"false".startsWith(f)?o+="false".slice(f.length):"null".startsWith(f)&&(o+="null".slice(f.length))}}return o}async function ai(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Tn({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Tn({text:SI(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var _I=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),jI=({schema:e,name:t,description:n})=>{const r=Ro(e);return{name:"object",responseFormat:rn(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const a=await Tn({text:i});if(!a.success)throw new ln({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=await Kr({value:a.value,schema:r});if(!o.success)throw new ln({message:"No object generated: response did not match schema.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});return o.value},async parsePartialOutput({text:i}){const s=await ai(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},NI=({element:e,name:t,description:n})=>{const r=Ro(e);return{name:"array",responseFormat:rn(r.jsonSchema).then(i=>{const{$schema:s,...a}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:a}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},s){const a=await Tn({text:i});if(!a.success)throw new ln({message:"No object generated: could not parse the response.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const o=a.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new ln({message:"No object generated: response did not match schema.",cause:new ir({value:o,cause:"response must be an object with an elements array"}),text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const l of o.elements){const c=await Kr({value:l,schema:r});if(!c.success)throw new ln({message:"No object generated: response did not match schema.",cause:c.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason})}return o.elements},async parsePartialOutput({text:i}){const s=await ai(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=s.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))return;const o=s.state==="repaired-parse"&&a.elements.length>0?a.elements.slice(0,-1):a.elements,l=[];for(const c of o){const f=await Kr({value:c,schema:r});f.success&&l.push(f.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},a){if(s!=null)for(;i<s.length;i++)a.enqueue(s[i])}})}}},CI=({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 Tn({text:r});if(!s.success)throw new ln({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const a=s.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string"||!e.includes(a.result))throw new ln({message:"No object generated: response did not match schema.",cause:new ir({value:a,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return a.result},async parsePartialOutput({text:r}){const i=await ai(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=i.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string")return;const a=e.filter(o=>o.startsWith(s.result));return i.state==="successful-parse"?a.includes(s.result)?{partial:s.result}:void 0:a.length===1?{partial:a[0]}:void 0}}},createElementStreamTransform(){}}),EI=({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 Tn({text:n});if(!i.success)throw new ln({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 ai(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(){}});si({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
79
|
+
|
|
80
|
+
`)},flush(e){e.enqueue(`data: [DONE]
|
|
81
|
+
|
|
82
|
+
`)}})}});var II=tI(()=>Fh(ft([Ze({type:xe("text-start"),id:se(),providerMetadata:je.optional()}),Ze({type:xe("text-delta"),id:se(),delta:se(),providerMetadata:je.optional()}),Ze({type:xe("text-end"),id:se(),providerMetadata:je.optional()}),Ze({type:xe("error"),errorText:se()}),Ze({type:xe("tool-input-start"),toolCallId:se(),toolName:se(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),title:se().optional()}),Ze({type:xe("tool-input-delta"),toolCallId:se(),inputTextDelta:se()}),Ze({type:xe("tool-input-available"),toolCallId:se(),toolName:se(),input:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),title:se().optional()}),Ze({type:xe("tool-input-error"),toolCallId:se(),toolName:se(),input:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),errorText:se(),title:se().optional()}),Ze({type:xe("tool-approval-request"),approvalId:se(),toolCallId:se()}),Ze({type:xe("tool-output-available"),toolCallId:se(),output:Lt(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional(),preliminary:ut().optional()}),Ze({type:xe("tool-output-error"),toolCallId:se(),errorText:se(),providerExecuted:ut().optional(),providerMetadata:je.optional(),dynamic:ut().optional()}),Ze({type:xe("tool-output-denied"),toolCallId:se()}),Ze({type:xe("reasoning-start"),id:se(),providerMetadata:je.optional()}),Ze({type:xe("reasoning-delta"),id:se(),delta:se(),providerMetadata:je.optional()}),Ze({type:xe("reasoning-end"),id:se(),providerMetadata:je.optional()}),Ze({type:xe("source-url"),sourceId:se(),url:se(),title:se().optional(),providerMetadata:je.optional()}),Ze({type:xe("source-document"),sourceId:se(),mediaType:se(),title:se(),filename:se().optional(),providerMetadata:je.optional()}),Ze({type:xe("file"),url:se(),mediaType:se(),providerMetadata:je.optional()}),Ze({type:Oh(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:se().optional(),data:Lt(),transient:ut().optional()}),Ze({type:xe("start-step")}),Ze({type:xe("finish-step")}),Ze({type:xe("start"),messageId:se().optional(),messageMetadata:Lt().optional()}),Ze({type:xe("finish"),finishReason:Th(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Lt().optional()}),Ze({type:xe("abort"),reason:se().optional()}),Ze({type:xe("message-metadata"),messageMetadata:Lt()})])));function zI(e){return e.type.startsWith("data-")}function Fa(e){return e.type.startsWith("tool-")}function TI(e){return e.type==="dynamic-tool"}function es(e){return Fa(e)||TI(e)}function Hu(e){return e.type.split("-").slice(1).join("-")}function AI({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 PI({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:a}){return e.pipeThrough(new TransformStream({async transform(o,l){await r(async({state:c,write:f})=>{var d,p,h,m;function w(g){const E=c.message.parts.filter(es).find(k=>k.toolCallId===g);if(E==null)throw new Ln({chunkType:"tool-invocation",chunkId:g,message:`No tool invocation found for tool call ID "${g}".`});return E}function S(g){var z;const E=c.message.parts.find($=>Fa($)&&$.toolCallId===g.toolCallId),k=g,C=E;if(E!=null){E.state=g.state,C.input=k.input,C.output=k.output,C.errorText=k.errorText,C.rawInput=k.rawInput,C.preliminary=k.preliminary,g.title!==void 0&&(C.title=g.title),C.providerExecuted=(z=k.providerExecuted)!=null?z:E.providerExecuted;const $=k.providerMetadata;if($!=null)if(g.state==="output-available"||g.state==="output-error"){const K=E;K.resultProviderMetadata=$}else E.callProviderMetadata=$}else c.message.parts.push({type:`tool-${g.toolName}`,toolCallId:g.toolCallId,state:g.state,title:g.title,input:k.input,output:k.output,rawInput:k.rawInput,errorText:k.errorText,providerExecuted:k.providerExecuted,preliminary:k.preliminary,...k.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:k.providerMetadata}:{},...k.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:k.providerMetadata}:{}})}function x(g){var z,E;const k=c.message.parts.find(K=>K.type==="dynamic-tool"&&K.toolCallId===g.toolCallId),C=g,$=k;if(k!=null){k.state=g.state,$.toolName=g.toolName,$.input=C.input,$.output=C.output,$.errorText=C.errorText,$.rawInput=(z=C.rawInput)!=null?z:$.rawInput,$.preliminary=C.preliminary,g.title!==void 0&&($.title=g.title),$.providerExecuted=(E=C.providerExecuted)!=null?E:k.providerExecuted;const K=C.providerMetadata;if(K!=null)if(g.state==="output-available"||g.state==="output-error"){const N=k;N.resultProviderMetadata=K}else k.callProviderMetadata=K}else c.message.parts.push({type:"dynamic-tool",toolName:g.toolName,toolCallId:g.toolCallId,state:g.state,input:C.input,output:C.output,errorText:C.errorText,preliminary:C.preliminary,providerExecuted:C.providerExecuted,title:g.title,...C.providerMetadata!=null&&(g.state==="output-available"||g.state==="output-error")?{resultProviderMetadata:C.providerMetadata}:{},...C.providerMetadata!=null&&!(g.state==="output-available"||g.state==="output-error")?{callProviderMetadata:C.providerMetadata}:{}})}async function _(g){if(g!=null){const z=c.message.metadata!=null?Kh(c.message.metadata,g):g;t!=null&&await Ju({value:z,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=z}}switch(o.type){case"text-start":{const g={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeTextParts[o.id]=g,c.message.parts.push(g),f();break}case"text-delta":{const g=c.activeTextParts[o.id];if(g==null)throw new Ln({chunkType:"text-delta",chunkId:o.id,message:`Received text-delta for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});g.text+=o.delta,g.providerMetadata=(d=o.providerMetadata)!=null?d:g.providerMetadata,f();break}case"text-end":{const g=c.activeTextParts[o.id];if(g==null)throw new Ln({chunkType:"text-end",chunkId:o.id,message:`Received text-end for missing text part with ID "${o.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});g.state="done",g.providerMetadata=(p=o.providerMetadata)!=null?p:g.providerMetadata,delete c.activeTextParts[o.id],f();break}case"reasoning-start":{const g={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};c.activeReasoningParts[o.id]=g,c.message.parts.push(g),f();break}case"reasoning-delta":{const g=c.activeReasoningParts[o.id];if(g==null)throw new Ln({chunkType:"reasoning-delta",chunkId:o.id,message:`Received reasoning-delta for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});g.text+=o.delta,g.providerMetadata=(h=o.providerMetadata)!=null?h:g.providerMetadata,f();break}case"reasoning-end":{const g=c.activeReasoningParts[o.id];if(g==null)throw new Ln({chunkType:"reasoning-end",chunkId:o.id,message:`Received reasoning-end for missing reasoning part with ID "${o.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});g.providerMetadata=(m=o.providerMetadata)!=null?m:g.providerMetadata,g.state="done",delete c.activeReasoningParts[o.id],f();break}case"file":{c.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url,...o.providerMetadata!=null?{providerMetadata:o.providerMetadata}:{}}),f();break}case"source-url":{c.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),f();break}case"source-document":{c.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),f();break}case"tool-input-start":{const g=c.message.parts.filter(Fa);c.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:g.length,dynamic:o.dynamic,title:o.title},o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}):S({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title,providerMetadata:o.providerMetadata}),f();break}case"tool-input-delta":{const g=c.partialToolCalls[o.toolCallId];if(g==null)throw new Ln({chunkType:"tool-input-delta",chunkId:o.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${o.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});g.text+=o.inputTextDelta;const{value:z}=await ai(g.text);g.dynamic?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:z,title:g.title}):S({toolCallId:o.toolCallId,toolName:g.toolName,state:"input-streaming",input:z,title:g.title}),f();break}case"tool-input-available":{o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):S({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),f(),s&&!o.providerExecuted&&await s({toolCall:o});break}case"tool-input-error":{const g=c.message.parts.filter(es).find(E=>E.toolCallId===o.toolCallId);(g!=null?g.type==="dynamic-tool":!!o.dynamic)?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):S({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),f();break}case"tool-approval-request":{const g=w(o.toolCallId);g.state="approval-requested",g.approval={id:o.approvalId},f();break}case"tool-output-denied":{const g=w(o.toolCallId);g.state="output-denied",f();break}case"tool-output-available":{const g=w(o.toolCallId);g.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-available",input:g.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}):S({toolCallId:o.toolCallId,toolName:Hu(g),state:"output-available",input:g.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,providerMetadata:o.providerMetadata,title:g.title}),f();break}case"tool-output-error":{const g=w(o.toolCallId);g.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:g.toolName,state:"output-error",input:g.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}):S({toolCallId:o.toolCallId,toolName:Hu(g),state:"output-error",input:g.input,rawInput:g.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:g.title}),f();break}case"start-step":{c.message.parts.push({type:"step-start"});break}case"finish-step":{c.activeTextParts={},c.activeReasoningParts={};break}case"start":{o.messageId!=null&&(c.message.id=o.messageId),await _(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&f();break}case"finish":{o.finishReason!=null&&(c.finishReason=o.finishReason),await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"message-metadata":{await _(o.messageMetadata),o.messageMetadata!=null&&f();break}case"error":{i==null||i(new Error(o.errorText));break}default:if(zI(o)){if((n==null?void 0:n[o.type])!=null){const E=c.message.parts.findIndex(C=>"id"in C&&"data"in C&&C.id===o.id&&C.type===o.type),k=E>=0?E:c.message.parts.length;await Ju({value:o.data,schema:n[o.type],context:{field:`message.parts[${k}].data`,entityName:o.type,entityId:o.id}})}const g=o;if(g.transient){a==null||a(g);break}const z=g.id!=null?c.message.parts.find(E=>g.type===E.type&&g.id===E.id):void 0;z!=null?z.data=g.data:c.message.parts.push(g),a==null||a(g),f()}}l.enqueue(o)})}}))}async function OI({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()}}si({prefix:"aitxt",size:24});si({prefix:"aiobj",size:24});var DI=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()})}};si({prefix:"aiobj",size:24});async function RI(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,i=await new Promise((s,a)=>{const o=new FileReader;o.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},o.onerror=l=>a(l),o.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var MI=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var n,r,i,s,a;const o=await rn(this.body),l=await rn(this.headers),c=await rn(this.credentials),f={...Fn(l),...Fn(t.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...o,...t.body},headers:f,credentials:c,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),p=(r=d==null?void 0:d.api)!=null?r:this.api,h=(d==null?void 0:d.headers)!==void 0?Fn(d.headers):f,m=(d==null?void 0:d.body)!==void 0?d.body:{...o,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},w=(i=d==null?void 0:d.credentials)!=null?i:c,x=await((s=this.fetch)!=null?s:globalThis.fetch)(p,{method:"POST",headers:{"Content-Type":"application/json",...h},body:JSON.stringify(m),credentials:w,signal:e});if(!x.ok)throw new Error((a=await x.text())!=null?a:"Failed to fetch the chat response.");if(!x.body)throw new Error("The response body is empty.");return this.processResponseStream(x.body)}async reconnectToStream(e){var t,n,r,i,s;const a=await rn(this.body),o=await rn(this.headers),l=await rn(this.credentials),c={...Fn(o),...Fn(e.headers)},f=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:c,credentials:l,requestMetadata:e.metadata})),d=(n=f==null?void 0:f.api)!=null?n:`${this.api}/${e.chatId}/stream`,p=(f==null?void 0:f.headers)!==void 0?Fn(f.headers):c,h=(r=f==null?void 0:f.credentials)!=null?r:l,w=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:p,credentials:h});if(w.status===204)return null;if(!w.ok)throw new Error((s=await w.text())!=null?s:"Failed to fetch the chat response.");if(!w.body)throw new Error("The response body is empty.");return this.processResponseStream(w.body)}},Yh=class extends MI{constructor(e={}){super(e)}processResponseStream(e){return oI({stream:e,schema:II}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},$I=class{constructor({generateId:e=cE,id:t=e(),transport:n=new Yh,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:a,onToolCall:o,onFinish:l,onData:c,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new DI,this.sendMessage=async(d,p)=>{var h,m,w,S;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...p});return}let x;if("text"in d||"files"in d?x={parts:[...Array.isArray(d.files)?d.files:await RI(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:x=d,d.messageId!=null){const _=this.state.messages.findIndex(g=>g.id===d.messageId);if(_===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[_].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,_+1),this.state.replaceMessage(_,{...x,id:d.messageId,role:(m=x.role)!=null?m:"user",metadata:d.metadata})}else this.state.pushMessage({...x,id:(w=x.id)!=null?w:this.generateId(),role:(S=x.role)!=null?S:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...p})},this.regenerate=async({messageId:d,...p}={})=>{const h=d==null?this.state.messages.length-1:this.state.messages.findIndex(m=>m.id===d);if(h===-1)throw new Error(`message ${d} 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:d,...p})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:p,reason:h,options:m})=>this.jobExecutor.run(async()=>{const w=this.state.messages,S=w[w.length-1],x=_=>es(_)&&_.state==="approval-requested"&&_.approval.id===d?{..._,state:"approval-responded",approval:{id:d,approved:p,reason:h}}:_;this.state.replaceMessage(w.length-1,{...S,parts:S.parts.map(x)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(x)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(_=>{var g;_&&this.makeRequest({trigger:"submit-message",messageId:(g=this.lastMessage)==null?void 0:g.id,...m})})}),this.addToolOutput=async({state:d="output-available",toolCallId:p,output:h,errorText:m,options:w})=>this.jobExecutor.run(async()=>{const S=this.state.messages,x=S[S.length-1],_=g=>es(g)&&g.toolCallId===p?{...g,state:d,output:h,errorText:m}:g;this.state.replaceMessage(S.length-1,{...x,parts:x.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(g=>{var z;g&&this.makeRequest({trigger:"submit-message",messageId:(z=this.lastMessage)==null?void 0:z.id,...w})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=o,this.onFinish=l,this.onData=c,this.sendAutomaticallyWhen=f}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var s,a,o;let l;if(e==="resume-stream")try{const 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 f=!1,d=!1,p=!1;try{const h={state:AI({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=h;let m;e==="resume-stream"?m=l:m=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 w=S=>this.jobExecutor.run(()=>S({state:h.state,write:()=>{var x;this.setStatus({status:"streaming"}),h.state.message.id===((x=this.lastMessage)==null?void 0:x.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await OI({stream:PI({stream:m,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:w,onError:S=>{throw S}}),onError:S=>{throw S}}),this.setStatus({status:"ready"})}catch(h){if(f||h.name==="AbortError")return f=!0,this.setStatus({status:"ready"}),null;p=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:f,isDisconnect:d,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:(o=this.lastMessage)==null?void 0:o.id,metadata:t,headers:n,body:r})}},oa,qu;function FI(){if(qu)return oa;qu=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let r,i=0;return function(...a){clearTimeout(r);const o=Date.now(),l=o-i,c=n-l;c<=0?(i=o,t.apply(this,a)):r=setTimeout(()=>{i=Date.now(),t.apply(this,a)},c)}}return oa=e,oa}var LI=FI();const ZI=Ua(LI);var Xh=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Be=(e,t,n)=>(Xh(e,t,"read from private field"),n?n.call(e):t.get(e)),$t=(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)},nn=(e,t,n,r)=>(Xh(e,t,"write to private field"),t.set(e,n),n);function BI(e,t){return t!=null?ZI(e,t):e}var Nt,Ci,Ei,Cr,Er,Ir,Un,La,Za,VI=class{constructor(e=[]){$t(this,Nt,void 0),$t(this,Ci,"ready"),$t(this,Ei,void 0),$t(this,Cr,new Set),$t(this,Er,new Set),$t(this,Ir,new Set),this.pushMessage=t=>{nn(this,Nt,Be(this,Nt).concat(t)),Be(this,Un).call(this)},this.popMessage=()=>{nn(this,Nt,Be(this,Nt).slice(0,-1)),Be(this,Un).call(this)},this.replaceMessage=(t,n)=>{nn(this,Nt,[...Be(this,Nt).slice(0,t),this.snapshot(n),...Be(this,Nt).slice(t+1)]),Be(this,Un).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?BI(t,n):t;return Be(this,Cr).add(r),()=>{Be(this,Cr).delete(r)}},this["~registerStatusCallback"]=t=>(Be(this,Er).add(t),()=>{Be(this,Er).delete(t)}),this["~registerErrorCallback"]=t=>(Be(this,Ir).add(t),()=>{Be(this,Ir).delete(t)}),$t(this,Un,()=>{Be(this,Cr).forEach(t=>t())}),$t(this,La,()=>{Be(this,Er).forEach(t=>t())}),$t(this,Za,()=>{Be(this,Ir).forEach(t=>t())}),nn(this,Nt,e)}get status(){return Be(this,Ci)}set status(e){nn(this,Ci,e),Be(this,La).call(this)}get error(){return Be(this,Ei)}set error(e){nn(this,Ei,e),Be(this,Za).call(this)}get messages(){return Be(this,Nt)}set messages(e){nn(this,Nt,[...e]),Be(this,Un).call(this)}};Nt=new WeakMap;Ci=new WeakMap;Ei=new WeakMap;Cr=new WeakMap;Er=new WeakMap;Ir=new WeakMap;Un=new WeakMap;La=new WeakMap;Za=new WeakMap;var Jn,Wu=class extends $I{constructor({messages:e,...t}){const n=new VI(e);super({...t,state:n}),$t(this,Jn,void 0),this["~registerMessagesCallback"]=(r,i)=>Be(this,Jn)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Be(this,Jn)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Be(this,Jn)["~registerErrorCallback"](r),nn(this,Jn,n)}};Jn=new WeakMap;function UI({experimental_throttle:e,resume:t=!1,...n}={}){const r=y.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,m;return(m=(h=r.current).onToolCall)==null?void 0:m.call(h,p)},onData:p=>{var h,m;return(m=(h=r.current).onData)==null?void 0:m.call(h,p)},onFinish:p=>{var h,m;return(m=(h=r.current).onFinish)==null?void 0:m.call(h,p)},onError:p=>{var h,m;return(m=(h=r.current).onError)==null?void 0:m.call(h,p)},sendAutomaticallyWhen:p=>{var h,m,w;return(w=(m=(h=r.current).sendAutomaticallyWhen)==null?void 0:m.call(h,p))!=null?w:!1}},s=y.useRef("chat"in n?n.chat:new Wu(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new Wu(i));const o=y.useCallback(p=>s.current["~registerMessagesCallback"](p,e),[e,s.current.id]),l=y.useSyncExternalStore(o,()=>s.current.messages,()=>s.current.messages),c=y.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),f=y.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),d=y.useCallback(p=>{typeof p=="function"&&(p=p(s.current.messages)),s.current.messages=p},[s]);return y.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:l,setMessages:d,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:f,resumeStream:s.current.resumeStream,status:c,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function Qh(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 em(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 tm(e,t,n){if(!(n!=null&&n.selectedText)){const i=JI(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const o=e.indexOf(i,s+1);let l;if(o===-1)l=s;else if(n.startLine&&n.startLine>0){const d=YI(e,n.startLine);l=XI(e,i,d)}else l=s;const c=e.slice(0,l),f=e.slice(l+i.length);return{original:e,modified:c+t+f}}if(n.startLine&&n.endLine){const o=GI(e,t,n.startLine,n.endLine);if(o)return o}const a=Gu(e,t);return a||{original:e,modified:t}}const r=Gu(e,t);return r||{original:e,modified:t}}function JI(e,t){let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n.name;if(typeof r!="string"||!r)return null;let i;try{i=JSON.parse(e)}catch{return null}const s=e.match(/\n(\s+)"/),a=s?s[1].length:2;if(!Ba(i,r,n))return null;const o=JSON.stringify(i,null,a);return{original:e,modified:o}}function Ba(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(Ba(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(Ba(r,t,n))return!0}return!1}function Gu(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)){const o=Object.keys(s).sort().join(","),l=Object.keys(a).sort().join(",");if(o===l)return null}}catch{}}catch{}const n=HI(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const a=qI(r,t,s);a&&(r=a,i=!0)}return i?{original:e,modified:r}:null}function HI(e){const t=[],n=e.split(`
|
|
83
|
+
`),r=n.find(s=>s.trim().length>0);if(!r)return t;const i=r.search(/\S/);for(const s of n){const a=s.search(/\S/);if(a<0||a!==i)continue;const o=s.match(/^\s*"([^"]+)"\s*:/);o&&t.push(o[1])}return[...new Set(t)]}function qI(e,t,n){const r=`"${n}"`,i=Ku(e,r);if(i.length===0)return null;const s=Ku(t,r);if(s.length===0)return null;const a=s[0],o=t.slice(a.start,a.end);let l=0;if(i.length>1){let f=-1;for(let d=0;d<i.length;d++){const p=e.slice(i[d].start,i[d].end),h=KI(p,o);h>f&&(f=h,l=d)}}const c=i[l];return e.slice(0,c.start)+o+e.slice(c.end)}function Ku(e,t){const n=[];let r=0;for(;;){const i=e.indexOf(t,r);if(i===-1)break;let s=i-1;for(;s>=0&&(e[s]===" "||e[s]===" ");)s--;const a=s<0?"":e[s];if(a!==""&&a!=="{"&&a!==","&&a!==`
|
|
84
|
+
`&&a!=="\r"){r=i+1;continue}const o=e.indexOf(":",i+t.length);if(o===-1){r=i+1;continue}const l=o+1,c=WI(e,l);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function WI(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return-1;const n=e[t];if(n==='"'){let i=t+1;for(;i<e.length;){if(e[i]==="\\"){i+=2;continue}if(e[i]==='"')return i+1;i++}return-1}if(n==="["||n==="{"){const i=n,s=n==="["?"]":"}";let a=1,o=t+1,l=!1;for(;o<e.length&&a>0;){if(e[o]==="\\"&&l){o+=2;continue}e[o]==='"'&&(l=!l),l||(e[o]===i?a++:e[o]===s&&a--),o++}return a===0?o:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function GI(e,t,n,r){const i=e.split(`
|
|
85
|
+
`);if(n<1||r<n||n>i.length)return null;const s=i.slice(0,n-1).join(`
|
|
86
|
+
`),a=i.slice(r).join(`
|
|
87
|
+
`),o=s+(s?`
|
|
88
|
+
`:"")+t+(a?`
|
|
89
|
+
`:"")+a;return{original:e,modified:o}}function KI(e,t){if(e===t)return 1;if(!e.length||!t.length)return 0;const n=3,r=new Set;for(let a=0;a<=e.length-n;a++)r.add(e.slice(a,a+n));let i=0;for(let a=0;a<=t.length-n;a++)r.has(t.slice(a,a+n))&&i++;const s=Math.max(e.length-n+1,t.length-n+1);return s>0?i/s:0}function YI(e,t){let n=0;const r=e.split(`
|
|
90
|
+
`);for(let i=0;i<Math.min(t-1,r.length);i++)n+=r[i].length+1;return n}function XI(e,t,n){let r=-1,i=1/0,s=e.indexOf(t);for(;s!==-1;){const a=Math.abs(s-n);a<i&&(i=a,r=s),s=e.indexOf(t,s+1)}return r}function QI(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(`
|
|
91
|
+
`);try{return JSON.parse(n),n}catch{}}return null}function ez(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=Qh(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function tz(){const e=Te(J=>J.threads),t=Te(J=>J.activeThreadId),n=Te(J=>J.updateThreadMessages),r=Te(J=>J.updateThreadTitle),i=Te(J=>J.clearContext),s=Te(J=>J.contextAttachments),a=Te(J=>J.scope),o=Te(J=>J.model),l=Ae(J=>J.activeTab),c=Ae(J=>J.documents),f=Ae(J=>J.documentTypes),d=Ae(J=>J.setPendingDiff),p=Ae(J=>J.createDocument),h=Ae(J=>J.openDocument),m=y.useRef(e);m.current=e;const w=y.useRef(l);w.current=l;const S=y.useRef(c);S.current=c;const x=y.useRef(f);x.current=f;const _=y.useRef(t);_.current=t;const g=l?t[l]:void 0,z=y.useRef(g);z.current=g;const E=y.useRef([]),k=y.useRef([]),C=y.useRef({}),$=y.useRef({}),[,K]=y.useState(0),N=y.useCallback(()=>K(J=>J+1),[]),I=y.useRef(null);I.current||(I.current=new Yh({api:"/api/ai/chat"}));const A=y.useCallback(()=>{const J=S.current.find(R=>R.name===w.current);return J?{name:J.name,text:J.text}:void 0},[]),B=y.useCallback(J=>C.current[J]||[],[]),D=UI({transport:I.current,onError:()=>{E.current.shift(),k.current.shift(),i()},onFinish:({messages:J})=>{var Y,oe;const R=z.current;if(R){n(R,J);const ne=m.current[R];if(ne&&ne.title.startsWith("Chat ")){const ie=J.find(W=>W.role==="user");if(ie){const W=((Y=ie.parts)==null?void 0:Y.filter(F=>F.type==="text").map(F=>F.text).join(""))||"";if(W){const F=W.length>50?W.slice(0,50)+"...":W;r(R,F)}}}}const q=E.current.shift()||[],v=k.current.shift()||"global",fe=J.filter(ne=>ne.role==="user"),ue=fe[fe.length-1];ue!=null&&ue.id&&(C.current[ue.id]=q,$.current[ue.id]=v);const b=J.filter(ne=>ne.role==="assistant").pop();if(b){const ie=[...(((oe=b.parts)==null?void 0:oe.filter(W=>W.type==="text").map(W=>W.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(ie.length>0){const W=QI(ie);if(W){const F=ie[ie.length-1][1],te=w.current;if(te){const V=S.current.find(Qe=>Qe.name===te),de=(V==null?void 0:V.text)||"",le=q[0],ye=ez(de,W,v);!ye&&v!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${v}", falling back to text merge`);const{original:Oe,modified:qe}=ye??tm(de,W,le);d(te,Oe,qe,em(F.replace(/\n$/,"")))}else{const V=`ai-generated-${Date.now()}`;p(V,W),h(V)}}}}i()}});y.useEffect(()=>{const J=D.messages.filter(R=>R.role==="user");for(let R=J.length-1;R>=0;R--){const q=J[R].id;if(q in C.current)break;E.current.length>0&&(C.current[q]=E.current[0],$.current[q]=k.current[0]||"global",N());break}},[D.messages,N]);const T=y.useCallback((J,R)=>{E.current.push([...s]),k.current.push(a),i();const q={text:J};R!=null&&R.length&&(q.files=R),D.sendMessage(q,{body:{format:yt,context:s,activeDocument:A(),documentType:w.current&&x.current[w.current]||"application/json+report",scope:a,model:o}})},[D.sendMessage,s,A,i,a,o]),P=y.useCallback(J=>$.current[J],[]);return{messages:D.messages,sendMessage:T,status:D.status,error:D.error,setMessages:D.setMessages,stop:D.stop,getMessageContext:B,getMessageScope:P}}const nm=y.createContext(null);function nz({children:e}){const t=tz();return u.jsx(nm.Provider,{value:t,children:e})}function rz(){const e=y.useContext(nm);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function iz(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 sz(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function rm({context:e,onRemove:t,variant:n="default"}){var c;const r=iz(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,a=sz(e.selectedText),o=n==="sent",l=u.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md border pl-2 ${t?"pr-1":"pr-2"} py-1 text-xs max-w-[280px] transition-colors ${o?"border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/20":"border-primary/20 bg-primary/5 hover:bg-primary/10"}`,children:[u.jsx(ug,{className:`h-3 w-3 shrink-0 ${o?"text-primary-foreground/60":"text-primary/60"}`}),u.jsx("span",{className:"truncate font-medium",children:s}),t&&u.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-opacity cursor-pointer","aria-label":"Remove context",children:u.jsx(Nn,{className:"h-3 w-3"})})]});return u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:l}),u.jsxs(Ke,{side:"top",className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),u.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:a}),e.jsonPath&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Zn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const im=32,az=10,sm=9,am=13,oz=160,lz=6158,uz=8192,cz=8203,dz=8239,fz=8287,pz=12288,hz=65279;function mz(e){return/^[0-9A-Fa-f]$/.test(e)}function bn(e){return e>="0"&&e<="9"}function gz(e){return e>=" "}function bi(e){return`,:[]/{}()
|
|
92
|
+
+`.includes(e)}function Yu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function Xu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const Qu=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,ec=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function tc(e){return`,[]/{}
|
|
93
|
+
+`.includes(e)}function nc(e){return Ii(e)||xz.test(e)}const xz=/^[[{\w-]$/;function yz(e){return e===`
|
|
94
|
+
`||e==="\r"||e===" "||e==="\b"||e==="\f"}function wn(e,t){const n=e.charCodeAt(t);return n===im||n===az||n===sm||n===am}function bz(e,t){const n=e.charCodeAt(t);return n===im||n===sm||n===am}function vz(e,t){const n=e.charCodeAt(t);return n===oz||n===lz||n>=uz&&n<=cz||n===dz||n===fz||n===pz||n===hz}function Ii(e){return om(e)||Va(e)}function om(e){return e==='"'||e==="“"||e==="”"}function rc(e){return e==='"'}function Va(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function ic(e){return e==="'"}function wr(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 Pt(e,t){let n=e.length;if(!wn(e,n-1))return e+t;for(;wn(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function wz(e,t,n){return e.substring(0,t)+e.substring(t+n)}function kz(e){return/[,\n][ \t\r]*$/.test(e)}const Sz={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},_z={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
95
|
+
`,r:"\r",t:" "};function sc(e){let t=0,n="";c(["```","[```","{```"]),s()||D(),c(["```","```]","```}"]);const i=d(",");for(i&&a(),nc(e[t])&&kz(n)?(i||(n=Pt(n,",")),x()):i&&(n=wr(n,","));e[t]==="}"||e[t]==="]";)t++,a();if(t>=e.length)return n;B();function s(){a();const R=w()||S()||_()||z()||E()||C(!1)||$();return a(),R}function a(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const q=t;let v=o(R);do v=l(),v&&(v=o(R));while(v);return t>q}function o(R){const q=R?wn:bz;let v="";for(;;)if(q(e,t))v+=e[t],t++;else if(vz(e,t))v+=" ",t++;else break;return v.length>0?(n+=v,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!jz(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
96
|
+
`;)t++;return!0}return!1}function c(R){if(f(R)){if(Yu(e[t]))for(;t<e.length&&Xu(e[t]);)t++;return a(),!0}return!1}function f(R){o(!0);for(const q of R){const v=t+q.length;if(e.slice(t,v)===q)return t=v,!0}return!1}function d(R){return e[t]===R?(n+=e[t],t++,!0):!1}function p(R){return e[t]===R?(t++,!0):!1}function h(){return p("\\")}function m(){return a(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,a(),p(","),!0):!1}function w(){if(e[t]==="{"){n+="{",t++,a(),p(",")&&a();let R=!0;for(;t<e.length&&e[t]!=="}";){let q;if(R?(q=!0,R=!1):(q=d(","),q||(n=Pt(n,",")),a()),m(),!(_()||C(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=wr(n,","):T();break}a();const fe=d(":"),ue=t>=e.length;fe||(nc(e[t])||ue?n=Pt(n,":"):P()),s()||(fe||ue?n+="null":P())}return e[t]==="}"?(n+="}",t++):n=Pt(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,a(),p(",")&&a();let R=!0;for(;t<e.length&&e[t]!=="]";)if(R?R=!1:d(",")||(n=Pt(n,",")),m(),!s()){n=wr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Pt(n,"]"),!0}return!1}function x(){let R=!0,q=!0;for(;q;)R?R=!1:d(",")||(n=Pt(n,",")),q=s();q||(n=wr(n,",")),n=`[
|
|
97
|
+
${n}
|
|
98
|
+
]`}function _(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,v=e[t]==="\\";if(v&&(t++,v=!0),Ii(e[t])){const fe=rc(e[t])?rc:ic(e[t])?ic:Va(e[t])?Va:om,ue=t,b=n.length;let Y='"';for(t++;;){if(t>=e.length){const oe=K(t-1);return!R&&bi(e.charAt(oe))?(t=ue,n=n.substring(0,b),_(!0)):(Y=Pt(Y,'"'),n+=Y,!0)}if(t===q)return Y=Pt(Y,'"'),n+=Y,!0;if(fe(e[t])){const oe=t,ne=Y.length;if(Y+='"',t++,n+=Y,a(!1),R||t>=e.length||bi(e[t])||Ii(e[t])||bn(e[t]))return g(),!0;const ie=K(oe-1),W=e.charAt(ie);if(W===",")return t=ue,n=n.substring(0,b),_(!1,ie);if(bi(W))return t=ue,n=n.substring(0,b),_(!0);n=n.substring(0,b),t=oe+1,Y=`${Y.substring(0,ne)}\\${Y.substring(ne)}`}else if(R&&tc(e[t])){if(e[t-1]===":"&&Qu.test(e.substring(ue+1,t+2)))for(;t<e.length&&ec.test(e[t]);)Y+=e[t],t++;return Y=Pt(Y,'"'),n+=Y,g(),!0}else if(e[t]==="\\"){const oe=e.charAt(t+1);if(_z[oe]!==void 0)Y+=e.slice(t,t+2),t+=2;else if(oe==="u"){let ie=2;for(;ie<6&&mz(e[t+ie]);)ie++;ie===6?(Y+=e.slice(t,t+6),t+=6):t+ie>=e.length?t=e.length:J()}else Y+=oe,t+=2}else{const oe=e.charAt(t);oe==='"'&&e[t-1]!=="\\"?(Y+=`\\${oe}`,t++):yz(oe)?(Y+=Sz[oe],t++):(gz(oe)||A(oe),Y+=oe,t++)}v&&h()}}return!1}function g(){let R=!1;for(a();e[t]==="+";){R=!0,t++,a(),n=wr(n,'"',!0);const q=n.length;_()?n=wz(n,q,1):n=Pt(n,'"')}return R}function z(){const R=t;if(e[t]==="-"){if(t++,N())return I(R),!0;if(!bn(e[t]))return t=R,!1}for(;bn(e[t]);)t++;if(e[t]==="."){if(t++,N())return I(R),!0;if(!bn(e[t]))return t=R,!1;for(;bn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,N())return I(R),!0;if(!bn(e[t]))return t=R,!1;for(;bn(e[t]);)t++}if(!N())return t=R,!1;if(t>R){const q=e.slice(R,t),v=/^0\d/.test(q);return n+=v?`"${q}"`:q,!0}return!1}function E(){return k("true","true")||k("false","false")||k("null","null")||k("True","true")||k("False","false")||k("None","null")}function k(R,q){return e.slice(t,t+R.length)===R?(n+=q,t+=R.length,!0):!1}function C(R){const q=t;if(Yu(e[t])){for(;t<e.length&&Xu(e[t]);)t++;let v=t;for(;wn(e,v);)v++;if(e[v]==="(")return t=v+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!tc(e[t])&&!Ii(e[t])&&(!R||e[t]!==":");)t++;if(e[t-1]===":"&&Qu.test(e.substring(q,t+2)))for(;t<e.length&&ec.test(e[t]);)t++;if(t>q){for(;wn(e,t-1)&&t>0;)t--;const v=e.slice(q,t);return n+=v==="undefined"?"null":JSON.stringify(v),e[t]==='"'&&t++,!0}}function $(){if(e[t]==="/"){const R=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring(R,t)),!0}}function K(R){let q=R;for(;q>0&&wn(e,q);)q--;return q}function N(){return t>=e.length||bi(e[t])||wn(e,t)}function I(R){n+=`${e.slice(R,t)}0`}function A(R){throw new Zn(`Invalid character ${JSON.stringify(R)}`,t)}function B(){throw new Zn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function D(){throw new Zn("Unexpected end of json string",e.length)}function T(){throw new Zn("Object key expected",t)}function P(){throw new Zn("Colon expected",t)}function J(){const R=e.slice(t,t+6);throw new Zn(`Invalid unicode character "${R}"`,t)}}function jz(e,t){return e[t]==="*"&&e[t+1]==="/"}function Nz({json:e,context:t,scope:n}){const[r,i]=y.useState(!1),[s,a]=y.useState(null),o=y.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return sc(e)}catch{}const x=`{${e}}`;try{return JSON.parse(x),x}catch{}try{return sc(x)}catch{return null}},[e]),l=y.useMemo(()=>em(o||e),[o,e]),c=Ae(x=>x.activeTab),f=Ae(x=>x.documents),d=Ae(x=>(x.acceptedApplyIds||[]).includes(l)),p=Ae(x=>x.setPendingDiff),h=Ae(x=>x.createDocument),m=Ae(x=>x.openDocument),w=y.useCallback(()=>{if(o){a(null);try{if(c){const x=f.find(k=>k.name===c),_=(x==null?void 0:x.text)||"";if(n==="templates")try{const k=JSON.parse(_),C=JSON.parse(o);if(Array.isArray(C.templates)){k.props||(k.props={}),k.props.templates=Qh(k.props.templates||[],C.templates);const $=JSON.stringify(k,null,2);p(c,_,$,l);return}}catch{}const g=t==null?void 0:t[0],{original:z,modified:E}=tm(_,o,g);p(c,z,E,l)}else{const x=`ai-generated-${Date.now()}`;h(x,o),m(x)}}catch(x){a(x instanceof Error?x.message:"Merge failed")}}},[o,c,f,p,h,m,t,n,l]),S=y.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(we,{variant:"secondary",size:"sm",onClick:w,disabled:d||!o,children:d?"Applied":o?"Apply to Editor":"Invalid JSON"}),u.jsx(we,{variant:"ghost",size:"sm",onClick:S,children:r?u.jsx(un,{className:"h-3.5 w-3.5"}):u.jsx(as,{className:"h-3.5 w-3.5"})})]}),s&&u.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function Cz({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:a}){const[o,l]=y.useState(null),[c,f]=y.useState(""),[d,p]=y.useState(null),h=y.useRef(null),m=(t==null?void 0:t.title)||"New Chat",w=m.length>24?m.slice(0,24)+"...":m;y.useEffect(()=>{o&&requestAnimationFrame(()=>{var C;return(C=h.current)==null?void 0:C.focus()})},[o]);const S=y.useCallback((C,$)=>{$.stopPropagation(),$.preventDefault(),l(C.id),f(C.title),p(null)},[]),x=y.useCallback(()=>{o&&c.trim()&&a(o,c.trim()),l(null),f("")},[o,c,a]),_=y.useCallback(()=>{l(null),f("")},[]),g=y.useCallback(C=>{C.stopPropagation(),C.key==="Enter"?(C.preventDefault(),x()):C.key==="Escape"&&(C.preventDefault(),_())},[x,_]),z=y.useCallback((C,$)=>{$.stopPropagation(),$.preventDefault(),p(C),l(null)},[]),E=y.useCallback(C=>{C.stopPropagation(),C.preventDefault(),d&&(s(d),p(null))},[d,s]),k=y.useCallback(C=>{C.stopPropagation(),C.preventDefault(),p(null)},[]);return u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(to,{onOpenChange:C=>{C||(l(null),p(null))},children:[u.jsx(no,{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:w}),u.jsx(on,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),u.jsxs(ds,{align:"start",className:"w-64",children:[e.map(C=>{const $=o===C.id;return d===C.id?u.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[u.jsx("span",{className:"text-red-400 text-xs flex-1 truncate",children:"Delete this thread?"}),u.jsx("button",{className:"shrink-0 text-red-400 hover:text-red-300 transition-colors cursor-pointer",onClick:E,children:u.jsx(un,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:k,children:u.jsx(Nn,{className:"h-3.5 w-3.5"})})]},C.id):$?u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:N=>N.stopPropagation(),onPointerDown:N=>N.stopPropagation(),children:[u.jsx("input",{ref:h,type:"text",value:c,onChange:N=>f(N.target.value),onKeyDown:g,onBlur:x,className:"flex-1 min-w-0 text-sm rounded 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:N=>{N.preventDefault(),x()},children:u.jsx(un,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:N=>{N.preventDefault(),_()},children:u.jsx(Nn,{className:"h-3.5 w-3.5"})})]},C.id):u.jsxs(Kt,{onSelect:()=>r(C.id),className:`group ${C.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[u.jsx("span",{className:"truncate flex-1",children:C.title.length>30?C.title.slice(0,30)+"...":C.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:N=>S(C,N),children:u.jsx(cg,{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:N=>z(C.id,N),children:u.jsx(Ha,{className:"h-3 w-3"})})]})]},C.id)}),u.jsx(Fr,{}),u.jsxs(Kt,{onSelect:C=>{C.preventDefault();const $=i();$&&(l($),f(Xa()),p(null))},children:[u.jsx(zi,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),u.jsx(we,{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(zi,{className:"h-3.5 w-3.5"})})]})}const lm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),Ez=Array.from(lm).join(","),Iz=20*1024*1024,ac=10;function zz(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 oc(e){return Array.from(e).filter(t=>lm.has(t.type)&&t.size<=Iz)}function um(e){return e.startsWith("image/")}function lc(){var G,he,Se;const e=Te(M=>M.contextAttachments),t=Te(M=>M.addContext),n=Te(M=>M.removeContext),r=Te(M=>M.scope),i=Te(M=>M.setScope),s=Te(M=>M.model),a=Te(M=>M.setModel),o=Te(M=>M.openChat),l=Te(M=>M.closeChat),c=Te(M=>M.threads),f=Te(M=>M.activeThreadId),d=Te(M=>M.createThread),p=Te(M=>M.deleteThread),h=Te(M=>M.switchThread),m=Te(M=>M.updateThreadMessages),w=Te(M=>M.updateThreadTitle),S=Te(M=>M.deleteThreadsForDocument),x=Ae(M=>M.activeTab),_=Ae(M=>M.documents),{messages:g,sendMessage:z,status:E,error:k,setMessages:C,stop:$,getMessageContext:K,getMessageScope:N}=rz(),[I,A]=y.useState(""),[B,D]=y.useState([]),[T,P]=y.useState(!1),[J,R]=y.useState(!1),q=y.useRef(null),v=y.useRef(null),fe=y.useRef(null),ue=y.useCallback(async M=>{const me=oc(M);if(me.length===0)return;const Ce=await Promise.all(me.map(zz));D($e=>{const nt=[...$e,...Ce];return nt.length>ac?nt.slice(0,ac):nt})},[]),b=y.useCallback(M=>{D(me=>me.filter((Ce,$e)=>$e!==M))},[]),Y=y.useCallback(M=>{var Ce;const me=(Ce=M.clipboardData)==null?void 0:Ce.files;if(me&&me.length>0){const $e=oc(me);$e.length>0&&(M.preventDefault(),ue($e))}},[ue]),oe=y.useCallback(M=>{var Ce;M.preventDefault(),R(!1);const me=(Ce=M.dataTransfer)==null?void 0:Ce.files;me&&me.length>0&&ue(Array.from(me))},[ue]),ne=y.useCallback(M=>{M.preventDefault(),R(!0)},[]),ie=y.useCallback(()=>R(!1),[]),W=x?f[x]:void 0,F=W?c[W]:void 0,te=y.useMemo(()=>x?Object.values(c).filter(M=>M.documentName===x).sort((M,me)=>me.updatedAt-M.updatedAt):[],[c,x]);y.useEffect(()=>{x&&te.length===0&&d(x)},[x,te.length,d]);const V=y.useRef(c);V.current=c,y.useEffect(()=>{const M=new Set(_.map(Ce=>Ce.name)),me=new Set;for(const Ce of Object.values(V.current))!M.has(Ce.documentName)&&Ce.documentName!=="__migrated__"&&me.add(Ce.documentName);for(const Ce of me)S(Ce)},[_,S]);const de=y.useRef(null);y.useEffect(()=>{de.current!==W&&(de.current=W,C((F==null?void 0:F.messages)??[]))},[W,F,C]),y.useEffect(()=>{var M;(M=q.current)==null||M.scrollIntoView({behavior:"smooth"})},[g,E]),y.useEffect(()=>{const M=me=>{var nt;const{documentName:Ce,selection:$e}=me.detail;t({...$e,documentName:Ce}),o(),(nt=v.current)==null||nt.focus()};return window.addEventListener("monaco-selection-to-ai",M),()=>window.removeEventListener("monaco-selection-to-ai",M)},[t,o]);const le=E==="streaming",ye=E==="submitted"||le,Oe=y.useCallback(M=>{M.preventDefault(),!(!I.trim()&&B.length===0||ye)&&(z(I,B.length>0?B:void 0),A(""),D([]))},[I,B,ye,z]),qe=y.useCallback(M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),Oe(M))},[Oe]),Qe=y.useCallback(()=>{g.length!==0&&P(!0)},[g.length]),j=y.useCallback(()=>{P(!1),C([]),W&&(m(W,[]),w(W,Xa()))},[C,W,m,w]),[O,Z]=y.useState(null),re=y.useCallback(M=>{Z(M)},[]),ee=y.useCallback(()=>{var nt,et;if(!O)return;const M=g.findIndex(it=>it.id===O);if(M===-1){Z(null);return}const me=g[M],Ce=new Set([M]);me.role==="user"&&((nt=g[M+1])==null?void 0:nt.role)==="assistant"?Ce.add(M+1):me.role==="assistant"&&M>0&&((et=g[M-1])==null?void 0:et.role)==="user"&&Ce.add(M-1);const $e=g.filter((it,en)=>!Ce.has(en));C($e),W&&m(W,$e),Z(null)},[O,g,C,W,m]),Q=y.useCallback(M=>{if(!ye){if(te.length<=1){Qe();return}p(M)}},[ye,te.length,Qe,p]),pe=y.useCallback(()=>{if(!(!x||ye))return d(x)},[x,ye,d]),ve=y.useCallback(M=>{ye||M===W||h(M)},[ye,W,h]),L=y.useCallback((M,me)=>{w(M,me)},[w]);return u.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[u.jsx(Cz,{threads:te,activeThread:F,disabled:ye,onSwitch:ve,onCreate:pe,onDelete:Q,onRename:L}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(we,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:Qe,disabled:ye||g.length===0,children:"Clear"}),u.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:u.jsx(Nn,{className:"h-3.5 w-3.5"})})]})]}),u.jsx($r,{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:[g.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(Zo,{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(wa,{shortcut:"mod+k"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),g.map((M,me)=>{let Ce;if(M.role==="user"){const et=K(M.id);et&&et.length>0&&(Ce=et)}else if(M.role==="assistant"){for(let et=me-1;et>=0;et--)if(g[et].role==="user"){Ce=K(g[et].id);break}}const $e=le&&me===g.length-1&&M.role==="assistant",nt=M.role==="user"?N(M.id):void 0;return u.jsx(Tz,{msg:M,isStreaming:$e,context:Ce,scope:nt,onDelete:ye?void 0:re},M.id)}),ye&&((G=g[g.length-1])==null?void 0:G.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(ua,{className:"h-3.5 w-3.5 animate-spin text-primary"}),u.jsx("span",{children:"Thinking..."})]})})}),k&&!ye&&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:k.message||"Something went wrong"})}),u.jsx("div",{ref:q})]})}),u.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${J?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:oe,onDragOver:ne,onDragLeave:ie,children:[e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((M,me)=>u.jsx(rm,{context:M,onRemove:()=>n(me)},me))}),u.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u.jsx(Oz,{model:s,setModel:a}),yt==="pptx"&&x&&u.jsx(Rz,{scope:r,setScope:i,docSize:((Se=(he=_.find(M=>M.name===x))==null?void 0:he.text)==null?void 0:Se.length)??0})]}),B.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:B.map((M,me)=>u.jsxs("div",{className:"relative group",children:[um(M.mediaType)?u.jsx("img",{src:M.url,alt:M.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(ca,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u.jsx("span",{className:"text-xs truncate text-muted-foreground",children:M.filename||"file"})]}),u.jsx("button",{type:"button",onClick:()=>b(me),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:u.jsx(Nn,{className:"h-3 w-3"})})]},me))}),u.jsxs("form",{onSubmit:Oe,className:"flex items-end gap-2",children:[u.jsx("input",{ref:fe,type:"file",accept:Ez,multiple:!0,className:"hidden",onChange:M=>{M.target.files&&ue(Array.from(M.target.files)),M.target.value=""}}),u.jsx(we,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var M;return(M=fe.current)==null?void 0:M.click()},title:"Attach file",children:u.jsx(ca,{className:"h-4 w-4"})}),u.jsx("textarea",{ref:v,value:I,onChange:M=>{A(M.target.value);const me=M.target;me.style.height="auto",me.style.height=`${Math.min(me.scrollHeight,128)}px`},onKeyDown:qe,onPaste:Y,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}),ye?u.jsx(we,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:$,title:"Stop generating",children:u.jsx(dg,{className:"h-4 w-4"})}):u.jsx(we,{type:"submit",size:"icon",disabled:!I.trim()&&B.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:u.jsx(Zo,{className:"h-4 w-4"})})]})]}),u.jsx(It,{open:T,onOpenChange:P,children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear thread"}),u.jsx(cn,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),u.jsxs(Cn,{children:[u.jsx(Vo,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(we,{variant:"destructive",size:"sm",onClick:j,children:"Clear"})]})]})}),u.jsx(It,{open:O!==null,onOpenChange:M=>{M||Z(null)},children:u.jsxs(St,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Delete message"}),u.jsx(cn,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),u.jsxs(Cn,{children:[u.jsx(Vo,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(we,{variant:"destructive",size:"sm",onClick:ee,children:"Delete"})]})]})})]})}const Tz=y.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,c;const a=((l=t.parts)==null?void 0:l.filter(f=>f.type==="text").map(f=>f.text).join(""))||"",o=((c=t.parts)==null?void 0:c.filter(f=>f.type==="file"))||[];return u.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:u.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?u.jsxs("div",{children:[o.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:o.map((f,d)=>um(f.mediaType)?u.jsx("img",{src:f.url,alt:f.filename||"image",className:"h-20 max-w-[160px] rounded object-cover"},d):u.jsxs("div",{className:"flex items-center gap-1.5 rounded bg-primary-foreground/20 px-2 py-1",children:[u.jsx(ca,{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"text-xs truncate max-w-[120px]",children:f.filename||"file"})]},d))}),r&&r.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((f,d)=>u.jsx(rm,{context:f,variant:"sent"},d))}),a&&u.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:a}),i&&i!=="global"&&u.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):u.jsx(Az,{text:a,isStreaming:n,context:r,scope:i}),s&&!n&&u.jsx("div",{className:"opacity-0 group-hover/msg:opacity-100 transition-opacity mt-1",children:u.jsx("button",{type:"button",onClick:()=>s(t.id),className:`p-0.5 rounded cursor-pointer ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:u.jsx(Ha,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function Az({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(sk,{remarkPlugins:[y1],components:{pre:({children:i})=>u.jsx(u.Fragment,{children:i}),code:({className:i,children:s})=>{const a=i==null?void 0:i.startsWith("language-"),o=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!a)return u.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs font-mono",children:s});const c=o==="json"||o==="jsonc";return u.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[u.jsx("span",{className:"font-mono",children:o||"code"}),!c&&u.jsx(Mz,{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(Nz,{json:l,context:n,scope:r})]})}},children:e})})}const Pz=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function Oz({model:e,setModel:t}){return u.jsxs(Rr,{value:e,onValueChange:n=>t(n),children:[u.jsx(er,{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(Mr,{})}),u.jsx(tr,{children:Pz.map(n=>u.jsx(En,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const uc={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"},Dz=1e5;function Rz({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(uc).map(r=>u.jsxs(We,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),u.jsx(Ke,{side:"top",className:"text-xs max-w-[200px]",children:uc[r]})]},r))})]}),e==="global"&&n>Dz&&u.jsxs("div",{className:"text-[10px] text-amber-500 flex items-center gap-1",children:[u.jsx(td,{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-amber-400",children:"slides"})," ","or"," ",u.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-amber-400",children:"templates"})]})]})]})}function Mz({text:e}){const[t,n]=y.useState(!1),r=y.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 $z({discoveryData:e}){const t=Rd(),n=xx(),r=Te(N=>N.chatOpen),i=Te(N=>N.toggleChat),[s,a]=y.useState(()=>{try{const N=localStorage.getItem("dev-env.sidebar-open");return n?!1:N?N==="true":!0}catch{return!n}}),[o,l]=y.useState(()=>{try{const N=localStorage.getItem("dev-env.preview-open");return N?N==="true":!0}catch{return!0}}),[c,f]=y.useState("editor"),[d,p]=y.useState(!1),h=150,[m,w]=y.useState(!s),[S,x]=y.useState(!1);y.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),y.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(o))}catch{}},[o]);const _=y.useRef(n);y.useEffect(()=>{n&&!_.current&&s&&(x(!0),a(!1),setTimeout(()=>{w(!0),x(!1)},h)),!n&&_.current&&!s&&(x(!0),a(!0),setTimeout(()=>{w(!1),x(!1)},h)),_.current=n},[n,s]);const g=y.useCallback(()=>{if(t){p(N=>!N);return}x(!0),a(N=>!N),setTimeout(()=>{w(N=>!N),x(!1)},h)},[t]),z=y.useCallback(()=>l(N=>!N),[]),E=y.useRef(i),k=y.useRef(g),C=y.useRef(z);y.useEffect(()=>{E.current=i}),y.useEffect(()=>{k.current=g}),y.useEffect(()=>{C.current=z}),y.useEffect(()=>{const N=I=>{(I.metaKey||I.ctrlKey)&&(I.code==="KeyB"&&!I.shiftKey&&(I.preventDefault(),k.current()),I.code==="KeyJ"&&I.shiftKey&&(I.preventDefault(),I.stopPropagation(),E.current()),I.code==="KeyP"&&I.shiftKey&&(I.preventDefault(),C.current()))};return window.addEventListener("keydown",N,!0),()=>window.removeEventListener("keydown",N,!0)},[]);const $=nz,K=[{key:"editor",icon:nd,label:"Editor"},{key:"preview",icon:rd,label:"Preview"},{key:"chat",icon:id,label:"Chat"}];return t?u.jsx($,{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(Pd,{open:d,onOpenChange:p,children:[u.jsx(fx,{asChild:!0,children:u.jsx(we,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:u.jsx(Qc,{className:"h-4 w-4"})})}),u.jsx(Qa,{side:"left",className:"p-0 w-72",children:u.jsx(tl,{discoveryData:e,onToggleSidebar:()=>p(!1),isCollapsed:!1})})]}),u.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:K.map(({key:N,icon:I,label:A})=>u.jsxs(we,{variant:c===N?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>f(N),children:[u.jsx(I,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"hidden xs:inline",children:A})]},N))})]}),c!=="chat"&&u.jsx(yl,{previewOpen:o,onTogglePreview:z}),u.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(nl,{})}),c==="preview"&&u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(rl,{})}),c==="chat"&&u.jsx(lc,{})]})]})}):u.jsx($,{children:u.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[u.jsx("div",{className:H("shrink-0 overflow-hidden border-r bg-sidebar","transition-[width] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]",s?"w-64":"w-12"),children:u.jsx(tl,{discoveryData:e,onToggleSidebar:g,isCollapsed:m,isAnimating:S})}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[u.jsx(yl,{previewOpen:o,onTogglePreview:z}),u.jsxs(zy,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[u.jsx(Ms,{defaultSize:o?50:100,minSize:20,id:"editor",order:1,children:u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(nl,{})})}),o&&u.jsxs(u.Fragment,{children:[u.jsx(pl,{withHandle:!0}),u.jsx(Ms,{defaultSize:50,minSize:20,id:"preview",order:2,children:u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(rl,{})})})]}),r&&u.jsxs(u.Fragment,{children:[u.jsx(pl,{withHandle:!0}),u.jsx(Ms,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:u.jsx(lc,{})})]})]})]})]})})}function Fz(){const[e,t]=y.useState(null),[n,r]=y.useState(!0),[i,s]=y.useState(null),a=y.useCallback(async()=>{r(!0),s(null);try{const o=await fetch("/api/discovery/all");if(!o.ok)throw new Error(`Discovery failed: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(o){console.error("Discovery error:",o),s(o instanceof Error?o.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return y.useEffect(()=>{a()},[a]),{data:e,loading:n,error:i,refetch:a}}function Lz(){const[e,t]=y.useState(!1),[n,r]=y.useState(null),[i,s]=y.useState(0);return{loadPlugins:y.useCallback(async()=>{t(!0),r(null);try{const o=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!o.ok)throw new Error(`Failed to load plugins: ${o.statusText}`);const l=await o.json();if(!l.success)throw new Error(l.error||"Failed to load plugins");return s(l.data.loaded),!0}catch(o){return console.error("Plugin loading error:",o),r(o instanceof Error?o.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function Zz(){const{data:e,loading:t,error:n}=Fz(),{loadPlugins:r}=Lz(),i=Dt(s=>s.applyPluginsWithValidation);return y.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const a=Dt.getState().selectedPlugins;a.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(a)),i())}})},[e,r,i]),t?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),u.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):u.jsx(pg,{children:u.jsx(hg,{children:u.jsx(mg,{children:u.jsx(gg,{children:u.jsx(xg,{children:u.jsx(Qg,{children:u.jsx($d,{children:u.jsx("section",{className:"flex h-screen w-full flex-col",children:u.jsx("div",{className:"grow overflow-hidden",children:u.jsx($z,{discoveryData:e})})})})})})})})})})}const Yz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:Zz},Symbol.toStringTag,{value:"Module"}));export{Vt as B,It as D,Yz as H,Fy as P,Ar as S,Zr as T,Wd as a,Ad as b,St as c,Ut as d,Jt as e,Dy as u};
|
|
99
|
+
//# sourceMappingURL=HomePage-BTmw2QAf.js.map
|