@json-to-office/jto 0.31.1 → 0.32.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 +1 -1
- package/dist/client/assets/HomePage-CxftAvxV.js +106 -0
- package/dist/client/assets/HomePage-CxftAvxV.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-DTKKgR2h.js → JsonEditorPage-I6sk6Db3.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-DTKKgR2h.js.map → JsonEditorPage-I6sk6Db3.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-CMMxV-i2.js → MonacoPluginProvider-kUq_bpMI.js} +3 -3
- package/dist/client/assets/{MonacoPluginProvider-CMMxV-i2.js.map → MonacoPluginProvider-kUq_bpMI.js.map} +1 -1
- package/dist/client/assets/{editor-gUyDUz63.js → editor-h_FlzUyg.js} +3 -3
- package/dist/client/assets/{editor-gUyDUz63.js.map → editor-h_FlzUyg.js.map} +1 -1
- package/dist/client/assets/editor-monaco-json-DsKirQnz.js +24 -0
- package/dist/client/assets/editor-monaco-json-DsKirQnz.js.map +1 -0
- package/dist/client/assets/editor-refs-store-KuYpGA4M.js +2 -0
- package/dist/client/assets/editor-refs-store-KuYpGA4M.js.map +1 -0
- package/dist/client/assets/{index-D1wtfnMa.js → index-B1h-zv5O.js} +4 -4
- package/dist/client/assets/index-B1h-zv5O.js.map +1 -0
- package/dist/client/assets/index-C9ply7vX.css +1 -0
- package/dist/client/assets/preview-aCcyncRa.js +3 -0
- package/dist/client/assets/{preview-CjoG7qgc.js.map → preview-aCcyncRa.js.map} +1 -1
- package/dist/client/assets/{ui-vendor-Nd4Lg2re.js → ui-vendor-Cs3OXpi7.js} +97 -47
- package/dist/client/assets/ui-vendor-Cs3OXpi7.js.map +1 -0
- package/dist/client/index.html +3 -3
- package/dist/client/templates/Alternative deck 16_9.pptx.json +27 -0
- package/dist/client/templates/Brand template 16_9.pptx.json +21 -0
- package/dist/client/templates/Company deck 16_9.pptx.json +60 -0
- package/dist/client/templates/Company deck 4_3.pptx.json +45 -0
- package/dist/client/templates/data-report-presentation.pptx.json +45 -0
- package/dist/client/templates/management-plan.pptx.json +32 -23
- package/dist/client/templates/minimalist-pitch-deck.pptx.json +33 -0
- package/dist/client/templates/modern-annual-report-1.docx.json +419 -185
- package/dist/client/templates/modern-annual-report-2.docx.json +475 -195
- package/dist/client/templates/modern-annual-report-3.docx.json +465 -277
- package/dist/client/templates/standard-annual-report.docx.json +98 -19
- package/dist/client/templates/tech-report.docx.json +141 -23
- package/dist/prompts/instructions-docx.md +1 -1
- package/package.json +7 -6
- package/dist/client/assets/HomePage-CUlcBMHx.js +0 -99
- package/dist/client/assets/HomePage-CUlcBMHx.js.map +0 -1
- package/dist/client/assets/button-DpZ0m-Zd.js +0 -2
- package/dist/client/assets/button-DpZ0m-Zd.js.map +0 -1
- package/dist/client/assets/editor-monaco-json-D4CMHx8D.js +0 -24
- package/dist/client/assets/editor-monaco-json-D4CMHx8D.js.map +0 -1
- package/dist/client/assets/index-D1wtfnMa.js.map +0 -1
- package/dist/client/assets/index-M8Aq8GqY.css +0 -1
- package/dist/client/assets/preview-CjoG7qgc.js +0 -3
- package/dist/client/assets/ui-vendor-Nd4Lg2re.js.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-h_FlzUyg.js","assets/react-vendor-CTFDOf2G.js","assets/editor-monaco-json-DsKirQnz.js","assets/index-B1h-zv5O.js","assets/query-vendor-Df8-oete.js","assets/radix-ui-Bq-7y_Sq.js","assets/ui-vendor-Cs3OXpi7.js","assets/monaco-editor-BcgxPCqT.js","assets/state-vendor-ByFYl9bq.js","assets/index-C9ply7vX.css","assets/editor-refs-store-KuYpGA4M.js","assets/MonacoPluginProvider-kUq_bpMI.js","assets/preview-aCcyncRa.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Mm=Object.defineProperty;var $m=(e,t,n)=>t in e?Mm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xa=(e,t,n)=>$m(e,typeof t!="symbol"?t+"":t,n);import{r as x,j as u,c as Se,R as Oc,g as oa}from"./react-vendor-CTFDOf2G.js";import{b as Pc,c as aa,d as Dc,e as hs,f as ms,D as gs,O as xs,g as Lm,V as Fm,h as Rc,I as Bm,i as Zm,j as Mc,k as Vm,l as $c,m as Um,n as Jm,G as Hm,S as Lc,o as Fc,L as Bc,p as Zc,q as Vc,r as yr,s as Wm,t as qm,u as Gm,v as Uc,w as Jc,x as Hc,y as Wc,z as qc,B as Gc,E as Yc,F as Kc,H as Xc,J as Ym,K as Km,M as Xm,N as Qc,Q as ed,U as td,W as nd,X as rd,Y as id,Z as sd,_ as od,$ as ad,a0 as ld,a1 as Qm,a2 as ud,a3 as eg,a4 as tg,a5 as cd,a6 as ng,a7 as rg,a8 as ig,a9 as sg,aa as og,ab as ag,ac as lg,ad as dd,ae as fd,af as pd}from"./radix-ui-Bq-7y_Sq.js";import{c as q,u as vr,S as sn,A as hd,T as vi,C as ug,E as cg,F as ot,a as dg,b as fg,d as qe,e as Ge,f as Ye,g as md,_ as gd,h as wi,i as pg,j as hg,k as mg,l as jr,s as Ls,m as Di,W as gg}from"./index-B1h-zv5O.js";import{X as xn,C as ci,a as bn,b as xg,d as di,G as xd,F as bg,e as Pn,f as bd,P as yg,g as vg,h as yd,E as vd,B as wo,H as wg,T as ko,L as Qa,i as kg,j as Sg,S as wd,I as _g,k as jg,l as So,m as Ng,n as Eg,o as Cg,p as Ig,q as Tg,r as Ag,s as zg,t as Og,u as bs,v as Pg,M as Dg,w as kd,x as nn,y as Rg,z as Mg,A as Sd,D as $g,J as Lg,K as Fg,N as Bg,R as Zg,O as Vg,Q as _d,U as Ug,V as _o,W as la,Y as jd,Z as Jg,_ as Nd,$ as jo,a0 as Hg,a1 as Wg,a2 as el,a3 as No}from"./ui-vendor-Cs3OXpi7.js";import{B as Ne,u as qg,d as tl}from"./editor-refs-store-KuYpGA4M.js";import{u as Pe,i as Gg,a as Eo,b as rn,g as Yg,c as Bt,T as Ed,d as ki,S as Kg,O as Xg,e as Qg,M as ex,D as tx}from"./MonacoPluginProvider-kUq_bpMI.js";import{u as ua,a as nx,d as rx,p as ix,b as sx,e as ox}from"./state-vendor-ByFYl9bq.js";import{b as ax}from"./query-vendor-Df8-oete.js";const Ct=Pc,lx=Dc,nl=aa,Cd=x.forwardRef(({className:e,...t},n)=>u.jsx(xs,{ref:n,className:q("fixed inset-0 z-50 bg-black/50",e),...t}));Cd.displayName=xs.displayName;const kt=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(lx,{children:[u.jsx(Cd,{}),u.jsxs(hs,{ref:r,className:q("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(aa,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[u.jsx(xn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));kt.displayName=hs.displayName;const Ut=({className:e,...t})=>u.jsx("div",{className:q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ut.displayName="DialogHeader";const yn=({className:e,...t})=>u.jsx("div",{className:q("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});yn.displayName="DialogFooter";const Jt=x.forwardRef(({className:e,...t},n)=>u.jsx(ms,{ref:n,className:q("text-lg leading-none font-semibold tracking-tight",e),...t}));Jt.displayName=ms.displayName;const an=x.forwardRef(({className:e,...t},n)=>u.jsx(gs,{ref:n,className:q("text-muted-foreground text-sm",e),...t}));an.displayName=gs.displayName;const qr=Lm,ux=Hm,Gr=Fm,cr=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Rc,{ref:r,className:q("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex min-h-9 w-full min-w-0 items-center justify-between gap-2 rounded-sm border bg-background px-3 py-2 text-sm shadow-xs focus:ring-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:min-w-0 [&>span]:whitespace-normal [&>span]:break-words text-left cursor-pointer",e),...n,children:[t,u.jsx(Bm,{asChild:!0,children:u.jsx(ci,{className:"h-4 w-4 shrink-0 opacity-50"})})]}));cr.displayName=Rc.displayName;const Id=x.forwardRef(({className:e,...t},n)=>u.jsx(Lc,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(xg,{className:"h-4 w-4"})}));Id.displayName=Lc.displayName;const Td=x.forwardRef(({className:e,...t},n)=>u.jsx(Fc,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ci,{className:"h-4 w-4"})}));Td.displayName=Fc.displayName;const dr=x.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>u.jsx(Zm,{children:u.jsxs(Mc,{ref:i,className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Id,{}),u.jsx(Vm,{className:q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Td,{})]})}));dr.displayName=Mc.displayName;const Ad=x.forwardRef(({className:e,...t},n)=>u.jsx(Bc,{ref:n,className:q("px-2 py-1.5 text-sm font-semibold",e),...t}));Ad.displayName=Bc.displayName;const Dn=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($c,{ref:r,className:q("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(Um,{children:u.jsx(bn,{className:"h-4 w-4"})})}),u.jsx(Jm,{children:t})]}));Dn.displayName=$c.displayName;const cx=x.forwardRef(({className:e,...t},n)=>u.jsx(Zc,{ref:n,className:q("bg-muted -mx-1 my-1 h-px",e),...t}));cx.displayName=Zc.displayName;const fi=x.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:q("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-sm border bg-background px-3 py-1 text-sm shadow-xs transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));fi.displayName="Input";const dx=di("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),sr=x.forwardRef(({className:e,...t},n)=>u.jsx(Vc,{ref:n,className:q(dx(),e),...t}));sr.displayName=Vc.displayName;const fx=di("inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-medium transition-colors focus:outline-none",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Kt({className:e,variant:t,...n}){return u.jsx("div",{className:q(fx({variant:t}),e),...n})}const px=({open:e,onOpenChange:t})=>{const{documents:n,documentTypes:r,activeTab:i,createDocument:s,openDocument:o}=Pe(ua(I=>({documents:I.documents,documentTypes:I.documentTypes,activeTab:I.activeTab,createDocument:I.createDocument,openDocument:I.openDocument}))),{toast:a}=vr(),l=x.useMemo(()=>n.filter(I=>r[I.name]!=="application/json+theme"),[n,r]),[c,d]=x.useState(""),[f,p]=x.useState(""),[h,g]=x.useState("playground"),[v,S]=x.useState(!1),[b,j]=x.useState(null),[m,T]=x.useState(null),[C,w]=x.useState(null),N=()=>{j(null),T(null),w(null)};x.useEffect(()=>{if(!e)return;j(null),T(null),w(null);const I=l.map(M=>M.name),z=I.includes(i)?i:I[0]??"";p(z),d(I.find(M=>M!==z)??"")},[e]);const H=async()=>{const I=l.find(M=>M.name===c),z=l.find(M=>M.name===f);if(!(!I||!z)){S(!0),j(null),T(null),w(null);try{const M=await fetch(hd.diff,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldDefinition:I.text,newDefinition:z.text,options:{author:h||"playground"}})}),A=await M.json();if(!M.ok||!A.success){const P=Array.isArray(A.errors)?`: ${A.errors.slice(0,3).map(D=>D.message||String(D)).join("; ")}`:"";throw new Error((A.error||`Diff failed (${M.status})`)+P)}T(A.data.summary),w(A.data.document)}catch(M){j(M instanceof Error?M.message:"Diff failed")}finally{S(!1)}}},O=()=>{if(!C)return;const I=new Set(n.map(A=>A.name));let z=`${f}-redline`,M=2;for(;I.has(z);)z=`${f}-redline-${M++}`;s(z,JSON.stringify(C,null,2)),o(z),a({title:`Redline created: ${z}`}),t(!1)},_=m?m.tracked.modified+m.tracked.inserted+m.tracked.deleted:0;return u.jsx(Ct,{open:e,onOpenChange:t,children:u.jsxs(kt,{className:"sm:max-w-[560px]",children:[u.jsxs(Ut,{children:[u.jsxs(Jt,{className:"flex items-center gap-2",children:[u.jsx(xd,{className:"size-4"}),"Compare documents"]}),u.jsx(an,{children:"Diff two versions into a redline with native Word tracked changes (accept/reject in Word)."})]}),u.jsxs("div",{className:"grid gap-4 py-2",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(sr,{htmlFor:"diff-base",children:"Base (old)"}),u.jsxs(qr,{value:c,onValueChange:I=>{d(I),N()},children:[u.jsx(cr,{id:"diff-base",children:u.jsx(Gr,{placeholder:"Select document"})}),u.jsx(dr,{children:l.map(I=>u.jsx(Dn,{value:I.name,children:I.name},I.name))})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(sr,{htmlFor:"diff-revised",children:"Revised (new)"}),u.jsxs(qr,{value:f,onValueChange:I=>{p(I),N()},children:[u.jsx(cr,{id:"diff-revised",children:u.jsx(Gr,{placeholder:"Select document"})}),u.jsx(dr,{children:l.map(I=>u.jsx(Dn,{value:I.name,children:I.name},I.name))})]})]})]}),u.jsxs("div",{className:"grid gap-1.5",children:[u.jsx(sr,{htmlFor:"diff-author",children:"Revision author"}),u.jsx(fi,{id:"diff-author",value:h,onChange:I=>{g(I.target.value),N()},placeholder:"playground"})]}),b&&u.jsx("p",{className:"text-sm text-destructive",role:"alert",children:b}),m&&u.jsxs("div",{className:"rounded-md border p-3 text-sm grid gap-2",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[u.jsxs(Kt,{variant:"secondary",children:[m.tracked.inserted," inserted"]}),u.jsxs(Kt,{variant:"secondary",children:[m.tracked.deleted," deleted"]}),u.jsxs(Kt,{variant:"secondary",children:[m.tracked.modified," modified"]}),u.jsxs("span",{className:"text-muted-foreground text-xs",children:[m.unchangedBlocks," blocks unchanged"]})]}),_===0&&m.untracked.length===0&&u.jsx("p",{className:"text-muted-foreground",children:"The documents are identical."}),m.untracked.length>0&&u.jsxs("div",{className:"grid gap-1 max-h-32 overflow-y-auto",children:[u.jsxs("p",{className:"font-medium text-warning-bg-foreground",children:[m.untracked.length," change(s) not expressible as tracked changes:"]}),m.untracked.map((I,z)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:[I.path," [",I.component,"] ",I.detail]},z))]}),m.notes.map((I,z)=>u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Note: ",I]},z))]})]}),u.jsx(yn,{children:m&&_+m.untracked.length>0?u.jsxs(Ne,{onClick:O,children:[u.jsx(bg,{className:"size-4 mr-1"}),"Open redline"]}):u.jsxs(Ne,{onClick:H,disabled:v||!c||!f||c===f,children:[v&&u.jsx(sn,{className:"size-4 mr-1"}),"Compare"]})})]})})};var pi=e=>e.type==="checkbox",Tn=e=>e instanceof Date,pt=e=>e==null;const zd=e=>typeof e=="object";var et=e=>!pt(e)&&!Array.isArray(e)&&zd(e)&&!Tn(e),Od=e=>et(e)&&e.target?pi(e.target)?e.target.checked:e.target.value:e,hx=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Pd=(e,t)=>e.has(hx(t)),mx=e=>{const t=e.constructor&&e.constructor.prototype;return et(t)&&t.hasOwnProperty("isPrototypeOf")},ca=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function bt(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(!(ca&&(e instanceof Blob||r))&&(n||et(e)))if(t=n?[]:{},!n&&!mx(e))t=e;else for(const i in e)e.hasOwnProperty(i)&&(t[i]=bt(e[i]));else return e;return t}var ys=e=>Array.isArray(e)?e.filter(Boolean):[],Qe=e=>e===void 0,le=(e,t,n)=>{if(!t||!et(e))return n;const r=ys(t.split(/[,[\].]+?/)).reduce((i,s)=>pt(i)?i:i[s],e);return Qe(r)||r===e?Qe(e[t])?n:e[t]:r},zt=e=>typeof e=="boolean",da=e=>/^\w*$/.test(e),Dd=e=>ys(e.replace(/["|']|\]/g,"").split(/\.|\[/)),$e=(e,t,n)=>{let r=-1;const i=da(t)?[t]:Dd(t),s=i.length,o=s-1;for(;++r<s;){const a=i[r];let l=n;if(r!==o){const c=e[a];l=et(c)||Array.isArray(c)?c:isNaN(+i[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=l,e=e[a]}return e};const Zi={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ft={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},tn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Rd=Se.createContext(null),vs=()=>Se.useContext(Rd),gx=e=>{const{children:t,...n}=e;return Se.createElement(Rd.Provider,{value:n},t)};var Md=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(i,s,{get:()=>{const o=s;return t._proxyFormState[o]!==Ft.all&&(t._proxyFormState[o]=!r||Ft.all),n&&(n[o]=!0),e[o]}});return i},yt=e=>et(e)&&!Object.keys(e).length,$d=(e,t,n,r)=>{n(e);const{name:i,...s}=e;return yt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(o=>t[o]===(!r||Ft.all))},Zr=e=>Array.isArray(e)?e:[e],Ld=(e,t,n)=>!e||!t||e===t||Zr(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function fa(e){const t=Se.useRef(e);t.current=e,Se.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function xx(e){const t=vs(),{control:n=t.control,disabled:r,name:i,exact:s}=e||{},[o,a]=Se.useState(n._formState),l=Se.useRef(!0),c=Se.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=Se.useRef(i);return d.current=i,fa({disabled:r,next:f=>l.current&&Ld(d.current,f.name,s)&&$d(f,c.current,n._updateFormState)&&a({...n._formState,...f}),subject:n._subjects.state}),Se.useEffect(()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1}),[n]),Se.useMemo(()=>Md(o,n,c.current,!1),[o,n])}var Yt=e=>typeof e=="string",Fd=(e,t,n,r,i)=>Yt(e)?(r&&t.watch.add(e),le(n,e,i)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),le(n,s))):(r&&(t.watchAll=!0),n);function bx(e){const t=vs(),{control:n=t.control,name:r,defaultValue:i,disabled:s,exact:o}=e||{},a=Se.useRef(r);a.current=r,fa({disabled:s,subject:n._subjects.values,next:d=>{Ld(a.current,d.name,o)&&c(bt(Fd(a.current,n._names,d.values||n._formValues,!1,i)))}});const[l,c]=Se.useState(n._getWatch(r,i));return Se.useEffect(()=>n._removeUnmounted()),l}function yx(e){const t=vs(),{name:n,disabled:r,control:i=t.control,shouldUnregister:s}=e,o=Pd(i._names.array,n),a=bx({control:i,name:n,defaultValue:le(i._formValues,n,le(i._defaultValues,n,e.defaultValue)),exact:!0}),l=xx({control:i,name:n,exact:!0}),c=Se.useRef(i.register(n,{...e.rules,value:a,...zt(e.disabled)?{disabled:e.disabled}:{}})),d=Se.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!le(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!le(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!le(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!le(l.validatingFields,n)},error:{enumerable:!0,get:()=>le(l.errors,n)}}),[l,n]),f=Se.useMemo(()=>({name:n,value:a,...zt(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p=>c.current.onChange({target:{value:Od(p),name:n},type:Zi.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:le(i._formValues,n),name:n},type:Zi.BLUR}),ref:p=>{const h=le(i._fields,n);h&&p&&(h._f.ref={focus:()=>p.focus(),select:()=>p.select(),setCustomValidity:g=>p.setCustomValidity(g),reportValidity:()=>p.reportValidity()})}}),[n,i._formValues,r,l.disabled,a,i._fields]);return Se.useEffect(()=>{const p=i._options.shouldUnregister||s,h=(g,v)=>{const S=le(i._fields,g);S&&S._f&&(S._f.mount=v)};if(h(n,!0),p){const g=bt(le(i._options.defaultValues,n));$e(i._defaultValues,n,g),Qe(le(i._formValues,n))&&$e(i._formValues,n,g)}return!o&&i.register(n),()=>{(o?p&&!i._state.action:p)?i.unregister(n):h(n,!1)}},[n,i,o,s]),Se.useEffect(()=>{i._updateDisabledField({disabled:r,fields:i._fields,name:n})},[r,n,i]),Se.useMemo(()=>({field:f,formState:l,fieldState:d}),[f,l,d])}const vx=e=>e.render(yx(e));var wx=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},rl=e=>({isOnSubmit:!e||e===Ft.onSubmit,isOnBlur:e===Ft.onBlur,isOnChange:e===Ft.onChange,isOnAll:e===Ft.all,isOnTouch:e===Ft.onTouched}),il=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Vr=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const s=le(e,i);if(s){const{_f:o,...a}=s;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],i)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(Vr(a,t))break}else if(et(a)&&Vr(a,t))break}}};var kx=(e,t,n)=>{const r=Zr(le(e,n));return $e(r,"root",t[n]),$e(e,n,r),e},pa=e=>e.type==="file",Gt=e=>typeof e=="function",Vi=e=>{if(!ca)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Ri=e=>Yt(e),ha=e=>e.type==="radio",Ui=e=>e instanceof RegExp;const sl={value:!1,isValid:!1},ol={value:!0,isValid:!0};var Bd=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Qe(e[0].attributes.value)?Qe(e[0].value)||e[0].value===""?ol:{value:e[0].value,isValid:!0}:ol:sl}return sl};const al={isValid:!1,value:null};var Zd=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,al):al;function ll(e,t,n="validate"){if(Ri(e)||Array.isArray(e)&&e.every(Ri)||zt(e)&&!e)return{type:n,message:Ri(e)?e:"",ref:t}}var Bn=e=>et(e)&&!Ui(e)?e:{value:e,message:""},ul=async(e,t,n,r,i,s)=>{const{ref:o,refs:a,required:l,maxLength:c,minLength:d,min:f,max:p,pattern:h,validate:g,name:v,valueAsNumber:S,mount:b}=e._f,j=le(n,v);if(!b||t.has(v))return{};const m=a?a[0]:o,T=z=>{i&&m.reportValidity&&(m.setCustomValidity(zt(z)?"":z||""),m.reportValidity())},C={},w=ha(o),N=pi(o),H=w||N,O=(S||pa(o))&&Qe(o.value)&&Qe(j)||Vi(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,_=wx.bind(null,v,r,C),I=(z,M,A,P=tn.maxLength,D=tn.minLength)=>{const U=z?M:A;C[v]={type:z?P:D,message:U,ref:o,..._(z?P:D,U)}};if(s?!Array.isArray(j)||!j.length:l&&(!H&&(O||pt(j))||zt(j)&&!j||N&&!Bd(a).isValid||w&&!Zd(a).isValid)){const{value:z,message:M}=Ri(l)?{value:!!l,message:l}:Bn(l);if(z&&(C[v]={type:tn.required,message:M,ref:m,..._(tn.required,M)},!r))return T(M),C}if(!O&&(!pt(f)||!pt(p))){let z,M;const A=Bn(p),P=Bn(f);if(!pt(j)&&!isNaN(j)){const D=o.valueAsNumber||j&&+j;pt(A.value)||(z=D>A.value),pt(P.value)||(M=D<P.value)}else{const D=o.valueAsDate||new Date(j),U=k=>new Date(new Date().toDateString()+" "+k),$=o.type=="time",X=o.type=="week";Yt(A.value)&&j&&(z=$?U(j)>U(A.value):X?j>A.value:D>new Date(A.value)),Yt(P.value)&&j&&(M=$?U(j)<U(P.value):X?j<P.value:D<new Date(P.value))}if((z||M)&&(I(!!z,A.message,P.message,tn.max,tn.min),!r))return T(C[v].message),C}if((c||d)&&!O&&(Yt(j)||s&&Array.isArray(j))){const z=Bn(c),M=Bn(d),A=!pt(z.value)&&j.length>+z.value,P=!pt(M.value)&&j.length<+M.value;if((A||P)&&(I(A,z.message,M.message),!r))return T(C[v].message),C}if(h&&!O&&Yt(j)){const{value:z,message:M}=Bn(h);if(Ui(z)&&!j.match(z)&&(C[v]={type:tn.pattern,message:M,ref:o,..._(tn.pattern,M)},!r))return T(M),C}if(g){if(Gt(g)){const z=await g(j,n),M=ll(z,m);if(M&&(C[v]={...M,..._(tn.validate,M.message)},!r))return T(M.message),C}else if(et(g)){let z={};for(const M in g){if(!yt(z)&&!r)break;const A=ll(await g[M](j,n),m,M);A&&(z={...A,..._(M,A.message)},T(A.message),r&&(C[v]=z))}if(!yt(z)&&(C[v]={ref:m,...z},!r))return C}}return T(!0),C};function Sx(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Qe(e)?r++:e[t[r++]];return e}function _x(e){for(const t in e)if(e.hasOwnProperty(t)&&!Qe(e[t]))return!1;return!0}function it(e,t){const n=Array.isArray(t)?t:da(t)?[t]:Dd(t),r=n.length===1?e:Sx(e,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(et(r)&&yt(r)||Array.isArray(r)&&_x(r))&&it(e,n.slice(0,-1)),e}var Fs=()=>{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=[]}}},Co=e=>pt(e)||!zd(e);function hn(e,t){if(Co(e)||Co(t))return e===t;if(Tn(e)&&Tn(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const s=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const o=t[i];if(Tn(s)&&Tn(o)||et(s)&&et(o)||Array.isArray(s)&&Array.isArray(o)?!hn(s,o):s!==o)return!1}}return!0}var Vd=e=>e.type==="select-multiple",jx=e=>ha(e)||pi(e),Bs=e=>Vi(e)&&e.isConnected,Ud=e=>{for(const t in e)if(Gt(e[t]))return!0;return!1};function Ji(e,t={}){const n=Array.isArray(e);if(et(e)||n)for(const r in e)Array.isArray(e[r])||et(e[r])&&!Ud(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Ji(e[r],t[r])):pt(e[r])||(t[r]=!0);return t}function Jd(e,t,n){const r=Array.isArray(e);if(et(e)||r)for(const i in e)Array.isArray(e[i])||et(e[i])&&!Ud(e[i])?Qe(t)||Co(n[i])?n[i]=Array.isArray(e[i])?Ji(e[i],[]):{...Ji(e[i])}:Jd(e[i],pt(t)?{}:t[i],n[i]):n[i]=!hn(e[i],t[i]);return n}var Nr=(e,t)=>Jd(e,t,Ji(t)),Hd=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Qe(e)?e:t?e===""?NaN:e&&+e:n&&Yt(e)?new Date(e):r?r(e):e;function Zs(e){const t=e.ref;return pa(t)?t.files:ha(t)?Zd(e.refs).value:Vd(t)?[...t.selectedOptions].map(({value:n})=>n):pi(t)?Bd(e.refs).value:Hd(Qe(t.value)?e.ref.value:t.value,e)}var Nx=(e,t,n,r)=>{const i={};for(const s of e){const o=le(t,s);o&&$e(i,s,o._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Er=e=>Qe(e)?e:Ui(e)?e.source:et(e)?Ui(e.value)?e.value.source:e.value:e;const cl="AsyncFunction";var Ex=e=>!!e&&!!e.validate&&!!(Gt(e.validate)&&e.validate.constructor.name===cl||et(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===cl)),Cx=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function dl(e,t,n){const r=le(e,n);if(r||da(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),o=le(t,s),a=le(e,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};i.pop()}return{name:n}}var Ix=(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,Tx=(e,t)=>!ys(le(e,t)).length&&it(e,t);const Ax={mode:Ft.onSubmit,reValidateMode:Ft.onChange,shouldFocusError:!0};function zx(e={}){let t={...Ax,...e},n={submitCount:0,isDirty:!1,isLoading:Gt(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=et(t.defaultValues)||et(t.values)?bt(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:bt(i),o={action:!1,mount:!1,watch:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},l,c=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={values:Fs(),array:Fs(),state:Fs()},p=rl(t.mode),h=rl(t.reValidateMode),g=t.criteriaMode===Ft.all,v=E=>R=>{clearTimeout(c),c=setTimeout(E,R)},S=async E=>{if(!t.disabled&&(d.isValid||E)){const R=t.resolver?yt((await H()).errors):await _(r,!0);R!==n.isValid&&f.state.next({isValid:R})}},b=(E,R)=>{!t.disabled&&(d.isValidating||d.validatingFields)&&((E||Array.from(a.mount)).forEach(L=>{L&&(R?$e(n.validatingFields,L,R):it(n.validatingFields,L))}),f.state.next({validatingFields:n.validatingFields,isValidating:!yt(n.validatingFields)}))},j=(E,R=[],L,te,K=!0,ee=!0)=>{if(te&&L&&!t.disabled){if(o.action=!0,ee&&Array.isArray(le(r,E))){const ue=L(le(r,E),te.argA,te.argB);K&&$e(r,E,ue)}if(ee&&Array.isArray(le(n.errors,E))){const ue=L(le(n.errors,E),te.argA,te.argB);K&&$e(n.errors,E,ue),Tx(n.errors,E)}if(d.touchedFields&&ee&&Array.isArray(le(n.touchedFields,E))){const ue=L(le(n.touchedFields,E),te.argA,te.argB);K&&$e(n.touchedFields,E,ue)}d.dirtyFields&&(n.dirtyFields=Nr(i,s)),f.state.next({name:E,isDirty:z(E,R),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else $e(s,E,R)},m=(E,R)=>{$e(n.errors,E,R),f.state.next({errors:n.errors})},T=E=>{n.errors=E,f.state.next({errors:n.errors,isValid:!1})},C=(E,R,L,te)=>{const K=le(r,E);if(K){const ee=le(s,E,Qe(L)?le(i,E):L);Qe(ee)||te&&te.defaultChecked||R?$e(s,E,R?ee:Zs(K._f)):P(E,ee),o.mount&&S()}},w=(E,R,L,te,K)=>{let ee=!1,ue=!1;const be={name:E};if(!t.disabled){const B=!!(le(r,E)&&le(r,E)._f&&le(r,E)._f.disabled);if(!L||te){d.isDirty&&(ue=n.isDirty,n.isDirty=be.isDirty=z(),ee=ue!==be.isDirty);const Y=B||hn(le(i,E),R);ue=!!(!B&&le(n.dirtyFields,E)),Y||B?it(n.dirtyFields,E):$e(n.dirtyFields,E,!0),be.dirtyFields=n.dirtyFields,ee=ee||d.dirtyFields&&ue!==!Y}if(L){const Y=le(n.touchedFields,E);Y||($e(n.touchedFields,E,L),be.touchedFields=n.touchedFields,ee=ee||d.touchedFields&&Y!==L)}ee&&K&&f.state.next(be)}return ee?be:{}},N=(E,R,L,te)=>{const K=le(n.errors,E),ee=d.isValid&&zt(R)&&n.isValid!==R;if(t.delayError&&L?(l=v(()=>m(E,L)),l(t.delayError)):(clearTimeout(c),l=null,L?$e(n.errors,E,L):it(n.errors,E)),(L?!hn(K,L):K)||!yt(te)||ee){const ue={...te,...ee&&zt(R)?{isValid:R}:{},errors:n.errors,name:E};n={...n,...ue},f.state.next(ue)}},H=async E=>{b(E,!0);const R=await t.resolver(s,t.context,Nx(E||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return b(E),R},O=async E=>{const{errors:R}=await H(E);if(E)for(const L of E){const te=le(R,L);te?$e(n.errors,L,te):it(n.errors,L)}else n.errors=R;return R},_=async(E,R,L={valid:!0})=>{for(const te in E){const K=E[te];if(K){const{_f:ee,...ue}=K;if(ee){const be=a.array.has(ee.name),B=K._f&&Ex(K._f);B&&d.validatingFields&&b([te],!0);const Y=await ul(K,a.disabled,s,g,t.shouldUseNativeValidation&&!R,be);if(B&&d.validatingFields&&b([te]),Y[ee.name]&&(L.valid=!1,R))break;!R&&(le(Y,ee.name)?be?kx(n.errors,Y,ee.name):$e(n.errors,ee.name,Y[ee.name]):it(n.errors,ee.name))}!yt(ue)&&await _(ue,R,L)}}return L.valid},I=()=>{for(const E of a.unMount){const R=le(r,E);R&&(R._f.refs?R._f.refs.every(L=>!Bs(L)):!Bs(R._f.ref))&&ie(E)}a.unMount=new Set},z=(E,R)=>!t.disabled&&(E&&R&&$e(s,E,R),!hn(oe(),i)),M=(E,R,L)=>Fd(E,a,{...o.mount?s:Qe(R)?i:Yt(E)?{[E]:R}:R},L,R),A=E=>ys(le(o.mount?s:i,E,t.shouldUnregister?le(i,E,[]):[])),P=(E,R,L={})=>{const te=le(r,E);let K=R;if(te){const ee=te._f;ee&&(!ee.disabled&&$e(s,E,Hd(R,ee)),K=Vi(ee.ref)&&pt(R)?"":R,Vd(ee.ref)?[...ee.ref.options].forEach(ue=>ue.selected=K.includes(ue.value)):ee.refs?pi(ee.ref)?ee.refs.length>1?ee.refs.forEach(ue=>(!ue.defaultChecked||!ue.disabled)&&(ue.checked=Array.isArray(K)?!!K.find(be=>be===ue.value):K===ue.value)):ee.refs[0]&&(ee.refs[0].checked=!!K):ee.refs.forEach(ue=>ue.checked=ue.value===K):pa(ee.ref)?ee.ref.value="":(ee.ref.value=K,ee.ref.type||f.values.next({name:E,values:{...s}})))}(L.shouldDirty||L.shouldTouch)&&w(E,K,L.shouldTouch,L.shouldDirty,!0),L.shouldValidate&&k(E)},D=(E,R,L)=>{for(const te in R){const K=R[te],ee=`${E}.${te}`,ue=le(r,ee);(a.array.has(E)||et(K)||ue&&!ue._f)&&!Tn(K)?D(ee,K,L):P(ee,K,L)}},U=(E,R,L={})=>{const te=le(r,E),K=a.array.has(E),ee=bt(R);$e(s,E,ee),K?(f.array.next({name:E,values:{...s}}),(d.isDirty||d.dirtyFields)&&L.shouldDirty&&f.state.next({name:E,dirtyFields:Nr(i,s),isDirty:z(E,ee)})):te&&!te._f&&!pt(ee)?D(E,ee,L):P(E,ee,L),il(E,a)&&f.state.next({...n}),f.values.next({name:o.mount?E:void 0,values:{...s}})},$=async E=>{o.mount=!0;const R=E.target;let L=R.name,te=!0;const K=le(r,L),ee=()=>R.type?Zs(K._f):Od(E),ue=be=>{te=Number.isNaN(be)||Tn(be)&&isNaN(be.getTime())||hn(be,le(s,L,be))};if(K){let be,B;const Y=ee(),fe=E.type===Zi.BLUR||E.type===Zi.FOCUS_OUT,_e=!Cx(K._f)&&!t.resolver&&!le(n.errors,L)&&!K._f.deps||Ix(fe,le(n.touchedFields,L),n.isSubmitted,h,p),F=il(L,a,fe);$e(s,L,Y),fe?(K._f.onBlur&&K._f.onBlur(E),l&&l(0)):K._f.onChange&&K._f.onChange(E);const pe=w(L,Y,fe,!1),Te=!yt(pe)||F;if(!fe&&f.values.next({name:L,type:E.type,values:{...s}}),_e)return d.isValid&&(t.mode==="onBlur"&&fe?S():fe||S()),Te&&f.state.next({name:L,...F?{}:pe});if(!fe&&F&&f.state.next({...n}),t.resolver){const{errors:Be}=await H([L]);if(ue(Y),te){const rt=dl(n.errors,r,L),tt=dl(Be,r,rt.name||L);be=tt.error,L=tt.name,B=yt(Be)}}else b([L],!0),be=(await ul(K,a.disabled,s,g,t.shouldUseNativeValidation))[L],b([L]),ue(Y),te&&(be?B=!1:d.isValid&&(B=await _(r,!0)));te&&(K._f.deps&&k(K._f.deps),N(L,B,be,pe))}},X=(E,R)=>{if(le(n.errors,R)&&E.focus)return E.focus(),1},k=async(E,R={})=>{let L,te;const K=Zr(E);if(t.resolver){const ee=await O(Qe(E)?E:K);L=yt(ee),te=E?!K.some(ue=>le(ee,ue)):L}else E?(te=(await Promise.all(K.map(async ee=>{const ue=le(r,ee);return await _(ue&&ue._f?{[ee]:ue}:ue)}))).every(Boolean),!(!te&&!n.isValid)&&S()):te=L=await _(r);return f.state.next({...!Yt(E)||d.isValid&&L!==n.isValid?{}:{name:E},...t.resolver||!E?{isValid:L}:{},errors:n.errors}),R.shouldFocus&&!te&&Vr(r,X,E?K:a.mount),te},oe=E=>{const R={...o.mount?s:i};return Qe(E)?R:Yt(E)?le(R,E):E.map(L=>le(R,L))},G=(E,R)=>({invalid:!!le((R||n).errors,E),isDirty:!!le((R||n).dirtyFields,E),error:le((R||n).errors,E),isValidating:!!le(n.validatingFields,E),isTouched:!!le((R||n).touchedFields,E)}),y=E=>{E&&Zr(E).forEach(R=>it(n.errors,R)),f.state.next({errors:E?n.errors:{}})},Z=(E,R,L)=>{const te=(le(r,E,{_f:{}})._f||{}).ref,K=le(n.errors,E)||{},{ref:ee,message:ue,type:be,...B}=K;$e(n.errors,E,{...B,...R,ref:te}),f.state.next({name:E,errors:n.errors,isValid:!1}),L&&L.shouldFocus&&te&&te.focus&&te.focus()},V=(E,R)=>Gt(E)?f.values.subscribe({next:L=>E(M(void 0,R),L)}):M(E,R,!0),ie=(E,R={})=>{for(const L of E?Zr(E):a.mount)a.mount.delete(L),a.array.delete(L),R.keepValue||(it(r,L),it(s,L)),!R.keepError&&it(n.errors,L),!R.keepDirty&&it(n.dirtyFields,L),!R.keepTouched&&it(n.touchedFields,L),!R.keepIsValidating&&it(n.validatingFields,L),!t.shouldUnregister&&!R.keepDefaultValue&&it(i,L);f.values.next({values:{...s}}),f.state.next({...n,...R.keepDirty?{isDirty:z()}:{}}),!R.keepIsValid&&S()},se=({disabled:E,name:R,field:L,fields:te})=>{(zt(E)&&o.mount||E||a.disabled.has(R))&&(E?a.disabled.add(R):a.disabled.delete(R),w(R,Zs(L?L._f:le(te,R)._f),!1,!1,!0))},re=(E,R={})=>{let L=le(r,E);const te=zt(R.disabled)||zt(t.disabled);return $e(r,E,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:E}},name:E,mount:!0,...R}}),a.mount.add(E),L?se({field:L,disabled:zt(R.disabled)?R.disabled:t.disabled,name:E}):C(E,!0,R.value),{...te?{disabled:R.disabled||t.disabled}:{},...t.progressive?{required:!!R.required,min:Er(R.min),max:Er(R.max),minLength:Er(R.minLength),maxLength:Er(R.maxLength),pattern:Er(R.pattern)}:{},name:E,onChange:$,onBlur:$,ref:K=>{if(K){re(E,R),L=le(r,E);const ee=Qe(K.value)&&K.querySelectorAll&&K.querySelectorAll("input,select,textarea")[0]||K,ue=jx(ee),be=L._f.refs||[];if(ue?be.find(B=>B===ee):ee===L._f.ref)return;$e(r,E,{_f:{...L._f,...ue?{refs:[...be.filter(Bs),ee,...Array.isArray(le(i,E))?[{}]:[]],ref:{type:ee.type,name:E}}:{ref:ee}}}),C(E,!1,void 0,ee)}else L=le(r,E,{}),L._f&&(L._f.mount=!1),(t.shouldUnregister||R.shouldUnregister)&&!(Pd(a.array,E)&&o.action)&&a.unMount.add(E)}}},de=()=>t.shouldFocusError&&Vr(r,X,a.mount),ge=E=>{zt(E)&&(f.state.next({disabled:E}),Vr(r,(R,L)=>{const te=le(r,L);te&&(R.disabled=te._f.disabled||E,Array.isArray(te._f.refs)&&te._f.refs.forEach(K=>{K.disabled=te._f.disabled||E}))},0,!1))},Ee=(E,R)=>async L=>{let te;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let K=bt(s);if(a.disabled.size)for(const ee of a.disabled)$e(K,ee,void 0);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:ee,values:ue}=await H();n.errors=ee,K=ue}else await _(r);if(it(n.errors,"root"),yt(n.errors)){f.state.next({errors:{}});try{await E(K,L)}catch(ee){te=ee}}else R&&await R({...n.errors},L),de(),setTimeout(de);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:yt(n.errors)&&!te,submitCount:n.submitCount+1,errors:n.errors}),te)throw te},ye=(E,R={})=>{le(r,E)&&(Qe(R.defaultValue)?U(E,bt(le(i,E))):(U(E,R.defaultValue),$e(i,E,bt(R.defaultValue))),R.keepTouched||it(n.touchedFields,E),R.keepDirty||(it(n.dirtyFields,E),n.isDirty=R.defaultValue?z(E,bt(le(i,E))):z()),R.keepError||(it(n.errors,E),d.isValid&&S()),f.state.next({...n}))},xe=(E,R={})=>{const L=E?bt(E):i,te=bt(L),K=yt(E),ee=K?i:te;if(R.keepDefaultValues||(i=L),!R.keepValues){if(R.keepDirtyValues){const ue=new Set([...a.mount,...Object.keys(Nr(i,s))]);for(const be of Array.from(ue))le(n.dirtyFields,be)?$e(ee,be,le(s,be)):U(be,le(ee,be))}else{if(ca&&Qe(E))for(const ue of a.mount){const be=le(r,ue);if(be&&be._f){const B=Array.isArray(be._f.refs)?be._f.refs[0]:be._f.ref;if(Vi(B)){const Y=B.closest("form");if(Y){Y.reset();break}}}}r={}}s=t.shouldUnregister?R.keepDefaultValues?bt(i):{}:bt(ee),f.array.next({values:{...ee}}),f.values.next({values:{...ee}})}a={mount:R.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!R.keepIsValid||!!R.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:R.keepSubmitCount?n.submitCount:0,isDirty:K?!1:R.keepDirty?n.isDirty:!!(R.keepDefaultValues&&!hn(E,i)),isSubmitted:R.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:K?{}:R.keepDirtyValues?R.keepDefaultValues&&s?Nr(i,s):n.dirtyFields:R.keepDefaultValues&&E?Nr(i,E):R.keepDirty?n.dirtyFields:{},touchedFields:R.keepTouched?n.touchedFields:{},errors:R.keepErrors?n.errors:{},isSubmitSuccessful:R.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},W=(E,R)=>xe(Gt(E)?E(s):E,R);return{control:{register:re,unregister:ie,getFieldState:G,handleSubmit:Ee,setError:Z,_executeSchema:H,_getWatch:M,_getDirty:z,_updateValid:S,_removeUnmounted:I,_updateFieldArray:j,_updateDisabledField:se,_getFieldArray:A,_reset:xe,_resetDefaultValues:()=>Gt(t.defaultValues)&&t.defaultValues().then(E=>{W(E,t.resetOptions),f.state.next({isLoading:!1})}),_updateFormState:E=>{n={...n,...E}},_disableForm:ge,_subjects:f,_proxyFormState:d,_setErrors:T,get _fields(){return r},get _formValues(){return s},get _state(){return o},set _state(E){o=E},get _defaultValues(){return i},get _names(){return a},set _names(E){a=E},get _formState(){return n},set _formState(E){n=E},get _options(){return t},set _options(E){t={...t,...E}}},trigger:k,register:re,handleSubmit:Ee,watch:V,setValue:U,getValues:oe,reset:W,resetField:ye,clearErrors:y,unregister:ie,setError:Z,setFocus:(E,R={})=>{const L=le(r,E),te=L&&L._f;if(te){const K=te.refs?te.refs[0]:te.ref;K.focus&&(K.focus(),R.shouldSelect&&Gt(K.select)&&K.select())}},getFieldState:G}}function Ox(e={}){const t=Se.useRef(void 0),n=Se.useRef(void 0),[r,i]=Se.useState({isDirty:!1,isValidating:!1,isLoading:Gt(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Gt(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...zx(e),formState:r});const s=t.current.control;return s._options=e,fa({subject:s._subjects.state,next:o=>{$d(o,s._proxyFormState,s._updateFormState,!0)&&i({...s._formState})}}),Se.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),Se.useEffect(()=>{if(s._proxyFormState.isDirty){const o=s._getDirty();o!==r.isDirty&&s._subjects.state.next({isDirty:o})}},[s,r.isDirty]),Se.useEffect(()=>{e.values&&!hn(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,i(o=>({...o}))):s._resetDefaultValues()},[e.values,s]),Se.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),Se.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()}),Se.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),t.current.formState=Md(r,s),t.current}function Px(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 Dx=gx,Wd=x.createContext({}),fl=({...e})=>u.jsx(Wd.Provider,{value:{name:e.name},children:u.jsx(vx,{...e})}),ws=()=>{const e=x.useContext(Wd),t=x.useContext(qd),{getFieldState:n,formState:r}=vs(),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}},qd=x.createContext({}),Io=x.forwardRef(({className:e,...t},n)=>{const r=x.useId();return u.jsx(qd.Provider,{value:{id:r},children:u.jsx("div",{ref:n,className:q("space-y-2",e),...t})})});Io.displayName="FormItem";const To=x.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:i}=ws();return u.jsx(sr,{ref:n,className:q(r&&"text-destructive",e),htmlFor:i,...t})});To.displayName="FormLabel";const Ao=x.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:i,formMessageId:s}=ws();return u.jsx(yr,{ref:t,id:r,"aria-describedby":n?`${i} ${s}`:`${i}`,"aria-invalid":!!n,...e})});Ao.displayName="FormControl";const Gd=x.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=ws();return u.jsx("p",{ref:n,id:r,className:q("text-muted-foreground text-[0.8rem]",e),...t})});Gd.displayName="FormDescription";const zo=x.forwardRef(({className:e,children:t,...n},r)=>{const{error:i,formMessageId:s}=ws(),o=i?String(i==null?void 0:i.message):t;return o?u.jsx("p",{ref:r,id:s,className:q("text-destructive text-[0.8rem] font-medium",e),...n,children:o}):null});zo.displayName="FormMessage";function ma(){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 Yd=()=>({chatOpen:!1,scope:"global",model:"opus",contextAttachments:[],threads:{},activeThreadId:{}}),Rx=(e=Yd())=>nx()(rx(ix((t,n)=>({...e,toggleChat:()=>t(r=>({chatOpen:!r.chatOpen})),openChat:()=>t({chatOpen:!0}),closeChat:()=>t({chatOpen:!1}),addContext:r=>t(i=>({contextAttachments:[...i.contextAttachments,r]})),removeContext:r=>t(i=>({contextAttachments:i.contextAttachments.filter((s,o)=>o!==r)})),clearContext:()=>t({contextAttachments:[]}),setScope:r=>t({scope:r}),setModel:r=>t({model:r}),createThread:r=>{const i=crypto.randomUUID(),s=Date.now(),o={id:i,documentName:r,title:ma(),messages:[],createdAt:s,updatedAt:s};return t(a=>({threads:{...a.threads,[i]:o},activeThreadId:{...a.activeThreadId,[r]:i}})),i},deleteThread:r=>{const i=n(),s=i.threads[r];if(!s)return;const o=Object.fromEntries(Object.entries(i.threads).filter(([c])=>c!==r)),a=s.documentName,l={...i.activeThreadId};if(l[a]===r){const c=Object.values(o).filter(d=>d.documentName===a);c.length>0?(c.sort((d,f)=>f.updatedAt-d.updatedAt),l[a]=c[0].id):delete l[a]}t({threads:o,activeThreadId:l})},switchThread:r=>{const s=n().threads[r];s&&t(o=>({activeThreadId:{...o.activeThreadId,[s.documentName]:r}}))},updateThreadMessages:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,messages:i,updatedAt:Date.now()}}}:s})},updateThreadTitle:(r,i)=>{t(s=>{const o=s.threads[r];return o?{threads:{...s.threads,[r]:{...o,title:i}}}:s})},deleteThreadsForDocument:r=>{t(i=>{const s={...i.threads},o={...i.activeThreadId};for(const[a,l]of Object.entries(s))l.documentName===r&&delete s[a];return delete o[r],{threads:s,activeThreadId:o}})},renameThreadsForDocument:(r,i)=>{t(s=>{const o={...s.threads},a={...s.activeThreadId};for(const[l,c]of Object.entries(o))c.documentName===r&&(o[l]={...c,documentName:i});return r in a&&(a[i]=a[r],delete a[r]),{threads:o,activeThreadId:a}})},clearChat:()=>{t(r=>({contextAttachments:[]}))}}),{name:"chat-storage",version:1,storage:sx(()=>Gg),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}}))),Kd=x.createContext(void 0),Mx=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=Rx(Yd())),u.jsx(Kd.Provider,{value:t.current,children:e})},Re=e=>{const t=x.useContext(Kd);if(!t)throw new Error("useChatStore must be used within ChatStoreProvider");return ox(t,e)};function $x(e,t,n){return t.filter(r=>r.name!==n).every(r=>r.name!==e)}function Lx(e,t,n){const r={},i=[];e!=="delete"&&(r.name=vi.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=vi.Optional(vi.String({description:"Template selection"})));const s=vi.Object(r,{additionalProperties:!1,required:i.length>0?i:void 0});return{schema:s,validate:o=>{const a=[];if(!ug(s,o))for(const c of cg(s,o))a.push({path:c.path.replace(/^\//,""),message:c.message});const l=o;if(e!=="delete"&&l.name){const c=l.name.trim();c?(l.name=c,t(c)||a.push({path:"name",message:"Document with this name already exists"})):a.push({path:"name",message:"Name can't be empty"})}return e==="create"&&(n!=null&&n.length)&&l.template&&(n.some(c=>c.name===l.template)||a.push({path:"template",message:"You must select a valid template"})),{success:a.length===0,data:a.length===0?l:void 0,errors:a}}}}function Fx(e,t,n){return e==="create"?{name:"",template:t}:e==="update"?{name:n}:{}}const Bx=e=>({create:{title:e?"New Theme":"New Document",description:e?"Create a new theme from scratch or based on discovered themes.":"Create a new document from scratch or based on discovered documents.",button:"Create",buttonVariant:"default"},update:{title:"Rename Document",description:"Give your document a new name.",button:"Save",buttonVariant:"default"},delete:{title:"Are you absolutely sure?",description:"This action cannot be undone. Are you sure you want to permanently delete this document?",button:"Confirm",buttonVariant:"destructive"}}),Zn="__empty__";function Zx({mode:e,shouldReset:t,postSubmit:n,selectedName:r,discoveredDocuments:i,discoveredThemes:s,isTheme:o}){const[a,l]=x.useState(!1),[c,d]=x.useState(null),[f,p]=x.useState("idle"),{toast:h}=vr(),g=Bx(o),{documents:v,openTabs:S,createDocument:b,renameDocument:j,deleteDocument:m,openDocument:T,closeDocument:C}=Pe(oe=>oe),{updateTheme:w,removeTheme:N}=Eo(oe=>oe),H=Re(oe=>oe.renameThreadsForDocument),O=Re(oe=>oe.deleteThreadsForDocument),_=x.useMemo(()=>o?s||[]:i||[],[o,i,s]),I=x.useMemo(()=>{const oe={current:[],downstream:[]};return _.forEach(G=>{oe[G.location]&&oe[G.location].push(G)}),oe},[_]),z=x.useMemo(()=>_.map(oe=>({name:oe.name,type:"application/json",text:"",mtime:new Date,ctime:new Date,atime:new Date})),[_]),M=x.useMemo(()=>Lx(e,oe=>$x(oe,v,r),z),[e,v,r,z]),A=M.schema,P=x.useMemo(()=>{const oe=new Map;return _.forEach(G=>oe.set(G.path,G)),oe},[_]),D=Zn,U=Ox({resolver:Px(M.validate),defaultValues:Fx(e,void 0,r)}),[$,X]=x.useState(D);x.useEffect(()=>{if($&&$!==Zn&&e==="create"){const oe=P.get($);if(oe){d(null),p("loading");let G=!1;return fetch(`/api/discovery/${o?"themes":"documents"}/${encodeURIComponent(oe.name)}/content`).then(y=>{if(!y.ok)throw new Error(`Failed to fetch content: ${y.statusText}`);return y.text()}).then(y=>{if(G)return;const Z=JSON.parse(y);d(JSON.stringify(Z,null,2)),p("idle")}).catch(y=>{G||(console.error("Failed to copy template:",y),d(null),p("error"))}),()=>{G=!0}}}p("idle")},[$,e,P,o]),x.useEffect(()=>{t&&(U.reset(),d(null),p("idle"),X(D))},[U,t]);const k=U.handleSubmit(async({name:oe,template:G})=>{l(!0);try{if(await new Promise(y=>setTimeout(y,200)),e==="create"){const y=$?P.get($):_.find(ye=>ye.name===G);let Z,V=oe;if(!!$&&$!==Zn&&c===null){h({title:f==="loading"?"Template still loading":`Could not copy ${(y==null?void 0:y.name)??"the selected template"}`,description:f==="loading"?"Wait for the template to finish loading, then try again.":"Pick another template, or create an empty one instead.",variant:"destructive"});return}if(o){const ye=V.replace(/\.(json|theme)$/i,"").toLowerCase().replace(/\s+/g,"-"),xe=ot==="docx"?dg(ye):{name:ye,colors:{primary:"#2563EB",secondary:"#64748B",accent:"#F8FAFC",background:"#FFFFFF",text:"#334155"},fonts:{heading:"Calibri",body:"Calibri"},defaults:{fontSize:18,fontColor:"#334155"}};Z=c||JSON.stringify(xe,null,2);const W=`.${ot}.theme.json`;V.endsWith(W)||(V=V.replace(/\.(pptx|docx)\.theme\.json$/i,"").replace(/\.theme\.json$/i,"").replace(/\.json$/i,""),V+=W)}else{const ye=y;Z=c||JSON.stringify(ot==="docx"?{name:"docx",props:{theme:(ye==null?void 0:ye.theme)||"default",metadata:{title:(ye==null?void 0:ye.title)||V.replace(/\.(json|js)$/i,"")}},children:[{name:"section",props:{},children:[{name:"paragraph",props:{text:"Start writing your document content here..."}}]}]}:{name:"pptx",props:{title:(ye==null?void 0:ye.title)||V.replace(/\.(json|js)$/i,""),theme:(ye==null?void 0:ye.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 xe=ot==="docx"?".docx.json":".pptx.json";!V.endsWith(xe)&&!V.endsWith(".json")&&(V+=xe)}const se=V.match(/(\.(pptx|docx)(\.theme)?\.json|\.json)$/i),re=se?se[0]:"",de=V.slice(0,V.length-re.length);let ge=V,Ee=1;for(;v.some(ye=>ye.name===ge);)Ee++,ge=`${de} (${Ee})${re}`;V=ge,b(V,Z),T(V),o&&w(V,Z)}else if(e==="update"){const y=r,Z=oe,V=S.includes(y);V&&C(y),j(y,Z),H(y,Z),V&&T(Z)}else if(e==="delete"){const y=r;C(y),m(y),O(y),o&&N(y)}n()}finally{l(!1)}});return u.jsx(Dx,{...U,children:u.jsxs("form",{onSubmit:k,children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:g[e].title}),u.jsx(an,{children:g[e].description})]}),u.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[A.properties&&"name"in A.properties&&u.jsx(fl,{control:U.control,name:"name",render:({field:oe})=>u.jsxs(Io,{children:[u.jsx(To,{children:"Name"}),u.jsx(Ao,{children:u.jsx(fi,{placeholder:"Enter a name or select a template below",autoComplete:"off",...oe})}),u.jsx(zo,{})]})}),e==="create"&&u.jsx(fl,{control:U.control,name:"template",render:({field:oe})=>u.jsxs(Io,{children:[u.jsx(To,{children:o?"Base Theme":"Base Document"}),u.jsxs(qr,{onValueChange:G=>{if(G===Zn)oe.onChange(void 0),U.setValue("name",""),X(Zn),d(null);else{const y=P.get(G);y&&(oe.onChange(y.name),U.setValue("name",y.name),X(G))}},defaultValue:D,children:[u.jsx(Ao,{children:u.jsx(cr,{children:u.jsx(Gr,{placeholder:`Select a discovered ${o?"theme":"document"}`})})}),u.jsxs(dr,{className:"max-h-[300px]",children:[u.jsxs(Dn,{value:Zn,children:["Empty ",o?"theme":"document"]}),Object.entries(I).map(([G,y])=>y.length===0?null:u.jsxs(ux,{children:[u.jsx(Ad,{children:G==="current"?"📁 Current Directory":"📦 Project"}),y.map(Z=>{let V;return Z.title&&Z.title!==Z.name?V=Z.title:Z.description&&(V=Z.description.length>40?Z.description.substring(0,40)+"...":Z.description),u.jsx(Dn,{value:Z.path,className:"pl-6",children:u.jsxs("span",{className:"flex flex-col",children:[u.jsx("span",{className:"font-medium",children:Z.name}),V&&u.jsx("span",{className:"text-muted-foreground text-xs",children:V})]})},Z.path)})]},G))]})]}),u.jsxs(Gd,{children:["Start empty or select a discovered"," ",o?"theme":"document"," as a starting point"]}),u.jsx(zo,{})]})})]}),u.jsx(yn,{children:u.jsx(Ne,{type:"submit",variant:g[e].buttonVariant,disabled:a,children:a?u.jsxs(u.Fragment,{children:[u.jsx(sn,{size:"sm",className:"mr-2"}),e==="create"?"Creating...":e==="update"?"Saving...":"Deleting..."]}):g[e].button})})]})})}const Hi=Se.memo(Zx);function cn(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}function ga({text:e,query:t}){if(!t)return u.jsx(u.Fragment,{children:e});const n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?u.jsx(u.Fragment,{children:e}):u.jsxs(u.Fragment,{children:[e.slice(0,n),u.jsx("mark",{className:"bg-transparent p-0 font-semibold text-current",children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function Oo({children:e,count:t,actions:n,className:r}){return u.jsxs("div",{className:q("flex h-6 shrink-0 items-center gap-1.5 px-1 select-none",r),children:[u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] text-sidebar-foreground/70 uppercase",children:e}),t!==void 0&&u.jsx("span",{className:"text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:t}),n&&u.jsx("div",{className:"ml-auto flex items-center gap-0.5",children:n})]})}const $t=Se.forwardRef(({className:e,...t},n)=>u.jsx("button",{ref:n,type:"button",className:q("flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm","text-sidebar-foreground/55 transition-colors","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-40","[&>svg]:size-3.5",e),...t}));$t.displayName="RailIconButton";function pl({tone:e,className:t}){return u.jsx("span",{"aria-hidden":!0,className:q("size-1.5 shrink-0 rounded-full",e==="preview"?"bg-data-blue":"bg-warning",t)})}function hl({icon:e,label:t,onClick:n,hint:r}){return n?u.jsxs("button",{type:"button",onClick:n,title:r,className:q("flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm px-2","text-[13px] text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[u.jsx(e,{className:"size-3.5 shrink-0"}),u.jsx("span",{className:"truncate",children:t})]}):u.jsx("p",{className:"px-2 py-1 text-[12px] leading-tight text-sidebar-foreground/70",children:t})}const Vx=Wm,Ux=qm,Jx=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(Wc,{ref:i,className:q("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none",t&&"pl-8",e),...r,children:[n,u.jsx(Pn,{className:"ml-auto h-4 w-4"})]}));Jx.displayName=Wc.displayName;const Hx=x.forwardRef(({className:e,...t},n)=>u.jsx(qc,{ref:n,className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-lg",e),...t}));Hx.displayName=qc.displayName;const Xd=x.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{children:u.jsx(Uc,{ref:n,className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md",e),...t})}));Xd.displayName=Uc.displayName;const Qd=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Hc,{ref:r,className:q("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}));Qd.displayName=Hc.displayName;const Wx=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(Gc,{ref:i,className:q("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(Yc,{children:u.jsx(bn,{className:"h-4 w-4"})})}),t]}));Wx.displayName=Gc.displayName;const qx=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Kc,{ref:r,className:q("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(Yc,{children:u.jsx(bd,{className:"h-4 w-4 fill-current"})})}),t]}));qx.displayName=Kc.displayName;const Gx=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Xc,{ref:r,className:q("text-foreground px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Gx.displayName=Xc.displayName;const ef=x.forwardRef(({className:e,...t},n)=>u.jsx(Jc,{ref:n,className:q("bg-border -mx-1 my-1 h-px",e),...t}));ef.displayName=Jc.displayName;const tf=({className:e,...t})=>u.jsx("span",{className:q("text-muted-foreground ml-auto text-xs tracking-widest",e),...t});tf.displayName="ContextMenuShortcut";const ks=Ym,Ss=Km,Yx=x.forwardRef(({className:e,inset:t,children:n,...r},i)=>u.jsxs(rd,{ref:i,className:q("focus:bg-accent data-[state=open]:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,u.jsx(Pn,{className:"ml-auto"})]}));Yx.displayName=rd.displayName;const Kx=x.forwardRef(({className:e,...t},n)=>u.jsx(id,{ref:n,className:q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-lg",e),...t}));Kx.displayName=id.displayName;const hi=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Xm,{children:u.jsx(Qc,{ref:r,sideOffset:t,className:q("bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));hi.displayName=Qc.displayName;const Lt=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(ed,{ref:r,className:q("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}));Lt.displayName=ed.displayName;const Xx=x.forwardRef(({className:e,children:t,checked:n,...r},i)=>u.jsxs(sd,{ref:i,className:q("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(od,{children:u.jsx(bn,{className:"h-4 w-4"})})}),t]}));Xx.displayName=sd.displayName;const Qx=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ad,{ref:r,className:q("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(od,{children:u.jsx(bd,{className:"h-2 w-2 fill-current"})})}),t]}));Qx.displayName=ad.displayName;const nf=x.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(nd,{ref:r,className:q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));nf.displayName=nd.displayName;const fr=x.forwardRef(({className:e,...t},n)=>u.jsx(td,{ref:n,className:q("bg-muted -mx-1 my-1 h-px",e),...t}));fr.displayName=td.displayName;const rf=({className:e,...t})=>u.jsx("span",{className:q("ml-auto text-xs tracking-widest opacity-60",e),...t});rf.displayName="DropdownMenuShortcut";const sf=x.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>u.jsx(ld,{ref:i,decorative:n,orientation:t,className:q("bg-border shrink-0",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));sf.displayName=ld.displayName;const of=Pc,eb=Qm,tb=Dc,af=x.forwardRef(({className:e,...t},n)=>u.jsx(xs,{className:q("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t,ref:n}));af.displayName=xs.displayName;const nb=di("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"}}),xa=x.forwardRef(({side:e="right",className:t,children:n,...r},i)=>u.jsxs(tb,{children:[u.jsx(af,{}),u.jsxs(hs,{ref:i,className:q(nb({side:e}),t),...r,children:[u.jsxs(aa,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[u.jsx(xn,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]}),n]})]}));xa.displayName=hs.displayName;const rb=x.forwardRef(({className:e,...t},n)=>u.jsx(ms,{ref:n,className:q("text-foreground text-lg font-semibold",e),...t}));rb.displayName=ms.displayName;const ib=x.forwardRef(({className:e,...t},n)=>u.jsx(gs,{ref:n,className:q("text-muted-foreground text-sm",e),...t}));ib.displayName=gs.displayName;function Ur({className:e,...t}){return u.jsx("div",{className:q("bg-primary/10 animate-pulse rounded-md",e),...t})}const Vs=768,Us=1200;function lf(e){return typeof window<"u"?window.innerWidth<e:!1}function uf(){const[e,t]=x.useState(()=>lf(Vs));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Vs-1}px)`),r=()=>{t(window.innerWidth<Vs)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function sb(){const[e,t]=x.useState(()=>lf(Us));return x.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Us-1}px)`),r=()=>{t(window.innerWidth<Us)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}const ob="sidebar_state",ab=60*60*24*7,lb="16rem",ub="18rem",cb="3rem",db="b",cf=x.createContext(null);function _s(){const e=x.useContext(cf);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const df=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...o},a)=>{const l=uf(),[c,d]=x.useState(!1),[f,p]=x.useState(e),h=t??f,g=x.useCallback(j=>{const m=typeof j=="function"?j(h):j;n?n(m):p(m),document.cookie=`${ob}=${m}; path=/; max-age=${ab}`},[n,h]),v=x.useCallback(()=>l?d(j=>!j):g(j=>!j),[l,g,d]);x.useEffect(()=>{const j=T=>{var N;const C=T;if(!C)return!1;const w=(N=C.tagName)==null?void 0:N.toLowerCase();return w==="input"||w==="textarea"||w==="select"||C.isContentEditable?!0:!!(C.closest&&C.closest(".monaco-editor"))},m=T=>{const C=T.metaKey||T.ctrlKey,w=T.key.toLowerCase();if(C&&w===db){T.preventDefault(),v();return}C&&w==="s"&&!j(T.target)&&(T.preventDefault(),v())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[v]);const S=h?"expanded":"collapsed",b=x.useMemo(()=>({state:S,open:h,setOpen:g,isMobile:l,openMobile:c,setOpenMobile:d,toggleSidebar:v}),[S,h,g,l,c,d,v]);return u.jsx(cf.Provider,{value:b,children:u.jsx(fg,{delayDuration:0,children:u.jsx("div",{style:{"--sidebar-width":lb,"--sidebar-width-icon":cb,...i},className:q("group/sidebar-wrapper has-[[data-variant=inset]]:bg-sidebar flex min-h-svh w-full",r),ref:a,...o,children:s})})})});df.displayName="SidebarProvider";const ff=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},o)=>{const{isMobile:a,state:l,openMobile:c,setOpenMobile:d}=_s();return n==="none"?u.jsx("div",{className:q("bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col",r),ref:o,...s,children:i}):a?u.jsx(of,{open:c,onOpenChange:d,...s,children:u.jsx(xa,{"data-sidebar":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden",style:{"--sidebar-width":ub},side:e,children:u.jsx("div",{className:"flex h-full w-full flex-col",children:i})})}):u.jsxs("div",{ref:o,className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,children:[u.jsx("div",{className:q("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:q("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})})]})});ff.displayName="Sidebar";const fb=x.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=_s();return u.jsxs(Ne,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:q("h-7 w-7",e),onClick:s=>{t==null||t(s),i()},...n,children:[u.jsx(yg,{}),u.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});fb.displayName="SidebarTrigger";const pb=x.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=_s();return u.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:q("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})});pb.displayName="SidebarRail";const hb=x.forwardRef(({className:e,...t},n)=>u.jsx("main",{ref:n,className:q("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}));hb.displayName="SidebarInset";const mb=x.forwardRef(({className:e,...t},n)=>u.jsx(fi,{ref:n,"data-sidebar":"input",className:q("bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",e),...t}));mb.displayName="SidebarInput";const Po=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"header",className:q("flex flex-col gap-2 p-2",e),...t}));Po.displayName="SidebarHeader";const pf=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"footer",className:q("flex flex-col gap-2 p-2",e),...t}));pf.displayName="SidebarFooter";const gb=x.forwardRef(({className:e,...t},n)=>u.jsx(sf,{ref:n,"data-sidebar":"separator",className:q("bg-sidebar-border mx-2 w-auto",e),...t}));gb.displayName="SidebarSeparator";const Do=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"content",className:q("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Do.displayName="SidebarContent";const xb=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group",className:q("relative flex w-full min-w-0 flex-col p-2",e),...t}));xb.displayName="SidebarGroup";const bb=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?yr:"div";return u.jsx(i,{ref:r,"data-sidebar":"group-label",className:q("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})});bb.displayName="SidebarGroupLabel";const yb=x.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?yr:"button";return u.jsx(i,{ref:r,"data-sidebar":"group-action",className:q("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})});yb.displayName="SidebarGroupAction";const vb=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"group-content",className:q("w-full text-sm",e),...t}));vb.displayName="SidebarGroupContent";const Dr=x.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu",className:q("flex w-full min-w-0 flex-col gap-1",e),...t}));Dr.displayName="SidebarMenu";const hf=x.forwardRef(({className:e,...t},n)=>u.jsx("li",{ref:n,"data-sidebar":"menu-item",className:q("group/menu-item relative",e),...t}));hf.displayName="SidebarMenuItem";const wb=di("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"}}),mf=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...o},a)=>{const l=e?yr:"button",{isMobile:c,state:d}=_s(),f=u.jsx(l,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:q(wb({variant:n,size:r}),s),...o});return i?(typeof i=="string"&&(i={children:i}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:f}),u.jsx(Ye,{side:"right",align:"center",hidden:d!=="collapsed"||c,...i})]})):f});mf.displayName="SidebarMenuButton";const gf=x.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?yr:"button";return u.jsx(s,{ref:i,"data-sidebar":"menu-action",className:q("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})});gf.displayName="SidebarMenuAction";const kb=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:q("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}));kb.displayName="SidebarMenuBadge";const Sb=x.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=x.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return u.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:q("flex h-8 items-center gap-2 rounded-md px-2",e),...n,children:[t&&u.jsx(Ur,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),u.jsx(Ur,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});Sb.displayName="SidebarMenuSkeleton";const _b=x.forwardRef(({className:e,...t},n)=>u.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:q("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}));_b.displayName="SidebarMenuSub";const jb=x.forwardRef(({...e},t)=>u.jsx("li",{ref:t,...e}));jb.displayName="SidebarMenuSubItem";const Nb=x.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const o=e?yr:"a";return u.jsx(o,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:q("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})});Nb.displayName="SidebarMenuSubButton";function Mi(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 Eb=typeof window<"u"?navigator.userAgent.toUpperCase().indexOf("MAC")>=0:!1;function Cb({document:e,compact:t=!1,query:n=""}){const r=x.useRef(null),[i,s]=x.useState(!1),[o,a]=x.useState(!1),[l,c]=x.useState(!1),[d,f]=x.useState(!1),p=Pe(G=>G.openDocument),h=Pe(G=>G.documentTypes),g=Pe(G=>G.activeTab),v=rn(G=>G.name),S=rn(G=>G.text),b=rn(G=>G.isGenerating),m=(h[e.name]||"application/json+report")==="application/json+theme",T=g===e.name,[C,w]=x.useState(v),[N,H]=x.useState(S),O=100,_=0;x.useEffect(()=>{const G=setTimeout(()=>{v&&S?(w(v),H(S)):b||(w(""),H(""))},b?O:_);return()=>clearTimeout(G)},[v,S,b]);const I=C===e.name,z=G=>{var Z;const y=new Set;try{const V=JSON.parse(G);(Z=V.props)!=null&&Z.theme&&y.add(V.props.theme),V.children&&Array.isArray(V.children)&&V.children.forEach(ie=>{var se;ie.name==="docx"&&((se=ie.props)!=null&&se.theme)&&y.add(ie.props.theme)})}catch{}return y},M=x.useMemo(()=>{if(!m||!N)return!1;try{const G=JSON.parse(e.text),y=Yg(G);if(y)return z(N).has(y)}catch{}return!1},[m,N,e.text]),A=x.useCallback(()=>{c(!1)},[]),P=x.useCallback(()=>{f(!1)},[]),D=T?null:I?"preview":M?"in-use":null,U=T?"Editing":I?"In preview":M?"Used by preview":null,$=x.useMemo(()=>[{key:"open",label:"Open",shortcut:Eb?"⌘⏎":"⌃⏎",run:()=>p(e.name)},{key:"download",label:"Download…",separatorBefore:!0,run:()=>Mi(e.name,new Blob([e.text],{type:e.type}))},{key:"rename",label:"Rename…",shortcut:"⏎",separatorBefore:!0,run:()=>c(!0)},{key:"delete",label:"Delete",shortcut:"⌫",danger:!0,run:()=>f(!0)}],[e.name,e.text,e.type,p]),X=m?vg:yd,k=i||o,oe=u.jsxs(mf,{size:"sm",ref:r,"aria-label":U?`${e.name} — ${U}`:e.name,className:q("relative h-7 rounded-sm text-[13px] font-normal","text-sidebar-foreground/85 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground",t?"size-7 justify-center px-0":"gap-2 pr-7 pl-2",k&&"bg-sidebar-accent/60 text-sidebar-foreground",T&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),title:U?`${e.name} — ${U}`:e.name,onClick:()=>{p(e.name)},onKeyDown:G=>{var y;(G.ctrlKey||G.metaKey)&&G.key==="Enter"?(p(e.name),G.preventDefault()):G.key==="Enter"?(c(!0),G.preventDefault()):G.key==="Backspace"||G.key==="Delete"?(f(!0),G.preventDefault()):G.key==="Escape"&&((y=r.current)==null||y.blur(),G.preventDefault())},children:[T&&u.jsx("span",{"aria-hidden":!0,className:q("bg-primary absolute top-1 bottom-1 left-0 w-[2px] rounded-full",t&&"top-1.5 bottom-1.5")}),u.jsx(X,{className:q("size-3.5 shrink-0",m?"text-accent2":"text-sidebar-foreground/60",T&&!m&&"text-sidebar-accent-foreground/70")}),!t&&u.jsx("span",{className:"flex-1 truncate",children:u.jsx(ga,{text:e.name,query:n})}),t&&D&&u.jsx(pl,{tone:D,className:"absolute top-1 right-1 size-1.5 ring-2 ring-[hsl(var(--sidebar))]"})]});return u.jsxs(hf,{children:[u.jsxs(Vx,{onOpenChange:s,children:[u.jsx(Ux,{className:"block",children:t?u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:oe}),u.jsx(Ye,{side:"right",children:u.jsxs("div",{className:"text-xs",children:[u.jsx("div",{children:e.name}),u.jsx("div",{className:"opacity-70",children:U??(m?"Theme":"Document")})]})})]}):oe}),u.jsx(Xd,{className:"w-44",children:$.map(G=>u.jsxs(Se.Fragment,{children:[G.separatorBefore&&u.jsx(ef,{}),u.jsxs(Qd,{onClick:G.run,className:q(G.danger&&"text-destructive focus:text-destructive"),children:[G.label,G.shortcut&&u.jsx(tf,{children:G.shortcut})]})]},G.key))})]}),!t&&u.jsxs(u.Fragment,{children:[D&&u.jsx(pl,{tone:D,className:q("pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 transition-opacity","group-hover/menu-item:opacity-0 group-focus-within/menu-item:opacity-0",o&&"opacity-0")}),u.jsxs(ks,{onOpenChange:a,children:[u.jsx(Ss,{asChild:!0,children:u.jsx(gf,{showOnHover:!0,"aria-label":`Actions for ${e.name}`,className:"top-1 size-5 rounded-sm text-sidebar-foreground/55 hover:text-sidebar-foreground [&>svg]:size-3.5",children:u.jsx(vd,{})})}),u.jsx(hi,{side:"right",align:"start",className:"w-44",children:$.map(G=>u.jsxs(Se.Fragment,{children:[G.separatorBefore&&u.jsx(fr,{}),u.jsxs(Lt,{onClick:G.run,className:q(G.danger&&"text-destructive focus:text-destructive"),children:[G.label,G.shortcut&&u.jsx(rf,{children:G.shortcut})]})]},G.key))})]})]}),u.jsx(Ct,{open:l,onOpenChange:c,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:G=>{var y;G.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Hi,{mode:"update",shouldReset:!l,postSubmit:A,selectedName:e.name})})}),u.jsx(Ct,{open:d,onOpenChange:f,children:u.jsx(kt,{className:"sm:max-w-[425px]",onCloseAutoFocus:G=>{var y;G.preventDefault(),(y=r.current)==null||y.focus()},children:u.jsx(Hi,{mode:"delete",shouldReset:!d,postSubmit:P,selectedName:e.name})})})]})}const Si=Se.memo(Cb);function Ib(e,t=!1){const n=e.length;let r=0,i="",s=0,o=16,a=0,l=0,c=0,d=0,f=0;function p(m,T){let C=0,w=0;for(;C<m;){let N=e.charCodeAt(r);if(N>=48&&N<=57)w=w*16+N-48;else if(N>=65&&N<=70)w=w*16+N-65+10;else if(N>=97&&N<=102)w=w*16+N-97+10;else break;r++,C++}return C<m&&(w=-1),w}function h(m){r=m,i="",s=0,o=16,f=0}function g(){let m=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&Vn(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46)if(r++,r<e.length&&Vn(e.charCodeAt(r)))for(r++;r<e.length&&Vn(e.charCodeAt(r));)r++;else return f=3,e.substring(m,r);let T=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101))if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&Vn(e.charCodeAt(r))){for(r++;r<e.length&&Vn(e.charCodeAt(r));)r++;T=r}else f=3;return e.substring(m,T)}function v(){let m="",T=r;for(;;){if(r>=n){m+=e.substring(T,r),f=2;break}const C=e.charCodeAt(r);if(C===34){m+=e.substring(T,r),r++;break}if(C===92){if(m+=e.substring(T,r),r++,r>=n){f=2;break}switch(e.charCodeAt(r++)){case 34:m+='"';break;case 92:m+="\\";break;case 47:m+="/";break;case 98:m+="\b";break;case 102:m+="\f";break;case 110:m+=`
|
|
3
|
+
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:const N=p(4);N>=0?m+=String.fromCharCode(N):f=4;break;default:f=5}T=r;continue}if(C>=0&&C<=31)if(Cr(C)){m+=e.substring(T,r),f=2;break}else f=6;r++}return m}function S(){if(i="",f=0,s=r,l=a,d=c,r>=n)return s=n,o=17;let m=e.charCodeAt(r);if(Js(m)){do r++,i+=String.fromCharCode(m),m=e.charCodeAt(r);while(Js(m));return o=15}if(Cr(m))return r++,i+=String.fromCharCode(m),m===13&&e.charCodeAt(r)===10&&(r++,i+=`
|
|
4
|
+
`),a++,c=r,o=14;switch(m){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=v(),o=10;case 47:const T=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!Cr(e.charCodeAt(r));)r++;return i=e.substring(T,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;const C=n-1;let w=!1;for(;r<C;){const N=e.charCodeAt(r);if(N===42&&e.charCodeAt(r+1)===47){r+=2,w=!0;break}r++,Cr(N)&&(N===13&&e.charCodeAt(r)===10&&r++,a++,c=r)}return w||(r++,f=1),i=e.substring(T,r),o=13}return i+=String.fromCharCode(m),r++,o=16;case 45:if(i+=String.fromCharCode(m),r++,r===n||!Vn(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=g(),o=11;default:for(;r<n&&b(m);)r++,m=e.charCodeAt(r);if(s!==r){switch(i=e.substring(s,r),i){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return i+=String.fromCharCode(m),r++,o=16}}function b(m){if(Js(m)||Cr(m))return!1;switch(m){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function j(){let m;do m=S();while(m>=12&&m<=15);return m}return{setPosition:h,getPosition:()=>r,scan:t?j:S,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>s,getTokenLength:()=>r-s,getTokenStartLine:()=>l,getTokenStartCharacter:()=>s-d,getTokenError:()=>f}}function Js(e){return e===32||e===9}function Cr(e){return e===10||e===13}function Vn(e){return e>=48&&e<=57}var ml;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(ml||(ml={}));new Array(20).fill(0).map((e,t)=>" ".repeat(t));const Un=200;new Array(Un).fill(0).map((e,t)=>`
|
|
5
|
+
`+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>`\r
|
|
6
|
+
`+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>`
|
|
7
|
+
`+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>"\r"+" ".repeat(t)),new Array(Un).fill(0).map((e,t)=>`\r
|
|
8
|
+
`+" ".repeat(t));var Wi;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Wi||(Wi={}));function Tb(e,t=[],n=Wi.DEFAULT){let r={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(l){r.type==="property"&&(r.length=l-r.offset,r=r.parent)}function s(l){return r.children.push(l),l}Ab(e,{onObjectBegin:l=>{r=s({type:"object",offset:l,length:-1,parent:r,children:[]})},onObjectProperty:(l,c,d)=>{r=s({type:"property",offset:c,length:-1,parent:r,children:[]}),r.children.push({type:"string",value:l,offset:c,length:d,parent:r})},onObjectEnd:(l,c)=>{i(l+c),r.length=l+c-r.offset,r=r.parent,i(l+c)},onArrayBegin:(l,c)=>{r=s({type:"array",offset:l,length:-1,parent:r,children:[]})},onArrayEnd:(l,c)=>{r.length=l+c-r.offset,r=r.parent,i(l+c)},onLiteralValue:(l,c,d)=>{s({type:zb(l),offset:c,length:d,parent:r,value:l}),i(c+d)},onSeparator:(l,c,d)=>{r.type==="property"&&(l===":"?r.colonOffset=c:l===","&&i(c))},onError:(l,c,d)=>{t.push({error:l,offset:c,length:d})}},n);const a=r.children[0];return a&&delete a.parent,a}function Ab(e,t,n=Wi.DEFAULT){const r=Ib(e,!1),i=[];let s=0;function o(A){return A?()=>s===0&&A(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(A){return A?P=>s===0&&A(P,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(A){return A?P=>s===0&&A(P,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(A){return A?()=>{s>0?s++:A(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(s=1)}:()=>!0}function d(A){return A?()=>{s>0&&s--,s===0&&A(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const f=c(t.onObjectBegin),p=l(t.onObjectProperty),h=d(t.onObjectEnd),g=c(t.onArrayBegin),v=d(t.onArrayEnd),S=l(t.onLiteralValue),b=a(t.onSeparator),j=o(t.onComment),m=a(t.onError),T=n&&n.disallowComments,C=n&&n.allowTrailingComma;function w(){for(;;){const A=r.scan();switch(r.getTokenError()){case 4:N(14);break;case 5:N(15);break;case 3:N(13);break;case 1:T||N(11);break;case 2:N(12);break;case 6:N(16);break}switch(A){case 12:case 13:T?N(10):j();break;case 16:N(1);break;case 15:case 14:break;default:return A}}}function N(A,P=[],D=[]){if(m(A),P.length+D.length>0){let U=r.getToken();for(;U!==17;){if(P.indexOf(U)!==-1){w();break}else if(D.indexOf(U)!==-1)break;U=w()}}}function H(A){const P=r.getTokenValue();return A?S(P):(p(P),i.push(P)),w(),!0}function O(){switch(r.getToken()){case 11:const A=r.getTokenValue();let P=Number(A);isNaN(P)&&(N(2),P=0),S(P);break;case 7:S(null);break;case 8:S(!0);break;case 9:S(!1);break;default:return!1}return w(),!0}function _(){return r.getToken()!==10?(N(3,[],[2,5]),!1):(H(!1),r.getToken()===6?(b(":"),w(),M()||N(4,[],[2,5])):N(5,[],[2,5]),i.pop(),!0)}function I(){f(),w();let A=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(A||N(4,[],[]),b(","),w(),r.getToken()===2&&C)break}else A&&N(6,[],[]);_()||N(4,[],[2,5]),A=!0}return h(),r.getToken()!==2?N(7,[2],[]):w(),!0}function z(){g(),w();let A=!0,P=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(P||N(4,[],[]),b(","),w(),r.getToken()===4&&C)break}else P&&N(6,[],[]);A?(i.push(0),A=!1):i[i.length-1]++,M()||N(4,[],[4,5]),P=!0}return v(),A||i.pop(),r.getToken()!==4?N(8,[4],[]):w(),!0}function M(){switch(r.getToken()){case 3:return z();case 1:return I();case 10:return H(!0);default:return O()}}return w(),r.getToken()===17?n.allowEmptyContent?!0:(N(4,[],[]),!1):M()?(r.getToken()!==17&&N(9,[],[]),!0):(N(4,[],[]),!1)}function zb(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}var gl;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(gl||(gl={}));var xl;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(xl||(xl={}));const Ob=Tb;var bl;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(bl||(bl={}));const Pb=60,Db=/§jtoc:\d+§/g;function Ae(e,t){if(!(!e||e.type!=="object"||!e.children))for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children;if((r==null?void 0:r.value)===t)return i}}function st(e){return(e==null?void 0:e.type)==="string"&&typeof e.value=="string"?e.value:void 0}function Ro(e){return(e==null?void 0:e.type)==="number"&&typeof e.value=="number"?e.value:void 0}function Et(e){return(e==null?void 0:e.type)==="array"&&e.children?e.children:[]}function vt(e,t=Pb,n=!1){const r=e.replace(Db,"…"),i=n?r.replace(/\s*\n\s*/g," ").trim():r.split(`
|
|
9
|
+
`)[0].trim();return i.length>t?`${i.slice(0,t-1)}…`:i}function Rb(e){const t=Et(Ae(e,"columns"));if(t.length>0)return`${Math.max(0,...t.map(i=>Et(Ae(i,"cells")).length))}×${t.length}`;const n=Et(Ae(e,"rows"));if(n.length>0){const r=n[0],i=(r==null?void 0:r.type)==="array"?Et(r).length:Et(Ae(r,"cells")).length;return i>0?`${n.length}×${i}`:`${n.length} rows`}}function Mb(e){const t=st(Ae(e,"alt"));if(t)return vt(t);const n=st(Ae(e,"src"));if(n){if(n.startsWith("data:")){const i=n.slice(5).split(/[;,]/)[0];return i?`image (${i.split("/").pop()})`:"image"}const r=n.split(/[?#]/)[0].split("/").pop();if(r)return vt(r,40)}return"image"}function $b(e,t){var r;const n=st(Ae(t,"text"));switch(e){case"heading":{const i=Ro(Ae(t,"level"))??1;return{label:n?vt(n):"heading",detail:`H${i}`}}case"text":return{label:n?vt(n):"text",detail:st(Ae(t,"style"))};case"paragraph":return{label:n?vt(n):"paragraph"};case"chart":case"highcharts":{const i=st(Ae(t,"title"))??st(Ae(Ae(t,"options"),"title"));return{label:i?vt(i):e,detail:st(Ae(t,"type"))}}case"table":return{label:"table",detail:Rb(t)};case"image":return{label:Mb(t)};case"shape":return{label:st(Ae(t,"type"))??"shape"};case"list":{const i=Et(Ae(t,"items"));return{label:"list",detail:i.length>0?`${i.length} items`:void 0}}case"section":{const i=st(Ae(Ae(t,"meta"),"title"))??st(Ae(t,"title"));return{label:i?vt(i):"section"}}case"statistic":{const i=st(Ae(t,"value"))??((r=Ro(Ae(t,"value")))==null?void 0:r.toString()),s=st(Ae(t,"label"));return{label:vt(s??i??"statistic"),detail:i}}default:return{label:n?vt(n):e}}}function pr(e){if(e.type!=="object")return null;const t=st(Ae(e,"name"));return t?{name:t,props:Ae(e,"props"),childrenArr:Ae(e,"children")}:null}function Lb(e){let t;for(const n of Et(e)){const r=pr(n);if(!r)continue;const i=st(Ae(r.props,"text"));if(i){if(r.name==="heading"||r.name==="text")return vt(i,48);r.name==="paragraph"&&t===void 0&&(t=vt(i,48))}}return t}function qi(e,t,n){let{label:r,detail:i}=$b(t.name,t.props);return r===t.name&&t.childrenArr&&(r=Lb(t.childrenArr)??r),{id:"",kind:t.name,label:r,detail:i,start:e.offset,end:e.offset+e.length,children:xf(t.childrenArr),reorder:n}}function xf(e){if(!e||e.type!=="array")return[];const t=`arr@${e.offset}`,n=[];for(const r of Et(e)){const i=pr(r);i&&n.push(qi(r,i,{groupId:t,sliceStart:r.offset,sliceEnd:r.offset+r.length}))}return n}function Fb(e){const t=Ae(e,"props"),n=st(Ae(Ae(t,"meta"),"title"));if(n)return vt(n,48,!0);let r;const i=(a,l)=>{l&&(!r||a<r.rank)&&(r={rank:a,text:l})},s=Ae(t,"placeholders");if((s==null?void 0:s.type)==="object"&&s.children)for(const a of s.children){if(a.type!=="property"||!a.children)continue;const[l,c]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:"",f=c?pr(c):null,p=f?st(Ae(f.props,"text")):void 0;i(d==="title"?0:d==="subtitle"||d.startsWith("heading")?1:2,p)}const o=(a,l)=>{const c=pr(a);if(c){if(c.name==="text"||c.name==="heading"){const d=st(Ae(c.props,"text"));if(d){const f=st(Ae(c.props,"style"))??"";i(f==="title"?0:f.startsWith("heading")?1:2,d)}}if(l<1)for(const d of Et(c.childrenArr))o(d,l+1)}};for(const a of Et(Ae(e,"children")))o(a,0);return r?vt(r.text,48,!0):void 0}function Bb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[];let i=0;for(const s of Et(t)){const o=pr(s);if(!o)continue;const a={groupId:n,sliceStart:s.offset,sliceEnd:s.offset+s.length};o.name==="slide"?(i+=1,r.push({id:"",kind:"slide",label:Fb(s)??`Slide ${i}`,detail:`${i}`,start:s.offset,end:s.offset+s.length,children:xf(o.childrenArr),reorder:a})):r.push(qi(s,o,a))}return r}function Zb(e){const t=Ae(e,"children");if(!t||t.type!=="array")return[];const n=`arr@${t.offset}`,r=[],i=[];for(const o of Et(t)){const a=pr(o);if(!a)continue;const l={groupId:n,sliceStart:o.offset,sliceEnd:o.offset+o.length},c=()=>i.length?i[i.length-1].node.children:r;if(a.name==="heading"){const d=Ro(Ae(a.props,"level"))??1;for(;i.length&&i[i.length-1].level>=d;)i.pop();const f=qi(o,a,l);c().push(f),i.push({level:d,node:f})}else c().push(qi(o,a,l))}const s=o=>{o.children.forEach(s);const a=o.children[o.children.length-1];o.kind==="heading"&&a&&(o.end=Math.max(o.end,a.end),o.reorder&&a.reorder&&(o.reorder.sliceEnd=Math.max(o.reorder.sliceEnd,a.reorder.sliceEnd)))};return r.forEach(s),r}function yl(e){switch(e.type){case"string":return vt(String(e.value??""),24);case"number":case"boolean":return String(e.value);case"array":return`${Et(e).length} items`;case"object":return;default:return}}function Vb(e){if(e.type!=="object"||!e.children)return[];const t=[];for(const n of e.children){if(n.type!=="property"||!n.children)continue;const[r,i]=n.children,s=typeof(r==null?void 0:r.value)=="string"?r.value:void 0;if(!s||s==="$schema"||!i)continue;const o=[];if(i.type==="object"&&i.children)for(const a of i.children){if(a.type!=="property"||!a.children)continue;const[l,c]=a.children,d=typeof(l==null?void 0:l.value)=="string"?l.value:void 0;!d||!c||o.push({id:"",kind:"key",label:d,detail:yl(c),start:a.offset,end:a.offset+a.length,children:[]})}t.push({id:"",kind:"key",label:s,detail:o.length===0?yl(i):void 0,start:n.offset,end:n.offset+n.length,children:o})}return t}function vl(e,t,n){if(!e.trim())return[];const r=Ob(e,[],{allowTrailingComma:!0});if(!r)return[];const i=n==="theme"?Vb(r):t==="pptx"?Bb(r):Zb(r);return bf(i,""),i}function bf(e,t){e.forEach((n,r)=>{n.id=t?`${t}.${r}`:`${r}`,bf(n.children,n.id)})}function yf(e,t){const n=[];let r=e;for(;;){const i=r.find(s=>t>=s.start&&t<s.end);if(!i)return n;n.push(i.id),r=i.children}}function Ub(e,t){const n=new Set;for(const r of t)for(const i of yf(e,r))n.add(i);return n}function Jb(e,t,n,r){if(n===r||n<0||r<0||n>=t.length||r>=t.length)return null;const i=t.map(d=>d.reorder);if(i.some(d=>!d))return null;const s=i[0].groupId;if(i.some(d=>d.groupId!==s))return null;for(let d=1;d<i.length;d++)if(i[d].sliceStart<i[d-1].sliceEnd)return null;const o=i.map(d=>e.slice(d.sliceStart,d.sliceEnd)),a=[];for(let d=1;d<i.length;d++){const f=e.slice(i[d-1].sliceEnd,i[d].sliceStart);if((f.match(/,/g)??[]).length!==1)return null;a.push(f)}const l=o.map((d,f)=>f);l.splice(r,0,l.splice(n,1)[0]);let c="";return l.forEach((d,f)=>{c+=o[d],f<a.length&&(c+=a[f])}),{start:i[0].sliceStart,end:i[i.length-1].sliceEnd,text:c}}const Hb={slide:Cg,heading:Eg,text:ko,paragraph:Ng,chart:So,highcharts:So,table:jg,image:_g,shape:wd,list:Sg,toc:kg,section:Qa,columns:Qa,"text-box":ko,statistic:wg,key:wo};function Wb(e,t){let n=e,r=null;for(const i of t.split(".")){if(r=n[Number(i)]??null,!r)return null;n=r.children}return r}function qb(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(0,t)}function Gb(){const{activeTab:e,documentTypes:t}=Pe(ua(O=>({activeTab:O.activeTab,documentTypes:O.documentTypes}))),n=Pe(O=>{var _;return O.activeTab?(_=O.documents.find(I=>I.name===O.activeTab))==null?void 0:_.text:void 0}),r=qg(O=>e?O.editors.get(e)??null:null),i=e&&t[e]==="application/json+theme"?"theme":"document",[s,o]=x.useState(()=>{try{const O=localStorage.getItem("dev-env.outline-open");return O?O==="true":!0}catch{return!0}});x.useEffect(()=>{try{localStorage.setItem("dev-env.outline-open",String(s))}catch{}},[s]);const[a,l]=x.useState([]),[c,d]=x.useState(null),[f,p]=x.useState(()=>new Set),[h,g]=x.useState(()=>new Set),[v,S]=x.useState(null),b=x.useRef(a);b.current=a;const j=x.useRef(null),m=x.useRef(null),T=x.useCallback(()=>{var I;if(!e){l([]);return}const O=((I=r==null?void 0:r.editor.getModel())==null?void 0:I.getValue())??n??"",_=vl(O,ot,i);if(l(_),m.current!==e){m.current=e;const z=new Set;if(i==="document"&&ot==="docx")for(const M of _)M.kind==="heading"&&z.add(M.id);g(z),d(null)}},[e,r,n,i]);x.useEffect(()=>{T();const O=r==null?void 0:r.editor.getModel();if(!O)return;const _=tl(T,300),I=O.onDidChangeContent(()=>_());return()=>{_.cancel(),I.dispose()}},[T,r]),x.useEffect(()=>{if(!r)return;const{editor:O}=r,_=tl(()=>{const z=O.getModel(),M=O.getPosition();if(!z||!M)return;const A=z.getOffsetAt(M),P=yf(b.current,A);if(P.length===0){d(null);return}d(P[P.length-1]);const D=P.slice(0,-1);D.length&&g(U=>{if(D.every(X=>U.has(X)))return U;const $=new Set(U);for(const X of D)$.add(X);return $})},150),I=O.onDidChangeCursorPosition(()=>_());return()=>{_.cancel(),I.dispose()}},[r]),x.useEffect(()=>{if(!c||!j.current)return;const O=j.current.querySelector(`[data-oid="${CSS.escape(c)}"]`);O==null||O.scrollIntoView({block:"nearest"})},[c]),x.useEffect(()=>{if(!r){p(new Set);return}const{editor:O,monaco:_}=r,I=()=>{const M=O.getModel();if(!M)return;const A=_.editor.getModelMarkers({resource:M.uri}).filter(P=>P.severity===_.MarkerSeverity.Error).map(P=>M.getOffsetAt({lineNumber:P.startLineNumber,column:P.startColumn}));p(Ub(b.current,A))};I();const z=_.editor.onDidChangeMarkers(M=>{const A=O.getModel();A&&M.some(P=>P.toString()===A.uri.toString())&&I()});return()=>z.dispose()},[r,a]);const C=x.useCallback(O=>{g(_=>{const I=new Set(_);return I.has(O)?I.delete(O):I.add(O),I})},[]),w=x.useCallback(O=>{if(d(O.id),!r)return;const{editor:_,monaco:I}=r,z=_.getModel();if(!z)return;const M=z.getPositionAt(O.start),A=z.getPositionAt(O.end),P=new I.Range(M.lineNumber,M.column,A.lineNumber,A.column);_.revealRangeNearTopIfOutsideViewport(P,I.editor.ScrollType.Smooth),_.setPosition(M),_.focus();const D=_.deltaDecorations([],[{range:P,options:{className:"jto-outline-flash"}}]);window.setTimeout(()=>_.deltaDecorations(D,[]),700)},[r]),N=x.useCallback(O=>{var y;if(!r||!O.overId)return;const{editor:_,monaco:I,collapse:z}=r,M=_.getModel();if(!M)return;const A=M.getValue(),P=vl(A,ot,i),D=O.parentId?((y=Wb(P,O.parentId))==null?void 0:y.children)??[]:P,U=D.findIndex(Z=>Z.id===O.dragId),$=D.findIndex(Z=>Z.id===O.overId);if(U===-1||$===-1)return;let X=$+(O.overHalf==="after"?1:0);U<X&&(X-=1);const k=Jb(A,D,U,X);if(!k)return;const oe=M.getPositionAt(k.start),G=M.getPositionAt(k.end);_.executeEdits("outline-reorder",[{range:new I.Range(oe.lineNumber,oe.column,G.lineNumber,G.column),text:k.text}]),z==null||z.resyncDecorations()},[r,i]),H=x.useMemo(()=>{const O=[],_=(I,z,M)=>{var D,U;const A=(U=(D=I[0])==null?void 0:D.reorder)==null?void 0:U.groupId,P=I.length>1&&A!==void 0&&I.every($=>{var X;return((X=$.reorder)==null?void 0:X.groupId)===A});I.forEach($=>{const X=Hb[$.kind]??Ig,k=$.children.length>0,oe=h.has($.id),G=c===$.id,y=(v==null?void 0:v.overId)===$.id;O.push(u.jsxs("div",{"data-oid":$.id,role:"treeitem","aria-selected":G,"aria-expanded":k?oe:void 0,tabIndex:0,draggable:P,onClick:()=>w($),onKeyDown:Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),w($)),Z.key==="ArrowRight"&&k&&!oe&&C($.id),Z.key==="ArrowLeft"&&k&&oe&&C($.id)},onDragStart:Z=>{Z.dataTransfer.setData("text/plain",$.id),Z.dataTransfer.effectAllowed="move",S({dragId:$.id,parentId:M,overId:null,overHalf:"before"})},onDragOver:Z=>{if(!v||v.dragId===$.id||qb(v.dragId)!==M)return;Z.preventDefault(),Z.dataTransfer.dropEffect="move";const V=Z.currentTarget.getBoundingClientRect(),ie=Z.clientY<V.top+V.height/2?"before":"after";(v.overId!==$.id||v.overHalf!==ie)&&S({...v,overId:$.id,overHalf:ie})},onDrop:Z=>{Z.preventDefault(),v&&N({...v,overId:$.id,overHalf:v.overHalf}),S(null)},onDragEnd:()=>S(null),className:q("group flex h-6 w-full cursor-pointer items-center gap-1 rounded-sm pr-1","text-[12px] text-sidebar-foreground/80 transition-colors select-none","hover:bg-sidebar-accent hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none",G&&"bg-sidebar-accent font-medium text-sidebar-foreground",y&&(v==null?void 0:v.overHalf)==="before"&&"shadow-[inset_0_2px_0_hsl(var(--ring))]",y&&(v==null?void 0:v.overHalf)==="after"&&"shadow-[inset_0_-2px_0_hsl(var(--ring))]"),style:{paddingLeft:4+z*12},children:[k?u.jsx("span",{role:"button","aria-label":oe?"Collapse":"Expand",onClick:Z=>{Z.stopPropagation(),C($.id)},className:"flex size-3.5 shrink-0 items-center justify-center rounded-xs text-sidebar-foreground/55 hover:text-sidebar-foreground",children:u.jsx(Pn,{className:q("size-3 transition-transform",oe&&"rotate-90")})}):u.jsx("span",{className:"size-3.5 shrink-0"}),$.kind==="slide"&&u.jsx("span",{className:"w-3 shrink-0 text-right text-[10px] tabular-nums text-sidebar-foreground/50",children:$.detail}),u.jsx(X,{className:"size-3.5 shrink-0 text-sidebar-foreground/55"}),u.jsx("span",{className:"min-w-0 flex-1 truncate",children:$.label}),$.kind!=="slide"&&$.detail&&u.jsx("span",{className:"shrink-0 text-[10px] text-sidebar-foreground/50",children:$.detail}),f.has($.id)&&u.jsx("span",{"aria-label":"Contains validation errors",className:"bg-destructive size-1.5 shrink-0 rounded-full"})]},$.id)),k&&oe&&_($.children,z+1,$.id)})};return _(a,0,""),O},[a,h,c,f,v,w,C,N]);return e?u.jsxs("section",{className:"mt-3 shrink-0",children:[u.jsx(Oo,{count:a.length||void 0,actions:u.jsx($t,{"aria-label":s?"Collapse outline":"Expand outline","aria-expanded":s,onClick:()=>o(O=>!O),children:u.jsx(Pn,{className:q("transition-transform",s&&"rotate-90")})}),children:"Outline"}),s&&(a.length>0?u.jsx("div",{ref:j,role:"tree","aria-label":"Document outline",className:"max-h-[45vh] overflow-y-auto",children:H}):u.jsx("p",{className:"px-2 py-1 text-[12px] leading-tight text-sidebar-foreground/60",children:"No structure to show yet."}))]}):null}const Yb=x.memo(Gb);async function Kb(e,t){const n=JSON.stringify({name:e,props:t,children:[]},null,2);await navigator.clipboard.writeText(n)}const Yr=x.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ud,{ref:r,className:q("relative overflow-hidden",e),...n,children:[u.jsx(eg,{className:"h-full w-full rounded-[inherit]",children:t}),u.jsx(vf,{}),u.jsx(tg,{})]}));Yr.displayName=ud.displayName;const vf=x.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(cd,{ref:r,orientation:t,className:q("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(ng,{className:"bg-border relative flex-1 rounded-full"})}));vf.displayName=cd.displayName;function ba({className:e,...t}){return u.jsx(rg,{"data-slot":"switch",className:q("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-off focus-visible:ring-ring inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",e),...t,children:u.jsx(ig,{"data-slot":"switch-thumb",className:q("bg-background pointer-events-none block size-4 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const Xb=di("relative w-full rounded-sm border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-card text-foreground",destructive:"border-transparent bg-destructive-bg text-destructive-bg-foreground [&>svg]:text-destructive-bg-foreground",warning:"border-transparent bg-warning-bg text-warning-bg-foreground [&>svg]:text-warning-bg-foreground",success:"border-transparent bg-success-bg text-success-bg-foreground [&>svg]:text-success-bg-foreground",info:"border-transparent bg-data-blue-bg text-data-blue-bg-foreground [&>svg]:text-data-blue-bg-foreground"}},defaultVariants:{variant:"default"}}),Gi=x.forwardRef(({className:e,variant:t,...n},r)=>u.jsx("div",{ref:r,role:"alert",className:q(Xb({variant:t}),e),...n}));Gi.displayName="Alert";const Qb=x.forwardRef(({className:e,...t},n)=>u.jsx("h5",{ref:n,className:q("mb-1 font-medium leading-none tracking-tight",e),...t}));Qb.displayName="AlertTitle";const Yi=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:q("text-sm [&_p]:leading-relaxed",e),...t}));Yi.displayName="AlertDescription";const Ki=x.memo(({keyName:e,value:t,depth:n=0,isLast:r=!1})=>{const[i,s]=x.useState(n<2),o=t!==null&&typeof t=="object",a=Array.isArray(t),l=()=>s(!i),c=()=>t===null?u.jsx("span",{className:"text-muted-foreground",children:"null"}):t===void 0?u.jsx("span",{className:"text-muted-foreground",children:"undefined"}):typeof t=="boolean"?u.jsx("span",{className:"text-warning",children:String(t)}):typeof t=="number"?u.jsx("span",{className:"text-success",children:t}):typeof t=="string"?t.startsWith("http")?u.jsxs("span",{className:"text-data-blue",children:['"',t,'"']}):t.startsWith("#/")?u.jsxs("span",{className:"text-warning",children:['"',t,'"']}):u.jsxs("span",{className:"text-destructive",children:['"',t,'"']}):null,d=o?Object.keys(t).length:0;return u.jsxs("div",{className:q("text-sm",n>0&&"ml-4"),children:[u.jsxs("div",{className:"flex items-start hover:bg-muted/30 rounded-sm px-1 py-0.5",children:[o&&u.jsx("button",{onClick:l,className:"mr-1 hover:bg-muted rounded-sm p-0.5","aria-label":i?"Collapse":"Expand",children:i?u.jsx(ci,{className:"h-3 w-3"}):u.jsx(Pn,{className:"h-3 w-3"})}),!o&&u.jsx("span",{className:"w-4"}),e&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"text-data-blue",children:['"',e,'"']}),u.jsx("span",{className:"mx-1",children:":"})]}),o?u.jsxs("span",{className:"text-muted-foreground",children:[a?"[":"{",!i&&u.jsxs("span",{className:"mx-1 text-xs",children:[d," ",a?"items":"properties"]}),!i&&(a?"]":"}")]}):c(),!o&&!r&&u.jsx("span",{className:"text-muted-foreground",children:","})]}),o&&i&&u.jsxs("div",{className:"ml-4",children:[a?t.map((f,p)=>u.jsx(Ki,{keyName:String(p),value:f,depth:n+1,isLast:p===t.length-1},p)):Object.entries(t).map(([f,p],h,g)=>u.jsx(Ki,{keyName:f,value:p,depth:n+1,isLast:h===g.length-1},f)),u.jsx("div",{className:"ml-4",children:u.jsxs("span",{className:"text-muted-foreground",children:[a?"]":"}",!r&&","]})})]})]})});Ki.displayName="JsonNode";const Xi=x.memo(({schema:e,loading:t=!1,error:n,className:r})=>t?u.jsxs("div",{className:q("space-y-4",r),children:[u.jsx(Ur,{className:"h-8 w-64"}),u.jsx(Ur,{className:"h-4 w-full"}),u.jsx(Ur,{className:"h-64 w-full"})]}):n?u.jsx(Gi,{variant:"destructive",className:r,children:u.jsx(Yi,{children:n})}):e?u.jsx(Yr,{className:q("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(Ki,{value:e})})}):u.jsx(Gi,{className:r,children:u.jsx(Yi,{children:"No schema available"})}));Xi.displayName="SchemaViewer";function ey({plugins:e,initialFocusedPlugin:t}){var m,T;const n=Bt(C=>C.togglePlugin),r=Bt(C=>C.isPluginSelected),i=Bt(C=>C.selectedPlugins),s=Bt(C=>C.isApplyingPlugins),[o,a]=x.useState(null),[l,c]=x.useState(null),[d,f]=x.useState("properties");x.useEffect(()=>{if(t){const C=e.find(w=>w.name===t);if(C){a(C);return}}e.length>0&&!o&&a(e[0])},[t,e]);const p=x.useMemo(()=>{const C={current:[],downstream:[],upstream:[]};return e.forEach(w=>{C[w.location]&&C[w.location].push(w)}),C},[e]),h=async(C,w)=>{o&&(await Kb(o.name,C.props),c(w),setTimeout(()=>c(null),2e3))},g=C=>{switch(C){case"current":return"Current Directory";case"downstream":return"Project";case"upstream":return"Parent Directories";default:return C}},v=C=>{switch(C){case"current":return u.jsx(Dg,{className:"size-3"});case"downstream":return u.jsx(Pg,{className:"size-3"});case"upstream":return u.jsx(yd,{className:"size-3"});default:return null}},S=((m=o==null?void 0:o.schema)==null?void 0:m.properties)&&Object.keys(o.schema.properties).length>0,b=(T=o==null?void 0:o.schema)==null?void 0:T.jsonSchema,j=(o==null?void 0:o.examples)&&o.examples.length>0;return u.jsxs(u.Fragment,{children:[u.jsxs(Ut,{children:[u.jsxs(Jt,{className:"flex items-center gap-2",children:[u.jsx(Tg,{className:"size-5 text-warning"}),"Plugins",u.jsxs(Kt,{variant:"secondary",className:"font-normal",children:[i.size," active"]})]}),u.jsxs(an,{children:[e.length," plugin",e.length!==1?"s":""," discovered in your project"]})]}),u.jsxs("div",{className:"mt-3 flex gap-0 h-[600px] border rounded-lg overflow-hidden",children:[u.jsx("div",{className:"w-[240px] flex-none border-r bg-muted/30",children:u.jsx(Yr,{className:"h-full",children:u.jsx("div",{className:"p-2 space-y-3",children:Object.entries(p).map(([C,w])=>w.length===0?null:u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[v(C),g(C)]}),u.jsx("div",{className:"space-y-0.5",children:w.map(N=>{const H=r(N.name),O=(o==null?void 0:o.name)===N.name;return u.jsxs("button",{onClick:()=>a(N),className:q("w-full text-left px-2 py-1.5 rounded-md transition-colors cursor-pointer","flex items-center gap-2",O?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"),children:[u.jsx("div",{className:q("size-1.5 rounded-full flex-none transition-colors",H?"bg-warning":"bg-muted-foreground/30")}),u.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.name})]},N.name)})})]},C))})})}),o?u.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[u.jsxs("div",{className:"flex-none px-5 py-4 border-b bg-background",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("h3",{className:"text-base font-semibold truncate",children:o.name}),o.version&&u.jsxs(Kt,{variant:"outline",className:"font-mono text-[11px] flex-none",children:["v",o.version]})]}),o.description&&u.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:o.description})]}),u.jsxs("div",{className:"flex items-center gap-2 flex-none pt-0.5",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:r(o.name)?"On":"Off"}),u.jsx(ba,{checked:r(o.name),onCheckedChange:()=>n(o),disabled:s,"aria-label":`Toggle ${o.name}`})]})]}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-2 text-xs text-muted-foreground",children:[v(o.location),u.jsx("span",{children:g(o.location)}),u.jsx("span",{className:"text-muted-foreground/60 mx-1",children:"/"}),u.jsx("span",{className:"font-mono truncate",children:o.relativePath})]})]}),u.jsxs("div",{className:"flex-none px-5 pt-3 pb-0 flex gap-1 border-b bg-background",children:[S&&u.jsx("button",{onClick:()=>f("properties"),className:q("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="properties"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(wo,{className:"size-3.5"}),"Properties"]})}),b&&u.jsx("button",{onClick:()=>f("schema"),className:q("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="schema"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(Ag,{className:"size-3.5"}),"Schema"]})}),j&&u.jsx("button",{onClick:()=>f("examples"),className:q("px-3 py-1.5 text-sm font-medium rounded-t-md border-b-2 transition-colors cursor-pointer",d==="examples"?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[u.jsx(zg,{className:"size-3.5"}),"Examples",u.jsx(Kt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:o.examples.length})]})})]}),u.jsx(Yr,{className:"flex-1",children:u.jsxs("div",{className:"p-5",children:[d==="properties"&&S&&u.jsx("div",{className:"space-y-1",children:Object.entries(o.schema.properties).map(([C,w])=>u.jsx(ty,{name:C,prop:w},C))}),d==="schema"&&b&&u.jsx(Xi,{schema:o.schema.jsonSchema,loading:!1,className:"h-[420px]"}),d==="examples"&&j&&o.examples.map((C,w)=>u.jsxs("div",{className:q(w>0&&"mt-4 pt-4 border-t"),children:[u.jsxs("div",{className:"flex items-center justify-between mb-2",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[C.title&&u.jsx("span",{className:"font-medium text-sm truncate",children:C.title}),!C.title&&u.jsxs("span",{className:"text-sm text-muted-foreground",children:["Example ",w+1]})]}),u.jsx(Ne,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs flex-none",onClick:()=>h(C,w),children:l===w?u.jsxs(u.Fragment,{children:[u.jsx(Og,{className:"size-3 mr-1 text-success"}),"Copied"]}):u.jsxs(u.Fragment,{children:[u.jsx(bs,{className:"size-3 mr-1"}),"Copy"]})})]}),C.description&&u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:C.description}),u.jsx("pre",{className:"p-3 bg-muted rounded-md overflow-x-auto text-xs font-mono leading-relaxed",children:JSON.stringify(C.props,null,2)})]},w)),!S&&!b&&!j&&u.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[u.jsx(wo,{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 ty({name:e,prop:t}){var o;const[n,r]=x.useState(!1),i=t.description||t.enum||t.default!==void 0||t.items||t.properties,s=t.type||(t.enum?"enum":t.oneOf?"oneOf":"—");return u.jsxs("div",{className:"rounded-md border",children:[u.jsxs("button",{onClick:()=>i&&r(!n),className:q("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(ci,{className:"size-3 text-muted-foreground flex-none"}):u.jsx(Pn,{className:"size-3 text-muted-foreground flex-none"}):u.jsx("span",{className:"size-3 flex-none"}),u.jsx("span",{className:"font-mono font-medium text-xs",children:e}),u.jsx(Kt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 flex-none",children:s}),t.optional===!1&&u.jsx("span",{className:"text-[10px] text-destructive font-medium flex-none",children:"required"}),u.jsx("span",{className:"flex-1"}),t.default!==void 0&&u.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex-none",children:["= ",JSON.stringify(t.default)]})]}),n&&i&&u.jsxs("div",{className:"px-3 pb-2 pt-0 ml-5 text-xs space-y-1 text-muted-foreground",children:[t.description&&u.jsx("p",{children:t.description}),t.enum&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Values: "}),t.enum.map((a,l)=>u.jsxs("span",{children:[l>0&&", ",u.jsx("code",{className:"bg-muted px-1 rounded-sm",children:JSON.stringify(a)})]},l))]}),((o=t.items)==null?void 0:o.type)&&u.jsxs("p",{children:[u.jsx("span",{className:"font-medium text-foreground",children:"Items: "}),t.items.type]})]})]})}const ny=sg,ry=og,iy=ag,sy={current:"Current directory",downstream:"Project"};function Hs({id:e,label:t,count:n,open:r,onToggle:i,children:s}){return u.jsxs(ny,{open:r,children:[u.jsxs(ry,{onClick:()=>i(e),className:q("flex h-7 w-full cursor-pointer items-center gap-1.5 rounded-sm px-1","text-sidebar-foreground/70 transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none"),children:[u.jsx(Pn,{className:q("size-3 shrink-0 transition-transform duration-150 ease-out",r&&"rotate-90")}),u.jsx("span",{className:"text-[11px] font-medium tracking-[0.08em] uppercase",children:t}),u.jsx("span",{className:"ml-auto text-[11px] font-normal tabular-nums text-sidebar-foreground/65",children:n})]}),u.jsx(iy,{children:u.jsx("div",{className:"border-sidebar-border/70 mt-0.5 ml-[13px] border-l pl-1",children:s})})]})}function wl({location:e}){return u.jsx("div",{className:"px-2 pt-2 pb-0.5 text-[10px] tracking-[0.08em] text-sidebar-foreground/65 uppercase",children:sy[e]??e})}function kl({name:e,subtitle:t,added:n,query:r,onSelect:i}){return u.jsxs("button",{type:"button",onClick:i,title:t?`${e} — ${t}`:e,"aria-label":n?`Open ${e}`:`Add ${e} to workspace`,className:q("group/row flex h-7 w-full cursor-pointer items-center gap-2 rounded-sm px-2","text-[13px] transition-colors","hover:bg-sidebar-accent/60 hover:text-sidebar-foreground","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none","text-sidebar-foreground/70"),children:[u.jsx("span",{className:"truncate",children:u.jsx(ga,{text:e,query:r})}),n?u.jsx("span",{className:"ml-auto shrink-0 text-[10px] tracking-[0.06em] text-sidebar-foreground/65 uppercase",children:"Open"}):u.jsx(nn,{"aria-hidden":!0,className:"ml-auto size-3.5 shrink-0 text-sidebar-foreground/45 opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-visible/row:opacity-100"})]})}function oy({documents:e,themes:t,plugins:n,openNames:r,query:i,expandedGroups:s,onToggleGroup:o,onQuickAdd:a,onShowPluginDetails:l,isPluginSelected:c,onTogglePlugin:d,isApplyingPlugins:f,selectedPluginCount:p}){const h=b=>i?!0:s.has(b),g=x.useMemo(()=>Sl(e),[e]),v=x.useMemo(()=>Sl(t),[t]);return e.length>0||t.length>0||n.length>0?u.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.length>0&&u.jsx(Hs,{id:"library-documents",label:"Project documents",count:e.length,open:h("library-documents"),onToggle:o,children:g.map(([b,j])=>u.jsxs(Se.Fragment,{children:[g.length>1&&u.jsx(wl,{location:b}),j.map(m=>u.jsx(kl,{name:m.name,subtitle:m.title,added:r.has(m.name),query:i,onSelect:()=>a(m.name,!1)},m.path||m.name))]},b))}),t.length>0&&u.jsx(Hs,{id:"library-themes",label:"Project themes",count:t.length,open:h("library-themes"),onToggle:o,children:v.map(([b,j])=>u.jsxs(Se.Fragment,{children:[v.length>1&&u.jsx(wl,{location:b}),j.map(m=>u.jsx(kl,{name:m.name,subtitle:m.description,added:r.has(m.name),query:i,onSelect:()=>a(m.name,!0)},m.path||m.name))]},b))}),n.length>0&&u.jsx(Hs,{id:"library-plugins",label:"Plugins",count:`${p}/${n.length}`,open:h("library-plugins"),onToggle:o,children:n.map(b=>{const j=c(b.name),m=`plugin-switch-${b.filePath||b.name}`;return u.jsxs("div",{title:b.description?`${b.name} — ${b.description}`:b.name,className:q("group/row flex h-7 w-full items-center gap-1 rounded-sm pr-1 pl-2","transition-colors hover:bg-sidebar-accent/60"),children:[u.jsx("label",{htmlFor:m,className:q("flex h-7 min-w-0 flex-1 cursor-pointer items-center text-[13px]",j?"text-sidebar-foreground":"text-sidebar-foreground/70"),children:u.jsx("span",{className:"truncate",children:u.jsx(ga,{text:b.name,query:i})})}),u.jsx($t,{"aria-label":`Details for ${b.name}`,onClick:T=>{T.stopPropagation(),l(b.name)},className:"opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100",children:u.jsx(kd,{})}),u.jsx(ba,{id:m,checked:j,onCheckedChange:()=>d(b),disabled:f,className:"shrink-0","aria-label":`Toggle ${b.name} plugin`})]},b.filePath||b.name)})})]}):null}function Sl(e){const t=["current","downstream"],n=new Map;return e.forEach(r=>{const i=n.get(r.location);i?i.push(r):n.set(r.location,[r])}),[...n.entries()].sort(([r],[i])=>t.indexOf(r)-t.indexOf(i))}function wf({children:e,className:t}){return u.jsx("kbd",{"data-slot":"kbd",className:q("pointer-events-none inline-flex h-5 w-fit min-w-5 select-none items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground","[[data-slot=tooltip-content]_&]:bg-primary-foreground/20 [[data-slot=tooltip-content]_&]:text-primary-foreground",t),children:e})}function ay({children:e,className:t}){return u.jsx("span",{className:q("inline-flex items-center gap-0.5",t),children:e})}const _i=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function Kr({shortcut:e,className:t}){const r=e.split("+").map(i=>i.trim().toLowerCase()).map(i=>{switch(i){case"mod":return _i?"⌘":"Ctrl";case"shift":return _i?"⇧":"Shift";case"alt":return _i?"⌥":"Alt";case"ctrl":return _i?"⌃":"Ctrl";case"enter":return"↵";default:return i.toUpperCase()}});return u.jsx(ay,{className:t,children:r.map((i,s)=>u.jsx(wf,{children:i},s))})}function ly({className:e}={}){const{theme:t,setTheme:n}=md(),r=t==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,i=x.useCallback(()=>{n(r==="dark"?"light":"dark")},[r,n]);return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(Ne,{variant:"ghost",size:"icon",onClick:i,className:e,children:[u.jsx(Rg,{className:"hidden dark:block"}),u.jsx(Mg,{className:"block dark:hidden"}),u.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),u.jsx(Ye,{children:u.jsx("p",{children:"Toggle theme"})})]})}function uy({discoveryData:e,onToggleSidebar:t,isCollapsed:n=!1,isAnimating:r=!1}){const{documents:i,documentTypes:s,createDocument:o,openDocument:a}=Pe(ua(W=>({documents:W.documents,documentTypes:W.documentTypes,createDocument:W.createDocument,openDocument:W.openDocument}))),l=Eo(W=>W.updateTheme),c=Eo(W=>W.removeTheme),d=x.useContext(Ed),[f,p]=x.useState(!1),[h,g]=x.useState(!1),[v,S]=x.useState(!1),[b,j]=x.useState(null),m=Bt(W=>W.togglePlugin),T=Bt(W=>W.isPluginSelected),C=Bt(W=>W.selectedPlugins),w=Bt(W=>W.isApplyingPlugins),[N,H]=x.useState(!1),[O,_]=x.useState(new Set(["library-documents"])),[I,z]=x.useState(""),M=x.useRef(null),{toast:A}=vr(),P=i.filter(W=>s[W.name]!=="application/json+theme"),D=i.filter(W=>s[W.name]==="application/json+theme"),U=x.useCallback(()=>{p(!1)},[]),$=x.useCallback(()=>{g(!1)},[]),X=x.useRef(new Map);x.useEffect(()=>{const W=X.current,Oe=new Map;D.forEach(Q=>{Oe.set(Q.name,Q.text),W.get(Q.name)!==Q.text&&l(Q.name,Q.text)}),W.forEach((Q,ve)=>{Oe.has(ve)||c(ve)}),X.current=Oe},[D,l,c]);const k=x.useRef(!1);x.useEffect(()=>{if(k.current||!d)return;k.current=!0;const W=new Set(D.map(Q=>Q.name));Object.keys(d.getState().customThemes).forEach(Q=>{W.has(Q)||c(Q)})},[D,c,d]);const oe=x.useCallback(W=>{_(Oe=>{const Q=new Set(Oe);return Q.has(W)?Q.delete(W):Q.add(W),Q})},[]),{resolvedTheme:G}=md(),y=G==="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",Z=x.useCallback(async(W,Oe)=>{if(i.some(Q=>Q.name===W)){a(W);return}try{const Q=await fetch(`/api/discovery/${Oe?"themes":"documents"}/${encodeURIComponent(W)}/content`);if(!Q.ok)throw new Error(Q.statusText);const ve=await Q.text(),E=JSON.parse(ve);o(W,JSON.stringify(E,null,2)),a(W),A({title:`Added ${Oe?"theme":"document"}: ${W}`})}catch{A({title:"Failed to load",description:`Could not load ${W}`,variant:"destructive"})}},[i,o,a,A]);x.useEffect(()=>{if(n)return;const W=Oe=>{var E,R,L,te,K;if(Oe.key!=="/"||Oe.metaKey||Oe.ctrlKey||Oe.altKey)return;const Q=Oe.target,ve=(E=Q==null?void 0:Q.tagName)==null?void 0:E.toLowerCase();ve==="input"||ve==="textarea"||ve==="select"||Q!=null&&Q.isContentEditable||(R=Q==null?void 0:Q.closest)!=null&&R.call(Q,".monaco-editor")||(L=M.current)!=null&&L.closest('[aria-hidden="true"], [inert]')||(Oe.preventDefault(),(te=M.current)==null||te.focus(),(K=M.current)==null||K.select())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[n]);const V=I.trim(),ie=x.useMemo(()=>new Set(i.map(W=>W.name)),[i]),se=x.useMemo(()=>P.filter(W=>cn(W.name,V)),[P,V]),re=x.useMemo(()=>D.filter(W=>cn(W.name,V)),[D,V]),de=x.useMemo(()=>((e==null?void 0:e.documents)??[]).filter(W=>cn(W.name,V)||cn(W.title??"",V)),[e,V]),ge=x.useMemo(()=>((e==null?void 0:e.themes)??[]).filter(W=>cn(W.name,V)||cn(W.description??"",V)),[e,V]),Ee=x.useMemo(()=>((e==null?void 0:e.plugins)??[]).filter(W=>cn(W.name,V)||cn(W.description??"",V)),[e,V]),ye=V.length>0&&se.length===0&&re.length===0&&de.length===0&&ge.length===0&&Ee.length===0,xe=q("transition-opacity duration-150 ease-out",r?"opacity-0":"opacity-100");return u.jsxs(u.Fragment,{children:[u.jsxs(ff,{collapsible:"none",style:{"--sidebar-width":n?"3rem":"16rem"},children:[n?u.jsxs(u.Fragment,{children:[u.jsx(Po,{className:q("gap-0 p-1.5",xe),children:u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{className:"mx-auto size-7","aria-label":"Expand sidebar","aria-expanded":!1,onClick:t,children:u.jsx(Sd,{})})}),u.jsxs(Ye,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Expand sidebar"}),u.jsx(Kr,{shortcut:"mod+b"})]})]})}),u.jsxs(Do,{className:q("gap-2 px-1 py-1",xe),children:[u.jsxs(Dr,{className:"items-center gap-0.5",children:[P.map(W=>u.jsx(Si,{document:W,compact:!0},W.name)),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{className:"size-7","aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"right",children:"New document"})]})]}),u.jsx("div",{className:"bg-sidebar-border/70 mx-auto h-px w-6"}),u.jsxs(Dr,{className:"items-center gap-0.5",children:[D.map(W=>u.jsx(Si,{document:W,compact:!0},W.name)),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{className:"size-7","aria-label":"New theme",onClick:()=>g(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"right",children:"New theme"})]})]})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs(Po,{className:q("gap-0 p-2",xe),children:[u.jsxs("div",{className:"flex h-7 items-center justify-between gap-1",children:[u.jsx("a",{href:"/","aria-label":"JSON to Office home",className:"focus-visible:ring-sidebar-ring flex items-center rounded-sm pl-1 focus-visible:ring-1 focus-visible:outline-none",children:u.jsx("img",{src:y,alt:"Wiseair",className:"h-[18px] w-auto max-w-[110px] shrink-0"})}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"Collapse sidebar","aria-expanded":!0,onClick:t,children:u.jsx($g,{})})}),u.jsxs(Ye,{side:"right",className:"flex items-center gap-2",children:[u.jsx("span",{children:"Collapse sidebar"}),u.jsx(Kr,{shortcut:"mod+b"})]})]})]}),u.jsxs("div",{className:"relative mt-2",children:[u.jsx(Lg,{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-sidebar-foreground/40"}),u.jsx("input",{ref:M,type:"text",value:I,spellCheck:!1,autoComplete:"off",placeholder:"Filter files…","aria-label":"Filter documents, themes and plugins",onChange:W=>z(W.target.value),onKeyDown:W=>{W.key==="Escape"&&(W.preventDefault(),z(""),W.currentTarget.blur())},className:q("border-sidebar-border/70 bg-sidebar-accent/40 h-7 w-full rounded-sm border","pr-7 pl-7 text-[13px] text-sidebar-foreground transition-colors","placeholder:text-sidebar-foreground/60","focus-visible:border-sidebar-ring focus-visible:bg-sidebar-accent/60","focus-visible:ring-sidebar-ring focus-visible:ring-1 focus-visible:outline-none")}),V?u.jsx($t,{"aria-label":"Clear filter",onClick:()=>{var W;z(""),(W=M.current)==null||W.focus()},className:"absolute top-1/2 right-1 -translate-y-1/2",children:u.jsx(xn,{})}):u.jsx(wf,{className:"absolute top-1/2 right-1.5 h-4 min-w-4 -translate-y-1/2 bg-transparent px-0 text-[10px] text-sidebar-foreground/65",children:"/"})]})]}),u.jsx(Do,{className:q("gap-0 px-2 pb-2",xe),children:ye?u.jsxs("div",{className:"px-1 py-6 text-center",children:[u.jsxs("p",{className:"text-[13px] text-sidebar-foreground/70",children:["No files match “",V,"”"]}),u.jsx("button",{type:"button",onClick:()=>{var W;z(""),(W=M.current)==null||W.focus()},className:"text-sidebar-foreground/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring mt-1 cursor-pointer rounded-sm text-[12px] underline-offset-2 hover:underline focus-visible:ring-1 focus-visible:outline-none",children:"Clear filter"})]}):u.jsxs(u.Fragment,{children:[(se.length>0||!V)&&u.jsxs("section",{children:[u.jsx(Oo,{count:(V?se.length:P.length)||void 0,actions:u.jsxs(u.Fragment,{children:[ot==="docx"&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"Compare documents",disabled:P.length<2,onClick:()=>H(!0),children:u.jsx(xd,{})})}),u.jsx(Ye,{side:"bottom",children:P.length<2?"Compare needs two documents":"Compare documents (redline)"})]}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"New document",onClick:()=>p(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"bottom",children:"New document"})]})]}),children:"Documents"}),u.jsx(Dr,{className:"gap-0.5",children:se.length>0?se.map(W=>u.jsx(Si,{document:W,query:V},W.name)):u.jsx(hl,{icon:nn,label:"New document",onClick:()=>p(!0)})})]}),(re.length>0||!V)&&u.jsxs("section",{className:"mt-3",children:[u.jsx(Oo,{count:(V?re.length:D.length)||void 0,actions:u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx($t,{"aria-label":"New theme",onClick:()=>g(!0),children:u.jsx(nn,{})})}),u.jsx(Ye,{side:"bottom",children:"New theme"})]}),children:"Themes"}),u.jsx(Dr,{className:"gap-0.5",children:re.length>0?re.map(W=>u.jsx(Si,{document:W,query:V},W.name)):u.jsx(hl,{icon:nn,label:"New theme",onClick:()=>g(!0)})})]}),!V&&u.jsx(Yb,{}),(de.length>0||ge.length>0||Ee.length>0)&&u.jsx("div",{className:"border-sidebar-border/70 mt-3 border-t pt-2",children:u.jsx(oy,{documents:de,themes:ge,plugins:Ee,openNames:ie,query:V,expandedGroups:O,onToggleGroup:oe,onQuickAdd:Z,onShowPluginDetails:W=>{j(W),S(!0)},isPluginSelected:T,onTogglePlugin:m,isApplyingPlugins:w,selectedPluginCount:C.size})})]})})]}),u.jsx(pf,{className:q("border-sidebar-border/70 gap-0 border-t p-1.5",xe),children:u.jsx("div",{className:q("flex items-center",n?"justify-center":"justify-start"),children:u.jsx(ly,{className:"size-7 rounded-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&_svg]:size-3.5"})})})]}),u.jsx(Ct,{open:f,onOpenChange:p,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Hi,{mode:"create",shouldReset:!f,postSubmit:U,discoveredDocuments:(e==null?void 0:e.documents)||[]})})}),u.jsx(Ct,{open:h,onOpenChange:g,children:u.jsx(kt,{className:"sm:max-w-[525px]",children:u.jsx(Hi,{mode:"create",shouldReset:!h,postSubmit:$,discoveredThemes:(e==null?void 0:e.themes)||[],isTheme:!0})})}),u.jsx(Ct,{open:v,onOpenChange:W=>{S(W),W||j(null)},children:u.jsx(kt,{className:"max-h-[85vh] overflow-hidden sm:max-w-5xl",children:u.jsx(ey,{plugins:(e==null?void 0:e.plugins)||[],initialFocusedPlugin:b})})}),u.jsx(px,{open:N,onOpenChange:H})]})}const _l=x.memo(uy),cy=x.lazy(()=>gd(()=>import("./editor-h_FlzUyg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Editor})));function jl(){return u.jsx(x.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(sn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading editor..."})]})}),children:u.jsx(cy,{})})}const dy=x.lazy(()=>gd(()=>import("./preview-aCcyncRa.js"),__vite__mapDeps([12,1,3,4,5,6,7,8,9,10,11])).then(e=>({default:e.Preview})));function Nl(){return u.jsx(x.Suspense,{fallback:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center",children:[u.jsx(sn,{className:"w-8 h-8 mx-auto mb-2"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading preview..."})]})}),children:u.jsx(dy,{})})}const{createElement:hr,createContext:fy,forwardRef:kf,useCallback:gt,useContext:Sf,useEffect:zn,useImperativeHandle:_f,useLayoutEffect:py,useMemo:hy,useRef:wt,useState:or}=Oc,El=Oc[`useId${Math.random()}`.slice(0,5)],my=py,js=fy(null);js.displayName="PanelGroupContext";const On=my,gy=typeof El=="function"?El:()=>null;let xy=0;function ya(e=null){const t=gy(),n=wt(e||t||null);return n.current===null&&(n.current=""+xy++),e??n.current}function jf({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:s,id:o,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:p,style:h,tagName:g="div",...v}){const S=Sf(js);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:j,getPanelSize:m,getPanelStyle:T,groupId:C,isPanelCollapsed:w,reevaluatePanelConstraints:N,registerPanel:H,resizePanel:O,unregisterPanel:_}=S,I=ya(o),z=wt({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:I,idIsFromProps:o!==void 0,order:p});wt({didLogMissingDefaultSizeWarning:!1}),On(()=>{const{callbacks:A,constraints:P}=z.current,D={...P};z.current.id=I,z.current.idIsFromProps=o!==void 0,z.current.order=p,A.onCollapse=c,A.onExpand=d,A.onResize=f,P.collapsedSize=n,P.collapsible=r,P.defaultSize=i,P.maxSize=a,P.minSize=l,(D.collapsedSize!==P.collapsedSize||D.collapsible!==P.collapsible||D.maxSize!==P.maxSize||D.minSize!==P.minSize)&&N(z.current,D)}),On(()=>{const A=z.current;return H(A),()=>{_(A)}},[p,I,H,_]),_f(s,()=>({collapse:()=>{b(z.current)},expand:A=>{j(z.current,A)},getId(){return I},getSize(){return m(z.current)},isCollapsed(){return w(z.current)},isExpanded(){return!w(z.current)},resize:A=>{O(z.current,A)}}),[b,j,m,w,I,O]);const M=T(z.current,i);return hr(g,{...v,children:e,className:t,id:o,style:{...M,...h},"data-panel":"","data-panel-collapsible":r||void 0,"data-panel-group-id":C,"data-panel-id":I,"data-panel-size":parseFloat(""+M.flexGrow).toFixed(1)})}const Nf=kf((e,t)=>hr(jf,{...e,forwardedRef:t}));jf.displayName="Panel";Nf.displayName="forwardRef(Panel)";let Mo=null,An=null;function by(e,t){if(t){const n=(t&Af)!==0,r=(t&zf)!==0,i=(t&Of)!==0,s=(t&Pf)!==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 yy(){An!==null&&(document.head.removeChild(An),Mo=null,An=null)}function Ws(e,t){const n=by(e,t);Mo!==n&&(Mo=n,An===null&&(An=document.createElement("style"),document.head.appendChild(An)),An.innerHTML=`*{cursor: ${n}!important;}`)}function Ef(e){return e.type==="keydown"}function Cf(e){return e.type.startsWith("pointer")}function If(e){return e.type.startsWith("mouse")}function Ns(e){if(Cf(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(If(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function vy(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function wy(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 ky(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Tl(e),b:Tl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;je(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Il(Cl(n.a)),b:Il(Cl(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const Sy=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function _y(e){var t;const n=getComputedStyle((t=Tf(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function jy(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||_y(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"||Sy.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Cl(e){let t=e.length;for(;t--;){const n=e[t];if(je(n,"Missing node"),jy(n))return n}return null}function Il(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Tl(e){const t=[];for(;e;)t.push(e),e=Tf(e);return t}function Tf(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Af=1,zf=2,Of=4,Pf=8,Ny=vy()==="coarse";let Zt=[],ar=!1,mn=new Map,Es=new Map;const Xr=new Set;function Ey(e,t,n,r,i){var s;const{ownerDocument:o}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:i},l=(s=mn.get(o))!==null&&s!==void 0?s:0;return mn.set(o,l+1),Xr.add(a),Qi(),function(){var d;Es.delete(e),Xr.delete(a);const f=(d=mn.get(o))!==null&&d!==void 0?d:1;if(mn.set(o,f-1),Qi(),f===1&&mn.delete(o),Zt.includes(a)){const p=Zt.indexOf(a);p>=0&&Zt.splice(p,1),wa(),i("up",!0,null)}}}function Al(e){const{target:t}=e,{x:n,y:r}=Ns(e);ar=!0,va({target:t,x:n,y:r}),Qi(),Zt.length>0&&(es("down",e),e.preventDefault(),e.stopPropagation())}function Ir(e){const{x:t,y:n}=Ns(e);if(ar&&e.buttons===0&&(ar=!1,es("up",e)),!ar){const{target:r}=e;va({target:r,x:t,y:n})}es("move",e),wa(),Zt.length>0&&e.preventDefault()}function Jn(e){const{target:t}=e,{x:n,y:r}=Ns(e);Es.clear(),ar=!1,Zt.length>0&&e.preventDefault(),es("up",e),va({target:t,x:n,y:r}),wa(),Qi()}function va({target:e,x:t,y:n}){Zt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Xr.forEach(i=>{const{element:s,hitAreaMargins:o}=i,a=s.getBoundingClientRect(),{bottom:l,left:c,right:d,top:f}=a,p=Ny?o.coarse:o.fine;if(t>=c-p&&t<=d+p&&n>=f-p&&n<=l+p){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&ky(r,s)>0){let g=r,v=!1;for(;g&&!g.contains(s);){if(wy(g.getBoundingClientRect(),a)){v=!0;break}g=g.parentElement}if(v)return}Zt.push(i)}})}function qs(e,t){Es.set(e,t)}function wa(){let e=!1,t=!1;Zt.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:t=!0});let n=0;Es.forEach(r=>{n|=r}),e&&t?Ws("intersection",n):e?Ws("horizontal",n):t?Ws("vertical",n):yy()}function Qi(){mn.forEach((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Jn),n.removeEventListener("pointerdown",Al),n.removeEventListener("pointerleave",Ir),n.removeEventListener("pointermove",Ir)}),window.removeEventListener("pointerup",Jn),window.removeEventListener("pointercancel",Jn),Xr.size>0&&(ar?(Zt.length>0&&mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Jn),n.addEventListener("pointerleave",Ir),n.addEventListener("pointermove",Ir))}),window.addEventListener("pointerup",Jn),window.addEventListener("pointercancel",Jn)):mn.forEach((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",Al,{capture:!0}),n.addEventListener("pointermove",Ir))}))}function es(e,t){Xr.forEach(n=>{const{setResizeHandlerState:r}=n,i=Zt.includes(n);r(e,i,t)})}function Cy(){const[e,t]=or(0);return gt(()=>t(n=>n+1),[])}function je(e,t){if(!e)throw console.error(t),Error(t)}const ka=10;function Rn(e,t,n=ka){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function on(e,t,n=ka){return Rn(e,t,n)===0}function Nt(e,t,n){return Rn(e,t,n)===0}function Iy(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],s=t[r];if(!Nt(i,s,n))return!1}return!0}function nr({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];je(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:s,maxSize:o=100,minSize:a=0}=r;if(Rn(n,a)<0)if(s){const l=(i+a)/2;Rn(n,l)<0?n=i:n=a}else n=a;return n=Math.min(o,n),n=parseFloat(n.toFixed(ka)),n}function Rr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Nt(e,0))return t;const o=[...t],[a,l]=r;je(a!=null,"Invalid first pivot index"),je(l!=null,"Invalid second pivot index");let c=0;if(s==="keyboard"){{const f=e<0?l:a,p=n[f];je(p,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:v=0}=p;if(g){const S=t[f];if(je(S!=null,`Previous layout not found for panel index ${f}`),Nt(S,h)){const b=v-S;Rn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const f=e<0?a:l,p=n[f];je(p,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:v=0}=p;if(g){const S=t[f];if(je(S!=null,`Previous layout not found for panel index ${f}`),Nt(S,v)){const b=S-h;Rn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const f=e<0?1:-1;let p=e<0?l:a,h=0;for(;;){const v=t[p];je(v!=null,`Previous layout not found for panel index ${p}`);const b=nr({panelConstraints:n,panelIndex:p,size:100})-v;if(h+=b,p+=f,p<0||p>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-g:g}{let p=e<0?a:l;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(c),g=t[p];je(g!=null,`Previous layout not found for panel index ${p}`);const v=g-h,S=nr({panelConstraints:n,panelIndex:p,size:v});if(!Nt(g,S)&&(c+=g-S,o[p]=S,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(Iy(i,o))return i;{const f=e<0?l:a,p=t[f];je(p!=null,`Previous layout not found for panel index ${f}`);const h=p+c,g=nr({panelConstraints:n,panelIndex:f,size:h});if(o[f]=g,!Nt(g,h)){let v=h-g,b=e<0?l:a;for(;b>=0&&b<n.length;){const j=o[b];je(j!=null,`Previous layout not found for panel index ${b}`);const m=j+v,T=nr({panelConstraints:n,panelIndex:b,size:m});if(Nt(j,T)||(v-=T-j,o[b]=T),Nt(v,0))break;e>0?b--:b++}}}const d=o.reduce((f,p)=>p+f,0);return Nt(d,100)?o:i}function Ty({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,s=0,o=0;const a=n[0];je(a!=null,"No pivot index found"),t.forEach((f,p)=>{const{constraints:h}=f,{maxSize:g=100,minSize:v=0}=h;p===a?(r=v,i=g):(s+=v,o+=g)});const l=Math.min(i,100-s),c=Math.max(r,100-o),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function Qr(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Df(e,t,n=document){const i=Qr(e,n).findIndex(s=>s.getAttribute("data-panel-resize-handle-id")===t);return i??null}function Rf(e,t,n){const r=Df(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Mf(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 Cs(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function Ay(e,t,n,r=document){var i,s,o,a;const l=Cs(t,r),c=Qr(e,r),d=l?c.indexOf(l):-1,f=(i=(s=n[d])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null,p=(o=(a=n[d+1])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null;return[f,p]}function zy({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,panelGroupElement:s,setLayout:o}){wt({didWarnAboutMissingResizeHandle:!1}),On(()=>{if(!s)return;const a=Qr(n,s);for(let l=0;l<i.length-1;l++){const{valueMax:c,valueMin:d,valueNow:f}=Ty({layout:r,panelsArray:i,pivotIndices:[l,l+1]}),p=a[l];if(p!=null){const h=i[l];je(h,`No panel data found for index "${l}"`),p.setAttribute("aria-controls",h.id),p.setAttribute("aria-valuemax",""+Math.round(c)),p.setAttribute("aria-valuemin",""+Math.round(d)),p.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{a.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,i,s]),zn(()=>{if(!s)return;const a=t.current;je(a,"Eager values not found");const{panelDataArray:l}=a,c=Mf(n,s);je(c!=null,`No group found for id "${n}"`);const d=Qr(n,s);je(d,`No resize handles found for group id "${n}"`);const f=d.map(p=>{const h=p.getAttribute("data-panel-resize-handle-id");je(h,"Resize handle element has no handle id attribute");const[g,v]=Ay(n,h,l,s);if(g==null||v==null)return()=>{};const S=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const j=l.findIndex(m=>m.id===g);if(j>=0){const m=l[j];je(m,`No panel data found for index ${j}`);const T=r[j],{collapsedSize:C=0,collapsible:w,minSize:N=0}=m.constraints;if(T!=null&&w){const H=Rr({delta:Nt(T,C)?N-C:C-T,initialLayout:r,panelConstraints:l.map(O=>O.constraints),pivotIndices:Rf(n,h,s),prevLayout:r,trigger:"keyboard"});r!==H&&o(H)}}break}}};return p.addEventListener("keydown",S),()=>{p.removeEventListener("keydown",S)}});return()=>{f.forEach(p=>p())}},[s,e,t,n,r,i,o])}function zl(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 $f(e,t){const n=e==="horizontal",{x:r,y:i}=Ns(t);return n?r:i}function Oy(e,t,n,r,i){const s=n==="horizontal",o=Cs(t,i);je(o,`No resize handle element found for id "${t}"`);const a=o.getAttribute("data-panel-group-id");je(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=$f(n,e),d=Mf(a,i);je(d,`No group element found for id "${a}"`);const f=d.getBoundingClientRect(),p=s?f.width:f.height;return(c-l)/p*100}function Py(e,t,n,r,i,s){if(Ef(e)){const o=n==="horizontal";let a=0;e.shiftKey?a=100:i!=null?a=i:a=10;let l=0;switch(e.key){case"ArrowDown":l=o?0:a;break;case"ArrowLeft":l=o?-a:0;break;case"ArrowRight":l=o?a:0;break;case"ArrowUp":l=o?0:-a;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:Oy(e,t,n,r,s)}function Dy({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,i=100;for(let s=0;s<e.length;s++){const o=n[s];je(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;a!=null&&(r++,t[s]=a,i-=a)}for(let s=0;s<e.length;s++){const o=n[s];je(o,`Panel constraints not found for index ${s}`);const{defaultSize:a}=o;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[s]=c,i-=c}return t}function Hn(e,t,n){t.forEach((r,i)=>{const s=e[i];je(s,`Panel data not found for index ${i}`);const{callbacks:o,constraints:a,id:l}=s,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:p,onExpand:h,onResize:g}=o;g&&g(r,f),d&&(p||h)&&(h&&(f==null||on(f,c))&&!on(r,c)&&h(),p&&(f==null||!on(f,c))&&on(r,c)&&p())}})}function ji(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 Ry({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:s=3}){const o=n[i];let a;return o==null?a=e!=null?e.toPrecision(s):"1":r.length===1?a="1":a=o.toPrecision(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function My(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function Ol(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 Lf(e){return`react-resizable-panels:${e}`}function Ff(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 Bf(e,t){try{const n=Lf(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function $y(e,t,n){var r,i;const s=(r=Bf(e,n))!==null&&r!==void 0?r:{},o=Ff(t);return(i=s[o])!==null&&i!==void 0?i:null}function Ly(e,t,n,r,i){var s;const o=Lf(e),a=Ff(t),l=(s=Bf(e,i))!==null&&s!==void 0?s:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(o,JSON.stringify(l))}catch(c){console.error(c)}}function Pl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,o)=>s+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!Nt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const o=n[s];je(o!=null,`No layout data found for index ${s}`);const a=100/r*o;n[s]=a}let i=0;for(let s=0;s<t.length;s++){const o=n[s];je(o!=null,`No layout data found for index ${s}`);const a=nr({panelConstraints:t,panelIndex:s,size:o});o!=a&&(i+=o-a,n[s]=a)}if(!Nt(i,0))for(let s=0;s<t.length;s++){const o=n[s];je(o!=null,`No layout data found for index ${s}`);const a=o+i,l=nr({panelConstraints:t,panelIndex:s,size:a});if(o!==l&&(i-=l-o,n[s]=l,Nt(i,0)))break}return n}const Fy=100,Mr={getItem:e=>(Ol(Mr),Mr.getItem(e)),setItem:(e,t)=>{Ol(Mr),Mr.setItem(e,t)}},Dl={};function Zf({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:s=null,onLayout:o=null,keyboardResizeBy:a=null,storage:l=Mr,style:c,tagName:d="div",...f}){const p=ya(s),h=wt(null),[g,v]=or(null),[S,b]=or([]),j=Cy(),m=wt({}),T=wt(new Map),C=wt(0),w=wt({autoSaveId:e,direction:r,dragState:g,id:p,keyboardResizeBy:a,onLayout:o,storage:l}),N=wt({layout:S,panelDataArray:[],panelDataArrayChanged:!1});wt({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),_f(i,()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:y}=N.current;return y},setLayout:y=>{const{onLayout:Z}=w.current,{layout:V,panelDataArray:ie}=N.current,se=Pl({layout:y,panelConstraints:ie.map(re=>re.constraints)});zl(V,se)||(b(se),N.current.layout=se,Z&&Z(se),Hn(ie,se,m.current))}}),[]),On(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=g,w.current.id=p,w.current.onLayout=o,w.current.storage=l}),zy({committedValuesRef:w,eagerValuesRef:N,groupId:p,layout:S,panelDataArray:N.current.panelDataArray,setLayout:b,panelGroupElement:h.current}),zn(()=>{const{panelDataArray:y}=N.current;if(e){if(S.length===0||S.length!==y.length)return;let Z=Dl[e];Z==null&&(Z=My(Ly,Fy),Dl[e]=Z);const V=[...y],ie=new Map(T.current);Z(e,V,ie,S,l)}},[e,S,l]),zn(()=>{});const H=gt(y=>{const{onLayout:Z}=w.current,{layout:V,panelDataArray:ie}=N.current;if(y.constraints.collapsible){const se=ie.map(Ee=>Ee.constraints),{collapsedSize:re=0,panelSize:de,pivotIndices:ge}=jn(ie,y,V);if(je(de!=null,`Panel size not found for panel "${y.id}"`),!on(de,re)){T.current.set(y.id,de);const ye=Xn(ie,y)===ie.length-1?de-re:re-de,xe=Rr({delta:ye,initialLayout:V,panelConstraints:se,pivotIndices:ge,prevLayout:V,trigger:"imperative-api"});ji(V,xe)||(b(xe),N.current.layout=xe,Z&&Z(xe),Hn(ie,xe,m.current))}}},[]),O=gt((y,Z)=>{const{onLayout:V}=w.current,{layout:ie,panelDataArray:se}=N.current;if(y.constraints.collapsible){const re=se.map(W=>W.constraints),{collapsedSize:de=0,panelSize:ge=0,minSize:Ee=0,pivotIndices:ye}=jn(se,y,ie),xe=Z??Ee;if(on(ge,de)){const W=T.current.get(y.id),Oe=W!=null&&W>=xe?W:xe,ve=Xn(se,y)===se.length-1?ge-Oe:Oe-ge,E=Rr({delta:ve,initialLayout:ie,panelConstraints:re,pivotIndices:ye,prevLayout:ie,trigger:"imperative-api"});ji(ie,E)||(b(E),N.current.layout=E,V&&V(E),Hn(se,E,m.current))}}},[]),_=gt(y=>{const{layout:Z,panelDataArray:V}=N.current,{panelSize:ie}=jn(V,y,Z);return je(ie!=null,`Panel size not found for panel "${y.id}"`),ie},[]),I=gt((y,Z)=>{const{panelDataArray:V}=N.current,ie=Xn(V,y);return Ry({defaultSize:Z,dragState:g,layout:S,panelData:V,panelIndex:ie})},[g,S]),z=gt(y=>{const{layout:Z,panelDataArray:V}=N.current,{collapsedSize:ie=0,collapsible:se,panelSize:re}=jn(V,y,Z);return je(re!=null,`Panel size not found for panel "${y.id}"`),se===!0&&on(re,ie)},[]),M=gt(y=>{const{layout:Z,panelDataArray:V}=N.current,{collapsedSize:ie=0,collapsible:se,panelSize:re}=jn(V,y,Z);return je(re!=null,`Panel size not found for panel "${y.id}"`),!se||Rn(re,ie)>0},[]),A=gt(y=>{const{panelDataArray:Z}=N.current;Z.push(y),Z.sort((V,ie)=>{const se=V.order,re=ie.order;return se==null&&re==null?0:se==null?-1:re==null?1:se-re}),N.current.panelDataArrayChanged=!0,j()},[j]);On(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:y,onLayout:Z,storage:V}=w.current,{layout:ie,panelDataArray:se}=N.current;let re=null;if(y){const ge=$y(y,se,V);ge&&(T.current=new Map(Object.entries(ge.expandToSizes)),re=ge.layout)}re==null&&(re=Dy({panelDataArray:se}));const de=Pl({layout:re,panelConstraints:se.map(ge=>ge.constraints)});zl(ie,de)||(b(de),N.current.layout=de,Z&&Z(de),Hn(se,de,m.current))}}),On(()=>{const y=N.current;return()=>{y.layout=[]}},[]);const P=gt(y=>{let Z=!1;const V=h.current;return V&&window.getComputedStyle(V,null).getPropertyValue("direction")==="rtl"&&(Z=!0),function(se){se.preventDefault();const re=h.current;if(!re)return()=>null;const{direction:de,dragState:ge,id:Ee,keyboardResizeBy:ye,onLayout:xe}=w.current,{layout:W,panelDataArray:Oe}=N.current,{initialLayout:Q}=ge??{},ve=Rf(Ee,y,re);let E=Py(se,y,de,ge,ye,re);const R=de==="horizontal";R&&Z&&(E=-E);const L=Oe.map(ee=>ee.constraints),te=Rr({delta:E,initialLayout:Q??W,panelConstraints:L,pivotIndices:ve,prevLayout:W,trigger:Ef(se)?"keyboard":"mouse-or-touch"}),K=!ji(W,te);(Cf(se)||If(se))&&C.current!=E&&(C.current=E,!K&&E!==0?R?qs(y,E<0?Af:zf):qs(y,E<0?Of:Pf):qs(y,0)),K&&(b(te),N.current.layout=te,xe&&xe(te),Hn(Oe,te,m.current))}},[]),D=gt((y,Z)=>{const{onLayout:V}=w.current,{layout:ie,panelDataArray:se}=N.current,re=se.map(W=>W.constraints),{panelSize:de,pivotIndices:ge}=jn(se,y,ie);je(de!=null,`Panel size not found for panel "${y.id}"`);const ye=Xn(se,y)===se.length-1?de-Z:Z-de,xe=Rr({delta:ye,initialLayout:ie,panelConstraints:re,pivotIndices:ge,prevLayout:ie,trigger:"imperative-api"});ji(ie,xe)||(b(xe),N.current.layout=xe,V&&V(xe),Hn(se,xe,m.current))},[]),U=gt((y,Z)=>{const{layout:V,panelDataArray:ie}=N.current,{collapsedSize:se=0,collapsible:re}=Z,{collapsedSize:de=0,collapsible:ge,maxSize:Ee=100,minSize:ye=0}=y.constraints,{panelSize:xe}=jn(ie,y,V);xe!=null&&(re&&ge&&on(xe,se)?on(se,de)||D(y,de):xe<ye?D(y,ye):xe>Ee&&D(y,Ee))},[D]),$=gt((y,Z)=>{const{direction:V}=w.current,{layout:ie}=N.current;if(!h.current)return;const se=Cs(y,h.current);je(se,`Drag handle element not found for id "${y}"`);const re=$f(V,Z);v({dragHandleId:y,dragHandleRect:se.getBoundingClientRect(),initialCursorPosition:re,initialLayout:ie})},[]),X=gt(()=>{v(null)},[]),k=gt(y=>{const{panelDataArray:Z}=N.current,V=Xn(Z,y);V>=0&&(Z.splice(V,1),delete m.current[y.id],N.current.panelDataArrayChanged=!0,j())},[j]),oe=hy(()=>({collapsePanel:H,direction:r,dragState:g,expandPanel:O,getPanelSize:_,getPanelStyle:I,groupId:p,isPanelCollapsed:z,isPanelExpanded:M,reevaluatePanelConstraints:U,registerPanel:A,registerResizeHandle:P,resizePanel:D,startDragging:$,stopDragging:X,unregisterPanel:k,panelGroupElement:h.current}),[H,g,r,O,_,I,p,z,M,U,A,P,D,$,X,k]),G={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return hr(js.Provider,{value:oe},hr(d,{...f,children:t,className:n,id:s,ref:h,style:{...G,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const Vf=kf((e,t)=>hr(Zf,{...e,forwardedRef:t}));Zf.displayName="PanelGroup";Vf.displayName="forwardRef(PanelGroup)";function Xn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function jn(e,t,n){const r=Xn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],o=n[r];return{...t.constraints,panelSize:o,pivotIndices:s}}function By({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){zn(()=>{if(e||n==null||r==null)return;const i=Cs(t,r);if(i==null)return;const s=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const a=i.getAttribute("data-panel-group-id");je(a,`No group element found for id "${a}"`);const l=Qr(a,r),c=Df(a,t,r);je(c!==null,`No resize element found for id "${t}"`);const d=o.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[d].focus();break}}};return i.addEventListener("keydown",s),()=>{i.removeEventListener("keydown",s)}},[r,e,t,n])}function Uf({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:s,onDragging:o,onFocus:a,style:l={},tabIndex:c=0,tagName:d="div",...f}){var p,h;const g=wt(null),v=wt({onDragging:o});zn(()=>{v.current.onDragging=o});const S=Sf(js);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:b,groupId:j,registerResizeHandle:m,startDragging:T,stopDragging:C,panelGroupElement:w}=S,N=ya(i),[H,O]=or("inactive"),[_,I]=or(!1),[z,M]=or(null),A=wt({state:H});On(()=>{A.current.state=H}),zn(()=>{if(n)M(null);else{const $=m(N);M(()=>$)}},[n,N,m]);const P=(p=r==null?void 0:r.coarse)!==null&&p!==void 0?p:15,D=(h=r==null?void 0:r.fine)!==null&&h!==void 0?h:5;return zn(()=>{if(n||z==null)return;const $=g.current;return je($,"Element ref not attached"),Ey(N,$,b,{coarse:P,fine:D},(k,oe,G)=>{if(oe)switch(k){case"down":{O("drag"),je(G,'Expected event to be defined for "down" action'),T(N,G);const{onDragging:y}=v.current;y&&y(!0);break}case"move":{const{state:y}=A.current;y!=="drag"&&O("hover"),je(G,'Expected event to be defined for "move" action'),z(G);break}case"up":{O("hover"),C();const{onDragging:y}=v.current;y&&y(!1);break}}else O("inactive")})},[P,b,n,D,m,N,z,T,C]),By({disabled:n,handleId:N,resizeHandler:z,panelGroupElement:w}),hr(d,{...f,children:e,className:t,id:i,onBlur:()=>{I(!1),s==null||s()},onFocus:()=>{I(!0),a==null||a()},ref:g,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":b,"data-panel-group-id":j,"data-resize-handle":"","data-resize-handle-active":H==="drag"?"pointer":_?"keyboard":void 0,"data-resize-handle-state":H,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":N})}Uf.displayName="PanelResizeHandle";const Zy=({className:e,...t})=>u.jsx(Vf,{className:q("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Gs=Nf,Rl=({withHandle:e,className:t,...n})=>u.jsx(Uf,{className:q("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(Fg,{className:"h-2.5 w-2.5"})})}),Jf=x.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:q("flex min-h-[80px] w-full rounded-sm border border-input bg-background px-3 py-2 text-sm shadow-xs","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Jf.displayName="Textarea";class Vy{constructor(t){Xa(this,"client");this.client=ax.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 Uy=new Vy;function Jy(){const e=x.useRef(null),t=x.useCallback(async(r,i,s,o,a)=>{e.current&&e.current.abort();const l=new AbortController;e.current=l;try{o==null||o("parsing","Validating JSON structure...");let c;try{c=JSON.parse(i)}catch(w){throw new Error(`Invalid JSON: ${w instanceof Error?w.message:"Unknown parse error"}`)}o==null||o("building",`Building ${wi.toLowerCase()} structure...`);const d={jsonDefinition:c,options:{...a,sourceName:r}};d.customThemes=s??{},o==null||o("rendering",`Generating ${ot.toUpperCase()} content...`);const f={"Content-Type":"application/json"};a!=null&&a.bypassCache&&(f["X-Bypass-Cache"]="true");const p=await fetch(hd.generate,{method:"POST",headers:f,body:JSON.stringify(d),signal:l.signal}),h=await p.json();if(!p.ok||!h.success){const w=h.error||h.message||`API request failed with status: ${p.status}`;throw new Error(w)}const{data:g,cache:v,warnings:S}=h,b=v.status==="HIT"?"HIT":v.status==="MISS"?"MISS":"UNKNOWN",j=b==="HIT"?`Served from cache (Hit rate: ${v.hitRate})`:`Generated fresh ${wi.toLowerCase()}`;o==null||o("finalizing",j);const m=globalThis.atob(g.document),T=new Uint8Array(m.length);for(let w=0;w<m.length;w++)T[w]=m.charCodeAt(w);const C=new Blob([T],{type:g.contentType});if(C.size===0)throw new Error(`Received empty ${wi.toLowerCase()} from API`);return{name:r,text:i,blob:C,filename:g.filename,fileId:g.fileId,cacheStatus:b,cacheHitRate:v.hitRate,warnings:S}}catch(c){throw c instanceof Error&&c.name==="AbortError"?new Error(`${wi} generation was cancelled`):c}finally{e.current===l&&(e.current=null)}},[]),n=x.useCallback(()=>{e.current&&(e.current.abort(),e.current=null)},[]);return{generatePresentation:t,generateDocument:t,cancelGeneration:n}}function Hy(e){if(!e||e.length===0)return null;const t=[{name:"heading",props:{level:1,text:"Document Generation Warnings"}},{name:"paragraph",props:{text:`${e.length} warning(s) were generated during document processing.`,spacing:{after:240}}}],n=new Map;for(const r of e){const i=n.get(r.component)||[];i.push(r),n.set(r.component,i)}for(const[r,i]of n.entries()){t.push({name:"heading",props:{level:2,text:`Component: ${r}`}});const s=[];for(const o of i){let a=o.message;if(o.context&&Object.keys(o.context).length>0){const l=Object.entries(o.context).map(([c,d])=>`${c}: ${JSON.stringify(d)}`).join(", ");a+=` (${l})`}s.push(a)}t.push({name:"list",props:{items:s,spacing:{after:120}}})}return{name:"docx",props:{metadata:{title:"Generation Warnings"},theme:"minimal"},children:t}}function Wy({open:e,onClose:t,nonSafeFonts:n,onChoose:r}){const[i,s]=Se.useState("custom");Se.useEffect(()=>{e&&s("custom")},[e]);const o=n.length===1?n[0]:n.slice(0,3).join(", ")+(n.length>3?` +${n.length-3} more`:""),a=[{value:"custom",title:"Keep custom fonts",desc:"Recipients with the font installed see the authored typeface. Others get a generic fallback."},{value:"substitute",title:"Convert to safe fonts",desc:"Rewrite non-safe families to Calibri / Georgia / Consolas so every recipient sees the same glyphs."}];return u.jsx(Ct,{open:e,onOpenChange:l=>!l&&t(),children:u.jsxs(kt,{className:"max-w-md",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Non-safe fonts in this document"}),u.jsxs(an,{children:[o," ",n.length===1?"is":"are"," not in the built-in safe list. Choose how to export."]})]}),u.jsx("div",{className:"grid gap-2 py-2",children:a.map(l=>{const c=i===l.value;return u.jsxs("button",{type:"button",onClick:()=>s(l.value),className:`text-left rounded-md border px-3 py-2 transition-colors ${c?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:`h-3.5 w-3.5 rounded-full border flex items-center justify-center ${c?"border-primary":"border-muted-foreground/50"}`,children:c&&u.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary"})}),u.jsx("span",{className:"text-sm font-medium",children:l.title})]}),u.jsx("p",{className:"mt-1 text-xs text-muted-foreground pl-6",children:l.desc})]},l.value)})}),u.jsxs(yn,{children:[u.jsx(Ne,{variant:"outline",size:"sm",onClick:t,children:"Cancel"}),u.jsx(Ne,{size:"sm",onClick:()=>{r(i),t()},children:"Download"})]})]})})}const Ml=ot==="docx"?["docxjs","LibreOffice"]:["LibreOffice"],Ys={docxjs:["⚡","(Fast) works in the browser — lower fidelity"],LibreOffice:["🖨️","(High fidelity) converts to PDF locally with LibreOffice"]};function qy({name:e,blob:t,displayReloadButton:n,iframeRef:r,autoReload:i,onToggleAutoReload:s,onManualRender:o,isGenerating:a,isRendering:l,onShowCacheMetrics:c,onShowSchemas:d,onShowFonts:f,documentText:p,editorDocumentText:h,warnings:g,renderingLibrary:v,setRenderingLibrary:S,onToggleChat:b,chatOpen:j,onTogglePreview:m,previewOpen:T}){const C=v!=="docxjs",[w,N]=x.useState(!1),[H,O]=x.useState(!1),[_,I]=x.useState(!1),[z,M]=x.useState(!1),[A,P]=x.useState(!1),[D,U]=x.useState(!1),[$,X]=x.useState(null),{toast:k}=vr(),{generateDocument:oe}=Jy(),G=x.useContext(Ed),y=x.useCallback(()=>{const Q={},{customThemes:ve}=G.getState();return Object.values(ve).forEach(E=>{E.valid&&E.parsed&&(Q[E.name]=E.parsed)}),Q},[G]),Z=Se.useMemo(()=>{if(!p)return[];try{const Q=JSON.parse(p);return[...(ot==="pptx"?pg:hg)(Q)].filter(E=>!mg(E))}catch{return[]}},[p]),[V,ie]=x.useState(!1),se=x.useCallback(async()=>{if(t){N(!0);try{await new Promise(Q=>setTimeout(Q,100)),Mi(`${e}${jr}`,t)}finally{setTimeout(()=>N(!1),500)}}},[t,e]),re=x.useCallback(async()=>{if(t){if(Z.length===0){await se();return}ie(!0)}},[t,Z.length,se]),de=x.useCallback(async Q=>{var ve;if(p){N(!0);try{const E=await oe(e,p,y(),void 0,{bypassCache:!0,fonts:{mode:Q}});if(E.blob.size===0)k({title:"Export failed",description:"The server returned an empty document.",variant:"destructive"});else{Mi(`${e}${jr}`,E.blob);const R=(ve=E.warnings)==null?void 0:ve.find(L=>{var te,K;return((te=L.context)==null?void 0:te.code)==="FONT_MODE_SUBSTITUTED"||((K=L.context)==null?void 0:K.code)==="FONT_MODE_CUSTOM"});R&&k({title:Q==="substitute"?"Fonts substituted":"Non-safe fonts kept",description:R.message})}}catch(E){k({title:"Export failed",description:E instanceof Error?E.message:String(E),variant:"destructive"})}finally{setTimeout(()=>N(!1),500)}}},[p,e,oe,k,y]),ge=x.useCallback(async()=>{if(!(!g||g.length===0)){O(!0);try{const Q=Hy(g);if(!Q){k({title:"No warnings",description:"There are no warnings to download.",variant:"destructive"});return}const ve=await oe("warnings",JSON.stringify(Q,null,2),{});ve&&typeof ve=="object"&&"blob"in ve&&ve.blob&&(Mi(`${e}-warnings${jr}`,ve.blob),k({title:"Warnings downloaded",description:`Downloaded warnings document with ${g.length} warning(s).`}))}catch(Q){console.error("Failed to generate warnings document:",Q),k({title:"Download failed",description:Q instanceof Error?Q.message:"Failed to generate warnings document",variant:"destructive"})}finally{setTimeout(()=>O(!1),500)}}},[g,e,oe,k]),Ee=x.useCallback(async()=>{const Q=r==null?void 0:r.current;if(Q!=null&&Q.src){I(!0);try{await new Promise(E=>{let R=null,L=!1;const te=()=>{R&&(clearTimeout(R),R=null),Q.removeEventListener("load",ee),Q.removeEventListener("error",ue)},K=()=>{L||(L=!0,te(),E())},ee=()=>K(),ue=()=>K();Q.addEventListener("load",ee),Q.addEventListener("error",ue),R=setTimeout(()=>{console.warn("Iframe reload timed out after 5 seconds"),K()},5e3);const be=Q.src,B=be.includes("?")?"&":"?",Y=Date.now();Q.src=`${be}${B}_reload=${Y}`})}catch(ve){console.error("Iframe reload failed:",ve)}finally{I(!1)}}},[r]),ye=x.useCallback(async()=>{M(!0);try{await Uy.delete(`/${ot}/cache`),window.dispatchEvent(new CustomEvent("cache:cleared")),k({title:"Cache Cleared",description:"All caches (document and component) have been successfully cleared.",variant:"default"})}catch(Q){console.error("Failed to clear cache:",Q),k({title:"Cache Clear Failed",description:"Failed to clear caches. Please try again.",variant:"destructive"})}finally{M(!1)}},[k]),xe=h??p,W=x.useCallback(()=>{var E,R;if(!xe){k({title:"No document available",description:"Please select a document to copy standard components",variant:"destructive"});return}try{JSON.parse(xe)}catch{k({title:"Document is not valid JSON",description:"Fix the JSON errors in the editor, then copy again",variant:"destructive"});return}U(!0);const Q=(async()=>{const L=await fetch(`/api/${ot}/standard-components`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonDefinition:xe,customThemes:y(),options:{sourceName:e}})});if(!L.ok){let K=`Request failed with status ${L.status}`;try{const ee=await L.json(),ue=ee.error??ee.message;typeof ue=="string"&&ue&&(K=ue)}catch{}throw new Error(K)}const te=await L.json();return JSON.stringify(te.data,null,2)})();let ve;typeof ClipboardItem<"u"&&((E=navigator.clipboard)!=null&&E.write)?ve=navigator.clipboard.write([new ClipboardItem({"text/plain":Q.then(L=>new Blob([L],{type:"text/plain"}))})]):(R=navigator.clipboard)!=null&&R.writeText?ve=Q.then(L=>navigator.clipboard.writeText(L)):ve=Promise.reject(new Error("Clipboard is not available in this context")),(async()=>{try{await ve,k({title:"Copied to clipboard",description:"Standard components JSON has been copied"})}catch(L){let te=null;try{te=await Q}catch(K){console.error("Error fetching standard components:",K),k({title:"Failed to get standard components",description:K instanceof Error?K.message:"Request failed",variant:"destructive"});return}console.error("Clipboard write failed:",L),X(te)}finally{U(!1)}})()},[xe,e,y,k]),Oe=x.useCallback(async()=>{if($!=null)try{await navigator.clipboard.writeText($),k({title:"Copied to clipboard",description:"Standard components JSON has been copied"}),X(null)}catch{k({title:"Clipboard unavailable",description:"Select the JSON in the dialog and copy it manually",variant:"destructive"})}},[$,k]);return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"bg-sidebar border-b flex flex-row flex-nowrap items-center justify-between gap-x-2 px-3 py-1.5",children:[u.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[u.jsx("p",{className:"text-foreground text-sm font-semibold tracking-tight truncate flex-1 min-w-0",children:e}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx("button",{type:"button","aria-label":"Preview disclaimer",className:"cursor-help inline-flex items-center justify-center h-6 w-6 rounded-sm hover:bg-muted/60 shrink-0",children:u.jsx(kd,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),u.jsx(Ye,{className:"max-w-sm",children:u.jsxs("p",{className:"text-sm",children:["Preview uses"," ",ot==="docx"?"docx-preview":"LibreOffice PDF conversion",". Download the ",jr," to verify fidelity."]})})]})]}),u.jsxs("div",{className:"flex flex-row items-center gap-x-1 shrink-0",children:[(!i||C)&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(Ne,{variant:"default",size:"sm",className:"gap-1.5 h-7 px-2.5",onClick:o,"aria-label":"Render preview",disabled:a||l||T===!1,children:[l?u.jsx(sn,{size:"sm"}):u.jsx(Bg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Run"})]})}),u.jsx(Ye,{children:u.jsx("p",{children:T===!1?"Open preview to run":l?"Rendering preview...":"Render preview"})})]}),ot==="docx"&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs("div",{className:"flex items-center gap-1.5 cursor-help ml-2 mr-1",children:[u.jsx(sr,{className:"text-xs text-muted-foreground hidden sm:inline",children:"Auto"}),u.jsx(ba,{checked:i,onCheckedChange:s,disabled:C})]})}),u.jsx(Ye,{children:u.jsx("p",{children:C?"Auto-reload is not available for Office, Docs, and LibreOffice renderers":`${i?"Disable":"Enable"} automatic preview reload on content changes`})})]}),n&&i&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ne,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:Ee,disabled:_||a||l,children:_?u.jsx(sn,{size:"sm"}):u.jsx(Zg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsx("p",{children:_?"Reloading...":"Reload"})})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsxs(Ne,{variant:"outline",size:"sm",className:"gap-1.5 h-7 px-2.5",disabled:!t||w||a,onClick:re,children:[w?u.jsx(sn,{size:"sm"}):u.jsx(Vg,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Download"})]})}),u.jsx(Ye,{children:u.jsxs("p",{children:["Download ",jr]})})]}),g&&g.length>0&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ne,{variant:"outline",size:"icon",className:"h-7 w-7 border-transparent bg-warning/10 text-warning hover:bg-warning/20",disabled:H||a,onClick:ge,children:H?u.jsx(sn,{size:"sm"}):u.jsx(_d,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsxs("p",{children:["Download warnings (",g.length,")"]})})]}),v&&S&&u.jsxs(qr,{value:v,onValueChange:S,children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(cr,{className:"w-[140px] h-7 text-xs hidden lg:flex",children:u.jsx(Gr,{placeholder:"Renderer"})})}),u.jsx(Ye,{children:u.jsx("p",{children:"Select the rendering library"})})]}),u.jsx(dr,{className:"text-sidebar-foreground",children:Ml.map(Q=>u.jsxs(Dn,{value:Q,children:[u.jsxs(qe,{children:[u.jsx(Ge,{tabIndex:-1,children:Ys[Q][0]}),u.jsx(Ye,{children:Ys[Q][1]})]})," ",Q]},Q))})]}),u.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),u.jsxs(ks,{children:[u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ss,{asChild:!0,children:u.jsx(Ne,{variant:"ghost",size:"icon",className:"h-7 w-7",children:u.jsx(vd,{className:"h-3.5 w-3.5"})})})}),u.jsx(Ye,{children:u.jsx("p",{children:"More actions"})})]}),u.jsxs(hi,{align:"end",className:"w-52",children:[d&&u.jsxs(Lt,{onClick:d,children:[u.jsx(Ug,{className:"h-4 w-4 mr-2"}),"View JSON Schemas"]}),f&&u.jsxs(Lt,{onClick:f,children:[u.jsx(ko,{className:"h-4 w-4 mr-2"}),"Browse fonts"]}),c&&u.jsxs(Lt,{onClick:c,children:[u.jsx(So,{className:"h-4 w-4 mr-2"}),"View cache metrics"]}),xe?u.jsxs(Lt,{onClick:W,disabled:D,children:[u.jsx(_o,{className:"h-4 w-4 mr-2"}),D?"Copying...":"Copy standard components"]}):u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx("span",{className:"block",children:u.jsxs(Lt,{disabled:!0,children:[u.jsx(_o,{className:"h-4 w-4 mr-2"}),"Copy standard components"]})})}),u.jsx(Ye,{side:"left",children:u.jsx("p",{children:"No document selected — open or select a document first"})})]}),u.jsx(fr,{}),u.jsxs(Lt,{onClick:()=>P(!0),disabled:z,className:"text-destructive focus:text-destructive",children:[u.jsx(la,{className:"h-4 w-4 mr-2"}),z?"Clearing...":"Clear all caches"]}),v&&S&&u.jsxs(u.Fragment,{children:[u.jsx(fr,{className:"lg:hidden"}),Ml.map(Q=>u.jsxs(Lt,{className:"lg:hidden",onClick:()=>S(Q),children:[u.jsx("span",{className:"mr-2",children:v===Q?"●":"○"}),Ys[Q][0]," ",Q]},Q))]})]})]}),m&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ne,{variant:T?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:m,children:T?u.jsx(jd,{className:"h-3.5 w-3.5"}):u.jsx(Jg,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[T?"Hide":"Show"," Preview"," ",u.jsx(Kr,{shortcut:"mod+shift+p"})]})})]}),b&&u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx(Ne,{variant:j?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:b,children:u.jsx(Nd,{className:"h-3.5 w-3.5"})})}),u.jsx(Ye,{children:u.jsxs("span",{className:"flex items-center gap-1.5",children:[j?"Close":"Open"," AI Chat"," ",u.jsx(Kr,{shortcut:"mod+shift+j"})]})})]})]})]}),u.jsx(Wy,{open:V,onClose:()=>ie(!1),nonSafeFonts:Z,onChoose:de}),u.jsx(Ct,{open:$!=null,onOpenChange:Q=>{Q||X(null)},children:u.jsxs(kt,{className:"max-w-lg",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Standard components"}),u.jsx(an,{children:"The browser blocked the automatic clipboard write. Copy the JSON from here instead."})]}),u.jsx(Jf,{readOnly:!0,value:$??"",className:"h-64 font-mono text-xs",onFocus:Q=>Q.currentTarget.select()}),u.jsxs(yn,{children:[u.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>X(null),children:"Close"}),u.jsx(Ne,{size:"sm",onClick:Oe,children:"Copy to clipboard"})]})]})}),u.jsx(Ct,{open:A,onOpenChange:P,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear all caches?"}),u.jsx(an,{children:"This will clear the document, component, and rasterized-visual caches. Next generation will be uncached."})]}),u.jsxs(yn,{children:[u.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>P(!1),children:"Cancel"}),u.jsx(Ne,{variant:"destructive",size:"sm",disabled:z,onClick:async()=>{await ye(),P(!1)},children:z?u.jsx(sn,{size:"sm"}):"Clear"})]})]})})]})}const Gy=Se.memo(qy),Hf=lg,Sa=x.forwardRef(({className:e,...t},n)=>u.jsx(dd,{ref:n,className:q("bg-muted text-muted-foreground inline-flex h-9 items-center justify-center rounded-sm p-1",e),...t}));Sa.displayName=dd.displayName;const ei=x.forwardRef(({className:e,...t},n)=>u.jsx(fd,{ref:n,className:q("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex cursor-pointer items-center justify-center rounded-sm px-3 py-1 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",e),...t}));ei.displayName=fd.displayName;const ti=x.forwardRef(({className:e,...t},n)=>u.jsx(pd,{ref:n,className:q("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",e),...t}));ti.displayName=pd.displayName;async function Yy(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 Ky(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 Xy(e){const t=Ky(e);return Yy(t)}const Qy=({open:e,onOpenChange:t,defaultTab:n="document"})=>{const[r,i]=x.useState(n),[s,o]=x.useState(null),[a,l]=x.useState(null),[c,d]=x.useState(!1),[f,p]=x.useState(!1),[h,g]=x.useState(null),[v,S]=x.useState(null),[b,j]=x.useState(!1),{toast:m}=vr(),T=Bt(M=>M.selectedPlugins),C=Array.from(T);x.useEffect(()=>{n&&i(n)},[n]);const w=x.useCallback(async()=>{d(!0),g(null);try{const M=await Ls.fetchDocumentSchema(C);o(M)}catch(M){const A=M instanceof Error?M.message:"Failed to load document schema";g(A),m({variant:"destructive",title:"Error loading schema",description:A})}finally{d(!1)}},[C,m]),N=x.useCallback(async()=>{if(!a){p(!0),S(null);try{const M=await Ls.fetchThemeSchema();l(M)}catch(M){const A=M instanceof Error?M.message:"Failed to load theme schema";S(A),m({variant:"destructive",title:"Error loading schema",description:A})}finally{p(!1)}}},[a,m]),[H,O]=x.useState([]);x.useEffect(()=>{e||(o(null),g(null))},[e]),x.useEffect(()=>{if(!e)return;const M=C.length!==H.length||C.some((A,P)=>A!==H[P]);r==="document"?(!s||M)&&(M&&(Ls.clearPluginSchemaCache(),O([...C])),c||w()):r==="theme"&&!a&&!f&&N()},[r,e,s,a,c,f,C,H,w,N]);const _=C.length,I=r==="document"?s:a,z=async()=>{if(I)try{await Xy(I)&&(j(!0),m({title:"Schema copied",description:"The JSON schema has been copied to your clipboard"}),setTimeout(()=>j(!1),2e3))}catch(M){console.error("Copy failed:",M)}};return u.jsx(Ct,{open:e,onOpenChange:t,children:u.jsxs(kt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ut,{children:u.jsx(Jt,{children:"Schema Viewer"})}),u.jsxs(Hf,{value:r,onValueChange:M=>i(M),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Sa,{children:[u.jsxs(ei,{value:"document",className:"flex items-center gap-1",children:["Document",_>0&&u.jsxs(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:["+",_]})]}),u.jsx(ei,{value:"theme",children:"Theme"})]}),u.jsx("div",{className:"ml-auto",children:u.jsx(Ne,{variant:"ghost",size:"icon",onClick:z,disabled:b||!I,"aria-label":"Copy schema",children:b?u.jsx(bn,{className:"h-4 w-4"}):u.jsx(bs,{className:"h-4 w-4"})})})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4",children:[u.jsx(ti,{value:"document",className:"h-full",children:u.jsx(Xi,{schema:s,loading:c,error:h||void 0})}),u.jsx(ti,{value:"theme",className:"h-full",children:u.jsx(Xi,{schema:a,loading:f,error:v||void 0})})]})]})]})})};function ev(e,t,n){if(t.length===0)return n;const r=$l(e,t[0]);let i=r;for(let s=0;s<t.length-1;s++){const o=t[s],a=t[s+1],l=i[o],c=$l(l,a);i[o]=c,i=c}return i[t[t.length-1]]=n,r}function $l(e,t){return typeof t=="number"?Array.isArray(e)?[...e]:[]:e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}const tv={safe:[],google:[]};function nv(e,t){var d;const n=`gf-${e.replace(/\s+/g,"-")}`,r=document.getElementById(n),i=new Set(t&&t.length>0?t:[400,700]),s=new Set(((d=r==null?void 0:r.dataset.weights)==null?void 0:d.split(",").map(Number).filter(f=>!Number.isNaN(f)))??[]),o=new Set([...s,...i]);if(r&&o.size===s.size)return;const a=[...o].sort((f,p)=>f-p).join(";"),l=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@${a}&display=swap`,c=r??document.createElement("link");r||(c.id=n,c.rel="stylesheet",document.head.appendChild(c)),c.href=l,c.dataset.weights=[...o].sort((f,p)=>f-p).join(",")}function rv(){const e=Pe(i=>i.activeTab),t=Pe(i=>i.documents),n=Pe(i=>i.documentTypes),r=Pe(i=>i.saveDocument);return x.useCallback(i=>{if(!e)return{ok:!1,error:"No active file"};if(n[e]!=="application/json+theme")return{ok:!1,error:"Fonts are registered on themes, not documents. Open a .theme.json file and try again."};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active theme not found"};let o;try{o=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active theme is not valid JSON: ${l.message}`}}const a=i(o);return r(e,JSON.stringify(a,null,2)),{ok:!0,name:e}},[e,t,n,r])}function iv(){const e=Pe(r=>r.activeTab),t=Pe(r=>r.documents),n=Pe(r=>r.saveDocument);return x.useCallback((r,i)=>{if(!e)return{ok:!1,error:"No active file"};const s=t.find(l=>l.name===e);if(!s)return{ok:!1,error:"Active document not found"};let o;try{o=JSON.parse(s.text)}catch(l){return{ok:!1,error:`Active document is not valid JSON: ${l.message}`}}const a=ev(o,r,i);return n(e,JSON.stringify(a,null,2)),{ok:!0,name:e}},[e,t,n])}function sv(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 Ll(e){return e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}const ov=({open:e,onOpenChange:t})=>{const n=Di(D=>D.open),r=Di(D=>D.contextual),i=Di(D=>D.close),s=e??n,o=r,a=x.useCallback(D=>{t&&t(D),D||i()},[t,i]),[l,c]=x.useState(tv),[d,f]=x.useState(!1),[p,h]=x.useState(""),[g,v]=x.useState("safe"),[S,b]=x.useState(null),[j,m]=x.useState(null),{toast:T}=vr(),C=rv(),w=iv(),N=Pe(D=>D.activeTab),H=Pe(D=>D.documentTypes),O=N&&H[N]==="application/json+theme",_=!!o||O;x.useEffect(()=>{s&&(l.safe.length>0||l.google.length>0||(f(!0),fetch("/api/fonts/catalog").then(D=>D.json()).then(D=>c(D)).catch(D=>{T({variant:"destructive",title:"Font catalog unavailable",description:D.message})}).finally(()=>f(!1))))},[s,l,T]),x.useEffect(()=>{if(!(g!=="google"||l.google.length===0))for(const D of l.google)nv(D.family,D.weights)},[g,l]);const I=x.useMemo(()=>l.safe.filter(D=>D.toLowerCase().includes(p.toLowerCase())),[l.safe,p]),z=x.useMemo(()=>l.google.filter(D=>D.family.toLowerCase().includes(p.toLowerCase())),[l.google,p]),M=x.useCallback(async D=>{try{await navigator.clipboard.writeText(D),m(D),setTimeout(()=>m(null),1500)}catch{T({variant:"destructive",title:"Copy failed",description:"Your browser blocked clipboard write."})}},[T]),A=x.useCallback(async(D,U,$)=>{b(D);try{const X=C(k=>(sv(k,$,D),k));if(!X.ok){T({variant:"destructive",title:"Could not insert font",description:X.error});return}T({title:"Font inserted",description:`${D} set as ${$} font in "${X.name}".`})}finally{b(null)}},[C,T]),P=x.useCallback(async D=>{if(o){b(D);try{const U=w(o.jsonPath,D);if(!U.ok){T({variant:"destructive",title:"Could not insert font",description:U.error});return}T({title:"Font inserted",description:`${D} set at ${Ll(o.jsonPath)}.`}),a(!1)}finally{b(null)}}},[o,w,T,a]);return u.jsx(Ct,{open:s,onOpenChange:a,children:u.jsxs(kt,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsx(Ut,{children:u.jsx(Jt,{children:o?`Font for ${Ll(o.jsonPath)}`:"Fonts"})}),!o&&!O&&u.jsx(Gi,{children:u.jsxs(Yi,{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(Hf,{value:g,onValueChange:D=>v(D),className:"flex-1 overflow-hidden flex flex-col",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Sa,{children:[u.jsxs(ei,{value:"safe",children:["Safe",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.safe.length})]}),u.jsxs(ei,{value:"google",children:["Google",u.jsx(Kt,{variant:"secondary",className:"ml-1 text-xs px-1 py-0",children:l.google.length})]})]}),u.jsx(fi,{type:"search",placeholder:"Search fonts...",value:p,onChange:D=>h(D.target.value),className:"ml-auto max-w-xs"})]}),u.jsxs("div",{className:"flex-1 overflow-auto mt-4 pr-2",children:[u.jsx(ti,{value:"safe",className:"m-0",children:d&&I.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(jo,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:I.map(D=>u.jsx(Fl,{family:D,meta:u.jsx("span",{className:"text-xs",children:"Installed with Office"}),previewStyle:{fontFamily:`"${D}", sans-serif`},onCopy:()=>M(D),copied:j===D,contextual:!!o,onUseThis:()=>P(D),onInsertHeading:()=>A(D,"safe","heading"),onInsertBody:()=>A(D,"safe","body"),applying:S===D,disabled:!_},D))})}),u.jsx(ti,{value:"google",className:"m-0",children:d&&z.length===0?u.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[u.jsx(jo,{className:"animate-spin mr-2"})," Loading catalog..."]}):u.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:z.map(D=>u.jsx(Fl,{family:D.family,meta:u.jsxs("span",{className:"text-xs",children:[D.category," · ",D.weights.length," weights"]}),previewStyle:{fontFamily:`"${D.family}", sans-serif`},onCopy:()=>M(D.family),copied:j===D.family,contextual:!!o,onUseThis:()=>P(D.family),onInsertHeading:()=>A(D.family,"google","heading"),onInsertBody:()=>A(D.family,"google","body"),applying:S===D.family,disabled:!_,extraAction:u.jsx(lv,{family:D.family,weights:D.weights,hasItalic:D.hasItalic})},D.family))})})]})]})]})})},av="The quick brown fox jumps over the lazy dog",lv=({family:e,weights:t,hasItalic:n})=>{const r=x.useMemo(()=>[...t].sort((i,s)=>i-s),[t]);return u.jsxs(ks,{children:[u.jsx(Ss,{asChild:!0,children:u.jsx(Ne,{size:"sm",variant:"ghost","aria-label":"Show variants",children:"Variants"})}),u.jsxs(hi,{align:"end",className:"min-w-[260px]",children:[u.jsxs(nf,{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=gg[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)})]})]})},Fl=({family:e,meta:t,previewStyle:n,onCopy:r,copied:i,contextual:s,onUseThis:o,onInsertHeading:a,onInsertBody:l,applying:c,disabled:d,extraAction:f})=>u.jsxs("div",{className:"border rounded-md p-3 flex flex-col gap-2 bg-card",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("div",{className:"font-medium truncate",children:e}),u.jsx("div",{className:"text-muted-foreground",children:t})]}),u.jsx("div",{className:"text-lg truncate",style:n,"aria-hidden":!0,children:av}),u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s?u.jsx(Ne,{size:"sm",onClick:o,disabled:c||d,"aria-label":`Use ${e} at the target path`,children:"Use this font"}):u.jsxs(u.Fragment,{children:[u.jsx(Ne,{size:"sm",variant:"secondary",onClick:a,disabled:c||d,"aria-label":`Set ${e} as heading font`,children:"Set heading"}),u.jsx(Ne,{size:"sm",variant:"secondary",onClick:l,disabled:c||d,"aria-label":`Set ${e} as body font`,children:"Set body"})]}),f,u.jsx(Ne,{size:"sm",variant:"ghost",className:"ml-auto",onClick:r,"aria-label":`Copy ${e}`,children:i?u.jsx(bn,{className:"h-4 w-4"}):u.jsx(bs,{className:"h-4 w-4"})})]})]});function Bl({previewOpen:e,onTogglePreview:t}){const n=rn(O=>O.name||""),r=rn(O=>O.blob),i=rn(O=>O.isGenerating),s=rn(O=>O.text),o=rn(O=>O.warnings),a=rn(O=>O.isRendering),l=ki(O=>O.autoReload),c=ki(O=>O.renderingLibrary),d=ki(O=>O.setSettings),f=ki(O=>O.useGlobalPreviewHeader??!0),p=Pe(O=>O.activeTab),h=Pe(O=>O.documentTypes),g=p&&h[p]==="application/json+theme"?"theme":"document",v=Pe(O=>{var _;return O.activeTab&&O.documentTypes[O.activeTab]!=="application/json+theme"?(_=O.documents.find(I=>I.name===O.activeTab))==null?void 0:_.text:void 0}),S=Re(O=>O.chatOpen),b=Re(O=>O.toggleChat),[j,m]=Se.useState(!1),T=Di(O=>O.openFor);if(!f)return null;const C=x.useCallback(()=>d({saveDocumentDebounceWait:2e3,autoReload:!l}),[l,d]),w=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:manualRender"))},[]),N=x.useCallback(()=>{window.dispatchEvent(new CustomEvent("preview:showCacheMetrics"))},[]),H=(n==null?void 0:n.trim())||"Preview";return u.jsxs("div",{className:"sticky top-0 z-20",children:[u.jsx(Gy,{name:H,blob:r,displayReloadButton:!1,autoReload:l,onToggleAutoReload:C,onManualRender:w,isGenerating:i,isRendering:!!a,onShowCacheMetrics:N,onShowSchemas:()=>m(!0),onShowFonts:()=>T(),documentText:s,editorDocumentText:v,warnings:o,renderingLibrary:c,setRenderingLibrary:O=>d({renderingLibrary:O}),onToggleChat:b,chatOpen:S,onTogglePreview:t,previewOpen:e}),u.jsx(Qy,{open:j,onOpenChange:m,defaultTab:g==="theme"?"theme":"document"}),u.jsx(ov,{})]})}function uv(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const cv=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fv={};function Zl(e,t){return(fv.jsx?dv:cv).test(e)}const pv=/[ \t\n\f\r]/g;function hv(e){return typeof e=="object"?e.type==="text"?Vl(e.value):!1:Vl(e)}function Vl(e){return e.replace(pv,"")===""}class mi{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}mi.prototype.normal={};mi.prototype.property={};mi.prototype.space=void 0;function Wf(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new mi(n,r,t)}function $o(e){return e.toLowerCase()}class St{constructor(t,n){this.attribute=n,this.property=t}}St.prototype.attribute="";St.prototype.booleanish=!1;St.prototype.boolean=!1;St.prototype.commaOrSpaceSeparated=!1;St.prototype.commaSeparated=!1;St.prototype.defined=!1;St.prototype.mustUseProperty=!1;St.prototype.number=!1;St.prototype.overloadedBoolean=!1;St.prototype.property="";St.prototype.spaceSeparated=!1;St.prototype.space=void 0;let mv=0;const ke=Ln(),nt=Ln(),Lo=Ln(),ne=Ln(),Ze=Ln(),lr=Ln(),jt=Ln();function Ln(){return 2**++mv}const Fo=Object.freeze(Object.defineProperty({__proto__:null,boolean:ke,booleanish:nt,commaOrSpaceSeparated:jt,commaSeparated:lr,number:ne,overloadedBoolean:Lo,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),Ks=Object.keys(Fo);class _a extends St{constructor(t,n,r,i){let s=-1;if(super(t,n),Ul(this,"space",i),typeof r=="number")for(;++s<Ks.length;){const o=Ks[s];Ul(this,Ks[s],(r&Fo[o])===Fo[o])}}}_a.prototype.defined=!0;function Ul(e,t,n){n&&(e[t]=n)}function wr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new _a(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[$o(r)]=r,n[$o(s.attribute)]=r}return new mi(t,n,e.space)}const qf=wr({properties:{ariaActiveDescendant:null,ariaAtomic:nt,ariaAutoComplete:null,ariaBusy:nt,ariaChecked:nt,ariaColCount:ne,ariaColIndex:ne,ariaColSpan:ne,ariaControls:Ze,ariaCurrent:null,ariaDescribedBy:Ze,ariaDetails:null,ariaDisabled:nt,ariaDropEffect:Ze,ariaErrorMessage:null,ariaExpanded:nt,ariaFlowTo:Ze,ariaGrabbed:nt,ariaHasPopup:null,ariaHidden:nt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ze,ariaLevel:ne,ariaLive:null,ariaModal:nt,ariaMultiLine:nt,ariaMultiSelectable:nt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:ne,ariaPressed:nt,ariaReadOnly:nt,ariaRelevant:null,ariaRequired:nt,ariaRoleDescription:Ze,ariaRowCount:ne,ariaRowIndex:ne,ariaRowSpan:ne,ariaSelected:nt,ariaSetSize:ne,ariaSort:null,ariaValueMax:ne,ariaValueMin:ne,ariaValueNow:ne,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Gf(e,t){return t in e?e[t]:t}function Yf(e,t){return Gf(e,t.toLowerCase())}const gv=wr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:lr,acceptCharset:Ze,accessKey:Ze,action:null,allow:null,allowFullScreen:ke,allowPaymentRequest:ke,allowUserMedia:ke,alt:null,as:null,async:ke,autoCapitalize:null,autoComplete:Ze,autoFocus:ke,autoPlay:ke,blocking:Ze,capture:null,charSet:null,checked:ke,cite:null,className:Ze,cols:ne,colSpan:null,content:null,contentEditable:nt,controls:ke,controlsList:Ze,coords:ne|lr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ke,defer:ke,dir:null,dirName:null,disabled:ke,download:Lo,draggable:nt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ke,formTarget:null,headers:Ze,height:ne,hidden:Lo,high:ne,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:ke,inputMode:null,integrity:null,is:null,isMap:ke,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:ke,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ke,low:ne,manifest:null,max:null,maxLength:ne,media:null,method:null,min:null,minLength:ne,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:ne,pattern:null,ping:Ze,placeholder:null,playsInline:ke,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ke,referrerPolicy:null,rel:Ze,required:ke,reversed:ke,rows:ne,rowSpan:ne,sandbox:Ze,scope:null,scoped:ke,seamless:ke,selected:ke,shadowRootClonable:ke,shadowRootDelegatesFocus:ke,shadowRootMode:null,shape:null,size:ne,sizes:null,slot:null,span:ne,spellCheck:nt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ne,step:null,style:null,tabIndex:ne,target:null,title:null,translate:null,type:null,typeMustMatch:ke,useMap:null,value:nt,width:ne,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,axis:null,background:null,bgColor:null,border:ne,borderColor:null,bottomMargin:ne,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:ne,leftMargin:ne,link:null,longDesc:null,lowSrc:null,marginHeight:ne,marginWidth:ne,noResize:ke,noHref:ke,noShade:ke,noWrap:ke,object:null,profile:null,prompt:null,rev:null,rightMargin:ne,rules:null,scheme:null,scrolling:nt,standby:null,summary:null,text:null,topMargin:ne,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ne,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ke,disableRemotePlayback:ke,prefix:null,property:null,results:ne,security:null,unselectable:null},space:"html",transform:Yf}),xv=wr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:jt,accentHeight:ne,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ne,amplitude:ne,arabicForm:null,ascent:ne,attributeName:null,attributeType:null,azimuth:ne,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ne,by:null,calcMode:null,capHeight:ne,className:Ze,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ne,diffuseConstant:ne,direction:null,display:null,dur:null,divisor:ne,dominantBaseline:null,download:ke,dx:null,dy:null,edgeMode:null,editable:null,elevation:ne,enableBackground:null,end:null,event:null,exponent:ne,externalResourcesRequired:null,fill:null,fillOpacity:ne,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:lr,g2:lr,glyphName:lr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ne,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ne,horizOriginX:ne,horizOriginY:ne,id:null,ideographic:ne,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ne,k:ne,k1:ne,k2:ne,k3:ne,k4:ne,kernelMatrix:jt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ne,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:ne,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:ne,overlineThickness:ne,paintOrder:null,panose1:null,path:null,pathLength:ne,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ze,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ne,pointsAtY:ne,pointsAtZ:ne,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:jt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:jt,rev:jt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:jt,requiredFeatures:jt,requiredFonts:jt,requiredFormats:jt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ne,specularExponent:ne,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ne,strikethroughThickness:ne,string:null,stroke:null,strokeDashArray:jt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ne,strokeOpacity:ne,strokeWidth:null,style:null,surfaceScale:ne,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:jt,tabIndex:ne,tableValues:null,target:null,targetX:ne,targetY:ne,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:jt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ne,underlineThickness:ne,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ne,values:null,vAlphabetic:ne,vMathematical:ne,vectorEffect:null,vHanging:ne,vIdeographic:ne,version:null,vertAdvY:ne,vertOriginX:ne,vertOriginY:ne,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ne,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Gf}),Kf=wr({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()}}),Xf=wr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Yf}),Qf=wr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),bv={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},yv=/[A-Z]/g,Jl=/-[a-z]/g,vv=/^data[-\w.:]+$/i;function wv(e,t){const n=$o(t);let r=t,i=St;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&vv.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Jl,Sv);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Jl.test(s)){let o=s.replace(yv,kv);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=_a}return new i(r,t)}function kv(e){return"-"+e.toLowerCase()}function Sv(e){return e.charAt(1).toUpperCase()}const _v=Wf([qf,gv,Kf,Xf,Qf],"html"),ja=Wf([qf,xv,Kf,Xf,Qf],"svg");function jv(e){return e.join(" ").trim()}var Wn={},Xs,Hl;function Nv(){if(Hl)return Xs;Hl=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
10
|
+
`,c="/",d="*",f="",p="comment",h="declaration";function g(S,b){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];b=b||{};var j=1,m=1;function T(A){var P=A.match(t);P&&(j+=P.length);var D=A.lastIndexOf(l);m=~D?A.length-D:m+A.length}function C(){var A={line:j,column:m};return function(P){return P.position=new w(A),O(),P}}function w(A){this.start=A,this.end={line:j,column:m},this.source=b.source}w.prototype.content=S;function N(A){var P=new Error(b.source+":"+j+":"+m+": "+A);if(P.reason=A,P.filename=b.source,P.line=j,P.column=m,P.source=S,!b.silent)throw P}function H(A){var P=A.exec(S);if(P){var D=P[0];return T(D),S=S.slice(D.length),P}}function O(){H(n)}function _(A){var P;for(A=A||[];P=I();)P!==!1&&A.push(P);return A}function I(){var A=C();if(!(c!=S.charAt(0)||d!=S.charAt(1))){for(var P=2;f!=S.charAt(P)&&(d!=S.charAt(P)||c!=S.charAt(P+1));)++P;if(P+=2,f===S.charAt(P-1))return N("End of comment missing");var D=S.slice(2,P-2);return m+=2,T(D),S=S.slice(P),m+=2,A({type:p,comment:D})}}function z(){var A=C(),P=H(r);if(P){if(I(),!H(i))return N("property missing ':'");var D=H(s),U=A({type:h,property:v(P[0].replace(e,f)),value:D?v(D[0].replace(e,f)):f});return H(o),U}}function M(){var A=[];_(A);for(var P;P=z();)P!==!1&&(A.push(P),_(A));return A}return O(),M()}function v(S){return S?S.replace(a,f):f}return Xs=g,Xs}var Wl;function Ev(){if(Wl)return Wn;Wl=1;var e=Wn&&Wn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Wn,"__esModule",{value:!0}),Wn.default=n;const t=e(Nv());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:d}=l;a?i(c,d,l):d&&(s=s||{},s[c]=d)}),s}return Wn}var Tr={},ql;function Cv(){if(ql)return Tr;ql=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},o=function(c,d){return d.toUpperCase()},a=function(c,d){return"".concat(d,"-")},l=function(c,d){return d===void 0&&(d={}),s(c)?c:(c=c.toLowerCase(),d.reactCompat?c=c.replace(i,a):c=c.replace(r,a),c.replace(t,o))};return Tr.camelCase=l,Tr}var Ar,Gl;function Iv(){if(Gl)return Ar;Gl=1;var e=Ar&&Ar.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Ev()),n=Cv();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Ar=r,Ar}var Tv=Iv();const Av=oa(Tv),ep=tp("end"),Na=tp("start");function tp(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 zv(e){const t=Na(e),n=ep(e);if(t&&n)return{start:t,end:n}}function Jr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Yl(e.position):"start"in e||"end"in e?Yl(e):"line"in e||"column"in e?Bo(e):""}function Bo(e){return Kl(e&&e.line)+":"+Kl(e&&e.column)}function Yl(e){return Bo(e&&e.start)+"-"+Bo(e&&e.end)}function Kl(e){return e&&typeof e=="number"?e:1}class ut extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Jr(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ut.prototype.file="";ut.prototype.name="";ut.prototype.reason="";ut.prototype.message="";ut.prototype.stack="";ut.prototype.column=void 0;ut.prototype.line=void 0;ut.prototype.ancestors=void 0;ut.prototype.cause=void 0;ut.prototype.fatal=void 0;ut.prototype.place=void 0;ut.prototype.ruleId=void 0;ut.prototype.source=void 0;const Ea={}.hasOwnProperty,Ov=new Map,Pv=/[A-Z]/g,Dv=new Set(["table","tbody","thead","tfoot","tr"]),Rv=new Set(["td","th"]),np="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Mv(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=Jv(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=Uv(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"?ja:_v,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=rp(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function rp(e,t,n){if(t.type==="element")return $v(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Lv(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Bv(e,t,n);if(t.type==="mdxjsEsm")return Fv(e,t);if(t.type==="root")return Zv(e,t,n);if(t.type==="text")return Vv(e,t)}function $v(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ja,e.schema=i),e.ancestors.push(t);const s=sp(e,t.tagName,!1),o=Hv(e,t);let a=Ia(e,t);return Dv.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!hv(l):!0})),ip(e,o,s,t),Ca(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Lv(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)}ni(e,t.position)}function Fv(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ni(e,t.position)}function Bv(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=ja,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:sp(e,t.name,!0),o=Wv(e,t),a=Ia(e,t);return ip(e,o,s,t),Ca(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Zv(e,t,n){const r={};return Ca(r,Ia(e,t)),e.create(t,e.Fragment,r,n)}function Vv(e,t){return t.value}function ip(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ca(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Uv(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function Jv(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Na(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function Hv(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ea.call(t.properties,i)){const s=qv(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&Rv.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Wv(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ni(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else ni(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Ia(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Ov;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=rp(e,s,o);a!==void 0&&n.push(a)}return n}function qv(e,t,n){const r=wv(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?uv(n):jv(n)),r.property==="style"){let i=typeof n=="object"?n:Gv(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Yv(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?bv[r.property]||r.property:r.attribute,n]}}function Gv(e,t){try{return Av(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new ut("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=np+"#cannot-parse-style-attribute",i}}function sp(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=Zl(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=Zl(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Ea.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);ni(e)}function ni(e,t){const n=new ut("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=np+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Yv(e){const t={};let n;for(n in e)Ea.call(e,n)&&(t[Kv(n)]=e[n]);return t}function Kv(e){let t=e.replace(Pv,Xv);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Xv(e){return"-"+e.toLowerCase()}const Qs={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"]},Qv={};function Ta(e,t){const n=Qv,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return op(e,r,i)}function op(e,t,n){if(ew(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 Xl(e.children,t,n)}return Array.isArray(e)?Xl(e,t,n):""}function Xl(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=op(e[i],t,n);return r.join("")}function ew(e){return!!(e&&typeof e=="object")}const Ql=document.createElement("i");function Aa(e){const t="&"+e+";";Ql.innerHTML=t;const n=Ql.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function It(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ot(e,t){return e.length>0?(It(e,e.length,0,t),e):t}const eu={}.hasOwnProperty;function ap(e){const t={};let n=-1;for(;++n<e.length;)tw(t,e[n]);return t}function tw(e,t){let n;for(n in t){const i=(eu.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){eu.call(i,o)||(i[o]=[]);const a=s[o];nw(i[o],Array.isArray(a)?a:a?[a]:[])}}}function nw(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);It(e,0,0,r)}function lp(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Vt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ht=kn(/[A-Za-z]/),lt=kn(/[\dA-Za-z]/),rw=kn(/[#-'*+\--9=?A-Z^-~]/);function ts(e){return e!==null&&(e<32||e===127)}const Zo=kn(/\d/),iw=kn(/[\dA-Fa-f]/),sw=kn(/[!-/:-@[-`{-~]/);function he(e){return e!==null&&e<-2}function Fe(e){return e!==null&&(e<0||e===32)}function Ie(e){return e===-2||e===-1||e===32}const Is=kn(new RegExp("\\p{P}|\\p{S}","u")),Mn=kn(/\s/);function kn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function kr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&<(e.charCodeAt(n+1))&<(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function De(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ie(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ie(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const ow={tokenize:aw};function aw(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),De(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return he(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const lw={tokenize:uw},tu={tokenize:cw};function uw(e){const t=this,n=[];let r=0,i,s,o;return a;function a(m){if(r<n.length){const T=n[r];return t.containerState=T[1],e.attempt(T[0].continuation,l,c)(m)}return c(m)}function l(m){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&j();const T=t.events.length;let C=T,w;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){w=t.events[C][1].end;break}b(r);let N=T;for(;N<t.events.length;)t.events[N][1].end={...w},N++;return It(t.events,C+1,0,t.events.slice(T)),t.events.length=N,c(m)}return a(m)}function c(m){if(r===n.length){if(!i)return p(m);if(i.currentConstruct&&i.currentConstruct.concrete)return g(m);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(tu,d,f)(m)}function d(m){return i&&j(),b(r),p(m)}function f(m){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(m)}function p(m){return t.containerState={},e.attempt(tu,h,g)(m)}function h(m){return r++,n.push([t.currentConstruct,t.containerState]),p(m)}function g(m){if(m===null){i&&j(),b(0),e.consume(m);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(m)}function v(m){if(m===null){S(e.exit("chunkFlow"),!0),b(0),e.consume(m);return}return he(m)?(e.consume(m),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(m),v)}function S(m,T){const C=t.sliceStream(m);if(T&&C.push(null),m.previous=s,s&&(s.next=m),s=m,i.defineSkip(m.start),i.write(C),t.parser.lazy[m.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const N=t.events.length;let H=N,O,_;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(O){_=t.events[H][1].end;break}O=!0}for(b(r),w=N;w<t.events.length;)t.events[w][1].end={..._},w++;It(t.events,H+1,0,t.events.slice(N)),t.events.length=w}}function b(m){let T=n.length;for(;T-- >m;){const C=n[T];t.containerState=C[1],C[0].exit.call(t,e)}n.length=m}function j(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function cw(e,t,n){return De(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function mr(e){if(e===null||Fe(e)||Mn(e))return 1;if(Is(e))return 2}function Ts(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 Vo={name:"attention",resolveAll:dw,tokenize:fw};function dw(e,t){let n=-1,r,i,s,o,a,l,c,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};nu(f,-l),nu(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Ot(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Ot(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=Ot(c,Ts(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Ot(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,c=Ot(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,It(e,r-1,n-r+3,c),n=r+c.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function fw(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=mr(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),d=mr(l),f=!d||d===2&&i||n.includes(l),p=!i||i===2&&d||n.includes(r);return c._open=!!(s===42?f:f&&(i||!p)),c._close=!!(s===42?p:p&&(d||!f)),t(l)}}function nu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const pw={name:"autolink",tokenize:hw};function hw(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return ht(h)?(e.consume(h),o):h===64?n(h):c(h)}function o(h){return h===43||h===45||h===46||lt(h)?(r=1,a(h)):c(h)}function a(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||lt(h))&&r++<32?(e.consume(h),a):(r=0,c(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||ts(h)?n(h):(e.consume(h),l)}function c(h){return h===64?(e.consume(h),d):rw(h)?(e.consume(h),c):n(h)}function d(h){return lt(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||lt(h))&&r++<63){const g=h===45?p:f;return e.consume(h),g}return n(h)}}const gi={partial:!0,tokenize:mw};function mw(e,t,n){return r;function r(s){return Ie(s)?De(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||he(s)?t(s):n(s)}}const up={continuation:{tokenize:xw},exit:bw,name:"blockQuote",tokenize:gw};function gw(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ie(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function xw(e,t,n){const r=this;return i;function i(o){return Ie(o)?De(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(up,t,n)(o)}}function bw(e){e.exit("blockQuote")}const cp={name:"characterEscape",tokenize:yw};function yw(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 sw(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const dp={name:"characterReference",tokenize:vw};function vw(e,t,n){const r=this;let i=0,s,o;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=lt,d(f))}function c(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=iw,d):(e.enter("characterReferenceValue"),s=7,o=Zo,d(f))}function d(f){if(f===59&&i){const p=e.exit("characterReferenceValue");return o===lt&&!Aa(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<s?(e.consume(f),d):n(f)}}const ru={partial:!0,tokenize:kw},iu={concrete:!0,name:"codeFenced",tokenize:ww};function ww(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(w){return c(w)}function c(w){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=w,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(w)}function d(w){return w===a?(o++,e.consume(w),d):o<3?n(w):(e.exit("codeFencedFenceSequence"),Ie(w)?De(e,f,"whitespace")(w):f(w))}function f(w){return w===null||he(w)?(e.exit("codeFencedFence"),r.interrupt?t(w):e.check(ru,v,T)(w)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||he(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(w)):Ie(w)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),De(e,h,"whitespace")(w)):w===96&&w===a?n(w):(e.consume(w),p)}function h(w){return w===null||he(w)?f(w):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(w))}function g(w){return w===null||he(w)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(w)):w===96&&w===a?n(w):(e.consume(w),g)}function v(w){return e.attempt(i,T,S)(w)}function S(w){return e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),b}function b(w){return s>0&&Ie(w)?De(e,j,"linePrefix",s+1)(w):j(w)}function j(w){return w===null||he(w)?e.check(ru,v,T)(w):(e.enter("codeFlowValue"),m(w))}function m(w){return w===null||he(w)?(e.exit("codeFlowValue"),j(w)):(e.consume(w),m)}function T(w){return e.exit("codeFenced"),t(w)}function C(w,N,H){let O=0;return _;function _(P){return w.enter("lineEnding"),w.consume(P),w.exit("lineEnding"),I}function I(P){return w.enter("codeFencedFence"),Ie(P)?De(w,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):z(P)}function z(P){return P===a?(w.enter("codeFencedFenceSequence"),M(P)):H(P)}function M(P){return P===a?(O++,w.consume(P),M):O>=o?(w.exit("codeFencedFenceSequence"),Ie(P)?De(w,A,"whitespace")(P):A(P)):H(P)}function A(P){return P===null||he(P)?(w.exit("codeFencedFence"),N(P)):H(P)}}}function kw(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const eo={name:"codeIndented",tokenize:_w},Sw={partial:!0,tokenize:jw};function _w(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),De(e,s,"linePrefix",5)(c)}function s(c){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):he(c)?e.attempt(Sw,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||he(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function jw(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):he(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):De(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):he(o)?i(o):n(o)}}const Nw={name:"codeText",previous:Cw,resolve:Ew,tokenize:Iw};function Ew(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 Cw(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Iw(e,t,n){let r=0,i,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):he(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(f))}function c(f){return f===null||f===32||f===96||he(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),c)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",c(f))}}class Tw{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&&zr(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),zr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),zr(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);zr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);zr(this.left,n.reverse())}}}function zr(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 fp(e){const t={};let n=-1,r,i,s,o,a,l,c;const d=new Tw(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Aw(d,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},a=d.slice(i,n),a.unshift(r),d.splice(i,n-i+1,a))}}return It(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function Aw(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let d,f,p=-1,h=n,g=0,v=0;const S=[v];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(v=p+1,S.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const b=a.slice(S[p],S[p+1]),j=s.pop();l.push([j,j+b.length-1]),e.splice(j,2,b)}for(l.reverse(),p=-1;++p<l.length;)c[g+l[p][0]]=g+l[p][1],g+=l[p][1]-l[p][0]-1;return c}const zw={resolve:Pw,tokenize:Dw},Ow={partial:!0,tokenize:Rw};function Pw(e){return fp(e),e}function Dw(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):he(a)?e.check(Ow,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Rw(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),De(e,s,"linePrefix")}function s(o){if(o===null||he(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function pp(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return f;function f(b){return b===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(b),e.exit(s),p):b===null||b===32||b===41||ts(b)?n(b):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(b))}function p(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===62?(e.exit("chunkString"),e.exit(a),p(b)):b===null||b===60||he(b)?n(b):(e.consume(b),b===92?g:h)}function g(b){return b===60||b===62||b===92?(e.consume(b),h):h(b)}function v(b){return!d&&(b===null||b===41||Fe(b))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(b)):d<c&&b===40?(e.consume(b),d++,v):b===41?(e.consume(b),d--,v):b===null||b===32||b===40||ts(b)?n(b):(e.consume(b),b===92?S:v)}function S(b){return b===40||b===41||b===92?(e.consume(b),v):v(b)}}function hp(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),d}function d(h){return a>999||h===null||h===91||h===93&&!l||h===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):he(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||he(h)||a++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!Ie(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,f):f(h)}}function mp(e,t,n,r,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,l):n(p)}function l(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),c(p))}function c(p){return p===o?(e.exit(s),l(o)):p===null?n(p):he(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),De(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===o||p===null||he(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?f:d)}function f(p){return p===o||p===92?(e.consume(p),d):d(p)}}function Hr(e,t){let n;return r;function r(i){return he(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ie(i)?De(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Mw={name:"definition",tokenize:Lw},$w={partial:!0,tokenize:Fw};function Lw(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),o(h)}function o(h){return hp.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return i=Vt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Fe(h)?Hr(e,c)(h):c(h)}function c(h){return pp(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt($w,f,f)(h)}function f(h){return Ie(h)?De(e,p,"whitespace")(h):p(h)}function p(h){return h===null||he(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Fw(e,t,n){return r;function r(a){return Fe(a)?Hr(e,i)(a):n(a)}function i(a){return mp(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ie(a)?De(e,o,"whitespace")(a):o(a)}function o(a){return a===null||he(a)?t(a):n(a)}}const Bw={name:"hardBreakEscape",tokenize:Zw};function Zw(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return he(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Vw={name:"headingAtx",resolve:Uw,tokenize:Jw};function Uw(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"},It(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Jw(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Fe(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||he(d)?(e.exit("atxHeading"),t(d)):Ie(d)?De(e,a,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),a(d))}function c(d){return d===null||d===35||Fe(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),c)}}const Hw=["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"],su=["pre","script","style","textarea"],Ww={concrete:!0,name:"htmlFlow",resolveTo:Yw,tokenize:Kw},qw={partial:!0,tokenize:Qw},Gw={partial:!0,tokenize:Xw};function Yw(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 Kw(e,t,n){const r=this;let i,s,o,a,l;return c;function c(y){return d(y)}function d(y){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(y),f}function f(y){return y===33?(e.consume(y),p):y===47?(e.consume(y),s=!0,v):y===63?(e.consume(y),i=3,r.interrupt?t:k):ht(y)?(e.consume(y),o=String.fromCharCode(y),S):n(y)}function p(y){return y===45?(e.consume(y),i=2,h):y===91?(e.consume(y),i=5,a=0,g):ht(y)?(e.consume(y),i=4,r.interrupt?t:k):n(y)}function h(y){return y===45?(e.consume(y),r.interrupt?t:k):n(y)}function g(y){const Z="CDATA[";return y===Z.charCodeAt(a++)?(e.consume(y),a===Z.length?r.interrupt?t:z:g):n(y)}function v(y){return ht(y)?(e.consume(y),o=String.fromCharCode(y),S):n(y)}function S(y){if(y===null||y===47||y===62||Fe(y)){const Z=y===47,V=o.toLowerCase();return!Z&&!s&&su.includes(V)?(i=1,r.interrupt?t(y):z(y)):Hw.includes(o.toLowerCase())?(i=6,Z?(e.consume(y),b):r.interrupt?t(y):z(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(y):s?j(y):m(y))}return y===45||lt(y)?(e.consume(y),o+=String.fromCharCode(y),S):n(y)}function b(y){return y===62?(e.consume(y),r.interrupt?t:z):n(y)}function j(y){return Ie(y)?(e.consume(y),j):_(y)}function m(y){return y===47?(e.consume(y),_):y===58||y===95||ht(y)?(e.consume(y),T):Ie(y)?(e.consume(y),m):_(y)}function T(y){return y===45||y===46||y===58||y===95||lt(y)?(e.consume(y),T):C(y)}function C(y){return y===61?(e.consume(y),w):Ie(y)?(e.consume(y),C):m(y)}function w(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),l=y,N):Ie(y)?(e.consume(y),w):H(y)}function N(y){return y===l?(e.consume(y),l=null,O):y===null||he(y)?n(y):(e.consume(y),N)}function H(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||Fe(y)?C(y):(e.consume(y),H)}function O(y){return y===47||y===62||Ie(y)?m(y):n(y)}function _(y){return y===62?(e.consume(y),I):n(y)}function I(y){return y===null||he(y)?z(y):Ie(y)?(e.consume(y),I):n(y)}function z(y){return y===45&&i===2?(e.consume(y),D):y===60&&i===1?(e.consume(y),U):y===62&&i===4?(e.consume(y),oe):y===63&&i===3?(e.consume(y),k):y===93&&i===5?(e.consume(y),X):he(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(qw,G,M)(y)):y===null||he(y)?(e.exit("htmlFlowData"),M(y)):(e.consume(y),z)}function M(y){return e.check(Gw,A,G)(y)}function A(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),P}function P(y){return y===null||he(y)?M(y):(e.enter("htmlFlowData"),z(y))}function D(y){return y===45?(e.consume(y),k):z(y)}function U(y){return y===47?(e.consume(y),o="",$):z(y)}function $(y){if(y===62){const Z=o.toLowerCase();return su.includes(Z)?(e.consume(y),oe):z(y)}return ht(y)&&o.length<8?(e.consume(y),o+=String.fromCharCode(y),$):z(y)}function X(y){return y===93?(e.consume(y),k):z(y)}function k(y){return y===62?(e.consume(y),oe):y===45&&i===2?(e.consume(y),k):z(y)}function oe(y){return y===null||he(y)?(e.exit("htmlFlowData"),G(y)):(e.consume(y),oe)}function G(y){return e.exit("htmlFlow"),t(y)}}function Xw(e,t,n){const r=this;return i;function i(o){return he(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Qw(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(gi,t,n)}}const e0={name:"htmlText",tokenize:t0};function t0(e,t,n){const r=this;let i,s,o;return a;function a(k){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(k),l}function l(k){return k===33?(e.consume(k),c):k===47?(e.consume(k),C):k===63?(e.consume(k),m):ht(k)?(e.consume(k),H):n(k)}function c(k){return k===45?(e.consume(k),d):k===91?(e.consume(k),s=0,g):ht(k)?(e.consume(k),j):n(k)}function d(k){return k===45?(e.consume(k),h):n(k)}function f(k){return k===null?n(k):k===45?(e.consume(k),p):he(k)?(o=f,U(k)):(e.consume(k),f)}function p(k){return k===45?(e.consume(k),h):f(k)}function h(k){return k===62?D(k):k===45?p(k):f(k)}function g(k){const oe="CDATA[";return k===oe.charCodeAt(s++)?(e.consume(k),s===oe.length?v:g):n(k)}function v(k){return k===null?n(k):k===93?(e.consume(k),S):he(k)?(o=v,U(k)):(e.consume(k),v)}function S(k){return k===93?(e.consume(k),b):v(k)}function b(k){return k===62?D(k):k===93?(e.consume(k),b):v(k)}function j(k){return k===null||k===62?D(k):he(k)?(o=j,U(k)):(e.consume(k),j)}function m(k){return k===null?n(k):k===63?(e.consume(k),T):he(k)?(o=m,U(k)):(e.consume(k),m)}function T(k){return k===62?D(k):m(k)}function C(k){return ht(k)?(e.consume(k),w):n(k)}function w(k){return k===45||lt(k)?(e.consume(k),w):N(k)}function N(k){return he(k)?(o=N,U(k)):Ie(k)?(e.consume(k),N):D(k)}function H(k){return k===45||lt(k)?(e.consume(k),H):k===47||k===62||Fe(k)?O(k):n(k)}function O(k){return k===47?(e.consume(k),D):k===58||k===95||ht(k)?(e.consume(k),_):he(k)?(o=O,U(k)):Ie(k)?(e.consume(k),O):D(k)}function _(k){return k===45||k===46||k===58||k===95||lt(k)?(e.consume(k),_):I(k)}function I(k){return k===61?(e.consume(k),z):he(k)?(o=I,U(k)):Ie(k)?(e.consume(k),I):O(k)}function z(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(e.consume(k),i=k,M):he(k)?(o=z,U(k)):Ie(k)?(e.consume(k),z):(e.consume(k),A)}function M(k){return k===i?(e.consume(k),i=void 0,P):k===null?n(k):he(k)?(o=M,U(k)):(e.consume(k),M)}function A(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||Fe(k)?O(k):(e.consume(k),A)}function P(k){return k===47||k===62||Fe(k)?O(k):n(k)}function D(k){return k===62?(e.consume(k),e.exit("htmlTextData"),e.exit("htmlText"),t):n(k)}function U(k){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),$}function $(k){return Ie(k)?De(e,X,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):X(k)}function X(k){return e.enter("htmlTextData"),o(k)}}const za={name:"labelEnd",resolveAll:s0,resolveTo:o0,tokenize:a0},n0={tokenize:l0},r0={tokenize:u0},i0={tokenize:c0};function s0(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&&It(e,0,e.length,n),e}function o0(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=Ot(a,e.slice(s+1,s+r+3)),a=Ot(a,[["enter",d,t]]),a=Ot(a,Ts(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Ot(a,[["exit",d,t],e[o-2],e[o-1],["exit",c,t]]),a=Ot(a,e.slice(o+1)),a=Ot(a,[["exit",l,t]]),It(e,s,e.length,a),e}function a0(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(p){return s?s._inactive?f(p):(o=r.parser.defined.includes(Vt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(n0,d,o?d:f)(p):p===91?e.attempt(r0,d,o?c:f)(p):o?d(p):f(p)}function c(p){return e.attempt(i0,d,f)(p)}function d(p){return t(p)}function f(p){return s._balanced=!0,n(p)}}function l0(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return Fe(f)?Hr(e,s)(f):s(f)}function s(f){return f===41?d(f):pp(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return Fe(f)?Hr(e,l)(f):d(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?mp(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function c(f){return Fe(f)?Hr(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function u0(e,t,n){const r=this;return i;function i(a){return hp.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Vt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function c0(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 d0={name:"labelStartImage",resolveAll:za.resolveAll,tokenize:f0};function f0(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const p0={name:"labelStartLink",resolveAll:za.resolveAll,tokenize:h0};function h0(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const to={name:"lineEnding",tokenize:m0};function m0(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),De(e,t,"linePrefix")}}const $i={name:"thematicBreak",tokenize:g0};function g0(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||he(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ie(c)?De(e,a,"whitespace")(c):a(c))}}const xt={continuation:{tokenize:v0},exit:k0,name:"list",tokenize:y0},x0={partial:!0,tokenize:S0},b0={partial:!0,tokenize:w0};function y0(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Zo(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check($i,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 Zo(h)&&++o<10?(e.consume(h),l):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):n(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(gi,r.interrupt?n:d,e.attempt(x0,p,f))}function d(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function f(h){return Ie(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 v0(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(gi,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,De(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ie(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(b0,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,De(e,e.attempt(xt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function w0(e,t,n){const r=this;return De(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function k0(e){e.exit(this.containerState.type)}function S0(e,t,n){const r=this;return De(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ie(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ou={name:"setextUnderline",resolveTo:_0,tokenize:j0};function _0(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function j0(e,t,n){const r=this;let i;return s;function s(c){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ie(c)?De(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||he(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const N0={tokenize:E0};function E0(e){const t=this,n=e.attempt(gi,r,e.attempt(this.parser.constructs.flowInitial,i,De(e,e.attempt(this.parser.constructs.flow,i,e.attempt(zw,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 C0={resolveAll:xp()},I0=gp("string"),T0=gp("text");function gp(e){return{resolveAll:xp(e==="text"?A0:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(d){return c(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return c(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function c(d){if(d===null)return!0;const f=i[d];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function xp(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 A0(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const z0={42:xt,43:xt,45:xt,48:xt,49:xt,50:xt,51:xt,52:xt,53:xt,54:xt,55:xt,56:xt,57:xt,62:up},O0={91:Mw},P0={[-2]:eo,[-1]:eo,32:eo},D0={35:Vw,42:$i,45:[ou,$i],60:Ww,61:ou,95:$i,96:iu,126:iu},R0={38:dp,92:cp},M0={[-5]:to,[-4]:to,[-3]:to,33:d0,38:dp,42:Vo,60:[pw,e0],91:p0,92:[Bw,cp],93:za,95:Vo,96:Nw},$0={null:[Vo,C0]},L0={null:[42,95]},F0={null:[]},B0=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:L0,contentInitial:O0,disable:F0,document:z0,flow:D0,flowInitial:P0,insideSpan:$0,string:R0,text:M0},Symbol.toStringTag,{value:"Module"}));function Z0(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(C),check:N(w),consume:j,enter:m,exit:T,interrupt:N(w,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function f(I){return o=Ot(o,I),S(),o[o.length-1]!==null?[]:(H(t,0),c.events=Ts(s,c.events,c),c.events)}function p(I,z){return U0(h(I),z)}function h(I){return V0(o,I)}function g(){const{_bufferIndex:I,_index:z,line:M,column:A,offset:P}=r;return{_bufferIndex:I,_index:z,line:M,column:A,offset:P}}function v(I){i[I.line]=I.column,_()}function S(){let I;for(;r._index<o.length;){const z=o[r._index];if(typeof z=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<z.length;)b(z.charCodeAt(r._bufferIndex));else b(z)}}function b(I){d=d(I)}function j(I){he(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,_()):I!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=I}function m(I,z){const M=z||{};return M.type=I,M.start=g(),c.events.push(["enter",M,c]),a.push(M),M}function T(I){const z=a.pop();return z.end=g(),c.events.push(["exit",z,c]),z}function C(I,z){H(I,z.from)}function w(I,z){z.restore()}function N(I,z){return M;function M(A,P,D){let U,$,X,k;return Array.isArray(A)?G(A):"tokenize"in A?G([A]):oe(A);function oe(ie){return se;function se(re){const de=re!==null&&ie[re],ge=re!==null&&ie.null,Ee=[...Array.isArray(de)?de:de?[de]:[],...Array.isArray(ge)?ge:ge?[ge]:[]];return G(Ee)(re)}}function G(ie){return U=ie,$=0,ie.length===0?D:y(ie[$])}function y(ie){return se;function se(re){return k=O(),X=ie,ie.partial||(c.currentConstruct=ie),ie.name&&c.parser.constructs.disable.null.includes(ie.name)?V():ie.tokenize.call(z?Object.assign(Object.create(c),z):c,l,Z,V)(re)}}function Z(ie){return I(X,k),P}function V(ie){return k.restore(),++$<U.length?y(U[$]):D}}}function H(I,z){I.resolveAll&&!s.includes(I)&&s.push(I),I.resolve&&It(c.events,z,c.events.length-z,I.resolve(c.events.slice(z),c)),I.resolveTo&&(c.events=I.resolveTo(c.events,c))}function O(){const I=g(),z=c.previous,M=c.currentConstruct,A=c.events.length,P=Array.from(a);return{from:A,restore:D};function D(){r=I,c.previous=z,c.currentConstruct=M,c.events.length=A,a=P,_()}}function _(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function V0(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function U0(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
11
|
+
`;break}case-3:{o=`\r
|
|
12
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function J0(e){const r={constructs:ap([B0,...(e||{}).extensions||[]]),content:i(ow),defined:[],document:i(lw),flow:i(N0),lazy:{},string:i(I0),text:i(T0)};return r;function i(s){return o;function o(a){return Z0(r,s,a)}}}function H0(e){for(;!fp(e););return e}const au=/[\0\t\n\r]/g;function W0(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,d,f,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(au.lastIndex=f,c=au.exec(s),p=c&&c.index!==void 0?c.index:s.length,h=s.charCodeAt(p),!c){t=s.slice(f);break}if(h===10&&f===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<p&&(l.push(s.slice(f,p)),e+=p-f),h){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const q0=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function G0(e){return e.replace(q0,Y0)}function Y0(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return lp(n.slice(s?2:1),s?16:10)}return Aa(n)||e}const bp={}.hasOwnProperty;function K0(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),X0(n)(H0(J0(n).document().write(W0()(e,t,!0))))}function X0(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(R),autolinkProtocol:O,autolinkEmail:O,atxHeading:s(Oe),blockQuote:s(ge),characterEscape:O,characterReference:O,codeFenced:s(Ee),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Ee,o),codeText:s(ye,o),codeTextData:O,data:O,codeFlowValue:O,definition:s(xe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(W),hardBreakEscape:s(Q),hardBreakTrailing:s(Q),htmlFlow:s(ve,o),htmlFlowData:O,htmlText:s(ve,o),htmlTextData:O,image:s(E),label:o,link:s(R),listItem:s(te),listItemValue:p,listOrdered:s(L,f),listUnordered:s(L),paragraph:s(K),reference:y,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Oe),strong:s(ee),thematicBreak:s(be)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:de,autolinkProtocol:re,blockQuote:l(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:ie,characterReference:se,codeFenced:l(S),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:_,codeIndented:l(b),codeText:l(P),codeTextData:_,data:_,definition:l(),definitionDestinationString:T,definitionLabelString:j,definitionTitleString:m,emphasis:l(),hardBreakEscape:l(z),hardBreakTrailing:l(z),htmlFlow:l(M),htmlFlowData:_,htmlText:l(A),htmlTextData:_,image:l(U),label:X,labelText:$,lineEnding:I,link:l(D),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Z,resourceDestinationString:k,resourceTitleString:oe,resource:G,setextHeading:l(H),setextHeadingLineSequence:N,setextHeadingText:w,strong:l(),thematicBreak:l()}};yp(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(B){let Y={type:"root",children:[]};const fe={stack:[Y],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:d,data:n},_e=[];let F=-1;for(;++F<B.length;)if(B[F][1].type==="listOrdered"||B[F][1].type==="listUnordered")if(B[F][0]==="enter")_e.push(F);else{const pe=_e.pop();F=i(B,pe,F)}for(F=-1;++F<B.length;){const pe=t[B[F][0]];bp.call(pe,B[F][1].type)&&pe[B[F][1].type].call(Object.assign({sliceSerialize:B[F][2].sliceSerialize},fe),B[F][1])}if(fe.tokenStack.length>0){const pe=fe.tokenStack[fe.tokenStack.length-1];(pe[1]||lu).call(fe,void 0,pe[0])}for(Y.position={start:dn(B.length>0?B[0][1].start:{line:1,column:1,offset:0}),end:dn(B.length>0?B[B.length-2][1].end:{line:1,column:1,offset:0})},F=-1;++F<t.transforms.length;)Y=t.transforms[F](Y)||Y;return Y}function i(B,Y,fe){let _e=Y-1,F=-1,pe=!1,Te,Be,rt,tt;for(;++_e<=fe;){const at=B[_e];switch(at[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{at[0]==="enter"?F++:F--,tt=void 0;break}case"lineEndingBlank":{at[0]==="enter"&&(Te&&!tt&&!F&&!rt&&(rt=_e),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!F&&at[0]==="enter"&&at[1].type==="listItemPrefix"||F===-1&&at[0]==="exit"&&(at[1].type==="listUnordered"||at[1].type==="listOrdered")){if(Te){let un=_e;for(Be=void 0;un--;){const en=B[un];if(en[1].type==="lineEnding"||en[1].type==="lineEndingBlank"){if(en[0]==="exit")continue;Be&&(B[Be][1].type="lineEndingBlank",pe=!0),en[1].type="lineEnding",Be=un}else if(!(en[1].type==="linePrefix"||en[1].type==="blockQuotePrefix"||en[1].type==="blockQuotePrefixWhitespace"||en[1].type==="blockQuoteMarker"||en[1].type==="listItemIndent"))break}rt&&(!Be||rt<Be)&&(Te._spread=!0),Te.end=Object.assign({},Be?B[Be][1].start:at[1].end),B.splice(Be||_e,0,["exit",Te,at[2]]),_e++,fe++}if(at[1].type==="listItemPrefix"){const un={type:"listItem",_spread:!1,start:Object.assign({},at[1].start),end:void 0};Te=un,B.splice(_e,0,["enter",un,at[2]]),_e++,fe++,rt=void 0,tt=!0}}}return B[Y][1]._spread=pe,fe}function s(B,Y){return fe;function fe(_e){a.call(this,B(_e),_e),Y&&Y.call(this,_e)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(B,Y,fe){this.stack[this.stack.length-1].children.push(B),this.stack.push(B),this.tokenStack.push([Y,fe||void 0]),B.position={start:dn(Y.start),end:void 0}}function l(B){return Y;function Y(fe){B&&B.call(this,fe),c.call(this,fe)}}function c(B,Y){const fe=this.stack.pop(),_e=this.tokenStack.pop();if(_e)_e[0].type!==B.type&&(Y?Y.call(this,B,_e[0]):(_e[1]||lu).call(this,B,_e[0]));else throw new Error("Cannot close `"+B.type+"` ("+Jr({start:B.start,end:B.end})+"): it’s not open");fe.position.end=dn(B.end)}function d(){return Ta(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(B){if(this.data.expectingFirstListItemValue){const Y=this.stack[this.stack.length-2];Y.start=Number.parseInt(this.sliceSerialize(B),10),this.data.expectingFirstListItemValue=void 0}}function h(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.lang=B}function g(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.meta=B}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B.replace(/(\r?\n|\r)$/g,"")}function j(B){const Y=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Y,fe.identifier=Vt(this.sliceSerialize(B)).toLowerCase()}function m(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.title=B}function T(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.url=B}function C(B){const Y=this.stack[this.stack.length-1];if(!Y.depth){const fe=this.sliceSerialize(B).length;Y.depth=fe}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function N(B){const Y=this.stack[this.stack.length-1];Y.depth=this.sliceSerialize(B).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function O(B){const fe=this.stack[this.stack.length-1].children;let _e=fe[fe.length-1];(!_e||_e.type!=="text")&&(_e=ue(),_e.position={start:dn(B.start),end:void 0},fe.push(_e)),this.stack.push(_e)}function _(B){const Y=this.stack.pop();Y.value+=this.sliceSerialize(B),Y.position.end=dn(B.end)}function I(B){const Y=this.stack[this.stack.length-1];if(this.data.atHardBreak){const fe=Y.children[Y.children.length-1];fe.position.end=dn(B.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Y.type)&&(O.call(this,B),_.call(this,B))}function z(){this.data.atHardBreak=!0}function M(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B}function A(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B}function P(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B}function D(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=Y,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function U(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=Y,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function $(B){const Y=this.sliceSerialize(B),fe=this.stack[this.stack.length-2];fe.label=G0(Y),fe.identifier=Vt(Y).toLowerCase()}function X(){const B=this.stack[this.stack.length-1],Y=this.resume(),fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,fe.type==="link"){const _e=B.children;fe.children=_e}else fe.alt=Y}function k(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.url=B}function oe(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.title=B}function G(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function Z(B){const Y=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Y,fe.identifier=Vt(this.sliceSerialize(B)).toLowerCase(),this.data.referenceType="full"}function V(B){this.data.characterReferenceType=B.type}function ie(B){const Y=this.sliceSerialize(B),fe=this.data.characterReferenceType;let _e;fe?(_e=lp(Y,fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_e=Aa(Y);const F=this.stack[this.stack.length-1];F.value+=_e}function se(B){const Y=this.stack.pop();Y.position.end=dn(B.end)}function re(B){_.call(this,B);const Y=this.stack[this.stack.length-1];Y.url=this.sliceSerialize(B)}function de(B){_.call(this,B);const Y=this.stack[this.stack.length-1];Y.url="mailto:"+this.sliceSerialize(B)}function ge(){return{type:"blockquote",children:[]}}function Ee(){return{type:"code",lang:null,meta:null,value:""}}function ye(){return{type:"inlineCode",value:""}}function xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function W(){return{type:"emphasis",children:[]}}function Oe(){return{type:"heading",depth:0,children:[]}}function Q(){return{type:"break"}}function ve(){return{type:"html",value:""}}function E(){return{type:"image",title:null,url:"",alt:null}}function R(){return{type:"link",title:null,url:"",children:[]}}function L(B){return{type:"list",ordered:B.type==="listOrdered",start:null,spread:B._spread,children:[]}}function te(B){return{type:"listItem",spread:B._spread,checked:null,children:[]}}function K(){return{type:"paragraph",children:[]}}function ee(){return{type:"strong",children:[]}}function ue(){return{type:"text",value:""}}function be(){return{type:"thematicBreak"}}}function dn(e){return{line:e.line,column:e.column,offset:e.offset}}function yp(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?yp(e,r):Q0(e,r)}}function Q0(e,t){let n;for(n in t)if(bp.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 lu(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Jr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Jr({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Jr({start:t.start,end:t.end})+") is still open")}function ek(e){const t=this;t.parser=n;function n(r){return K0(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function tk(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 nk(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
13
|
+
`}]}function rk(e,t){const n=t.value?t.value+`
|
|
14
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function ik(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sk(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ok(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=kr(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function ak(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 lk(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function vp(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function uk(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vp(e,t);const i={src:kr(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 ck(e,t){const n={src:kr(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 dk(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 fk(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vp(e,t);const i={href:kr(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 pk(e,t){const n={href:kr(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 hk(e,t,n){const r=e.all(t),i=n?mk(n):wp(t),s={},o=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const d=r[a];(i||a!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
|
|
15
|
+
`}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
|
|
16
|
+
`});const c={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,c),e.applyData(t,c)}function mk(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=wp(n[r])}return t}function wp(e){const t=e.spread;return t??e.children.length>1}function gk(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function xk(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bk(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function yk(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vk(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=Na(t.children[1]),l=ep(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function wk(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const c=[];for(;++l<a;){const f=t.children[l],p={},h=o?o[l]:void 0;h&&(p.align=h);let g={type:"element",tagName:s,properties:p,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),c.push(g)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,d),e.applyData(t,d)}function kk(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const uu=9,cu=32;function Sk(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(du(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(du(t.slice(i),i>0,!1)),s.join("")}function du(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===uu||s===cu;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===uu||s===cu;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function _k(e,t){const n={type:"text",value:Sk(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function jk(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Nk={blockquote:tk,break:nk,code:rk,delete:ik,emphasis:sk,footnoteReference:ok,heading:ak,html:lk,imageReference:uk,image:ck,inlineCode:dk,linkReference:fk,link:pk,listItem:hk,list:gk,paragraph:xk,root:bk,strong:yk,table:vk,tableCell:kk,tableRow:wk,text:_k,thematicBreak:jk,toml:Ni,yaml:Ni,definition:Ni,footnoteDefinition:Ni};function Ni(){}const kp=-1,As=0,Wr=1,ns=2,Oa=3,Pa=4,Da=5,Ra=6,Sp=7,_p=8,fu=typeof self=="object"?self:globalThis,Ek=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case As:case kp:return n(o,i);case Wr:{const a=n([],i);for(const l of o)a.push(r(l));return a}case ns:{const a=n({},i);for(const[l,c]of o)a[r(l)]=r(c);return a}case Oa:return n(new Date(o),i);case Pa:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case Da:{const a=n(new Map,i);for(const[l,c]of o)a.set(r(l),r(c));return a}case Ra:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case Sp:{const{name:a,message:l}=o;return n(new fu[a](l),i)}case _p:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new fu[s](o),i)};return r},pu=e=>Ek(new Map,e)(0),qn="",{toString:Ck}={},{keys:Ik}=Object,Or=e=>{const t=typeof e;if(t!=="object"||!e)return[As,t];const n=Ck.call(e).slice(8,-1);switch(n){case"Array":return[Wr,qn];case"Object":return[ns,qn];case"Date":return[Oa,qn];case"RegExp":return[Pa,qn];case"Map":return[Da,qn];case"Set":return[Ra,qn];case"DataView":return[Wr,n]}return n.includes("Array")?[Wr,n]:n.includes("Error")?[Sp,n]:[ns,n]},Ei=([e,t])=>e===As&&(t==="function"||t==="symbol"),Tk=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=Or(o);switch(a){case As:{let d=o;switch(l){case"bigint":a=_p,d=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);d=null;break;case"undefined":return i([kp],o)}return i([a,d],o)}case Wr:{if(l){let p=o;return l==="DataView"?p=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(p=new Uint8Array(o)),i([l,[...p]],o)}const d=[],f=i([a,d],o);for(const p of o)d.push(s(p));return f}case ns:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const d=[],f=i([a,d],o);for(const p of Ik(o))(e||!Ei(Or(o[p])))&&d.push([s(p),s(o[p])]);return f}case Oa:return i([a,o.toISOString()],o);case Pa:{const{source:d,flags:f}=o;return i([a,{source:d,flags:f}],o)}case Da:{const d=[],f=i([a,d],o);for(const[p,h]of o)(e||!(Ei(Or(p))||Ei(Or(h))))&&d.push([s(p),s(h)]);return f}case Ra:{const d=[],f=i([a,d],o);for(const p of o)(e||!Ei(Or(p)))&&d.push(s(p));return f}}const{message:c}=o;return i([a,{name:l,message:c}],o)};return s},hu=(e,{json:t,lossy:n}={})=>{const r=[];return Tk(!(t||n),!!t,new Map,r)(e),r},rs=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?pu(hu(e,t)):structuredClone(e):(e,t)=>pu(hu(e,t));function Ak(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 zk(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Ok(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Ak,r=e.options.footnoteBackLabel||zk,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const c=e.footnoteById.get(e.footnoteOrder[l]);if(!c)continue;const d=e.all(c),f=String(c.identifier).toUpperCase(),p=kr(f.toLowerCase());let h=0;const g=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){g.length>0&&g.push({type:"text",value:" "});let j=typeof n=="string"?n:n(l,h);typeof j=="string"&&(j={type:"text",value:j}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,h),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const S=d[d.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const j=S.children[S.children.length-1];j&&j.type==="text"?j.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...g)}else d.push(...g);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(c,b),a.push(b)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...rs(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
17
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
18
|
+
`}]}}const zs=function(e){if(e==null)return Mk;if(typeof e=="function")return Os(e);if(typeof e=="object")return Array.isArray(e)?Pk(e):Dk(e);if(typeof e=="string")return Rk(e);throw new Error("Expected function, string, or object as test")};function Pk(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=zs(e[n]);return Os(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Dk(e){const t=e;return Os(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Rk(e){return Os(t);function t(n){return n&&n.type===e}}function Os(e){return t;function t(n,r,i){return!!($k(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Mk(){return!0}function $k(e){return e!==null&&typeof e=="object"&&"type"in e}const jp=[],Lk=!0,Uo=!1,Fk="skip";function Np(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=zs(i),o=r?-1:1;a(e,void 0,[])();function a(l,c,d){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=jp,g,v,S;if((!t||s(l,c,d[d.length-1]||void 0))&&(h=Bk(n(l,d)),h[0]===Uo))return h;if("children"in l&&l.children){const b=l;if(b.children&&h[0]!==Fk)for(v=(r?b.children.length:-1)+o,S=d.concat(b);v>-1&&v<b.children.length;){const j=b.children[v];if(g=a(j,v,S)(),g[0]===Uo)return g;v=typeof g[1]=="number"?g[1]:v+o}}return h}}}function Bk(e){return Array.isArray(e)?e:typeof e=="number"?[Lk,e]:e==null?jp:[e]}function Ma(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),Np(e,s,a,i);function a(l,c){const d=c[c.length-1],f=d?d.children.indexOf(l):void 0;return o(l,f,d)}}const Jo={}.hasOwnProperty,Zk={};function Vk(e,t){const n=t||Zk,r=new Map,i=new Map,s=new Map,o={...Nk,...n.handlers},a={all:c,applyData:Jk,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:Uk,wrap:Wk};return Ma(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:i,p=String(d.identifier).toUpperCase();f.has(p)||f.set(p,d)}}),a;function l(d,f){const p=d.type,h=a.handlers[p];if(Jo.call(a.handlers,p)&&h)return h(a,d,f);if(a.options.passThrough&&a.options.passThrough.includes(p)){if("children"in d){const{children:v,...S}=d,b=rs(S);return b.children=a.all(d),b}return rs(d)}return(a.options.unknownHandler||Hk)(a,d,f)}function c(d){const f=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const g=a.one(p[h],d);if(g){if(h&&p[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=mu(g.value)),!Array.isArray(g)&&g.type==="element")){const v=g.children[0];v&&v.type==="text"&&(v.value=mu(v.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function Uk(e,t){e.position&&(t.position=zv(e))}function Jk(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,rs(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Hk(e,t){const n=t.data||{},r="value"in t&&!(Jo.call(n,"hProperties")||Jo.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 Wk(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
19
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
20
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
21
|
+
`}),n}function mu(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function gu(e,t){const n=Vk(e,t),r=n.one(e,void 0),i=Ok(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
22
|
+
`},i),s}function qk(e,t){return e&&"run"in e?async function(n,r){const i=gu(n,{file:r,...t});await e.run(i,r)}:function(n,r){return gu(n,{file:r,...e||t})}}function xu(e){if(e)throw e}var no,bu;function Gk(){if(bu)return no;bu=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(c){return typeof Array.isArray=="function"?Array.isArray(c):t.call(c)==="[object Array]"},s=function(c){if(!c||t.call(c)!=="[object Object]")return!1;var d=e.call(c,"constructor"),f=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!d&&!f)return!1;var p;for(p in c);return typeof p>"u"||e.call(c,p)},o=function(c,d){n&&d.name==="__proto__"?n(c,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):c[d.name]=d.newValue},a=function(c,d){if(d==="__proto__")if(e.call(c,d)){if(r)return r(c,d).value}else return;return c[d]};return no=function l(){var c,d,f,p,h,g,v=arguments[0],S=1,b=arguments.length,j=!1;for(typeof v=="boolean"&&(j=v,v=arguments[1]||{},S=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});S<b;++S)if(c=arguments[S],c!=null)for(d in c)f=a(v,d),p=a(c,d),v!==p&&(j&&p&&(s(p)||(h=i(p)))?(h?(h=!1,g=f&&i(f)?f:[]):g=f&&s(f)?f:{},o(v,{name:d,newValue:l(j,g,p)})):typeof p<"u"&&o(v,{name:d,newValue:p}));return v},no}var Yk=Gk();const ro=oa(Yk);function Ho(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 Kk(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...c){const d=e[++s];let f=-1;if(l){o(l);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,d?Xk(d,a)(...c):o(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Xk(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(c){const d=c;if(a&&n)throw d;return i(d)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const Wt={basename:Qk,dirname:e1,extname:t1,join:n1,sep:"/"};function Qk(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');xi(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function e1(e){if(xi(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 t1(e){xi(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function n1(...e){let t=-1,n;for(;++t<e.length;)xi(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":r1(n)}function r1(e){xi(e);const t=e.codePointAt(0)===47;let n=i1(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function i1(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function xi(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const s1={cwd:o1};function o1(){return"/"}function Wo(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function a1(e){if(typeof e=="string")e=new URL(e);else if(!Wo(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 l1(e)}function l1(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 io=["history","path","basename","stem","extname","dirname"];class Ep{constructor(t){let n;t?Wo(t)?n={path:t}:typeof t=="string"||u1(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":s1.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<io.length;){const s=io[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)io.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Wt.basename(this.path):void 0}set basename(t){oo(t,"basename"),so(t,"basename"),this.path=Wt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Wt.dirname(this.path):void 0}set dirname(t){yu(this.basename,"dirname"),this.path=Wt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Wt.extname(this.path):void 0}set extname(t){if(so(t,"extname"),yu(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Wt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Wo(t)&&(t=a1(t)),oo(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Wt.basename(this.path,this.extname):void 0}set stem(t){oo(t,"stem"),so(t,"stem"),this.path=Wt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new ut(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function so(e,t){if(e&&e.includes(Wt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Wt.sep+"`")}function oo(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function yu(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function u1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const c1=function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s},d1={}.hasOwnProperty;class $a extends c1{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=Kk()}copy(){const t=new $a;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ro(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(uo("data",this.frozen),this.namespace[t]=n,this):d1.call(this.namespace,t)&&this.namespace[t]||void 0:t?(uo("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=Ci(t),r=this.parser||this.Parser;return ao("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ao("process",this.parser||this.Parser),lo("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=Ci(t),l=r.parse(a);r.run(l,a,function(d,f,p){if(d||!f||!p)return c(d);const h=f,g=r.stringify(h,p);h1(g)?p.value=g:p.result=g,c(d,p)});function c(d,f){d||!f?o(d):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),ao("processSync",this.parser||this.Parser),lo("processSync",this.compiler||this.Compiler),this.process(t,i),wu("processSync","process",n),r;function i(s,o){n=!0,xu(s),r=o}}run(t,n,r){vu(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const l=Ci(n);i.run(t,l,c);function c(d,f,p){const h=f||t;d?a(d):o?o(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),wu("runSync","run",r),i;function s(o,a){xu(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=Ci(n),i=this.compiler||this.Compiler;return lo("stringify",i),vu(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(uo("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[d,...f]=c;l(d,f)}else o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(c.plugins),c.settings&&(i.settings=ro(!0,i.settings,c.settings))}function a(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){const f=c[d];s(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===c){p=f;break}if(p===-1)r.push([c,...d]);else if(d.length>0){let[h,...g]=d;const v=r[p][1];Ho(v)&&Ho(h)&&(h=ro(!0,v,h)),r[p]=[c,h,...g]}}}}const f1=new $a().freeze();function ao(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function lo(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function uo(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 vu(e){if(!Ho(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function wu(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ci(e){return p1(e)?e:new Ep(e)}function p1(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h1(e){return typeof e=="string"||m1(e)}function m1(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const g1="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",ku=[],Su={allowDangerousHtml:!0},x1=/^(https?|ircs?|mailto|xmpp)$/i,b1=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function y1(e){const t=v1(e),n=w1(e);return k1(t.runSync(t.parse(n),n),e)}function v1(e){const t=e.rehypePlugins||ku,n=e.remarkPlugins||ku,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Su}:Su;return f1().use(ek).use(n).use(qk,r).use(t)}function w1(e){const t=e.children||"",n=new Ep;return typeof t=="string"&&(n.value=t),n}function k1(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||S1;for(const d of b1)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+g1+d.id,void 0);return Ma(e,c),Mv(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return o?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in Qs)if(Object.hasOwn(Qs,h)&&Object.hasOwn(d.properties,h)){const g=d.properties[h],v=Qs[h];(v===null||v.includes(d.tagName))&&(d.properties[h]=l(String(g||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return a&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function S1(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||x1.test(e.slice(0,t))?e:""}function _u(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 _1(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function j1(e,t,n){const i=zs((n||{}).ignore||[]),s=N1(t);let o=-1;for(;++o<s.length;)Np(e,"text",a);function a(c,d){let f=-1,p;for(;++f<d.length;){const h=d[f],g=p?p.children:void 0;if(i(h,g?g.indexOf(h):void 0,p))return;p=h}if(p)return l(c,d)}function l(c,d){const f=d[d.length-1],p=s[o][0],h=s[o][1];let g=0;const S=f.children.indexOf(c);let b=!1,j=[];p.lastIndex=0;let m=p.exec(c.value);for(;m;){const T=m.index,C={index:m.index,input:m.input,stack:[...d,c]};let w=h(...m,C);if(typeof w=="string"&&(w=w.length>0?{type:"text",value:w}:void 0),w===!1?p.lastIndex=T+1:(g!==T&&j.push({type:"text",value:c.value.slice(g,T)}),Array.isArray(w)?j.push(...w):w&&j.push(w),g=T+m[0].length,b=!0),!p.global)break;m=p.exec(c.value)}return b?(g<c.value.length&&j.push({type:"text",value:c.value.slice(g)}),f.children.splice(S,1,...j)):j=[c],S+j.length}}function N1(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([E1(i[0]),C1(i[1])])}return t}function E1(e){return typeof e=="string"?new RegExp(_1(e),"g"):e}function C1(e){return typeof e=="function"?e:function(){return e}}const co="phrasing",fo=["autolink","link","image","label"];function I1(){return{transforms:[R1],enter:{literalAutolink:A1,literalAutolinkEmail:po,literalAutolinkHttp:po,literalAutolinkWww:po},exit:{literalAutolink:D1,literalAutolinkEmail:P1,literalAutolinkHttp:z1,literalAutolinkWww:O1}}}function T1(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:co,notInConstruct:fo},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:co,notInConstruct:fo},{character:":",before:"[ps]",after:"\\/",inConstruct:co,notInConstruct:fo}]}}function A1(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function po(e){this.config.enter.autolinkProtocol.call(this,e)}function z1(e){this.config.exit.autolinkProtocol.call(this,e)}function O1(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 P1(e){this.config.exit.autolinkEmail.call(this,e)}function D1(e){this.exit(e)}function R1(e){j1(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,M1],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),$1]],{ignore:["link","linkReference"]})}function M1(e,t,n,r,i){let s="";if(!Cp(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!L1(n)))return!1;const o=F1(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function $1(e,t,n,r){return!Cp(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function L1(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 F1(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=_u(e,"(");let s=_u(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 Cp(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Mn(n)||Is(n))&&(!t||n!==47)}Ip.peek=G1;function B1(){this.buffer()}function Z1(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function V1(){this.buffer()}function U1(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function J1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Vt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function H1(e){this.exit(e)}function W1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Vt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function q1(e){this.exit(e)}function G1(){return"["}function Ip(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function Y1(){return{enter:{gfmFootnoteCallString:B1,gfmFootnoteCall:Z1,gfmFootnoteDefinitionLabelString:V1,gfmFootnoteDefinition:U1},exit:{gfmFootnoteCallString:J1,gfmFootnoteCall:H1,gfmFootnoteDefinitionLabelString:W1,gfmFootnoteDefinition:q1}}}function K1(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Ip},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const c=s.enter("footnoteDefinition"),d=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),d(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
|
|
23
|
+
`:" ")+s.indentLines(s.containerFlow(r,a.current()),t?Tp:X1))),c(),l}}function X1(e,t,n){return t===0?e:Tp(e,t,n)}function Tp(e,t,n){return(n?"":" ")+e}const Q1=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ap.peek=iS;function eS(){return{canContainEols:["delete"],enter:{strikethrough:nS},exit:{strikethrough:rS}}}function tS(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Q1}],handlers:{delete:Ap}}}function nS(e){this.enter({type:"delete",children:[]},e)}function rS(e){this.exit(e)}function Ap(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function iS(){return"~"}function sS(e){return e.length}function oS(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||sS,s=[],o=[],a=[],l=[];let c=0,d=-1;for(;++d<e.length;){const v=[],S=[];let b=-1;for(e[d].length>c&&(c=e[d].length);++b<e[d].length;){const j=aS(e[d][b]);if(n.alignDelimiters!==!1){const m=i(j);S[b]=m,(l[b]===void 0||m>l[b])&&(l[b]=m)}v.push(j)}o[d]=v,a[d]=S}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<c;)s[f]=ju(r[f]);else{const v=ju(r);for(;++f<c;)s[f]=v}f=-1;const p=[],h=[];for(;++f<c;){const v=s[f];let S="",b="";v===99?(S=":",b=":"):v===108?S=":":v===114&&(b=":");let j=n.alignDelimiters===!1?1:Math.max(1,l[f]-S.length-b.length);const m=S+"-".repeat(j)+b;n.alignDelimiters!==!1&&(j=S.length+j+b.length,j>l[f]&&(l[f]=j),h[f]=j),p[f]=m}o.splice(1,0,p),a.splice(1,0,h),d=-1;const g=[];for(;++d<o.length;){const v=o[d],S=a[d];f=-1;const b=[];for(;++f<c;){const j=v[f]||"";let m="",T="";if(n.alignDelimiters!==!1){const C=l[f]-(S[f]||0),w=s[f];w===114?m=" ".repeat(C):w===99?C%2?(m=" ".repeat(C/2+.5),T=" ".repeat(C/2-.5)):(m=" ".repeat(C/2),T=m):T=" ".repeat(C)}n.delimiterStart!==!1&&!f&&b.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&j==="")&&(n.delimiterStart!==!1||f)&&b.push(" "),n.alignDelimiters!==!1&&b.push(m),b.push(j),n.alignDelimiters!==!1&&b.push(T),n.padding!==!1&&b.push(" "),(n.delimiterEnd!==!1||f!==c-1)&&b.push("|")}g.push(n.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return g.join(`
|
|
24
|
+
`)}function aS(e){return e==null?"":String(e)}function ju(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 lS(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),uS);return i(),o}function uS(e,t,n){return">"+(n?"":" ")+e}function cS(e,t){return Nu(e,t.inConstruct,!0)&&!Nu(e,t.notInConstruct,!1)}function Nu(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 Eu(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
25
|
+
`&&cS(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
26
|
+
`}function dS(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function fS(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 pS(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 hS(e,t,n,r){const i=pS(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(fS(e,n)){const f=n.enter("codeIndented"),p=n.indentLines(s,mS);return f(),p}const a=n.createTracker(r),l=i.repeat(Math.max(dS(s,i)+1,3)),c=n.enter("codeFenced");let d=a.move(l);if(e.lang){const f=n.enter(`codeFencedLang${o}`);d+=a.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...a.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${o}`);d+=a.move(" "),d+=a.move(n.safe(e.meta,{before:d,after:`
|
|
27
|
+
`,encode:["`"],...a.current()})),f()}return d+=a.move(`
|
|
28
|
+
`),s&&(d+=a.move(s+`
|
|
29
|
+
`)),d+=a.move(l),c(),d}function mS(e,t,n){return(n?"":" ")+e}function La(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 gS(e,t,n,r){const i=La(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":`
|
|
30
|
+
`,...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),o(),c}function xS(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 ri(e){return"&#x"+e.toString(16).toUpperCase()+";"}function is(e,t,n){const r=mr(e),i=mr(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}}zp.peek=bS;function zp(e,t,n,r){const i=xS(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),d=is(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=ri(c)+l.slice(1));const f=l.charCodeAt(l.length-1),p=is(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+ri(f));const h=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},a+l+h}function bS(e,t,n){return n.options.emphasis||"*"}function yS(e,t){let n=!1;return Ma(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Uo}),!!((!e.depth||e.depth<3)&&Ta(e)&&(t.options.setext||n))}function vS(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(yS(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
31
|
+
`,after:`
|
|
32
|
+
`});return f(),d(),p+`
|
|
33
|
+
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
34
|
+
`))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let c=n.containerPhrasing(e,{before:"# ",after:`
|
|
35
|
+
`,...s.current()});return/^[\t ]/.test(c)&&(c=ri(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),a(),c}Op.peek=wS;function Op(e){return e.value||""}function wS(){return"<"}Pp.peek=kS;function Pp(e,t,n,r){const i=La(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(e.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),o(),c}function kS(){return"!"}Dp.peek=SS;function Dp(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!c||c!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function SS(){return"!"}Rp.peek=_S;function Rp(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function _S(){return"`"}function Mp(e,t){const n=Ta(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))}$p.peek=jS;function $p(e,t,n,r){const i=La(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(Mp(e,n)){const d=n.stack;n.stack=[],a=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(e,{before:f,after:">",...o.current()})),f+=o.move(">"),a(),n.stack=d,f}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=o.move(" "+i),c+=o.move(n.safe(e.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),a(),c}function jS(e,t,n){return Mp(e,n)?"<":"["}Lp.peek=NS;function Lp(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const d=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=d,s(),i==="full"||!c||c!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function NS(){return"["}function Fa(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 ES(e){const t=Fa(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 CS(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 Fp(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 IS(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?CS(n):Fa(n);const a=e.ordered?o==="."?")":".":ES(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Fp(n)===o&&d){let f=-1;for(;++f<e.children.length;){const p=e.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const c=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),c}function TS(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 AS(e,t,n,r){const i=TS(n);let s=n.bulletCurrent||Fa(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,a.current()),d);return l(),c;function d(f,p,h){return p?(h?"":" ".repeat(o))+f:(h?s:s+" ".repeat(o-s.length))+f}}function zS(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const OS=zs(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function PS(e,t,n,r){return(e.children.some(function(o){return OS(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function DS(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Bp.peek=RS;function Bp(e,t,n,r){const i=DS(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),d=is(r.before.charCodeAt(r.before.length-1),c,i);d.inside&&(l=ri(c)+l.slice(1));const f=l.charCodeAt(l.length-1),p=is(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+ri(f));const h=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},a+l+h}function RS(e,t,n){return n.options.strong||"*"}function MS(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 LS(e,t,n){const r=(Fp(n)+(n.options.ruleSpaces?" ":"")).repeat($S(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Zp={blockquote:lS,break:Eu,code:hS,definition:gS,emphasis:zp,hardBreak:Eu,heading:vS,html:Op,image:Pp,imageReference:Dp,inlineCode:Rp,link:$p,linkReference:Lp,list:IS,listItem:AS,paragraph:zS,root:PS,strong:Bp,text:MS,thematicBreak:LS};function FS(){return{enter:{table:BS,tableData:Cu,tableHeader:Cu,tableRow:VS},exit:{codeText:US,table:ZS,tableData:ho,tableHeader:ho,tableRow:ho}}}function BS(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 ZS(e){this.exit(e),this.data.inTable=void 0}function VS(e){this.enter({type:"tableRow",children:[]},e)}function ho(e){this.exit(e)}function Cu(e){this.enter({type:"tableCell",children:[]},e)}function US(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,JS));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function JS(e,t){return t==="|"?t:e}function HS(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
36
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:a}};function o(h,g,v,S){return c(d(h,v,S),h.align)}function a(h,g,v,S){const b=f(h,v,S),j=c([b]);return j.slice(0,j.indexOf(`
|
|
37
|
+
`))}function l(h,g,v,S){const b=v.enter("tableCell"),j=v.enter("phrasing"),m=v.containerPhrasing(h,{...S,before:s,after:s});return j(),b(),m}function c(h,g){return oS(h,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function d(h,g,v){const S=h.children;let b=-1;const j=[],m=g.enter("table");for(;++b<S.length;)j[b]=f(S[b],g,v);return m(),j}function f(h,g,v){const S=h.children;let b=-1;const j=[],m=g.enter("tableRow");for(;++b<S.length;)j[b]=l(S[b],h,g,v);return m(),j}function p(h,g,v){let S=Zp.inlineCode(h,g,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function WS(){return{exit:{taskListCheckValueChecked:Iu,taskListCheckValueUnchecked:Iu,paragraph:GS}}}function qS(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:YS}}}function Iu(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function GS(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function YS(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=Zp.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(d){return d+o}}function KS(){return[I1(),Y1(),eS(),FS(),WS()]}function XS(e){return{extensions:[T1(),K1(e),tS(),HS(e),qS()]}}const QS={tokenize:s_,partial:!0},Vp={tokenize:o_,partial:!0},Up={tokenize:a_,partial:!0},Jp={tokenize:l_,partial:!0},e_={tokenize:u_,partial:!0},Hp={name:"wwwAutolink",tokenize:r_,previous:qp},Wp={name:"protocolAutolink",tokenize:i_,previous:Gp},ln={name:"emailAutolink",tokenize:n_,previous:Yp},Qt={};function t_(){return{text:Qt}}let Nn=48;for(;Nn<123;)Qt[Nn]=ln,Nn++,Nn===58?Nn=65:Nn===91&&(Nn=97);Qt[43]=ln;Qt[45]=ln;Qt[46]=ln;Qt[95]=ln;Qt[72]=[ln,Wp];Qt[104]=[ln,Wp];Qt[87]=[ln,Hp];Qt[119]=[ln,Hp];function n_(e,t,n){const r=this;let i,s;return o;function o(f){return!qo(f)||!Yp.call(r,r.previous)||Ba(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return qo(f)?(e.consume(f),a):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(e_,d,c)(f):f===45||f===95||lt(f)?(s=!0,e.consume(f),l):d(f)}function c(f){return e.consume(f),i=!0,l}function d(f){return s&&i&&ht(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function r_(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!qp.call(r,r.previous)||Ba(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(QS,e.attempt(Vp,e.attempt(Up,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function i_(e,t,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&Gp.call(r,r.previous)&&!Ba(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(ht(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?c:(s=!0,l)):n(f)}function c(f){return f===null||ts(f)||Fe(f)||Mn(f)||Is(f)?n(f):e.attempt(Vp,e.attempt(Up,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function s_(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function o_(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(Jp,l,a)(c):c===null||Fe(c)||Mn(c)||c!==45&&Is(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function a_(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Jp,t,s)(o):o===null||Fe(o)||Mn(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function l_(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Fe(a)||Mn(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Fe(a)||Mn(a)?t(a):r(a)}function s(a){return ht(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):ht(a)?(e.consume(a),o):n(a)}}function u_(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return lt(s)?n(s):t(s)}}function qp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Fe(e)}function Gp(e){return!ht(e)}function Yp(e){return!(e===47||qo(e))}function qo(e){return e===43||e===45||e===46||e===95||lt(e)}function Ba(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 c_={tokenize:b_,partial:!0};function d_(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:m_,continuation:{tokenize:g_},exit:x_}},text:{91:{name:"gfmFootnoteCall",tokenize:h_},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:f_,resolveTo:p_}}}}function f_(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Vt(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function p_(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function h_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(f){if(s>999||f===93&&!o||f===null||f===91||Fe(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Vt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Fe(f)||(o=!0),s++,e.consume(f),f===92?d:c}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function m_(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(g)}function d(g){if(o>999||g===93&&!a||g===null||g===91||Fe(g))return n(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Vt(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Fe(g)||(a=!0),o++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),o++,d):d(g)}function p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),De(e,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return t(g)}}function g_(e,t,n){return e.check(gi,t,e.attempt(c_,t,n))}function x_(e){e.exit("gfmFootnoteDefinition")}function b_(e,t,n){const r=this;return De(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function y_(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",d,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",f,a]],h=a.parser.constructs.insideSpan.null;h&&It(p,p.length,0,Ts(h,o.slice(c+1,l),a)),It(p,p.length,0,[["exit",f,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",d,a]]),It(o,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,d=this.events;let f=0;return p;function p(g){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const v=mr(c);if(g===126)return f>1?l(g):(o.consume(g),f++,h);if(f<2&&!n)return l(g);const S=o.exit("strikethroughSequenceTemporary"),b=mr(g);return S._open=!b||b===2&&!!v,S._close=!v||v===2&&!!b,a(g)}}}class v_{constructor(){this.map=[]}add(t,n,r){w_(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function w_(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 k_(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 S_(){return{flow:{null:{name:"table",tokenize:__,resolveAll:j_}}}}function __(e,t,n){const r=this;let i=0,s=0,o;return a;function a(_){let I=r.events.length-1;for(;I>-1;){const A=r.events[I][1].type;if(A==="lineEnding"||A==="linePrefix")I--;else break}const z=I>-1?r.events[I][1].type:null,M=z==="tableHead"||z==="tableRow"?w:l;return M===w&&r.parser.lazy[r.now().line]?n(_):M(_)}function l(_){return e.enter("tableHead"),e.enter("tableRow"),c(_)}function c(_){return _===124||(o=!0,s+=1),d(_)}function d(_){return _===null?n(_):he(_)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),h):n(_):Ie(_)?De(e,d,"whitespace")(_):(s+=1,o&&(o=!1,i+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),o=!0,d):(e.enter("data"),f(_)))}function f(_){return _===null||_===124||Fe(_)?(e.exit("data"),d(_)):(e.consume(_),_===92?p:f)}function p(_){return _===92||_===124?(e.consume(_),f):f(_)}function h(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),o=!1,Ie(_)?De(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):g(_))}function g(_){return _===45||_===58?S(_):_===124?(o=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),v):C(_)}function v(_){return Ie(_)?De(e,S,"whitespace")(_):S(_)}function S(_){return _===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),b):_===45?(s+=1,b(_)):_===null||he(_)?T(_):C(_)}function b(_){return _===45?(e.enter("tableDelimiterFiller"),j(_)):C(_)}function j(_){return _===45?(e.consume(_),j):_===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),m):(e.exit("tableDelimiterFiller"),m(_))}function m(_){return Ie(_)?De(e,T,"whitespace")(_):T(_)}function T(_){return _===124?g(_):_===null||he(_)?!o||i!==s?C(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):C(_)}function C(_){return n(_)}function w(_){return e.enter("tableRow"),N(_)}function N(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),N):_===null||he(_)?(e.exit("tableRow"),t(_)):Ie(_)?De(e,N,"whitespace")(_):(e.enter("data"),H(_))}function H(_){return _===null||_===124||Fe(_)?(e.exit("data"),N(_)):(e.consume(_),_===92?O:H)}function O(_){return _===92||_===124?(e.consume(_),H):H(_)}}function j_(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,d,f;const p=new v_;for(;++n<e.length;){const h=e[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(Tu(p,t,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,t]])),i=g.type==="tableDelimiterRow"?2:d?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],f=Ii(p,t,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=Ii(p,t,s,i,void 0,f)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],f=Ii(p,t,s,i,n,f)):o[1]!==0&&(f=Ii(p,t,o,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Tu(p,t,l,c,d),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=k_(t.events,n))}return e}function Ii(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Qn(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Qn(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Qn(t.events,n[2]),d=Qn(t.events,n[3]),f={type:a,start:Object.assign({},c),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,v=n[3]-n[2]-1;e.add(g,v,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(s.end=Object.assign({},Qn(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Tu(e,t,n,r,i){const s=[],o=Qn(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Qn(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const N_={name:"tasklistCheck",tokenize:C_};function E_(){return{text:{91:N_}}}function C_(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Fe(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return he(l)?t(l):Ie(l)?e.check({tokenize:I_},t,n)(l):n(l)}}function I_(e,t,n){return De(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function T_(e){return ap([t_(),d_(),y_(e),S_(),E_()])}const A_={};function z_(e){const t=this,n=e||A_,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(T_(n)),s.push(KS()),o.push(XS(n))}var Kp="vercel.ai.error",O_=Symbol.for(Kp),Au,zu,Xt=class Xp extends(zu=Error,Au=O_,zu){constructor({name:t,message:n,cause:r}){super(n),this[Au]=!0,this.name=t,this.cause=r}static isInstance(t){return Xp.hasMarker(t,Kp)}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 Qp(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var eh="AI_InvalidArgumentError",th=`vercel.ai.error.${eh}`,P_=Symbol.for(th),Ou,Pu,D_=class extends(Pu=Xt,Ou=P_,Pu){constructor({message:e,cause:t,argument:n}){super({name:eh,message:e,cause:t}),this[Ou]=!0,this.argument=n}static isInstance(e){return Xt.hasMarker(e,th)}},nh="AI_JSONParseError",rh=`vercel.ai.error.${nh}`,R_=Symbol.for(rh),Du,Ru,Mu=class extends(Ru=Xt,Du=R_,Ru){constructor({text:e,cause:t}){super({name:nh,message:`JSON parsing failed: Text: ${e}.
|
|
38
|
+
Error message: ${Qp(t)}`,cause:t}),this[Du]=!0,this.text=e}static isInstance(e){return Xt.hasMarker(e,rh)}},ih="AI_TypeValidationError",sh=`vercel.ai.error.${ih}`,M_=Symbol.for(sh),$u,Lu,gr=class Go extends(Lu=Xt,$u=M_,Lu){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:ih,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
39
|
+
Error message: ${Qp(n)}`,cause:n}),this[$u]=!0,this.value=t,this.context=r}static isInstance(t){return Xt.hasMarker(t,sh)}static wrap({value:t,cause:n,context:r}){var i,s,o;return Go.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===(r==null?void 0:r.field)&&((s=n.context)==null?void 0:s.entityName)===(r==null?void 0:r.entityName)&&((o=n.context)==null?void 0:o.entityId)===(r==null?void 0:r.entityId)?n:new Go({value:t,cause:n,context:r})}};function J(e,t,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);const c=o.prototype,d=Object.keys(c);for(let f=0;f<d.length;f++){const p=d[f];p in a||(a[p]=c[p].bind(a))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:e});function o(a){var l;const c=n!=null&&n.Parent?new s:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(e)}}),Object.defineProperty(o,"name",{value:e}),o}class ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class oh extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const ah={};function vn(e){return ah}function lh(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 Yo(e,t){return typeof t=="bigint"?t.toString():t}function Ps(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Za(e){return e==null}function Va(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function $_(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l!=null&&l[1]&&(i=Number.parseInt(l[1]))}const s=n>i?n:i,o=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const Fu=Symbol("evaluating");function ze(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Fu)return r===void 0&&(r=Fu,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Sn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Bu(e){return JSON.stringify(e)}function L_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const uh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ii(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const F_=Ps(()=>{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 xr(e){if(ii(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ii(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ch(e){return xr(e)?{...e}:Array.isArray(e)?[...e]:e}const B_=new Set(["string","number","symbol"]);function br(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _n(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function 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 Z_(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const V_={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 U_(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Sn(e._zod.def,{get shape(){const o={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(o[a]=n.shape[a])}return Fn(this,"shape",o),o},checks:[]});return _n(e,s)}function J_(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Sn(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete o[a]}return Fn(this,"shape",o),o},checks:[]});return _n(e,s)}function H_(e,t){if(!xr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const o in t)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Sn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Fn(this,"shape",s),s}});return _n(e,i)}function W_(e,t){if(!xr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Fn(this,"shape",r),r}});return _n(e,n)}function q_(e,t){const n=Sn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Fn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return _n(e,n)}function G_(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Sn(t._zod.def,{get shape(){const a=t._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=e?new e({type:"optional",innerType:a[c]}):a[c];return Fn(this,"shape",l),l},checks:[]});return _n(t,o)}function Y_(e,t,n){const r=Sn(t._zod.def,{get shape(){const i=t._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new e({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new e({type:"nonoptional",innerType:i[o]});return Fn(this,"shape",s),s}});return _n(t,r)}function rr(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function ir(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Ti(e){return typeof e=="string"?e:e==null?void 0:e.message}function wn(e,t,n){var i,s,o,a,l,c;const r={...e,path:e.path??[]};if(!e.message){const d=Ti((o=(s=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,e))??Ti((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??Ti((l=n.customError)==null?void 0:l.call(n,e))??Ti((c=n.localeError)==null?void 0:c.call(n,e))??"Invalid input";r.message=d}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function Ua(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function si(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const dh=(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,Yo,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},fh=J("$ZodError",dh),ph=J("$ZodError",dh,{Parent:Error});function K_(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 X_(e,t=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let o=n,a=0;for(;a<s.path.length;){const l=s.path[a];a===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(s))):o[l]=o[l]||{_errors:[]},o=o[l],a++}}};return r(e),n}const Ja=e=>(t,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new ur;if(o.issues.length){const a=new((i==null?void 0:i.Err)??e)(o.issues.map(l=>wn(l,s,vn())));throw uh(a,i==null?void 0:i.callee),a}return o.value},Ha=e=>async(t,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??e)(o.issues.map(l=>wn(l,s,vn())));throw uh(a,i==null?void 0:i.callee),a}return o.value},Ds=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 ur;return s.issues.length?{success:!1,error:new(e??fh)(s.issues.map(o=>wn(o,i,vn())))}:{success:!0,data:s.value}},Q_=Ds(ph),Rs=e=>async(t,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(o=>wn(o,i,vn())))}:{success:!0,data:s.value}},ej=Rs(ph),tj=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ja(e)(t,n,i)},nj=e=>(t,n,r)=>Ja(e)(t,n,r),rj=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ha(e)(t,n,i)},ij=e=>async(t,n,r)=>Ha(e)(t,n,r),sj=e=>(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ds(e)(t,n,i)},oj=e=>(t,n,r)=>Ds(e)(t,n,r),aj=e=>async(t,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Rs(e)(t,n,i)},lj=e=>async(t,n,r)=>Rs(e)(t,n,r),uj=/^[cC][^\s-]{8,}$/,cj=/^[0-9a-z]+$/,dj=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,fj=/^[0-9a-vA-V]{20}$/,pj=/^[A-Za-z0-9]{27}$/,hj=/^[a-zA-Z0-9_-]{21}$/,mj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gj=/^([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})$/,Zu=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)$/,xj=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,bj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function yj(){return new RegExp(bj,"u")}const vj=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wj=/^(([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}|:))$/,kj=/^((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])$/,Sj=/^(([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])$/,_j=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hh=/^[A-Za-z0-9_-]*$/,jj=/^\+[1-9]\d{6,14}$/,mh="(?:(?:\\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])))",Nj=new RegExp(`^${mh}$`);function gh(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 Ej(e){return new RegExp(`^${gh(e)}$`)}function Cj(e){const t=gh({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(`^${mh}T(?:${r})$`)}const Ij=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}$`)},Tj=/^-?\d+$/,xh=/^-?\d+(?:\.\d+)?$/,Aj=/^(?:true|false)$/i,zj=/^null$/i,Oj=/^[^A-Z]*$/,Pj=/^[^a-z]*$/,_t=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bh={number:"number",bigint:"bigint",object:"date"},yh=J("$ZodCheckLessThan",(e,t)=>{_t.init(e,t);const n=bh[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})}}),vh=J("$ZodCheckGreaterThan",(e,t)=>{_t.init(e,t);const n=bh[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})}}),Dj=J("$ZodCheckMultipleOf",(e,t)=>{_t.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):$_(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})}}),Rj=J("$ZodCheckNumberFormat",(e,t)=>{var o;_t.init(e,t),t.format=t.format||"float64";const n=(o=t.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=V_[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=i,l.maximum=s,n&&(l.pattern=Tj)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<i&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Mj=J("$ZodCheckMaxLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Za(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const o=Ua(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),$j=J("$ZodCheckMinLength",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Za(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const o=Ua(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Lj=J("$ZodCheckLengthEquals",(e,t)=>{var n;_t.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Za(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const o=Ua(i),a=s>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ms=J("$ZodCheckStringFormat",(e,t)=>{var n,r;_t.init(e,t),e._zod.onattach.push(i=>{const s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Fj=J("$ZodCheckRegex",(e,t)=>{Ms.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})}}),Bj=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Oj),Ms.init(e,t)}),Zj=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Pj),Ms.init(e,t)}),Vj=J("$ZodCheckIncludes",(e,t)=>{_t.init(e,t);const n=br(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})}}),Uj=J("$ZodCheckStartsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`^${br(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})}}),Jj=J("$ZodCheckEndsWith",(e,t)=>{_t.init(e,t);const n=new RegExp(`.*${br(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})}}),Hj=J("$ZodCheckOverwrite",(e,t)=>{_t.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Wj{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
40
|
+
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,i.join(`
|
|
41
|
+
`))}}const qj={major:4,minor:3,patch:6},He=J("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qj;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const s=(a,l,c)=>{let d=rr(a),f;for(const p of l){if(p._zod.def.when){if(!p._zod.def.when(a))continue}else if(d)continue;const h=a.issues.length,g=p._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new ur;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,a.issues.length!==h&&(d||(d=rr(a,h)))});else{if(a.issues.length===h)continue;d||(d=rr(a,h))}}return f?f.then(()=>a):a},o=(a,l,c)=>{if(rr(a))return a.aborted=!0,a;const d=s(l,r,c);if(d instanceof Promise){if(c.async===!1)throw new ur;return d.then(f=>e._zod.parse(f,c))}return e._zod.parse(d,c)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const d=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>o(f,a,l)):o(d,a,l)}const c=e._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new ur;return c.then(d=>s(d,r,l))}return s(c,r,l)}}ze(e,"~standard",()=>({validate:s=>{var o;try{const a=Q_(e,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return ej(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}))}),Wa=J("$ZodString",(e,t)=>{var n;He.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Ij(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ke=J("$ZodStringFormat",(e,t)=>{Ms.init(e,t),Wa.init(e,t)}),Gj=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=gj),Ke.init(e,t)}),Yj=J("$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=Zu(r))}else t.pattern??(t.pattern=Zu());Ke.init(e,t)}),Kj=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xj),Ke.init(e,t)}),Xj=J("$ZodURL",(e,t)=>{Ke.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Qj=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=yj()),Ke.init(e,t)}),eN=J("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=hj),Ke.init(e,t)}),tN=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=uj),Ke.init(e,t)}),nN=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cj),Ke.init(e,t)}),rN=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=dj),Ke.init(e,t)}),iN=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=fj),Ke.init(e,t)}),sN=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=pj),Ke.init(e,t)}),oN=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Cj(t)),Ke.init(e,t)}),aN=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Nj),Ke.init(e,t)}),lN=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ej(t)),Ke.init(e,t)}),uN=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=mj),Ke.init(e,t)}),cN=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=vj),Ke.init(e,t),e._zod.bag.format="ipv4"}),dN=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wj),Ke.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),fN=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=kj),Ke.init(e,t)}),pN=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Sj),Ke.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function wh(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const hN=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=_j),Ke.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{wh(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function mN(e){if(!hh.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return wh(n)}const gN=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=hh),Ke.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{mN(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),xN=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=jj),Ke.init(e,t)});function bN(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const yN=J("$ZodJWT",(e,t)=>{Ke.init(e,t),e._zod.check=n=>{bN(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),kh=J("$ZodNumber",(e,t)=>{He.init(e,t),e._zod.pattern=e._zod.bag.pattern??xh,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),vN=J("$ZodNumberFormat",(e,t)=>{Rj.init(e,t),kh.init(e,t)}),wN=J("$ZodBoolean",(e,t)=>{He.init(e,t),e._zod.pattern=Aj,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}}),kN=J("$ZodNull",(e,t)=>{He.init(e,t),e._zod.pattern=zj,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}}),SN=J("$ZodUnknown",(e,t)=>{He.init(e,t),e._zod.parse=n=>n}),_N=J("$ZodNever",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Vu(e,t,n){e.issues.length&&t.issues.push(...ir(n,e.issues)),t.value[n]=e.value}const jN=J("$ZodArray",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],l=t.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(c=>Vu(c,n,o))):Vu(l,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function ss(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...ir(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Sh(e){var r,i,s,o;const t=Object.keys(e.shape);for(const a of t)if(!((o=(s=(i=(r=e.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=Z_(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function _h(e,t,n,r,i,s){const o=[],a=i.keySet,l=i.catchall._zod,c=l.def.type,d=l.optout==="optional";for(const f in t){if(a.has(f))continue;if(c==="never"){o.push(f);continue}const p=l.run({value:t[f],issues:[]},r);p instanceof Promise?e.push(p.then(h=>ss(h,n,f,t,d))):ss(p,n,f,t,d)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const NN=J("$ZodObject",(e,t)=>{He.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=Ps(()=>Sh(t));ze(e._zod,"propValues",()=>{const a=t.shape,l={};for(const c in a){const d=a[c]._zod;if(d.values){l[c]??(l[c]=new Set);for(const f of d.values)l[c].add(f)}}return l});const i=ii,s=t.catchall;let o;e._zod.parse=(a,l)=>{o??(o=r.value);const c=a.value;if(!i(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};const d=[],f=o.shape;for(const p of o.keys){const h=f[p],g=h._zod.optout==="optional",v=h._zod.run({value:c[p],issues:[]},l);v instanceof Promise?d.push(v.then(S=>ss(S,a,p,c,g))):ss(v,a,p,c,g)}return s?_h(d,c,a,l,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),EN=J("$ZodObjectJIT",(e,t)=>{NN.init(e,t);const n=e._zod.parse,r=Ps(()=>Sh(t)),i=p=>{var m;const h=new Wj(["shape","payload","ctx"]),g=r.value,v=T=>{const C=Bu(T);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};h.write("const input = payload.value;");const S=Object.create(null);let b=0;for(const T of g.keys)S[T]=`key_${b++}`;h.write("const newResult = {};");for(const T of g.keys){const C=S[T],w=Bu(T),N=p[T],H=((m=N==null?void 0:N._zod)==null?void 0:m.optout)==="optional";h.write(`const ${C} = ${v(T)};`),H?h.write(`
|
|
42
|
+
if (${C}.issues.length) {
|
|
43
|
+
if (${w} in input) {
|
|
44
|
+
payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
|
|
45
|
+
...iss,
|
|
46
|
+
path: iss.path ? [${w}, ...iss.path] : [${w}]
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (${C}.value === undefined) {
|
|
52
|
+
if (${w} in input) {
|
|
53
|
+
newResult[${w}] = undefined;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
newResult[${w}] = ${C}.value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
`):h.write(`
|
|
60
|
+
if (${C}.issues.length) {
|
|
61
|
+
payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
|
|
62
|
+
...iss,
|
|
63
|
+
path: iss.path ? [${w}, ...iss.path] : [${w}]
|
|
64
|
+
})));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (${C}.value === undefined) {
|
|
68
|
+
if (${w} in input) {
|
|
69
|
+
newResult[${w}] = undefined;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
newResult[${w}] = ${C}.value;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
`)}h.write("payload.value = newResult;"),h.write("return payload;");const j=h.compile();return(T,C)=>j(p,T,C)};let s;const o=ii,a=!ah.jitless,c=a&&F_.value,d=t.catchall;let f;e._zod.parse=(p,h)=>{f??(f=r.value);const g=p.value;return o(g)?a&&c&&(h==null?void 0:h.async)===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),d?_h([],g,p,h,f,e):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});function Uu(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const i=e.filter(s=>!rr(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(o=>wn(o,r,vn())))}),t)}const jh=J("$ZodUnion",(e,t)=>{He.init(e,t),ze(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ze(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ze(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ze(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=>Va(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(n)return r(i,s);let o=!1;const a=[];for(const l of t.options){const c=l._zod.run({value:i.value,issues:[]},s);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(l=>Uu(l,i,e,s)):Uu(a,i,e,s)}}),CN=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,jh.init(e,t);const n=e._zod.parse;ze(e._zod,"propValues",()=>{const i={};for(const s of t.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,l]of Object.entries(o)){i[a]||(i[a]=new Set);for(const c of l)i[a].add(c)}}return i});const r=Ps(()=>{var o;const i=t.options,s=new Map;for(const a of i){const l=(o=a._zod.propValues)==null?void 0:o[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const c of l){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,a)}}return s});e._zod.parse=(i,s)=>{const o=i.value;if(!ii(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),i;const a=r.value.get(o==null?void 0:o[t.discriminator]);return a?a._zod.run(i,s):t.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),IN=J("$ZodIntersection",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([l,c])=>Ju(n,l,c)):Ju(n,s,o)}});function Ko(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(xr(e)&&xr(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),i={...e,...t};for(const s of r){const o=Ko(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],s=t[r],o=Ko(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ju(e,t,n){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&e.issues.push({...i,keys:s}),rr(e))return e;const o=Ko(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const TN=J("$ZodRecord",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!xr(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],o=t.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);const d=t.valueType._zod.run({value:i[c],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...ir(c,f.issues)),n.value[c]=f.value})):(d.issues.length&&n.issues.push(...ir(c,d.issues)),n.value[c]=d.value)}let l;for(const c in i)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let l=t.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&xh.test(a)&&l.issues.length){const f=t.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){t.mode==="loose"?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>wn(f,r,vn())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:i[a],issues:[]},r);d instanceof Promise?s.push(d.then(f=>{f.issues.length&&n.issues.push(...ir(a,f.issues)),n.value[l.value]=f.value})):(d.issues.length&&n.issues.push(...ir(a,d.issues)),n.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),AN=J("$ZodEnum",(e,t)=>{He.init(e,t);const n=lh(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>B_.has(typeof i)).map(i=>typeof i=="string"?br(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:e}),i}}),zN=J("$ZodLiteral",(e,t)=>{if(He.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?br(r):r?br(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}}),ON=J("$ZodTransform",(e,t)=>{He.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new oh(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new ur;return n.value=i,n}});function Hu(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Nh=J("$ZodOptional",(e,t)=>{He.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Va(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=>Hu(s,n.value)):Hu(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),PN=J("$ZodExactOptional",(e,t)=>{Nh.init(e,t),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),DN=J("$ZodNullable",(e,t)=>{He.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Va(n.source)}|null)$`):void 0}),ze(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)}),RN=J("$ZodDefault",(e,t)=>{He.init(e,t),e._zod.optin="optional",ze(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=>Wu(s,t)):Wu(i,t)}});function Wu(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const MN=J("$ZodPrefault",(e,t)=>{He.init(e,t),e._zod.optin="optional",ze(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))}),$N=J("$ZodNonOptional",(e,t)=>{He.init(e,t),ze(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=>qu(s,e)):qu(i,e)}});function qu(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 LN=J("$ZodCatch",(e,t)=>{He.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(o=>wn(o,r,vn()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>wn(s,r,vn()))},input:n.value}),n.issues=[]),n)}}),FN=J("$ZodPipe",(e,t)=>{He.init(e,t),ze(e._zod,"values",()=>t.in._zod.values),ze(e._zod,"optin",()=>t.in._zod.optin),ze(e._zod,"optout",()=>t.out._zod.optout),ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(o=>Ai(o,t.in,r)):Ai(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Ai(s,t.out,r)):Ai(i,t.out,r)}});function Ai(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const BN=J("$ZodReadonly",(e,t)=>{He.init(e,t),ze(e._zod,"propValues",()=>t.innerType._zod.propValues),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),ze(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(Gu):Gu(i)}});function Gu(e){return e.value=Object.freeze(e.value),e}const ZN=J("$ZodLazy",(e,t)=>{He.init(e,t),ze(e._zod,"innerType",()=>t.getter()),ze(e._zod,"pattern",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.pattern}),ze(e._zod,"propValues",()=>{var n,r;return(r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.propValues}),ze(e._zod,"optin",()=>{var n,r;return((r=(n=e._zod.innerType)==null?void 0:n._zod)==null?void 0:r.optin)??void 0}),ze(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)}),VN=J("$ZodCustom",(e,t)=>{_t.init(e,t),He.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>Yu(s,n,r,e));Yu(i,n,r,e)}});function Yu(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(si(i))}}var Ku;class UN{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 JN(){return new UN}(Ku=globalThis).__zod_globalRegistry??(Ku.__zod_globalRegistry=JN());const $r=globalThis.__zod_globalRegistry;function HN(e,t){return new e({type:"string",...ce(t)})}function WN(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ce(t)})}function Xu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ce(t)})}function qN(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ce(t)})}function GN(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ce(t)})}function YN(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ce(t)})}function KN(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ce(t)})}function XN(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ce(t)})}function QN(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ce(t)})}function eE(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ce(t)})}function tE(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ce(t)})}function nE(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ce(t)})}function rE(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ce(t)})}function iE(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ce(t)})}function sE(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ce(t)})}function oE(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ce(t)})}function aE(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ce(t)})}function lE(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ce(t)})}function uE(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ce(t)})}function cE(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ce(t)})}function dE(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ce(t)})}function fE(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ce(t)})}function pE(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ce(t)})}function hE(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ce(t)})}function mE(e,t){return new e({type:"string",format:"date",check:"string_format",...ce(t)})}function gE(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ce(t)})}function xE(e,t){return new e({type:"string",format:"duration",check:"string_format",...ce(t)})}function bE(e,t){return new e({type:"number",checks:[],...ce(t)})}function yE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ce(t)})}function vE(e,t){return new e({type:"boolean",...ce(t)})}function wE(e,t){return new e({type:"null",...ce(t)})}function kE(e){return new e({type:"unknown"})}function SE(e,t){return new e({type:"never",...ce(t)})}function Qu(e,t){return new yh({check:"less_than",...ce(t),value:e,inclusive:!1})}function mo(e,t){return new yh({check:"less_than",...ce(t),value:e,inclusive:!0})}function ec(e,t){return new vh({check:"greater_than",...ce(t),value:e,inclusive:!1})}function go(e,t){return new vh({check:"greater_than",...ce(t),value:e,inclusive:!0})}function tc(e,t){return new Dj({check:"multiple_of",...ce(t),value:e})}function Eh(e,t){return new Mj({check:"max_length",...ce(t),maximum:e})}function os(e,t){return new $j({check:"min_length",...ce(t),minimum:e})}function Ch(e,t){return new Lj({check:"length_equals",...ce(t),length:e})}function _E(e,t){return new Fj({check:"string_format",format:"regex",...ce(t),pattern:e})}function jE(e){return new Bj({check:"string_format",format:"lowercase",...ce(e)})}function NE(e){return new Zj({check:"string_format",format:"uppercase",...ce(e)})}function EE(e,t){return new Vj({check:"string_format",format:"includes",...ce(t),includes:e})}function CE(e,t){return new Uj({check:"string_format",format:"starts_with",...ce(t),prefix:e})}function IE(e,t){return new Jj({check:"string_format",format:"ends_with",...ce(t),suffix:e})}function Sr(e){return new Hj({check:"overwrite",tx:e})}function TE(e){return Sr(t=>t.normalize(e))}function AE(){return Sr(e=>e.trim())}function zE(){return Sr(e=>e.toLowerCase())}function OE(){return Sr(e=>e.toUpperCase())}function PE(){return Sr(e=>L_(e))}function DE(e,t,n){return new e({type:"array",element:t,...ce(n)})}function RE(e,t,n){const r=ce(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function ME(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ce(n)})}function $E(e){const t=LE(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(si(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(si(i))}},e(n.value,n)));return t}function LE(e,t){const n=new _t({check:"custom",...ce(t)});return n._zod.check=e,n}function as(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)??$r,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Ve(e,t,n={path:[],schemaPath:[]}){var d,f;var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);const a=(f=(d=e._zod).toJSONSchema)==null?void 0:f.call(d);if(a)o.schema=a;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,p);else{const g=o.schema,v=t.processors[i.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);v(e,t,g,p)}const h=e._zod.parent;h&&(o.ref||(o.ref=h),Ve(h,t,p),t.seen.get(h).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(o.schema,l),t.io==="input"&&dt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ls(e,t){var o,a,l,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of e.seen.entries()){const f=(o=e.metadataRegistry.get(d[0]))==null?void 0:o.id;if(f){const p=r.get(f);if(p&&p!==d[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,d[0])}}const i=d=>{var v;const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const S=(v=e.external.registry.get(d[0]))==null?void 0:v.id,b=e.external.uri??(m=>m);if(S)return{ref:b(S)};const j=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=j,{defId:j,ref:`${b("__shared")}#/${f}/${j}`}}if(d[1]===n)return{ref:"#"};const h=`#/${f}/`,g=d[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:h+g}},s=d=>{if(d[1].schema.$ref)return;const f=d[1],{ref:p,defId:h}=i(d);f.def={...f.schema},h&&(f.defId=h);const g=f.schema;for(const v in g)delete g[v];g.$ref=p};if(e.cycles==="throw")for(const d of e.seen.entries()){const f=d[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
|
|
76
|
+
|
|
77
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const f=d[1];if(t===d[0]){s(d);continue}if(e.external){const h=(l=e.external.registry.get(d[0]))==null?void 0:l.id;if(t!==d[0]&&h){s(d);continue}}if((c=e.metadataRegistry.get(d[0]))==null?void 0:c.id){s(d);continue}if(f.cycle){s(d);continue}if(f.count>1&&e.reused==="ref"){s(d);continue}}}function us(e,t){var o,a,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const d=e.seen.get(c);if(d.ref===null)return;const f=d.def??d.schema,p={...f},h=d.ref;if(d.ref=null,h){r(h);const v=e.seen.get(h),S=v.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(S)):Object.assign(f,S),Object.assign(f,p),c._zod.parent===h)for(const j in f)j==="$ref"||j==="allOf"||j in p||delete f[j];if(S.$ref&&v.def)for(const j in f)j==="$ref"||j==="allOf"||j in v.def&&JSON.stringify(f[j])===JSON.stringify(v.def[j])&&delete f[j]}const g=c._zod.parent;if(g&&g!==h){r(g);const v=e.seen.get(g);if(v!=null&&v.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const S in f)S==="$ref"||S==="allOf"||S in v.def&&JSON.stringify(f[S])===JSON.stringify(v.def[S])&&delete f[S]}e.override({zodSchema:c,jsonSchema:f,path:d.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(o=e.external)!=null&&o.uri){const c=(a=e.external.registry.get(t))==null?void 0:a.id;if(!c)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(c)}Object.assign(i,n.def??n.schema);const s=((l=e.external)==null?void 0:l.defs)??{};for(const c of e.seen.entries()){const d=c[1];d.def&&d.defId&&(s[d.defId]=d.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const c=JSON.parse(JSON.stringify(i));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:cs(t,"input",e.processors),output:cs(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function dt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return dt(r.element,n);if(r.type==="set")return dt(r.valueType,n);if(r.type==="lazy")return dt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return dt(r.innerType,n);if(r.type==="intersection")return dt(r.left,n)||dt(r.right,n);if(r.type==="record"||r.type==="map")return dt(r.keyType,n)||dt(r.valueType,n);if(r.type==="pipe")return dt(r.in,n)||dt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(dt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(dt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(dt(i,n))return!0;return!!(r.rest&&dt(r.rest,n))}return!1}const FE=(e,t={})=>n=>{const r=as({...n,processors:t});return Ve(e,r),ls(r,e),us(r,e)},cs=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=as({...i??{},target:s,io:t,processors:n});return Ve(e,o),ls(o,e),us(o,e)},BE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ih=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=BE[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),c&&(i.contentEncoding=c),l&&l.size>0){const d=[...l];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Th=(e,t,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof s=="number"&&(i.minimum=s,typeof d=="number"&&t.target!=="draft-04"&&(d>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c),typeof o=="number"&&(i.maximum=o,typeof c=="number"&&t.target!=="draft-04"&&(c<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof l=="number"&&(i.multipleOf=l)},Ah=(e,t,n,r)=>{n.type="boolean"},ZE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},VE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},zh=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},UE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},JE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Oh=(e,t,n,r)=>{n.not={}},HE=(e,t,n,r)=>{},Ph=(e,t,n,r)=>{},WE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Dh=(e,t,n,r)=>{const i=e._zod.def,s=lh(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},Rh=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const o of i.values)if(o===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},qE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},GE=(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},YE=(e,t,n,r)=>{const i=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:l}=e._zod.bag;o!==void 0&&(s.minLength=o),a!==void 0&&(s.maxLength=a),l?l.length===1?(s.contentMediaType=l[0],Object.assign(i,s)):(Object.assign(i,s),i.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(i,s)},KE=(e,t,n,r)=>{n.type="boolean"},Mh=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},XE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},$h=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},QE=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},eC=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Lh=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ve(s.element,t,{...r,path:[...r.path,"items"]})},Fh=(e,t,n,r)=>{var c;const i=n,s=e._zod.def;i.type="object",i.properties={};const o=s.shape;for(const d in o)i.properties[d]=Ve(o[d],t,{...r,path:[...r.path,"properties",d]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(d=>{const f=s.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((c=s.catchall)==null?void 0:c._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Ve(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Bh=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,o=i.options.map((a,l)=>Ve(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=o:n.anyOf=o},Zh=(e,t,n,r)=>{const i=e._zod.def,s=Ve(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=Ve(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=l},tC=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="array";const o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((p,h)=>Ve(p,t,{...r,path:[...r.path,o,h]})),c=s.rest?Ve(s.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=l,c&&(i.items=c)):t.target==="openapi-3.0"?(i.items={anyOf:l},c&&i.items.anyOf.push(c),i.minItems=l.length,c||(i.maxItems=l.length)):(i.items=l,c&&(i.additionalItems=c));const{minimum:d,maximum:f}=e._zod.bag;typeof d=="number"&&(i.minItems=d),typeof f=="number"&&(i.maxItems=f)},Vh=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(s.mode==="loose"&&l&&l.size>0){const d=Ve(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of l)i.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Ve(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Ve(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const d=[...c].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(i.required=d)}},Uh=(e,t,n,r)=>{const i=e._zod.def,s=Ve(i.innerType,t,r),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Jh=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Hh=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Wh=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},qh=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},Gh=(e,t,n,r)=>{const i=e._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ve(s,t,r);const o=t.seen.get(e);o.ref=s},Yh=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},nC=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},qa=(e,t,n,r)=>{const i=e._zod.def;Ve(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},Kh=(e,t,n,r)=>{const i=e._zod.innerType;Ve(i,t,r);const s=t.seen.get(e);s.ref=i},nc={string:Ih,number:Th,boolean:Ah,bigint:ZE,symbol:VE,null:zh,undefined:UE,void:JE,never:Oh,any:HE,unknown:Ph,date:WE,enum:Dh,literal:Rh,nan:qE,template_literal:GE,file:YE,success:KE,custom:Mh,function:XE,transform:$h,map:QE,set:eC,array:Lh,object:Fh,union:Bh,intersection:Zh,tuple:tC,record:Vh,nullable:Uh,nonoptional:Jh,default:Hh,prefault:Wh,catch:qh,pipe:Gh,readonly:Yh,promise:nC,optional:qa,lazy:Kh};function rC(e,t){if("_idmap"in e){const r=e,i=as({...t,processors:nc}),s={};for(const l of r._idmap.entries()){const[c,d]=l;Ve(d,i)}const o={},a={registry:r,uri:t==null?void 0:t.uri,defs:s};i.external=a;for(const l of r._idmap.entries()){const[c,d]=l;ls(i,d),o[c]=us(i,d)}if(Object.keys(s).length>0){const l=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[l]:s}}return{schemas:o}}const n=as({...t,processors:nc});return Ve(e,n),ls(n,e),us(n,e)}const iC=J("ZodISODateTime",(e,t)=>{oN.init(e,t),Xe.init(e,t)});function sC(e){return hE(iC,e)}const oC=J("ZodISODate",(e,t)=>{aN.init(e,t),Xe.init(e,t)});function aC(e){return mE(oC,e)}const lC=J("ZodISOTime",(e,t)=>{lN.init(e,t),Xe.init(e,t)});function uC(e){return gE(lC,e)}const cC=J("ZodISODuration",(e,t)=>{uN.init(e,t),Xe.init(e,t)});function dC(e){return xE(cC,e)}const fC=(e,t)=>{fh.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>X_(e,n)},flatten:{value:n=>K_(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Yo,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Yo,2)}},isEmpty:{get(){return e.issues.length===0}}})},Pt=J("ZodError",fC,{Parent:Error}),pC=Ja(Pt),hC=Ha(Pt),mC=Ds(Pt),Xh=Rs(Pt),gC=tj(Pt),xC=nj(Pt),bC=rj(Pt),yC=ij(Pt),vC=sj(Pt),wC=oj(Pt),kC=aj(Pt),SC=lj(Pt),We=J("ZodType",(e,t)=>(He.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:cs(e,"input"),output:cs(e,"output")}}),e.toJSONSchema=FE(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Sn(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>_n(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>pC(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>mC(e,n,r),e.parseAsync=async(n,r)=>hC(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Xh(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>gC(e,n,r),e.decode=(n,r)=>xC(e,n,r),e.encodeAsync=async(n,r)=>bC(e,n,r),e.decodeAsync=async(n,r)=>yC(e,n,r),e.safeEncode=(n,r)=>vC(e,n,r),e.safeDecode=(n,r)=>wC(e,n,r),e.safeEncodeAsync=async(n,r)=>kC(e,n,r),e.safeDecodeAsync=async(n,r)=>SC(e,n,r),e.refine=(n,r)=>e.check(yI(n,r)),e.superRefine=n=>e.check(vI(n)),e.overwrite=n=>e.check(Sr(n)),e.optional=()=>sc(e),e.exactOptional=()=>sI(e),e.nullable=()=>oc(e),e.nullish=()=>sc(oc(e)),e.nonoptional=n=>dI(e,n),e.array=()=>_r(e),e.or=n=>mt([e,n]),e.and=n=>QC(e,n),e.transform=n=>ac(e,rI(n)),e.default=n=>lI(e,n),e.prefault=n=>cI(e,n),e.catch=n=>pI(e,n),e.pipe=n=>ac(e,n),e.readonly=()=>gI(e),e.describe=n=>{const r=e.clone();return $r.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){var n;return(n=$r.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return $r.get(e);const r=e.clone();return $r.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Qh=J("_ZodString",(e,t)=>{Wa.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Ih(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(_E(...r)),e.includes=(...r)=>e.check(EE(...r)),e.startsWith=(...r)=>e.check(CE(...r)),e.endsWith=(...r)=>e.check(IE(...r)),e.min=(...r)=>e.check(os(...r)),e.max=(...r)=>e.check(Eh(...r)),e.length=(...r)=>e.check(Ch(...r)),e.nonempty=(...r)=>e.check(os(1,...r)),e.lowercase=r=>e.check(jE(r)),e.uppercase=r=>e.check(NE(r)),e.trim=()=>e.check(AE()),e.normalize=(...r)=>e.check(TE(...r)),e.toLowerCase=()=>e.check(zE()),e.toUpperCase=()=>e.check(OE()),e.slugify=()=>e.check(PE())}),_C=J("ZodString",(e,t)=>{Wa.init(e,t),Qh.init(e,t),e.email=n=>e.check(WN(jC,n)),e.url=n=>e.check(XN(NC,n)),e.jwt=n=>e.check(pE(BC,n)),e.emoji=n=>e.check(QN(EC,n)),e.guid=n=>e.check(Xu(rc,n)),e.uuid=n=>e.check(qN(zi,n)),e.uuidv4=n=>e.check(GN(zi,n)),e.uuidv6=n=>e.check(YN(zi,n)),e.uuidv7=n=>e.check(KN(zi,n)),e.nanoid=n=>e.check(eE(CC,n)),e.guid=n=>e.check(Xu(rc,n)),e.cuid=n=>e.check(tE(IC,n)),e.cuid2=n=>e.check(nE(TC,n)),e.ulid=n=>e.check(rE(AC,n)),e.base64=n=>e.check(cE($C,n)),e.base64url=n=>e.check(dE(LC,n)),e.xid=n=>e.check(iE(zC,n)),e.ksuid=n=>e.check(sE(OC,n)),e.ipv4=n=>e.check(oE(PC,n)),e.ipv6=n=>e.check(aE(DC,n)),e.cidrv4=n=>e.check(lE(RC,n)),e.cidrv6=n=>e.check(uE(MC,n)),e.e164=n=>e.check(fE(FC,n)),e.datetime=n=>e.check(sC(n)),e.date=n=>e.check(aC(n)),e.time=n=>e.check(uC(n)),e.duration=n=>e.check(dC(n))});function ae(e){return HN(_C,e)}const Xe=J("ZodStringFormat",(e,t)=>{Ke.init(e,t),Qh.init(e,t)}),jC=J("ZodEmail",(e,t)=>{Kj.init(e,t),Xe.init(e,t)}),rc=J("ZodGUID",(e,t)=>{Gj.init(e,t),Xe.init(e,t)}),zi=J("ZodUUID",(e,t)=>{Yj.init(e,t),Xe.init(e,t)}),NC=J("ZodURL",(e,t)=>{Xj.init(e,t),Xe.init(e,t)}),EC=J("ZodEmoji",(e,t)=>{Qj.init(e,t),Xe.init(e,t)}),CC=J("ZodNanoID",(e,t)=>{eN.init(e,t),Xe.init(e,t)}),IC=J("ZodCUID",(e,t)=>{tN.init(e,t),Xe.init(e,t)}),TC=J("ZodCUID2",(e,t)=>{nN.init(e,t),Xe.init(e,t)}),AC=J("ZodULID",(e,t)=>{rN.init(e,t),Xe.init(e,t)}),zC=J("ZodXID",(e,t)=>{iN.init(e,t),Xe.init(e,t)}),OC=J("ZodKSUID",(e,t)=>{sN.init(e,t),Xe.init(e,t)}),PC=J("ZodIPv4",(e,t)=>{cN.init(e,t),Xe.init(e,t)}),DC=J("ZodIPv6",(e,t)=>{dN.init(e,t),Xe.init(e,t)}),RC=J("ZodCIDRv4",(e,t)=>{fN.init(e,t),Xe.init(e,t)}),MC=J("ZodCIDRv6",(e,t)=>{pN.init(e,t),Xe.init(e,t)}),$C=J("ZodBase64",(e,t)=>{hN.init(e,t),Xe.init(e,t)}),LC=J("ZodBase64URL",(e,t)=>{gN.init(e,t),Xe.init(e,t)}),FC=J("ZodE164",(e,t)=>{xN.init(e,t),Xe.init(e,t)}),BC=J("ZodJWT",(e,t)=>{yN.init(e,t),Xe.init(e,t)}),em=J("ZodNumber",(e,t)=>{kh.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Th(e,r,i),e.gt=(r,i)=>e.check(ec(r,i)),e.gte=(r,i)=>e.check(go(r,i)),e.min=(r,i)=>e.check(go(r,i)),e.lt=(r,i)=>e.check(Qu(r,i)),e.lte=(r,i)=>e.check(mo(r,i)),e.max=(r,i)=>e.check(mo(r,i)),e.int=r=>e.check(ic(r)),e.safe=r=>e.check(ic(r)),e.positive=r=>e.check(ec(0,r)),e.nonnegative=r=>e.check(go(0,r)),e.negative=r=>e.check(Qu(0,r)),e.nonpositive=r=>e.check(mo(0,r)),e.multipleOf=(r,i)=>e.check(tc(r,i)),e.step=(r,i)=>e.check(tc(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 ZC(e){return bE(em,e)}const VC=J("ZodNumberFormat",(e,t)=>{vN.init(e,t),em.init(e,t)});function ic(e){return yE(VC,e)}const UC=J("ZodBoolean",(e,t)=>{wN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ah(e,n,r)});function ft(e){return vE(UC,e)}const JC=J("ZodNull",(e,t)=>{kN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>zh(e,n,r)});function HC(e){return wE(JC,e)}const WC=J("ZodUnknown",(e,t)=>{SN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ph()});function qt(){return kE(WC)}const qC=J("ZodNever",(e,t)=>{_N.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Oh(e,n,r)});function tm(e){return SE(qC,e)}const GC=J("ZodArray",(e,t)=>{jN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lh(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(os(n,r)),e.nonempty=n=>e.check(os(1,n)),e.max=(n,r)=>e.check(Eh(n,r)),e.length=(n,r)=>e.check(Ch(n,r)),e.unwrap=()=>e.element});function _r(e,t){return DE(GC,e,t)}const nm=J("ZodObject",(e,t)=>{EN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Fh(e,n,r,i),ze(e,"shape",()=>t.shape),e.keyof=()=>im(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:qt()}),e.loose=()=>e.clone({...e._zod.def,catchall:qt()}),e.strict=()=>e.clone({...e._zod.def,catchall:tm()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>H_(e,n),e.safeExtend=n=>W_(e,n),e.merge=n=>q_(e,n),e.pick=n=>U_(e,n),e.omit=n=>J_(e,n),e.partial=(...n)=>G_(sm,e,n[0]),e.required=(...n)=>Y_(om,e,n[0])});function Le(e,t){const n={type:"object",shape:e??{},...ce(t)};return new nm(n)}function Ue(e,t){return new nm({type:"object",shape:e,catchall:tm(),...ce(t)})}const rm=J("ZodUnion",(e,t)=>{jh.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bh(e,n,r,i),e.options=t.options});function mt(e,t){return new rm({type:"union",options:e,...ce(t)})}const YC=J("ZodDiscriminatedUnion",(e,t)=>{rm.init(e,t),CN.init(e,t)});function KC(e,t,n){return new YC({type:"union",options:t,discriminator:e,...ce(n)})}const XC=J("ZodIntersection",(e,t)=>{IN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Zh(e,n,r,i)});function QC(e,t){return new XC({type:"intersection",left:e,right:t})}const eI=J("ZodRecord",(e,t)=>{TN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vh(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function oi(e,t,n){return new eI({type:"record",keyType:e,valueType:t,...ce(n)})}const Xo=J("ZodEnum",(e,t)=>{AN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(r,i,s)=>Dh(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Xo({...t,checks:[],...ce(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Xo({...t,checks:[],...ce(i),entries:s})}});function im(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Xo({type:"enum",entries:n,...ce(t)})}const tI=J("ZodLiteral",(e,t)=>{zN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Rh(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 me(e,t){return new tI({type:"literal",values:Array.isArray(e)?e:[e],...ce(t)})}const nI=J("ZodTransform",(e,t)=>{ON.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$h(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new oh(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(si(s,n.value,t));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=e),n.issues.push(si(o))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function rI(e){return new nI({type:"transform",transform:e})}const sm=J("ZodOptional",(e,t)=>{Nh.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qa(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function sc(e){return new sm({type:"optional",innerType:e})}const iI=J("ZodExactOptional",(e,t)=>{PN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qa(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function sI(e){return new iI({type:"optional",innerType:e})}const oI=J("ZodNullable",(e,t)=>{DN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Uh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function oc(e){return new oI({type:"nullable",innerType:e})}const aI=J("ZodDefault",(e,t)=>{RN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lI(e,t){return new aI({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ch(t)}})}const uI=J("ZodPrefault",(e,t)=>{MN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function cI(e,t){return new uI({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ch(t)}})}const om=J("ZodNonOptional",(e,t)=>{$N.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function dI(e,t){return new om({type:"nonoptional",innerType:e,...ce(t)})}const fI=J("ZodCatch",(e,t)=>{LN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pI(e,t){return new fI({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const hI=J("ZodPipe",(e,t)=>{FN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gh(e,n,r,i),e.in=t.in,e.out=t.out});function ac(e,t){return new hI({type:"pipe",in:e,out:t})}const mI=J("ZodReadonly",(e,t)=>{BN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function gI(e){return new mI({type:"readonly",innerType:e})}const xI=J("ZodLazy",(e,t)=>{ZN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kh(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function bI(e){return new xI({type:"lazy",getter:e})}const Ga=J("ZodCustom",(e,t)=>{VN.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Mh(e,n)});function am(e,t){return RE(Ga,e??(()=>!0),t)}function yI(e,t={}){return ME(Ga,e,t)}function vI(e){return $E(e)}function ds(e,t={}){const n=new Ga({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 ai;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(ai||(ai={}));var lc;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(lc||(lc={}));ai.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);ai.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 fs extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof fs))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ai.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()}}fs.create=e=>new fs(e);var uc;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(uc||(uc={}));var we;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(we||(we={}));class cc 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 xo(e){}function wI(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=xo,onError:n=xo,onRetry:r=xo,onComment:i}=e;let s="",o=!0,a,l="",c="";function d(v){const S=o?v.replace(/^\xEF\xBB\xBF/,""):v,[b,j]=kI(`${s}${S}`);for(const m of b)f(m);s=j,o=!1}function f(v){if(v===""){h();return}if(v.startsWith(":")){i&&i(v.slice(v.startsWith(": ")?2:1));return}const S=v.indexOf(":");if(S!==-1){const b=v.slice(0,S),j=v[S+1]===" "?2:1,m=v.slice(S+j);p(b,m,v);return}p(v,"",v)}function p(v,S,b){switch(v){case"event":c=S;break;case"data":l=`${l}${S}
|
|
78
|
+
`;break;case"id":a=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new cc(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:b}));break;default:n(new cc(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:S,line:b}));break}}function h(){l.length>0&&t({id:a,event:c||void 0,data:l.endsWith(`
|
|
79
|
+
`)?l.slice(0,-1):l}),a=void 0,l="",c=""}function g(v={}){s&&v.consume&&f(s),o=!0,a=void 0,l="",c="",s=""}return{feed:d,reset:g}}function kI(e){const t=[];let n="",r=0;for(;r<e.length;){const i=e.indexOf("\r",r),s=e.indexOf(`
|
|
80
|
+
`,r);let o=-1;if(i!==-1&&s!==-1?o=Math.min(i,s):i!==-1?i===e.length-1?o=-1:o=i:s!==-1&&(o=s),o===-1){n=e.slice(r);break}else{const a=e.slice(r,o);t.push(a),r=o+1,e[r-1]==="\r"&&e[r]===`
|
|
81
|
+
`&&r++}}return[t,n]}class SI extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let i;super({start(s){i=wI({onEvent:o=>{s.enqueue(o)},onError(o){t==="terminate"?s.error(o):typeof t=="function"&&t(o)},onRetry:n,onComment:r})},transform(s){i.feed(s)}})}}var bi=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,o=new Array(t);for(let a=0;a<t;a++)o[a]=n[Math.random()*s|0];return o.join("")};if(e==null)return i;if(n.includes(r))throw new D_({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},_I=bi();function Gn(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,r)=>{t[r.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}var jI=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,NI=/"(?: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 dc(e){const t=JSON.parse(e);return t===null||typeof t!="object"||jI.test(e)===!1&&NI.test(e)===!1?t:EI(t)}function EI(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 CI(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return dc(e)}try{return dc(e)}finally{Error.stackTraceLimit=t}}function Ya(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:n}=e;if(n!=null)for(const r of Object.keys(n))n[r]=En(n[r])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(En):En(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(En)),e.allOf!=null&&(e.allOf=e.allOf.map(En)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(En));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=En(t[n]);return e}function En(e){return typeof e=="boolean"?e:Ya(e)}var II=Symbol("Let zodToJsonSchema decide on which parser to use"),fc={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"},TI=e=>typeof e=="string"?{...fc,name:e}:{...fc,...e};function Tt(){return{}}function AI(e,t){var n,r,i;const s={type:"array"};return(n=e.type)!=null&&n._def&&((i=(r=e.type)==null?void 0:r._def)==null?void 0:i.typeName)!==we.ZodAny&&(s.items=Me(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(s.minItems=e.minLength.value),e.maxLength&&(s.maxItems=e.maxLength.value),e.exactLength&&(s.minItems=e.exactLength.value,s.maxItems=e.exactLength.value),s}function zI(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 OI(){return{type:"boolean"}}function lm(e,t){return Me(e.type._def,t)}var PI=(e,t)=>Me(e.innerType._def,t);function um(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>um(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 DI(e)}}var DI=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 RI(e,t){return{...Me(e.innerType._def,t),default:e.defaultValue()}}function MI(e,t){return t.effectStrategy==="input"?Me(e.schema._def,t):Tt()}function $I(e){return{type:"string",enum:Array.from(e.values)}}var LI=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function FI(e,t){const n=[Me(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Me(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(LI(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:o,...a}=i;s=a}r.push(s)}}),r.length?{allOf:r}:void 0}function BI(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 bo=void 0,Dt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(bo===void 0&&(bo=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),bo),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 cm(e,t){const n={type:"string"};if(e.checks)for(const r of e.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(t.emailStrategy){case"format:email":Rt(n,"email",r.message,t);break;case"format:idn-email":Rt(n,"idn-email",r.message,t);break;case"pattern:zod":ct(n,Dt.email,r.message,t);break}break;case"url":Rt(n,"uri",r.message,t);break;case"uuid":Rt(n,"uuid",r.message,t);break;case"regex":ct(n,r.regex,r.message,t);break;case"cuid":ct(n,Dt.cuid,r.message,t);break;case"cuid2":ct(n,Dt.cuid2,r.message,t);break;case"startsWith":ct(n,RegExp(`^${yo(r.value,t)}`),r.message,t);break;case"endsWith":ct(n,RegExp(`${yo(r.value,t)}$`),r.message,t);break;case"datetime":Rt(n,"date-time",r.message,t);break;case"date":Rt(n,"date",r.message,t);break;case"time":Rt(n,"time",r.message,t);break;case"duration":Rt(n,"duration",r.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{ct(n,RegExp(yo(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Rt(n,"ipv4",r.message,t),r.version!=="v4"&&Rt(n,"ipv6",r.message,t);break}case"base64url":ct(n,Dt.base64url,r.message,t);break;case"jwt":ct(n,Dt.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&ct(n,Dt.ipv4Cidr,r.message,t),r.version!=="v4"&&ct(n,Dt.ipv6Cidr,r.message,t);break}case"emoji":ct(n,Dt.emoji(),r.message,t);break;case"ulid":{ct(n,Dt.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Rt(n,"binary",r.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ct(n,Dt.base64,r.message,t);break}}break}case"nanoid":ct(n,Dt.nanoid,r.message,t)}return n}function yo(e,t){return t.patternStrategy==="escape"?VI(e):e}var ZI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function VI(e){let t="";for(let n=0;n<e.length;n++)ZI.has(e[n])||(t+="\\"),t+=e[n];return t}function Rt(e,t,n,r){var i;e.format||(i=e.anyOf)!=null&&i.some(s=>s.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function ct(e,t,n,r){var i;e.pattern||(i=e.allOf)!=null&&i.some(s=>s.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:pc(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=pc(t,r)}function pc(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source;let s="",o=!1,a=!1,l=!1;for(let c=0;c<i.length;c++){if(o){s+=i[c],o=!1;continue}if(r.i){if(a){if(i[c].match(/[a-z]/)){l?(s+=i[c],s+=`${i[c-2]}-${i[c]}`.toUpperCase(),l=!1):i[c+1]==="-"&&((n=i[c+2])!=null&&n.match(/[a-z]/))?(s+=i[c],l=!0):s+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){s+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){s+=`(^|(?<=[\r
|
|
82
|
+
]))`;continue}else if(i[c]==="$"){s+=`($|(?=[\r
|
|
83
|
+
]))`;continue}}if(r.s&&i[c]==="."){s+=a?`${i[c]}\r
|
|
84
|
+
`:`[${i[c]}\r
|
|
85
|
+
]`;continue}s+=i[c],i[c]==="\\"?o=!0:a&&i[c]==="]"?a=!1:!a&&i[c]==="["&&(a=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return s}function dm(e,t){var n,r,i,s,o,a;const l={type:"object",additionalProperties:(n=Me(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((r=e.keyType)==null?void 0:r._def.typeName)===we.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:c,...d}=cm(e.keyType._def,t);return{...l,propertyNames:d}}else{if(((s=e.keyType)==null?void 0:s._def.typeName)===we.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((o=e.keyType)==null?void 0:o._def.typeName)===we.ZodBranded&&e.keyType._def.type._def.typeName===we.ZodString&&((a=e.keyType._def.type._def.checks)!=null&&a.length)){const{type:c,...d}=lm(e.keyType._def,t);return{...l,propertyNames:d}}}return l}function UI(e,t){if(t.mapStrategy==="record")return dm(e,t);const n=Me(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Tt(),r=Me(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Tt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function JI(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 HI(){return{not:Tt()}}function WI(){return{type:"null"}}var Qo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function qI(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(r=>r._def.typeName in Qo&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const o=Qo[s._def.typeName];return o&&!i.includes(o)?[...i,o]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,s)=>{const o=typeof s._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){const i=r.filter((s,o,a)=>a.indexOf(s)===o);return{type:i.length>1?i:i[0],enum:n.reduce((s,o)=>s.includes(o._def.value)?s:[...s,o._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return GI(e,t)}var GI=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((r,i)=>Me(r._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!t.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function YI(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Qo[e.innerType._def.typeName],"null"]};const n=Me(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function KI(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 XI(e,t){const n={type:"object",properties:{}},r=[],i=e.shape();for(const o in i){let a=i[o];if(a===void 0||a._def===void 0)continue;const l=eT(a),c=Me(a._def,{...t,currentPath:[...t.currentPath,"properties",o],propertyPath:[...t.currentPath,"properties",o]});c!==void 0&&(n.properties[o]=c,l||r.push(o))}r.length&&(n.required=r);const s=QI(e,t);return s!==void 0&&(n.additionalProperties=s),n}function QI(e,t){if(e.catchall._def.typeName!=="ZodNever")return Me(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function eT(e){try{return e.isOptional()}catch{return!0}}var tT=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Me(e.innerType._def,t);const r=Me(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Tt()},r]}:Tt()},nT=(e,t)=>{if(t.pipeStrategy==="input")return Me(e.in._def,t);if(t.pipeStrategy==="output")return Me(e.out._def,t);const n=Me(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),r=Me(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function rT(e,t){return Me(e.type._def,t)}function iT(e,t){const r={type:"array",uniqueItems:!0,items:Me(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}function sT(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,r)=>Me(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Me(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,r)=>Me(n._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function oT(){return{not:Tt()}}function aT(){return Tt()}var lT=(e,t)=>Me(e.innerType._def,t),uT=(e,t,n)=>{switch(t){case we.ZodString:return cm(e,n);case we.ZodNumber:return KI(e);case we.ZodObject:return XI(e,n);case we.ZodBigInt:return zI(e);case we.ZodBoolean:return OI();case we.ZodDate:return um(e,n);case we.ZodUndefined:return oT();case we.ZodNull:return WI();case we.ZodArray:return AI(e,n);case we.ZodUnion:case we.ZodDiscriminatedUnion:return qI(e,n);case we.ZodIntersection:return FI(e,n);case we.ZodTuple:return sT(e,n);case we.ZodRecord:return dm(e,n);case we.ZodLiteral:return BI(e);case we.ZodEnum:return $I(e);case we.ZodNativeEnum:return JI(e);case we.ZodNullable:return YI(e,n);case we.ZodOptional:return tT(e,n);case we.ZodMap:return UI(e,n);case we.ZodSet:return iT(e,n);case we.ZodLazy:return()=>e.getter()._def;case we.ZodPromise:return rT(e,n);case we.ZodNaN:case we.ZodNever:return HI();case we.ZodEffects:return MI(e,n);case we.ZodAny:return Tt();case we.ZodUnknown:return aT();case we.ZodDefault:return RI(e,n);case we.ZodBranded:return lm(e,n);case we.ZodReadonly:return lT(e,n);case we.ZodCatch:return PI(e,n);case we.ZodPipeline:return nT(e,n);case we.ZodFunction:case we.ZodVoid:case we.ZodSymbol:return;default:return(r=>{})()}},cT=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function Me(e,t,n=!1){var r;const i=t.seen.get(e);if(t.override){const l=(r=t.override)==null?void 0:r.call(t,e,t,i,n);if(l!==II)return l}if(i&&!n){const l=dT(i,t);if(l!==void 0)return l}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const o=uT(e,e.typeName,t),a=typeof o=="function"?Me(o(),t):o;if(a&&fT(e,t,a),t.postProcess){const l=t.postProcess(a,e,t);return s.jsonSchema=a,l}return s.jsonSchema=a,a}var dT=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:cT(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`),Tt()):t.$refStrategy==="seen"?Tt():void 0}},fT=(e,t,n)=>(e.description&&(n.description=e.description),n),pT=e=>{const t=TI(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}]))}},hT=(e,t)=>{var n;const r=pT(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[d,f])=>{var p;return{...c,[d]:(p=Me(f._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?p:Tt()}},{}):void 0;const s=typeof t=="string"?t:(t==null?void 0:t.nameStrategy)==="title"||t==null?void 0:t.name,o=(n=Me(e._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))!=null?n:Tt(),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(o.title=a);const l=s===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...i,[s]:o}};return l.$schema="http://json-schema.org/draft-07/schema#",l},ea=Symbol.for("vercel.ai.schema");function mT(e){let t;return()=>(t==null&&(t=e()),t)}function $s(e,{validate:t}={}){return{[ea]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function gT(e){return typeof e=="object"&&e!==null&&ea in e&&e[ea]===!0&&"jsonSchema"in e&&"validate"in e}function Ka(e){return e==null?$s({properties:{},additionalProperties:!1}):gT(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?fm(e):xT(e):e()}function xT(e){return $s(()=>Ya(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 gr({value:t,cause:n.issues})}}})}function bT(e,t){var n;const r=(n=void 0)!=null?n:!1;return $s(()=>hT(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 yT(e,t){var n;const r=(n=void 0)!=null?n:!1;return $s(()=>Ya(rC(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const s=await Xh(e,i);return s.success?{success:!0,value:s.data}:{success:!1,error:s.error}}})}function vT(e){return"_zod"in e}function fm(e,t){return vT(e)?yT(e):bT(e)}async function hc({value:e,schema:t,context:n}){const r=await li({value:e,schema:t,context:n});if(!r.success)throw gr.wrap({value:e,cause:r.error,context:n});return r.value}async function li({value:e,schema:t,context:n}){const r=Ka(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:gr.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:gr.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function $n({text:e,schema:t}){try{const n=CI(e);return t==null?{success:!0,value:n,rawValue:n}:await li({value:n,schema:t})}catch(n){return{success:!1,error:Mu.isInstance(n)?n:new Mu({text:e,cause:n}),rawValue:void 0}}}function wT({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new SI).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await $n({text:n,schema:t}))}}))}async function pn(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var kT=Object.defineProperty,ST=(e,t)=>{for(var n in t)kT(e,n,{get:t[n],enumerable:!0})},pm="AI_NoObjectGeneratedError",hm=`vercel.ai.error.${pm}`,_T=Symbol.for(hm),mm,gn=class extends Xt{constructor({message:e="No object generated.",cause:t,text:n,response:r,usage:i,finishReason:s}){super({name:pm,message:e,cause:t}),this[mm]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=s}static isInstance(e){return Xt.hasMarker(e,hm)}};mm=_T;var gm="AI_UIMessageStreamError",xm=`vercel.ai.error.${gm}`,jT=Symbol.for(xm),bm,Yn=class extends Xt{constructor({chunkType:e,chunkId:t,message:n}){super({name:gm,message:n}),this[bm]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return Xt.hasMarker(e,xm)}};bm=jT;var ym=mt([ae(),ds(Uint8Array),ds(ArrayBuffer),am(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),ui=bI(()=>mt([HC(),ae(),ZC(),ft(),oi(ae(),ui.optional()),_r(ui)])),Ce=oi(ae(),oi(ae(),ui.optional())),vm=Le({type:me("text"),text:ae(),providerOptions:Ce.optional()}),NT=Le({type:me("image"),image:mt([ym,ds(URL)]),mediaType:ae().optional(),providerOptions:Ce.optional()}),wm=Le({type:me("file"),data:mt([ym,ds(URL)]),filename:ae().optional(),mediaType:ae(),providerOptions:Ce.optional()}),ET=Le({type:me("reasoning"),text:ae(),providerOptions:Ce.optional()}),CT=Le({type:me("tool-call"),toolCallId:ae(),toolName:ae(),input:qt(),providerOptions:Ce.optional(),providerExecuted:ft().optional()}),IT=KC("type",[Le({type:me("text"),value:ae(),providerOptions:Ce.optional()}),Le({type:me("json"),value:ui,providerOptions:Ce.optional()}),Le({type:me("execution-denied"),reason:ae().optional(),providerOptions:Ce.optional()}),Le({type:me("error-text"),value:ae(),providerOptions:Ce.optional()}),Le({type:me("error-json"),value:ui,providerOptions:Ce.optional()}),Le({type:me("content"),value:_r(mt([Le({type:me("text"),text:ae(),providerOptions:Ce.optional()}),Le({type:me("media"),data:ae(),mediaType:ae()}),Le({type:me("file-data"),data:ae(),mediaType:ae(),filename:ae().optional(),providerOptions:Ce.optional()}),Le({type:me("file-url"),url:ae(),providerOptions:Ce.optional()}),Le({type:me("file-id"),fileId:mt([ae(),oi(ae(),ae())]),providerOptions:Ce.optional()}),Le({type:me("image-data"),data:ae(),mediaType:ae(),providerOptions:Ce.optional()}),Le({type:me("image-url"),url:ae(),providerOptions:Ce.optional()}),Le({type:me("image-file-id"),fileId:mt([ae(),oi(ae(),ae())]),providerOptions:Ce.optional()}),Le({type:me("custom"),providerOptions:Ce.optional()})]))})]),km=Le({type:me("tool-result"),toolCallId:ae(),toolName:ae(),output:IT,providerOptions:Ce.optional()}),TT=Le({type:me("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),AT=Le({type:me("tool-approval-response"),approvalId:ae(),approved:ft(),reason:ae().optional()}),zT=Le({role:me("system"),content:ae(),providerOptions:Ce.optional()}),OT=Le({role:me("user"),content:mt([ae(),_r(mt([vm,NT,wm]))]),providerOptions:Ce.optional()}),PT=Le({role:me("assistant"),content:mt([ae(),_r(mt([vm,wm,ET,CT,km,TT]))]),providerOptions:Ce.optional()}),DT=Le({role:me("tool"),content:_r(mt([km,AT])),providerOptions:Ce.optional()});mt([zT,OT,PT,DT]);function Sm(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const i=t[r];if(i===void 0)continue;const s=r in e?e[r]:void 0,o=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),a=s!=null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp);o&&a?n[r]=Sm(s,i):n[r]=i}return n}var RT={};ST(RT,{array:()=>FT,choice:()=>BT,json:()=>ZT,object:()=>LT,text:()=>$T});function MT(e){const t=["ROOT"];let n=-1,r=null;function i(l,c,d){switch(l){case'"':{n=c,t.pop(),t.push(d),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=c,r=c,t.pop(),t.push(d),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=c,t.pop(),t.push(d),t.push("INSIDE_NUMBER");break}case"{":{n=c,t.pop(),t.push(d),t.push("INSIDE_OBJECT_START");break}case"[":{n=c,t.pop(),t.push(d),t.push("INSIDE_ARRAY_START");break}}}function s(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=c,t.pop();break}}}function o(l,c){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=c,t.pop();break}}}for(let l=0;l<e.length;l++){const c=e[l];switch(t[t.length-1]){case"ROOT":i(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{s(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{n=l,t.pop();break}default:{n=l,i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&s(c,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const f=e.substring(r,l+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?s(c,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&o(c,l)):n=l;break}}}let a=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{a+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{a+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{a+="]";break}case"INSIDE_LITERAL":{const d=e.substring(r,e.length);"true".startsWith(d)?a+="true".slice(d.length):"false".startsWith(d)?a+="false".slice(d.length):"null".startsWith(d)&&(a+="null".slice(d.length))}}return a}async function yi(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await $n({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await $n({text:MT(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var $T=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),LT=({schema:e,name:t,description:n})=>{const r=Ka(e);return{name:"object",responseFormat:pn(r.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},s){const o=await $n({text:i});if(!o.success)throw new gn({message:"No object generated: could not parse the response.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=await li({value:o.value,schema:r});if(!a.success)throw new gn({message:"No object generated: response did not match schema.",cause:a.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});return a.value},async parsePartialOutput({text:i}){const s=await yi(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:s.value}}},createElementStreamTransform(){}}},FT=({element:e,name:t,description:n})=>{const r=Ka(e);return{name:"array",responseFormat:pn(r.jsonSchema).then(i=>{const{$schema:s,...o}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:o}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},s){const o=await $n({text:i});if(!o.success)throw new gn({message:"No object generated: could not parse the response.",cause:o.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});const a=o.value;if(a==null||typeof a!="object"||!("elements"in a)||!Array.isArray(a.elements))throw new gn({message:"No object generated: response did not match schema.",cause:new gr({value:a,cause:"response must be an object with an elements array"}),text:i,response:s.response,usage:s.usage,finishReason:s.finishReason});for(const l of a.elements){const c=await li({value:l,schema:r});if(!c.success)throw new gn({message:"No object generated: response did not match schema.",cause:c.error,text:i,response:s.response,usage:s.usage,finishReason:s.finishReason})}return a.elements},async parsePartialOutput({text:i}){const s=await yi(i);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const o=s.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))return;const a=s.state==="repaired-parse"&&o.elements.length>0?o.elements.slice(0,-1):o.elements,l=[];for(const c of a){const d=await li({value:c,schema:r});d.success&&l.push(d.value)}return{partial:l}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:s},o){if(s!=null)for(;i<s.length;i++)o.enqueue(s[i])}})}}},BT=({options:e,name:t,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},i){const s=await $n({text:r});if(!s.success)throw new gn({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const o=s.value;if(o==null||typeof o!="object"||!("result"in o)||typeof o.result!="string"||!e.includes(o.result))throw new gn({message:"No object generated: response did not match schema.",cause:new gr({value:o,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return o.result},async parsePartialOutput({text:r}){const i=await yi(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=i.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string")return;const o=e.filter(a=>a.startsWith(s.result));return i.state==="successful-parse"?o.includes(s.result)?{partial:s.result}:void 0:o.length===1?{partial:o[0]}:void 0}}},createElementStreamTransform(){}}),ZT=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},r){const i=await $n({text:n});if(!i.success)throw new gn({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value},async parsePartialOutput({text:n}){const r=await yi(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(){}});bi({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
86
|
+
|
|
87
|
+
`)},flush(e){e.enqueue(`data: [DONE]
|
|
88
|
+
|
|
89
|
+
`)}})}});var VT=mT(()=>fm(mt([Ue({type:me("text-start"),id:ae(),providerMetadata:Ce.optional()}),Ue({type:me("text-delta"),id:ae(),delta:ae(),providerMetadata:Ce.optional()}),Ue({type:me("text-end"),id:ae(),providerMetadata:Ce.optional()}),Ue({type:me("error"),errorText:ae()}),Ue({type:me("tool-input-start"),toolCallId:ae(),toolName:ae(),providerExecuted:ft().optional(),providerMetadata:Ce.optional(),dynamic:ft().optional(),title:ae().optional()}),Ue({type:me("tool-input-delta"),toolCallId:ae(),inputTextDelta:ae()}),Ue({type:me("tool-input-available"),toolCallId:ae(),toolName:ae(),input:qt(),providerExecuted:ft().optional(),providerMetadata:Ce.optional(),dynamic:ft().optional(),title:ae().optional()}),Ue({type:me("tool-input-error"),toolCallId:ae(),toolName:ae(),input:qt(),providerExecuted:ft().optional(),providerMetadata:Ce.optional(),dynamic:ft().optional(),errorText:ae(),title:ae().optional()}),Ue({type:me("tool-approval-request"),approvalId:ae(),toolCallId:ae()}),Ue({type:me("tool-output-available"),toolCallId:ae(),output:qt(),providerExecuted:ft().optional(),providerMetadata:Ce.optional(),dynamic:ft().optional(),preliminary:ft().optional()}),Ue({type:me("tool-output-error"),toolCallId:ae(),errorText:ae(),providerExecuted:ft().optional(),providerMetadata:Ce.optional(),dynamic:ft().optional()}),Ue({type:me("tool-output-denied"),toolCallId:ae()}),Ue({type:me("reasoning-start"),id:ae(),providerMetadata:Ce.optional()}),Ue({type:me("reasoning-delta"),id:ae(),delta:ae(),providerMetadata:Ce.optional()}),Ue({type:me("reasoning-end"),id:ae(),providerMetadata:Ce.optional()}),Ue({type:me("source-url"),sourceId:ae(),url:ae(),title:ae().optional(),providerMetadata:Ce.optional()}),Ue({type:me("source-document"),sourceId:ae(),mediaType:ae(),title:ae(),filename:ae().optional(),providerMetadata:Ce.optional()}),Ue({type:me("file"),url:ae(),mediaType:ae(),providerMetadata:Ce.optional()}),Ue({type:am(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:ae().optional(),data:qt(),transient:ft().optional()}),Ue({type:me("start-step")}),Ue({type:me("finish-step")}),Ue({type:me("start"),messageId:ae().optional(),messageMetadata:qt().optional()}),Ue({type:me("finish"),finishReason:im(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:qt().optional()}),Ue({type:me("abort"),reason:ae().optional()}),Ue({type:me("message-metadata"),messageMetadata:qt()})])));function UT(e){return e.type.startsWith("data-")}function ta(e){return e.type.startsWith("tool-")}function JT(e){return e.type==="dynamic-tool"}function ps(e){return ta(e)||JT(e)}function mc(e){return e.type.split("-").slice(1).join("-")}function HT({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 WT({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:s,onData:o}){return e.pipeThrough(new TransformStream({async transform(a,l){await r(async({state:c,write:d})=>{var f,p,h,g;function v(m){const C=c.message.parts.filter(ps).find(w=>w.toolCallId===m);if(C==null)throw new Yn({chunkType:"tool-invocation",chunkId:m,message:`No tool invocation found for tool call ID "${m}".`});return C}function S(m){var T;const C=c.message.parts.find(H=>ta(H)&&H.toolCallId===m.toolCallId),w=m,N=C;if(C!=null){C.state=m.state,N.input=w.input,N.output=w.output,N.errorText=w.errorText,N.rawInput=w.rawInput,N.preliminary=w.preliminary,m.title!==void 0&&(N.title=m.title),N.providerExecuted=(T=w.providerExecuted)!=null?T:C.providerExecuted;const H=w.providerMetadata;if(H!=null)if(m.state==="output-available"||m.state==="output-error"){const O=C;O.resultProviderMetadata=H}else C.callProviderMetadata=H}else c.message.parts.push({type:`tool-${m.toolName}`,toolCallId:m.toolCallId,state:m.state,title:m.title,input:w.input,output:w.output,rawInput:w.rawInput,errorText:w.errorText,providerExecuted:w.providerExecuted,preliminary:w.preliminary,...w.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:w.providerMetadata}:{},...w.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:w.providerMetadata}:{}})}function b(m){var T,C;const w=c.message.parts.find(O=>O.type==="dynamic-tool"&&O.toolCallId===m.toolCallId),N=m,H=w;if(w!=null){w.state=m.state,H.toolName=m.toolName,H.input=N.input,H.output=N.output,H.errorText=N.errorText,H.rawInput=(T=N.rawInput)!=null?T:H.rawInput,H.preliminary=N.preliminary,m.title!==void 0&&(H.title=m.title),H.providerExecuted=(C=N.providerExecuted)!=null?C:w.providerExecuted;const O=N.providerMetadata;if(O!=null)if(m.state==="output-available"||m.state==="output-error"){const _=w;_.resultProviderMetadata=O}else w.callProviderMetadata=O}else c.message.parts.push({type:"dynamic-tool",toolName:m.toolName,toolCallId:m.toolCallId,state:m.state,input:N.input,output:N.output,errorText:N.errorText,preliminary:N.preliminary,providerExecuted:N.providerExecuted,title:m.title,...N.providerMetadata!=null&&(m.state==="output-available"||m.state==="output-error")?{resultProviderMetadata:N.providerMetadata}:{},...N.providerMetadata!=null&&!(m.state==="output-available"||m.state==="output-error")?{callProviderMetadata:N.providerMetadata}:{}})}async function j(m){if(m!=null){const T=c.message.metadata!=null?Sm(c.message.metadata,m):m;t!=null&&await hc({value:T,schema:t,context:{field:"message.metadata",entityId:c.message.id}}),c.message.metadata=T}}switch(a.type){case"text-start":{const m={type:"text",text:"",providerMetadata:a.providerMetadata,state:"streaming"};c.activeTextParts[a.id]=m,c.message.parts.push(m),d();break}case"text-delta":{const m=c.activeTextParts[a.id];if(m==null)throw new Yn({chunkType:"text-delta",chunkId:a.id,message:`Received text-delta for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});m.text+=a.delta,m.providerMetadata=(f=a.providerMetadata)!=null?f:m.providerMetadata,d();break}case"text-end":{const m=c.activeTextParts[a.id];if(m==null)throw new Yn({chunkType:"text-end",chunkId:a.id,message:`Received text-end for missing text part with ID "${a.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});m.state="done",m.providerMetadata=(p=a.providerMetadata)!=null?p:m.providerMetadata,delete c.activeTextParts[a.id],d();break}case"reasoning-start":{const m={type:"reasoning",text:"",providerMetadata:a.providerMetadata,state:"streaming"};c.activeReasoningParts[a.id]=m,c.message.parts.push(m),d();break}case"reasoning-delta":{const m=c.activeReasoningParts[a.id];if(m==null)throw new Yn({chunkType:"reasoning-delta",chunkId:a.id,message:`Received reasoning-delta for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});m.text+=a.delta,m.providerMetadata=(h=a.providerMetadata)!=null?h:m.providerMetadata,d();break}case"reasoning-end":{const m=c.activeReasoningParts[a.id];if(m==null)throw new Yn({chunkType:"reasoning-end",chunkId:a.id,message:`Received reasoning-end for missing reasoning part with ID "${a.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});m.providerMetadata=(g=a.providerMetadata)!=null?g:m.providerMetadata,m.state="done",delete c.activeReasoningParts[a.id],d();break}case"file":{c.message.parts.push({type:"file",mediaType:a.mediaType,url:a.url,...a.providerMetadata!=null?{providerMetadata:a.providerMetadata}:{}}),d();break}case"source-url":{c.message.parts.push({type:"source-url",sourceId:a.sourceId,url:a.url,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"source-document":{c.message.parts.push({type:"source-document",sourceId:a.sourceId,mediaType:a.mediaType,title:a.title,filename:a.filename,providerMetadata:a.providerMetadata}),d();break}case"tool-input-start":{const m=c.message.parts.filter(ta);c.partialToolCalls[a.toolCallId]={text:"",toolName:a.toolName,index:m.length,dynamic:a.dynamic,title:a.title},a.dynamic?b({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}):S({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-streaming",input:void 0,providerExecuted:a.providerExecuted,title:a.title,providerMetadata:a.providerMetadata}),d();break}case"tool-input-delta":{const m=c.partialToolCalls[a.toolCallId];if(m==null)throw new Yn({chunkType:"tool-input-delta",chunkId:a.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${a.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});m.text+=a.inputTextDelta;const{value:T}=await yi(m.text);m.dynamic?b({toolCallId:a.toolCallId,toolName:m.toolName,state:"input-streaming",input:T,title:m.title}):S({toolCallId:a.toolCallId,toolName:m.toolName,state:"input-streaming",input:T,title:m.title}),d();break}case"tool-input-available":{a.dynamic?b({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}):S({toolCallId:a.toolCallId,toolName:a.toolName,state:"input-available",input:a.input,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:a.title}),d(),s&&!a.providerExecuted&&await s({toolCall:a});break}case"tool-input-error":{const m=c.message.parts.filter(ps).find(C=>C.toolCallId===a.toolCallId);(m!=null?m.type==="dynamic-tool":!!a.dynamic)?b({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}):S({toolCallId:a.toolCallId,toolName:a.toolName,state:"output-error",input:void 0,rawInput:a.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata}),d();break}case"tool-approval-request":{const m=v(a.toolCallId);m.state="approval-requested",m.approval={id:a.approvalId},d();break}case"tool-output-denied":{const m=v(a.toolCallId);m.state="output-denied",d();break}case"tool-output-available":{const m=v(a.toolCallId);m.type==="dynamic-tool"?b({toolCallId:a.toolCallId,toolName:m.toolName,state:"output-available",input:m.input,output:a.output,preliminary:a.preliminary,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:m.title}):S({toolCallId:a.toolCallId,toolName:mc(m),state:"output-available",input:m.input,output:a.output,providerExecuted:a.providerExecuted,preliminary:a.preliminary,providerMetadata:a.providerMetadata,title:m.title}),d();break}case"tool-output-error":{const m=v(a.toolCallId);m.type==="dynamic-tool"?b({toolCallId:a.toolCallId,toolName:m.toolName,state:"output-error",input:m.input,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:m.title}):S({toolCallId:a.toolCallId,toolName:mc(m),state:"output-error",input:m.input,rawInput:m.rawInput,errorText:a.errorText,providerExecuted:a.providerExecuted,providerMetadata:a.providerMetadata,title:m.title}),d();break}case"start-step":{c.message.parts.push({type:"step-start"});break}case"finish-step":{c.activeTextParts={},c.activeReasoningParts={};break}case"start":{a.messageId!=null&&(c.message.id=a.messageId),await j(a.messageMetadata),(a.messageId!=null||a.messageMetadata!=null)&&d();break}case"finish":{a.finishReason!=null&&(c.finishReason=a.finishReason),await j(a.messageMetadata),a.messageMetadata!=null&&d();break}case"message-metadata":{await j(a.messageMetadata),a.messageMetadata!=null&&d();break}case"error":{i==null||i(new Error(a.errorText));break}default:if(UT(a)){if((n==null?void 0:n[a.type])!=null){const C=c.message.parts.findIndex(N=>"id"in N&&"data"in N&&N.id===a.id&&N.type===a.type),w=C>=0?C:c.message.parts.length;await hc({value:a.data,schema:n[a.type],context:{field:`message.parts[${w}].data`,entityName:a.type,entityId:a.id}})}const m=a;if(m.transient){o==null||o(m);break}const T=m.id!=null?c.message.parts.find(C=>m.type===C.type&&m.id===C.id):void 0;T!=null?T.data=m.data:c.message.parts.push(m),o==null||o(m),d()}}l.enqueue(a)})}}))}async function qT({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()}}bi({prefix:"aitxt",size:24});bi({prefix:"aiobj",size:24});var GT=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()})}};bi({prefix:"aiobj",size:24});async function YT(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:r}=t,i=await new Promise((s,o)=>{const a=new FileReader;a.onload=l=>{var c;s((c=l.target)==null?void 0:c.result)},a.onerror=l=>o(l),a.readAsDataURL(t)});return{type:"file",mediaType:r,filename:n,url:i}}))}var KT=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:s,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=s,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){var n,r,i,s,o;const a=await pn(this.body),l=await pn(this.headers),c=await pn(this.credentials),d={...Gn(l),...Gn(t.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...a,...t.body},headers:d,credentials:c,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),p=(r=f==null?void 0:f.api)!=null?r:this.api,h=(f==null?void 0:f.headers)!==void 0?Gn(f.headers):d,g=(f==null?void 0:f.body)!==void 0?f.body:{...a,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},v=(i=f==null?void 0:f.credentials)!=null?i:c,b=await((s=this.fetch)!=null?s:globalThis.fetch)(p,{method:"POST",headers:{"Content-Type":"application/json",...h},body:JSON.stringify(g),credentials:v,signal:e});if(!b.ok)throw new Error((o=await b.text())!=null?o:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}async reconnectToStream(e){var t,n,r,i,s;const o=await pn(this.body),a=await pn(this.headers),l=await pn(this.credentials),c={...Gn(a),...Gn(e.headers)},d=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...o,...e.body},headers:c,credentials:l,requestMetadata:e.metadata})),f=(n=d==null?void 0:d.api)!=null?n:`${this.api}/${e.chatId}/stream`,p=(d==null?void 0:d.headers)!==void 0?Gn(d.headers):c,h=(r=d==null?void 0:d.credentials)!=null?r:l,v=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"GET",headers:p,credentials:h});if(v.status===204)return null;if(!v.ok)throw new Error((s=await v.text())!=null?s:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}},_m=class extends KT{constructor(e={}){super(e)}processResponseStream(e){return wT({stream:e,schema:VT}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},XT=class{constructor({generateId:e=_I,id:t=e(),transport:n=new _m,messageMetadataSchema:r,dataPartSchemas:i,state:s,onError:o,onToolCall:a,onFinish:l,onData:c,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new GT,this.sendMessage=async(f,p)=>{var h,g,v,S;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...p});return}let b;if("text"in f||"files"in f?b={parts:[...Array.isArray(f.files)?f.files:await YT(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:b=f,f.messageId!=null){const j=this.state.messages.findIndex(m=>m.id===f.messageId);if(j===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[j].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,j+1),this.state.replaceMessage(j,{...b,id:f.messageId,role:(g=b.role)!=null?g:"user",metadata:f.metadata})}else this.state.pushMessage({...b,id:(v=b.id)!=null?v:this.generateId(),role:(S=b.role)!=null?S:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...p})},this.regenerate=async({messageId:f,...p}={})=>{const h=f==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===f);if(h===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...p})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:f,approved:p,reason:h,options:g})=>this.jobExecutor.run(async()=>{const v=this.state.messages,S=v[v.length-1],b=j=>ps(j)&&j.state==="approval-requested"&&j.approval.id===f?{...j,state:"approval-responded",approval:{id:f,approved:p,reason:h}}:j;this.state.replaceMessage(v.length-1,{...S,parts:S.parts.map(b)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(b)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(j=>{var m;j&&this.makeRequest({trigger:"submit-message",messageId:(m=this.lastMessage)==null?void 0:m.id,...g})})}),this.addToolOutput=async({state:f="output-available",toolCallId:p,output:h,errorText:g,options:v})=>this.jobExecutor.run(async()=>{const S=this.state.messages,b=S[S.length-1],j=m=>ps(m)&&m.toolCallId===p?{...m,state:f,output:h,errorText:g}:m;this.state.replaceMessage(S.length-1,{...b,parts:b.parts.map(j)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(j)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(m=>{var T;m&&this.makeRequest({trigger:"submit-message",messageId:(T=this.lastMessage)==null?void 0:T.id,...v})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=s,this.onError=o,this.onToolCall=a,this.onFinish=l,this.onData=c,this.sendAutomaticallyWhen=d}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var s,o,a;let l;if(e==="resume-stream")try{const h=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(h==null)return;l=h}catch(h){this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h});return}this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let d=!1,f=!1,p=!1;try{const h={state:HT({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=h;let g;e==="resume-stream"?g=l:g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});const v=S=>this.jobExecutor.run(()=>S({state:h.state,write:()=>{var b;this.setStatus({status:"streaming"}),h.state.message.id===((b=this.lastMessage)==null?void 0:b.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await qT({stream:WT({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:S=>{throw S}}),onError:S=>{throw S}}),this.setStatus({status:"ready"})}catch(h){if(d||h.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;p=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(o=this.onFinish)==null||o.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:p,finishReason:(s=this.activeResponse)==null?void 0:s.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}!p&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(a=this.lastMessage)==null?void 0:a.id,metadata:t,headers:n,body:r})}},vo,gc;function QT(){if(gc)return vo;gc=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let r,i=0;return function(...o){clearTimeout(r);const a=Date.now(),l=a-i,c=n-l;c<=0?(i=a,t.apply(this,o)):r=setTimeout(()=>{i=Date.now(),t.apply(this,o)},c)}}return vo=e,vo}var eA=QT();const tA=oa(eA);var jm=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Je=(e,t,n)=>(jm(e,t,"read from private field"),n?n.call(e):t.get(e)),Ht=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},fn=(e,t,n,r)=>(jm(e,t,"write to private field"),t.set(e,n),n);function nA(e,t){return t!=null?tA(e,t):e}var At,Li,Fi,Lr,Fr,Br,er,na,ra,rA=class{constructor(e=[]){Ht(this,At,void 0),Ht(this,Li,"ready"),Ht(this,Fi,void 0),Ht(this,Lr,new Set),Ht(this,Fr,new Set),Ht(this,Br,new Set),this.pushMessage=t=>{fn(this,At,Je(this,At).concat(t)),Je(this,er).call(this)},this.popMessage=()=>{fn(this,At,Je(this,At).slice(0,-1)),Je(this,er).call(this)},this.replaceMessage=(t,n)=>{fn(this,At,[...Je(this,At).slice(0,t),this.snapshot(n),...Je(this,At).slice(t+1)]),Je(this,er).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const r=n?nA(t,n):t;return Je(this,Lr).add(r),()=>{Je(this,Lr).delete(r)}},this["~registerStatusCallback"]=t=>(Je(this,Fr).add(t),()=>{Je(this,Fr).delete(t)}),this["~registerErrorCallback"]=t=>(Je(this,Br).add(t),()=>{Je(this,Br).delete(t)}),Ht(this,er,()=>{Je(this,Lr).forEach(t=>t())}),Ht(this,na,()=>{Je(this,Fr).forEach(t=>t())}),Ht(this,ra,()=>{Je(this,Br).forEach(t=>t())}),fn(this,At,e)}get status(){return Je(this,Li)}set status(e){fn(this,Li,e),Je(this,na).call(this)}get error(){return Je(this,Fi)}set error(e){fn(this,Fi,e),Je(this,ra).call(this)}get messages(){return Je(this,At)}set messages(e){fn(this,At,[...e]),Je(this,er).call(this)}};At=new WeakMap;Li=new WeakMap;Fi=new WeakMap;Lr=new WeakMap;Fr=new WeakMap;Br=new WeakMap;er=new WeakMap;na=new WeakMap;ra=new WeakMap;var tr,xc=class extends XT{constructor({messages:e,...t}){const n=new rA(e);super({...t,state:n}),Ht(this,tr,void 0),this["~registerMessagesCallback"]=(r,i)=>Je(this,tr)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>Je(this,tr)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>Je(this,tr)["~registerErrorCallback"](r),fn(this,tr,n)}};tr=new WeakMap;function iA({experimental_throttle:e,resume:t=!1,...n}={}){const r=x.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:p=>{var h,g;return(g=(h=r.current).onToolCall)==null?void 0:g.call(h,p)},onData:p=>{var h,g;return(g=(h=r.current).onData)==null?void 0:g.call(h,p)},onFinish:p=>{var h,g;return(g=(h=r.current).onFinish)==null?void 0:g.call(h,p)},onError:p=>{var h,g;return(g=(h=r.current).onError)==null?void 0:g.call(h,p)},sendAutomaticallyWhen:p=>{var h,g,v;return(v=(g=(h=r.current).sendAutomaticallyWhen)==null?void 0:g.call(h,p))!=null?v:!1}},s=x.useRef("chat"in n?n.chat:new xc(i));("chat"in n&&n.chat!==s.current||"id"in n&&s.current.id!==n.id)&&(s.current="chat"in n?n.chat:new xc(i));const a=x.useCallback(p=>s.current["~registerMessagesCallback"](p,e),[e,s.current.id]),l=x.useSyncExternalStore(a,()=>s.current.messages,()=>s.current.messages),c=x.useSyncExternalStore(s.current["~registerStatusCallback"],()=>s.current.status,()=>s.current.status),d=x.useSyncExternalStore(s.current["~registerErrorCallback"],()=>s.current.error,()=>s.current.error),f=x.useCallback(p=>{typeof p=="function"&&(p=p(s.current.messages)),s.current.messages=p},[s]);return x.useEffect(()=>{t&&s.current.resumeStream()},[t,s]),{id:s.current.id,messages:l,setMessages:f,sendMessage:s.current.sendMessage,regenerate:s.current.regenerate,clearError:s.current.clearError,stop:s.current.stop,error:d,resumeStream:s.current.resumeStream,status:c,addToolResult:s.current.addToolOutput,addToolOutput:s.current.addToolOutput,addToolApprovalResponse:s.current.addToolApprovalResponse}}function Nm(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 Cm(e,t,n){if(!(n!=null&&n.selectedText)){const i=sA(e,t);if(i)return i}if(n!=null&&n.selectedText){const i=n.selectedText,s=e.indexOf(i);if(s!==-1){const a=e.indexOf(i,s+1);let l;if(a===-1)l=s;else if(n.startLine&&n.startLine>0){const f=dA(e,n.startLine);l=fA(e,i,f)}else l=s;const c=e.slice(0,l),d=e.slice(l+i.length);return{original:e,modified:c+t+d}}if(n.startLine&&n.endLine){const a=uA(e,t,n.startLine,n.endLine);if(a)return a}const o=bc(e,t);return o||{original:e,modified:t}}const r=bc(e,t);return r||{original:e,modified:t}}function sA(e,t){let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!="object"||Array.isArray(n))return null;const r=n.name;if(typeof r!="string"||!r)return null;let i;try{i=JSON.parse(e)}catch{return null}const s=e.match(/\n(\s+)"/),o=s?s[1].length:2;if(!ia(i,r,n))return null;const a=JSON.stringify(i,null,o);return{original:e,modified:a}}function ia(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(ia(i,t,n))return!0}return!1}if(e&&typeof e=="object"){for(const r of Object.values(e))if(ia(r,t,n))return!0}return!1}function bc(e,t){try{const s=JSON.parse(t);if(s&&typeof s=="object"&&!Array.isArray(s))try{const o=JSON.parse(e);if(o&&typeof o=="object"&&!Array.isArray(o)){const a=Object.keys(s).sort().join(","),l=Object.keys(o).sort().join(",");if(a===l)return null}}catch{}}catch{}const n=oA(t);if(n.length===0)return null;let r=e,i=!1;for(const s of n){const o=aA(r,t,s);o&&(r=o,i=!0)}return i?{original:e,modified:r}:null}function oA(e){const t=[],n=e.split(`
|
|
90
|
+
`),r=n.find(s=>s.trim().length>0);if(!r)return t;const i=r.search(/\S/);for(const s of n){const o=s.search(/\S/);if(o<0||o!==i)continue;const a=s.match(/^\s*"([^"]+)"\s*:/);a&&t.push(a[1])}return[...new Set(t)]}function aA(e,t,n){const r=`"${n}"`,i=yc(e,r);if(i.length===0)return null;const s=yc(t,r);if(s.length===0)return null;const o=s[0],a=t.slice(o.start,o.end);let l=0;if(i.length>1){let d=-1;for(let f=0;f<i.length;f++){const p=e.slice(i[f].start,i[f].end),h=cA(p,a);h>d&&(d=h,l=f)}}const c=i[l];return e.slice(0,c.start)+a+e.slice(c.end)}function yc(e,t){const n=[];let r=0;for(;;){const i=e.indexOf(t,r);if(i===-1)break;let s=i-1;for(;s>=0&&(e[s]===" "||e[s]===" ");)s--;const o=s<0?"":e[s];if(o!==""&&o!=="{"&&o!==","&&o!==`
|
|
91
|
+
`&&o!=="\r"){r=i+1;continue}const a=e.indexOf(":",i+t.length);if(a===-1){r=i+1;continue}const l=a+1,c=lA(e,l);if(c===-1){r=i+1;continue}n.push({start:i,end:c}),r=c}return n}function lA(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return-1;const n=e[t];if(n==='"'){let i=t+1;for(;i<e.length;){if(e[i]==="\\"){i+=2;continue}if(e[i]==='"')return i+1;i++}return-1}if(n==="["||n==="{"){const i=n,s=n==="["?"]":"}";let o=1,a=t+1,l=!1;for(;a<e.length&&o>0;){if(e[a]==="\\"&&l){a+=2;continue}e[a]==='"'&&(l=!l),l||(e[a]===i?o++:e[a]===s&&o--),a++}return o===0?a:-1}let r=t;for(;r<e.length&&/[^\s,\]}]/.test(e[r]);)r++;return r>t?r:-1}function uA(e,t,n,r){const i=e.split(`
|
|
92
|
+
`);if(n<1||r<n||n>i.length)return null;const s=i.slice(0,n-1).join(`
|
|
93
|
+
`),o=i.slice(r).join(`
|
|
94
|
+
`),a=s+(s?`
|
|
95
|
+
`:"")+t+(o?`
|
|
96
|
+
`:"")+o;return{original:e,modified:a}}function cA(e,t){if(e===t)return 1;if(!e.length||!t.length)return 0;const n=3,r=new Set;for(let o=0;o<=e.length-n;o++)r.add(e.slice(o,o+n));let i=0;for(let o=0;o<=t.length-n;o++)r.has(t.slice(o,o+n))&&i++;const s=Math.max(e.length-n+1,t.length-n+1);return s>0?i/s:0}function dA(e,t){let n=0;const r=e.split(`
|
|
97
|
+
`);for(let i=0;i<Math.min(t-1,r.length);i++)n+=r[i].length+1;return n}function fA(e,t,n){let r=-1,i=1/0,s=e.indexOf(t);for(;s!==-1;){const o=Math.abs(s-n);o<i&&(i=o,r=s),s=e.indexOf(t,s+1)}return r}function pA(e){const t=e[e.length-1][1];try{return JSON.parse(t),t}catch{}if(e.length>1){const n=e.map(r=>r[1]).join(`
|
|
98
|
+
`);try{return JSON.parse(n),n}catch{}}return null}function hA(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=Nm(r.props.templates||[],i.templates);else return null;return{original:e,modified:JSON.stringify(r,null,2)}}catch{return null}}function mA(){const e=Re(U=>U.threads),t=Re(U=>U.activeThreadId),n=Re(U=>U.updateThreadMessages),r=Re(U=>U.updateThreadTitle),i=Re(U=>U.clearContext),s=Re(U=>U.contextAttachments),o=Re(U=>U.scope),a=Re(U=>U.model),l=Pe(U=>U.activeTab),c=Pe(U=>U.documents),d=Pe(U=>U.documentTypes),f=Pe(U=>U.setPendingDiff),p=Pe(U=>U.createDocument),h=Pe(U=>U.openDocument),g=x.useRef(e);g.current=e;const v=x.useRef(l);v.current=l;const S=x.useRef(c);S.current=c;const b=x.useRef(d);b.current=d;const j=x.useRef(t);j.current=t;const m=l?t[l]:void 0,T=x.useRef(m);T.current=m;const C=x.useRef([]),w=x.useRef([]),N=x.useRef({}),H=x.useRef({}),[,O]=x.useState(0),_=x.useCallback(()=>O(U=>U+1),[]),I=x.useRef(null);I.current||(I.current=new _m({api:"/api/ai/chat"}));const z=x.useCallback(()=>{const U=S.current.find($=>$.name===v.current);return U?{name:U.name,text:U.text}:void 0},[]),M=x.useCallback(U=>N.current[U]||[],[]),A=iA({transport:I.current,onError:()=>{C.current.shift(),w.current.shift(),i()},onFinish:({messages:U})=>{var Z,V;const $=T.current;if($){n($,U);const ie=g.current[$];if(ie&&ie.title.startsWith("Chat ")){const se=U.find(re=>re.role==="user");if(se){const re=((Z=se.parts)==null?void 0:Z.filter(de=>de.type==="text").map(de=>de.text).join(""))||"";if(re){const de=re.length>50?re.slice(0,50)+"...":re;r($,de)}}}}const X=C.current.shift()||[],k=w.current.shift()||"global",oe=U.filter(ie=>ie.role==="user"),G=oe[oe.length-1];G!=null&&G.id&&(N.current[G.id]=X,H.current[G.id]=k);const y=U.filter(ie=>ie.role==="assistant").pop();if(y){const se=[...(((V=y.parts)==null?void 0:V.filter(re=>re.type==="text").map(re=>re.text).join(""))||"").matchAll(/```(?:json|jsonc)\s*\n([\s\S]*?)```/g)];if(se.length>0){const re=pA(se);if(re){const de=se[se.length-1][1],ge=v.current;if(ge){const Ee=S.current.find(ve=>ve.name===ge),ye=(Ee==null?void 0:Ee.text)||"",xe=X[0],W=hA(ye,re,k);!W&&k!=="global"&&console.warn(`[chat] scopedMerge failed for scope="${k}", falling back to text merge`);const{original:Oe,modified:Q}=W??Cm(ye,re,xe);f(ge,Oe,Q,Em(de.replace(/\n$/,"")))}else{const Ee=`ai-generated-${Date.now()}`;p(Ee,re),h(Ee)}}}}i()}});x.useEffect(()=>{const U=A.messages.filter($=>$.role==="user");for(let $=U.length-1;$>=0;$--){const X=U[$].id;if(X in N.current)break;C.current.length>0&&(N.current[X]=C.current[0],H.current[X]=w.current[0]||"global",_());break}},[A.messages,_]);const P=x.useCallback((U,$)=>{C.current.push([...s]),w.current.push(o),i();const X={text:U};$!=null&&$.length&&(X.files=$),A.sendMessage(X,{body:{format:ot,context:s,activeDocument:z(),documentType:v.current&&b.current[v.current]||"application/json+report",scope:o,model:a}})},[A.sendMessage,s,z,i,o,a]),D=x.useCallback(U=>H.current[U],[]);return{messages:A.messages,sendMessage:P,status:A.status,error:A.error,setMessages:A.setMessages,stop:A.stop,getMessageContext:M,getMessageScope:D}}const Im=x.createContext(null);function gA({children:e}){const t=mA();return u.jsx(Im.Provider,{value:t,children:e})}function xA(){const e=x.useContext(Im);if(!e)throw new Error("useChatSessionContext must be used within ChatSessionProvider");return e}function bA(e){try{const t=JSON.parse(e.selectedText);if(t!=null&&t.name)return t.name}catch{}return e.propertyKey?e.propertyKey:e.jsonPath?(e.jsonPath.split(".").pop()??e.jsonPath).replace(/\[\d+\]/g,""):"selection"}function yA(e,t=50){const n=e.replace(/[\n\r]+/g," ").replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t)+"…":n}function Tm({context:e,onRemove:t,variant:n="default"}){var c;const r=bA(e),i=((c=e.documentName)==null?void 0:c.replace(/\.json$/,""))??"",s=i?`${i} › ${r}`:r,o=yA(e.selectedText),a=n==="sent",l=u.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md border pl-2 ${t?"pr-1":"pr-2"} py-1 text-xs max-w-[280px] transition-colors ${a?"border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/20":"border-primary/20 bg-primary/5 hover:bg-primary/10"}`,children:[u.jsx(Hg,{className:`h-3 w-3 shrink-0 ${a?"text-primary-foreground/60":"text-primary/60"}`}),u.jsx("span",{className:"truncate font-medium",children:s}),t&&u.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-sm p-0.5 opacity-60 hover:opacity-100 hover:bg-muted transition-opacity cursor-pointer","aria-label":"Remove context",children:u.jsx(xn,{className:"h-3 w-3"})})]});return u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:l}),u.jsxs(Ye,{side:"top",className:"max-w-xs",children:[u.jsx("p",{className:"text-xs font-medium mb-0.5",children:s}),u.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:o}),e.jsonPath&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1",children:e.jsonPath})]})]})}class Kn extends Error{constructor(t,n){super(`${t} at position ${n}`),this.position=n}}const Am=32,vA=10,zm=9,Om=13,wA=160,kA=6158,SA=8192,_A=8203,jA=8239,NA=8287,EA=12288,CA=65279;function IA(e){return/^[0-9A-Fa-f]$/.test(e)}function Cn(e){return e>="0"&&e<="9"}function TA(e){return e>=" "}function Oi(e){return`,:[]/{}()
|
|
99
|
+
+`.includes(e)}function vc(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function wc(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}const kc=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Sc=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function _c(e){return`,[]/{}
|
|
100
|
+
+`.includes(e)}function jc(e){return Bi(e)||AA.test(e)}const AA=/^[[{\w-]$/;function zA(e){return e===`
|
|
101
|
+
`||e==="\r"||e===" "||e==="\b"||e==="\f"}function In(e,t){const n=e.charCodeAt(t);return n===Am||n===vA||n===zm||n===Om}function OA(e,t){const n=e.charCodeAt(t);return n===Am||n===zm||n===Om}function PA(e,t){const n=e.charCodeAt(t);return n===wA||n===kA||n>=SA&&n<=_A||n===jA||n===NA||n===EA||n===CA}function Bi(e){return Pm(e)||sa(e)}function Pm(e){return e==='"'||e==="“"||e==="”"}function Nc(e){return e==='"'}function sa(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function Ec(e){return e==="'"}function Pr(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const r=e.lastIndexOf(t);return r!==-1?e.substring(0,r)+(n?"":e.substring(r+1)):e}function Mt(e,t){let n=e.length;if(!In(e,n-1))return e+t;for(;In(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function DA(e,t,n){return e.substring(0,t)+e.substring(t+n)}function RA(e){return/[,\n][ \t\r]*$/.test(e)}const MA={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},$A={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" "};function Cc(e){let t=0,n="";c(["```","[```","{```"]),s()||A(),c(["```","```]","```}"]);const i=f(",");for(i&&o(),jc(e[t])&&RA(n)?(i||(n=Mt(n,",")),b()):i&&(n=Pr(n,","));e[t]==="}"||e[t]==="]";)t++,o();if(t>=e.length)return n;M();function s(){o();const $=v()||S()||j()||T()||C()||N(!1)||H();return o(),$}function o(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;const X=t;let k=a($);do k=l(),k&&(k=a($));while(k);return t>X}function a($){const X=$?In:OA;let k="";for(;;)if(X(e,t))k+=e[t],t++;else if(PA(e,t))k+=" ",t++;else break;return k.length>0?(n+=k,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!LA(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
|
|
103
|
+
`;)t++;return!0}return!1}function c($){if(d($)){if(vc(e[t]))for(;t<e.length&&wc(e[t]);)t++;return o(),!0}return!1}function d($){a(!0);for(const X of $){const k=t+X.length;if(e.slice(t,k)===X)return t=k,!0}return!1}function f($){return e[t]===$?(n+=e[t],t++,!0):!1}function p($){return e[t]===$?(t++,!0):!1}function h(){return p("\\")}function g(){return o(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,o(),p(","),!0):!1}function v(){if(e[t]==="{"){n+="{",t++,o(),p(",")&&o();let $=!0;for(;t<e.length&&e[t]!=="}";){let X;if($?(X=!0,$=!1):(X=f(","),X||(n=Mt(n,",")),o()),g(),!(j()||N(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?n=Pr(n,","):P();break}o();const oe=f(":"),G=t>=e.length;oe||(jc(e[t])||G?n=Mt(n,":"):D()),s()||(oe||G?n+="null":D())}return e[t]==="}"?(n+="}",t++):n=Mt(n,"}"),!0}return!1}function S(){if(e[t]==="["){n+="[",t++,o(),p(",")&&o();let $=!0;for(;t<e.length&&e[t]!=="]";)if($?$=!1:f(",")||(n=Mt(n,",")),g(),!s()){n=Pr(n,",");break}return e[t]==="]"?(n+="]",t++):n=Mt(n,"]"),!0}return!1}function b(){let $=!0,X=!0;for(;X;)$?$=!1:f(",")||(n=Mt(n,",")),X=s();X||(n=Pr(n,",")),n=`[
|
|
104
|
+
${n}
|
|
105
|
+
]`}function j(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,k=e[t]==="\\";if(k&&(t++,k=!0),Bi(e[t])){const oe=Nc(e[t])?Nc:Ec(e[t])?Ec:sa(e[t])?sa:Pm,G=t,y=n.length;let Z='"';for(t++;;){if(t>=e.length){const V=O(t-1);return!$&&Oi(e.charAt(V))?(t=G,n=n.substring(0,y),j(!0)):(Z=Mt(Z,'"'),n+=Z,!0)}if(t===X)return Z=Mt(Z,'"'),n+=Z,!0;if(oe(e[t])){const V=t,ie=Z.length;if(Z+='"',t++,n+=Z,o(!1),$||t>=e.length||Oi(e[t])||Bi(e[t])||Cn(e[t]))return m(),!0;const se=O(V-1),re=e.charAt(se);if(re===",")return t=G,n=n.substring(0,y),j(!1,se);if(Oi(re))return t=G,n=n.substring(0,y),j(!0);n=n.substring(0,y),t=V+1,Z=`${Z.substring(0,ie)}\\${Z.substring(ie)}`}else if($&&_c(e[t])){if(e[t-1]===":"&&kc.test(e.substring(G+1,t+2)))for(;t<e.length&&Sc.test(e[t]);)Z+=e[t],t++;return Z=Mt(Z,'"'),n+=Z,m(),!0}else if(e[t]==="\\"){const V=e.charAt(t+1);if($A[V]!==void 0)Z+=e.slice(t,t+2),t+=2;else if(V==="u"){let se=2;for(;se<6&&IA(e[t+se]);)se++;se===6?(Z+=e.slice(t,t+6),t+=6):t+se>=e.length?t=e.length:U()}else Z+=V,t+=2}else{const V=e.charAt(t);V==='"'&&e[t-1]!=="\\"?(Z+=`\\${V}`,t++):zA(V)?(Z+=MA[V],t++):(TA(V)||z(V),Z+=V,t++)}k&&h()}}return!1}function m(){let $=!1;for(o();e[t]==="+";){$=!0,t++,o(),n=Pr(n,'"',!0);const X=n.length;j()?n=DA(n,X,1):n=Mt(n,'"')}return $}function T(){const $=t;if(e[t]==="-"){if(t++,_())return I($),!0;if(!Cn(e[t]))return t=$,!1}for(;Cn(e[t]);)t++;if(e[t]==="."){if(t++,_())return I($),!0;if(!Cn(e[t]))return t=$,!1;for(;Cn(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,_())return I($),!0;if(!Cn(e[t]))return t=$,!1;for(;Cn(e[t]);)t++}if(!_())return t=$,!1;if(t>$){const X=e.slice($,t),k=/^0\d/.test(X);return n+=k?`"${X}"`:X,!0}return!1}function C(){return w("true","true")||w("false","false")||w("null","null")||w("True","true")||w("False","false")||w("None","null")}function w($,X){return e.slice(t,t+$.length)===$?(n+=X,t+=$.length,!0):!1}function N($){const X=t;if(vc(e[t])){for(;t<e.length&&wc(e[t]);)t++;let k=t;for(;In(e,k);)k++;if(e[k]==="(")return t=k+1,s(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!_c(e[t])&&!Bi(e[t])&&(!$||e[t]!==":");)t++;if(e[t-1]===":"&&kc.test(e.substring(X,t+2)))for(;t<e.length&&Sc.test(e[t]);)t++;if(t>X){for(;In(e,t-1)&&t>0;)t--;const k=e.slice(X,t);return n+=k==="undefined"?"null":JSON.stringify(k),e[t]==='"'&&t++,!0}}function H(){if(e[t]==="/"){const $=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,n+=JSON.stringify(e.substring($,t)),!0}}function O($){let X=$;for(;X>0&&In(e,X);)X--;return X}function _(){return t>=e.length||Oi(e[t])||In(e,t)}function I($){n+=`${e.slice($,t)}0`}function z($){throw new Kn(`Invalid character ${JSON.stringify($)}`,t)}function M(){throw new Kn(`Unexpected character ${JSON.stringify(e[t])}`,t)}function A(){throw new Kn("Unexpected end of json string",e.length)}function P(){throw new Kn("Object key expected",t)}function D(){throw new Kn("Colon expected",t)}function U(){const $=e.slice(t,t+6);throw new Kn(`Invalid unicode character "${$}"`,t)}}function LA(e,t){return e[t]==="*"&&e[t+1]==="/"}function FA({json:e,context:t,scope:n}){const[r,i]=x.useState(!1),[s,o]=x.useState(null),a=x.useMemo(()=>{try{return JSON.parse(e),e}catch{}try{return Cc(e)}catch{}const b=`{${e}}`;try{return JSON.parse(b),b}catch{}try{return Cc(b)}catch{return null}},[e]),l=x.useMemo(()=>Em(a||e),[a,e]),c=Pe(b=>b.activeTab),d=Pe(b=>b.documents),f=Pe(b=>(b.acceptedApplyIds||[]).includes(l)),p=Pe(b=>b.setPendingDiff),h=Pe(b=>b.createDocument),g=Pe(b=>b.openDocument),v=x.useCallback(()=>{if(a){o(null);try{if(c){const b=d.find(w=>w.name===c),j=(b==null?void 0:b.text)||"";if(n==="templates")try{const w=JSON.parse(j),N=JSON.parse(a);if(Array.isArray(N.templates)){w.props||(w.props={}),w.props.templates=Nm(w.props.templates||[],N.templates);const H=JSON.stringify(w,null,2);p(c,j,H,l);return}}catch{}const m=t==null?void 0:t[0],{original:T,modified:C}=Cm(j,a,m);p(c,T,C,l)}else{const b=`ai-generated-${Date.now()}`;h(b,a),g(b)}}catch(b){o(b instanceof Error?b.message:"Merge failed")}}},[a,c,d,p,h,g,t,n,l]),S=x.useCallback(async()=>{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},[e]);return u.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2 border-t",children:[u.jsxs("div",{className:"flex gap-1.5",children:[u.jsx(Ne,{variant:"secondary",size:"sm",onClick:v,disabled:f||!a,children:f?"Applied":a?"Apply to Editor":"Invalid JSON"}),u.jsx(Ne,{variant:"ghost",size:"sm",onClick:S,children:r?u.jsx(bn,{className:"h-3.5 w-3.5"}):u.jsx(bs,{className:"h-3.5 w-3.5"})})]}),s&&u.jsx("p",{className:"text-xs text-destructive m-0",children:s})]})}function BA({threads:e,activeThread:t,disabled:n,onSwitch:r,onCreate:i,onDelete:s,onRename:o}){const[a,l]=x.useState(null),[c,d]=x.useState(""),[f,p]=x.useState(null),h=x.useRef(null),g=(t==null?void 0:t.title)||"New Chat",v=g.length>24?g.slice(0,24)+"...":g;x.useEffect(()=>{a&&requestAnimationFrame(()=>{var N;return(N=h.current)==null?void 0:N.focus()})},[a]);const S=x.useCallback((N,H)=>{H.stopPropagation(),H.preventDefault(),l(N.id),d(N.title),p(null)},[]),b=x.useCallback(()=>{a&&c.trim()&&o(a,c.trim()),l(null),d("")},[a,c,o]),j=x.useCallback(()=>{l(null),d("")},[]),m=x.useCallback(N=>{N.stopPropagation(),N.key==="Enter"?(N.preventDefault(),b()):N.key==="Escape"&&(N.preventDefault(),j())},[b,j]),T=x.useCallback((N,H)=>{H.stopPropagation(),H.preventDefault(),p(N),l(null)},[]),C=x.useCallback(N=>{N.stopPropagation(),N.preventDefault(),f&&(s(f),p(null))},[f,s]),w=x.useCallback(N=>{N.stopPropagation(),N.preventDefault(),p(null)},[]);return u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(ks,{onOpenChange:N=>{N||(l(null),p(null))},children:[u.jsx(Ss,{asChild:!0,disabled:n,children:u.jsxs("button",{className:"flex items-center gap-1 text-sm font-semibold tracking-tight hover:text-foreground/80 transition-colors max-w-[180px] cursor-pointer",children:[u.jsx("div",{className:"h-2 w-2 rounded-full bg-primary/70 shrink-0"}),u.jsx("span",{className:"truncate",children:v}),u.jsx(ci,{className:"h-3 w-3 shrink-0 opacity-60"})]})}),u.jsxs(hi,{align:"start",className:"w-64",children:[e.map(N=>{const H=a===N.id;return f===N.id?u.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-sm",children:[u.jsx("span",{className:"text-destructive text-xs flex-1 truncate",children:"Delete this thread?"}),u.jsx("button",{className:"shrink-0 text-destructive hover:text-destructive/80 transition-colors cursor-pointer",onClick:C,children:u.jsx(bn,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:w,children:u.jsx(xn,{className:"h-3.5 w-3.5"})})]},N.id):H?u.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1",onClick:_=>_.stopPropagation(),onPointerDown:_=>_.stopPropagation(),children:[u.jsx("input",{ref:h,type:"text",value:c,onChange:_=>d(_.target.value),onKeyDown:m,onBlur:b,className:"flex-1 min-w-0 text-sm rounded-sm border border-border bg-background px-1.5 py-0.5 outline-none focus:ring-1 focus:ring-primary/40"}),u.jsx("button",{className:"shrink-0 text-primary hover:text-primary/80 transition-colors cursor-pointer",onMouseDown:_=>{_.preventDefault(),b()},children:u.jsx(bn,{className:"h-3.5 w-3.5"})}),u.jsx("button",{className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onMouseDown:_=>{_.preventDefault(),j()},children:u.jsx(xn,{className:"h-3.5 w-3.5"})})]},N.id):u.jsxs(Lt,{onSelect:()=>r(N.id),className:`group ${N.id===(t==null?void 0:t.id)?"bg-accent":""}`,children:[u.jsx("span",{className:"truncate flex-1",children:N.title.length>30?N.title.slice(0,30)+"...":N.title}),u.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[u.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 cursor-pointer",onClick:_=>S(N,_),children:u.jsx(Wg,{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:_=>T(N.id,_),children:u.jsx(la,{className:"h-3 w-3"})})]})]},N.id)}),u.jsx(fr,{}),u.jsxs(Lt,{onSelect:N=>{N.preventDefault();const H=i();H&&(l(H),d(ma()),p(null))},children:[u.jsx(nn,{className:"h-3.5 w-3.5 mr-1.5"}),"New Chat"]})]})]}),u.jsx(Ne,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>i(),disabled:n,title:"New chat thread",children:u.jsx(nn,{className:"h-3.5 w-3.5"})})]})}const Dm=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain","text/markdown","text/csv","text/html"]),ZA=Array.from(Dm).join(","),VA=20*1024*1024,Ic=10;function UA(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 Tc(e){return Array.from(e).filter(t=>Dm.has(t.type)&&t.size<=VA)}function Rm(e){return e.startsWith("image/")}function Ac(){var Y,fe,_e;const e=Re(F=>F.contextAttachments),t=Re(F=>F.addContext),n=Re(F=>F.removeContext),r=Re(F=>F.scope),i=Re(F=>F.setScope),s=Re(F=>F.model),o=Re(F=>F.setModel),a=Re(F=>F.openChat),l=Re(F=>F.closeChat),c=Re(F=>F.threads),d=Re(F=>F.activeThreadId),f=Re(F=>F.createThread),p=Re(F=>F.deleteThread),h=Re(F=>F.switchThread),g=Re(F=>F.updateThreadMessages),v=Re(F=>F.updateThreadTitle),S=Re(F=>F.deleteThreadsForDocument),b=Pe(F=>F.activeTab),j=Pe(F=>F.documents),{messages:m,sendMessage:T,status:C,error:w,setMessages:N,stop:H,getMessageContext:O,getMessageScope:_}=xA(),[I,z]=x.useState(""),[M,A]=x.useState([]),[P,D]=x.useState(!1),[U,$]=x.useState(!1),X=x.useRef(null),k=x.useRef(null),oe=x.useRef(null),G=x.useCallback(async F=>{const pe=Tc(F);if(pe.length===0)return;const Te=await Promise.all(pe.map(UA));A(Be=>{const rt=[...Be,...Te];return rt.length>Ic?rt.slice(0,Ic):rt})},[]),y=x.useCallback(F=>{A(pe=>pe.filter((Te,Be)=>Be!==F))},[]),Z=x.useCallback(F=>{var Te;const pe=(Te=F.clipboardData)==null?void 0:Te.files;if(pe&&pe.length>0){const Be=Tc(pe);Be.length>0&&(F.preventDefault(),G(Be))}},[G]),V=x.useCallback(F=>{var Te;F.preventDefault(),$(!1);const pe=(Te=F.dataTransfer)==null?void 0:Te.files;pe&&pe.length>0&&G(Array.from(pe))},[G]),ie=x.useCallback(F=>{F.preventDefault(),$(!0)},[]),se=x.useCallback(()=>$(!1),[]),re=b?d[b]:void 0,de=re?c[re]:void 0,ge=x.useMemo(()=>b?Object.values(c).filter(F=>F.documentName===b).sort((F,pe)=>pe.updatedAt-F.updatedAt):[],[c,b]);x.useEffect(()=>{b&&ge.length===0&&f(b)},[b,ge.length,f]);const Ee=x.useRef(c);Ee.current=c,x.useEffect(()=>{const F=new Set(j.map(Te=>Te.name)),pe=new Set;for(const Te of Object.values(Ee.current))!F.has(Te.documentName)&&Te.documentName!=="__migrated__"&&pe.add(Te.documentName);for(const Te of pe)S(Te)},[j,S]);const ye=x.useRef(null);x.useEffect(()=>{ye.current!==re&&(ye.current=re,N((de==null?void 0:de.messages)??[]))},[re,de,N]),x.useEffect(()=>{var F;(F=X.current)==null||F.scrollIntoView({behavior:"smooth"})},[m,C]),x.useEffect(()=>{const F=pe=>{var rt;const{documentName:Te,selection:Be}=pe.detail;t({...Be,documentName:Te}),a(),(rt=k.current)==null||rt.focus()};return window.addEventListener("monaco-selection-to-ai",F),()=>window.removeEventListener("monaco-selection-to-ai",F)},[t,a]);const xe=C==="streaming",W=C==="submitted"||xe,Oe=x.useCallback(F=>{F.preventDefault(),!(!I.trim()&&M.length===0||W)&&(T(I,M.length>0?M:void 0),z(""),A([]))},[I,M,W,T]),Q=x.useCallback(F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),Oe(F))},[Oe]),ve=x.useCallback(()=>{m.length!==0&&D(!0)},[m.length]),E=x.useCallback(()=>{D(!1),N([]),re&&(g(re,[]),v(re,ma()))},[N,re,g,v]),[R,L]=x.useState(null),te=x.useCallback(F=>{L(F)},[]),K=x.useCallback(()=>{var rt,tt;if(!R)return;const F=m.findIndex(at=>at.id===R);if(F===-1){L(null);return}const pe=m[F],Te=new Set([F]);pe.role==="user"&&((rt=m[F+1])==null?void 0:rt.role)==="assistant"?Te.add(F+1):pe.role==="assistant"&&F>0&&((tt=m[F-1])==null?void 0:tt.role)==="user"&&Te.add(F-1);const Be=m.filter((at,un)=>!Te.has(un));N(Be),re&&g(re,Be),L(null)},[R,m,N,re,g]),ee=x.useCallback(F=>{if(!W){if(ge.length<=1){ve();return}p(F)}},[W,ge.length,ve,p]),ue=x.useCallback(()=>{if(!(!b||W))return f(b)},[b,W,f]),be=x.useCallback(F=>{W||F===re||h(F)},[W,re,h]),B=x.useCallback((F,pe)=>{v(F,pe)},[v]);return u.jsxs("div",{className:"flex flex-col h-full border-l bg-surface-chat",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/60 bg-surface-chat",children:[u.jsx(BA,{threads:ge,activeThread:de,disabled:W,onSwitch:be,onCreate:ue,onDelete:ee,onRename:B}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ne,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:ve,disabled:W||m.length===0,children:"Clear"}),u.jsx(Ne,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:l,title:"Close chat",children:u.jsx(xn,{className:"h-3.5 w-3.5"})})]})]}),u.jsx(Yr,{className:"flex-1 min-h-0 [&_[data-radix-scroll-area-viewport]>div]:!block",children:u.jsxs("div",{className:"p-3 space-y-4 min-w-0",children:[m.length===0&&u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[u.jsx("div",{className:"rounded-xl bg-primary/10 p-3 mb-4",children:u.jsx(el,{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(Kr,{shortcut:"mod+k"}),u.jsx("span",{className:"text-xs text-muted-foreground",children:"to send a selection"})]})]}),m.map((F,pe)=>{let Te;if(F.role==="user"){const tt=O(F.id);tt&&tt.length>0&&(Te=tt)}else if(F.role==="assistant"){for(let tt=pe-1;tt>=0;tt--)if(m[tt].role==="user"){Te=O(m[tt].id);break}}const Be=xe&&pe===m.length-1&&F.role==="assistant",rt=F.role==="user"?_(F.id):void 0;return u.jsx(JA,{msg:F,isStreaming:Be,context:Te,scope:rt,onDelete:W?void 0:te},F.id)}),W&&((Y=m[m.length-1])==null?void 0:Y.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(jo,{className:"h-3.5 w-3.5 animate-spin text-primary"}),u.jsx("span",{children:"Thinking..."})]})})}),w&&!W&&u.jsx("div",{className:"flex justify-start",children:u.jsx("div",{className:"rounded-lg px-3 py-2 bg-destructive/10 border border-destructive/30 text-destructive text-sm max-w-[90%]",children:w.message||"Something went wrong"})}),u.jsx("div",{ref:X})]})}),u.jsxs("div",{className:`border-t border-border/60 p-2.5 space-y-2 bg-surface-chat transition-colors ${U?"ring-2 ring-primary/40 bg-primary/5":""}`,onDrop:V,onDragOver:ie,onDragLeave:se,children:[e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.map((F,pe)=>u.jsx(Tm,{context:F,onRemove:()=>n(pe)},pe))}),u.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[u.jsx(qA,{model:s,setModel:o}),ot==="pptx"&&b&&u.jsx(YA,{scope:r,setScope:i,docSize:((_e=(fe=j.find(F=>F.name===b))==null?void 0:fe.text)==null?void 0:_e.length)??0})]}),M.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1.5",children:M.map((F,pe)=>u.jsxs("div",{className:"relative group",children:[Rm(F.mediaType)?u.jsx("img",{src:F.url,alt:F.filename||"attachment",className:"h-14 w-14 rounded-md object-cover border border-border/60"}):u.jsxs("div",{className:"h-14 px-2.5 flex items-center gap-1.5 rounded-md border border-border/60 bg-muted/60 max-w-[140px]",children:[u.jsx(No,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),u.jsx("span",{className:"text-xs truncate text-muted-foreground",children:F.filename||"file"})]}),u.jsx("button",{type:"button",onClick:()=>y(pe),className:"absolute -top-1.5 -right-1.5 rounded-full bg-destructive text-destructive-foreground p-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:u.jsx(xn,{className:"h-3 w-3"})})]},pe))}),u.jsxs("form",{onSubmit:Oe,className:"flex items-end gap-2",children:[u.jsx("input",{ref:oe,type:"file",accept:ZA,multiple:!0,className:"hidden",onChange:F=>{F.target.files&&G(Array.from(F.target.files)),F.target.value=""}}),u.jsx(Ne,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 h-9 w-9 rounded-lg text-muted-foreground hover:text-foreground",onClick:()=>{var F;return(F=oe.current)==null?void 0:F.click()},title:"Attach file",children:u.jsx(No,{className:"h-4 w-4"})}),u.jsx("textarea",{ref:k,value:I,onChange:F=>{z(F.target.value);const pe=F.target;pe.style.height="auto",pe.style.height=`${Math.min(pe.scrollHeight,128)}px`},onKeyDown:Q,onPaste:Z,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}),W?u.jsx(Ne,{type:"button",size:"icon",variant:"destructive",className:"shrink-0 h-9 w-9 rounded-lg",onClick:H,title:"Stop generating",children:u.jsx(wd,{className:"h-4 w-4"})}):u.jsx(Ne,{type:"submit",size:"icon",disabled:!I.trim()&&M.length===0,className:"shrink-0 h-9 w-9 rounded-lg",children:u.jsx(el,{className:"h-4 w-4"})})]})]}),u.jsx(Ct,{open:P,onOpenChange:D,children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Clear thread"}),u.jsx(an,{children:"This will delete all messages in this thread. This action cannot be undone."})]}),u.jsxs(yn,{children:[u.jsx(nl,{asChild:!0,children:u.jsx(Ne,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Ne,{variant:"destructive",size:"sm",onClick:E,children:"Clear"})]})]})}),u.jsx(Ct,{open:R!==null,onOpenChange:F=>{F||L(null)},children:u.jsxs(kt,{className:"max-w-sm",children:[u.jsxs(Ut,{children:[u.jsx(Jt,{children:"Delete message"}),u.jsx(an,{children:"This will delete the message and its paired response. This action cannot be undone."})]}),u.jsxs(yn,{children:[u.jsx(nl,{asChild:!0,children:u.jsx(Ne,{variant:"ghost",size:"sm",children:"Cancel"})}),u.jsx(Ne,{variant:"destructive",size:"sm",onClick:K,children:"Delete"})]})]})})]})}const JA=x.memo(function({msg:t,isStreaming:n,context:r,scope:i,onDelete:s}){var l,c;const o=((l=t.parts)==null?void 0:l.filter(d=>d.type==="text").map(d=>d.text).join(""))||"",a=((c=t.parts)==null?void 0:c.filter(d=>d.type==="file"))||[];return u.jsx("div",{className:`group/msg flex ${t.role==="user"?"justify-end":"justify-start"}`,children:u.jsxs("div",{className:`rounded-lg px-3 py-2 max-w-[90%] overflow-hidden min-w-0 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted/60 border border-border/40"}`,children:[t.role==="user"?u.jsxs("div",{children:[a.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:a.map((d,f)=>Rm(d.mediaType)?u.jsx("img",{src:d.url,alt:d.filename||"image",className:"h-20 max-w-[160px] rounded-sm object-cover"},f):u.jsxs("div",{className:"flex items-center gap-1.5 rounded-sm bg-primary-foreground/20 px-2 py-1",children:[u.jsx(No,{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"text-xs truncate max-w-[120px]",children:d.filename||"file"})]},f))}),r&&r.length>0&&u.jsx("div",{className:"flex flex-wrap gap-1 mb-1.5",children:r.map((d,f)=>u.jsx(Tm,{context:d,variant:"sent"},f))}),o&&u.jsx("div",{className:"whitespace-pre-wrap text-sm break-words",children:o}),i&&i!=="global"&&u.jsx("span",{className:"text-[10px] text-primary-foreground/60 mt-0.5 block text-right",children:i})]}):u.jsx(HA,{text:o,isStreaming:n,context:r,scope:i}),s&&!n&&u.jsx("div",{className:"opacity-0 transition-opacity group-hover/msg:opacity-100 focus-within:opacity-100 mt-1",children:u.jsx("button",{type:"button","aria-label":"Delete message",onClick:()=>s(t.id),className:`p-0.5 rounded-sm cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring ${t.role==="user"?"text-primary-foreground/50 hover:text-primary-foreground/80":"text-muted-foreground hover:text-destructive"}`,children:u.jsx(la,{className:"h-3 w-3"})})})]})})},(e,t)=>e.msg.id===t.msg.id&&e.msg===t.msg&&e.isStreaming===t.isStreaming&&e.scope===t.scope&&e.onDelete===t.onDelete&&e.context===t.context);function HA({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(y1,{remarkPlugins:[z_],components:{pre:({children:i})=>u.jsx(u.Fragment,{children:i}),code:({className:i,children:s})=>{const o=i==null?void 0:i.startsWith("language-"),a=(i==null?void 0:i.replace("language-",""))||"",l=String(s).replace(/\n$/,"");if(!o)return u.jsx("code",{className:"rounded-sm bg-muted px-1 py-0.5 text-xs font-mono",children:s});const c=a==="json"||a==="jsonc";return u.jsxs("div",{className:"my-2 rounded-lg border bg-card",children:[u.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/60 border-b text-xs text-muted-foreground",children:[u.jsx("span",{className:"font-mono",children:a||"code"}),!c&&u.jsx(KA,{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(FA,{json:l,context:n,scope:r})]})}},children:e})})}const WA=[{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}];function qA({model:e,setModel:t}){return u.jsxs(qr,{value:e,onValueChange:n=>t(n),children:[u.jsx(cr,{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(Gr,{})}),u.jsx(dr,{children:WA.map(n=>u.jsx(Dn,{value:n.value,className:"text-xs",children:n.label},n.value))})]})}const zc={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"},GA=1e5;function YA({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(zc).map(r=>u.jsxs(qe,{children:[u.jsx(Ge,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>t(r),className:`px-2 py-0.5 rounded-sm text-[10px] cursor-pointer transition-colors ${e===r?"bg-background text-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r})}),u.jsx(Ye,{side:"top",className:"text-xs max-w-[200px]",children:zc[r]})]},r))})]}),e==="global"&&n>GA&&u.jsxs("div",{className:"text-[10px] text-warning flex items-center gap-1",children:[u.jsx(_d,{className:"h-3 w-3 shrink-0"}),u.jsxs("span",{children:["Large doc — switch to"," ",u.jsx("button",{type:"button",onClick:()=>t("slides"),className:"underline cursor-pointer hover:text-warning/80",children:"slides"})," ","or"," ",u.jsx("button",{type:"button",onClick:()=>t("templates"),className:"underline cursor-pointer hover:text-warning/80",children:"templates"})]})]})]})}function KA({text:e}){const[t,n]=x.useState(!1),r=x.useCallback(async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},[e]);return u.jsx("button",{onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:t?"Copied!":"Copy"})}function XA({discoveryData:e}){const t=uf(),n=sb(),r=Re(_=>_.chatOpen),i=Re(_=>_.toggleChat),[s,o]=x.useState(()=>{try{const _=localStorage.getItem("dev-env.sidebar-open");return n?!1:_?_==="true":!0}catch{return!n}}),[a,l]=x.useState(()=>{try{const _=localStorage.getItem("dev-env.preview-open");return _?_==="true":!0}catch{return!0}}),[c,d]=x.useState("editor"),[f,p]=x.useState(!1),h=150,[g,v]=x.useState(!s),[S,b]=x.useState(!1);x.useEffect(()=>{try{localStorage.setItem("dev-env.sidebar-open",String(s))}catch{}},[s]),x.useEffect(()=>{try{localStorage.setItem("dev-env.preview-open",String(a))}catch{}},[a]);const j=x.useRef(n);x.useEffect(()=>{n&&!j.current&&s&&(b(!0),o(!1),setTimeout(()=>{v(!0),b(!1)},h)),!n&&j.current&&!s&&(b(!0),o(!0),setTimeout(()=>{v(!1),b(!1)},h)),j.current=n},[n,s]);const m=x.useCallback(()=>{if(t){p(_=>!_);return}b(!0),o(_=>!_),setTimeout(()=>{v(_=>!_),b(!1)},h)},[t]),T=x.useCallback(()=>l(_=>!_),[]),C=x.useRef(i),w=x.useRef(m),N=x.useRef(T);x.useEffect(()=>{C.current=i}),x.useEffect(()=>{w.current=m}),x.useEffect(()=>{N.current=T}),x.useEffect(()=>{const _=I=>{(I.metaKey||I.ctrlKey)&&(I.code==="KeyB"&&!I.shiftKey&&(I.preventDefault(),w.current()),I.code==="KeyJ"&&I.shiftKey&&(I.preventDefault(),I.stopPropagation(),C.current()),I.code==="KeyP"&&I.shiftKey&&(I.preventDefault(),N.current()))};return window.addEventListener("keydown",_,!0),()=>window.removeEventListener("keydown",_,!0)},[]);const H=gA,O=[{key:"editor",icon:_o,label:"Editor"},{key:"preview",icon:jd,label:"Preview"},{key:"chat",icon:Nd,label:"Chat"}];return t?u.jsx(H,{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(of,{open:f,onOpenChange:p,children:[u.jsx(eb,{asChild:!0,children:u.jsx(Ne,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsx(xa,{side:"left",className:"p-0 w-72",children:u.jsx(_l,{discoveryData:e,onToggleSidebar:()=>p(!1),isCollapsed:!1})})]}),u.jsx("div",{className:"flex gap-0.5 flex-1 min-w-0",children:O.map(({key:_,icon:I,label:z})=>u.jsxs(Ne,{variant:c===_?"default":"ghost",size:"sm",className:"h-7 gap-1.5 text-xs flex-1",onClick:()=>d(_),children:[u.jsx(I,{className:"h-3.5 w-3.5"}),u.jsx("span",{className:"hidden xs:inline",children:z})]},_))})]}),c!=="chat"&&u.jsx(Bl,{previewOpen:a,onTogglePreview:T}),u.jsxs("div",{className:"flex-1 min-h-0",children:[c==="editor"&&u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(jl,{})}),c==="preview"&&u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Nl,{})}),c==="chat"&&u.jsx(Ac,{})]})]})}):u.jsx(H,{children:u.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[u.jsx("div",{className:q("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(_l,{discoveryData:e,onToggleSidebar:m,isCollapsed:g,isAnimating:S})}),u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[u.jsx(Bl,{previewOpen:a,onTogglePreview:T}),u.jsxs(Zy,{direction:"horizontal",autoSaveId:"layout-main",className:"flex-1 min-h-0",children:[u.jsx(Gs,{defaultSize:a?50:100,minSize:20,id:"editor",order:1,children:u.jsx("div",{className:"h-full bg-surface-editor",children:u.jsx(jl,{})})}),a&&u.jsxs(u.Fragment,{children:[u.jsx(Rl,{withHandle:!0}),u.jsx(Gs,{defaultSize:50,minSize:20,id:"preview",order:2,children:u.jsx("div",{className:"h-full bg-surface-preview",children:u.jsx(Nl,{})})})]}),r&&u.jsxs(u.Fragment,{children:[u.jsx(Rl,{withHandle:!0}),u.jsx(Gs,{defaultSize:30,minSize:25,maxSize:50,id:"chat",order:3,children:u.jsx(Ac,{})})]})]})]})]})})}function QA(){const[e,t]=x.useState(null),[n,r]=x.useState(!0),[i,s]=x.useState(null),o=x.useCallback(async()=>{r(!0),s(null);try{const a=await fetch("/api/discovery/all");if(!a.ok)throw new Error(`Discovery failed: ${a.statusText}`);const l=await a.json();if(!l.success)throw new Error(l.error||"Discovery failed");t(l.data)}catch(a){console.error("Discovery error:",a),s(a instanceof Error?a.message:"Failed to fetch discovered items"),t({plugins:[],documents:[],themes:[]})}finally{r(!1)}},[]);return x.useEffect(()=>{o()},[o]),{data:e,loading:n,error:i,refetch:o}}let Pi=null;async function ez(){const e=await fetch("/api/discovery/load-plugins",{method:"POST"});if(!e.ok)throw new Error(`Failed to load plugins: ${e.statusText}`);const t=await e.json();if(!t.success)throw new Error(t.error||"Failed to load plugins");return t.data.loaded}function tz(){const[e,t]=x.useState(!1),[n,r]=x.useState(null),[i,s]=x.useState(0);return{loadPlugins:x.useCallback(async()=>{t(!0),r(null);try{Pi||(Pi=ez().finally(()=>{Pi=null}));const a=await Pi;return s(a),!0}catch(a){return console.error("Plugin loading error:",a),r(a instanceof Error?a.message:"Failed to load plugins"),!1}finally{t(!1)}},[]),loading:e,error:n,loadedCount:i}}function nz(){const{data:e,loading:t,error:n}=QA(),{loadPlugins:r}=tz(),i=Bt(s=>s.applyPluginsWithValidation);return x.useEffect(()=>{e&&e.plugins.length>0&&r().then(s=>{if(s){console.log("Plugins loaded successfully");const o=Bt.getState().selectedPlugins;o.size>0&&(console.log("Auto-applying persisted plugin selections:",Array.from(o)),i())}})},[e,r,i]),t?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium",children:"Discovering project resources..."}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:"Searching for documents, themes, and plugins"})]})}):n?u.jsx("div",{className:"flex items-center justify-center h-screen",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"text-lg font-medium text-destructive",children:"Discovery failed"}),u.jsx("div",{className:"text-sm text-muted-foreground mt-2",children:n}),u.jsx("div",{className:"text-xs text-muted-foreground mt-4",children:"The playground will work with limited functionality."})]})}):u.jsx(Kg,{children:u.jsx(Xg,{children:u.jsx(Qg,{children:u.jsx(ex,{children:u.jsx(tx,{children:u.jsx(Mx,{children:u.jsx(df,{children:u.jsx("section",{className:"flex h-screen w-full flex-col",children:u.jsx("div",{className:"grow overflow-hidden",children:u.jsx(XA,{discoveryData:e})})})})})})})})})})}const fz=Object.freeze(Object.defineProperty({__proto__:null,HomePage:nz},Symbol.toStringTag,{value:"Module"}));export{Kt as B,Ct as D,fz as H,Gy as P,Ur as S,ti as T,Hf as a,sf as b,kt as c,Ut as d,Jt as e,Jy as u};
|
|
106
|
+
//# sourceMappingURL=HomePage-CxftAvxV.js.map
|